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

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Thu Oct 28 14:15:37 CEST 2010


Author: nerville
Date: 2010-10-28 14:15:37 +0200 (Thu, 28 Oct 2010)
New Revision: 11227

Modified:
   trunk/src/common/docman/Document.class.php
   trunk/src/common/docman/actions/lockfile.php
   trunk/src/common/docman/views/listfile.php
   trunk/src/db/20101027-docman-lock.sql
   trunk/src/www/themes/funky/Theme.class.php
Log:
make lock/unlock more robust

Modified: trunk/src/common/docman/Document.class.php
===================================================================
--- trunk/src/common/docman/Document.class.php	2010-10-28 09:59:54 UTC (rev 11226)
+++ trunk/src/common/docman/Document.class.php	2010-10-28 12:15:37 UTC (rev 11227)
@@ -479,14 +479,17 @@
      *  setLock - set the locking status of the document
      *
      *  @param  int The status of the lock
+     *  @param  int The userid who set the lock
      *  @return boolean success
      */
-    function setLock($stateLock) {
+    function setLock($stateLock,$userid=NULL) {
 		$res = db_query_params ('UPDATE doc_data SET
-								locked=$1
-								WHERE group_id=$2
-								AND docid=$3',
+                                locked=$1,
+                                locked_by=$2
+								WHERE group_id=$3
+								AND docid=$4',
 								array ($stateLock,
+                                    $userid,
 					       			$this->Group->getID(),
 									$this->getID())
 								);
@@ -561,9 +564,10 @@
 			doc_group=$4,
 			filetype=$5,
 			filename=$6,
-			updatedate=$7
-			WHERE group_id=$8
-			AND docid=$9',
+			updatedate=$7,
+            locked=$8
+			WHERE group_id=$9
+			AND docid=$10',
 					array (htmlspecialchars($title),
 					       htmlspecialchars($description),
 					       $stateid,
@@ -571,6 +575,7 @@
 					       $filetype,
 					       $filename,
 					       time(),
+                           0,
 					       $this->Group->getID(),
 					       $this->getID())) ;
 		

Modified: trunk/src/common/docman/actions/lockfile.php
===================================================================
--- trunk/src/common/docman/actions/lockfile.php	2010-10-28 09:59:54 UTC (rev 11226)
+++ trunk/src/common/docman/actions/lockfile.php	2010-10-28 12:15:37 UTC (rev 11227)
@@ -41,7 +41,11 @@
 	if ($d->isError())
 	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
 
-	echo $d->setLock($lock);
+    if ($lock == 0) {
+	    echo $d->setLock($lock);
+    } else {
+        echo $d->setLock($lock,$LUSER->getID());
+    }
     exit;
 }
 ?>

Modified: trunk/src/common/docman/views/listfile.php
===================================================================
--- trunk/src/common/docman/views/listfile.php	2010-10-28 09:59:54 UTC (rev 11226)
+++ trunk/src/common/docman/views/listfile.php	2010-10-28 12:15:37 UTC (rev 11227)
@@ -41,6 +41,13 @@
 ?>
 
 <script language="javascript">
+var lockfileid = new Array();
+JQuery(window).unload(function(){
+    for (var localid in localfileid) {
+        JQuery.ajax({async: false, url:"<?php util_make_url('docman') ?>", data: {group_id:<?php echo $group_id ?>,action:'lockfile',lock:0,fileid:localid}});
+    }
+});
+
 function displaySubGroup() {
 	if ( 'none' == document.getElementById('addsubdocgroup').style.display ) {
 		document.getElementById('addsubdocgroup').style.display = 'block';
@@ -71,13 +78,15 @@
 function displayEditFile(id) {
 	var divid = 'editfile'+id;
 	if ( 'none' == document.getElementById(divid).style.display ) {
+        lockfileid.push(id);
 		document.getElementById(divid).style.display = 'block';
-        jQuery.get('http://forge/docman/',
-                    {group_id:6,action:'lockfile',lock:1,fileid:id});
+        jQuery.get('<?php util_make_url('docman') ?>',
+                    {group_id:<?php echo $group_id ?>,action:'lockfile',lock:1,fileid:id});
 	} else {
 		document.getElementById(divid).style.display = 'none';
-        jQuery.get('http://forge/docman/',
-                    {group_id:6,action:'lockfile',lock:0,fileid:id});
+        lockfileid.splice(lockfileid.indexOf(id),1);
+        jQuery.get('<?php util_make_url('docman') ?>',
+                    {group_id:<?php echo $group_id ?>,action:'lockfile',lock:0,fileid:id});
 	}
 }
 </script>

Modified: trunk/src/db/20101027-docman-lock.sql
===================================================================
--- trunk/src/db/20101027-docman-lock.sql	2010-10-28 09:59:54 UTC (rev 11226)
+++ trunk/src/db/20101027-docman-lock.sql	2010-10-28 12:15:37 UTC (rev 11227)
@@ -5,6 +5,7 @@
 ALTER TABLE DOC_DATA ADD COLUMN locked INT;
 ALTER TABLE DOC_DATA ALTER COLUMN locked SET DEFAULT 0;
 UPDATE DOC_DATA SET locked = 0;
+ALTER TABLE DOC_DATA ADD COLUMN locked_by INT;
 DROP VIEW docdata_vw;
 CREATE 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.filename, d.filetype, d.filesize, d.reserved, d.reserved_by, d.locked, doc_states.name AS state_name, doc_groups.groupname AS group_name FROM doc_data d, users, doc_groups, doc_states where d.created_by = users.user_id and doc_groups.doc_group = d.doc_group and doc_states.stateid = d.stateid;
+    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.filename, d.filetype, d.filesize, d.reserved, d.reserved_by, d.locked, d.locked_by, doc_states.name AS state_name, doc_groups.groupname AS group_name FROM doc_data d, users, doc_groups, doc_states where d.created_by = users.user_id and doc_groups.doc_group = d.doc_group and doc_states.stateid = d.stateid;

Modified: trunk/src/www/themes/funky/Theme.class.php
===================================================================
--- trunk/src/www/themes/funky/Theme.class.php	2010-10-28 09:59:54 UTC (rev 11226)
+++ trunk/src/www/themes/funky/Theme.class.php	2010-10-28 12:15:37 UTC (rev 11227)
@@ -405,7 +405,7 @@
         ?>
         <script>
             var JQuery = jQuery.noConflict();
-            $(window).load(function(){
+            JQuery(window).load(function(){
                     jQuery(".quicknews").hide();
             });
         </script>




More information about the Fusionforge-commits mailing list