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_admi...


From: Pascal Vilarem
Subject: [Phpgroupware-cvs] ged inc/class.ged_dm.inc.php inc/class.ged_admi...
Date: Thu, 02 Aug 2007 21:48:57 +0000

CVSROOT:        /sources/phpgroupware
Module name:    ged
Changes by:     Pascal Vilarem <maat>   07/08/02 21:48:57

Modified files:
        inc            : class.ged_dm.inc.php class.ged_admin.inc.php 
        templates/base : places.tpl 

Log message:
        added: admin form to manage doc places for each project ("quick add" 
feature in progress)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.inc.php?cvsroot=phpgroupware&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_admin.inc.php?cvsroot=phpgroupware&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/places.tpl?cvsroot=phpgroupware&r1=1.1&r2=1.2

Patches:
Index: inc/class.ged_dm.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- inc/class.ged_dm.inc.php    2 Aug 2007 15:34:10 -0000       1.40
+++ inc/class.ged_dm.inc.php    2 Aug 2007 21:48:56 -0000       1.41
@@ -1518,6 +1518,7 @@
                                
$elements[$i]['lock_user_id']=$this->db->f('lock_user_id');
                                
$elements[$i]['description']=$this->db->f('description');
                                
$elements[$i]['validity_period']=$this->db->f('validity_period');
+                               
$elements[$i]['project_root']=$this->db->f('project_root');
        
                                $i ++;
                        }
@@ -1529,6 +1530,11 @@
 
        }
 
+       function list_sub_folders ( $element_id )
+       {
+               return( $this->list_elements($element_id, 'folder'));
+       }
+
        function list_versions($element_id)
        {
                $versions=null;
@@ -3143,6 +3149,11 @@
                return ($out ); 
        }
 
+       function list_projects()
+       {
+               
+       }
+
        function get_project_name($project_root_id)
        {
                $db2 = clone($this->db);
@@ -3219,6 +3230,97 @@
                return($result);
        }
        
+       function list_types_places($project_root_id)
+       {
+               $places=null;
+               
+               // if is_project($project_root_id) ?
+               $sql="SELECT * from ged_types_places WHERE 
project_root=".$project_root_id;
+               
+               $this->db->query($sql);
+
+               $i=0;
+               while ($this->db->next_record())
+               {
+                       $places[$i]['type_id']=$this->db->f('type_id');
+                       
$places[$i]['project_root']=$this->db->f('project_root');
+                       $places[$i]['element_id']=$this->db->f('element_id');
+                       $i ++;
+               }
+                       
+               $this->db->unlock();
+               
+               return ($places);
+       }
+       
+       function list_unplaced_types ($project_root_id)
+       {
+               $types=null;
+               
+               // if is_project($project_root_id) ?
+               $sql="SELECT ged_doc_types.* from (ged_doc_types LEFT JOIN 
ged_types_places ";
+               $sql.="ON ged_types_places.type_id=ged_doc_types.type_id ";     
        
+               $sql.="AND ged_types_places.project_root=".$project_root_id.") 
";
+               $sql.="WHERE ged_types_places.element_id is null";
+               
+               $this->db->query($sql);
+
+               $i=0;
+               while ($this->db->next_record())
+               {
+                       $types[$i]['type_id']=$this->db->f('type_id');
+                       $types[$i]['type_desc']=$this->db->f('type_desc');
+                       $types[$i]['type_ref']=$this->db->f('type_ref');
+                       $types[$i]['type_chrono']=$this->db->f('type_chrono');  
                
+                       $i ++;
+               }
+                       
+               $this->db->unlock();
+               
+               return ($types);
+               
+       }
+
+       function add_places($places)
+       {
+               foreach ( $places as $place )
+               {                        
+                       
+                       $sql="INSERT INTO ged_types_places (type_id, 
project_root, element_id) values ( '".addslashes($place['type_id'])."', 
".(int)$place['project_root'].", ".(int)$place['element_id'].") ";
+
+                       $this -> db->query($sql, __LINE__, __FILE__);
+                       $this->db->unlock();            
+               }
+               
+       }
+
+       function delete_places($places)
+       {
+               foreach ( $places as $place )
+               {                        
+                       
+                       $sql="DELETE FROM ged_types_places WHERE 
type_id='".addslashes($place['type_id'])."' AND 
project_root=".(int)$place['project_root'];
+
+                       $this -> db->query($sql, __LINE__, __FILE__);
+                       $this->db->unlock();            
+               }
+               
+       }
+
+       function update_places($places)
+       {
+               foreach ( $places as $place )
+               {                        
+                       
+                       $sql="UPDATE ged_types_places SET 
element_id=".(int)$place['element_id']." ";
+                       $sql.="WHERE 
type_id='".addslashes($place['type_id'])."' AND 
project_root=".(int)$place['project_root'];
+
+                       $this -> db->query($sql, __LINE__, __FILE__);
+                       $this->db->unlock();            
+               }
+               
+       }
+       
        function list_chronos($project_root_id)
        {
                $out=null;

Index: inc/class.ged_admin.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_admin.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- inc/class.ged_admin.inc.php 2 Aug 2007 15:34:10 -0000       1.1
+++ inc/class.ged_admin.inc.php 2 Aug 2007 21:48:57 -0000       1.2
@@ -80,6 +80,8 @@
                $this->t->set_var('submit_field', "submit");
                $this->t->set_var('submit_value', lang("submit"));
                
+               if ( isset($doc_types))
+               {
                foreach ( $doc_types as $doc_type )
                {                       
                        $this->t->set_var('type_id_field', 
"doc_types[".$doc_type['type_id']."][type_id]");
@@ -104,6 +106,7 @@
                        /*
                         * actions update and delete
                         */
+                                
                        $this->t->set_var('action_bloc_handler', '');
                        
                        $this->t->set_var('action_field', 'action');
@@ -117,6 +120,7 @@
                        
                        $this->t->fp('types_bloc_handler', 'types_bloc', True);
                }
+               }
                
                /*
                 * new line to allow admin to add a new doc type
@@ -151,13 +155,190 @@
                $this->t->pfp('out', 'types_tpl');
        }
        
+       function gen_subfolder_select ( $element_id, $field_name, 
$selected_element_id='', $recursion_level=0)
+       {
+               $my_sub_folders=$this->ged_dm->list_sub_folders($element_id);
+               
+               if ( $recursion_level == 0)
+               {
+                       $select_sub_folders_html="<select 
name=\"".$field_name."\">\n";
+               }
+               else
+               {
+                       $select_sub_folders_html="";
+               }
+
+               $indent=str_repeat("&nbsp;", $recursion_level*4)."-";
+               
+               foreach ( $my_sub_folders as $my_sub_folder )
+               {
+                       $selected="";
+                       if ( $my_sub_folder['element_id'] == 
$selected_element_id)
+                       {
+                               $selected="selected ";
+                       }
+                       
+                       $project_style="";
+                       if ( $my_sub_folder['element_id'] == 
$my_sub_folder['project_root'])
+                       {
+                               $project_style="style=\"font-weight:bold;\"";
+                       }
+                       
+                       $select_sub_folders_html.="<option ".$project_style." 
value=\"".$my_sub_folder['element_id']."\" 
$selected>".$indent.$my_sub_folder['name']."</option>\n";
+                       
+                       $select_sub_folders_html.=$this->gen_subfolder_select ( 
$my_sub_folder['element_id'], $field_name, $selected_element_id, 
$recursion_level+1);
+               }
+               
+               if ( $recursion_level == 0)
+               {
+                       $select_sub_folders_html.="</select>\n";
+               }       
+               
+               return ( $select_sub_folders_html );
+               
+       }
+       
+       function gen_unplaced_types_select ( $project_root_id, $field_name )
+       {
+               $select_unplaced_types_html="<select 
name=\"".$field_name."\">\n";
+               
+               
$my_unplaced_types=$this->ged_dm->list_unplaced_types($project_root_id);
+               
+               foreach ( $my_unplaced_types as $my_unplaced_type )
+               {
+                       $chrono_flag=$style="";
+                       if ( $my_unplaced_type['type_chrono']==1)
+                       {
+                               $chrono_flag=" [C]";
+                               $style="style=\"font-weight: bold;\"";
+                       }
+
+                       $select_unplaced_types_html.="<option ".$style." 
value=\"".$my_unplaced_type['type_id']."\" 
>".$my_unplaced_type['type_desc'].$chrono_flag."</option>\n";
+               }
+               
+               $select_unplaced_types_html.="</select>\n";
+               
+               return ( $select_unplaced_types_html );
+       }
+       
        function places()
        {
+               //$project_root_id=1;
+               $project_root_id=get_var('project_root',array('GET'));
+               $action=get_var('action',array('POST'));
+               $places=get_var('places',array('POST'));
+               
+               if (  $action==lang("add"))
+               {
+                       $this->ged_dm->add_places($places);
+               }
+               elseif ( $action==lang("update"))
+               {
+                       $this->ged_dm->update_places($places);
+               }
+               elseif ( $action == lang("delete"))
+               {
+                       $this->ged_dm->delete_places($places);                  
+               }
+
                $this->t->set_file(array('places_tpl'=>'places.tpl'));
 
+               /*
+                * Afficher la liste des projets
+                */
+               $this->t->set_block('places_tpl', 'projects_bloc', 
'projects_bloc_handler');
+               $this->t->set_var('projects_bloc_handler', '');
+               
+               $projects=$this->ged_dm->list_available_projects();
+               
+               if ( isset($projects))
+               {
+                       foreach( $projects as $the_project_root => 
$the_project_name)
+                       {
+                               $link_data=null;
+                               $link_data['menuaction']='ged.ged_admin.places';
+                               $link_data['project_root']=$the_project_root;
+                               
+                               $this->t->set_var('project_link', 
$GLOBALS['phpgw']->link('/index.php', $link_data));
+                               $this->t->set_var('project_name', 
$the_project_name);
+                                
+                               $this->t->fp('projects_bloc_handler', 
'projects_bloc', True);
+                       }
+               }
+               else
+               {
+                       $this->t->set_var('projects_bloc_handler', lang("No 
project available"));
+               }
+               
+                
+               $this->t->set_block('places_tpl', 'edit_bloc', 
'edit_bloc_handler');
+               $this->t->set_var('edit_bloc_handler', '');
+
+               if ( is_numeric($project_root_id))
+               {
+                       
$types_places=$this->ged_dm->list_types_places($project_root_id);
+                       
+                       $this->t->set_block('edit_bloc', 'types_bloc', 
'types_bloc_handler');
+                       $this->t->set_var('types_bloc_handler', '');
+                       $this->t->set_block('types_bloc', 'action_bloc', 
'action_bloc_handler');
+                       $this->t->set_var('action_bloc_handler', '');
+                       
+                       $this->t->set_var('active_project_name', 
$this->ged_dm->get_project_name($project_root_id));
+                       
+                       if ( isset($types_places))
+                       {
+                               $i=0;
+                               foreach ( $types_places as $type_place )
+                               {                       
+                                       $this->t->set_var('type_desc', "<input 
type=\"hidden\" name=\"places[".$i."][type_id]\" 
value=\"".$type_place['type_id']."\"/>".$type_place['type_id']);
+                                       $this->t->set_var('select', 
$this->gen_subfolder_select($project_root_id,"places[".$i."][element_id]", 
$type_place['element_id']));
+                                       $this->t->set_var('project',"<input 
type=\"hidden\" name=\"places[".$i."][project_root]\" 
value=\"".$project_root_id."\"/>");
+                                       
+                                       
$this->t->set_var('action_bloc_handler', '');
+                                       
+                                       $this->t->set_var('action_field', 
'action');
+                                       $this->t->set_var('action_value', 
lang('update'));
+                                       $this->t->fp('action_bloc_handler', 
'action_bloc', True);
+               
+                                       $this->t->set_var('action_field', 
'action');
+                                       $this->t->set_var('action_value', 
lang('delete'));
+                                       $this->t->fp('action_bloc_handler', 
'action_bloc', True);
+                                       
+                                       $i++;
+                                       $this->t->fp('types_bloc_handler', 
'types_bloc', True);
+                               }
+                       }               
+                       
+       
+                       $this->t->set_var('type_desc', 
$this->gen_unplaced_types_select ( $project_root_id, "places[new][type_id]" ));
+                       $this->t->set_var('select', 
$this->gen_subfolder_select($project_root_id,"places[new][element_id]", 0));
+                       $this->t->set_var('project',"<input type=\"hidden\" 
name=\"places[new][project_root]\" value=\"".$project_root_id."\"/>");
+                       
+                       /*
+                        * action add
+                        */
+                       
+                       $this->t->set_var('action_bloc_handler', '');
+                       
+                       $this->t->set_var('action_field', 'action');
+                       $this->t->set_var('action_value', lang('add'));
+                       $this->t->fp('action_bloc_handler', 'action_bloc', 
True);
+       
+       
+                       $this->t->fp('types_bloc_handler', 'types_bloc', True);
+
+                       $this->t->fp('edit_bloc_handler', 'edit_bloc', True);
+               }
+               else
+               {
+                       $this->t->set_var('edit_bloc_handler', lang( "Please 
choose a project"));
+               }
+               
+
                $this->display_app_header();            
 
                $this->t->pfp('out', 'places_tpl');
+
        }
        
 }

Index: templates/base/places.tpl
===================================================================
RCS file: /sources/phpgroupware/ged/templates/base/places.tpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- templates/base/places.tpl   2 Aug 2007 15:34:11 -0000       1.1
+++ templates/base/places.tpl   2 Aug 2007 21:48:57 -0000       1.2
@@ -1 +1,27 @@
 <h1>Places</h1>
\ No newline at end of file
+<h2>Projects</h2>
+<!-- BEGIN projects_bloc -->
+<a href="{project_link}">{project_name}</a><br/>
+<!-- END projects_bloc -->
+<h2>Places for project : {active_project_name}</h2>
+<!-- BEGIN edit_bloc -->
+<table >
+<tr class="head_class">
+<td colspan="2">Type</td>
+<td>Place</td>
+<td colspan="2">actions</td>
+</tr>
+<!-- BEGIN types_bloc -->
+<tr class="{tr_class}">
+<td><form name="doc_types-{type_id_value}" method="POST"></td>
+<td>{project}{type_desc}</td>
+<td>{select}</td>
+<td><!-- BEGIN action_bloc --><input type="submit" name ="{action_field}" 
value="{action_value}"/><!-- END action_bloc --></td>
+<td></form></td>
+</tr>
+<!-- END types_bloc -->
+</table>
+<br/>
+<!-- END edit_bloc -->
+
+<br/>




reply via email to

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