[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] ged inc/class.ged_dm.inc.php inc/class.flow_cli...
From: |
Pascal Vilarem |
Subject: |
[Phpgroupware-cvs] ged inc/class.ged_dm.inc.php inc/class.flow_cli... |
Date: |
Fri, 09 Nov 2007 15:15:18 +0000 |
CVSROOT: /sources/phpgroupware
Module name: ged
Changes by: Pascal Vilarem <maat> 07/11/09 15:15:18
Modified files:
inc : class.ged_dm.inc.php class.flow_client.inc.php
class.ged_ui.inc.php
templates/base : stats.tpl
Log message:
made simpler : version management
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.inc.php?cvsroot=phpgroupware&r1=1.55&r2=1.56
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flow_client.inc.php?cvsroot=phpgroupware&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_ui.inc.php?cvsroot=phpgroupware&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/stats.tpl?cvsroot=phpgroupware&r1=1.3&r2=1.4
Patches:
Index: inc/class.ged_dm.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- inc/class.ged_dm.inc.php 6 Nov 2007 17:26:41 -0000 1.55
+++ inc/class.ged_dm.inc.php 9 Nov 2007 15:15:17 -0000 1.56
@@ -12,7 +12,7 @@
***************************************************************************/
$GLOBALS['debug']["ged.ged_dm"] = false;
-$GLOBALS['debug']["ged.ged_dm.list_versions"] = true;
+$GLOBALS['debug']["ged.ged_dm.get_previous_version"] = true;
class ged_dm
{
@@ -430,25 +430,19 @@
if ( $this->debug('add_version') )
print ( "add_version: entering.<br>\n");
- // MEMO gestion des numeros de versions
-
-
$current_or_alert_or_refused_version=$this->get_current_or_alert_or_refused_version($new_version['element_id']);
- $major=$current_or_alert_or_refused_version['major'];
- $minor=$current_or_alert_or_refused_version['minor'];
$last_version=$this->get_last_version($new_version['element_id']);
- if ($last_version['status'] == 'current' ||
$last_version['status'] == 'refused' || $last_version['status'] == 'alert' )
- {
- if ($new_version['type']=='major')
+ // MEMO gestion des numeros de versions
+ $major=$new_version['major'];
+ $minor=$new_version['minor'];
+
+ if ( $major < $last_version['major'] || $major ==
$last_version['major'] && $minor < $last_version['minor'] )
{
- $major++;
- $minor=0;
+ $major=$last_version['major'];
+ $minor=$last_version['minor']+1;
}
- elseif ($new_version['type']=='minor') $minor ++;
- else
- return "PB Version";
- // MEMO gestion du stored_name pour �viter les
�crasements.
+ // MEMO gestion du stored_name pour eviter les ecrasements.
$basename=basename($new_version['file_name']);
$candidate_name=$basename;
@@ -511,44 +505,36 @@
print ( "add_version: end.<br>\n");
return "OK";
- }
}
function update_version($amended_version)
{
- // MEMO gestion des numeros de versions
-
-
$cur_version=$this->get_current_or_alert_or_refused_version($amended_version['element_id']);
$me_version=$this->get_version_info($amended_version['version_id']);
+
$first_version=$this->get_first_version($amended_version['element_id']);
- if ( isset($cur_version))
- {
- $major=$cur_version['major'];
- $minor=$cur_version['minor'];
+ // MEMO gestion des numeros de versions
+ $major=$amended_version['major'];
+ $minor=$amended_version['minor'];
- if ($amended_version['type']=='major')
+ if ( $me_version['version_id'] != $first_version['version_id'] )
{
- $major++;
- $minor=0;
- }
- elseif ($amended_version['type']=='minor')
- {
- $minor ++;
- }
- else
+
+
$previous_version=$this->get_previous_version($amended_version['version_id']);
+
+ //DEBUG
+ //_debug_array($previous_version);
+ //die();
+
+ if ( $major < $previous_version['major'] || ($major ==
$previous_version['major'] && $minor <= $previous_version['minor']))
{
- return "PB Version";
- }
+ $major=$previous_version['major'];
+ $minor=$previous_version['minor']+1;
}
- else
- {
- $major=$me_version['major'];
- $minor=$me_version['minor'];
}
- // MEMO gestion du stored_name pour �viter les �crasements.
+ // MEMO gestion du stored_name pour eviter les ecrasements.
if ($amended_version['file_name'] !="")
{
@@ -808,6 +794,66 @@
}
+ function get_first_version($element_id)
+ {
+ if ( $this->debug('get_first_version') )
+ print ( "get_last_version: entering with
element_id=".$element_id."<br>\n");
+
+ if ( ! $this->can_read($element_id))
+ die("argh");
+
+ if ( isset($this->acl[$element_id]['statuses']) &&
is_array($this->acl[$element_id]['statuses']))
+ {
+ $or='';
+ $sqlstatuses="AND (";
+ foreach ( $this->acl[$element_id]['statuses'] as
$granted_status)
+ {
+ $sqlstatuses.=$or."status='".$granted_status."'
";
+ $or="OR ";
+ }
+ $sqlstatuses.=") ";
+ }
+ else
+ {
+ $sqlstatuses='';
+ }
+
+ $sql="SELECT * FROM ".$this->tables['versions']." ";
+ $sql.="WHERE element_id=".$element_id." ".$sqlstatuses;
+ $sql.="ORDER BY version_id ASC LIMIT 1";
+
+ if ( $this->debug('get_element_acl') )
+ print ( "get_last_version: ".$sql."<br>\n");
+
+ $this->db->query($sql, __LINE__, __FILE__);
+
+ if ($this->db->next_record());
+ {
+ $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['validation_date']=$this->db->f('validation_date');
+ }
+
+ $this->db->unlock();
+
+
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+
+ return $version;
+
+ }
+
function get_last_version($element_id)
{
if ( $this->debug('get_last_version') )
@@ -865,6 +911,54 @@
$version['mime_type']=$this->get_mime_type($version['file_extension']);
return $version;
+ }
+
+ function get_previous_version($version_id)
+ {
+ if ( $this->debug('get_previous_version') )
+ print ( "get_previous_version: entering with
version_id=".$version_id."<br>\n");
+
+ $sql="SELECT version2.* FROM ".$this->tables['versions']."
version2 ";
+ $sql.="INNER JOIN ".$this->tables['versions']." version1 ";
+ $sql.="ON version1.element_id=version2.element_id ";
+ $sql.="WHERE version1.version_id=".$version_id." ";
+ $sql.="AND version2.version_id < ". $version_id." " ;
+ $sql.="ORDER BY version2.version_id DESC LIMIT 1";
+
+ if ( $this->debug('get_previous_version') )
+ print ( "get_previous_version: ".$sql."<br>\n");
+
+ $this->db->query($sql, __LINE__, __FILE__);
+
+ if ($this->db->next_record());
+ {
+ $element_id=$this->db->f('element_id');
+
+ $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']=$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['validation_date']=$this->db->f('validation_date');
+ }
+
+ $this->db->unlock();
+
+ if ( ! $this->can_read($element_id))
+ die("argh");
+
+
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+
+ return $version;
}
Index: inc/class.flow_client.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.flow_client.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- inc/class.flow_client.inc.php 6 Nov 2007 17:26:41 -0000 1.8
+++ inc/class.flow_client.inc.php 9 Nov 2007 15:15:17 -0000 1.9
@@ -45,6 +45,16 @@
}
}
+ function load_template_defaults()
+ {
+ $this->t->set_var('lang_name', lang('name'));
+ $this->t->set_var('lang_type', lang('type'));
+ $this->t->set_var('lang_reference', lang('reference'));
+ $this->t->set_var('lang_description',
lang('description'));
+ $this->t->set_var('lang_period', lang('lifetime'));
+ $this->t->set_var('lang_version', lang('version'));
+ }
+
function display_app_header()
{
$GLOBALS['phpgw']->common->phpgw_header();
@@ -228,6 +238,8 @@
// needed for 'update_version' action
$new_version_description=get_var('version_description',
array('POST', 'GET'));
+ $new_major_value=get_var('major', array('POST', 'GET'));
+ $new_minor_value=get_var('minor', array('POST', 'GET'));
// TODO : version numbering
$new_version_type=get_var('version_type', array('POST',
'GET'));
@@ -265,7 +277,8 @@
$new_version['relations']=$new_relations;
// TODO : version numbering
- $new_version['type']='major';
+ $new_version['major']=$new_major_value;
+ $new_version['minor']=$new_minor_value;
$new_version['description']=$new_version_description;
@@ -291,7 +304,8 @@
$amended_version['file_mime_type']=$_FILES['version_file']['type'];
// TODO : version numbering
- $amended_version['type']='major';
+ $amended_version['major']=$new_major_value;
+ $amended_version['minor']=$new_minor_value;
if ( is_array($new_relations))
{
@@ -472,6 +486,7 @@
{
$this->t->set_file(array('update_file_tpl'=>'update_file.tpl'));
+ $this->load_template_defaults();
$this->display_app_header();
$this->t->set_var('element_id_value',
$object['element_id']);
@@ -499,6 +514,11 @@
$this->t->set_var('element_id_field',
'element_id');
$this->t->set_var('file_name_field',
'file_name');
+ $this->t->set_var('major_field', 'major');
+ $this->t->set_var('minor_field', 'minor');
+ $this->t->set_var('major_value', 1);
+ $this->t->set_var('minor_value', 0);
+
$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');
@@ -578,21 +598,7 @@
$this->t->set_var('version_id_value',
$object['version_id']);
$this->t->set_var('version_description_value',
$version_description);
- /* type and 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);
- }
+ // TODO : versions numbers
$this->t->set_block('update_file_tpl',
'relations_list_block', 'relations_list_block_handle');
Index: inc/class.ged_ui.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_ui.inc.php,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- inc/class.ged_ui.inc.php 6 Nov 2007 17:26:41 -0000 1.52
+++ inc/class.ged_ui.inc.php 9 Nov 2007 15:15:17 -0000 1.53
@@ -950,6 +950,15 @@
$last_version=$this->ged_dm->get_last_version($focused_id);
+ if ( empty($last_version['element_id']) )
+ {
+ $link_data=null;
+
$link_data['menuaction']='ged.ged_ui.browse';
+
$link_data['focused_id']=$focused_element['parent_id'];
+
+
$GLOBALS['phpgw']->redirect_link('/index.php', $link_data);
+ }
+
if ($focused_version_id != 0)
{
$focused_version=$this->ged_dm->get_version_info($focused_version_id);
@@ -1077,7 +1086,7 @@
break;
}
- if ( isset ($focused_element['project_root']) &&
$focused_element['project_root'] != 0)
+ if ( isset ($focused_element['project_root']) &&
$focused_element['project_root'] != 0 &&
$this->ged_dm->can_change_acl($focused_element['project_root']))
{
$link_data=null;
$link_data['menuaction']='ged.ged_ui.chrono';
Index: templates/base/stats.tpl
===================================================================
RCS file: /sources/phpgroupware/ged/templates/base/stats.tpl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- templates/base/stats.tpl 17 Jul 2007 12:54:29 -0000 1.3
+++ templates/base/stats.tpl 9 Nov 2007 15:15:18 -0000 1.4
@@ -12,6 +12,7 @@
</form>
<!-- BEGIN ged_projects -->
<h2>Project : {project_name}</h3>
+<img src="{test_graph_link}" />
<h3>Documents delivered during period : {count_delivered}</h2>
<table cellspacing="0" cellpadding="0" width="70%">
<!-- BEGIN delivered_block -->
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] ged inc/class.ged_dm.inc.php inc/class.flow_cli...,
Pascal Vilarem <=