various minor clean ups

remove old code, add scope of variables, add additional comments
This commit is contained in:
Uwe Steinmann 2016-04-07 08:29:35 +02:00
parent 7fa26ace57
commit 2c14ec295a
3 changed files with 27 additions and 78 deletions

View File

@ -30,7 +30,7 @@ define("S_DRAFT_APP", 1);
/*
* Document is released. A document is in release state either when
* it needs no review or approval after uploaded or has been reviewed
* and/or approved..
* and/or approved.
*/
define("S_RELEASED", 2);
@ -2427,6 +2427,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* then its status is set to S_RELEASED immediately. Any change of
* the status is monitored in the table tblDocumentStatusLog. This
* function will always return the latest entry for the content.
*
* @return array latest record from tblDocumentStatusLog
*/
function getStatus($limit=1) { /* {{{ */
$db = $this->_document->_dms->getDB();
@ -2436,20 +2438,6 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
// Retrieve the current overall status of the content represented by
// this object.
if (!isset($this->_status)) {
/*
if (!$db->createTemporaryTable("ttstatid", $forceTemporaryTable)) {
return false;
}
$queryStr="SELECT `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ".
"`tblDocumentStatusLog`.`comment`, `tblDocumentStatusLog`.`date`, ".
"`tblDocumentStatusLog`.`userID` ".
"FROM `tblDocumentStatus` ".
"LEFT JOIN `tblDocumentStatusLog` USING (`statusID`) ".
"LEFT JOIN `ttstatid` ON `ttstatid`.`maxLogID` = `tblDocumentStatusLog`.`statusLogID` ".
"WHERE `ttstatid`.`maxLogID`=`tblDocumentStatusLog`.`statusLogID` ".
"AND `tblDocumentStatus`.`documentID` = '". $this->_document->getID() ."' ".
"AND `tblDocumentStatus`.`version` = '". $this->_version ."' ";
*/
$queryStr=
"SELECT `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ".
"`tblDocumentStatusLog`.`comment`, `tblDocumentStatusLog`.`date`, ".
@ -2545,7 +2533,6 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return false;
unset($this->_status);
return true;
} /* }}} */
@ -3344,8 +3331,6 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
function delIndReviewer($user, $requestUser) { /* {{{ */
$db = $this->_document->_dms->getDB();
$userID = $user->getID();
// Check to see if the user can be removed from the review list.
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
@ -3354,7 +3339,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (count($reviewStatus["indstatus"])==0) {
// User is not assigned to review this document. No action required.
// Return an error.
return -3;
return -2;
}
$indstatus = array_pop($reviewStatus["indstatus"]);
if ($indstatus["status"]!=0) {
@ -3386,7 +3371,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (count($reviewStatus)==0) {
// User is not assigned to review this document. No action required.
// Return an error.
return -3;
return -2;
}
if ($reviewStatus[0]["status"]!=0) {
// User has already submitted a review or has already been deleted;
@ -3417,7 +3402,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (count($approvalStatus["indstatus"])==0) {
// User is not assigned to approve this document. No action required.
// Return an error.
return -3;
return -2;
}
$indstatus = array_pop($approvalStatus["indstatus"]);
if ($indstatus["status"]!=0) {
@ -3449,7 +3434,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (count($approvalStatus)==0) {
// User is not assigned to approve this document. No action required.
// Return an error.
return -3;
return -2;
}
if ($approvalStatus[0]["status"]!=0) {
// User has already submitted an approval or has already been deleted;

View File

@ -92,14 +92,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
*
* @return string name of folder
*/
function getName() { return $this->_name; }
public function getName() { return $this->_name; }
/*
* Set the name of the folder.
*
* @param string $newName set a new name of the folder
*/
function setName($newName) { /* {{{ */
public function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE tblFolders SET name = " . $db->qstr($newName) . " WHERE id = ". $this->_id;
@ -111,9 +111,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
return true;
} /* }}} */
function getComment() { return $this->_comment; }
public function getComment() { return $this->_comment; }
function setComment($newComment) { /* {{{ */
public function setComment($newComment) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE tblFolders SET comment = " . $db->qstr($newComment) . " WHERE id = ". $this->_id;
@ -129,7 +129,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
*
* @return integer unix timestamp of creation date
*/
function getDate() { /* {{{ */
public function getDate() { /* {{{ */
return $this->_date;
} /* }}} */
@ -162,7 +162,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
*
* @return object parent folder or false if there is no parent folder
*/
function getParent() { /* {{{ */
public function getParent() { /* {{{ */
if ($this->_id == $this->_dms->rootFolderID || empty($this->_parentID)) {
return false;
}
@ -200,7 +200,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
* @param object $newParent new parent folder
* @return boolean true if operation was successful otherwise false
*/
function setParent($newParent) { /* {{{ */
public function setParent($newParent) { /* {{{ */
$db = $this->_dms->getDB();
if ($this->_id == $this->_dms->rootFolderID || empty($this->_parentID)) {
@ -274,7 +274,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
*
* @return object owner of the folder
*/
function getOwner() { /* {{{ */
public function getOwner() { /* {{{ */
if (!isset($this->_owner))
$this->_owner = $this->_dms->getUser($this->_ownerID);
return $this->_owner;
@ -427,7 +427,6 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$this->_subFolders = array();
for ($i = 0; $i < count($resArr); $i++)
// $this->_subFolders[$i] = new SeedDMS_Core_Folder($resArr[$i]["id"], $resArr[$i]["name"], $resArr[$i]["parent"], $resArr[$i]["comment"], $resArr[$i]["owner"], $resArr[$i]["inheritAccess"], $resArr[$i]["defaultAccess"], $resArr[$i]["sequence"]);
$this->_subFolders[$i] = $this->_dms->getFolder($resArr[$i]["id"]);
}
@ -743,6 +742,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
* must be the id of the attribute definition.
* @param array $version_attributes list of document version attributes.
* The element key must be the id of the attribute definition.
* @param object $workflow
* @return array/boolean false in case of error, otherwise an array
* containing two elements. The first one is the new document, the
* second one is the result set returned when inserting the content.
@ -810,6 +810,13 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
return array($document, $res);
} /* }}} */
/**
* Remove recursively a folder
*
* Removes a folder, all its subfolders and documents
*
* @return boolean true on success, false in case of an error
*/
function remove() { /* {{{ */
$db = $this->_dms->getDB();

View File

@ -22,7 +22,7 @@
* 2010 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_Core_User {
class SeedDMS_Core_User { /* {{{ */
/**
* @var integer id of user
*
@ -67,9 +67,7 @@ class SeedDMS_Core_User {
/**
* @var string prefered language of user
* possible values are 'English', 'German', 'Chinese_ZH_TW', 'Czech'
* 'Francais', 'Hungarian', 'Italian', 'Portuguese_BR', 'Slovak',
* 'Spanish'
* possible values are subdirectories within the language directory
*
* @access protected
*/
@ -771,8 +769,6 @@ class SeedDMS_Core_User {
/**
* Returns all documents locked by a given user
* FIXME: Not full implemented. Do not use, because it still requires the
* temporary tables!
*
* @param object $user
* @return array list of documents
@ -802,7 +798,7 @@ class SeedDMS_Core_User {
* Get a list of reviews
* This function returns a list of all reviews seperated by individual
* and group reviews. If the document id
* is passed, then only this document will be checked for approvals. The
* is passed, then only this document will be checked for reviews. The
* same is true for the version of a document which limits the list
* further.
*
@ -818,11 +814,6 @@ class SeedDMS_Core_User {
function getReviewStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
/*
if (!$db->createTemporaryTable("ttreviewid")) {
return false;
}
*/
$status = array("indstatus"=>array(), "grpstatus"=>array());
// See if the user is assigned as an individual reviewer.
@ -912,27 +903,7 @@ class SeedDMS_Core_User {
function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
/*
if (!$db->createTemporaryTable("ttapproveid")) {
return false;
}
*/
$status = array("indstatus"=>array(), "grpstatus"=>array());
// See if the user is assigned as an individual approver.
/*
$queryStr = "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
"`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". $version ."' ").
"AND `tblDocumentApprovers`.`type`='0' ".
"AND `tblDocumentApprovers`.`required`='". $this->_id ."' ";
*/
$queryStr =
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
@ -962,20 +933,6 @@ class SeedDMS_Core_User {
// See if the user is the member of a group that has been assigned to
// approve the document version.
/*
$queryStr = "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
"`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentApprovers`.`required` ".
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". $version ."' ").
"AND `tblDocumentApprovers`.`type`='1' ".
"AND `tblGroupMembers`.`userID`='". $this->_id ."'";
*/
$queryStr =
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
@ -1315,5 +1272,5 @@ class SeedDMS_Core_User {
return $notifications;
} /* }}} */
}
} /* }}} */
?>