CVSROOT: /sources/phpgroupware
Module name: ged
Changes by: Pascal Vilarem <maat> 07/08/01 17:28:49
Modified files:
inc : class.ged_dm.inc.php class.ged_ui.inc.php
setup : tables_update.inc.php setup.inc.php
tables_current.inc.php
Added files:
templates/base : refuse_file.tpl reject_file.tpl
Log message:
added : automatic insert of comment file and reason for reject and
refuse actions
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/refuse_file.tpl?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/ged/templates/base/reject_file.tpl?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_dm.inc.php?cvsroot=phpgroupware&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.ged_ui.inc.php?cvsroot=phpgroupware&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/ged/setup/tables_update.inc.php?cvsroot=phpgroupware&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/ged/setup/setup.inc.php?cvsroot=phpgroupware&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/ged/setup/tables_current.inc.php?cvsroot=phpgroupware&r1=1.7&r2=1.8
Patches:
Index: inc/class.ged_dm.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_dm.inc.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- inc/class.ged_dm.inc.php 31 Jul 2007 17:02:11 -0000 1.38
+++ inc/class.ged_dm.inc.php 1 Aug 2007 17:28:49 -0000 1.39
@@ -62,6 +62,10 @@
// TODO a g�rer via le (futur) hook d'admin
$this->datadir=$GLOBALS['phpgw_info']['server']['files_dir']."/ged-data";
+ // TODO : find a better way to know what doc type
+ // TODO : should be used for comments ( cf reject and refuse
actions )
+ $this->comment_file_type='fiche-relecture';
+
if ( ! is_dir ( $this->datadir ))
mkdir ( $this->datadir);
@@ -585,11 +589,32 @@
// Gestion des relations
if ( is_array($amended_version['relations']))
{
+
$this->set_relations($amended_version['version_id'],$amended_version['relations']);
+ }
+ else
+ {
+
$this->erase_relations($amended_version['version_id']);
+ }
+ }
+
+ return "OK";
+
+ }
+
+ function erase_relations($version_id)
+ {
+ $sql="DELETE FROM ".$this->tables['relations']." where
linking_version_id=".$version_id;
+ $this->db->query($sql, __LINE__, __FILE__);
+ $this->db->unlock();
+ }
+
+ function set_relations($version_id,$relations)
+ {
// Enlever les relations en trop
- $sql="DELETE FROM
".$this->tables['relations']." where
linking_version_id=".$amended_version['version_id']." ";
+ $sql="DELETE FROM ".$this->tables['relations']." where
linking_version_id=".$version_id." ";
$sql.=" AND ( ";
$_and='';
- foreach ( $amended_version['relations'] as
$relation )
+ foreach ( $relations as $relation )
{
$sql.=$_and."linked_version_id
!=".$relation['linked_version_id']." ";
$_and='AND ';
@@ -601,10 +626,10 @@
// Mettre à jour les existantes
// Ou insérer les nouvelles
- foreach ( $amended_version['relations'] as
$relation )
+ foreach ( $relations as $relation )
{
$sql="SELECT * FROM
".$this->tables['relations']." ";
- $sql.="WHERE
linking_version_id=".$amended_version['version_id']." ";
+ $sql.="WHERE linking_version_id=".$version_id." ";
$sql.="AND
linked_version_id=".$relation['linked_version_id']." ";
$this->db->query($sql, __LINE__,
__FILE__);
$n_found_rows=$this->db->num_rows();
@@ -614,7 +639,7 @@
// Alors on insère
if ( $n_found_rows == 0 )
{
- $sql3="INSERT INTO
ged_relations ( linked_version_id, linking_version_id, relation_type) values (
".$relation['linked_version_id'].",".$amended_version['version_id'].",'".$relation['relation_type']."'
);";
+ $sql3="INSERT INTO ged_relations (
linked_version_id, linking_version_id, relation_type) values (
".$relation['linked_version_id'].",".$version_id.",'".$relation['relation_type']."'
);";
$this->db->query($sql3,
__LINE__, __FILE__);
$this->db->unlock();
}
@@ -622,7 +647,7 @@
{
$sql2="UPDATE
".$this->tables['relations']." ";
$sql2.="SET
relation_type='".$relation['relation_type']."' ";
- $sql2.="WHERE
linking_version_id=".$amended_version['version_id']." ";
+ $sql2.="WHERE
linking_version_id=".$version_id." ";
$sql2.="AND
linked_version_id=".$relation['linked_version_id']." ";
$this->db->query($sql2,
__LINE__, __FILE__);
@@ -630,17 +655,6 @@
}
}
}
- else
- {
- $sql="DELETE FROM
".$this->tables['relations']." where
linking_version_id=".$amended_version['version_id'];
- $this->db->query($sql, __LINE__, __FILE__);
- $this->db->unlock();
- }
- }
-
- return "OK";
-
- }
function add_folder($new_folder)
{
@@ -912,7 +926,6 @@
return $version;
}
-
function get_current_or_alert_or_refused_version($element_id)
{
$version=null;
@@ -1065,9 +1078,10 @@
return $version;
}
-
function get_pending_for_internal_review ($element_id)
{
+ $version=null;
+
if ( $this->debug('get_pending_for_internal_review') )
print ( "get_pending_for_internal_review: entering with
element_id=".$element_id."<br>\n");
@@ -1258,6 +1272,7 @@
return $version;
}
+
function get_parent_id($item_id)
{
$sql="SELECT parent_id FROM ".$this->tables['elements']." ";
@@ -1275,6 +1290,7 @@
return $out;
}
+
function get_path($focused_id)
{
$current_id=$focused_id;
@@ -1299,6 +1315,7 @@
return false;
}
+
function can_read($element_id)
{
// db2 neededbecause can_read can be called during a $this->db
loop;
@@ -1417,6 +1434,7 @@
return ( $result );
}
+
// DONE acl management
function list_elements($parent_id=0, $type='', $order='name')
{
@@ -2066,9 +2084,12 @@
// Say file is not valid
- function reject_file ( $element_id, $reason="Default reason" )
+ function reject_file ( $element_id, $comment='rejected',
$comment_file=null )
{
$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) )
@@ -2081,18 +2102,52 @@
$this->db->query($sql, __LINE__, __FILE__);
$this->db->unlock();
- $this->store_history ('rejected', 'rejected',
$pending_version['version_id']);
+ if (isset($comment_file))
+ {
+ $new_file=$comment_file;
+
+
$new_file['doc_type']=$this->comment_file_type;
+
$new_file['parent_id']=$this->get_type_place($new_file['doc_type'],$element['project_root']);
+
$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);
+
+
$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 ('rejected', $comment,
$pending_version['version_id']);
+
+ $result=true;
}
}
+ else
+ {
+ $result=false;
+ }
+ // TODO : check if all is ok
+ return ( $result );
+ }
// Say file is not valid
// A new version must be worked on and delivered
// User must have acceptation rights on this document
- function refuse_file ( $element_id, $reason="Default reason" )
+ function refuse_file ( $element_id, $comment='rejected',
$comment_file=null )
{
$pending_version=$this->get_pending_for_acceptation($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) )
@@ -2105,9 +2160,39 @@
$this->db->query($sql, __LINE__, __FILE__);
$this->db->unlock();
- $this->store_history ('refused', 'refused',
$pending_version['version_id']);
+ if (isset($comment_file))
+ {
+ $new_file=$comment_file;
+
$new_file['doc_type']=$this->comment_file_type;
+
$new_file['parent_id']=$this->get_type_place($new_file['doc_type'],$element['project_root']);
+
$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);
+
+
$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 ('refused', $comment,
$pending_version['version_id']);
+
+ $result=true;
+ }
}
+ else
+ {
+ $result=false;
}
+ // TODO : check if all is ok
+ return ( $result );
}
// Submit file to customer for acceptation
@@ -2919,11 +3004,31 @@
return ($out );
}
+ function get_type_desc($doc_type)
+ {
+ $db2 = clone($this->db);
+ $out=null;
+ $sql="SELECT * FROM ged_doc_types WHERE
type_id='".$doc_type."'";
+
+ $db2->query($sql, __LINE__, __FILE__);
+
+ if($db2->next_record())
+ {
+ $out=$db2->f('type_desc');
+ }
+
+ $db2->unlock();
+ $db2->free();
+ unset($db2);
+
+ return ($out );
+ }
+
function get_type_std_ref($doc_type)
{
$db2 = clone($this->db);
$out=null;
- $sql="SELECT * FROM ged_doc_types WHERE type_id='".$doc_type."'
and type_chrono=1";
+ $sql="SELECT * FROM ged_doc_types WHERE
type_id='".$doc_type."'";
$db2->query($sql, __LINE__, __FILE__);
@@ -2986,7 +3091,7 @@
$type_base_ref=$project_base_ref."/".$type_std_ref;
$db2 = clone($this->db);
- $sql=$sql="SELECT reference FROM ged_elements WHERE reference
like '".$type_base_ref."%' order by element_id desc limit 1";
+ $sql="SELECT reference FROM ged_elements WHERE reference like
'".$type_base_ref."%' order by element_id desc limit 1";
$db2->query($sql, __LINE__, __FILE__);
if($db2->next_record())
@@ -3007,6 +3112,34 @@
}
+ function get_type_place($doc_type, $project_root_id=null)
+ {
+ if ( isset($project_root_id))
+ {
+ $db2 = clone($this->db);
+ $sql="SELECT element_id FROM ged_types_places WHERE
project_root=".$project_root_id." AND type_id='".$doc_type."'";
+ $db2->query($sql, __LINE__, __FILE__);
+
+ if($db2->next_record())
+ {
+ $result=$db2->f('element_id');
+ }
+ else
+ {
+ $result=null;
+ }
+
+ $db2->unlock();
+ $db2->free();
+ unset($db2);
+ }
+ else
+ {
+ $result=null;
+ }
+ return($result);
+ }
+
function list_chronos($project_root_id)
{
$out=null;
Index: inc/class.ged_ui.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.ged_ui.inc.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- inc/class.ged_ui.inc.php 31 Jul 2007 17:02:11 -0000 1.42
+++ inc/class.ged_ui.inc.php 1 Aug 2007 17:28:49 -0000 1.43
@@ -2346,16 +2346,50 @@
function reject_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
+ $reject_file=get_var('reject_file',array('POST'));
+ $comment=addslashes(get_var('comment', array( 'POST')));
+
+ if ($reject_file==lang('Reject 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'];
- $this->ged_dm->reject_file ( $element_id );
-
+ if ( $this->ged_dm->reject_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('reject_file_tpl'=>'reject_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_reject_file', lang('Reject file'));
+
+ $reject_link_data['menuaction']='ged.ged_ui.reject_file';
+ $this->t->set_var('action_reject',
$GLOBALS['phpgw']->link('/index.php', $reject_link_data));
+
+ $this->display_app_header();
+
+ $this->t->pfp('out', 'reject_file_tpl');
+
+ }
function approve_file()
{
@@ -2385,16 +2419,50 @@
function refuse_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
+ $refuse_file=get_var('refuse_file',array('POST'));
+ $comment=addslashes(get_var('comment', array( 'POST')));
+
+ if ($refuse_file==lang('Refuse 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'];
- $this->ged_dm->refuse_file ( $element_id );
-
+ if ( $this->ged_dm->refuse_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('refuse_file_tpl'=>'refuse_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_refuse_file', lang('Refuse file'));
+
+ $refuse_link_data['menuaction']='ged.ged_ui.refuse_file';
+ $this->t->set_var('action_refuse',
$GLOBALS['phpgw']->link('/index.php', $refuse_link_data));
+
+ $this->display_app_header();
+
+ $this->t->pfp('out', 'refuse_file_tpl');
+
+ }
// Search
function search()
Index: setup/tables_update.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/setup/tables_update.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- setup/tables_update.inc.php 26 Jul 2007 14:42:47 -0000 1.11
+++ setup/tables_update.inc.php 1 Aug 2007 17:28:49 -0000 1.12
@@ -17,7 +17,7 @@
$test[]='0.9.18.002';
$test[]='0.9.18.003';
$test[]='0.9.18.004';
-
+ $test[]='0.9.18.005';
function ged_upgrade0_9_16_000()
{
@@ -190,7 +190,29 @@
$GLOBALS['phpgw_setup']->oProc->RenameColumn('ged_doc_types',
'type_smq_ref', 'type_ref');
- $GLOBALS['setup_info']['ged']['currentver']='0.9.18.004';
+ $GLOBALS['setup_info']['ged']['currentver']='0.9.18.005';
+ return $GLOBALS['setup_info']['ged']['currentver'];
+
+ }
+
+ function ged_upgrade0_9_18_005()
+ {
+
+ $GLOBALS['phpgw_setup']->oProc->CreateTable('ged_types_places',
+ array(
+ 'fd'=>array(
+ 'type_id'=>array('type'=>'varchar',
'precision'=>255,'nullable'=>False),
+ 'project_root' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'element_id' => array('type' =>
'int','precision' => 4,'nullable' => False)
+ ),
+ 'pk'=>array(),
+ 'fk'=>array(),
+ 'ix'=>array(),
+ 'uc'=>array()
+ )
+ );
+
+ $GLOBALS['setup_info']['ged']['currentver']='0.9.18.006';
return $GLOBALS['setup_info']['ged']['currentver'];
}
Index: setup/setup.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/setup/setup.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- setup/setup.inc.php 26 Jul 2007 14:42:47 -0000 1.9
+++ setup/setup.inc.php 1 Aug 2007 17:28:49 -0000 1.10
@@ -13,7 +13,7 @@
$setup_info['ged']['name']='ged';
$setup_info['ged']['title']='Document Management System';
- $setup_info['ged']['version']='0.9.18.005';
+ $setup_info['ged']['version']='0.9.18.006';
$setup_info['ged']['app_order']=17;
$setup_info['ged']['enable']=1;
$setup_info['calendar']['app_group'] = 'office';
@@ -50,6 +50,7 @@
'ged_versions',
'ged_acl',
'ged_doc_types',
+ 'ged_types_places',
'ged_periods'
);
Index: setup/tables_current.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/setup/tables_current.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- setup/tables_current.inc.php 26 Jul 2007 14:42:47 -0000 1.7
+++ setup/tables_current.inc.php 1 Aug 2007 17:28:49 -0000 1.8
@@ -141,6 +141,14 @@
'ix'=>array(),
'uc'=>array()
),
+ 'ged_types_places' => array(
+ 'fd' => array(
+ ),
+ 'pk' => array(),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
'ged_periods'=>array(
'fd'=>array(
'period'=>array('type'=>'int',
'precision'=>4,'nullable'=>False,'default'=>'0'),
Index: templates/base/refuse_file.tpl
===================================================================
RCS file: templates/base/refuse_file.tpl
diff -N templates/base/refuse_file.tpl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ templates/base/refuse_file.tpl 1 Aug 2007 17:28:48 -0000 1.1
@@ -0,0 +1,32 @@
+<form name="FileList" enctype="multipart/form-data" action="{action_refuse}"
method="post">
+<input type="hidden" name="{element_id_field}" value="{element_id_value}">
+<table cellpadding="5">
+<tr>
+<td colspan="2">
+<h2>Refuse 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="refuse_file" value="{lang_refuse_file}" />
+</td>
+</tr>
+ </table>
+ </form>
\ No newline at end of file
Index: templates/base/reject_file.tpl
===================================================================
RCS file: templates/base/reject_file.tpl
diff -N templates/base/reject_file.tpl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ templates/base/reject_file.tpl 1 Aug 2007 17:28:49 -0000 1.1
@@ -0,0 +1,32 @@
+<form name="FileList" enctype="multipart/form-data" action="{action_reject}"
method="post">
+<input type="hidden" name="{element_id_field}" value="{element_id_value}">
+<table cellpadding="5">
+<tr>
+<td colspan="2">
+<h2>Reject 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="reject_file" value="{lang_reject_file}" />
+</td>
+</tr>
+ </table>
+ </form>
\ No newline at end of file
_______________________________________________
phpGroupWare-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs