[Fusionforge-commits] r11681 - in branches/Branch_5_1/src: common/docman common/docman/include www/docman

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Dec 1 14:39:46 CET 2010


Author: nerville
Date: 2010-12-01 14:39:45 +0100 (Wed, 01 Dec 2010)
New Revision: 11681

Modified:
   branches/Branch_5_1/src/common/docman/Document.class.php
   branches/Branch_5_1/src/common/docman/include/utils.php
   branches/Branch_5_1/src/www/docman/index.php
Log:
fix editfile : use correctly lock in trash and pending views

Modified: branches/Branch_5_1/src/common/docman/Document.class.php
===================================================================
--- branches/Branch_5_1/src/common/docman/Document.class.php	2010-12-01 13:26:29 UTC (rev 11680)
+++ branches/Branch_5_1/src/common/docman/Document.class.php	2010-12-01 13:39:45 UTC (rev 11681)
@@ -596,7 +596,7 @@
 	 * @return	boolean	success
 	 */
 	function setLock($stateLock, $userid = NULL, $thistime = 0) {
-		$res = db_query_params ('UPDATE doc_data SET
+		$res = db_query_params('UPDATE doc_data SET
 					locked=$1,
 					locked_by=$2,
 					lockdate=$3
@@ -681,15 +681,15 @@
 		}
 
 		if ($filename) {
-			$result = db_query_params('SELECT filename, doc_group FROM docdata_vw WHERE filename = $1 and doc_group = $2',
-						array($filename, $doc_group));
+			$result = db_query_params('SELECT filename, doc_group FROM docdata_vw WHERE filename = $1 and doc_group = $2 and stateid = $3',
+						array($filename, $doc_group, $stateid));
 			if (!$result || db_numrows($result) > 0) {
 				$this->setError(_('Document already published in this directory'));
 				return false;
 			}
 		}
 
-		$res = db_query_params ('UPDATE doc_data SET
+		$res = db_query_params('UPDATE doc_data SET
 					title=$1,
 					description=$2,
 					stateid=$3,
@@ -730,7 +730,7 @@
 				$kwords = '';
 			}
 
-			$res = db_query_params ('UPDATE doc_data SET filesize=$1, data_words=$2 WHERE group_id=$3 AND docid=$4',
+			$res = db_query_params('UPDATE doc_data SET filesize=$1, data_words=$2 WHERE group_id=$3 AND docid=$4',
 						array(strlen($data),
 							$kwords,
 							$this->Group->getID(),
@@ -744,7 +744,7 @@
 
 			switch ($this->Group->getStorageAPI()) {
 				case 'DB': {
-					$res = db_query_params ('UPDATE doc_data SET data = $1 where group_id = $2 and docid = $3',
+					$res = db_query_params('UPDATE doc_data SET data = $1 where group_id = $2 and docid = $3',
 								array(base64_encode($data),
 									$this->Group->getID(),
 									$this->getID())

Modified: branches/Branch_5_1/src/common/docman/include/utils.php
===================================================================
--- branches/Branch_5_1/src/common/docman/include/utils.php	2010-12-01 13:26:29 UTC (rev 11680)
+++ branches/Branch_5_1/src/common/docman/include/utils.php	2010-12-01 13:39:45 UTC (rev 11681)
@@ -143,16 +143,22 @@
  * @todo : use jquery
  */
 function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid = 0, $parent_group = 0) {
+	global $group_id;
 	if (!array_key_exists("$parent_group", $nested_groups) || !is_array($nested_groups["$parent_group"])) {
 		return;
 	}
 	
 	echo '<script type="text/javascript">';
+	echo 'var lockInterval = new Array();';
 	echo 'function EditData(iddiv) {';
-	echo '	if ( "none" == document.getElementById(iddiv).style.display ) {';
-	echo '		document.getElementById(iddiv).style.display = "block";';
+	echo '	if ( "none" == document.getElementById(\'editdata\'+iddiv).style.display ) {';
+	echo '		document.getElementById(\'editdata\'+iddiv).style.display = "block";';
+	echo '		jQuery.get(\''. util_make_url('docman') .'\',{group_id:'. $group_id.',action:\'lockfile\',lock:1,fileid:iddiv});';
+	echo '		lockInterval[iddiv] = setInterval("jQuery.get(\''. util_make_url('docman') .'\',{group_id:'. $group_id .',action:\'lockfile\',lock:1,fileid:"+iddiv+"})",60000);';
 	echo '	} else {';
-	echo '		document.getElementById(iddiv).style.display = "none";';
+	echo '		document.getElementById(\'editdata\'+iddiv).style.display = "none";';
+	echo '		jQuery.get(\''. util_make_url('docman') .'\',{group_id:'. $group_id .',action:\'lockfile\',lock:0,fileid:iddiv});';
+	echo '		clearInterval(lockInterval[iddiv]);';
 	echo '	}';
 	echo '}';
 	echo '</script>';
@@ -192,7 +198,7 @@
 				}
 				$tooltip = htmlspecialchars($tooltip);
 				echo '<li>'.  html_image('docman/file_type_unknown.png', '22', '22', array("border"=>"0")). 
-					$docs[$j]->getName(). ' - ' . $tooltip . '&nbsp;<a href="#" onclick="javascript:EditData(\'editdata'.$docs[$j]->getID().'\')" >'. html_image('docman/edit-file.png', '22', '22', array('alt'=>'editfile')) .'</a></li>';
+					$docs[$j]->getName(). ' - ' . $tooltip . '&nbsp;<a href="#" onclick="javascript:EditData(\''.$docs[$j]->getID().'\')" >'. html_image('docman/edit-file.png', '22', '22', array('alt'=>'editfile')) .'</a></li>';
 				echo "<i>".$docs[$j]->getDescription()."</i><br/>";
 				echo '<div class="docman_div_include" id="editdata'.$docs[$j]->getID().'" style="display:none">';
 				document_editdata($docs[$j]);

Modified: branches/Branch_5_1/src/www/docman/index.php
===================================================================
--- branches/Branch_5_1/src/www/docman/index.php	2010-12-01 13:26:29 UTC (rev 11680)
+++ branches/Branch_5_1/src/www/docman/index.php	2010-12-01 13:39:45 UTC (rev 11681)
@@ -104,7 +104,6 @@
 		break;
 }
 
-use_javascript('/scripts/jquery/jquery-1.4.2.min.js');
 html_use_tooltips();
 use_javascript('scripts/DocManController.js');
 use_javascript('/js/sortable.js');




More information about the Fusionforge-commits mailing list