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 class.ged_dm.inc.p...


From: Pascal Vilarem
Subject: [Phpgroupware-cvs] ged/inc class.ged_ui.inc.php class.ged_dm.inc.p...
Date: Thu, 22 Mar 2007 09:19:28 +0000

CVSROOT:        /sources/phpgroupware
Module name:    ged
Changes by:     Pascal Vilarem <maat>   07/03/22 09:19:28

Modified files:
        inc            : class.ged_ui.inc.php class.ged_dm.inc.php 
                         hook_home.inc.php 

Log message:
        relations between docs management (beta)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_ui.inc.php?cvsroot=phpgroupware&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.inc.php?cvsroot=phpgroupware&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/ged/inc/hook_home.inc.php?cvsroot=phpgroupware&r1=1.5&r2=1.6

Patches:
Index: class.ged_ui.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_ui.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- class.ged_ui.inc.php        9 Mar 2007 16:27:10 -0000       1.11
+++ class.ged_ui.inc.php        22 Mar 2007 09:19:28 -0000      1.12
@@ -22,7 +22,7 @@
        var $debug=1;
        var $browser;
 
-       var $public_functions=array('browse'=>true, 'add_file'=>true, 
'add_folder'=>true, 'update_file'=>true, 'update_folder'=>true, 
'delete_folder'=>true, 'download'=>true, 'view'=>true, 'update_file'=>true, 
'delete_file'=>true, 'change_acl'=>true, 'approve_file'=>true );
+       var $public_functions=array('browse'=>true, 'add_file'=>true, 
'add_folder'=>true, 'update_file'=>true, 'update_folder'=>true, 
'delete_folder'=>true, 'download'=>true, 'view'=>true, 'update_file'=>true, 
'delete_file'=>true, 'change_acl'=>true, 'approve_file'=>true, 'submit_file'=> 
true, 'accept_file'=> true, 'deliver_file'=> true, 'reject_file'=> true );
 
        var $icons;
 
@@ -195,6 +195,8 @@
                $this->t->set_var('lang_period', lang('Validity'));
                $this->t->set_var('period_field', 'validity_period');
 
+               $this->t->set_var('relation_label', lang('Relation'));
+
 
                $this->t->set_var('lang_creator', lang('creator'));
                
@@ -449,10 +451,32 @@
 
                $element_info=$this->ged_dm->get_element_info($element_id);
 
-               
$current_version=$this->ged_dm->get_current_version($element_id);
+               
$current_version=$this->ged_dm->get_current_or_alert_or_rejected_version($element_id);
 
                $list_versions=$this->ged_dm->list_versions($element_id);
     
+               
$list_relations=$this->ged_dm->list_version_relations($current_version['version_id']);
+               
+               $this->t->set_block('file_tpl', 'relations_list', 
'relations_list_handle');
+
+               if ($list_relations !="")
+               foreach ($list_relations as $list_relation)
+               {
+                       $this->t->set_var('relation_name', 
$list_relation['name']);
+                       $this->t->set_var('relation_reference', 
$list_relation['reference']);
+                       $this->t->set_var('relation_version', 
$list_relation['major'].".".$list_relation['minor']);
+                       $this->t->set_var('relation_status_value', 
$list_relation['status']);
+                       $this->t->set_var('relation_status_image', 
$GLOBALS['phpgw']->common->image('ged', $list_relation['status']."-32"));
+                       
+                       $link_data=null;
+                       $link_data['menuaction']='ged.ged_ui.browse';
+                       $link_data['focused_id']=$list_relation['element_id'];
+                       $this->t->set_var('relation_link', 
$GLOBALS['phpgw']->link('/index.php', $link_data));
+                       
+                       
+                       $this->t->fp('relations_list_handle', 'relations_list', 
True);
+               }       
+    
                $this->t->set_block('file_tpl', 'versions_list', 
'versions_list_handle');
 
                $versions_numcol=2;
@@ -695,6 +719,8 @@
                                if ( $this->debug('browse') )
                                        print ( "browse: case file<br/>\n");
 
+                               
$last_version=$this->ged_dm->get_last_version($focused_id);
+
                                $this->t->set_var('main_content', 
$this->draw_file_panel($focused_id));
                                $this->t->set_var('add_folder', '');
                                $this->t->set_var('lang_add_folder', '');
@@ -702,7 +728,7 @@
                                $this->t->set_var('lang_add_file', '');
                                
                                // TODO if acl write DONE
-                               if ( $this->ged_dm->can_write($focused_id) )
+                               if ( $this->ged_dm->can_write($focused_id) && ( 
$last_version['status'] == 'working' || $last_version['status'] == 'current' || 
$last_version['status'] == 'rejected' || $last_version['status'] == 'alert' ) )
                                {
                                        $link_data=null;
                                        
$link_data['menuaction']='ged.ged_ui.update_file';
@@ -723,9 +749,19 @@
                                // TODO : Add actions depending on document 
status and user roles
                                // TODO : if can_write and exist working version
                                // TODO : add a "submit" document link 
+                               if ( $this->ged_dm->can_write($focused_id) && 
$last_version['status'] == 'working' )
+                               {
+                                       $link_data=null;
+                                       
$link_data['menuaction']='ged.ged_ui.submit_file';
+                                       $link_data['element_id']=$focused_id;
+                                       
$approve_file_url=$GLOBALS['phpgw']->link('/index.php', $link_data);
+                                       $this->t->set_var('submit_file', "<a 
href=\"".$approve_file_url."\">".lang('Submit file')."</a>");
+                                       
+                               }
+                               
                                
                                // TODO : droit specifique d'approbation ?
-                               if ( $this->ged_dm->can_change_acl($focused_id) 
)
+                               if ( $this->ged_dm->admin && 
($last_version['status'] == 'working' || $last_version['status'] == 
'pending_for_internal_review' || $last_version['status'] == 
'pending_for_approval' )  )
                                {
                                        $link_data=null;
                                        
$link_data['menuaction']='ged.ged_ui.approve_file';
@@ -734,6 +770,35 @@
                                        $this->t->set_var('approve_file', "<a 
href=\"".$approve_file_url."\">".lang('Approve file')."</a>");
                                }
 
+                               if ( $this->ged_dm->admin && 
$last_version['status'] == 'pending_for_internal_review' )
+                               {
+                                       $link_data=null;
+                                       
$link_data['menuaction']='ged.ged_ui.accept_file';
+                                       $link_data['element_id']=$focused_id;
+                                       
$accept_file_url=$GLOBALS['phpgw']->link('/index.php', $link_data);
+                                       $this->t->set_var('accept_file', "<a 
href=\"".$accept_file_url."\">".lang('Accept file')."</a>");
+                               }
+
+                               if ( $this->ged_dm->admin && 
$last_version['status'] == 'ready_for_delivery' )
+                               {
+                                       $link_data=null;
+                                       
$link_data['menuaction']='ged.ged_ui.deliver_file';
+                                       $link_data['element_id']=$focused_id;
+                                       
$accept_file_url=$GLOBALS['phpgw']->link('/index.php', $link_data);
+                                       $this->t->set_var('deliver_file', "<a 
href=\"".$accept_file_url."\">".lang('Deliver file')."</a>");
+                               }
+                               
+                               if ( $this->ged_dm->admin && 
$last_version['status'] == 'pending_for_approval' )
+                               {
+                                       $link_data=null;
+                                       
$link_data['menuaction']='ged.ged_ui.reject_file';
+                                       $link_data['element_id']=$focused_id;
+                                       
$accept_file_url=$GLOBALS['phpgw']->link('/index.php', $link_data);
+                                       $this->t->set_var('reject_file', "<a 
href=\"".$accept_file_url."\">".lang('Reject file')."</a>");
+                               }
+                               
+                               
+
                                // TODO : droit specifique de delete ?
                                if ( $this->ged_dm->admin )
                                {
@@ -941,6 +1006,12 @@
                $version_description=get_var('version_description', 
array('POST', 'GET'));
                $version_type=get_var('version_type', array('POST', 'GET'));
                
+               $search=get_var('search', array('POST', 'GET'));
+               $query=get_var('query', array('POST', 'GET'));
+               $do_add_relation=get_var('do_add_relation', array('POST', 
'GET'));
+               $do_remove_relation=get_var('do_remove_relation', array('POST', 
'GET'));
+               $relations=get_var('relations', array('POST', 'GET'));
+               
                // New status management system
                // Based on aproval in progress
                // Status is the consequency of actions
@@ -949,6 +1020,8 @@
                // for special cases 
                // $version_status=get_var('version_status', array('POST', 
'GET'));
     
+               $relations=get_var('relations', array('POST', 'GET'));
+    
     $version_id=get_var('version_id', array('POST', 'GET'));
                $validity_period=get_var('validity_period', array('POST', 
'GET'));
 
@@ -1010,6 +1083,7 @@
       $new_version['file_tmp_name']=$_FILES['version_file']['tmp_name'];
       $new_version['file_mime_type']=$_FILES['version_file']['type'];
       $new_version['type']=$version_type;
+      $new_version['relations']=$relations;
       
                // New status management system
                        // Based on aproval in progress  
@@ -1100,16 +1174,118 @@
       }
       else
       {
+                       if ( ( $search=="search" || $do_add_relation != '' || 
$do_remove_relation != '' ) && $query != ''  )
+                               {
+                                       
$search_results=$this->ged_dm->search($query);
+                               }
+                               
+                               if ( is_array($relations))
+                               {
+                                       // TODO : Enrichir un peu pour afficher 
plus d'infos'                                   
+                                       $i=0;
+                                       foreach ( $relations as $relation )
+                                       {
+                                               if ( 
$relation['linked_version_id'] != $do_remove_relation || $do_remove_relation == 
'')
+                                               {
+                                                       // TODO : Ajouter le nom
+                                                       
$version_relations[$i]=$this->ged_dm->get_version_info($relation['linked_version_id']);
+                                                       
$version_relations[$i]['linked_version_id']=$relation['linked_version_id'];
+                                                       
$version_relations[$i]['relation_type']=$relation['relation_type'];
+                                                       
+                                                       $i++;                   
                                
+                                               }
+                                       }
+                                       
+                               }
+                               else
+                               {
+                                       
$version_relations=$this->ged_dm->list_version_relations ( 
$last_version['version_id'] );
+                               }
+                               
+                               if ( $do_add_relation != '')
+                               {
+                                       
$version_relations_next_index=sizeof($version_relations)+1;
+                                       
+                                       
$new_version_to_add=$this->ged_dm->get_version_info($do_add_relation);
+                                       
+                                       
$version_relations[$version_relations_next_index]['version_id']=$do_add_relation;
+                                       
$version_relations[$version_relations_next_index]['linked_version_id']=$do_add_relation;
+                                       
$version_relations[$version_relations_next_index]['relation_type']='dependancy';
+                                       
$version_relations[$version_relations_next_index]['element_id']=$new_version_to_add['element_id'];
+                                       
$version_relations[$version_relations_next_index]['name']=$new_version_to_add['name'];
+                                       
$version_relations[$version_relations_next_index]['major']=$new_version_to_add['major'];
+                                       
$version_relations[$version_relations_next_index]['minor']=$new_version_to_add['minor'];
+                                       
$version_relations[$version_relations_next_index]['status']=$new_version_to_add['status'];
+                                       
$version_relations[$version_relations_next_index]['reference']=$new_version_to_add['reference'];
+                               }
+
+       
+       $new_relations=null;
+       $nri=0;
+       if ( is_array($version_relations))
+       {
+               foreach ( $version_relations as $version_relation )
+               {
+                       print ($version_relation['status'] );
+                       
+                       // NIARF
+                       if ( array_key_exists('status', $version_relation) )
+                       {
+                               if ( $version_relation['status']=='obsolete' || 
$version_relation['status']=='rejected' )
+                               {
+                                       print ( 'new version : 
'.$version_relation['version_id']."<br/>\n");
+                                       
+                                       // TODO : prepare data for future 
relation creation
+                                       
$new_relations[$nri]=$this->ged_dm->get_current_version($version_relation['element_id']);
+                                       
+                                       
$new_relations[$nri]['linked_version_id']=$version_relation['version_id'];
+                                       
$new_relations[$nri]['relation_type']='dependancy';
+                                       
+                                       $nri++;                                 
        
+                               }
+                               else
+                               {
+                                       print ( 'report : 
'.$version_relation['version_id']."<br/>\n");
+                                       
+                                       // TODO : prepare data for future 
relation creation
+                                       
$new_relations[$nri]['linked_version_id']=$version_relation['version_id'];
+                                       
$new_relations[$nri]['major']=$version_relation['major'];
+                                       
$new_relations[$nri]['minor']=$version_relation['minor'];
+                                       
$new_relations[$nri]['status']=$version_relation['status'];
+                                       
$new_relations[$nri]['reference']=$version_relation['reference'];
+                                       
$new_relations[$nri]['name']=$version_relation['name'];
+                                       
$new_relations[$nri]['relation_type']='dependancy';
+                                       
+                                       $nri++;                                 
        
+                               }                               
+                       }
+                       else
+                       {
+                               // TODO : prepare data for future relation 
creation
+                               
$new_relations[$nri]['linked_version_id']=$version_relation['version_id'];
+                               
$new_relations[$nri]['major']=$version_relation['major'];
+                               
$new_relations[$nri]['minor']=$version_relation['minor'];
+                               
$new_relations[$nri]['status']=$version_relation['status'];
+                               
$new_relations[$nri]['reference']=$version_relation['reference'];
+                               
$new_relations[$nri]['name']=$version_relation['name'];
+                               
$new_relations[$nri]['relation_type']='dependancy';
+                               
+                               $nri++;                                         
                                
+                       }                       
+               }               
+       }
+       
         $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'));
 
                $this->t->set_var('element_id_value', $element_id);
+               $this->t->set_var('search_query', $query);
     
     /* file */
                $this->t->set_var('file_description_value', $file_description);
@@ -1155,8 +1331,71 @@
         $this->t->set_var('version_type_checked', '');
       
       $this->t->fp('version_type_block_handle', 'version_type_block', True);
+    }
+    
+    $this->t->set_block('update_file_tpl', 'relations_list_block', 
'relations_list_block_handle');
+    
+    if ( isset($new_relations))
+    {
+           if ( is_array($new_relations))
+           {   
+               $nri=0;
+               foreach ($new_relations as $new_relation)
+               {
+                       $this->t->set_var('relations_element_reference', 
$new_relation['reference']);
+                       $this->t->set_var('relations_element_major', 
$new_relation['major']);
+                       $this->t->set_var('relations_element_minor', 
$new_relation['minor']);
+                       $this->t->set_var('relations_element_status_image', 
$GLOBALS['phpgw']->common->image('ged', $new_relation['status']."-16"));
+                       $this->t->set_var('relations_element_name', 
$new_relation['name']);
+                       
+                       $this->t->set_var('relations_id_field', 
'relations['.$nri.'][linked_version_id]');
+                       $this->t->set_var('relations_id_value', 
$new_relation['linked_version_id']);
+                       
+                       $this->t->set_var('relations_type_field', 
'relations['.$nri.'][relation_type]');
+                       $this->t->set_var('relations_type_value', 
$new_relation['relation_type']);
+       
+                       $nri++;
+                       $this->t->fp('relations_list_block_handle', 
'relations_list_block', True);   
+               }
+               
+           }
+    }
+    
            
+               if ( isset($search_results))
+               {
+                       if ( is_array($search_results))
+                       {
+                               $this->t->set_block('update_file_tpl', 
'search_list_block', 'search_list_block_handle');
+                                       
+               //$nri=0;
+               foreach ($search_results as $search_result)
+               {
+                       $this->t->set_var('element_id', 
$search_result['element_id']);
+                       $this->t->set_var('version_id', 
$search_result['version_id']);
+                       $this->t->set_var('name', $search_result['name']);
+                       $this->t->set_var('reference', 
$search_result['reference']);
+                       $this->t->set_var('version', 
"v".$search_result['major'].".".$search_result['minor']);
+                       $this->t->set_var('status', $search_result['status']);
+                       
+                       
+                                       $this->t->set_var('status_image', 
$GLOBALS['phpgw']->common->image('ged', $search_result['status']."-16"));
+                       
+                                       $link_data=null;
+                                       
$link_data['menuaction']='ged.ged_ui.browse';
+                                       
$link_data['focused_id']=$search_result['element_id'];
+                                       $this->t->set_var('search_link', 
$GLOBALS['phpgw']->link('/index.php', $link_data));
+                       
+                               
+                       //$nri++;
+                       $this->t->fp('search_list_block_handle', 
'search_list_block', True);   
+               }                               
     }
+                       else
+                               $this->t->set_block('update_file_tpl', 
'search_list_block', 'search_list_block_handle');
+               }
+               else
+                       $this->t->set_block('update_file_tpl', 
'search_list_block', 'search_list_block_handle');
     
                // New status management system
                // Based on aproval in progress
@@ -1395,8 +1634,8 @@
 
        }
        
-       // TODO : g�rer la confirmation DONE
-       // TODO : Afficher quelques d�tails... nom etc.
+       // TODO : gerer la confirmation DONE
+       // TODO : Afficher quelques details... nom etc.
        function delete_folder()
        {
                $element_id=get_var('element_id', array('GET', 'POST'));
@@ -1627,6 +1866,58 @@
                $GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
        }
        
+       function submit_file()
+       {
+               $element_id=get_var('element_id', array('GET', 'POST'));
+               
+               $this->ged_dm->submit_file ( $element_id );
+
+               $link_data=null;
+               $link_data['menuaction']='ged.ged_ui.browse';
+               $link_data['focused_id']=$element_id;
+       
+               $GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
+       }
+
+       function accept_file()
+       {
+               $element_id=get_var('element_id', array('GET', 'POST'));
+               
+               $this->ged_dm->accept_file ( $element_id );
+
+               $link_data=null;
+               $link_data['menuaction']='ged.ged_ui.browse';
+               $link_data['focused_id']=$element_id;
+       
+               $GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
+       }
+
+       function deliver_file()
+       {
+               $element_id=get_var('element_id', array('GET', 'POST'));
+               
+               $this->ged_dm->deliver_file ( $element_id );
+
+               $link_data=null;
+               $link_data['menuaction']='ged.ged_ui.browse';
+               $link_data['focused_id']=$element_id;
+       
+               $GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
+       }
+
+       function reject_file()
+       {
+               $element_id=get_var('element_id', array('GET', 'POST'));
+               
+               $this->ged_dm->reject_file ( $element_id );
+
+               $link_data=null;
+               $link_data['menuaction']='ged.ged_ui.browse';
+               $link_data['focused_id']=$element_id;
+       
+               $GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
+       }
+
 }
 
 ?>

Index: class.ged_dm.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- class.ged_dm.inc.php        8 Mar 2007 22:24:46 -0000       1.7
+++ class.ged_dm.inc.php        22 Mar 2007 09:19:28 -0000      1.8
@@ -261,10 +261,13 @@
 
                // MEMO gestion des numeros de versions
 
-               
$cur_version=$this->get_current_version($new_version['element_id']);
-               $major=$cur_version['major'];
-               $minor=$cur_version['minor'];
+               
$current_or_alert_or_rejected_version=$this->get_current_or_alert_or_rejected_version($new_version['element_id']);
+               $major=$current_or_alert_or_rejected_version['major'];
+               $minor=$current_or_alert_or_rejected_version['minor'];
+               
$last_version=$this->get_last_version($new_version['element_id']);
 
+               if ($last_version['status'] == 'current' || 
$last_version['status'] == 'rejected' || $last_version['status'] == 'alert' )
+               {
                if ($new_version['type']=='major')
                {
                        $major ++;
@@ -313,14 +316,28 @@
                        //print ("<br/>".$sql1);
 
                        $this->db->query($sql1, __LINE__, __FILE__);
+                               
+                               
$my_new_version_id=$new_element_id=$this->db->get_last_insert_id($this->tables['versions'],
 'version_id');
+                               
                        $this->db->unlock();
 
                }
     
-    if ($new_version['status']=="current")
+                       // AJOUT des relations
+                       if ( is_array($new_version['relations']))
+                       {
+                               foreach ( $new_version['relations'] as 
$relation )
+                               {
+                                       $sql3="INSERT INTO ged_relations ( 
linked_version_id, linking_version_id, relation_type) values ( 
".$relation['linked_version_id'].",".$my_new_version_id.",'".$relation['relation_type']."'
 );";
+                                       $this->db->query($sql3, __LINE__, 
__FILE__);
+                                       $this->db->unlock();
+                               }
+                       }
+           
+           if ($new_version['status']=="current" && 
$current_or_alert_or_rejected_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']);
+             $sql2=sprintf($sql_model2, $this->tables['versions'], 
$current_or_alert_or_rejected_version['version_id']);
 
       $this->db->query($sql2, __LINE__, __FILE__);
       $this->db->unlock();
@@ -331,6 +348,7 @@
                        print ( "add_version: end.<br>\n");
 
                return "OK";
+               }
 
        }
 
@@ -342,6 +360,8 @@
                
$cur_version=$this->get_current_version($amended_version['element_id']);
                
$me_version=$this->get_version_info($amended_version['version_id']);
 
+               if (  $me_version['status']=='working' )
+               {
                $major=$cur_version['major'];
                $minor=$cur_version['minor'];
 
@@ -411,6 +431,8 @@
                $this->db->query($sql1, __LINE__, __FILE__);
                $this->db->unlock();
 
+               }
+
                // New status management system
                // Based on aproval in progress
                
@@ -489,8 +511,10 @@
 
        function get_version_info($version_id)
        {
-               $sql="SELECT * FROM ".$this->tables['versions']." ";
-               $sql.="WHERE version_id=".$version_id." ";
+               $sql="SELECT ".$this->tables['versions'].".*, 
".$this->tables['elements'].".name, ".$this->tables['elements'].".reference 
FROM ".$this->tables['versions']." ";
+               $sql.="INNER JOIN ".$this->tables['elements']." ON ";
+               $sql.=" ".$this->tables['elements'].".element_id = 
".$this->tables['versions'].".element_id "; 
+               $sql.="WHERE 
".$this->tables['versions'].".version_id=".$version_id." ";
 
                $this->db->query($sql, __LINE__, __FILE__);
 
@@ -510,6 +534,8 @@
                        $version['file_name']=$this->db->f('file_name');
                        $version['stored_name']=$this->db->f('stored_name');
                        $version['major']=$this->db->f('major');
+                       $version['name']=$this->db->f('name');
+                       $version['reference']=$this->db->f('reference');
                        
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
                }
 
@@ -612,6 +638,248 @@
                return $version;
        }
 
+       function get_current_or_alert_or_rejected_version($element_id)
+       {
+               if ( $this->debug('get_current_or_alert_or_rejected_version') )
+                       print ( "get_current_or_alert_or_rejected_version: 
entering with element_id=".$element_id."<br>\n");
+               
+               $sql="SELECT * FROM ".$this->tables['versions']." ";
+               $sql.="WHERE element_id=".$element_id." ";
+               $sql.="AND ( status='current' OR status='alert' OR 
status='rejected' ) ";
+               $sql.="ORDER BY version_id DESC LIMIT 1";
+
+               if ( $this->debug('get_current_or_alert_or_rejected_version') )
+                       print ( "get_current_or_alert_or_rejected_version: 
".$sql."<br>\n");
+
+               //print ("<pre>");
+               //print_r($this->db->metadata( $this->tables['versions'] ));
+               //print ("</pre>");
+               
+               
+               $this->db->query($sql, __LINE__, __FILE__);
+
+               if ($this->db->next_record());
+               {
+                       
+                       
$version['validation_date']=$this->db->f('validation_date');
+                       $version['url']=$this->db->f('url');
+                       $version['size']=$this->db->f('size');
+                       $version['status']=$this->db->f('status');
+                       $version['creator_id']=$this->db->f('creator_id');
+                       $version['creation_date']=$this->db->f('creation_date');
+                       $version['minor']=$this->db->f('minor');
+                       $version['version_id']=$this->db->f('version_id');
+                       $version['element_id']=$this->db->f('element_id');
+                       $version['description']=$this->db->f('description');
+                       
$version['file_extension']=$this->db->f('file_extension');
+                       $version['file_name']=$this->db->f('file_name');
+                       $version['stored_name']=$this->db->f('stored_name');
+                       $version['major']=$this->db->f('major');
+                       
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
+                       
+                       
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+                       
+               }
+
+               $this->db->unlock();
+                               
+               return $version;
+       }
+       
+       function get_working_version($element_id)
+       {
+               if ( $this->debug('get_working_version') )
+                       print ( "get_working_version: entering with 
element_id=".$element_id."<br>\n");
+               
+               $sql="SELECT * FROM ".$this->tables['versions']." ";
+               $sql.="WHERE element_id=".$element_id." ";
+               $sql.="AND ( status='working' )";
+               $sql.="ORDER BY version_id DESC LIMIT 1";
+
+               if ( $this->debug('get_working_version') )
+                       print ( "get_working_version: ".$sql."<br>\n");
+
+               //print ("<pre>");
+               //print_r($this->db->metadata( $this->tables['versions'] ));
+               //print ("</pre>");
+               
+               
+               $this->db->query($sql, __LINE__, __FILE__);
+
+               if ($this->db->next_record());
+               {
+                       
+                       
$version['validation_date']=$this->db->f('validation_date');
+                       $version['url']=$this->db->f('url');
+                       $version['size']=$this->db->f('size');
+                       $version['status']=$this->db->f('status');
+                       $version['creator_id']=$this->db->f('creator_id');
+                       $version['creation_date']=$this->db->f('creation_date');
+                       $version['minor']=$this->db->f('minor');
+                       $version['version_id']=$this->db->f('version_id');
+                       $version['element_id']=$this->db->f('element_id');
+                       $version['description']=$this->db->f('description');
+                       
$version['file_extension']=$this->db->f('file_extension');
+                       $version['file_name']=$this->db->f('file_name');
+                       $version['stored_name']=$this->db->f('stored_name');
+                       $version['major']=$this->db->f('major');
+                       
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
+                       
+                       
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+                       
+               }
+
+               $this->db->unlock();
+                               
+               return $version;
+       }
+
+
+       function get_pending_for_internal_review ($element_id)
+       {
+               if ( $this->debug('get_pending_for_internal_review') )
+                       print ( "get_pending_for_internal_review: entering with 
element_id=".$element_id."<br>\n");
+               
+               $sql="SELECT * FROM ".$this->tables['versions']." ";
+               $sql.="WHERE element_id=".$element_id." ";
+               $sql.="AND ( status='pending_for_internal_review' )";
+               $sql.="ORDER BY version_id DESC LIMIT 1";
+
+               if ( $this->debug('get_pending_for_internal_review') )
+                       print ( "get_pending_for_internal_review: 
".$sql."<br>\n");
+
+               //print ("<pre>");
+               //print_r($this->db->metadata( $this->tables['versions'] ));
+               //print ("</pre>");
+               
+               
+               $this->db->query($sql, __LINE__, __FILE__);
+
+               if ($this->db->next_record());
+               {
+                       
+                       
$version['validation_date']=$this->db->f('validation_date');
+                       $version['url']=$this->db->f('url');
+                       $version['size']=$this->db->f('size');
+                       $version['status']=$this->db->f('status');
+                       $version['creator_id']=$this->db->f('creator_id');
+                       $version['creation_date']=$this->db->f('creation_date');
+                       $version['minor']=$this->db->f('minor');
+                       $version['version_id']=$this->db->f('version_id');
+                       $version['element_id']=$this->db->f('element_id');
+                       $version['description']=$this->db->f('description');
+                       
$version['file_extension']=$this->db->f('file_extension');
+                       $version['file_name']=$this->db->f('file_name');
+                       $version['stored_name']=$this->db->f('stored_name');
+                       $version['major']=$this->db->f('major');
+                       
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
+                       
+                       
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+                       
+               }
+
+               $this->db->unlock();
+                               
+               return $version;
+       }
+
+       function get_ready_for_delivery ($element_id)
+       {
+               if ( $this->debug('get_ready_for_delivery') )
+                       print ( "get_ready_for_delivery: entering with 
element_id=".$element_id."<br>\n");
+               
+               $sql="SELECT * FROM ".$this->tables['versions']." ";
+               $sql.="WHERE element_id=".$element_id." ";
+               $sql.="AND ( status='ready_for_delivery' )";
+               $sql.="ORDER BY version_id DESC LIMIT 1";
+
+               if ( $this->debug('get_ready_for_delivery') )
+                       print ( "get_ready_for_delivery: ".$sql."<br>\n");
+
+               //print ("<pre>");
+               //print_r($this->db->metadata( $this->tables['versions'] ));
+               //print ("</pre>");
+               
+               
+               $this->db->query($sql, __LINE__, __FILE__);
+
+               if ($this->db->next_record());
+               {
+                       
+                       
$version['validation_date']=$this->db->f('validation_date');
+                       $version['url']=$this->db->f('url');
+                       $version['size']=$this->db->f('size');
+                       $version['status']=$this->db->f('status');
+                       $version['creator_id']=$this->db->f('creator_id');
+                       $version['creation_date']=$this->db->f('creation_date');
+                       $version['minor']=$this->db->f('minor');
+                       $version['version_id']=$this->db->f('version_id');
+                       $version['element_id']=$this->db->f('element_id');
+                       $version['description']=$this->db->f('description');
+                       
$version['file_extension']=$this->db->f('file_extension');
+                       $version['file_name']=$this->db->f('file_name');
+                       $version['stored_name']=$this->db->f('stored_name');
+                       $version['major']=$this->db->f('major');
+                       
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
+                       
+                       
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+                       
+               }
+
+               $this->db->unlock();
+                               
+               return $version;
+       }
+
+
+       function get_pending_for_approval ($element_id)
+       {
+               if ( $this->debug('get_pending_for_approval') )
+                       print ( "get_pending_for_approval: entering with 
element_id=".$element_id."<br>\n");
+               
+               $sql="SELECT * FROM ".$this->tables['versions']." ";
+               $sql.="WHERE element_id=".$element_id." ";
+               $sql.="AND ( status='pending_for_approval' )";
+               $sql.="ORDER BY version_id DESC LIMIT 1";
+
+               if ( $this->debug('get_pending_for_approval') )
+                       print ( "get_pending_for_approval: ".$sql."<br>\n");
+
+               //print ("<pre>");
+               //print_r($this->db->metadata( $this->tables['versions'] ));
+               //print ("</pre>");
+               
+               
+               $this->db->query($sql, __LINE__, __FILE__);
+
+               if ($this->db->next_record());
+               {
+                       
+                       
$version['validation_date']=$this->db->f('validation_date');
+                       $version['url']=$this->db->f('url');
+                       $version['size']=$this->db->f('size');
+                       $version['status']=$this->db->f('status');
+                       $version['creator_id']=$this->db->f('creator_id');
+                       $version['creation_date']=$this->db->f('creation_date');
+                       $version['minor']=$this->db->f('minor');
+                       $version['version_id']=$this->db->f('version_id');
+                       $version['element_id']=$this->db->f('element_id');
+                       $version['description']=$this->db->f('description');
+                       
$version['file_extension']=$this->db->f('file_extension');
+                       $version['file_name']=$this->db->f('file_name');
+                       $version['stored_name']=$this->db->f('stored_name');
+                       $version['major']=$this->db->f('major');
+                       
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
+                       
+                       
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+                       
+               }
+
+               $this->db->unlock();
+                               
+               return $version;
+       }
+
        function get_working_or_pending_version($element_id)
        {
                if ( $this->debug('get_working_version') )
@@ -619,7 +887,7 @@
                
                $sql="SELECT * FROM ".$this->tables['versions']." ";
                $sql.="WHERE element_id=".$element_id." ";
-               $sql.="AND ( status='working' OR status='pending' )";
+               $sql.="AND ( status='working' OR 
status='pending_for_internal_review' OR status='pending_for_approval' )";
                $sql.="ORDER BY version_id DESC LIMIT 1";
 
                if ( $this->debug('get_working_version') )
@@ -1327,7 +1595,7 @@
        // User must have approval rights on this document
        function approve_file ( $element_id )
        {
-                       
$current_version=$this->get_current_version($element_id);
+                       
$current_or_alert_or_rejected_version=$this->get_current_or_alert_or_rejected_version($element_id);
                        
$working_or_pending_version=$this->get_working_or_pending_version($element_id);
                        
                        // Need to check if there is a working version
@@ -1336,12 +1604,23 @@
                                if ($working_or_pending_version['version_id'] )
                                {
                                        // If there is a previous "current" 
make it obsolete
-                                       if (is_array($current_version) )
+                                       if 
(is_array($current_or_alert_or_rejected_version) )
                                        {
-                                               if 
($current_version['version_id'] )
+                                               if 
($current_or_alert_or_rejected_version['version_id'] )
                                                {
-                                                       $sql="UPDATE 
ged_versions set status='obsolete' WHERE 
version_id=".$current_version['version_id'];                      
+                                                       $sql="UPDATE 
ged_versions set status='obsolete' WHERE 
version_id=".$current_or_alert_or_rejected_version['version_id'];               
  
                                                        $this->db->query($sql, 
__LINE__, __FILE__);
+                                                       
+                                                       // TODO : Set status of 
depending documents to alert
+                                                       
$versions_referring_to=$this->list_versions_referring_to($current_or_alert_or_rejected_version['version_id']);
+                                                       
+                                                       if ( 
is_array($versions_referring_to))
+                                                       {
+                                                               foreach ( 
$versions_referring_to as $version_referring_to)
+                                                               {
+                                                                       
$this->alert_version ($version_referring_to['version_id']);
+                                                               }
+                                                       }
                                                }
                                        }
                                        $sql="UPDATE ged_versions set 
status='current', validation_date=".time()." WHERE 
version_id=".$working_or_pending_version['version_id'];                        
@@ -1352,19 +1631,31 @@
                        $this->db->unlock();
        }
 
+       function alert_version ( $version_id )
+       {
+               $sql="UPDATE ged_versions set status='alert' WHERE 
version_id=".$version_id." AND status='current'";            
+               $this->db->query($sql, __LINE__, __FILE__);
+               
+               // TODO : recursivite
+                                               
+               $this->db->unlock();
+       }
+
        // Say file is not valid
        // A new version must be worked on and delivered
        // User must have approval rights on this document
        function reject_file ( $element_id, $reason="Default reason" )
        {
-                       
$working_or_pending_version=$this->get_working_or_pending_version($element_id);
+                       
$pending_version=$this->get_pending_for_approval($element_id);
                        
-                       // Need to check if there is a wrking version
-                       if (is_array($working_or_pending_version) )
+                       // Need to check if there is a working version
+                       if (is_array($pending_version) )
                        {
-                               if ($working_or_pending_version['version_id'] )
+                               if ($pending_version['version_id'] )
                                {
-                                       $sql="UPDATE ged_versions set 
status='rejected', validation_date=".time()." WHERE 
version_id=".$working_or_pending_version['version_id'];                       
+                                       // Set "pending_for_internal_review" 
status
+                                       // TODO : Add submission date
+                                       $sql="UPDATE ged_versions set 
status='rejected' WHERE version_id=".$pending_version['version_id'];            
          
                                        $this->db->query($sql, __LINE__, 
__FILE__);
                                }
                        }
@@ -1373,10 +1664,26 @@
        }
 
        // Submit file to customer for approval
+
        // After a contractual timeout the file is
        // considered approved
-       function deliver_file ( $element_id, $timeout=30 )
+       function deliver_file ( $element_id )
+       {
+                       
$pending_version=$this->get_ready_for_delivery($element_id);
+                       
+                       // Need to check if there is a working version
+                       if (is_array($pending_version) )
+                       {
+                               if ($pending_version['version_id'] )
        {
+                                       // Set "pending_for_internal_review" 
status
+                                       // TODO : Add submission date
+                                       $sql="UPDATE ged_versions set 
status='pending_for_approval' WHERE 
version_id=".$pending_version['version_id'];                  
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
+                               }
+                       }
+                                               
+                       $this->db->unlock();
        }
 
        // submit file for internal approval then delivery
@@ -1384,8 +1691,120 @@
        // and the performer of this action must have editor role
        function submit_file ( $element_id )
        {
+                       
$working_version=$this->get_working_version($element_id);
+                       
+                       // Need to check if there is a working version
+                       if (is_array($working_version) )
+                       {
+                               if ($working_version['version_id'] )
+                               {
+                                       // Set "pending_for_internal_review" 
status
+                                       // TODO : Add submission date
+                                       $sql="UPDATE ged_versions set 
status='pending_for_internal_review' WHERE 
version_id=".$working_version['version_id'];                   
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
+                               }
+                       }
+                                               
+                       $this->db->unlock();
+       }
+
+       function accept_file ( $element_id )
+       {
+                       
$pending_version=$this->get_pending_for_internal_review($element_id);
+                       
+                       // Need to check if there is a working version
+                       if (is_array($pending_version) )
+                       {
+                               if ($pending_version['version_id'] )
+                               {
+                                       // Set "pending_for_internal_review" 
status
+                                       // TODO : Add submission date
+                                       $sql="UPDATE ged_versions set 
status='ready_for_delivery' WHERE version_id=".$pending_version['version_id'];  
                  
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
+                               }
+                       }
+                                               
+                       $this->db->unlock();
        }
 
+       // relations management
+       
+       function list_version_relations ( $version_id )
+       {
+               if ( is_numeric($version_id) )
+               {
+                       $sql="SELECT ged_relations.*, ged_versions.*, 
ged_elements.* ";
+                       $sql.="FROM (ged_relations INNER JOIN ged_versions on 
ged_relations.linked_version_id=ged_versions.version_id) ";
+                       $sql.="INNER JOIN ged_elements ON 
ged_versions.element_id = ged_elements.element_id WHERE 
linking_version_id=".$version_id;
+                       
+                       $this->db->query($sql);
+       
+                       $i=0;
+                       while ($this->db->next_record())
+                       {
+                               $element_id=$this->db->f('element_id');
+                               
+                               if ( $this->can_read($element_id) )
+                               {
+                                       
$relations[$i]['element_id']=$element_id;
+                                       
$relations[$i]['version_id']=$this->db->f('version_id');
+                                       
$relations[$i]['name']=$this->db->f('name');
+                                       
$relations[$i]['status']=$this->db->f('status');
+                                       
$relations[$i]['reference']=$this->db->f('reference');
+                                       
$relations[$i]['major']=$this->db->f('major');
+                                       
$relations[$i]['minor']=$this->db->f('minor');
+                                       $i ++;
+                               }
+                       }
+                               
+                       $this->db->unlock();
+               }
+               
+               if ( isset($relations))
+                       return ($relations);
+               else
+                       return null;                    
+       }
+
+       function list_versions_referring_to ( $version_id )
+       {
+               if ( is_numeric($version_id) )
+               {
+                       $sql="SELECT ged_relations.*, ged_versions.*, 
ged_elements.* ";
+                       $sql.="FROM (ged_relations INNER JOIN ged_versions on 
ged_relations.linking_version_id=ged_versions.version_id) ";
+                       $sql.="INNER JOIN ged_elements ON 
ged_versions.element_id = ged_elements.element_id WHERE 
linked_version_id=".$version_id;
+                       
+                       $this->db->query($sql);
+       
+                       $i=0;
+                       while ($this->db->next_record())
+                       {
+                               $element_id=$this->db->f('element_id');
+                               
+                               if ( $this->can_read($element_id) )
+                               {
+                                       
$relations[$i]['element_id']=$element_id;
+                                       
$relations[$i]['version_id']=$this->db->f('version_id');
+                                       
$relations[$i]['name']=$this->db->f('name');
+                                       
$relations[$i]['status']=$this->db->f('status');
+                                       
$relations[$i]['reference']=$this->db->f('reference');
+                                       
$relations[$i]['major']=$this->db->f('major');
+                                       
$relations[$i]['minor']=$this->db->f('minor');
+                                       $i ++;
+                               }
+                       }
+                               
+                       $this->db->unlock();
+               }
+               
+               if ( isset($relations))
+                       return ($relations);
+               else
+                       return null;                    
+       }
+       
+       // Home board functions
+       
        function list_new_documents ()
        {
                // Get previous login time
@@ -1403,7 +1822,7 @@
                
                // List new suff
                
-               $sql="SELECT * from ged_elements INNER JOIN ged_versions ON 
ged_elements.element_id=ged_versions.element_id ";
+               $sql="SELECT ged_elements.*, ged_versions.* from ged_elements 
INNER JOIN ged_versions ON ged_elements.element_id=ged_versions.element_id ";
                $sql.="WHERE ged_versions.status='current' AND ( 
ged_versions.validation_date >=$then ";
                $sql.="OR ( ( ged_elements.validity_period > 0 OR 
ged_elements.validity_period IS NOT NULL) AND ged_versions.creation_date 
>=$then ))";
                
@@ -1418,6 +1837,7 @@
                        {
                                $docs[$i]['element_id']=$element_id;
                                $docs[$i]['name']=$this->db->f('name');
+                               $docs[$i]['status']=$this->db->f('status');
                                
$docs[$i]['reference']=$this->db->f('reference');
                                
$docs[$i]['description']=$this->db->f('description');
                                $i ++;
@@ -1426,7 +1846,10 @@
                        
                $this->db->unlock();
 
+               if ( isset($docs))
                return ($docs);
+               else
+                       return null;
        }
 
        function list_documents_to_expire ($period=0)
@@ -1437,9 +1860,16 @@
                $now=time();
                $then=$now+$period*24*3600;
                
-               $sql="SELECT * from ged_elements INNER JOIN ged_versions ON 
ged_elements.element_id=ged_versions.element_id ";
-               $sql.="WHERE ged_versions.status='current' AND ( 
ged_elements.validity_period+ged_versions.validation_date < $then ";
-               $sql.="OR ( ( ged_elements.validity_period > 0 OR 
ged_elements.validity_period IS NOT NULL) AND ged_versions.validation_date IS 
NULL ))";
+               $sql="SELECT ged_elements.*, ged_current_version.* ";
+               $sql.="FROM ( ged_elements ";
+               $sql.="INNER JOIN ged_versions as ged_current_version ";
+               $sql.="ON 
ged_elements.element_id=ged_current_version.element_id ";
+               $sql.="AND ged_current_version.status='current' ) ";
+               $sql.="GROUP BY ged_elements.element_id ";
+               $sql.="HAVING ged_elements.validity_period IS NOT NULL ";
+               $sql.="AND ged_elements.validity_period > 0 ";
+               $sql.="AND ( 
ged_elements.validity_period+ged_current_version.validation_date < $then ";
+               $sql.="OR  ged_current_version.validation_date IS NULL ) ";
                
                $this->db->query($sql);
 
@@ -1447,12 +1877,14 @@
                while ($this->db->next_record())
                {
                        $element_id=$this->db->f('element_id');
+                       $version_id=$this->db->f('version_id');
                        
                        if ( $this->can_read($element_id) )
                        {
                                $docs[$i]['element_id']=$element_id;
                                $docs[$i]['name']=$this->db->f('name');
                                
$docs[$i]['reference']=$this->db->f('reference');
+                               $docs[$i]['status']=$this->db->f('status');
                                
$docs[$i]['description']=$this->db->f('description');
                                
$docs[$i]['validity_period']=$this->db->f('validity_period');
                                
$docs[$i]['validation_date']=$this->db->f('validation_date');
@@ -1463,9 +1895,96 @@
                        
                $this->db->unlock();
 
+               if ( isset($docs))
                return ($docs);
+               else
+                       return null;
        
        }
 
+       function list_pending_documents ()
+       {
+                                       
+               $sql="SELECT ged_elements.*, ged_current_version.* ";
+               $sql.="FROM ( ged_elements ";
+               $sql.="INNER JOIN ged_versions as ged_current_version ";
+               $sql.="ON 
ged_elements.element_id=ged_current_version.element_id ";
+               $sql.="AND ( 
ged_current_version.status='pending_for_internal_review' or 
ged_current_version.status='pending_for_approval' or 
ged_current_version.status='ready_for_delivery' )) ";
+               $sql.="GROUP BY ged_elements.element_id ";
+               
+               $this->db->query($sql);
+
+               $i=0;
+               while ($this->db->next_record())
+               {
+                       $element_id=$this->db->f('element_id');
+                       $version_id=$this->db->f('version_id');
+                       
+                       if ( $this->can_write($element_id) )
+                       {
+                               $docs[$i]['element_id']=$element_id;
+                               $docs[$i]['name']=$this->db->f('name');
+                               $docs[$i]['status']=$this->db->f('status');
+                               
$docs[$i]['reference']=$this->db->f('reference');
+                               
$docs[$i]['description']=$this->db->f('description');
+                               $i ++;
+                       }
+               }
+                       
+               $this->db->unlock();
+               
+               if ( isset($docs))
+                       return ($docs);
+               else
+                       return null;
+       
+       }
+
+  // Recherches
+  
+  function search($query)
+  {
+               $sql="SELECT ged_elements.*, ged_current_version.* ";
+               $sql.="FROM ( ged_elements ";
+               $sql.="INNER JOIN ged_versions as ged_current_version ";
+               $sql.="ON 
ged_elements.element_id=ged_current_version.element_id ";
+               $sql.="AND ( ged_current_version.status='current' or 
ged_current_version.status='working' )) ";
+               $sql.="WHERE ged_elements.name like '%".$query."%' OR 
ged_elements.description like '%".$query."%' OR ged_elements.reference like 
'%".$query."%' ";
+               $sql.="OR  ged_current_version.description like 
'%".$query."%';";
+               
+               $this->db->query($sql);
+
+               $i=0;
+               while ($this->db->next_record())
+               {
+                       $element_id=$this->db->f('element_id');
+                       $version_id=$this->db->f('version_id');
+                       
+                       print ( "--".$element_id);
+                       if ( $this->can_write($element_id) )
+                       {
+                               $docs[$i]['element_id']=$element_id;
+                               
$docs[$i]['version_id']=$this->db->f('version_id');
+                               $docs[$i]['name']=$this->db->f('name');
+                               $docs[$i]['status']=$this->db->f('status');
+                               $docs[$i]['major']=$this->db->f('major');
+                               $docs[$i]['minor']=$this->db->f('minor');
+                               
$docs[$i]['reference']=$this->db->f('reference');
+                               
+                               
$docs[$i]['reference']=$this->db->f('reference');
+                               
$docs[$i]['description']=$this->db->f('description');
+                               $i ++;
+                       }
+               }
+                       
+               $this->db->unlock();
+               
+               if ( isset($docs))
+                       return ($docs);
+               else
+                       return null;
+
+       
+  }
 }
 ?>

Index: hook_home.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/hook_home.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- hook_home.inc.php   30 Aug 2006 17:02:38 -0000      1.5
+++ hook_home.inc.php   22 Mar 2007 09:19:28 -0000      1.6
@@ -19,7 +19,7 @@
                        $title='<font color="#FFFFFF">'.lang('ged').'</font>';
                
                $portalbox=CreateObject('phpgwapi.listbox',
-                       Array(
+                       @Array(
                                'title'=>$title,
                                
'primary'=>$GLOBALS['phpgw_info']['theme']['navbar_bg'],
                                
'secondary'=>$GLOBALS['phpgw_info']['theme']['navbar_bg'],
@@ -33,11 +33,11 @@
                $app_id=$GLOBALS['phpgw']->applications->name2id('ged');
                $GLOBALS['portal_order'][]=$app_id;
                $var=Array(
-                       'up'=>Array('url'=>'/set_box.php', 'app'=>$app_id),
-                       'down'=>Array('url'=>'/set_box.php', 'app'=>$app_id),
-                       'close'=>Array('url'=>'/set_box.php', 'app'=>$app_id),
-                       'question'=>Array('url'=>'/set_box.php', 
'app'=>$app_id),
-                       'edit'=>Array('url'=>'/set_box.php', 'app'=>$app_id)
+               //      'up'=>Array('url'=>'/set_box.php', 'app'=>$app_id),
+               //      'down'=>Array('url'=>'/set_box.php', 'app'=>$app_id),
+               //      'close'=>Array('url'=>'/set_box.php', 'app'=>$app_id),
+               //      'question'=>Array('url'=>'/set_box.php', 
'app'=>$app_id),
+               //      'edit'=>Array('url'=>'/set_box.php', 'app'=>$app_id)
                );
 
                while(list($key,$value)=each($var))
@@ -47,12 +47,13 @@
 
                        $portalbox->data=Array();
                        
-                       if($data)
+                       if ( isset($data))
+                               if(is_array($data))
                        {
                                $portalbox->data=$data;
                        }
                        
-                       $GLOBALS['extra_data']='<td style="background: 
white;"><div style="margin-left: 1em;">'."\n";
+                       $GLOBALS['extra_data']='<td><div style="margin-left: 
1em;">'."\n";
                        
                        /* partie interessante */
                        
@@ -62,9 +63,13 @@
                        
                        if ( is_array($docs1) )
                        {
+                               $GLOBALS['extra_data'] .="<table>\n";
+                               $GLOBALS['extra_data'] .="<tr>\n";
+                               $GLOBALS['extra_data'] .="<td colspan=\"2\">\n";
                                $GLOBALS['extra_data'] .="<h2>".lang ('New 
documents')."</h2>"."\n";
+                               $GLOBALS['extra_data'] .="</td>\n";
+                               $GLOBALS['extra_data'] .="</tr>\n";
                        
-                               $GLOBALS['extra_data'] .="<ul 
style=\"margin-left: 2em;\">\n";
                                foreach ( $docs1 as $doc )
                                {
                                        
@@ -72,21 +77,34 @@
                                        
$link_data['focused_id']=$doc['element_id'];
                                        
$link=$GLOBALS['phpgw']->link('/index.php', $link_data);
                        
+                                       $GLOBALS['extra_data'] .="<tr>\n";
+                                       $GLOBALS['extra_data'] .="<td>\n";
+                                       $GLOBALS['extra_data'] .= "<img 
src=\"".$GLOBALS['phpgw']->common->image('ged', $doc['status']."-16")."\">\n";
+                                       $GLOBALS['extra_data'] .="</td>\n";
+
+                                       $GLOBALS['extra_data'] .="<td>\n";
                                        if ( $doc['reference'] !="" )
-                                               $GLOBALS['extra_data'] 
.="<li><a href=\"".$link."\" >".$doc['name']." 
(".$doc['reference'].")</a>"."</li>\n";
+                                               $GLOBALS['extra_data'] .="<a 
href=\"".$link."\" >".$doc['name']." [".$doc['reference']."]</a>\n";
                                        else
-                                               $GLOBALS['extra_data'] 
.="<li><a href=\"".$link."\" >".$doc['name']."</a>"."</li>\n";
+                                               $GLOBALS['extra_data'] .="<a 
href=\"".$link."\" >".$doc['name']."</a>\n";
+                                       
+                                       $GLOBALS['extra_data'] .="</td>\n";
+                                       $GLOBALS['extra_data'] .="</tr>\n";
                                }
-                               $GLOBALS['extra_data'] .="</ul>\n";
+                               $GLOBALS['extra_data'] .="</table>\n";
                        }
 
                        $docs2=$ged_dm->list_documents_to_expire();
                        
                        if ( is_array($docs2) )
                        {
-                               $GLOBALS['extra_data'] .="<h2>".lang('Documents 
to check soon')."</h2>"."\n";
+                               $GLOBALS['extra_data'] .="<table>\n";
+                               $GLOBALS['extra_data'] .="<tr>\n";
+                               $GLOBALS['extra_data'] .="<td colspan=\"2\">\n";
+                               $GLOBALS['extra_data'] .="<h2>".lang 
('Documents to check soon')."</h2>"."\n";
+                               $GLOBALS['extra_data'] .="</td>\n";
+                               $GLOBALS['extra_data'] .="</tr>\n";
                                
-                               $GLOBALS['extra_data'] .="<ul 
style=\"margin-left: 2em;\">"."\n";
                                foreach ( $docs2 as $doc )
                                {
                                        
@@ -99,12 +117,57 @@
                                        else
                                                $expiration=lang("Too late!");
                        
+                                       $GLOBALS['extra_data'] .="<tr>\n";
+                                       $GLOBALS['extra_data'] .="<td>\n";
+                                       $GLOBALS['extra_data'] .= "<img 
src=\"".$GLOBALS['phpgw']->common->image('ged', $doc['status']."-16")."\">\n";
+                                       $GLOBALS['extra_data'] .="</td>\n";
+
+                                       $GLOBALS['extra_data'] .="<td>\n";
+
                                        if ( $doc['reference'] !="" )
-                                               $GLOBALS['extra_data'] 
.="<li><a href=\"".$link."\" >".$doc['name']." (".$doc['reference'].")</a> 
[".lang("Deadline")." : ".$expiration."]</li>"."\n";
+                                               $GLOBALS['extra_data'] .="<a 
href=\"".$link."\" >".$doc['name']." [".$doc['reference']."]</a> 
(".lang("Deadline")." : ".$expiration.")"."\n";
                                        else
-                                               $GLOBALS['extra_data'] 
.="<li><a href=\"".$link."\" >".$doc['name']."</a> [".lang("Deadline")." : 
".$expiration."]</li>"."\n";
+                                               $GLOBALS['extra_data'] .="<a 
href=\"".$link."\" >".$doc['name']."</a> (".lang("Deadline")." : 
".$expiration.")"."\n";
+
+                                       $GLOBALS['extra_data'] .="</td>\n";
+                                       $GLOBALS['extra_data'] .="</tr>\n";
+                               }
+                               $GLOBALS['extra_data'] .="</table>\n";
+                       }
+
+                       $docs3=$ged_dm->list_pending_documents();
+                       
+                       if ( is_array($docs3) )
+                       {
+                               $GLOBALS['extra_data'] .="<table>\n";
+                               $GLOBALS['extra_data'] .="<tr>\n";
+                               $GLOBALS['extra_data'] .="<td colspan=\"2\">\n";
+                               $GLOBALS['extra_data'] .="<h2>".lang ('Pending 
documents')."</h2>"."\n";
+                               $GLOBALS['extra_data'] .="</td>\n";
+                               $GLOBALS['extra_data'] .="</tr>\n";
+
+                               foreach ( $docs3 as $doc )
+                               {
+                                       
+                                       
$link_data['menuaction']='ged.ged_ui.browse';
+                                       
$link_data['focused_id']=$doc['element_id'];
+                                       
$link=$GLOBALS['phpgw']->link('/index.php', $link_data);
+                                                               
+                                       $GLOBALS['extra_data'] .="<tr>\n";
+                                       $GLOBALS['extra_data'] .="<td>\n";
+                                       $GLOBALS['extra_data'] .= "<img 
src=\"".$GLOBALS['phpgw']->common->image('ged', $doc['status']."-16")."\">\n";
+                                       $GLOBALS['extra_data'] .="</td>\n";
+
+                                       $GLOBALS['extra_data'] .="<td>\n";
+                                       if ( $doc['reference'] !="" )
+                                               $GLOBALS['extra_data'] .="<a 
href=\"".$link."\" >".$doc['name']." [".$doc['reference']."]</a>"."\n";
+                                       else
+                                               $GLOBALS['extra_data'] .="<a 
href=\"".$link."\" >".$doc['name']."</a>"."\n";
+
+                                       $GLOBALS['extra_data'] .="</td>\n";
+                                       $GLOBALS['extra_data'] .="</tr>\n";
                                }
-                               $GLOBALS['extra_data'] .="</ul>"."\n";
+                               $GLOBALS['extra_data'] .="</table>\n";
                        }
                        
                        /* fin partie interessante */
@@ -112,7 +175,7 @@
                        $GLOBALS['extra_data'] .='</div></td>';
                
                        // output the portalbox
-                       if ( is_array($docs1) || is_array($docs2) )
+                       if ( is_array($docs1) || is_array($docs2) || 
is_array($docs3) )
                                echo "\n".'<!-- BEGIN ged info 
-->'."\n".$portalbox->draw($GLOBALS['extra_data'])."\n".'<!-- END ged info 
-->'."\n";
                        else
                                echo "\n".'<!-- BEGIN ged info 
-->'."\n".$portalbox->draw('<td style="background: white;"><div 
style="margin-left: 1em;">'.lang("Nothing to 
notice...")).'</div></td>'."\n".'<!-- END ged info -->'."\n";




reply via email to

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