[Fusionforge-commits] r11217 - in trunk/src: common/docman common/docman/actions common/docman/views db www/docman www/themes/funky/images/docman www/themes/gforge/images/docman

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Oct 27 17:09:14 CEST 2010


Author: nerville
Date: 2010-10-27 17:09:14 +0200 (Wed, 27 Oct 2010)
New Revision: 11217

Added:
   trunk/src/common/docman/actions/enforcereserve.php
   trunk/src/common/docman/actions/releasefile.php
   trunk/src/common/docman/actions/reservefile.php
   trunk/src/db/20101027-docman-lock.sql
   trunk/src/www/themes/funky/images/docman/document-reserved.png
   trunk/src/www/themes/funky/images/docman/edit-forbidden.png
   trunk/src/www/themes/funky/images/docman/enforce-document.png
   trunk/src/www/themes/funky/images/docman/release-document.png
   trunk/src/www/themes/funky/images/docman/reserve-document.png
   trunk/src/www/themes/funky/images/docman/trash-forbidden.png
   trunk/src/www/themes/gforge/images/docman/document-reserved.png
   trunk/src/www/themes/gforge/images/docman/edit-forbidden.png
   trunk/src/www/themes/gforge/images/docman/enforce-document.png
   trunk/src/www/themes/gforge/images/docman/release-document.png
   trunk/src/www/themes/gforge/images/docman/reserve-document.png
   trunk/src/www/themes/gforge/images/docman/trash-forbidden.png
Modified:
   trunk/src/common/docman/Document.class.php
   trunk/src/common/docman/views/listfile.php
   trunk/src/www/docman/index.php
Log:
basic reservation document and backend for lock during edition

Modified: trunk/src/common/docman/Document.class.php
===================================================================
--- trunk/src/common/docman/Document.class.php	2010-10-27 09:24:16 UTC (rev 11216)
+++ trunk/src/common/docman/Document.class.php	2010-10-27 15:09:14 UTC (rev 11217)
@@ -426,6 +426,33 @@
 	}
 
 	/**
+	 *	getLocked - get the lock status of this document.
+	 *
+	 *	@return int	The lock status of this document.
+	 */
+	function getLocked() {
+		return $this->data_array['locked'];
+	}
+
+	/**
+	 *	getReservedBy - get the owner of the reversed status of this document.
+	 *
+	 *	@return int	The owner of the reversed status of this document.
+	 */
+	function getReservedBy() {
+		return $this->data_array['reserved_by'];
+	}
+
+	/**
+	 *	getReserved - get the reversed status of this document.
+	 *
+	 *	@return int	The reversed status of this document.
+	 */
+	function getReserved() {
+		return $this->data_array['reserved'];
+	}
+
+	/**
 	 *  setState - set the stateid of the document.
 	 *
 	 *	@param	int	The state id of the doc_states table.
@@ -448,6 +475,55 @@
 		return true;
 	}
 
+    /**
+     *  setLock - set the locking status of the document
+     *
+     *  @param  int The status of the lock
+     *  @return boolean success
+     */
+    function setLock($stateLock) {
+		$res = db_query_params ('UPDATE doc_data SET
+								locked=$1
+								WHERE group_id=$2
+								AND docid=$3',
+								array ($stateLock,
+					       			$this->Group->getID(),
+									$this->getID())
+								);
+		if (!$res || db_affected_rows($res) < 1) {
+			$this->setOnUpdateError(_('Document lock failed').' '.db_error());
+			return false;
+		}
+		$this->sendNotice(false);
+		return true;
+	}
+
+    /**
+     *  setReservedBy - set the reserved status of the document and the owner
+     *
+     *  @param  int The status of the reserved
+     *  @param  int The ID of the owner : by default : noone
+     *  @return boolean success
+     */
+    function setReservedBy($statusReserved,$idReserver=NULL) {
+		$res = db_query_params ('UPDATE doc_data SET
+                                reserved=$1,
+                                reserved_by=$2
+								WHERE group_id=$3
+								AND docid=$4',
+                                array ($statusReserved,
+                                    $idReserver,
+					       			$this->Group->getID(),
+									$this->getID())
+								);
+		if (!$res || db_affected_rows($res) < 1) {
+			$this->setOnUpdateError(_('Document reservation failed').' '.db_error());
+			return false;
+		}
+		$this->sendNotice(false);
+		return true;
+	}
+
 	/**
 	 *	update - use this function to update an existing entry in the database.
 	 *

Copied: trunk/src/common/docman/actions/enforcereserve.php (from rev 11216, trunk/src/common/docman/actions/trashfile.php)
===================================================================
--- trunk/src/common/docman/actions/enforcereserve.php	                        (rev 0)
+++ trunk/src/common/docman/actions/enforcereserve.php	2010-10-27 15:09:14 UTC (rev 11217)
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2000, Quentin Cregan/Sourceforge
+ * Copyright 2002-2003, Tim Perdue/GForge, LLC
+ * Copyright 2010, Franck Villaume - Capgemini
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* please do not add require here : use www/docman/index.php to add require */
+/* global variables used */
+global $g; //group object
+global $dirid; //id of doc_group
+global $group_id; // id of group
+
+if (!forge_check_perm ('docman', $group_id, 'admin')) {
+	$return_msg = _('Document Action Denied');
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
+} else {
+
+	$fileid = getIntFromRequest('fileid');
+	$d= new Document($g,$fileid);
+
+	if ($d->isError())
+	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+
+	if ( !$d->setReservedBy('0') )
+	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+
+	$return_msg = _('Document reservation enforced successfully');
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
+}
+?>

Copied: trunk/src/common/docman/actions/releasefile.php (from rev 11216, trunk/src/common/docman/actions/trashfile.php)
===================================================================
--- trunk/src/common/docman/actions/releasefile.php	                        (rev 0)
+++ trunk/src/common/docman/actions/releasefile.php	2010-10-27 15:09:14 UTC (rev 11217)
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2000, Quentin Cregan/Sourceforge
+ * Copyright 2002-2003, Tim Perdue/GForge, LLC
+ * Copyright 2010, Franck Villaume - Capgemini
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* please do not add require here : use www/docman/index.php to add require */
+/* global variables used */
+global $g; //group object
+global $dirid; //id of doc_group
+global $group_id; // id of group
+
+if (!forge_check_perm ('docman', $group_id, 'approve')) {
+	$return_msg = _('Document Action Denied');
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
+} else {
+
+	$fileid = getIntFromRequest('fileid');
+	$d= new Document($g,$fileid);
+
+	if ($d->isError())
+	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+
+	if ( !$d->setReservedBy(0) )
+	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+
+	$return_msg = _('Document released successfully');
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
+}
+?>

Copied: trunk/src/common/docman/actions/reservefile.php (from rev 11216, trunk/src/common/docman/actions/trashfile.php)
===================================================================
--- trunk/src/common/docman/actions/reservefile.php	                        (rev 0)
+++ trunk/src/common/docman/actions/reservefile.php	2010-10-27 15:09:14 UTC (rev 11217)
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2000, Quentin Cregan/Sourceforge
+ * Copyright 2002-2003, Tim Perdue/GForge, LLC
+ * Copyright 2010, Franck Villaume - Capgemini
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* please do not add require here : use www/docman/index.php to add require */
+/* global variables used */
+global $g; //group object
+global $dirid; //id of doc_group
+global $group_id; // id of group
+global $LUSER; // User object
+
+if (!forge_check_perm ('docman', $group_id, 'approve')) {
+	$return_msg = _('Document Action Denied');
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
+} else {
+
+	$fileid = getIntFromRequest('fileid');
+	$d= new Document($g,$fileid);
+
+	if ($d->isError())
+	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+
+	if ( !$d->setReservedBy('1',$LUSER->getID()) )
+	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+
+	$return_msg = _('Document reserved successfully');
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
+}
+?>

Modified: trunk/src/common/docman/views/listfile.php
===================================================================
--- trunk/src/common/docman/views/listfile.php	2010-10-27 09:24:16 UTC (rev 11216)
+++ trunk/src/common/docman/views/listfile.php	2010-10-27 15:09:14 UTC (rev 11217)
@@ -32,6 +32,7 @@
 global $nested_docs; // flat docs array
 global $nested_groups; // flat document directories array
 global $HTML; // Layout object
+global $LUSER; // User object
 
 $DocGroupName = getNameDocGroup($dirid,$group_id);
 if (!$DocGroupName) {
@@ -176,7 +177,12 @@
 			echo date(_('Y-m-d H:i'),$d->getCreated());
 		}
 		echo '</td>';
-		echo '<td>'.$d->getStateName().'</td>';
+        echo '<td>';
+        if ($d->getReserved()) {
+            echo html_image('docman/document-reserved.png',22,22,array('alt'=>_('Reserved Document')));
+        } else {
+            echo $d->getStateName().'</td>';
+        }
 		echo '<td>';
 		switch ($d->getFileType()) {
 		case "URL":
@@ -199,8 +205,25 @@
 
 		if (forge_check_perm ('docman', $group_id, 'approve')) {
 			echo '<td>';
-			echo '<a href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'">'.html_image('docman/trash-empty.png',22,22,array('alt'=>'trashfile')). '</a>';
-			echo '<a href="#" onclick="javascript:displayEditFile(\''.$d->getID().'\')" >'.html_image('docman/edit-file.png',22,22,array('alt'=>'editfile')). '</a>';
+            if (!$d->getLocked() && !$d->getReserved()) {
+			    echo '<a href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'">'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Trash this file'))). '</a>';
+			    echo '<a href="#" onclick="javascript:displayEditFile(\''.$d->getID().'\')" >'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this file'))). '</a>';
+			        echo '<a href="?group_id='.$group_id.'&action=reservefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'">'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve this document'))). '</a>';
+            } else {
+                if ($d->getReservedBy() != $LUSER->getID()) {
+                    echo html_image('docman/trash-forbidden.png',22,22,array('alt'=>_('Trash forbidden')));
+                    echo html_image('docman/edit-forbidden.png',22,22,array('alt'=>_('Edition forbidden')));
+                    if (forge_check_perm ('docman', $group_id, 'admin')) {
+                        echo '<a href="?group_id='.$group_id.'&action=enforcereserve&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'">'.html_image('docman/enforce-document.png',22,22,array('alt'=>'Enforce reservation'));
+                    } else {
+                        echo html_image('docman/document-reserved.png',22,22,array('alt',_('Document reserved by')));
+                    }
+                } else {
+			        echo '<a href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'">'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Trash this file'))). '</a>';
+			        echo '<a href="#" onclick="javascript:displayEditFile(\''.$d->getID().'\')" >'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this file'))). '</a>';
+			        echo '<a href="?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'">'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release this document'))). '</a>';
+                }
+            }
 			echo '</td>';
 		}
 		echo '</tr>';

Copied: trunk/src/db/20101027-docman-lock.sql (from rev 11216, trunk/src/db/20101024-docman-createonline.sql)
===================================================================
--- trunk/src/db/20101027-docman-lock.sql	                        (rev 0)
+++ trunk/src/db/20101027-docman-lock.sql	2010-10-27 15:09:14 UTC (rev 11217)
@@ -0,0 +1,9 @@
+ALTER TABLE DOC_DATA ADD COLUMN reserved INT;
+ALTER TABLE DOC_DATA ALTER COLUMN reserved SET DEFAULT 0;
+UPDATE DOC_DATA SET reserved = 0;
+ALTER TABLE DOC_DATA ADD COLUMN reserved_by INT;
+ALTER TABLE DOC_DATA ADD COLUMN locked INT;
+ALTER TABLE DOC_DATA ALTER COLUMN locked SET DEFAULT 0;
+UPDATE DOC_DATA SET locked = 0;
+CREATE OR REPLACE VIEW docdata_vw AS
+    SELECT users.user_name, users.realname, users.email, d.group_id, d.docid, d.stateid, d.title, d.updatedate, d.createdate, d.created_by, d.doc_group, d.description, d.language_id, d.filename, d.filetype, d.filesize, doc_states.name AS state_name, doc_groups.groupname AS group_name, sl.name AS language_name, d.locked, d.reserved, d.reserved_by FROM ((((doc_data d NATURAL JOIN doc_states) NATURAL JOIN doc_groups) JOIN supported_languages sl ON ((sl.language_id = d.language_id))) JOIN users ON ((users.user_id = d.created_by)));

Modified: trunk/src/www/docman/index.php
===================================================================
--- trunk/src/www/docman/index.php	2010-10-27 09:24:16 UTC (rev 11216)
+++ trunk/src/www/docman/index.php	2010-10-27 15:09:14 UTC (rev 11217)
@@ -95,6 +95,9 @@
 	case "updateenginesearch":
 	case "updatewebdavinterface":
 	case "updatecreateonline":
+	case "reservefile":
+	case "releasefile":
+	case "enforcereserve":
 		include ("docman/actions/$action.php");
 		break;
 }

Added: trunk/src/www/themes/funky/images/docman/document-reserved.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/funky/images/docman/document-reserved.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/funky/images/docman/edit-forbidden.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/funky/images/docman/edit-forbidden.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/funky/images/docman/enforce-document.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/funky/images/docman/enforce-document.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/funky/images/docman/release-document.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/funky/images/docman/release-document.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/funky/images/docman/reserve-document.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/funky/images/docman/reserve-document.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/funky/images/docman/trash-forbidden.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/funky/images/docman/trash-forbidden.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/gforge/images/docman/document-reserved.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/gforge/images/docman/document-reserved.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/gforge/images/docman/edit-forbidden.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/gforge/images/docman/edit-forbidden.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/gforge/images/docman/enforce-document.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/gforge/images/docman/enforce-document.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/gforge/images/docman/release-document.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/gforge/images/docman/release-document.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/gforge/images/docman/reserve-document.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/gforge/images/docman/reserve-document.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/gforge/images/docman/trash-forbidden.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/gforge/images/docman/trash-forbidden.png
___________________________________________________________________
Added: svn:mime-type
   + image/png




More information about the Fusionforge-commits mailing list