mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 05:11:27 +00:00 
			
		
		
		
	Merge branch 'seeddms-4.3.x' into seeddms-5.0.x
This commit is contained in:
		
						commit
						1e17c393bb
					
				|  | @ -217,6 +217,17 @@ class SeedDMS_Core_DMS { | |||
| 		return false; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Checks if date conforms to a given format | ||||
| 	 * | ||||
| 	 * @param string $date date to be checked | ||||
| 	 * @return boolean true if date is in propper format, otherwise false | ||||
| 	 */ | ||||
| 	static function checkDate($date, $format='Y-m-d H:i:s') { /* {{{ */ | ||||
| 		$d = DateTime::createFromFormat($format, $date); | ||||
| 		return $d && $d->format($format) == $date; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Filter objects out which are not accessible in a given mode by a user. | ||||
| 	 * | ||||
|  |  | |||
|  | @ -333,6 +333,30 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ | |||
| 		return $this->_date; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Set creation date of the document | ||||
| 	 * | ||||
| 	 * @param integer $date timestamp of creation date. If false then set it | ||||
| 	 * to the current timestamp | ||||
| 	 * @return boolean true on success | ||||
| 	 */ | ||||
| 	function setDate($date) { /* {{{ */ | ||||
| 		$db = $this->_dms->getDB(); | ||||
| 
 | ||||
| 		if(!$date) | ||||
| 			$date = time(); | ||||
| 		else { | ||||
| 			if(!is_numeric($date)) | ||||
| 				return false; | ||||
| 		} | ||||
| 
 | ||||
| 		$queryStr = "UPDATE tblDocuments SET date = " . (int) $date . " WHERE id = ". $this->_id; | ||||
| 		if (!$db->getResult($queryStr)) | ||||
| 			return false; | ||||
| 		$this->_date = $date; | ||||
| 		return true; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the parent folder of the document | ||||
| 	 * | ||||
|  | @ -2431,7 +2455,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ | |||
| 	 * @param object $updateUser user initiating the status change | ||||
| 	 * @return boolean true on success, otherwise false | ||||
| 	 */ | ||||
| 	function setStatus($status, $comment, $updateUser) { /* {{{ */ | ||||
| 	function setStatus($status, $comment, $updateUser, $date='') { /* {{{ */ | ||||
| 		$db = $this->_document->_dms->getDB(); | ||||
| 
 | ||||
| 		if (!is_numeric($status)) return false; | ||||
|  | @ -2454,8 +2478,12 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ | |||
| 		if ($this->_status["status"]==$status) { | ||||
| 			return false; | ||||
| 		} | ||||
| 		if($date) | ||||
| 			$ddate = $db->qstr($date); | ||||
| 		else | ||||
| 			$ddate = 'CURRENT_TIMESTAMP'; | ||||
| 		$queryStr = "INSERT INTO `tblDocumentStatusLog` (`statusID`, `status`, `comment`, `date`, `userID`) ". | ||||
| 			"VALUES ('". $this->_status["statusID"] ."', '". (int) $status ."', ".$db->qstr($comment).", CURRENT_TIMESTAMP, '". $updateUser->getID() ."')"; | ||||
| 			"VALUES ('". $this->_status["statusID"] ."', '". (int) $status ."', ".$db->qstr($comment).", ".$ddate.", '". $updateUser->getID() ."')"; | ||||
| 		$res = $db->getResult($queryStr); | ||||
| 		if (is_bool($res) && !$res) | ||||
| 			return false; | ||||
|  | @ -2464,6 +2492,55 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ | |||
| 		return true; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Rewrites the complete status log | ||||
| 	 *  | ||||
| 	 * Attention: this function is highly dangerous. | ||||
| 	 * It removes an existing status log and rewrites it. | ||||
| 	 * This method was added for importing an xml dump. | ||||
| 	 * | ||||
| 	 * @param array $statuslog new status log with the newest log entry first. | ||||
| 	 * @return boolean true on success, otherwise false | ||||
| 	 */ | ||||
| 	function rewriteStatusLog($statuslog) { /* {{{ */ | ||||
| 		$db = $this->_document->_dms->getDB(); | ||||
| 
 | ||||
| 		$queryStr= "SELECT `tblDocumentStatus`.* FROM `tblDocumentStatus` WHERE `tblDocumentStatus`.`documentID` = '". $this->_document->getID() ."' AND `tblDocumentStatus`.`version` = '". $this->_version ."' "; | ||||
| 		$res = $db->getResultArray($queryStr); | ||||
| 		if (is_bool($res) && !$res) | ||||
| 			return false; | ||||
| 
 | ||||
| 		$statusID = $res[0]['statusID']; | ||||
| 
 | ||||
| 		$db->startTransaction(); | ||||
| 
 | ||||
| 		/* First, remove the old entries */ | ||||
| 		$queryStr = "DELETE from `tblDocumentStatusLog` where `statusID`=".$statusID; | ||||
| 		if (!$db->getResult($queryStr)) { | ||||
| 			$db->rollbackTransaction(); | ||||
| 			return false; | ||||
| 		} | ||||
| 
 | ||||
| 		/* Second, insert the new entries */ | ||||
| 		$statuslog = array_reverse($statuslog); | ||||
| 		foreach($statuslog as $log) { | ||||
| 			if(!SeedDMS_Core_DMS::checkDate($log['date'], 'Y-m-d H:i:s')) { | ||||
| 				$db->rollbackTransaction(); | ||||
| 				return false; | ||||
| 			} | ||||
| 			$queryStr = "INSERT INTO `tblDocumentStatusLog` (`statusID`, `status`, `comment`, `date`, `userID`) ". | ||||
| 				"VALUES ('".$statusID ."', '".(int) $log['status']."', ".$db->qstr($log['comment']) .", ".$db->qstr($log['date']).", ".$log['user']->getID().")"; | ||||
| 			if (!$db->getResult($queryStr)) { | ||||
| 				$db->rollbackTransaction(); | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		$db->commitTransaction(); | ||||
| 		return true; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Returns the access mode similar to a document | ||||
| 	 * There is no real access mode for document content, so this is more | ||||
|  | @ -2555,6 +2632,73 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ | |||
| 		return $this->_reviewStatus; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Rewrites the complete review log | ||||
| 	 *  | ||||
| 	 * Attention: this function is highly dangerous. | ||||
| 	 * It removes an existing review log and rewrites it. | ||||
| 	 * This method was added for importing an xml dump. | ||||
| 	 * | ||||
| 	 * @param array $reviewlog new status log with the newest log entry first. | ||||
| 	 * @return boolean true on success, otherwise false | ||||
| 	 */ | ||||
| 	function rewriteReviewLog($reviewers) { /* {{{ */ | ||||
| 		$db = $this->_document->_dms->getDB(); | ||||
| 
 | ||||
| 		$queryStr= "SELECT `tblDocumentReviewers`.* FROM `tblDocumentReviewers` WHERE `tblDocumentReviewers`.`documentID` = '". $this->_document->getID() ."' AND `tblDocumentReviewers`.`version` = '". $this->_version ."' "; | ||||
| 		$res = $db->getResultArray($queryStr); | ||||
| 		if (is_bool($res) && !$res) | ||||
| 			return false; | ||||
| 
 | ||||
| 		$db->startTransaction(); | ||||
| 
 | ||||
| 		if($res) { | ||||
| 			foreach($res as $review) { | ||||
| 				$reviewID = $review['reviewID']; | ||||
| 
 | ||||
| 				/* First, remove the old entries */ | ||||
| 				$queryStr = "DELETE from `tblDocumentReviewLog` where `reviewID`=".$reviewID; | ||||
| 				if (!$db->getResult($queryStr)) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 
 | ||||
| 				$queryStr = "DELETE from `tblDocumentReviewers` where `reviewID`=".$reviewID; | ||||
| 				if (!$db->getResult($queryStr)) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		/* Second, insert the new entries */ | ||||
| 		foreach($reviewers as $review) { | ||||
| 			$queryStr = "INSERT INTO `tblDocumentReviewers` (`documentID`, `version`, `type`, `required`) ". | ||||
| 				"VALUES ('".$this->_document->getID()."', '".$this->_version."', ".$review['type'] .", ".$review['required']->getID().")"; | ||||
| 			if (!$db->getResult($queryStr)) { | ||||
| 				$db->rollbackTransaction(); | ||||
| 				return false; | ||||
| 			} | ||||
| 			$reviewID = $db->getInsertID(); | ||||
| 			$reviewlog = array_reverse($review['logs']); | ||||
| 			foreach($reviewlog as $log) { | ||||
| 				if(!SeedDMS_Core_DMS::checkDate($log['date'], 'Y-m-d H:i:s')) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 				$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ". | ||||
| 					"VALUES ('".$reviewID ."', '".(int) $log['status']."', ".$db->qstr($log['comment']) .", ".$db->qstr($log['date']).", ".$log['user']->getID().")"; | ||||
| 				if (!$db->getResult($queryStr)) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		$db->commitTransaction(); | ||||
| 		return true; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get the current approval status of the document content | ||||
| 	 * The approval status is a list of approvals and its current status | ||||
|  | @ -2612,6 +2756,73 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ | |||
| 		return $this->_approvalStatus; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Rewrites the complete approval log | ||||
| 	 *  | ||||
| 	 * Attention: this function is highly dangerous. | ||||
| 	 * It removes an existing review log and rewrites it. | ||||
| 	 * This method was added for importing an xml dump. | ||||
| 	 * | ||||
| 	 * @param array $reviewlog new status log with the newest log entry first. | ||||
| 	 * @return boolean true on success, otherwise false | ||||
| 	 */ | ||||
| 	function rewriteApprovalLog($reviewers) { /* {{{ */ | ||||
| 		$db = $this->_document->_dms->getDB(); | ||||
| 
 | ||||
| 		$queryStr= "SELECT `tblDocumentApprovers`.* FROM `tblDocumentApprovers` WHERE `tblDocumentApprovers`.`documentID` = '". $this->_document->getID() ."' AND `tblDocumentApprovers`.`version` = '". $this->_version ."' "; | ||||
| 		$res = $db->getResultArray($queryStr); | ||||
| 		if (is_bool($res) && !$res) | ||||
| 			return false; | ||||
| 
 | ||||
| 		$db->startTransaction(); | ||||
| 
 | ||||
| 		if($res) { | ||||
| 			foreach($res as $review) { | ||||
| 				$reviewID = $review['reviewID']; | ||||
| 
 | ||||
| 				/* First, remove the old entries */ | ||||
| 				$queryStr = "DELETE from `tblDocumentApproveLog` where `approveID`=".$reviewID; | ||||
| 				if (!$db->getResult($queryStr)) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 
 | ||||
| 				$queryStr = "DELETE from `tblDocumentApprovers` where `approveID`=".$reviewID; | ||||
| 				if (!$db->getResult($queryStr)) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		/* Second, insert the new entries */ | ||||
| 		foreach($reviewers as $review) { | ||||
| 			$queryStr = "INSERT INTO `tblDocumentApprovers` (`documentID`, `version`, `type`, `required`) ". | ||||
| 				"VALUES ('".$this->_document->getID()."', '".$this->_version."', ".$review['type'] .", ".$review['required']->getID().")"; | ||||
| 			if (!$db->getResult($queryStr)) { | ||||
| 				$db->rollbackTransaction(); | ||||
| 				return false; | ||||
| 			} | ||||
| 			$reviewID = $db->getInsertID(); | ||||
| 			$reviewlog = array_reverse($review['logs']); | ||||
| 			foreach($reviewlog as $log) { | ||||
| 				if(!SeedDMS_Core_DMS::checkDate($log['date'], 'Y-m-d H:i:s')) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 				$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ". | ||||
| 					"VALUES ('".$reviewID ."', '".(int) $log['status']."', ".$db->qstr($log['comment']) .", ".$db->qstr($log['date']).", ".$log['user']->getID().")"; | ||||
| 				if (!$db->getResult($queryStr)) { | ||||
| 					$db->rollbackTransaction(); | ||||
| 					return false; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		$db->commitTransaction(); | ||||
| 		return true; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function addIndReviewer($user, $requestUser, $listadmin=false) { /* {{{ */ | ||||
| 		$db = $this->_document->_dms->getDB(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -183,6 +183,30 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { | |||
| 		return $this->_date; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Set creation date of the document | ||||
| 	 * | ||||
| 	 * @param integer $date timestamp of creation date. If false then set it | ||||
| 	 * to the current timestamp | ||||
| 	 * @return boolean true on success | ||||
| 	 */ | ||||
| 	function setDate($date) { /* {{{ */ | ||||
| 		$db = $this->_dms->getDB(); | ||||
| 
 | ||||
| 		if(!$date) | ||||
| 			$date = time(); | ||||
| 		else { | ||||
| 			if(!is_numeric($date)) | ||||
| 				return false; | ||||
| 		} | ||||
| 
 | ||||
| 		$queryStr = "UPDATE tblFolders SET date = " . (int) $date . " WHERE id = ". $this->_id; | ||||
| 		if (!$db->getResult($queryStr)) | ||||
| 			return false; | ||||
| 		$this->_date = $date; | ||||
| 		return true; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Returns the parent | ||||
| 	 * | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ | |||
| //    along with this program; if not, write to the Free Software
 | ||||
| //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | ||||
| //
 | ||||
| //    Translators: Admin (1226), dgrutsch (3), netixw (14)
 | ||||
| //    Translators: Admin (1230), dgrutsch (3), netixw (14)
 | ||||
| 
 | ||||
| $text = array( | ||||
| 'accept' => 'Accept', | ||||
|  | @ -781,10 +781,10 @@ URL: [url]', | |||
| 'reviewer_already_removed' => 'Reviewer has already been removed from review process or has already submitted a review', | ||||
| 'review_deletion_email' => 'Review request deleted', | ||||
| 'review_deletion_email_body' => 'Review request deleted | ||||
| Dokument: [name] | ||||
| Document: [name] | ||||
| Version: [version] | ||||
| Elternordner: [folder_path] | ||||
| Benutzer: [username] | ||||
| Parentfolder: [folder_path] | ||||
| User: [username] | ||||
| URL: [url]', | ||||
| 'review_deletion_email_subject' => '[sitename]: [name] - Review request deleted', | ||||
| 'review_file' => 'File', | ||||
|  | @ -913,7 +913,7 @@ URL: [url]', | |||
| 'settings_autoLoginUser' => 'Automatic login', | ||||
| 'settings_autoLoginUser_desc' => 'Use this user id for accesses if the user is not already logged in. Such an access will not create a session.', | ||||
| 'settings_backupDir' => 'Backup directory', | ||||
| 'settings_backupDir_desc' => 'Directory where the backup tool saves backups. If this directory ist not set or cannot be accessed, then the backups will be saved in the content directory.', | ||||
| 'settings_backupDir_desc' => 'Directory where the backup tool saves backups. If this directory is not set or cannot be accessed, then the backups will be saved in the content directory.', | ||||
| 'settings_cacheDir' => 'Cache directory', | ||||
| 'settings_cacheDir_desc' => 'Where the preview images are stored (best to choose a directory that is not accessible through your web-server)', | ||||
| 'settings_Calendar' => 'Calendar settings', | ||||
|  | @ -986,7 +986,7 @@ URL: [url]', | |||
| 'settings_enableNotificationAppRev' => 'Enable reviewer/approver notification', | ||||
| 'settings_enableNotificationAppRev_desc' => 'Check to send a notification to the reviewer/approver when a new document version is added', | ||||
| 'settings_enableNotificationWorkflow' => 'Send notification to users in next workflow transition', | ||||
| 'settings_enableNotificationWorkflow_desc' => 'If this option is enabled, the users and groups which need to take action in the next workflow transiton will be notified. Even if they have not added a notification for the document.', | ||||
| 'settings_enableNotificationWorkflow_desc' => 'If this option is enabled, the users and groups which need to take action in the next workflow transition will be notified. Even if they have not added a notification for the document.', | ||||
| 'settings_enableOwnerNotification' => 'Enable owner notification by default', | ||||
| 'settings_enableOwnerNotification_desc' => 'Check for adding a notification for the owner if a document when it is added.', | ||||
| 'settings_enableOwnerRevApp' => 'Allow review/approval for owner', | ||||
|  | @ -1263,7 +1263,7 @@ URL: [url]', | |||
| 'transition_triggered_email_subject' => '[sitename]: [name] - Workflow transition triggered', | ||||
| 'transmittal' => 'Transmittal', | ||||
| 'transmittalitem_removed' => 'Transmittal item removed', | ||||
| 'transmittalitem_updated' => 'Dokument updated to latest version', | ||||
| 'transmittalitem_updated' => 'Document updated to latest version', | ||||
| 'transmittal_comment' => 'Comment', | ||||
| 'transmittal_name' => 'Name', | ||||
| 'transmittal_size' => 'Size', | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -100,7 +100,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 			echo " parent=\"".$parent->getID()."\""; | ||||
| 		echo ">\n"; | ||||
| 		echo $indent." <attr name=\"name\">".wrapWithCData($folder->getName())."</attr>\n"; | ||||
| 		echo $indent." <attr name=\"date\">".date('c', $folder->getDate())."</attr>\n"; | ||||
| 		echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $folder->getDate())."</attr>\n"; | ||||
| 		echo $indent." <attr name=\"defaultaccess\">".$folder->getDefaultAccess()."</attr>\n"; | ||||
| 		echo $indent." <attr name=\"inheritaccess\">".$folder->inheritsAccess()."</attr>\n"; | ||||
| 		echo $indent." <attr name=\"sequence\">".$folder->getSequence()."</attr>\n"; | ||||
|  | @ -153,9 +153,9 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 				echo " locked=\"true\""; | ||||
| 			echo ">\n"; | ||||
| 			echo $indent." <attr name=\"name\">".wrapWithCData($document->getName())."</attr>\n"; | ||||
| 			echo $indent." <attr name=\"date\">".date('c', $document->getDate())."</attr>\n"; | ||||
| 			echo $indent." <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $document->getDate())."</attr>\n"; | ||||
| 			if($document->getExpires()) | ||||
| 				echo $indent." <attr name=\"expires\">".date('c', $document->getExpires())."</attr>\n"; | ||||
| 				echo $indent." <attr name=\"expires\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $document->getExpires())."</attr>\n"; | ||||
| 			echo $indent." <attr name=\"owner\">".$owner->getId()."</attr>\n"; | ||||
| 			if($document->getKeywords()) | ||||
| 				echo $indent." <attr name=\"keywords\">".wrapWithCData($document->getKeywords())."</attr>\n"; | ||||
|  | @ -213,7 +213,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 					$owner = $version->getUser(); | ||||
| 					echo $indent."  <version version=\"".$version->getVersion()."\">\n"; | ||||
| 					echo $indent."   <attr name=\"mimetype\">".$version->getMimeType()."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"date\">".date('c', $version->getDate())."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $version->getDate())."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"filetype\">".$version->getFileType()."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"comment\">".wrapWithCData($version->getComment())."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"owner\">".$owner->getId()."</attr>\n"; | ||||
|  | @ -224,6 +224,18 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 							echo $indent."   <attr type=\"user\" attrdef=\"".$attrdef->getID()."\">".$attribute->getValue()."</attr>\n"; | ||||
| 						} | ||||
| 					} | ||||
| 					if($statuslog = $version->getStatusLog()) { | ||||
| 						echo $indent."   <status id=\"".$statuslog[0]['statusID']."\">\n"; | ||||
| 						foreach($statuslog as $entry) { | ||||
| 							echo $indent."    <statuslog>\n"; | ||||
| 							echo $indent."     <attr name=\"status\">".$entry['status']."</attr>\n"; | ||||
| 							echo $indent."     <attr name=\"comment\">".wrapWithCData($entry['comment'])."</attr>\n"; | ||||
| 							echo $indent."     <attr name=\"date\" format=\"Y-m-d H:i:s\">".$entry['date']."</attr>\n"; | ||||
| 							echo $indent."     <attr name=\"user\">".$entry['userID']."</attr>\n"; | ||||
| 							echo $indent."    </statuslog>\n"; | ||||
| 						} | ||||
| 						echo $indent."   </status>\n"; | ||||
| 					} | ||||
| 					if($approvalStatus) { | ||||
| 						echo $indent."   <approvals>\n"; | ||||
| 						$curapprovalid = 0; | ||||
|  | @ -240,7 +252,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 							echo $indent."      <attr name=\"user\">".$a['userID']."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"status\">".$a['status']."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"comment\">".wrapWithCData($a['comment'])."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"date\">".$a['date']."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"date\" format=\"Y-m-d H:i:s\">".$a['date']."</attr>\n"; | ||||
| 							echo $indent."     </approvallog>\n"; | ||||
| //							echo $indent."    </approval>\n";
 | ||||
| 							$curapprovalid = $a['approveID']; | ||||
|  | @ -265,7 +277,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 							echo $indent."      <attr name=\"user\">".$a['userID']."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"status\">".$a['status']."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"comment\">".wrapWithCData($a['comment'])."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"date\">".$a['date']."</attr>\n"; | ||||
| 							echo $indent."      <attr name=\"date\" format=\"Y-m-d H:i:s\">".$a['date']."</attr>\n"; | ||||
| 							echo $indent."     </reviewlog>\n"; | ||||
| //							echo $indent."    </review>\n";
 | ||||
| 							$curreviewid = $a['reviewID']; | ||||
|  | @ -304,7 +316,7 @@ function tree($folder, $parent=null, $indent='', $skipcurrent=false) { /* {{{ */ | |||
| 					echo $indent."  <file id=\"".$file->getId()."\">\n"; | ||||
| 					echo $indent."   <attr name=\"name\">".wrapWithCData($file->getName())."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"mimetype\">".$file->getMimeType()."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"date\">".date('c', $file->getDate())."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"date\" format=\"Y-m-d H:i:s\">".date('Y-m-d H:i:s', $file->getDate())."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"filetype\">".wrapWithCData($file->getFileType())."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"owner\">".$owner->getId()."</attr>\n"; | ||||
| 					echo $indent."   <attr name=\"comment\">".wrapWithCData($file->getComment())."</attr>\n"; | ||||
|  |  | |||
|  | @ -24,8 +24,40 @@ function usage() { /* {{{ */ | |||
| 	echo "  --debug: turn debug output on\n"; | ||||
| } /* }}} */ | ||||
| 
 | ||||
| function dateToTimestamp($date) { /* {{{ */ | ||||
| 	return time(); | ||||
| function dateToTimestamp($date, $format='Y-m-d H:i:s') { /* {{{ */ | ||||
| 	$p = date_parse_from_format($format, $date); | ||||
| 	return mktime($p['hour'], $p['minute'], $p['second'], $p['month'], $p['day'], $p['year']); | ||||
| } /* }}} */ | ||||
| 
 | ||||
| function getRevAppLog($reviews) { /* {{{ */ | ||||
| 	global $dms, $objmap; | ||||
| 
 | ||||
| 	$newreviews = array(); | ||||
| 	foreach($reviews as $i=>$review) { | ||||
| 		$newreview = array('type'=>$review['attributes']['type']); | ||||
| 		if($review['attributes']['type'] == 1) { | ||||
| 			if(isset($objmap['groups'][(int) $review['attributes']['required']])) | ||||
| 				$newreview['required'] = $dms->getGroup($objmap['groups'][(int) $review['attributes']['required']]); | ||||
| 		} else { | ||||
| 			if(isset($objmap['users'][(int) $review['attributes']['required']])) | ||||
| 				$newreview['required'] = $dms->getUser($objmap['users'][(int) $review['attributes']['required']]); | ||||
| 		} | ||||
| 		$newreview['logs'] = array(); | ||||
| 		foreach($review['logs'] as $j=>$log) { | ||||
| 			if(!array_key_exists($log['attributes']['user'], $objmap['users'])) { | ||||
| 				echo "Warning: user for review log cannot be mapped\n"; | ||||
| 			} else { | ||||
| 				$newlog = array(); | ||||
| 				$newlog['user'] = $dms->getUser($objmap['users'][$log['attributes']['user']]); | ||||
| 				$newlog['status'] = $log['attributes']['status']; | ||||
| 				$newlog['comment'] = $log['attributes']['comment']; | ||||
| 				$newlog['date'] = $log['attributes']['date']; | ||||
| 				$newreview['logs'][] = $newlog; | ||||
| 			} | ||||
| 		} | ||||
| 		$newreviews[] = $newreview; | ||||
| 	} | ||||
| 	return $newreviews; | ||||
| } /* }}} */ | ||||
| 
 | ||||
| function insert_user($user) { /* {{{ */ | ||||
|  | @ -187,8 +219,8 @@ function insert_keywordcategory($keywordcat) { /* {{{ */ | |||
| function insert_document($document) { /* {{{ */ | ||||
| 	global $dms, $debug, $defaultUser, $objmap, $sections, $rootfolder; | ||||
| 
 | ||||
| 	if($debug) | ||||
| 		print_r($document); | ||||
| 	if($debug) print_r($document); | ||||
| 
 | ||||
| 	if(!array_key_exists((int) $document['attributes']['owner'], $objmap['users'])) { | ||||
| 		echo "Warning: owner of document cannot be mapped using default user\n"; | ||||
| 		$owner = $defaultUser; | ||||
|  | @ -245,6 +277,7 @@ function insert_document($document) { /* {{{ */ | |||
| 		} | ||||
| 		if(!$error) { | ||||
| 			$reviews = array('i'=>array(), 'g'=>array()); | ||||
| 			/* | ||||
| 			if($initversion['reviews']) { | ||||
| 				foreach($initversion['reviews'] as $review) { | ||||
| 					if($review['attributes']['type'] == 1) { | ||||
|  | @ -256,7 +289,9 @@ function insert_document($document) { /* {{{ */ | |||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 */ | ||||
| 			$approvals = array('i'=>array(), 'g'=>array()); | ||||
| 			/* | ||||
| 			if($initversion['approvals']) { | ||||
| 				foreach($initversion['approvals'] as $approval) { | ||||
| 					if($approval['attributes']['type'] == 1) { | ||||
|  | @ -268,6 +303,7 @@ function insert_document($document) { /* {{{ */ | |||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 */ | ||||
| 			$version_attributes = array(); | ||||
| 			if(isset($initversion['user_attributes'])) { | ||||
| 				foreach($initversion['user_attributes'] as $orgid=>$value) { | ||||
|  | @ -305,6 +341,32 @@ function insert_document($document) { /* {{{ */ | |||
| 			} else { | ||||
| 				$newDocument = $result[0]; | ||||
| 				unlink($filename); | ||||
| 
 | ||||
| 				$newVersion = $result[1]->getContent(); | ||||
| 				$newVersion->setDate(dateToTimestamp($initversion['attributes']['date'])); | ||||
| 				$newlogs = array(); | ||||
| 				foreach($initversion['statuslogs'] as $i=>$log) { | ||||
| 					if(!array_key_exists($log['attributes']['user'], $objmap['users'])) { | ||||
| 						unset($initversion['statuslogs'][$i]); | ||||
| 						echo "Warning: user for status log cannot be mapped\n"; | ||||
| 					} else { | ||||
| 						$log['attributes']['user'] = $dms->getUser($objmap['users'][$log['attributes']['user']]); | ||||
| 						$newlogs[] = $log['attributes']; | ||||
| 					} | ||||
| 				} | ||||
| 				$newVersion->rewriteStatusLog($newlogs); | ||||
| 
 | ||||
| 				/* Set reviewers and review log */ | ||||
| 				if($initversion['reviews']) { | ||||
| 					$newreviews = getRevAppLog($initversion['reviews']); | ||||
| 					$newVersion->rewriteReviewLog($newreviews); | ||||
| 				} | ||||
| 				if($initversion['approvals']) { | ||||
| 					$newapprovals = getRevAppLog($initversion['approvals']); | ||||
| 					$newVersion->rewriteApprovalLog($newapprovals); | ||||
| 				} | ||||
| 
 | ||||
| 				$newDocument->setDate(dateToTimestamp($document['attributes']['date'])); | ||||
| 				$newDocument->setDefaultAccess($document['attributes']['defaultaccess']); | ||||
| 				foreach($document['versions'] as $version) { | ||||
| 					if(!array_key_exists((int) $version['attributes']['owner'], $objmap['users'])) { | ||||
|  | @ -314,6 +376,7 @@ function insert_document($document) { /* {{{ */ | |||
| 					$owner = $dms->getUser($objmap['users'][(int) $version['attributes']['owner']]); | ||||
| 
 | ||||
| 					$reviews = array('i'=>array(), 'g'=>array()); | ||||
| 					/* | ||||
| 					if($version['reviews']) { | ||||
| 						foreach($version['reviews'] as $review) { | ||||
| 							if($review['attributes']['type'] == 1) { | ||||
|  | @ -325,7 +388,9 @@ function insert_document($document) { /* {{{ */ | |||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 					 */ | ||||
| 					$approvals = array('i'=>array(), 'g'=>array()); | ||||
| 					/* | ||||
| 					if($version['approvals']) { | ||||
| 						foreach($version['approvals'] as $approval) { | ||||
| 							if($approval['attributes']['type'] == 1) { | ||||
|  | @ -337,6 +402,7 @@ function insert_document($document) { /* {{{ */ | |||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 					 */ | ||||
| 					$version_attributes = array(); | ||||
| 					if(isset($version['user_attributes'])) { | ||||
| 						foreach($version['user_attributes'] as $orgid=>$value) { | ||||
|  | @ -358,7 +424,7 @@ function insert_document($document) { /* {{{ */ | |||
| 						$filename = tempnam('/tmp', 'FOO'); | ||||
| 						file_put_contents($filename, $filecontents); | ||||
| 					} | ||||
| 					if(!$newDocument->addContent( | ||||
| 					if(!($result = $newDocument->addContent( | ||||
| 						$version['attributes']['comment'], | ||||
| 						$owner, | ||||
| 						$filename, | ||||
|  | @ -370,8 +436,31 @@ function insert_document($document) { /* {{{ */ | |||
| 						$version['version'],	 | ||||
| 						$version_attributes, | ||||
| 						null //workflow
 | ||||
| 					)) { | ||||
| 					))) { | ||||
| 					} | ||||
| 					$newVersion = $result->getContent(); | ||||
| 					$newVersion->setDate(dateToTimestamp($version['attributes']['date'])); | ||||
| 					$newlogs = array(); | ||||
| 					foreach($version['statuslogs'] as $i=>$log) { | ||||
| 						if(!array_key_exists($log['attributes']['user'], $objmap['users'])) { | ||||
| 							unset($version['statuslogs'][$i]); | ||||
| 							echo "Warning: user for status log cannot be mapped\n"; | ||||
| 						} else { | ||||
| 							$log['attributes']['user'] = $dms->getUser($objmap['users'][$log['attributes']['user']]); | ||||
| 							$newlogs[] = $log['attributes']; | ||||
| 						} | ||||
| 					} | ||||
| 					$newVersion->rewriteStatusLog($newlogs); | ||||
| 
 | ||||
| 					if($version['reviews']) { | ||||
| 						$newreviews = getRevAppLog($version['reviews']); | ||||
| 						$newVersion->rewriteReviewLog($newreviews); | ||||
| 					} | ||||
| 					if($version['approvals']) { | ||||
| 						$newapprovals = getRevAppLog($version['approvals']); | ||||
| 						$newVersion->rewriteApprovalLog($newapprovals); | ||||
| 					} | ||||
| 
 | ||||
| 					unlink($filename); | ||||
| 				}	 | ||||
| 			} | ||||
|  | @ -491,6 +580,7 @@ function insert_folder($folder) { /* {{{ */ | |||
| 			return false; | ||||
| 		} | ||||
| 
 | ||||
| 		$newFolder->setDate(dateToTimestamp($folder['attributes']['date'])); | ||||
| 		$newFolder->setDefaultAccess($folder['attributes']['defaultaccess']); | ||||
| 		if(isset($folder['notifications']['users']) && $folder['notifications']['users']) { | ||||
| 			foreach($folder['notifications']['users'] as $userid) { | ||||
|  | @ -574,7 +664,7 @@ function resolve_links() { /* {{{ */ | |||
| } /* }}} */ | ||||
| 
 | ||||
| function startElement($parser, $name, $attrs) { /* {{{ */ | ||||
| 	global $elementstack, $objmap, $cur_user, $cur_group, $cur_folder, $cur_document, $cur_version, $cur_approval, $cur_approvallog, $cur_review, $cur_reviewlog, $cur_attrdef, $cur_documentcat, $cur_keyword, $cur_keywordcat, $cur_file, $cur_link; | ||||
| 	global $elementstack, $objmap, $cur_user, $cur_group, $cur_folder, $cur_document, $cur_version, $cur_statuslog, $cur_approval, $cur_approvallog, $cur_review, $cur_reviewlog, $cur_attrdef, $cur_documentcat, $cur_keyword, $cur_keywordcat, $cur_file, $cur_link; | ||||
| 
 | ||||
| 	$parent = end($elementstack); | ||||
| 	array_push($elementstack, array('name'=>$name, 'attributes'=>$attrs)); | ||||
|  | @ -648,6 +738,10 @@ function startElement($parser, $name, $attrs) { /* {{{ */ | |||
| 			$cur_version['approvals'] = array(); | ||||
| 			$cur_version['reviews'] = array(); | ||||
| 			break; | ||||
| 		case "STATUSLOG": | ||||
| 			$cur_statuslog = array(); | ||||
| 			$cur_statuslog['attributes'] = array(); | ||||
| 			break; | ||||
| 		case "APPROVAL": | ||||
| 			$cur_approval = array(); | ||||
| 			$cur_approval['attributes'] = array(); | ||||
|  | @ -685,6 +779,8 @@ function startElement($parser, $name, $attrs) { /* {{{ */ | |||
| 				} else { | ||||
| 					$cur_version['attributes'][$attrs['NAME']] = ''; | ||||
| 				} | ||||
| 			} elseif($parent['name'] == 'STATUSLOG') { | ||||
| 				$cur_statuslog['attributes'][$attrs['NAME']] = ''; | ||||
| 			} elseif($parent['name'] == 'APPROVAL') { | ||||
| 				$cur_approval['attributes'][$attrs['NAME']] = ''; | ||||
| 			} elseif($parent['name'] == 'APPROVALLOG') { | ||||
|  | @ -823,7 +919,7 @@ function startElement($parser, $name, $attrs) { /* {{{ */ | |||
| } /* }}} */ | ||||
| 
 | ||||
| function endElement($parser, $name) { /* {{{ */ | ||||
| 	global $dms, $sections, $rootfolder, $objmap, $elementstack, $users, $groups, $links,$cur_user, $cur_group, $cur_folder, $cur_document, $cur_version, $cur_approval, $cur_approvallog, $cur_review, $cur_reviewlog, $cur_attrdef, $cur_documentcat, $cur_keyword, $cur_keywordcat, $cur_file, $cur_link; | ||||
| 	global $dms, $sections, $rootfolder, $objmap, $elementstack, $users, $groups, $links,$cur_user, $cur_group, $cur_folder, $cur_document, $cur_version, $cur_statuslog, $cur_approval, $cur_approvallog, $cur_review, $cur_reviewlog, $cur_attrdef, $cur_documentcat, $cur_keyword, $cur_keywordcat, $cur_file, $cur_link; | ||||
| 
 | ||||
| 	array_pop($elementstack); | ||||
| 	$parent = end($elementstack); | ||||
|  | @ -839,6 +935,9 @@ function endElement($parser, $name) { /* {{{ */ | |||
| 		case "VERSION": | ||||
| 			$cur_document['versions'][] = $cur_version; | ||||
| 			break; | ||||
| 		case "STATUSLOG": | ||||
| 			$cur_version['statuslogs'][] = $cur_statuslog; | ||||
| 			break; | ||||
| 		case "APPROVAL": | ||||
| 			$cur_version['approvals'][] = $cur_approval; | ||||
| 			break; | ||||
|  | @ -854,7 +953,7 @@ function endElement($parser, $name) { /* {{{ */ | |||
| 		case "USER": | ||||
| 			/* users can be the users data or the member of a group */ | ||||
| 			$first = $elementstack[1]; | ||||
| 			if($first['name'] == 'USERS') { | ||||
| 			if($first['name'] == 'USERS' && $parent['name'] == 'USERS') { | ||||
| 				$users[$cur_user['id']] = $cur_user; | ||||
| 				insert_user($cur_user); | ||||
| 			} | ||||
|  | @ -894,7 +993,7 @@ function endElement($parser, $name) { /* {{{ */ | |||
| } /* }}} */ | ||||
| 
 | ||||
| function characterData($parser, $data) { /* {{{ */ | ||||
| 	global $elementstack, $objmap, $cur_user, $cur_group, $cur_folder, $cur_document, $cur_version, $cur_approval, $cur_approvallog, $cur_review, $cur_reviewlog, $cur_attrdef, $cur_documentcat, $cur_keyword, $cur_keywordcat, $cur_file, $cur_link; | ||||
| 	global $elementstack, $objmap, $cur_user, $cur_group, $cur_folder, $cur_document, $cur_version, $cur_statuslog, $cur_approval, $cur_approvallog, $cur_review, $cur_reviewlog, $cur_attrdef, $cur_documentcat, $cur_keyword, $cur_keywordcat, $cur_file, $cur_link; | ||||
| 
 | ||||
| 	$current = end($elementstack); | ||||
| 	$parent = prev($elementstack); | ||||
|  | @ -922,6 +1021,9 @@ function characterData($parser, $data) { /* {{{ */ | |||
| 						$cur_version['attributes'][$current['attributes']['NAME']] = $data; | ||||
| 					} | ||||
| 					break; | ||||
| 				case 'STATUSLOG': | ||||
| 					$cur_statuslog['attributes'][$current['attributes']['NAME']] = $data; | ||||
| 					break; | ||||
| 				case 'APPROVAL': | ||||
| 					$cur_approval['attributes'][$current['attributes']['NAME']] = $data; | ||||
| 					break; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann