phpgroupware-cvs
[Top][All Lists]
Advanced

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

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


From: Pascal Vilarem
Subject: [Phpgroupware-cvs] ged inc/class.ged_dm.inc.php inc/class.ged_ui.i...
Date: Thu, 30 Aug 2007 17:03:22 +0000

CVSROOT:        /sources/phpgroupware
Module name:    ged
Changes by:     Pascal Vilarem <maat>   07/08/30 17:03:22

Modified files:
        inc            : class.ged_dm.inc.php class.ged_ui.inc.php 
Added files:
        templates/base : approve_file.tpl accept_file.tpl 

Log message:
        feature : added automatic review insert for accept and approve
        fix : comment file at the right place for all 
approve/accept/reject/refuse

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.inc.php?cvsroot=phpgroupware&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_ui.inc.php?cvsroot=phpgroupware&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/approve_file.tpl?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/accept_file.tpl?cvsroot=phpgroupware&rev=1.1

Patches:
Index: inc/class.ged_dm.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- inc/class.ged_dm.inc.php    3 Aug 2007 13:35:45 -0000       1.43
+++ inc/class.ged_dm.inc.php    30 Aug 2007 17:03:21 -0000      1.44
@@ -661,7 +661,7 @@
        {
                $parent=$this->get_element_info($new_folder['parent_id']);
                
-               if ( ! is_null($parent['project_root']==null) && ! 
$parent['project_root']==0 )
+               if ( isset($parent['project_root']) &&  
(int)$parent['project_root']!=0 )
                {
                        $sql_model="INSERT INTO %s ( type, parent_id, name, 
reference, description, owner_id, creator_id, creation_date, project_name, 
project_root  ) VALUES ";
                        $sql_model.=" ( '%s', %d, '%s', '%s', '%s', %d, %d, %d, 
'%s', %d) ";
@@ -2036,10 +2036,13 @@
        // Say file is OK
        // User must have acceptation rights on this document
 
-       function accept_file ( $element_id )
+       function accept_file ( $element_id, $comment='accepted', 
$comment_file=null )
        {
                
$current_or_alert_version=$this->get_current_or_alert_version($element_id);
                
$working_or_pending_version=$this->get_working_or_pending_version($element_id);
+               $element=$this->get_element_info($element_id);
+               
+               $result=false;
                
                // Need to check if there is a working version
                if (is_array($working_or_pending_version) )
@@ -2068,13 +2071,50 @@
                                                }
                                        }
                                }
+                               
                                $sql="UPDATE ged_versions set status='current', 
validation_date=".time()." WHERE 
version_id=".$working_or_pending_version['version_id'];                        
                                $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->unlock();
                                
-                               $this->store_history ('accepted', 'accepted', 
$working_or_pending_version['version_id']);
+                               if (isset($comment_file) && 
$comment_file['file_name'] != "")
+                               {
+                                       $new_file=$comment_file;
+                                       
$new_file['doc_type']=$this->external_review_file_type;
+                                       
$new_file['name']=$this->get_type_desc($new_file['doc_type'])." / 
".$element['name'];
+                                       $new_file['description']=$comment;
+                                       
$new_file['reference']=$this->get_next_available_reference($new_file['doc_type'],
 $element['project_root'] );
+                                       $new_file['major']=1;
+                                       $new_file['minor']=0;
+                                       $new_file['validity_period']=0;
+                                       
+                                       $new_place=null;
+                                       
$new_place=$this->get_type_place($new_file['doc_type'],$element['project_root']);
+                                       if ( !isset($new_place))
+                                       {
+                                               
$new_place=$element['parent_id'];
                        }
+                                       $new_file['parent_id']=$new_place;
+                                       
+                                       $new_id=$this->add_file($new_file);
+
+                                       
$new_version=$this->get_last_version($new_id);
+                                       
$new_relations[0]['linked_version_id']=$working_or_pending_version['version_id'];
+                                       
$new_relations[0]['relation_type']='comment';
+                                       
+                                       
$this->set_relations($new_version['version_id'],$new_relations);
+                                       
                }
+                               
+                               $this->store_history ('accepted', $comment, 
$working_or_pending_version['version_id']);
+                               $result=true;
+                       }
+               }
+               else
+               {
+                       $result=false;
+               }
+               // TODO : check if all is ok
+               return ( $result );
        }
 
        function alert_version ( $version_id )
@@ -2109,25 +2149,26 @@
                                $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->unlock();
                                
-                               if (isset($comment_file))
+                               if (isset($comment_file) && 
$comment_file['file_name'] != "")
                                {
                                        $new_file=$comment_file;
                                        
+                                       $new_file=$comment_file;
+                                       
$new_file['doc_type']=$this->external_review_file_type;
+                                       
$new_file['name']=$this->get_type_desc($new_file['doc_type'])." / 
".$element['name'];
+                                       $new_file['description']=$comment;
+                                       
$new_file['reference']=$this->get_next_available_reference($new_file['doc_type'],
 $element['project_root'] );
+                                       $new_file['major']=1;
+                                       $new_file['minor']=0;
+                                       $new_file['validity_period']=0;
+                                       
                                        $new_place=null;
                                        
$new_place=$this->get_type_place($new_file['doc_type'],$element['project_root']);
                                        if ( !isset($new_place))
                                        {
                                                
$new_place=$element['parent_id'];
                                        }
-                                       
-                                       
$new_file['doc_type']=$this->internal_review_file_type;
                                        $new_file['parent_id']=$new_place;
-                                       
$new_file['name']=$this->get_type_desc($new_file['doc_type'])." / 
".$element['name'];
-                                       $new_file['description']=$comment;
-                                       
$new_file['reference']=$this->get_next_available_reference($new_file['doc_type'],
 $element['project_root'] );
-                                       $new_file['major']=1;
-                                       $new_file['minor']=0;
-                                       $new_file['validity_period']=0;
                                        
                                        $new_id=$this->add_file($new_file);
                                        
@@ -2174,18 +2215,11 @@
                                $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->unlock();
                                
-                               if (isset($comment_file))
+                               if (isset($comment_file) && 
$comment_file['file_name'] != "")
                                {
-                                       $new_place=null;
-                                       
$new_place=$this->get_type_place($new_file['doc_type'],$element['project_root']);
-                                       if ( !isset($new_place))
-                                       {
-                                               
$new_place=$element['parent_id'];
-                                       }
                                        
                                        $new_file=$comment_file;
                                        
$new_file['doc_type']=$this->external_review_file_type;
-                                       $new_file['parent_id']=$new_place;
                                        
$new_file['name']=$this->get_type_desc($new_file['doc_type'])." / 
".$element['name'];
                                        $new_file['description']=$comment;
                                        
$new_file['reference']=$this->get_next_available_reference($new_file['doc_type'],
 $element['project_root'] );
@@ -2193,6 +2227,14 @@
                                        $new_file['minor']=0;
                                        $new_file['validity_period']=0;
                                        
+                                       $new_place=null;
+                                       
$new_place=$this->get_type_place($new_file['doc_type'],$element['project_root']);
+                                       if ( !isset($new_place))
+                                       {
+                                               
$new_place=$element['parent_id'];
+                                       }
+                                       $new_file['parent_id']=$new_place;
+                                       
                                        $new_id=$this->add_file($new_file);
 
                                        
$new_version=$this->get_last_version($new_id);
@@ -2263,9 +2305,14 @@
                }               
        }
 
-       function approve_file ( $element_id )
+       function approve_file ( $element_id, $comment='approved', 
$comment_file=null )
        {
+               _debug_array($comment_file);
+               
                
$pending_version=$this->get_pending_for_internal_review($element_id);
+               $element=$this->get_element_info($element_id);
+               
+               $result=false;
                
                // Need to check if there is a working version
                if (is_array($pending_version) )
@@ -2285,9 +2332,46 @@
                                $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->unlock();
                                
-                               $this->store_history ('approved', 'approved', 
$pending_version['version_id']);
+                               if (isset($comment_file) && 
$comment_file['file_name'] != "")
+                               {
+                                       $new_file=$comment_file;
+                                       
$new_file['doc_type']=$this->external_review_file_type;
+                                       
$new_file['name']=$this->get_type_desc($new_file['doc_type'])." / 
".$element['name'];
+                                       $new_file['description']=$comment;
+                                       
$new_file['reference']=$this->get_next_available_reference($new_file['doc_type'],
 $element['project_root'] );
+                                       $new_file['major']=1;
+                                       $new_file['minor']=0;
+                                       $new_file['validity_period']=0;
+                                       
+                                       $new_place=null;
+                                       
$new_place=$this->get_type_place($new_file['doc_type'],$element['project_root']);
+                                       if ( !isset($new_place))
+                                       {
+                                               
$new_place=$element['parent_id'];
+                                       }
+                                       $new_file['parent_id']=$new_place;
+                                       
+                                       $new_id=$this->add_file($new_file);
+
+                                       
$new_version=$this->get_last_version($new_id);
+                                       
$new_relations[0]['linked_version_id']=$pending_version['version_id'];
+                                       
$new_relations[0]['relation_type']='comment';
+                                       
+                                       
$this->set_relations($new_version['version_id'],$new_relations);
+                                       
                        }
+
+                               $this->store_history ('approved', $comment, 
$pending_version['version_id']);
+                                                               
+                               $result=true;
+                       }
+               }
+               else
+               {
+                       $result=false;
                }
+               // TODO : check if all is ok
+               return ( $result );
        }
 
        // relations management
@@ -3391,5 +3475,10 @@
                
                return ($out);
        }
+       
+       function get_project_status($project_root)
+       {
+               
+       }
 }
 ?>

Index: inc/class.ged_ui.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_ui.inc.php,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- inc/class.ged_ui.inc.php    3 Aug 2007 13:35:45 -0000       1.45
+++ inc/class.ged_ui.inc.php    30 Aug 2007 17:03:21 -0000      1.46
@@ -2333,16 +2333,49 @@
        
        function accept_file()
        {
+               // element data
                $element_id=get_var('element_id', array('GET', 'POST'));
+               
$pending_version=$this->ged_dm->get_pending_for_internal_review($element_id);
+               // Comment file data
+               $accept_file=get_var('accept_file',array('POST'));
+               $comment=addslashes(get_var('comment', array( 'POST')));
                
-               $this->ged_dm->accept_file ( $element_id );
+               if ($accept_file==lang('Accept file'))
+               {
+                       $comment_file['file_name']=$_FILES['file']['name'];
+                       $comment_file['file_size']=$_FILES['file']['size'];
+                       
$comment_file['file_tmp_name']=$_FILES['file']['tmp_name'];
+                       $comment_file['file_mime_type']=$_FILES['file']['type'];
 
+                       if ( $this->ged_dm->accept_file ( $element_id, 
$comment, $comment_file ))
+                       {
                $link_data=null;
                $link_data['menuaction']='ged.ged_ui.browse';
                $link_data['focused_id']=$element_id;
+                               
$link_data['version_id']=$pending_version['version_id'];
        
                $GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
        }
+                       // TODO : else get error message and display it
+               }
+               
+               $this->set_template_defaults();
+
+               $this->t->set_file(array('accept_file_tpl'=>'accept_file.tpl'));
+               
+               $this->t->set_var('element_id_value', $element_id);
+               $this->t->set_var('comment_field', 'comment');
+               $this->t->set_var('comment_label', lang('comment'));
+               $this->t->set_var('comment_value', $comment);
+               $this->t->set_var('lang_accept_file', lang('Accept file'));
+
+               $accept_link_data['menuaction']='ged.ged_ui.accept_file';
+               $this->t->set_var('action_accept', 
$GLOBALS['phpgw']->link('/index.php', $accept_link_data));
+               
+               $this->display_app_header();
+
+               $this->t->pfp('out', 'accept_file_tpl');
+       }
 
        function submit_file()
        {
@@ -2401,21 +2434,53 @@
                $this->display_app_header();
 
                $this->t->pfp('out', 'reject_file_tpl');
-
        }
 
        function approve_file()
        {
+               // element data
                $element_id=get_var('element_id', array('GET', 'POST'));
+               
$pending_version=$this->ged_dm->get_pending_for_internal_review($element_id);
+               // Comment file data
+               $approve_file=get_var('approve_file',array('POST'));
+               $comment=addslashes(get_var('comment', array( 'POST')));
                
-               $this->ged_dm->approve_file ( $element_id );
+               if ($approve_file==lang('Approve file'))
+               {
+                       $comment_file['file_name']=$_FILES['file']['name'];
+                       $comment_file['file_size']=$_FILES['file']['size'];
+                       
$comment_file['file_tmp_name']=$_FILES['file']['tmp_name'];
+                       $comment_file['file_mime_type']=$_FILES['file']['type'];
 
+                       if ( $this->ged_dm->approve_file ( $element_id, 
$comment, $comment_file ))
+                       {
                $link_data=null;
                $link_data['menuaction']='ged.ged_ui.browse';
                $link_data['focused_id']=$element_id;
+                               
$link_data['version_id']=$pending_version['version_id'];
        
                $GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
        }
+                       // TODO : else get error message and display it
+               }
+               
+               $this->set_template_defaults();
+
+               
$this->t->set_file(array('approve_file_tpl'=>'approve_file.tpl'));
+               
+               $this->t->set_var('element_id_value', $element_id);
+               $this->t->set_var('comment_field', 'comment');
+               $this->t->set_var('comment_label', lang('comment'));
+               $this->t->set_var('comment_value', $comment);
+               $this->t->set_var('lang_approve_file', lang('Approve file'));
+
+               $approve_link_data['menuaction']='ged.ged_ui.approve_file';
+               $this->t->set_var('action_approve', 
$GLOBALS['phpgw']->link('/index.php', $approve_link_data));
+               
+               $this->display_app_header();
+
+               $this->t->pfp('out', 'approve_file_tpl');
+       }
 
        function deliver_file()
        {
@@ -2710,6 +2775,12 @@
                        
                        $this->t->fp('ged_projects_handle', 'ged_projects', 
True);
                }       
+
+               //$link_data=null;
+               //$link_data['menuaction']='ged.ged_stats.ged_pie_status';
+               //$the_graph_link=$GLOBALS['phpgw']->link('/index.php', 
$link_data);
+               //$this->t->set_var('test_graph_link', $the_graph_link);
+
                $this->t->pfp('out', 'stats_tpl');
 
        }

Index: templates/base/approve_file.tpl
===================================================================
RCS file: templates/base/approve_file.tpl
diff -N templates/base/approve_file.tpl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ templates/base/approve_file.tpl     30 Aug 2007 17:03:22 -0000      1.1
@@ -0,0 +1,32 @@
+<form name="FileList" enctype="multipart/form-data" action="{action_approve}" 
method="post">
+<input type="hidden" name="{element_id_field}" value="{element_id_value}">
+<table cellpadding="5">
+<tr>
+<td colspan="2">
+<h2>Approve file</h2>
+</td>
+</tr>
+<tr>
+<td>
+{comment_label} :
+</td>
+<td>
+<textarea name="{comment_field}" rows="10" cols="50" wrap="off" 
>{comment_value}</textarea>
+</td>
+</tr>
+<tr>
+<td>
+{lang_file} :  
+</td>
+<td>
+<input name="{file_field}" type="file" value="{file_value}"/>
+</td>
+</tr>
+
+<tr>
+<td colspan="2" align="center" >
+<input type="submit" name="approve_file" value="{lang_approve_file}" />
+</td>
+</tr>
+</table>
+</form>
\ No newline at end of file

Index: templates/base/accept_file.tpl
===================================================================
RCS file: templates/base/accept_file.tpl
diff -N templates/base/accept_file.tpl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ templates/base/accept_file.tpl      30 Aug 2007 17:03:22 -0000      1.1
@@ -0,0 +1,32 @@
+<form name="FileList" enctype="multipart/form-data" action="{action_accept}" 
method="post">
+<input type="hidden" name="{element_id_field}" value="{element_id_value}">
+<table cellpadding="5">
+<tr>
+<td colspan="2">
+<h2>Accept file</h2>
+</td>
+</tr>
+<tr>
+<td>
+{comment_label} :
+</td>
+<td>
+<textarea name="{comment_field}" rows="10" cols="50" wrap="off" 
>{comment_value}</textarea>
+</td>
+</tr>
+<tr>
+<td>
+{lang_file} :  
+</td>
+<td>
+<input name="{file_field}" type="file" value="{file_value}""/>
+</td>
+</tr>
+
+<tr>
+<td colspan="2" align="center" >
+<input type="submit" name="accept_file" value="{lang_accept_file}" />
+</td>
+</tr>
+</table>
+</form>
\ No newline at end of file




reply via email to

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