[Top][All Lists]
[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.php
From: |
Pascal Vilarem |
Subject: |
[Phpgroupware-cvs] ged/inc class.ged_ui.inc.php class.ged_dm.inc.php |
Date: |
Thu, 08 Mar 2007 14:15:27 +0000 |
CVSROOT: /sources/phpgroupware
Module name: ged
Changes by: Pascal Vilarem <maat> 07/03/08 14:15:25
Modified files:
inc : class.ged_ui.inc.php class.ged_dm.inc.php
Log message:
more debug things and few correction to make ged work again with head.
New status management in progress.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_ui.inc.php?cvsroot=phpgroupware&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.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.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- class.ged_ui.inc.php 7 Mar 2007 18:01:07 -0000 1.8
+++ class.ged_ui.inc.php 8 Mar 2007 14:15:25 -0000 1.9
@@ -11,6 +11,8 @@
* option) any later version
***************************************************************************/
+$GLOBALS['debug']["ged.ged_ui"]=false;
+
class ged_ui
{
var $t;
@@ -20,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, 'css'=>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 );
var $icons;
@@ -90,31 +92,25 @@
function debug ($thefunction)
{
- if ( ! isset($GLOBALS['debug']))
+ if ( ! array_key_exists('debug', $GLOBALS))
$GLOBALS['debug']=Array();
- if ( ! isset($GLOBALS['debug']['all']))
- $GLOBALS['debug']=false;
-
- if ( ! isset($GLOBALS['debug']['all']))
- $GLOBALS['debug']=false;
+ if ( !array_key_exists('all', $GLOBALS['debug']))
+ $GLOBALS['debug']['all']=false;
- if ( $GLOBALS['debug']["ged.".get_class($this)] )
+ if ( !array_key_exists ("ged.".get_class($this),
$GLOBALS['debug']) )
$GLOBALS['debug']["ged.".get_class($this)]=false;
- if (
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction] )
-
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction];
+ if ( !array_key_exists
("ged.".get_class($this).".".$thefunction, $GLOBALS['debug']))
+
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction]=false;
if ( $GLOBALS['debug']['all'] ||
$GLOBALS['debug']["ged.".get_class($this)] ||
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction])
{
$GLOBALS['debug']['show']=true;
return true;
}
- }
-
- function css ()
- {
- return "";
+ else
+ return false;
}
function truncate ( $label, $size=30 )
@@ -907,6 +903,10 @@
// TODO acl here DONE
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;
@@ -918,17 +918,23 @@
$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('GET', 'POST'));
- $file_name=get_var('file_name', array('GET', 'POST'));
- $file_description=get_var('file_description', array('GET',
'POST'));
-
- $update_version=get_var('update_version', array('GET', 'POST'));
- $version_description=get_var('version_description',
array('GET', 'POST'));
- $version_type=get_var('version_type', array('GET', 'POST'));
- $version_status=get_var('version_status', array('GET', 'POST'));
- $version_id=get_var('version_id', array('GET', 'POST'));
- $validity_period=get_var('validity_period', array('GET',
'POST'));
+ $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'));
+
+ $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'));
+
+ // New status management system
+ // Based on aproval in progress
+ //$version_status=get_var('version_status', 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();
@@ -951,8 +957,10 @@
$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('version_status_field', 'version_status');
+ // New status management system
+ // Based on aproval in progress
+ //$this->t->set_var('version_status_field', 'version_status');
if ($update_file==lang('Update'))
{
@@ -986,7 +994,11 @@
$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['status']=$version_status;
+
+ // 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);
@@ -1013,7 +1025,11 @@
$amended_version['file_tmp_name']=$_FILES['version_file']['tmp_name'];
$amended_version['file_mime_type']=$_FILES['version_file']['type'];
$amended_version['type']=$version_type;
- $amended_version['status']=$version_status;
+
+ // New status management system
+ // Based on aproval in progress
+ //$amended_version['status']=$version_status;
+
$amended_version['description']=$version_description;
$amended_version['version_id']=$version_id;
@@ -1043,6 +1059,10 @@
$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'];
@@ -1122,28 +1142,35 @@
}
- $this->t->set_block('update_file_tpl', 'version_status_block',
'version_status_block_handle');
- $temp_statuses=Array('working', 'current');
- foreach ( $temp_statuses as $temp_status )
- {
- $this->t->set_var('version_status_label', lang($temp_status));
- $this->t->set_var('version_status_value',$temp_status);
-
- if ( $version_status==$temp_status )
- $this->t->set_var('version_status_checked', 'checked');
- else
- $this->t->set_var('version_status_checked', '');
+ // New status management system
+ // Based on aproval in progress
-
- $this->t->fp('version_status_block_handle', 'version_status_block',
True);
-
- }
+ //$this->t->set_block('update_file_tpl', 'version_status_block',
'version_status_block_handle');
+ //$temp_statuses=Array('working', 'current');
+ //foreach ( $temp_statuses as $temp_status )
+ //{
+ // $this->t->set_var('version_status_label', lang($temp_status));
+ // $this->t->set_var('version_status_value',$temp_status);
+ //
+ // if ( $version_status==$temp_status )
+ // $this->t->set_var('version_status_checked', 'checked');
+ // else
+ // $this->t->set_var('version_status_checked', '');
+ //
+ //
+ // $this->t->fp('version_status_block_handle', 'version_status_block',
True);
+ //
+ //}
$this->display_app_header();
$this->t->pfp('out', 'update_file_tpl');
+ if ( $this->debug('update_file') )
+ print ( "ui_update_file: end.<br>\n");
+
+
}
function delete_file()
@@ -1467,6 +1494,7 @@
if ( $ac['changeacl']=='on' )
$changeacl=1;
+ if ( isset ($ac['recursive']))
if ( $ac['recursive']=='on' )
$recursive=true;
Index: class.ged_dm.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- class.ged_dm.inc.php 7 Mar 2007 18:00:16 -0000 1.5
+++ class.ged_dm.inc.php 8 Mar 2007 14:15:25 -0000 1.6
@@ -77,26 +77,25 @@
function debug ($thefunction)
{
- if ( ! isset($GLOBALS['debug']))
+ if ( ! array_key_exists('debug', $GLOBALS))
$GLOBALS['debug']=Array();
- if ( ! isset($GLOBALS['debug']['all']))
- $GLOBALS['debug']=false;
+ if ( !array_key_exists('all', $GLOBALS['debug']))
+ $GLOBALS['debug']['all']=false;
- if ( ! isset($GLOBALS['debug']['all']))
- $GLOBALS['debug']=false;
-
- if ( $GLOBALS['debug']["ged.".get_class($this)] )
+ if ( !array_key_exists ("ged.".get_class($this),
$GLOBALS['debug']) )
$GLOBALS['debug']["ged.".get_class($this)]=false;
- if (
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction] )
-
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction];
+ if ( !array_key_exists
("ged.".get_class($this).".".$thefunction, $GLOBALS['debug']))
+
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction]=false;
if ( $GLOBALS['debug']['all'] ||
$GLOBALS['debug']["ged.".get_class($this)] ||
$GLOBALS['debug']["ged.".get_class($this).".".$thefunction])
{
$GLOBALS['debug']['show']=true;
return true;
}
+ else
+ return false;
}
function get_file_extention($filename)
@@ -152,7 +151,7 @@
//print ($sql);
$this->db->query($sql, __LINE__, __FILE__);
- //r�cup�rer l'id
+ //recuperer l'id
$new_element_id=$this->db->get_last_insert_id($this->tables['elements'],
'element_id');
$this->db->unlock();
@@ -162,7 +161,7 @@
$sql_model1="INSERT INTO %s ( size, file_name,
stored_name, file_extension, creator_id, creation_date, status, element_id,
description, major, minor ) VALUES ";
$sql_model1.=" ( %d, '%s', '%s', '%s', %d, %d, '%s',
%d, '%s', %d, %d ) ";
- $sql1=sprintf($sql_model1, $this->tables['versions'],
$new_file['file_size'], $new_file['file_name'], $candidate_name, $extension,
$GLOBALS['phpgw_info']['user']['account_id'], time(), 'current',
$new_element_id, lang("First version"), 1, 0);
+ $sql1=sprintf($sql_model1, $this->tables['versions'],
$new_file['file_size'], $new_file['file_name'], $candidate_name, $extension,
$GLOBALS['phpgw_info']['user']['account_id'], time(), 'current',
$new_element_id, lang("First version"), 0, 1);
//print ("<br/>".$sql1);
@@ -257,6 +256,8 @@
function add_version($new_version)
{
+ if ( $this->debug('add_version') )
+ print ( "add_version: entering.<br>\n");
// MEMO gestion des numeros de versions
@@ -307,7 +308,7 @@
$sql_model1="INSERT INTO %s ( size, file_name,
stored_name, file_extension, creator_id, creation_date, status, element_id,
description, major, minor ) VALUES ";
$sql_model1.=" ( %d, '%s', '%s', '%s', %d, %d, '%s',
%d, '%s', %d, %d ) ";
- $sql1=sprintf($sql_model1, $this->tables['versions'],
$new_version['file_size'], $new_version['file_name'], $candidate_name,
$extension, $GLOBALS['phpgw_info']['user']['account_id'], time(),
$new_version['status'], $new_version['element_id'],
$new_version['description'], $major, $minor);
+ $sql1=sprintf($sql_model1, $this->tables['versions'],
$new_version['file_size'], $new_version['file_name'], $candidate_name,
$extension, $GLOBALS['phpgw_info']['user']['account_id'], time(), 'working',
$new_version['element_id'], $new_version['description'], $major, $minor);
//print ("<br/>".$sql1);
@@ -326,6 +327,8 @@
}
+ if ( $this->debug('add_version') )
+ print ( "add_version: end.<br>\n");
return "OK";
@@ -394,7 +397,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'], $candidate_name,
$extension, $amended_version['status'], $amended_version['description'],
$major, $minor, $amended_version['version_id']);
+ $sql1=sprintf($sql_model1, $this->tables['versions'],
$amended_version['file_size'], $amended_version['file_name'], $candidate_name,
$extension, 'working', $amended_version['description'], $major, $minor,
$amended_version['version_id']);
}
else
{
@@ -402,21 +405,24 @@
$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['status'], $amended_version['description'], $major, $minor,
$amended_version['version_id']);
+ $sql1=sprintf($sql_model1, $this->tables['versions'],
'working', $amended_version['description'], $major, $minor,
$amended_version['version_id']);
}
$this->db->query($sql1, __LINE__, __FILE__);
$this->db->unlock();
- if ($amended_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']);
+ // New status management system
+ // Based on aproval in progress
- $this->db->query($sql2, __LINE__, __FILE__);
- $this->db->unlock();
+ //if ($amended_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']);
- }
+ // $this->db->query($sql2, __LINE__, __FILE__);
+ // $this->db->unlock();
+
+ //}
return "OK";
@@ -504,13 +510,14 @@
$version['file_name']=$this->db->f('file_name');
$version['stored_name']=$this->db->f('stored_name');
$version['major']=$this->db->f('major');
-
$version['mime_type']=$this->get_mime_type($version['file_extension']);
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
-
}
$this->db->unlock();
+
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+
+
return $version;
}
@@ -545,20 +552,21 @@
$version['file_name']=$this->db->f('file_name');
$version['stored_name']=$this->db->f('stored_name');
$version['major']=$this->db->f('major');
-
$version['mime_type']=$this->get_mime_type($version['file_extension']);
$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_current_version($element_id)
{
- if ( $this->debug('get_element_acl') )
+ if ( $this->debug('get_current_version') )
print ( "get_current_version: entering with
element_id=".$element_id."<br>\n");
$sql="SELECT * FROM ".$this->tables['versions']." ";
@@ -566,7 +574,7 @@
$sql.="AND status='current' ";
$sql.="ORDER BY version_id DESC LIMIT 1";
- if ( $this->debug('get_element_acl') )
+ if ( $this->debug('get_current_version') )
print ( "get_current_version: ".$sql."<br>\n");
//print ("<pre>");
@@ -593,16 +601,63 @@
$version['file_name']=$this->db->f('file_name');
$version['stored_name']=$this->db->f('stored_name');
$version['major']=$this->db->f('major');
-
$version['mime_type']=$this->get_mime_type($version['file_extension']);
$version['file_full_path']=$this->datadir.'/'.$version['stored_name'];
+
+
$version['mime_type']=$this->get_mime_type($version['file_extension']);
+
}
$this->db->unlock();
- //$this->db->Debug=false;
-
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_parent_id($item_id)
@@ -842,18 +897,20 @@
$versions[$ii]['file_extension']=$this->db->f('file_extension');
$versions[$ii]['file_name']=$this->db->f('file_name');
$versions[$ii]['stored_name']=$this->db->f('stored_name');
-
$versions[$ii]['mime_type']=$this->get_mime_type($versions[$ii]['file_extension']);
$versions[$ii]['file_full_path']=$this->datadir.'/'.$versions[$ii]['stored_name'];
$versions[$ii]['validation_date']=$this->db->f('validation_date');
$ii++;
}
+ for ( $jj=0;$jj< $ii; $jj++)
+
$versions[$jj]['mime_type']=$this->get_mime_type($versions[$jj]['file_extension']);
+
$this->db->unlock();
}
else
{
- $versions[$ii]=$this->get_current_version($element_id);
+ $versions[0]=$this->get_current_version($element_id);
}
if ( $this->debug('list_version') )
@@ -867,10 +924,13 @@
if ( $this->debug('get_mime_type') )
print ("get_mime_type: debut<br/>\n");
- $sql_model="SELECT mime_type FROM %s WHERE file_extension='%s'
";
+ $sql_model="SELECT mime_type FROM %s WHERE
file_extension='%s';";
$sql=sprintf($sql_model, $this->tables['mimetypes'],
$file_extension);
+ if ( $this->debug('get_mime_type') )
+ print ("get_mime_type: ".$sql."<br/>\n");
+
$this->db->query($sql, __LINE__, __FILE__);
if ($this->db->next_record())
@@ -878,6 +938,9 @@
else
$out="default";
+ if ( $this->debug('get_mime_type') )
+ print ("get_mime_type: ".$out."<br/>\n");
+
return $out;
}
@@ -1263,10 +1326,20 @@
function approve_file ( $element_id )
{
$current_version=$this->get_current_version($element_id);
+
$working_version=$this->get_working_version($element_id);
- $sql="UPDATE ged_versions set
`validation_date`=".time()." WHERE version_id=".$current_version['version_id'];
+ if (is_array($current_version) )
+ {
+ $sql="UPDATE ged_versions set
`status`='obsolete' WHERE version_id=".$current_version['version_id'];
+ $this->db->query($sql, __LINE__, __FILE__);
+ }
+ if (is_array($working_version) )
+ {
+ $sql="UPDATE ged_versions set
`status`='current', `validation_date`=".time()." WHERE
version_id=".$working_version['version_id'];
$this->db->query($sql, __LINE__, __FILE__);
+ }
+
$this->db->unlock();
- [Phpgroupware-cvs] ged/inc class.ged_ui.inc.php class.ged_dm.inc.php,
Pascal Vilarem <=