CVSROOT: /sources/phpgroupware Module name: ged Changes by: Pascal Vilarem <maat> 07/10/29 15:41:12
Modified files: inc : class.ged_dm.inc.php class.flows.inc.php class.flow_client.inc.php class.soflows.inc.php class.ged_ui.inc.php templates/base : file.tpl Log message: added : lock status added : update, lock and unlock methods CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.inc.php?cvsroot=phpgroupware&r1=1.51&r2=1.52 http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flows.inc.php?cvsroot=phpgroupware&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flow_client.inc.php?cvsroot=phpgroupware&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.soflows.inc.php?cvsroot=phpgroupware&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_ui.inc.php?cvsroot=phpgroupware&r1=1.49&r2=1.50 http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/file.tpl?cvsroot=phpgroupware&r1=1.11&r2=1.12 Patches: Index: inc/class.ged_dm.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v retrieving revision 1.51 retrieving revision 1.52 diff -u -b -r1.51 -r1.52 --- inc/class.ged_dm.inc.php 27 Oct 2007 09:09:16 -0000 1.51 +++ inc/class.ged_dm.inc.php 29 Oct 2007 15:41:11 -0000 1.52 @@ -274,52 +274,6 @@ } - function set_file_lock($element_id, $lock) - { - - if ( $this->can_change_file_lock($element_id) ) - { - if ( $lock==true ) - { - $lock_value=1; - } - else - { - $lock_value=0; - } - - $sql="UPDATE ged_elements set lock_status=".$lock_value.", lock_user_id=".$GLOBALS['phpgw_info']['user']['account_id']." WHERE element_id=".$element_id; - - $this->db->query($sql, __LINE__, __FILE__); - $this->db->unlock(); - - $version=$this->get_last_version($element_id); - - if ( $lock==true ) - { - $this->store_history ('locked', 'locked', $version['version_id']); - } - else - { - $this->store_history ('unlocked', 'unlocked', $version['version_id']); - } - - } - } - - function is_locked($element_id) - { - $out=false; - $element=$this->get_element_info($element_id); - - if ( $element['lock_status'] == 1 && $element['lock_user_id'] != $GLOBALS['phpgw_info']['user']['account_id']) - { - $out=true; - } - - return ( $out ); - } - function set_project ($element_id, $project_name, $the_root_element_id=null) { if ( $the_root_element_id == null ) @@ -516,8 +470,6 @@ $cur_version=$this->get_current_or_alert_or_refused_version($amended_version['element_id']); $me_version=$this->get_version_info($amended_version['version_id']); - if ( $me_version['status']=='working' ) - { if ( isset($cur_version)) { $major=$cur_version['major']; @@ -589,7 +541,7 @@ $sql_model1.="status='%s', description='%s', major=%d, minor=%d "; $sql_model1.="WHERE version_id=%d"; - $sql1=sprintf($sql_model1, $this->tables['versions'], $amended_version['file_size'], $amended_version['file_name'], $this->cleanstr($candidate_name), $extension, 'working', $this->cleanstr($amended_version['description']), $major, $minor, $amended_version['version_id']); + $sql1=sprintf($sql_model1, $this->tables['versions'], $amended_version['file_size'], $amended_version['file_name'], $this->cleanstr($candidate_name), $extension, $me_version['status'], $this->cleanstr($amended_version['description']), $major, $minor, $amended_version['version_id']); } else { @@ -597,7 +549,7 @@ $sql_model1.="status='%s', description='%s', major=%d, minor=%d "; $sql_model1.="WHERE version_id=%d"; - $sql1=sprintf($sql_model1, $this->tables['versions'], 'working', $this->cleanstr($amended_version['description']), $major, $minor, $amended_version['version_id']); + $sql1=sprintf($sql_model1, $this->tables['versions'], $me_version['status'], $this->cleanstr($amended_version['description']), $major, $minor, $amended_version['version_id']); } $this->db->query($sql1, __LINE__, __FILE__); @@ -614,7 +566,6 @@ { $this->erase_relations($amended_version['version_id']); } - } return "OK"; @@ -745,8 +696,6 @@ $out['creator_id']=$this->db->f('creator_id'); $out['owner_id']=$this->db->f('owner_id'); $out['creation_date']=$this->db->f('creation_date'); - $out['lock_status']=$this->db->f('lock_status'); - $out['lock_user_id']=$this->db->f('lock_user_id'); $out['description']=$this->db->f('description'); $out['validity_period']=$this->db->f('validity_period'); $out['project_name']=$this->db->f('project_name'); @@ -1477,23 +1426,6 @@ return ($result ); } - function can_change_file_lock($element_id) - { - $out=false; - $element=$this->get_element_info($element_id); - - if ( $element['lock_status'] == 0 && $this->can_write($element_id) ) - { - $out=true; - } - elseif ( $element['lock_status'] == 1 && ( $this->admin == true || ($element['lock_user_id'] == $GLOBALS['phpgw_info']['user']['account_id'] && $this->can_write($element_id))) ) - { - $out=true; - } - - return( $out ); - } - function can_change_acl($element_id) { // db2 neededbecause can_read can be called during a $this->db loop; @@ -1617,8 +1549,6 @@ $elements[$i]['creator_id']=$this->db->f('creator_id'); $elements[$i]['owner_id']=$this->db->f('owner_id'); $elements[$i]['creation_date']=$this->db->f('creation_date'); - $elements[$i]['lock_status']=$this->db->f('lock_status'); - $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'); Index: inc/class.flows.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.flows.inc.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- inc/class.flows.inc.php 27 Oct 2007 09:09:16 -0000 1.5 +++ inc/class.flows.inc.php 29 Oct 2007 15:41:11 -0000 1.6 @@ -252,7 +252,11 @@ //déclencher les triggers foreach ($triggers as $trigger) { - if ($trigger['app']==$app ) + if ($trigger['class']=='flows' ) + { + $trigger_object=&$this; + } + elseif ($trigger['app']==$app ) { $trigger_object=&$this->app_flow_client; } @@ -261,6 +265,8 @@ $trigger_object=CreateObject($trigger['app'].'.flow_client', True); } + $trigger['context']['account_id']=$account_id; + $trigger_result=call_user_func(array(&$trigger_object, $trigger['method']),$object,$trigger['context']); //TODO : contrôler le résultat des triggers @@ -357,6 +363,20 @@ } + function grant_role($object,$trigger_context=null) + { + $transition=$trigger_context['transition']; + $account_id=$trigger_context['account_id']; + return ($this->soflows->grant_role($transition,$object,$account_id)); + } + + function remove_role($object,$trigger_context=null) + { + $transition=$trigger_context['transition']; + $account_id=$trigger_context['account_id']; + return ($this->soflows->remove_role($transition,$object,$account_id)); + } + } ?> \ No newline at end of file Index: inc/class.flow_client.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.flow_client.inc.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- inc/class.flow_client.inc.php 27 Oct 2007 09:09:16 -0000 1.6 +++ inc/class.flow_client.inc.php 29 Oct 2007 15:41:12 -0000 1.7 @@ -254,7 +254,7 @@ $function_result=Array('status' => 'ok'); $function_result['comment']="updated file info"; } - elseif ( $update_version==lang('New') ) + elseif ( $context['custom_fields']['update_mode'] == 'new' && $update_version==lang('New') ) { $new_version['element_id']=$version['element_id']; @@ -282,7 +282,7 @@ } } - elseif ($update_version==lang('Update') ) + elseif ($context['custom_fields']['update_mode'] == 'update' && $update_version==lang('Update') ) { $amended_version['element_id']=$version['element_id']; $amended_version['file_name']=$_FILES['version_file']['name']; @@ -333,13 +333,13 @@ $version_description=$version['description']; $version_id=$version['version_id']; - if ( $version_status=='working' ) + if ( $context['custom_fields']['update_mode'] == 'update' ) { // TODO : Guess next version numbers $this->t->set_var('update_version_action', lang('Update')); } - else + elseif ( $context['custom_fields']['update_mode'] == 'new' ) { // TODO : Guess next version numbers Index: inc/class.soflows.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.soflows.inc.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- inc/class.soflows.inc.php 27 Oct 2007 09:09:16 -0000 1.6 +++ inc/class.soflows.inc.php 29 Oct 2007 15:41:12 -0000 1.7 @@ -135,7 +135,7 @@ $sql.="AND ".$sql_context_base; // DEBUG - //print ($sql); + //print ($sql."<br/>"); $this->db->query($sql, __LINE__, __FILE__); @@ -428,6 +428,79 @@ } + function grant_role($transition,$object=null,$account_id=null) + { + if ( ! is_null($object)) + { + if (is_null($account_id)) + { + $the_account_id=$GLOBALS['phpgw_info']['user']['account_id']; + } + else + { + $the_account_id=$account_id; + } + + foreach ( $object as $field => $content ) + { + if ( $field != 'app') + { + $temp_array[$field]=$content; + } + } + + $role_context=serialize($temp_array); + + $sql="INSERT INTO phpgw_flows_roles (transition,account_id,context) VALUES "; + $sql.="('".$transition."',".$the_account_id.",'".$role_context."' )"; + + $this->db->query($sql, __LINE__, __FILE__); + + $result=true; + } + else + { + $result=false; + } + return ($result); + } + + function remove_role($transition,$object=null,$account_id=null) + { + if ( ! is_null($object)) + { + if (is_null($account_id)) + { + $the_account_id=$GLOBALS['phpgw_info']['user']['account_id']; + } + else + { + $the_account_id=$account_id; + } + + foreach ( $object as $field => $content ) + { + if ( $field != 'app') + { + $temp_array[$field]=$content; + } + } + + $role_context=serialize($temp_array); + + $sql="DELETE FROM phpgw_flows_roles WHERE "; + $sql.="transition='".$transition."' AND account_id=".$the_account_id." AND context='".$role_context."'"; + + $this->db->query($sql, __LINE__, __FILE__); + + $result=true; + } + else + { + $result=false; + } + return ($result); + } } Index: inc/class.ged_ui.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.ged_ui.inc.php,v retrieving revision 1.49 retrieving revision 1.50 diff -u -b -r1.49 -r1.50 --- inc/class.ged_ui.inc.php 27 Oct 2007 09:09:16 -0000 1.49 +++ inc/class.ged_ui.inc.php 29 Oct 2007 15:41:12 -0000 1.50 @@ -30,15 +30,11 @@ 'browse'=>true, 'add_file'=>true, 'add_folder'=>true, - 'update_file'=>true, 'update_folder'=>true, 'delete_folder'=>true, 'download'=>true, 'package_download' => true, 'view'=>true, - 'update_file'=>true, - 'lock_file' => true, - 'unlock_file' => true, 'delete_file'=>true, 'change_acl'=>true, 'search' => true, @@ -566,36 +562,6 @@ $element_info=$this->ged_dm->get_element_info($element_id); - $this->t->set_var( 'lock_alert_message', ''); - if ( $this->ged_dm->is_locked($element_id) ) - { - $this->t->set_var( 'lock_alert_message', lang( 'This file is locked by')." ".$GLOBALS['phpgw']->common->grab_owner_name($element_info['lock_user_id'])); - } - - /* - if ( $this->ged_dm->can_write($element_id)) - { - $version_id=get_var('version_id',array('GET','POST')); - if ( $version_id != '' ) - { - $current_version=$this->ged_dm->get_version_info($version_id); - - if ( $current_version['element_id']!=$element_id) - $current_version=$this->ged_dm->get_current_or_alert_or_refused_version($element_id); - - } - else - $current_version=$this->ged_dm->get_current_or_alert_or_refused_version($element_id); - - if ( $current_version['element_id']!=$element_id) - $current_version=$this->ged_dm->get_last_version($element_id); - } - elseif ($this->ged_dm->can_read($element_id)) - { - $current_version=$this->ged_dm->get_current_or_pending_for_acceptation_version($element_id); - } - */ - $current_version=$this->ged_dm->get_version_info($version_id); $this->t->set_var('current_version_status_image', $GLOBALS['phpgw']->common->image('ged', $current_version['status']."-48")); @@ -1023,8 +989,8 @@ 'app' => 'ged', 'project_root' => $focused_element['project_root'], 'doc_type' => $focused_element['doc_type'], - 'element_id' => $focused_id, - 'version_id' => $focused_version['version_id'] + 'element_id' => (int)$focused_id, + 'version_id' => (int)$focused_version['version_id'] ); $flow_actions=$this->flows->get_available_transitions($flow_object); @@ -1053,30 +1019,6 @@ $this->t->set_var('change_acl', "<a href=\"".$update_file_url."\">".lang('Change ACL')."</a>"); } - // TODO : Allow lock only if workflow status allows it - if ($last_version['status'] == 'working' && $this->ged_dm->can_change_file_lock($focused_id) ) - { - $this->t->set_var('lock_file', ''); - - if ( $focused_element['lock_status'] == 0 ) - { - $link_data=null; - $link_data['menuaction']='ged.ged_ui.lock_file'; - $link_data['element_id']=$focused_id; - $lock_file_url=$GLOBALS['phpgw']->link('/index.php', $link_data); - $this->t->set_var('lock_file', "<a href=\"".$lock_file_url."\">".lang('Lock file')."</a>"); - } - elseif( $focused_element['lock_status'] == 1 ) - { - $link_data=null; - $link_data['menuaction']='ged.ged_ui.unlock_file'; - $link_data['element_id']=$focused_id; - $lock_file_url=$GLOBALS['phpgw']->link('/index.php', $link_data); - $this->t->set_var('lock_file', "<a href=\"".$lock_file_url."\"><b>".lang('Unlock file')."</b></a>"); - } - - } - // TODO : droit specifique de delete ? if ( $this->ged_dm->admin ) { @@ -1289,556 +1231,6 @@ } - // New status management : at first status=working - // for new versions - // is a version is already working then it is overrriden - // we can change version type : major / minor and the description - // perhaps consider an "edit" method for all - - // DONE acl here - function update_file() - { - - if ( $this->debug('update_file') ) - print ( "ui_update_file: entering.<br>\n"); - - $element_id=get_var('element_id', array('GET', 'POST')); - - $link_data=null; - $link_data['menuaction']='ged.ged_ui.browse'; - $link_data['focused_id']=$element_id; - - if ( ! $this->ged_dm->can_write($element_id) ) - { - $GLOBALS['phpgw']->redirect_link('/index.php', $link_data); - } - - if ( $this->debug('update_file') ) - print ( "ui_update_file: ok can write.<br>\n"); - - $update_file=get_var('update_file', array('POST', 'GET')); - $file_name=get_var('file_name', array('POST', 'GET')); - $file_description=get_var('file_description', array('POST', 'GET')); - $referenceq=addslashes(get_var('referenceq',array('GET','POST'))); - $doc_type=addslashes(get_var('document_type', array('GET', 'POST'))); - - - $update_version=get_var('update_version', array('POST', 'GET')); - $version_description=get_var('version_description', array('POST', 'GET')); - $version_type=get_var('version_type', array('POST', 'GET')); - - $go_back=get_var('go_back', 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 - // no direct management - // i'll perhaps add an admin option to change manually status - // 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')); - - $this->set_template_defaults(); - - $link_data=null; - $link_data['menuaction']='ged.ged_ui.update_file'; - $this->t->set_var('action_update', $GLOBALS['phpgw']->link('/index.php', $link_data)); - - $this->t->set_var('reset_file_field', 'reset_file'); - $this->t->set_var('reset_file_action', lang('Undo')); - $this->t->set_var('update_file_field', 'update_file'); - $this->t->set_var('update_file_action', lang('Update')); - $this->t->set_var('update_version_field', 'update_version'); - - $this->t->set_var('reset_version_field', 'reset_version'); - $this->t->set_var('reset_version_action', lang('Undo')); - - $this->t->set_var('go_back_field', 'go_back'); - $this->t->set_var('go_back_action', lang('Go back')); - - $this->t->set_var('element_id_field', 'element_id'); - $this->t->set_var('file_name_field', 'file_name'); - - $this->t->set_var('file_description_field', 'file_description'); - $this->t->set_var('version_description_field', 'version_description'); - $this->t->set_var('version_file_field', 'version_file'); - $this->t->set_var('version_type_field', 'version_type'); - - $this->t->set_var('add-image', $GLOBALS['phpgw']->common->image('ged', "add-16")); - $this->t->set_var('remove-image', $GLOBALS['phpgw']->common->image('ged', "remove-16")); - - // New status management system - // Based on aproval in progress - //$this->t->set_var('version_status_field', 'version_status'); - - if ($update_file==lang('Update')) - { - - $new_file['element_id']=$element_id; - - $new_file['name']=$file_name; - $new_file['reference']=$referenceq; - $new_file['doc_type']=$doc_type; - $new_file['description']=$file_description; - $new_file['validity_period']=$validity_period; - - - $this->ged_dm->update_file($new_file); - $file_updated='done'; - - if ($file_updated=='done') - { - $link_data=null; - $link_data['menuaction']='ged.ged_ui.browse'; - $link_data['focused_id']=$element_id; - - $GLOBALS['phpgw']->redirect_link('/index.php', $link_data); - } - - } - elseif ( $update_version==lang('New') ) - { - - $new_version['element_id']=$element_id; - $new_version['file_name']=$_FILES['version_file']['name']; - $new_version['file_size']=$_FILES['version_file']['size']; - $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 - //$new_version['status']=$version_status; - - $new_version['description']=$version_description; - - $version_added=$this->ged_dm->add_version($new_version); - - if ($version_added=='OK') - { - $link_data=null; - $link_data['menuaction']='ged.ged_ui.browse'; - $link_data['focused_id']=$element_id; - - $GLOBALS['phpgw']->redirect_link('/index.php', $link_data); - } - else - { - print ( $version_added); - $this->t->set_var('update_version_action', lang('New')); - } - - } - elseif ($update_version==lang('Update') ) - { - - $amended_version['element_id']=$element_id; - $amended_version['file_name']=$_FILES['version_file']['name']; - $amended_version['file_size']=$_FILES['version_file']['size']; - $amended_version['file_tmp_name']=$_FILES['version_file']['tmp_name']; - $amended_version['file_mime_type']=$_FILES['version_file']['type']; - $amended_version['type']=$version_type; - - // New status management system - // Based on aproval in progress - //$amended_version['status']=$version_status; - - if ( is_array($relations)) - { - $amended_version['relations']=$relations; - } - else - $amended_version['relations']=null; - - $amended_version['description']=$version_description; - $amended_version['version_id']=$version_id; - - $version_updated=$this->ged_dm->update_version($amended_version); - - if ($version_updated=='OK') - { - $link_data=null; - $link_data['menuaction']='ged.ged_ui.browse'; - $link_data['focused_id']=$element_id; - - $GLOBALS['phpgw']->redirect_link('/index.php', $link_data); - } - else - print ( $version_updated); - - - } - elseif ( $go_back == lang('Go back')) - { - $link_data=null; - $link_data['menuaction']='ged.ged_ui.browse'; - $link_data['focused_id']=$element_id; - - $GLOBALS['phpgw']->redirect_link('/index.php', $link_data); - } - else - { - $focused_element=$this->ged_dm->get_element_info($element_id); - $file_name=$focused_element['name']; - $file_description=$focused_element['description']; - $validity_period=$focused_element['validity_period']; - $referenceq=$focused_element['reference']; - $doc_type=$focused_element['doc_type']; - - $last_version=$this->ged_dm->get_last_version($element_id); - - $version_status=$last_version['status']; - - // New status management system - // Based on aproval in progress - // TODO : A revoir complètement la gestion des status - - if ( $version_status=='working' ) - { - $version_status=$last_version['status']; - $version_description=$last_version['description']; - $version_id=$last_version['version_id']; - - $current_version=$this->ged_dm->get_current_version($element_id); - - $version_major=$current_version['major']-$last_version['major']; - $version_minor=$current_version['minor']-$last_version['minor']; - - - if ( $version_major !=0 ) - $version_type='major'; - elseif ( $version_minor !=0 ) - $version_type='minor'; - - // Relations management on existing working version - - $this->t->set_var('update_version_action', lang('Update')); - } - else - { - // Cetait la [HOP1] - - $this->t->set_var('update_version_action', lang('New')); - $version_type='minor'; - $version_status='working'; - - } - - - - - // Now c'est la [HOP1] - - if ( ( $search=="search" || $do_add_relation != '' || $do_remove_relation != '' ) && $query != '' ) - { - $search_results=$this->ged_dm->search($query); - } - - if ( is_array($relations) || $search=="search" || $do_add_relation != '' || $do_remove_relation != '' ) - { - // 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_out ( $last_version['version_id'] ); - //_debug_array($version_relations); - } - - 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']=='refused' ) - { - // print ( 'new version : '.$version_relation['version_id']."<br/>\n"); - - // TODO : prepare data for future relation creation - $the_new_relations=$this->ged_dm->get_current_version($version_relation['element_id']); - - $new_relations[$nri]['linked_version_id']=$the_new_relations['version_id']; - $new_relations[$nri]['reference']=$version_relation['reference']; - $new_relations[$nri]['name']=$version_relation['name']; - $new_relations[$nri]['major']=$the_new_relations['major']; - $new_relations[$nri]['minor']=$the_new_relations['minor']; - $new_relations[$nri]['status']=$the_new_relations['status']; - - - $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_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); - $this->t->set_var('file_name_value', $file_name); - - $this->t->set_block('update_file_tpl', 'power_block', 'power_block_handle'); - - // Begin power_block zone - if ( $this->ged_dm->admin ) - { - - $this->t->set_var('new_reference', $referenceq); - - $select_types=$this->ged_dm->list_doc_types (); - - $select_types_html="<select name=\"document_type\">\n"; - foreach ($select_types as $select_type) - { - $selected=""; - if ($select_type['type_id'] == $doc_type ) - { - $selected=" selected "; - } - - $chrono_flag=$style=""; - if ( $select_type['type_chrono']==1) - { - $chrono_flag=" [C]"; - $style="style=\"font-weight: bold;\""; - } - $select_types_html.="<option ".$style." value=\"".$select_type['type_id']."\"".$selected.">".lang($select_type['type_desc']).$chrono_flag."</option>\n"; - } - $select_types_html.="</select>\n"; - - $this->t->set_var('select_type', $select_types_html); - $this->t->fp('power_block_handle', 'power_block', True); - // End power_block zone - } - else - { - $this->t->set_var( 'power_block_handle', ""); - } - - $select_periods=$this->ged_dm->select_periods (); - - $select_period_html='<select name="validity_period">\n'; - foreach ($select_periods as $select_period) - { - if ($select_period['period']==$validity_period ) - { - $select_period_html.="<option value=\"".$select_period['period']."\" selected>".lang($select_period['description'])."</option>\n"; - } - else - { - $select_period_html.="<option value=\"".$select_period['period']."\">".lang($select_period['description'])."</option>\n"; - } - } - $select_period_html.="</select>\n"; - - $this->t->set_var('select_period', $select_period_html); - - - /*version*/ - $this->t->set_var('version_id_field', 'version_id'); - $this->t->set_var('version_id_value', $version_id); - $this->t->set_var('version_description_value', $version_description); - - /* type et status */ - $this->t->set_block('update_file_tpl', 'version_type_block', 'version_type_block_handle'); - $temp_types=Array('major', 'minor'); - foreach ( $temp_types as $temp_type ) - { - $this->t->set_var('version_type_label', lang($temp_type)); - $this->t->set_var('version_type_value',$temp_type); - - if ( $version_type==$temp_type ) - $this->t->set_var('version_type_checked', 'checked'); - else - $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'); - - $this->display_app_header(); - - $this->t->pfp('out', 'update_file_tpl'); - - if ( $this->debug('update_file') ) - print ( "ui_update_file: end.<br>\n"); - - - } - - function lock_file() - { - $element_id=get_var('element_id', array('GET', 'POST')); - - $this->ged_dm->set_file_lock($element_id, true); - - $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 unlock_file() - { - $element_id=get_var('element_id', array('GET', 'POST')); - - $this->ged_dm->set_file_lock($element_id, false); - - $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 delete_file() { @@ -2305,8 +1697,8 @@ 'app' => 'ged', 'project_root' => $element['project_root'], 'doc_type' => $element['doc_type'], - 'element_id' => $element_id, - 'version_id' => $version_id + 'element_id' => (int)$element_id, + 'version_id' => (int)$version_id ); $do_transition_result=$this->flows->do_transition($transition, $flow_object); Index: templates/base/file.tpl =================================================================== RCS file: /sources/phpgroupware/ged/templates/base/file.tpl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -b -r1.11 -r1.12 --- templates/base/file.tpl 31 Jul 2007 17:02:11 -0000 1.11 +++ templates/base/file.tpl 29 Oct 2007 15:41:12 -0000 1.12 @@ -1,6 +1,5 @@ <div style="float: right"><img src="{current_version_status_image}"/></div> <div class="ged_title">{name} [{reference}] v{current_version}</div> -<div class="alert_message">{lock_alert_message}</div> <div class="ged_file_description">{description}<br/> {current_version_description}</div> <div class="ged_file_metadata">Owned by : {owner} - Creation : {creation_date} - Version : {current_version_date} by {current_version_creator} - _______________________________________________ phpGroupWare-cvs mailing list phpGroupWare-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs