phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] ged inc/class.ged_ui.inc.php inc/class.ged_dm.i...


From: Pascal Vilarem
Subject: [Phpgroupware-cvs] ged inc/class.ged_ui.inc.php inc/class.ged_dm.i...
Date: Fri, 23 Mar 2007 16:07:15 +0000

CVSROOT:        /sources/phpgroupware
Module name:    ged
Changes by:     Pascal Vilarem <maat>   07/03/23 16:07:15

Modified files:
        inc            : class.ged_ui.inc.php class.ged_dm.inc.php 
        templates/base : update_file.tpl file.tpl 
Added files:
        templates/base/images: working-16.png 

Log message:
        relations between docs management (beta2)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_ui.inc.php?cvsroot=phpgroupware&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.inc.php?cvsroot=phpgroupware&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/update_file.tpl?cvsroot=phpgroupware&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/file.tpl?cvsroot=phpgroupware&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/images/working-16.png?cvsroot=phpgroupware&rev=1.1

Patches:
Index: inc/class.ged_ui.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_ui.inc.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- inc/class.ged_ui.inc.php    22 Mar 2007 10:43:50 -0000      1.14
+++ inc/class.ged_ui.inc.php    23 Mar 2007 16:07:14 -0000      1.15
@@ -451,8 +451,22 @@
 
                $element_info=$this->ged_dm->get_element_info($element_id);
 
+               $version_id=get_var('version_id',array('GET','POST'));
+               
+               if ( $version_id != '' )
+               {
+                       
$current_version=$this->ged_dm->get_version_info($version_id);
+                       
+                       if ( $current_version['element_id']!=$element_id)
                
$current_version=$this->ged_dm->get_current_or_alert_or_rejected_version($element_id);
 
+               }
+               else
+                       
$current_version=$this->ged_dm->get_current_or_alert_or_rejected_version($element_id);
+               
+               if ( $current_version['element_id']!=$element_id)
+                       
$current_version=$this->ged_dm->get_last_version($element_id);
+
                $list_versions=$this->ged_dm->list_versions($element_id);
                
                
$list_relations=$this->ged_dm->list_version_relations($current_version['version_id']);
@@ -514,6 +528,12 @@
                        $this->t->set_var('version_status_image', 
$GLOBALS['phpgw']->common->image('ged', $version_info['status']."-32"));
 
                        $link_data=null;
+                       $link_data['menuaction']='ged.ged_ui.browse';
+                       $link_data['focused_id']=$element_id;                   
+                       $link_data['version_id']=$version_info['version_id'];
+                       $this->t->set_var('show_version_link', 
$GLOBALS['phpgw']->link('/index.php', $link_data));
+
+                       $link_data=null;
                        $link_data['menuaction']='ged.ged_ui.download';
                        $link_data['version_id']=$version_info['version_id'];
                        $this->t->set_var('download_file_link', 
$GLOBALS['phpgw']->link('/index.php', $link_data));
@@ -1123,6 +1143,11 @@
                        // Based on aproval in progress  
       //$amended_version['status']=$version_status;
       
+      if ( is_array($relations))
+      {
+       $amended_version['relations']=$relations;
+      }
+      
       $amended_version['description']=$version_description;
       $amended_version['version_id']=$version_id;
       
@@ -1173,10 +1198,25 @@
         elseif ( $version_minor !=0 )
           $version_type='minor';
         
+       // Relations management on existing working version
+        
         $this->t->set_var('update_version_action', lang('Update'));
       }
       else
       {
+       // Cetait la
+       
+        $this->t->set_var('update_version_action', lang('New'));
+        $version_type='minor';
+        $version_status='working';
+      
+      }
+
+
+
+
+       // Now c'est là
+       
                        if ( ( $search=="search" || $do_add_relation != '' || 
$do_remove_relation != '' ) && $query != ''  )
                                {
                                        
$search_results=$this->ged_dm->search($query);
@@ -1277,12 +1317,6 @@
                        }                       
                }               
        }
-       
-        $this->t->set_var('update_version_action', lang('New'));
-        $version_type='minor';
-        $version_status='working';
-      
-      }
                }
                                
                $this->t->set_file(array('update_file_tpl'=>'update_file.tpl'));

Index: inc/class.ged_dm.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- inc/class.ged_dm.inc.php    22 Mar 2007 10:43:50 -0000      1.9
+++ inc/class.ged_dm.inc.php    23 Mar 2007 16:07:14 -0000      1.10
@@ -24,7 +24,7 @@
        var $sqlaclchange_acl;
        var $datadir;
 
-       var $tables=Array('comments'=>'ged_comments', 
'elements'=>'ged_elements', 'history'=>'ged_history', 'mimetypes'=>'ged_mimes', 
'acl'=>'ged_acl', 'versions'=>'ged_versions');
+       var $tables=Array('comments'=>'ged_comments', 
'elements'=>'ged_elements', 'history'=>'ged_history', 'mimetypes'=>'ged_mimes', 
'acl'=>'ged_acl', 'versions'=>'ged_versions', 'relations' => 'ged_relations');
 
        function ged_dm()
        {
@@ -401,13 +401,16 @@
        
                                if 
(move_uploaded_file($amended_version['file_tmp_name'], $new_name))
                                {
-       
                                        $download_result='OK';
-       
                                }
                                else
+                               {
+                                       $download_result='';
                                        return "PB download";
                        }
+                       }
+                       else
+                               $download_result='';    
        
                        // MEMO attention que if $new_version['status'] est 
current il faut rendre obsol�te la "vieille"
        
@@ -431,20 +434,55 @@
                        $this->db->query($sql1, __LINE__, __FILE__);
                        $this->db->unlock();
                
+                       // Gestion des relations
+                       if ( is_array($amended_version['relations']))
+                       {
+                               // Enlever les relations en trop
+                               $sql="DELETE FROM 
".$this->tables['relations']." where 
linking_version_id=".$amended_version['version_id']." "; 
+                               $sql.=" AND ( ";
+                               $_and='';
+                               foreach ( $amended_version['relations'] as 
$relation ) 
+                               {
+                                       $sql.=$_and."linked_version_id 
!=".$relation['linked_version_id']." ";
+                                       $_and='AND ';
                }
+                               $sql.=")";
 
-               // New status management system
-               // Based on aproval in progress
+                               $this->db->query($sql, __LINE__, __FILE__);
+                               $this->db->unlock();
                
-               //if ($amended_version['status']=="current")
-               //{
-               //      $sql_model2="UPDATE %s set status='obsolete' WHERE 
version_id=%d";
-               //      $sql2=sprintf($sql_model2, $this->tables['versions'], 
$cur_version['version_id']);
+                               // Mettre à jour les existantes
+                               // Ou insérer les nouvelles
+                               foreach ( $amended_version['relations'] as 
$relation ) 
+                               {
+                                       $sql="SELECT * FROM 
".$this->tables['relations']." ";
+                                       $sql.="WHERE 
linking_version_id=".$amended_version['version_id']." ";
+                                       $sql.="AND 
linked_version_id=".$relation['linked_version_id']." ";
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
+                                       $n_found_rows=$this->db->num_rows();
+                                       $this->db->unlock();
 
-               //      $this->db->query($sql2, __LINE__, __FILE__);
-               //      $this->db->unlock();
+                                       // Si lenombre de lignes trouvées est 
zéro
+                                       // Alors on insère
+                                       if (  $n_found_rows == 0 )
+                                       {
+                                               $sql3="INSERT INTO 
ged_relations ( linked_version_id, linking_version_id, relation_type) values ( 
".$relation['linked_version_id'].",".$amended_version['version_id'].",'".$relation['relation_type']."'
 );";
+                                               $this->db->query($sql3, 
__LINE__, __FILE__);
+                                               $this->db->unlock();
+                                       }
+                                       else
+                                       {
+                                               $sql2="UPDATE 
".$this->tables['relations']." ";
+                                               $sql2.="SET 
relation_type='".$relation['relation_type']."' ";
+                                               $sql2.="WHERE 
linking_version_id=".$amended_version['version_id']." ";
+                                               $sql2.="AND 
linked_version_id=".$relation['linked_version_id']." ";
 
-               //}
+                                               $this->db->query($sql2, 
__LINE__, __FILE__);
+                                               $this->db->unlock();            
                        
+                                       }
+                               }
+                       }
+               }
 
                return "OK";
 

Index: templates/base/update_file.tpl
===================================================================
RCS file: /sources/phpgroupware/ged/templates/base/update_file.tpl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- templates/base/update_file.tpl      22 Mar 2007 10:37:42 -0000      1.5
+++ templates/base/update_file.tpl      23 Mar 2007 16:07:15 -0000      1.6
@@ -1,4 +1,4 @@
-p<table border="0" cellpadding="5" width="100%">
+<table border="0" cellpadding="5" width="100%">
 <tbody>
 <tr>
 <td colspan="2">

Index: templates/base/file.tpl
===================================================================
RCS file: /sources/phpgroupware/ged/templates/base/file.tpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- templates/base/file.tpl     20 Mar 2007 17:49:37 -0000      1.4
+++ templates/base/file.tpl     23 Mar 2007 16:07:15 -0000      1.5
@@ -21,7 +21,7 @@
 <table id="ged_file_versions" cellspacing="0" cellpadding"0">
 <!-- BEGIN versions_list -->
 <tr class="{file_version_status_oe}">
-       <td rowspan="2"><img src="{version_status_image}"/></td>
+       <td rowspan="2"><a href="{show_version_link}#ged_file_relations"><img 
style="{border: none;}" src="{version_status_image}"/></a></td>
        <td ><em>{version}</em></td>
        <td>{version_description}</td>
        <td align="right">

Index: templates/base/images/working-16.png
===================================================================
RCS file: templates/base/images/working-16.png
diff -N templates/base/images/working-16.png
Binary files /dev/null and /tmp/cvsf1yHa2 differ




reply via email to

[Prev in Thread] Current Thread [Next in Thread]