[Fusionforge-commits] r11556 - in trunk/src/common/docman: . actions engine views

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Nov 17 15:16:47 CET 2010


Author: nerville
Date: 2010-11-17 15:16:47 +0100 (Wed, 17 Nov 2010)
New Revision: 11556

Modified:
   trunk/src/common/docman/Document.class.php
   trunk/src/common/docman/DocumentFactory.class.php
   trunk/src/common/docman/DocumentGroup.class.php
   trunk/src/common/docman/DocumentGroupFactory.class.php
   trunk/src/common/docman/Parsedata.class.php
   trunk/src/common/docman/actions/addfile.php
   trunk/src/common/docman/actions/addsubdocgroup.php
   trunk/src/common/docman/actions/deldir.php
   trunk/src/common/docman/actions/editdocgroup.php
   trunk/src/common/docman/actions/editfile.php
   trunk/src/common/docman/actions/emptytrash.php
   trunk/src/common/docman/actions/enforcereserve.php
   trunk/src/common/docman/actions/forcereindexenginesearch.php
   trunk/src/common/docman/actions/lockfile.php
   trunk/src/common/docman/actions/monitorfile.php
   trunk/src/common/docman/actions/releasefile.php
   trunk/src/common/docman/actions/reservefile.php
   trunk/src/common/docman/actions/trashdir.php
   trunk/src/common/docman/actions/trashfile.php
   trunk/src/common/docman/actions/updatecreateonline.php
   trunk/src/common/docman/actions/updateenginesearch.php
   trunk/src/common/docman/actions/updatewebdavinterface.php
   trunk/src/common/docman/engine/parser_doc.php
   trunk/src/common/docman/engine/parser_html.php
   trunk/src/common/docman/engine/parser_oo.php
   trunk/src/common/docman/engine/parser_pdf.php
   trunk/src/common/docman/engine/parser_text.inc.php
   trunk/src/common/docman/engine/parser_text.php
   trunk/src/common/docman/views/addfile.php
Log:
clean-up, remove dead code

Modified: trunk/src/common/docman/Document.class.php
===================================================================
--- trunk/src/common/docman/Document.class.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/Document.class.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -34,21 +34,21 @@
 	/**
 	 * Associative array of data from db.
 	 *
-	 * @var	 array   $data_array.
+	 * @var	 array	$data_array.
 	 */
 	var $data_array;
 
 	/**
 	 * The Group object.
 	 *
-	 * @var	 object  $Group.
+	 * @var	object	$Group.
 	 */
-	var	$Group;
+	var $Group;
 
 	/**
 	 * The Search engine path.
 	 *
-	 * @var  string $engine_path
+	 * @var	string	$engine_path
 	 */
 	var $engine_path;
 
@@ -60,14 +60,14 @@
 	 * @param	array	The associative array of data.
 	 * @return	boolean	success.
 	 */
-	function Document(&$Group, $docid=false, $arr=false, $engine = "") {
+	function Document(&$Group, $docid = false, $arr = false, $engine = '') {
 		$this->Error();
 		if (!$Group || !is_object($Group)) {
 			$this->setNotValidGroupObjectError();
 			return false;
 		}
 		if ($Group->isError()) {
-			$this->setError('Document:: '.$Group->getErrorMessage());
+			$this->setError('Document:: '. $Group->getErrorMessage());
 			return false;
 		}
 		$this->Group =& $Group;
@@ -80,13 +80,13 @@
 			} else {
 				$this->data_array =& $arr;
 				if ($this->data_array['group_id'] != $this->Group->getID()) {
-					$this->setError(_('Group_id in db result does not match Group Object'));
+					$this->setError('Document:: '. _('Group_id in db result does not match Group Object'));
 					$this->data_array = null;
 					return false;
 				}
 			}
 			if (!$this->isPublic()) {
-				$perm =& $this->Group->getPermission ();
+				$perm =& $this->Group->getPermission();
 
 				if (!$perm || !is_object($perm) || !$perm->isMember()) {
 					$this->setPermissionDeniedError();
@@ -110,7 +110,7 @@
 	 *	@param	string	The description of this document.
 	 *	@return	boolean	success.
 	 */
-	function create($filename,$filetype,$data,$doc_group,$title,$description) {
+	function create($filename, $filetype, $data, $doc_group, $title, $description) {
 		if (strlen($title) < 5) {
 			$this->setError(_('Title Must Be At Least 5 Characters'));
 			return false;
@@ -121,7 +121,7 @@
 		}
 
 		$result = db_query_params('SELECT filename,doc_group from docdata_vw where filename = $1 and doc_group = $2',
-			array($filename,$doc_group));
+			array($filename, $doc_group));
 
 		if (!$result || db_numrows($res) > 0) {
 			$this->setError(_('Document already published in this directory'));
@@ -132,7 +132,7 @@
 
 		$doc_initstatus = '3';
 		// If Editor - uploaded Documents are ACTIVE
-		if ( session_loggedin() ) {
+		if (session_loggedin()) {
 			$perm =& $this->Group->getPermission ();
 			if ($perm && is_object($perm) && $perm->isDocEditor()) {
 				$doc_initstatus = '1';
@@ -149,8 +149,8 @@
 
 		// key words for in-document search
 		if ($this->Group->useDocmanSearch()) {
-			$kw = new Parsedata ($this->engine_path);
-			$kwords = $kw->get_parse_data ($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
+			$kw = new Parsedata($this->engine_path);
+			$kwords = $kw->get_parse_data($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
 		} else {
 			$kwords ='';
 		}
@@ -159,9 +159,9 @@
 
 		db_begin();
 		$result = db_query_params('INSERT INTO doc_data (group_id,title,description,createdate,doc_group,
-			stateid,filename,filetype,filesize,data_words,created_by)
-                        VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)',
-					  array($this->Group->getId(),
+						stateid,filename,filetype,filesize,data_words,created_by)
+						VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)',
+						array($this->Group->getId(),
 						htmlspecialchars($title),
 						htmlspecialchars($description),
 						time(),
@@ -178,22 +178,24 @@
 			return false;
 		}
 
-		$docid=db_insertid($result,'doc_data','docid');
+		$docid = db_insertid($result,'doc_data','docid');
 
 		switch ($this->Group->getStorageAPI()) {
-		case 'DB':
-			$result = db_query_params('UPDATE doc_data set data = $1 where docid = $2',
-				array(base64_encode($data),$docid));
-			if (!$result) {
-				$this->setError(_('Error Adding Document:').' '.db_error().$result);
+			case 'DB': {
+				$result = db_query_params('UPDATE doc_data set data = $1 where docid = $2',
+								array(base64_encode($data),$docid));
+				if (!$result) {
+					$this->setError(_('Error Adding Document:').' '.db_error().$result);
+					db_rollback();
+					return false;
+				}
+				break;
+			}
+			default: {
+				$this->setError(_('Error Adding Document: No Storage API'));
 				db_rollback();
 				return false;
 			}
-		break;
-		default:
-			$this->setError(_('Error Adding Document: No Storage API'));
-		db_rollback();
-		return false;
 		}
 
 		if (!$this->fetchData($docid)) {
@@ -212,9 +214,8 @@
 	 * @return	boolean	success
 	 */
 	function fetchData($docid) {
-		$res = db_query_params ('SELECT * FROM docdata_vw WHERE docid=$1 AND group_id=$2',
-					array ($docid,
-					       $this->Group->getID()));
+		$res = db_query_params('SELECT * FROM docdata_vw WHERE docid=$1 AND group_id=$2',
+					array($docid, $this->Group->getID()));
 		if (!$res || db_numrows($res) < 1) {
 			$this->setError(_('Document:: Invalid docid'));
 			return false;
@@ -245,7 +246,7 @@
 	/**
 	 * getName - get the name of this document.
 	 *
-	 * @return string	The name of this document.
+	 * @return	string	The name of this document.
 	 */
 	function getName() {
 		return $this->data_array['title'];
@@ -254,7 +255,7 @@
 	/**
 	 * getDescription - the description of this document.
 	 *
-	 * @return string	The description.
+	 * @return	string	The description.
 	 */
 	function getDescription() {
 		return $this->data_array['description'];
@@ -268,7 +269,7 @@
 	function isURL() {
 		return ($this->data_array['filetype'] == 'URL');
 	}
-	
+
 	/**
 	 * isText - whether this document is a text document and not a binary one.
 	 *
@@ -276,12 +277,12 @@
 	 */
 	function isText() {
 		$doctype = $this->data_array['filetype'];
-		if (preg_match('|^text/|i',$doctype)) { // text plain, text html, text x-patch, etc
+		if (preg_match('|^text/|i', $doctype)) { // text plain, text html, text x-patch, etc
 			return true;
-		}	
+		}
 		return false;
 	}
-	
+
 	/**
 	 * isHtml - whether this document is a html document.
 	 *
@@ -291,9 +292,9 @@
 		$doctype = $this->data_array['filetype'];
 		if (preg_match('/html/i',$doctype)) {
 			return true;
-		}	
+		}
 		return false;
-	}	
+	}
 
 	/**
 	 * isPublic - whether this document is available to the general public.
@@ -301,7 +302,7 @@
 	 * @return	boolean	is_public.
 	 */
 	function isPublic() {
-		return (($this->data_array['stateid'] == 1) ? true  : false);
+		return (($this->data_array['stateid'] == 1) ? true : false);
 	}
 
 	/**
@@ -316,7 +317,7 @@
 	/**
 	 * getStateName - the statename of this document.
 	 *
-	 * @return string	The statename.
+	 * @return	string	The statename.
 	 */
 	function getStateName() {
 		return $this->data_array['state_name'];
@@ -334,7 +335,7 @@
 	/**
 	 * getDocGroupName - the doc_group_name of this document.
 	 *
-	 * @return string	The docgroupname.
+	 * @return	string	The docgroupname.
 	 */
 	function getDocGroupName() {
 		return $this->data_array['group_name'];
@@ -352,7 +353,7 @@
 	/**
 	 * getCreatorUserName - the unix name of the person who created this document.
 	 *
-	 * @return string	The unix name of the creator.
+	 * @return	string	The unix name of the creator.
 	 */
 	function getCreatorUserName() {
 		return $this->data_array['user_name'];
@@ -361,7 +362,7 @@
 	/**
 	 * getCreatorRealName - the real name of the person who created this document.
 	 *
-	 * @return string	The real name of the creator.
+	 * @return	string	The real name of the creator.
 	 */
 	function getCreatorRealName() {
 		return $this->data_array['realname'];
@@ -370,7 +371,7 @@
 	/**
 	 * getCreatorEmail - the email of the person who created this document.
 	 *
-	 * @return string	The email of the creator.
+	 * @return	string	The email of the creator.
 	 */
 	function getCreatorEmail() {
 		return $this->data_array['email'];
@@ -379,7 +380,7 @@
 	/**
 	 * getFileName - the filename of this document.
 	 *
-	 * @return string	The filename.
+	 * @return	string	The filename.
 	 */
 	function getFileName() {
 		return $this->data_array['filename'];
@@ -388,7 +389,7 @@
 	/**
 	 * getFileType - the filetype of this document.
 	 *
-	 * @return string	The filetype.
+	 * @return	string	The filetype.
 	 */
 	function getFileType() {
 		return $this->data_array['filetype'];
@@ -397,17 +398,16 @@
 	/**
 	 * getFileData - the filedata of this document.
 	 *
-	 * @return string	The filedata.
+	 * @return	string	The filedata.
 	 */
 	function getFileData() {
 		//
 		//	Because this could be a large string, we only fetch if we actually need it
 		//
-		$res = db_query_params ('SELECT data FROM doc_data WHERE docid=$1',
-					array ($this->getID())) ;
+		$res = db_query_params('SELECT data FROM doc_data WHERE docid=$1',array($this->getID()));
 		return base64_decode(db_result($res,0,'data'));
 	}
-	
+
 	/**
 	* getFileSize - Return the size of the document
 	*
@@ -416,10 +416,11 @@
 	function getFileSize() {
 		return $this->data_array['filesize'];
 	}
+
 	/**
 	 * getUpdated - get the time this document was updated.
 	 *
-	 * @return int	The epoch date this document was updated.
+	 * @return	int	The epoch date this document was updated.
 	 */
 	function getUpdated() {
 		return $this->data_array['updatedate'];
@@ -428,7 +429,7 @@
 	/**
 	 * getCreated - get the time this document was created.
 	 *
-	 * @return int	The epoch date this document was created.
+	 * @return	int	The epoch date this document was created.
 	 */
 	function getCreated() {
 		return $this->data_array['createdate'];
@@ -437,7 +438,7 @@
 	/**
 	 * getLocked - get the lock status of this document.
 	 *
-	 * @return int	The lock status of this document.
+	 * @return	int	The lock status of this document.
 	 */
 	function getLocked() {
 		return $this->data_array['locked'];
@@ -446,7 +447,7 @@
 	/**
 	 * getLockdate - get the lock time of this document.
 	 *
-	 * @return int	The lock time of this document.
+	 * @return	int	The lock time of this document.
 	 */
 	function getLockdate() {
 		return $this->data_array['lockdate'];
@@ -455,7 +456,7 @@
 	/**
 	 * getLockedBy - get the user id who set lock on this document.
 	 *
-	 * @return int	The user id who set lock on this document.
+	 * @return	int	The user id who set lock on this document.
 	 */
 	function getLockedBy() {
 		return $this->data_array['locked_by'];
@@ -464,7 +465,7 @@
 	/**
 	 * getReservedBy - get the owner of the reversed status of this document.
 	 *
-	 * @return int	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'];
@@ -473,7 +474,7 @@
 	/**
 	 * getReserved - get the reversed status of this document.
 	 *
-	 * @return int	The reversed status of this document.
+	 * @return	int	The reversed status of this document.
 	 */
 	function getReserved() {
 		return $this->data_array['reserved'];
@@ -496,7 +497,7 @@
 				if ( $i > 0 )
 					$comma = ',';
 
-				$values .=$comma.$arr['email'];
+				$values .= $comma.$arr['email'];
 				$i++;
 			}
 		}
@@ -516,7 +517,7 @@
 			$condition = 'user_id='.$userid.' AND';
 		}
 		$result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE '.$condition.' doc_id=$1',
-								array ($this->getID()));
+						array($this->getID()));
 
 		if (!$result || db_numrows($result) < 1)
 			return false;
@@ -532,7 +533,7 @@
 	 */
 	function removeMonitoredBy($userid) {
 		$result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id=$1 AND user_id=$2',
-								array ($this->getID(), $userid));
+						array ($this->getID(), $userid));
 
 		if (!$result) {
 			$this->setError(_('Unable To Remove Monitor').' : '.db_error());
@@ -549,11 +550,11 @@
 	 */
 	function addMonitoredBy($userid) {
 		$result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE user_id=$1 AND doc_id=$2',
-								array ($userid, $this->getID()));
+						array($userid, $this->getID()));
 
 		if (!$result || db_numrows($result) < 1) {
 			$result = db_query_params('INSERT INTO docdata_monitored_docman (doc_id,user_id) VALUES ($1,$2)',
-									array ($this->getID(), $userid));
+							array($this->getID(), $userid));
 
 			if (!$result) {
 				$this->setError(_('Unable To Add Monitor').' : '.db_error());
@@ -570,14 +571,14 @@
 	 * @return	boolean	success.
 	 */
 	function setState($stateid) {
-		$res = db_query_params ('UPDATE doc_data SET
-								stateid=$1
-								WHERE group_id=$2
-								AND docid=$3',
-								array ($stateid,
-					       			$this->Group->getID(),
-									$this->getID())
-								);
+		$res = db_query_params('UPDATE doc_data SET
+					stateid=$1
+					WHERE group_id=$2
+					AND docid=$3',
+					array($stateid,
+						$this->Group->getID(),
+						$this->getID())
+					);
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setOnUpdateError(db_error());
 			return false;
@@ -594,19 +595,19 @@
 	 * @param	time	the epoch time
 	 * @return	boolean	success
 	 */
-    function setLock($stateLock,$userid=NULL,$thistime=0) {
+	function setLock($stateLock, $userid = NULL, $thistime = 0) {
 		$res = db_query_params ('UPDATE doc_data SET
 					locked=$1,
 					locked_by=$2,
 					lockdate=$3
 					WHERE group_id=$4
 					AND docid=$5',
-					array ($stateLock,
+					array($stateLock,
 						$userid,
 						$thistime,
 						$this->Group->getID(),
-									$this->getID())
-								);
+						$this->getID())
+					);
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setOnUpdateError(_('Document lock failed').' '.db_error());
 			return false;
@@ -624,13 +625,13 @@
 	 * @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
+	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,
+					array($statusReserved,
 						$idReserver,
 						$this->Group->getID(),
 						$this->getID())
@@ -655,16 +656,15 @@
 	 * @param	int	The state id of the doc_states table.
 	 * @return	boolean	success.
 	 */
-	function update($filename,$filetype,$data,$doc_group,$title,$description,$stateid) {
+	function update($filename, $filetype, $data, $doc_group, $title, $description, $stateid) {
 		global $LUSER;
 
-		$perm =& $this->Group->getPermission ();
+		$perm =& $this->Group->getPermission();
 		if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
 			$this->setPermissionDeniedError();
 			return false;
 		}
 
-
 		if ($this->getLockedBy() != $LUSER->getID()) {
 			$this->setPermissionDeniedError();
 			return false;
@@ -681,7 +681,7 @@
 		}
 
 		$result = db_query_params('SELECT filename,doc_group from docdata_vw',
-					array($filename,$doc_group));
+						array($filename, $doc_group));
 
 		if ($data) {
 			if (!$result || db_numrows($res) > 0) {
@@ -690,30 +690,30 @@
 			}
 		}
 
-
 		$res = db_query_params ('UPDATE doc_data SET
-			title=$1,
-			description=$2,
-			stateid=$3,
-			doc_group=$4,
-			filetype=$5,
-			filename=$6,
-			updatedate=$7,
-			locked=$8,
-			locked_by=$9
-			WHERE group_id=$10
-			AND docid=$11',
-			array (htmlspecialchars($title),
-				htmlspecialchars($description),
-				$stateid,
-				$doc_group,
-				$filetype,
-				$filename,
-				time(),
-				0,
-				NULL,
-				$this->Group->getID(),
-				$this->getID())) ;
+					title=$1,
+					description=$2,
+					stateid=$3,
+					doc_group=$4,
+					filetype=$5,
+					filename=$6,
+					updatedate=$7,
+					locked=$8,
+					locked_by=$9
+					WHERE group_id=$10
+					AND docid=$11',
+					array(htmlspecialchars($title),
+						htmlspecialchars($description),
+						$stateid,
+						$doc_group,
+						$filetype,
+						$filename,
+						time(),
+						0,
+						NULL,
+						$this->Group->getID(),
+						$this->getID())
+					);
 
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setOnUpdateError(db_error());
@@ -725,17 +725,18 @@
 
 			// key words for in-document search
 			if ($this->Group->useDocmanSearch()) {
-				$kw = new Parsedata ($this->engine_path);
-				$kwords = $kw->get_parse_data ($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
+				$kw = new Parsedata($this->engine_path);
+				$kwords = $kw->get_parse_data($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
 			} else {
 				$kwords = '';
 			}
 
 			$res = db_query_params ('UPDATE doc_data SET filesize=$1, data_words=$2 WHERE group_id=$3 AND docid=$4',
-						array (strlen($data),
+						array(strlen($data),
 							$kwords,
 							$this->Group->getID(),
-							$this->getID())) ;
+							$this->getID())
+						);
 
 			if (!$res || db_affected_rows($res) < 1) {
 				$this->setOnUpdateError(db_error());
@@ -743,20 +744,23 @@
 			}
 
 			switch ($this->Group->getStorageAPI()) {
-			case 'DB':
-				$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()));
+				case 'DB': {
+					$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())
+								);
 
-				if (!$res || db_affected_rows($res) < 1) {
-					$this->setOnUpdateError(db_error());
+					if (!$res || db_affected_rows($res) < 1) {
+						$this->setOnUpdateError(db_error());
+						return false;
+					}
+					break;
+				}
+				default: {
+					$this->setOnUpdateError(_('No Storage API'));
 					return false;
 				}
-				break;
-			default:
-				$this->setOnUpdateError(_('No Storage API'));
-				return false;
 			}
 		}
 
@@ -784,45 +788,47 @@
 			$body = _('Project:').' '.$this->Group->getPublicName()."\n";
 			$body .= _('Directory:').' '.$this->getDocGroupName()."\n";
 			$body .= _('Document title:').' '.$this->getName()."\n";
-			$body .= _('Document description:').' '.util_unconvert_htmlspecialchars( $this->getDescription() )."\n";
+			$body .= _('Document description:').' '.util_unconvert_htmlspecialchars($this->getDescription())."\n";
 			$body .= _('Submitter:').' '.$this->getCreatorRealName()." (".$this->getCreatorUserName().") \n";
 			$body .= "\n\n-------------------------------------------------------\n".
 				_('For more info, visit:').
 				"\n\n" . util_make_url('/docman/?group_id='.$this->Group->getID().'&view=listfile&dirid='.$this->getDocGroupID());
 
-			util_send_message('',$subject,$body,'',$BCC);
+			util_send_message('', $subject, $body, '', $BCC);
 		}
 
 		return true;
 	}
-	
+
 	/**
 	 * delete - Delete this file
 	 *
 	 * @return	boolean	success
 	 */
 	function delete() {
-		$perm =& $this->Group->getPermission ();
+		$perm =& $this->Group->getPermission();
 		if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
 			$this->setPermissionDeniedError();
 			return false;
 		}
-		
-		$result = db_query_params ('DELETE FROM doc_data WHERE docid=$1',
-					   array ($this->getID())) ;
+
+		$result = db_query_params('DELETE FROM doc_data WHERE docid=$1',
+						array($this->getID()));
 		if (!$result) {
 			$this->setError(_('Error Deleting Document:').' '.db_error());
 			db_rollback();
 			return false;
 		}
-		
+
 		switch ($this->Group->getStorageAPI()) {
-		case 'DB':
-			break;
-		default:
-			$this->setError(_('Error Deleting Document: No Storage API'));
-			db_rollback();
-			return false;
+			case 'DB': {
+				break;
+			}
+			default: {
+				$this->setError(_('Error Deleting Document: No Storage API'));
+				db_rollback();
+				return false;
+			}
 		}
 
 		// we should be able to send a notice that this doc has been deleted .... but we need to rewrite sendNotice

Modified: trunk/src/common/docman/DocumentFactory.class.php
===================================================================
--- trunk/src/common/docman/DocumentFactory.class.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/DocumentFactory.class.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -46,7 +46,6 @@
 
 	var $stateid;
 	var $docgroupid;
-	var $sort='group_name, title';
 
 	/**
 	 * Constructor.
@@ -85,7 +84,7 @@
 	 * @param	int	The stateid from the doc_states table.
 	 */
 	function setStateID($stateid) {
-		$this->stateid=$stateid;
+		$this->stateid = $stateid;
 	}
 
 	/**
@@ -94,19 +93,10 @@
 	 * @param	int	The doc_group from the doc_groups table.
 	 */
 	function setDocGroupID($docgroupid) {
-		$this->docgroupid=$docgroupid;
+		$this->docgroupid = $docgroupid;
 	}
 
 	/**
-	 * setSort - call this before getDocuments() if you want to control the sorting.
-	 *
-	 * @param	string	The name of the field to sort on.
-	 */
-	function setSort($sort) {
-		$this->sort=$sort;
-	}
-
-	/**
 	 * getDocuments - returns an array of Document objects.
 	 *
 	 * @return	array	Document objects.
@@ -115,7 +105,7 @@
 		if (!$this->Documents) {
 			$this->getFromDB();
 		}
-		
+
 		$return = array();
 		// If the document group is specified, we should only check that group in
 		// the Documents array. If not, we should check ALL the groups.
@@ -124,31 +114,31 @@
 		} else {
 			$keys = array_keys($this->Documents);
 		}
-		
+
 		foreach ($keys as $key) {
-			if (!array_key_exists($key, $this->Documents)) continue;	// Should not happen
+			if (!array_key_exists($key, $this->Documents)) continue;		// Should not happen
 			$count = count($this->Documents[$key]);
-			
+
 			for ($i=0; $i < $count; $i++) {
-				$valid = true;		// do we need to return this document?
+				$valid = true;							// do we need to return this document?
 				$doc =& $this->Documents[$key][$i];
-				
+
 				if (!$this->stateid) {
 					if (session_loggedin()) {
-						$perm =& $this->Group->getPermission ();
+						$perm =& $this->Group->getPermission();
 						if (!$perm || !is_object($perm) || !$perm->isMember()) {
 							if ($doc->getStateID() != 1) {		// non-active document?
 								$valid = false;
 							}
 						} else {
 							if ($doc->getStateID() != 1 &&		/* not active */
-								$doc->getStateID() != 4 &&			/* not hidden */
-								$doc->getStateID() != 5) {			/* not private */
+								$doc->getStateID() != 4 &&	/* not hidden */
+								$doc->getStateID() != 5) {	/* not private */
 								$valid = false;
 							}
 						}
 					} else {
-						if ($doc->getStateID() != 1) {		// non-active document?
+						if ($doc->getStateID() != 1) {			// non-active document?
 							$valid = false;
 						}
 					}
@@ -178,18 +168,17 @@
 	 */
 	function getFromDB() {
 		$this->Documents = array();
-		$result = db_query_params ('SELECT * FROM docdata_vw ORDER BY title',
-					   array());
+		$result = db_query_params('SELECT * FROM docdata_vw WHERE group_id = $1 ORDER BY title',
+						array($this->Group->getID()));
 		if (!$result) {
-			exit_error(db_error(),'docman');
+			exit_error(db_error(), 'docman');
 		}
-		
+
 		while ($arr = db_fetch_array($result)) {
 			$doc_group_id = $arr['doc_group'];
 			if (!is_array(@$this->Documents[$doc_group_id])) {
 				$this->Documents[$doc_group_id] = array();
 			}
-			
 			$this->Documents[$doc_group_id][] = new Document($this->Group, $arr['docid'], $arr);
 		}
 	}
@@ -198,20 +187,20 @@
 	 * getStates - Return an array of states that have documents associated to them
 	 */
 	function getUsedStates() {
-		$result = db_query_params ('SELECT DISTINCT doc_states.stateid,doc_states.name 
-			FROM doc_states,doc_data
-			WHERE doc_data.stateid=doc_states.stateid
-			ORDER BY doc_states.name ASC',
-					   array());
+		$result = db_query_params('SELECT DISTINCT doc_states.stateid,doc_states.name 
+					FROM doc_states,doc_data
+					WHERE doc_data.stateid=doc_states.stateid
+					ORDER BY doc_states.name ASC',
+					array());
 		if (!$result) {
-			exit_error(db_error(),'docman');
+			exit_error(db_error(), 'docman');
 		}
-		
+
 		$return = array();
 		while ($arr = db_fetch_array($result)) {
 			$return[] = $arr;
 		}
-		
+
 		return $return;
 	}
 

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/DocumentGroup.class.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -35,7 +35,7 @@
 	 *
 	 * @var	object	$Group.
 	 */
-	var $Group; //object
+	var $Group;
 
 	/**
 	 * Array of data.
@@ -51,9 +51,9 @@
 	 *
 	 * @param	object	Group object.
 	 * @param	array	(all fields from doc_groups) OR doc_group from database.
-	 * @return boolean	success.
+	 * @return	boolean	success.
 	 */
-	function DocumentGroup(&$Group, $data=false) {
+	function DocumentGroup(&$Group, $data = false) {
 		$this->Error();
 
 		//was Group legit?
@@ -91,7 +91,7 @@
 	 * @param	string	Item name.
 	 * @return	boolean	on success / false on failure.
 	 */
-	function create($name,$parent_doc_group=0) {
+	function create($name, $parent_doc_group = 0) {
 		//
 		//	data validation
 		//
@@ -103,8 +103,7 @@
 		if ($parent_doc_group) {
 			// check if parent group exists
 			$res = db_query_params ('SELECT * FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
-						array ($parent_doc_group,
-						       $this->Group->getID())) ;
+						array($parent_doc_group, $this->Group->getID())) ;
 			if (!$res || db_numrows($res) < 1) {
 				$this->setError(_('DocumentGroup: Invalid Document Directory parent ID'));
 				return false;
@@ -113,26 +112,28 @@
 			$parent_doc_group = 0;
 		}
 
-		$perm =& $this->Group->getPermission ();
+		$perm =& $this->Group->getPermission();
 		if (!$perm || !$perm->isDocEditor()) {
 			$this->setPermissionDeniedError();
 			return false;
 		}
 		
 		$res=db_query_params('SELECT * FROM doc_groups WHERE groupname=$1 AND parent_doc_group=$2 AND group_id=$3',
-				array($name,
-					$parent_doc_group,
-					$this->Group->getID()));
+					array($name,
+						$parent_doc_group,
+						$this->Group->getID())
+					);
 		if ($res && db_numrows($res) > 0) {
 			$this->setError(_('Directory name already exists'));
 			return false;
 		}
 
 		$result = db_query_params ('INSERT INTO doc_groups (group_id,groupname,parent_doc_group,stateid) VALUES ($1, $2, $3, $4)',
-					   array ($this->Group->getID(),
-						  htmlspecialchars($name),
-                          $parent_doc_group,
-                          '1')) ;
+						array ($this->Group->getID(),
+							htmlspecialchars($name),
+							$parent_doc_group,
+							'1')
+						);
 		if ($result && db_affected_rows($result) > 0) {
 			$this->clearError();
 		} else {
@@ -142,7 +143,7 @@
 
 		$doc_group = db_insertid($result, 'doc_groups', 'doc_group');
 
-		//	Now set up our internal data structures
+		// Now set up our internal data structures
 		if (!$this->fetchData($doc_group)) {
 			return false;
 		}
@@ -152,7 +153,7 @@
 
 	/**
 	 * delete - delete a DocumentGroup.
-	 *          delete is recursive and permanent
+	 * WARNING delete is recursive and permanent
 	 * @param	int	Document Group Id, integer Project Group Id
 	 * @return	boolean	success
 	 */
@@ -164,24 +165,21 @@
 		}
 		db_begin();
 		/* delete documents in directory */
-		$result = db_query_params ('DELETE FROM doc_data where doc_group = $1 and group_id = $2',
-					array($doc_groupid,
-						$project_group_id));
+		$result = db_query_params('DELETE FROM doc_data where doc_group = $1 and group_id = $2',
+					array($doc_groupid, $project_group_id));
 
 		/* delete directory */
-		$result = db_query_params ('DELETE FROM doc_groups where doc_group = $1 and group_id = $2',
-					array($doc_groupid,
-						$project_group_id));
+		$result = db_query_params('DELETE FROM doc_groups where doc_group = $1 and group_id = $2',
+					array($doc_groupid, $project_group_id));
 
 		db_commit();
 
 		/* is there any subdir ? */
-		$subdir = db_query_params ('select doc_group from doc_groups where parent_doc_group = $1 and group_id = $2',
-					array($doc_groupid,
-						$project_group_id));
+		$subdir = db_query_params('select doc_group from doc_groups where parent_doc_group = $1 and group_id = $2',
+					array($doc_groupid, $project_group_id));
 		/* make a recursive call */
 		while ($arr = db_fetch_array($subdir)) {
-			$this->delete($arr['doc_group'],$project_group_id);
+			$this->delete($arr['doc_group'], $project_group_id);
 		}
 
 		if (!$result) {
@@ -197,8 +195,8 @@
 	 * @return	boolean	success
 	 */
 	function fetchData($id) {
-		$res = db_query_params ('SELECT * FROM doc_groups WHERE doc_group=$1',
-					array ($id)) ;
+		$res = db_query_params('SELECT * FROM doc_groups WHERE doc_group=$1',
+					array($id));
 		if (!$res || db_numrows($res) < 1) {
 			$this->setError(_('DocumentGroup: Invalid Document Directory ID'));
 			return false;
@@ -225,7 +223,7 @@
 	function getID() {
 		return $this->data_array['doc_group'];
 	}
-	
+
 	/**
 	 * getID - get parent DocumentGroup's id.
 	 *
@@ -259,7 +257,7 @@
 	 * @param	string	Name of the category.
 	 * @return boolean.
 	 */
-	function update($name,$parent_doc_group) {
+	function update($name, $parent_doc_group) {
 		$perm =& $this->Group->getPermission ();
 		if (!$perm || !$perm->isDocEditor()) {
 			$this->setPermissionDeniedError();
@@ -269,34 +267,37 @@
 			$this->setMissingParamsError();
 			return false;
 		}
-		
+
 		if ($parent_doc_group) {
 			// check if parent group exists
-			$res = db_query_params ('SELECT * FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
-						array ($parent_doc_group,
-						       $this->Group->getID())) ;
+			$res = db_query_params('SELECT * FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
+						array($parent_doc_group,
+							$this->Group->getID())
+						);
 			if (!$res || db_numrows($res) < 1) {
 				$this->setError(_('DocumentGroup: Invalid Document Directory parent ID'));
 				return false;
 			}
 		} else {
-			$parent_doc_group=0;
+			$parent_doc_group = 0;
 		}
 
-		$res=db_query_params ('SELECT * FROM doc_groups WHERE groupname=$1 AND parent_doc_group=$2 AND group_id=$3',
-				array($name,
+		$res=db_query_params('SELECT * FROM doc_groups WHERE groupname=$1 AND parent_doc_group=$2 AND group_id=$3',
+					array($name,
 						$parent_doc_group,
-						$this->Group->getID()));
+						$this->Group->getID())
+					);
 		if ($res && db_numrows($res) > 0) {
 			$this->setError(_('Directory name already exists'));
 			return false;
 		}
 
-		$result = db_query_params ('UPDATE doc_groups SET groupname=$1, parent_doc_group=$2 WHERE doc_group=$3 AND group_id=$4',
-					   array(htmlspecialchars($name),
-						 $parent_doc_group,
-						 $this->getID(),
-						 $this->Group->getID())) ;
+		$result = db_query_params('UPDATE doc_groups SET groupname=$1, parent_doc_group=$2 WHERE doc_group=$3 AND group_id=$4',
+						array(htmlspecialchars($name),
+							$parent_doc_group,
+							$this->getID(),
+							$this->Group->getID())
+					);
 		if ($result && db_affected_rows($result) > 0) {
 			return true;
 		} else {
@@ -304,7 +305,7 @@
 			return false;
 		}
 	}
-		
+
 	/**
 	* hasDocuments - Recursive function that checks if this group or any of it childs has documents associated to it
 	*
@@ -316,12 +317,14 @@
 	* @param	int	(optional) State of the documents
 	* @return	boolean	success
 	*/
-	function hasDocuments(&$nested_groups, &$document_factory, $stateid=0) {
+	function hasDocuments(&$nested_groups, &$document_factory, $stateid = 0) {
 		$doc_group_id = $this->getID();
 		static $result = array();	// this function will probably be called several times so we better store results in order to speed things up
-		if (!array_key_exists($stateid, $result) || !is_array($result[$stateid])) $result[$stateid] = array();
+		if (!array_key_exists($stateid, $result) || !is_array($result[$stateid]))
+			$result[$stateid] = array();
 
-		if (array_key_exists($doc_group_id, $result[$stateid])) return $result[$stateid][$doc_group_id];
+		if (array_key_exists($doc_group_id, $result[$stateid]))
+			return $result[$stateid][$doc_group_id];
 
 		// check if it has documents
 		if ($stateid) {
@@ -333,9 +336,9 @@
 			$result[$stateid][$doc_group_id] = true;
 			return true;
 		}
-		
+
 		// this group doesn't have documents... check recursively on the childs
-		if (array_key_exists($doc_group_id,$nested_groups) && is_array($nested_groups[$doc_group_id])) {
+		if (array_key_exists($doc_group_id, $nested_groups) && is_array($nested_groups[$doc_group_id])) {
 			$count = count($nested_groups[$doc_group_id]);
 			for ($i=0; $i < $count; $i++) {
 				if ($nested_groups[$doc_group_id][$i]->hasDocuments($nested_groups, $document_factory, $stateid)) {
@@ -357,7 +360,7 @@
 	* hasSubgroup - Checks if this group has a specified subgroup associated to it
 	*
 	* @param	array	Array of nested groups information, fetched from DocumentGroupFactory class
-	* @param	int		ID of the subgroup
+	* @param	int	ID of the subgroup
 	* @return	boolean	success
 	*/
 	function hasSubgroup(&$nested_groups, $doc_subgroup_id) {
@@ -383,14 +386,15 @@
 	/**
 	 * setStateID - set the state id of this document group
 	 *
-	 * @param	int		State ID
+	 * @param	int	State ID
 	 * @return	boolean success
 	 */
 	function setStateID($stateid) {
-		$res = db_query_params ('UPDATE doc_groups SET stateid=$1
-								WHERE doc_group=$2
-								AND group_id=$3',
-								array ($stateid,$this->getID(),$this->Group->getID()));
+		$res = db_query_params('UPDATE doc_groups SET stateid=$1
+							WHERE doc_group=$2
+							AND group_id=$3',
+							array ($stateid,$this->getID(),$this->Group->getID())
+					);
 
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setOnUpdateError(_('DocumentGroup:').' '.db_error());

Modified: trunk/src/common/docman/DocumentGroupFactory.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroupFactory.class.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/DocumentGroupFactory.class.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -55,9 +55,9 @@
 	 */
 	function DocumentGroupFactory(&$Group) {
 		$this->Error();
-		
+
 		if (!$Group || !is_object($Group)) {
-			$this->setError(_("DocumentGroupFactory:: Invalid Project"));
+			$this->setError(_('DocumentGroupFactory:: Invalid Project'));
 			return false;
 		}
 		if ($Group->isError()) {
@@ -75,15 +75,15 @@
 	 * @param	int	The stateid of DocumentGroup.
 	 * @return	array	The array of DocumentGroup.
 	 */
-	function &getNested($stateid=1) {
+	function &getNested($stateid = 1) {
 		if ($this->nested_groups) {
 			return $this->nested_groups;
 		}
-		
-		$result = db_query_params ('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
-						array ($this->Group->getID(),$stateid));
+
+		$result = db_query_params('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
+						array($this->Group->getID(), $stateid));
 		$rows = db_numrows($result);
-		
+
 		if (!$result) {
 			$this->setError(_('No Document Directory Found').' '.db_error());
 			return false;
@@ -92,7 +92,7 @@
 				$this->flat_groups[] = new DocumentGroup($this->Group, $arr);
 			}
 		}
-		
+
 		// Build the nested array
 		$count = count($this->flat_groups);
 		for ($i=0; $i < $count; $i++) {
@@ -108,13 +108,13 @@
 	 * @param	int	The stateid of DocumentGroups
 	 * @return	array	The array of DocumentGroup.
 	 */
-	function &getDocumentGroups($stateid=1) {
+	function &getDocumentGroups($stateid = 1) {
 		if ($this->flat_groups) {
 			return $this->flat_groups;
 		}
 
-		$result = db_query_params ('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
-						array ($this->Group->getID(),$stateid)) ;
+		$result = db_query_params('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
+						array($this->Group->getID(), $stateid));
 		$rows = db_numrows($result);
 
 		if (!$result || $rows < 1) {

Modified: trunk/src/common/docman/Parsedata.class.php
===================================================================
--- trunk/src/common/docman/Parsedata.class.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/Parsedata.class.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -41,7 +41,7 @@
 		return true;
 	}
 
-	function get_parse_data ($data, $title, $description, $filetype) {
+	function get_parse_data($data, $title, $description, $filetype) {
 		$parser = "";
 		$rep = "";
 		$data1 = $data;
@@ -72,13 +72,13 @@
 		return preg_replace("/\n/", " ", "$rep $rep1");
 	}
 
-	function print_debug ($text) {
+	function print_debug($text) {
 		echo "$text \n";
 		ob_flush();
 	}
 }
 
-function get_parser_list ($parser_path) {
+function get_parser_list($parser_path) {
 	$file = $parser_path."parser_list.txt";
 	$rep = array();
 	$fp = fopen ($file, "r");

Modified: trunk/src/common/docman/actions/addfile.php
===================================================================
--- trunk/src/common/docman/actions/addfile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/addfile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -29,55 +29,55 @@
 global $g; //group object
 global $group_id; // id of group
 
-session_require_perm ('docman',$group_id,'submit');
+session_require_perm('docman', $group_id, 'submit');
 
-$upload_dir = forge_get_config('ftp_upload_dir') . "/" . $g->getUnixName();
+$upload_dir = forge_get_config('ftp_upload_dir') . '/' . $g->getUnixName();
 
 $doc_group = getIntFromRequest('doc_group');
 $title = getStringFromRequest('title');
 $description = getStringFromRequest('description');
 $file_url = getStringFromRequest('file_url');
-//$ftp_filename = getStringFromRequest('ftp_filename');
 $uploaded_data = getUploadedFile('uploaded_data');
 $type = getStringFromRequest('type');
 $name = getStringFromRequest('name');
 
 if (!$doc_group || $doc_group == 100) {
-	//cannot add a doc unless an appropriate group is provided		
-    $return_msg= _('No valid Document Directory was selected.');
-    session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+	//cannot add a doc unless an appropriate group is provided
+	$return_msg = _('No valid Document Directory was selected.');
+	session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
 }
 	
-if (!$title || !$description || (!$uploaded_data && !$file_url && (!$editor && !$name ) )) {
-    $missing_params = array();
-    if (!$title)
-        $missing_params[] = 'title';
+if (!$title || !$description || (!$uploaded_data && !$file_url && (!$editor && !$name))) {
+	$missing_params = array();
+	if (!$title)
+		$missing_params[] = 'title';
 
-    if (!$description)
-        $missing_params[] = 'description';
+	if (!$description)
+		$missing_params[] = 'description';
 
+	if (forge_get_config('use_ssl'))
+		$url = "https://";
+	else
+		$url = "http://";
 
-    if (forge_get_config('use_ssl'))
-        $url = "https://" ;
-    else
-        $url = "http://" ;
+	$url .= forge_get_config('web_host');
 
-    $url .= forge_get_config('web_host') ;
-
-	exit_missing_param(substr($_SERVER['HTTP_REFERER'],strlen($url)),$missing_params,'docman');
+	exit_missing_param(substr($_SERVER['HTTP_REFERER'], strlen($url)),$missing_params,'docman');
 }
 
 if (empty($gfcommon)) {
-    $engine_dir = '../../common';
+	$engine_dir = '../../common';
 } else {
-    $engine_dir = $gfcommon;
+	$engine_dir = $gfcommon;
 }
-$d = new Document($g, false, false,$engine_dir.'/docman/engine/');
-if (!$d || !is_object($d)) {		
-    $return_msg= _('Error getting blank document.');
-    session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
-} elseif ($d->isError()) {	
-    session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($d->getErrorMessage()));
+
+$d = new Document($g, false, false, $engine_dir.'/docman/engine/');
+
+if (!$d || !is_object($d)) {
+	$return_msg= _('Error getting blank document.');
+	session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+} elseif ($d->isError()) {
+	session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($d->getErrorMessage()));
 }
 
 switch ($type) {
@@ -87,54 +87,52 @@
 		$sanitizer = new TextSanitizer();
 		$data = $sanitizer->SanitizeHtml($data);
 		if (strlen($data)<1) {
-	        $return_msg= _('Error getting blank document.');
-		    session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+			$return_msg = _('Error getting blank document.');
+			session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
 		}
-		$uploaded_data_type='text/html';
+		$uploaded_data_type = 'text/html';
 		break;
 	}
 	case 'pasteurl' : {
 		$data = '';
-		$uploaded_data_name=$file_url;
-		$uploaded_data_type='URL';
+		$uploaded_data_name = $file_url;
+		$uploaded_data_type = 'URL';
 		break;
 	}
 	case 'httpupload' : {
-		if (!is_uploaded_file($uploaded_data['tmp_name'])) {			
-	        $return_msg= _('Invalid file name.');
-		    session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+		if (!is_uploaded_file($uploaded_data['tmp_name'])) {
+		$return_msg = _('Invalid file name.');
+			session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
 		}
 		$data = fread(fopen($uploaded_data['tmp_name'], 'r'), $uploaded_data['size']);
-		$file_url='';
-		$uploaded_data_name=$uploaded_data['name'];
-		$uploaded_data_type=$uploaded_data['type'];
+		$file_url = '';
+		$uploaded_data_name = $uploaded_data['name'];
+		$uploaded_data_type = $uploaded_data['type'];
 		break;
 	}
-	/*
-	case 'ftpupload' : {	
-		$uploaded_data_name=$upload_dir.'/'.$ftp_filename;
-		$data = fread(fopen($uploaded_data_name, 'r'), filesize($uploaded_data_name));
+	default: {
+		$return_msg = _('Unknown type submission.');
+		session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
 	}
-	*/
 }
 
-if (!$d->create($uploaded_data_name,$uploaded_data_type,$data,$doc_group,$title,$description)) {
-	if (forge_check_perm ('docman', $group_id, 'approve')) {
+if (!$d->create($uploaded_data_name, $uploaded_data_type, $data, $doc_group, $title, $description)) {
+	if (forge_check_perm('docman', $group_id, 'approve')) {
 		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'&error_msg='.urlencode($d->getErrorMessage()));
-    } else {
+	} else {
 		session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($d->getErrorMessage()));
-    }
+	}
 } else {
 	if ($type == 'editor') {
 		//release the cookie for the document contents (should expire at the end of the session anyway)
-		setcookie ("gforgecurrentdocdata", "", time() - 3600);
+		setcookie("gforgecurrentdocdata", "", time() - 3600);
 	}
 	// check if the user is docman's admin
-	if (forge_check_perm ('docman', $group_id, 'approve')) {
-		$return_msg= _('Document submitted successfully');
+	if (forge_check_perm('docman', $group_id, 'approve')) {
+		$return_msg = _('Document submitted successfully.');
 		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'&feedback='.urlencode($return_msg));
-    } else {
-		$return_msg= _('Document submitted successfully : pending state (need validation)');
+	} else {
+		$return_msg = _('Document submitted successfully : pending state (need validation).');
 		session_redirect('/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg));
 	}
 }

Modified: trunk/src/common/docman/actions/addsubdocgroup.php
===================================================================
--- trunk/src/common/docman/actions/addsubdocgroup.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/addsubdocgroup.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -30,8 +30,8 @@
 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');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Document Action Denied.');
 	if ($dirid) {
 		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
 	} else {
@@ -49,10 +49,10 @@
 		session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($dg->getErrorMessage()));
 
 	if ($dirid) {
-		$return_msg = _('Document Sub Directory successfully created');
+		$return_msg = _('Document Sub Directory successfully created.');
 		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
 	} else {
-		$return_msg = _('Document Directory successfully created');
+		$return_msg = _('Document Directory successfully created.');
 		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dg->getID().'&feedback='.urlencode($return_msg));
 	}
 }

Modified: trunk/src/common/docman/actions/deldir.php
===================================================================
--- trunk/src/common/docman/actions/deldir.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/deldir.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -31,18 +31,18 @@
 global $group_id; // id of group
 
 if (!forge_check_perm('docman', $group_id, 'approve')) {
-	$return_msg = _('Docman Action Denied');
+	$return_msg = _('Docman Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
 } else {
 
-	$dg = new DocumentGroup($g,$dirid);
+	$dg = new DocumentGroup($g, $dirid);
 	if ($dg->isError())
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
 
-	if (!$dg->delete($dirid,$group_id))
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+	if (!$dg->delete($dirid, $group_id))
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
 
-	$return_msg = _('Document Directory deleted successfully');
+	$return_msg = _('Document Directory deleted successfully.');
 	session_redirect('/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg));
 }
 ?>

Modified: trunk/src/common/docman/actions/editdocgroup.php
===================================================================
--- trunk/src/common/docman/actions/editdocgroup.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/editdocgroup.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -32,13 +32,13 @@
 $groupname = getStringFromRequest('groupname');
 $parent_dirid = getIntFromRequest('parent_dirid');
 
-$dg = new DocumentGroup($g,$dirid);
+$dg = new DocumentGroup($g, $dirid);
 if ($dg->isError())
-    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
 
-if (!$dg->update($groupname,$parent_dirid))
-    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+if (!$dg->update($groupname, $parent_dirid))
+	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
 
-$return_msg = _('Document Directory Updated successfully');
+$return_msg = _('Document Directory Updated successfully.');
 session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
 ?>

Modified: trunk/src/common/docman/actions/editfile.php
===================================================================
--- trunk/src/common/docman/actions/editfile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/editfile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -30,7 +30,7 @@
 global $group_id; // id of group
 
 if (!forge_check_perm('docman', $group_id, 'approve')) {
-	$return_msg = _('Document Action Denied');
+	$return_msg = _('Document Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
 } else {
 	$doc_group = getIntFromRequest('doc_group');
@@ -39,21 +39,20 @@
 	$description = getStringFromRequest('description');
 	$data = getStringFromRequest('details'.$docid);
 	$file_url = getStringFromRequest('file_url');
-	//$ftp_filename = getStringFromRequest('ftp_filename');
 	$uploaded_data = getUploadedFile('uploaded_data');
 	$stateid = getIntFromRequest('stateid');
 	$filetype = getStringFromRequest('filetype');
 	$editor = getStringFromRequest('editor');
-    $fromview = getStringFromRequest('fromview');
-    if ( 'admin' == $fromview ) {
-        $urlparam = '&view='.$fromview;
-    } else {
-        $urlparam = '&view=listfile&dirid='.$doc_group;
-    }
+	$fromview = getStringFromRequest('fromview');
+	if ( 'admin' == $fromview ) {
+		$urlparam = '&view='.$fromview;
+	} else {
+		$urlparam = '&view=listfile&dirid='.$doc_group;
+	}
 
 	$d= new Document($g,$docid,false,$gfcommon.'docman/engine/');
 	if ($d->isError())
-	    session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
 
 	$sanitizer = new TextSanitizer();
 	$data = $sanitizer->SanitizeHtml($data);
@@ -64,38 +63,24 @@
 
 	} elseif (!empty($uploaded_data) && $uploaded_data['name']) {
 		if (!is_uploaded_file($uploaded_data['tmp_name'])) {
-			$return_msg = sprintf(_('Invalid file attack attempt %1$s'), $uploaded_data['name']);
-	        session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($return_msg));
-        }
-
+			$return_msg = sprintf(_('Invalid file attack attempt %1$s.'), $uploaded_data['name']);
+		session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($return_msg));
+		}
 		$data = fread(fopen($uploaded_data['tmp_name'], 'r'), $uploaded_data['size']);
-		$filename=$uploaded_data['name'];
-		$filetype=$uploaded_data['type'];
+		$filename = $uploaded_data['name'];
+		$filetype = $uploaded_data['type'];
 	} elseif ($file_url) {
 		$data = '';
-		$filename=$file_url;
-		$filetype='URL';
-	/*
-	} elseif (forge_get_config('use_ftp_uploads') && $ftp_filename!=100) { //100==None
-		$filename=$upload_dir.'/'.$ftp_filename;
-		$data = fread(fopen($filename, 'r'), filesize($filename));
-		$filetype=$uploaded_data_type;
-	} elseif (forge_get_config('use_manual_uploads') && $uploaded_filename!=100 && util_is_valid_filename($uploaded_filename)) { //100==None
-		$incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
-		$filename = $incoming.'/'.$uploaded_filename;
-		$data = addslashes(fread(fopen($filename, 'r'), filesize($filename)));
-		$finfo = finfo_open (FILEINFO_MIME_TYPE) ;
-		$filetype = finfo_file($finfo, $filename) ;
-		finfo_close ($finfo) ;
-	*/
+		$filename = $file_url;
+		$filetype = 'URL';
 	} else {
-		$filename=$d->getFileName();
-		$filetype=$d->getFileType();
+		$filename = $d->getFileName();
+		$filetype = $d->getFileType();
 	}
-	if (!$d->update($filename,$filetype,$data,$doc_group,$title,$description,$stateid))
-	    session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
+	if (!$d->update($filename, $filetype, $data, $doc_group, $title, $description, $stateid))
+		session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
 
-	$return_msg = _('Document Updated successfully');
+	$return_msg = _('Document Updated successfully.');
 	session_redirect('/docman/?group_id='.$group_id.$urlparam.'&feedback='.urlencode($return_msg));
 }
 ?>

Modified: trunk/src/common/docman/actions/emptytrash.php
===================================================================
--- trunk/src/common/docman/actions/emptytrash.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/emptytrash.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -28,21 +28,20 @@
 global $dirid; //id of doc_group
 global $group_id; // id of group
 
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg= _('Docman Action Denied');
+if ( !forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Docman Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
 } else {
-
 	/* you must first delete files before dirs because of database constraints */
 	$emptyFile = db_query_params('DELETE FROM doc_data WHERE stateid=$1 and group_id=$2',array('2',$group_id));
 	if (!$emptyFile)
-	    session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
+		session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
 
 	$emptyDir = db_query_params('DELETE FROM doc_groups WHERE stateid=$1 and group_id=$2',array('2',$group_id));
 	if (!$emptyDir)
-	    session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
+		session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
 
-	$return_msg = _('Emptied Trash successfully');
+	$return_msg = _('Emptied Trash successfully.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
 }
 ?>

Modified: trunk/src/common/docman/actions/enforcereserve.php
===================================================================
--- trunk/src/common/docman/actions/enforcereserve.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/enforcereserve.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -28,21 +28,21 @@
 global $dirid; //id of doc_group
 global $group_id; // id of group
 
-if (!forge_check_perm ('docman', $group_id, 'admin')) {
-	$return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'admin')) {
+	$return_msg = _('Docman 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);
+	$d = new Document($g, $fileid);
 
 	if ($d->isError())
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+		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()));
+	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');
+	$return_msg = _('Document reservation enforced successfully.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
 }
 ?>

Modified: trunk/src/common/docman/actions/forcereindexenginesearch.php
===================================================================
--- trunk/src/common/docman/actions/forcereindexenginesearch.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/forcereindexenginesearch.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -27,17 +27,17 @@
 global $g; //group object
 global $group_id; // id of group
 
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg= _('Docman Action Denied');
+if ( !forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Docman Action Denied');
 	session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
 } else {
 	if ($_POST['status']) {
 		$status = 1;
-		$return_msg= _('Search Engine Reindex Forced : search results will be available within 24h');
+		$return_msg = _('Search Engine Reindex Forced : search results will be available within 24h.');
 	}
 
 	if (!$g->setDocmanForceReindexSearch($status))
-	    session_redirect('/docman/?group_id='.$group_id.'&view=admin&error_msg='.urlencode($g->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=admin&error_msg='.urlencode($g->getErrorMessage()));
 
 	session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
 }

Modified: trunk/src/common/docman/actions/lockfile.php
===================================================================
--- trunk/src/common/docman/actions/lockfile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/lockfile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -28,23 +28,23 @@
 global $group_id; // id of group
 global $LUSER; // User object
 
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Docman Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
 } else {
 
 	$fileid = getIntFromRequest('fileid');
-    $lock = getIntFromRequest('lock');
-	$d= new Document($g,$fileid);
+	$lock = getIntFromRequest('lock');
+	$d = new Document($g, $fileid);
 
 	if ($d->isError())
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
 
-    if ($lock == 0) {
-	    echo $d->setLock($lock);
-    } else {
-        echo $d->setLock($lock,$LUSER->getID(),time());
-    }
-    exit;
+	if ($lock == 0) {
+		echo $d->setLock($lock);
+	} else {
+		echo $d->setLock($lock, $LUSER->getID(), time());
+	}
+	exit;
 }
 ?>

Modified: trunk/src/common/docman/actions/monitorfile.php
===================================================================
--- trunk/src/common/docman/actions/monitorfile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/monitorfile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -28,36 +28,38 @@
 global $group_id; // id of group
 global $LUSER; // User object
 
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Docman Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
 } else {
-
 	$fileid = getIntFromRequest('fileid');
-    $option = getStringFromRequest('option');
-	$d= new Document($g,$fileid);
+	$option = getStringFromRequest('option');
+	$d = new Document($g, $fileid);
 
 	if ($d->isError())
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
 
 	switch ($option) {
-	case "add":
-		if (!$d->addMonitoredBy($LUSER->getID())) {
-	    	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
-		} else {
-			$feedback = _('Monitoring started');
+		case "add": {
+			if (!$d->addMonitoredBy($LUSER->getID())) {
+				session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+			} else {
+				$feedback = _('Monitoring started.');
+			}
+			break;
 		}
-		break;
-	case "remove":
-		if (!$d->removeMonitoredBy($LUSER->getID())) {
-	    	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
-		} else {
-			$feedback = _('Monitoring stopped');
+		case "remove": {
+			if (!$d->removeMonitoredBy($LUSER->getID())) {
+				session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+			} else {
+				$feedback = _('Monitoring stopped.');
+			}
+			break;
 		}
-		break;
-	default:
-		$error_msg = _('Docman : monitoring action unknown');
-	   	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($error_msg));
+		default: {
+			$error_msg = _('Docman : monitoring action unknown.');
+			session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($error_msg));
+		}
 	}
 
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($feedback));

Modified: trunk/src/common/docman/actions/releasefile.php
===================================================================
--- trunk/src/common/docman/actions/releasefile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/releasefile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -27,21 +27,21 @@
 global $dirid; //id of doc_group
 global $group_id; // id of group
 
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Docman 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);
+	$d= new Document($g, $fileid);
 
 	if ($d->isError())
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+		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()));
+	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');
+	$return_msg = _('Document released successfully.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
 }
 ?>

Modified: trunk/src/common/docman/actions/reservefile.php
===================================================================
--- trunk/src/common/docman/actions/reservefile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/reservefile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -28,21 +28,21 @@
 global $group_id; // id of group
 global $LUSER; // User object
 
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Docman 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);
+	$d = new Document($g, $fileid);
 
 	if ($d->isError())
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+		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()));
+	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');
+	$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/actions/trashdir.php
===================================================================
--- trunk/src/common/docman/actions/trashdir.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/trashdir.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -32,28 +32,28 @@
 global $dgf; // document group factory of this group
 global $d_arr; // documents array of this group
 
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg = _('Document Action Denied');
+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 {
 
 	/* when moving a document group to trash, it's recursive and it's applied to documents that belong to these document groups */
 	/* Get the document groups info */
 	$trashnested_groups =& $dgf->getNested();
-	$trashnested_docs=array();
+	$trashnested_docs = array();
 	/* put the doc objects into an array keyed of the docgroup */
 	foreach ($d_arr as $doc) {
 		$trashnested_docs[$doc->getDocGroupID()][] = $doc;
 	}
 
 	/* set to trash content of this dirid */
-	docman_recursive_stateid($dirid,$trashnested_groups,$trashnested_docs,2);
+	docman_recursive_stateid($dirid, $trashnested_groups, $trashnested_docs, 2);
 
 	/* set this dirid to trash */
-	$dg = new DocumentGroup($g,$dirid);
+	$dg = new DocumentGroup($g, $dirid);
 	$dg->setStateID('2');
 
-	$return_msg = _('Document Directory moved to trash successfully');
+	$return_msg = _('Document Directory moved to trash successfully.');
 	session_redirect('/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg));
 }
 ?>

Modified: trunk/src/common/docman/actions/trashfile.php
===================================================================
--- trunk/src/common/docman/actions/trashfile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/trashfile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -30,21 +30,21 @@
 global $dirid; //id of doc_group
 global $group_id; // id of group
 
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg = _('Docman 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);
+	$d = new Document($g, $fileid);
 
 	if ($d->isError())
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
 
-	if ( !$d->setState('2') )
-	    session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+	if (!$d->setState('2'))
+		session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
 
-	$return_msg = _('Document moved to trash successfully');
+	$return_msg = _('Document moved to trash successfully.');
 	session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
 }
 ?>

Modified: trunk/src/common/docman/actions/updatecreateonline.php
===================================================================
--- trunk/src/common/docman/actions/updatecreateonline.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/updatecreateonline.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -22,21 +22,23 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg= _('Docman Action Denied');
+/* please do not add require here : use www/docman/index.php to add require */
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg= _('Docman Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
 } else {
 
 	if ($_POST['status']) {
 		$status = 1;
-		$return_msg= _('Create Online Documents Status updated successfully : Active');
+		$return_msg = _('Create Online Documents Status updated successfully : Active.');
 	} else {
 		$status = 0;
-		$return_msg= _('Create Online Documents Status updated successfully : Off');
+		$return_msg = _('Create Online Documents Status updated successfully : Off.');
 	}
 
 	if (!$g->setDocmanCreateOnlineStatus($status))
-	    session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
 
 	session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
 }

Modified: trunk/src/common/docman/actions/updateenginesearch.php
===================================================================
--- trunk/src/common/docman/actions/updateenginesearch.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/updateenginesearch.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -22,21 +22,23 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg= _('Docman Action Denied');
+/* please do not add require here : use www/docman/index.php to add require */
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg= _('Docman Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
 } else {
 
 	if ($_POST['status']) {
 		$status = 1;
-		$return_msg= _('Search Engine Status updated successfully : Active');
+		$return_msg = _('Search Engine Status updated successfully : Active.');
 	} else {
 		$status = 0;
-		$return_msg= _('Search Engine Status updated successfully : Off');
+		$return_msg = _('Search Engine Status updated successfully : Off.');
 	}
 
 	if (!$g->setDocmanSearchStatus($status))
-	    session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
 
 	session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
 }

Modified: trunk/src/common/docman/actions/updatewebdavinterface.php
===================================================================
--- trunk/src/common/docman/actions/updatewebdavinterface.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/actions/updatewebdavinterface.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -22,21 +22,23 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
-	$return_msg= _('Docman Action Denied');
+/* please do not add require here : use www/docman/index.php to add require */
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+	$return_msg= _('Docman Action Denied.');
 	session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
 } else {
 
 	if ($_POST['status']) {
 		$status = 1;
-		$return_msg= _('Webdav Interface updated successfully : Active');
+		$return_msg = _('Webdav Interface updated successfully : Active.');
 	} else {
 		$status = 0;
-		$return_msg= _('Webdav Interface updated successfully : Off');
+		$return_msg = _('Webdav Interface updated successfully : Off.');
 	}
 
 	if (!$g->setDocmanWebdav($status))
-	    session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
+		session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
 
 	session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
 }

Modified: trunk/src/common/docman/engine/parser_doc.php
===================================================================
--- trunk/src/common/docman/engine/parser_doc.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/engine/parser_doc.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -29,23 +29,21 @@
 require_once $gfcommon.'docman/engine/parser_text.inc.php';
 
 
-if ($argc != 2)
-{
+if ($argc != 2) {
 	echo "Usage : parser_doc.php <filename>\n";
 	exit (1);
 }
 
 $fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+	exit (1);
+
 $fichout = "/tmp/gfo".rand(10000, 99999).".tmp";
 $cmd = "/usr/bin/antiword -i1 -t $fichin > $fichout";
 $res = shell_exec($cmd);
 
 
-$rep = parser_text($fichout);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface les fichiers témporaires
+echo parser_text($fichout);
 unlink ($fichout);
 
 // Local Variables:

Modified: trunk/src/common/docman/engine/parser_html.php
===================================================================
--- trunk/src/common/docman/engine/parser_html.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/engine/parser_html.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -29,28 +29,26 @@
 
 require_once $gfcommon.'docman/engine/parser_text.inc.php';
 
-if ($argc != 2)
-{
+if ($argc != 2) {
 	echo "Usage : parser_html.php <filename>\n";
 	exit (1);
 }
+
 $fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+	exit (1);
 
 $fd = fopen($fichin, "r");
 $contents = fread($fd, filesize($fichin));
 fclose($fd);
 
 $strip_content = strip_tags($contents);
-$filename = tempnam("/tmp","tmp");
+$filename = tempnam("/tmp", "tmp");
 $fd = fopen($filename, "w");
-fwrite ( $fd , $strip_content );
+fwrite($fd , $strip_content);
 fclose($fd);
 
-$rep = parser_text($filename);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface le fichier source
+echo parser_text($filename);
 unlink ($fichin);
 
 // Local Variables:

Modified: trunk/src/common/docman/engine/parser_oo.php
===================================================================
--- trunk/src/common/docman/engine/parser_oo.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/engine/parser_oo.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -29,31 +29,32 @@
 require_once $gfcommon.'docman/engine/parser_text.inc.php';
 
 
-if ($argc != 2)
-{
+if ($argc != 2) {
 	echo "Usage : parser_oo.php <filename>\n";
 	exit (1);
 }
 
 $fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+	exit (1);
+
 $zip = new ZipArchive;
 if ($zip->open($fichin) === TRUE) {
 	$output_dir = $fichin.".dir";
 	mkdir($output_dir);
-	$zip->extractTo($output_dir,array('content.xml'));
+	$zip->extractTo($output_dir, array('content.xml'));
 	$zip->close();
 } else {
 	exit (2);
 }
+
 // transformer le context.xml en fichier txt
 $regexp_oo = "sed -e 's/<[^>]*>//g;s/&lt;/</g;s/&gt;/>/g;s/&apos;/'\"'\"'/g;s/&quot;/\"/g;s/&amp;/\&/g'";
 
 $cmd = $regexp_oo." ".$output_dir."/content.xml > ".$output_dir."/content.xml.txt";
 
 $res = shell_exec($cmd);
-$rep = parser_text($output_dir.'/content.xml.txt');
-echo "$rep";
+echo parser_text($output_dir.'/content.xml.txt');
 
 unlink($output_dir.'/content.xml');
 unlink($output_dir.'/content.xml.txt');

Modified: trunk/src/common/docman/engine/parser_pdf.php
===================================================================
--- trunk/src/common/docman/engine/parser_pdf.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/engine/parser_pdf.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -30,22 +30,20 @@
 require_once $gfcommon.'docman/engine/parser_text.inc.php';
 
 
-if ($argc != 2)
-{
+if ($argc != 2) {
 	echo "Usage : parser_pdf.php <filename>\n";
 	exit (1);
 }
 
 $fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+	exit (1);
+
 $fichout = tempnam("/tmp","tmp");
 $cmd = "/usr/bin/pdftotext $fichin $fichout";
 $res = shell_exec($cmd);
 
-$rep = parser_text($fichout);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface les fichiers témporaires
+echo parser_text($fichout);
 unlink ($fichout);
 
 // Local Variables:

Modified: trunk/src/common/docman/engine/parser_text.inc.php
===================================================================
--- trunk/src/common/docman/engine/parser_text.inc.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/engine/parser_text.inc.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -23,10 +23,11 @@
  * USA
  */
 
-function parser_text($fichin)
-{
+function parser_text($fichin) {
 	$tstart = microtime_float();
-	if (!is_file($fichin)) return "";
+	if (!is_file($fichin))
+		return "";
+
 	$fp = fopen ($fichin, "r");
 	$buff = fread ($fp, filesize($fichin));
 	// tout en minuscules
@@ -38,7 +39,6 @@
 	$buff = suppression_diacritics($buff);
 	// tous les mots dans un tableau
 	$a = explode(" ", $buff);
-	//sort($a);
 	// élimination des doublons
 	$a = array_unique($a);
 	// envoi du résultat sur stdout
@@ -46,33 +46,27 @@
 	return $rep;
 }
 
-function print_list ($list)
-{
+function print_list($list) {
 	$rep = "";
-	foreach ($list as $el)
-	{
+	foreach ($list as $el) {
 		if (strlen($el) > 1) $rep .= "$el ";
 	}
 	return $rep;
 }
 
-function suppression_diacritics($text)
-{
+function suppression_diacritics($text) {
 	$b = $text;
-	$b = iconv ('UTF-8', 'US-ASCII//TRANSLIT', $b) ;
+	$b = iconv('UTF-8', 'US-ASCII//TRANSLIT', $b) ;
 	$b = strtr($b, "\t\r\n?.*'\":;,#![]()", "                 ");
 	return $b;
 }
 
-function microtime_float()
-{
-  list($usec, $sec) = explode(" ", microtime());
-  return ((float)$usec + (float)$sec);
+function microtime_float() {
+	list($usec, $sec) = explode(" ", microtime());
+	return ((float)$usec + (float)$sec);
 }
 
-
-function print_debug ($text)
-{
+function print_debug ($text) {
 	echo "$text <br />\n";
 	ob_flush();
 }

Modified: trunk/src/common/docman/engine/parser_text.php
===================================================================
--- trunk/src/common/docman/engine/parser_text.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/engine/parser_text.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -29,18 +29,16 @@
 
 require_once $gfcommon.'docman/engine/parser_text.inc.php';
 
-if ($argc != 2)
-{
+if ($argc != 2) {
 	echo "Usage : parser_text.php <filename>\n";
 	exit (1);
 }
+
 $fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+	exit (1);
 
-$rep = parser_text($fichin);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface le fichier source
+echo parser_text($fichin);
 unlink ($fichin);
 
 // Local Variables:

Modified: trunk/src/common/docman/views/addfile.php
===================================================================
--- trunk/src/common/docman/views/addfile.php	2010-11-17 12:07:10 UTC (rev 11555)
+++ trunk/src/common/docman/views/addfile.php	2010-11-17 14:16:47 UTC (rev 11556)
@@ -39,22 +39,22 @@
 ?>
 	<script type="text/javascript" >
 	function displayRowFile() {
-	    document.getElementById('filerow').style.display = '';
-        document.getElementById('urlrow').style.display = 'none';
-        document.getElementById('editrow').style.display = 'none';
-        document.getElementById('editnamerow').style.display = 'none';
+		document.getElementById('filerow').style.display = '';
+		document.getElementById('urlrow').style.display = 'none';
+		document.getElementById('editrow').style.display = 'none';
+		document.getElementById('editnamerow').style.display = 'none';
 	}
 	function displayRowUrl() {
-	    document.getElementById('filerow').style.display = 'none';
-        document.getElementById('urlrow').style.display = '';
-	    document.getElementById('editrow').style.display = 'none';
-	    document.getElementById('editnamerow').style.display = 'none';
+		document.getElementById('filerow').style.display = 'none';
+		document.getElementById('urlrow').style.display = '';
+		document.getElementById('editrow').style.display = 'none';
+		document.getElementById('editnamerow').style.display = 'none';
 	}
 	function displayRowEditor() {
-	    document.getElementById('filerow').style.display = 'none';
-        document.getElementById('urlrow').style.display = 'none';
-	    document.getElementById('editrow').style.display = '';
-	    document.getElementById('editnamerow').style.display = '';
+		document.getElementById('filerow').style.display = 'none';
+	document.getElementById('urlrow').style.display = 'none';
+		document.getElementById('editrow').style.display = '';
+		document.getElementById('editnamerow').style.display = '';
 	}
 	</script>
 <?php
@@ -70,9 +70,9 @@
 				<tr>
 					<td style="text-align:right;">
 						<strong>'. _('Document Title').'</strong>'.utils_requiredField()
-                	.'</td><td>'
-                    	.'&nbsp;<input type="text" name="title" size="40" maxlength="255" />&nbsp;'
-                    	.sprintf(_('(at least %1$s characters)'), 5)
+					.'</td><td>'
+			.'&nbsp;<input type="text" name="title" size="40" maxlength="255" />&nbsp;'
+			.sprintf(_('(at least %1$s characters)'), 5)
 					.'</td>
 				</tr>
 				<tr>




More information about the Fusionforge-commits mailing list