mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 08:55:54 +00:00
more documentation, better parameter checking, return false is sql fails
This commit is contained in:
parent
7366644d19
commit
335c2ffee5
|
@ -3826,12 +3826,25 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add user as new reviewer
|
||||
*
|
||||
* @param object $user user in charge for the review
|
||||
* @param object $requestUser user requesting the operation (usually the
|
||||
* currently logged in user)
|
||||
*
|
||||
* @return integer|false if > 0 the id of the review log, if < 0 the error
|
||||
* code, false in case of an sql error
|
||||
*/
|
||||
function addIndReviewer($user, $requestUser) { /* {{{ */
|
||||
if(!$user || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$user->isType('user'))
|
||||
return -1;
|
||||
|
||||
$userID = $user->getID();
|
||||
|
||||
// Get the list of users and groups with read access to this document.
|
||||
|
@ -3871,18 +3884,33 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
"VALUES ('". $reviewID ."', '0', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add reviewer to event notification table.
|
||||
//$this->_document->addNotify($userID, true);
|
||||
|
||||
return 0;
|
||||
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
|
||||
$db->dropTemporaryTable('ttreviewid');
|
||||
return $reviewLogID;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add group as new reviewer
|
||||
*
|
||||
* @param object $group group in charge for the review
|
||||
* @param object $requestUser user requesting the operation (usually the
|
||||
* currently logged in user)
|
||||
*
|
||||
* @return integer|false if > 0 the id of the review log, if < 0 the error
|
||||
* code, false in case of an sql error
|
||||
*/
|
||||
function addGrpReviewer($group, $requestUser) { /* {{{ */
|
||||
if(!$group || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$group->isType('group'))
|
||||
return -1;
|
||||
|
||||
$groupID = $group->getID();
|
||||
|
||||
// Get the list of users and groups with read access to this document.
|
||||
|
@ -3950,21 +3978,30 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
* be set again and 0 will be returned. Іf the review could be succesfully
|
||||
* added, the review log id will be returned.
|
||||
*
|
||||
* @see SeedDMS_Core_DocumentContent::setApprovalByInd()
|
||||
* @param object $user user doing the review
|
||||
* @param object $requestUser user asking for the review, this is mostly
|
||||
* @see SeedDMS_Core_DocumentContent::setApprovalByInd()
|
||||
*
|
||||
* @param object $user user doing the review
|
||||
* @param object $requestUser user asking for the review, this is mostly
|
||||
* the user currently logged in.
|
||||
* @param integer $status status of review
|
||||
* @param string $comment comment for review
|
||||
* @return integer new review log id
|
||||
* @param string $comment comment for review
|
||||
*
|
||||
* @return integer|bool new review log id, error code 0 till -4,
|
||||
* false in case of an sql error
|
||||
*/
|
||||
function setReviewByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
|
||||
if(!$user || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
// Check to see if the user can be removed from the review list.
|
||||
if(!$user->isType('user'))
|
||||
return -1;
|
||||
|
||||
// Check if the user is on the review list at all.
|
||||
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($reviewStatus) && !$reviewStatus) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (count($reviewStatus["indstatus"])==0) {
|
||||
// User is not assigned to review this document. No action required.
|
||||
|
@ -4001,13 +4038,17 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
*
|
||||
* This method will not delete anything from the database, but will add
|
||||
* a new review log entry which sets the status to 0. This is only allowed
|
||||
* if the current status is either 1 or -1.
|
||||
* if the current status is either 1 (reviewed) or -1 (rejected).
|
||||
*
|
||||
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
|
||||
* should be called to recalculate the document status.
|
||||
*
|
||||
* @param SeedDMS_Core_User $user
|
||||
* @return int 0 if successful
|
||||
* @param integer $reviewid id of review
|
||||
* @param SeedDMS_Core_User $requestUser user requesting the removal
|
||||
* @param string $comment comment
|
||||
*
|
||||
* @return integer|bool true if successful, error code < 0,
|
||||
* false in case of an sql error
|
||||
*/
|
||||
public function removeReview($reviewid, $requestUser, $comment='') { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
@ -4050,27 +4091,35 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
* {@see SeedDMS_Core_DocumentContent::setReviewByInd()} but adds a review
|
||||
* for a group instead of a user.
|
||||
*
|
||||
* @param object $group group doing the review
|
||||
* @param object $requestUser user asking for the review, this is mostly
|
||||
* @param object $group group doing the review
|
||||
* @param object $requestUser user asking for the review, this is mostly
|
||||
* the user currently logged in.
|
||||
* @param integer $status status of review
|
||||
* @param string $comment comment for review
|
||||
* @return integer new review log id
|
||||
* @param string $comment comment for review
|
||||
*
|
||||
* @return integer|bool new review log id, error code 0 till -4,
|
||||
* false in case of an sql error
|
||||
*/
|
||||
function setReviewByGrp($group, $requestUser, $status, $comment, $file='') { /* {{{ */
|
||||
if(!$group || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
// Check to see if the user can be removed from the review list.
|
||||
if(!$group->isType('group'))
|
||||
return -1;
|
||||
|
||||
// Check if the group is on the review list at all.
|
||||
$reviewStatus = $group->getReviewStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($reviewStatus) && !$reviewStatus) {
|
||||
return -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (count($reviewStatus)==0) {
|
||||
// User is not assigned to review this document. No action required.
|
||||
// Return an error.
|
||||
return -3;
|
||||
}
|
||||
if ($reviewStatus[0]["status"]==-2) {
|
||||
if ((int) $reviewStatus[0]["status"]==-2) {
|
||||
// Group has been deleted from reviewers
|
||||
return -4;
|
||||
}
|
||||
|
@ -4086,22 +4135,34 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
$requestUser->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res)
|
||||
return -1;
|
||||
else {
|
||||
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
|
||||
if($file) {
|
||||
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'r' . $reviewLogID);
|
||||
}
|
||||
return $reviewLogID;
|
||||
}
|
||||
return false;
|
||||
|
||||
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
|
||||
if($file) {
|
||||
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'r' . $reviewLogID);
|
||||
}
|
||||
return $reviewLogID;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add user as new approver
|
||||
*
|
||||
* @param object $user user in charge for the approval
|
||||
* @param object $requestUser user requesting the operation (usually the
|
||||
* currently logged in user)
|
||||
*
|
||||
* @return integer|false if > 0 the id of the approval log, if < 0 the error
|
||||
* code, false in case of an sql error
|
||||
*/
|
||||
function addIndApprover($user, $requestUser) { /* {{{ */
|
||||
if(!$user || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$user->isType('user'))
|
||||
return -1;
|
||||
|
||||
$userID = $user->getID();
|
||||
|
||||
// Get the list of users and groups with read access to this document.
|
||||
|
@ -4141,16 +4202,33 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
"VALUES ('". $approveID ."', '0', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
|
||||
$db->dropTemporaryTable('ttapproveid');
|
||||
return $approveLogID;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add group as new approver
|
||||
*
|
||||
* @param object $group group in charge for the approval
|
||||
* @param object $requestUser user requesting the operation (usually the
|
||||
* currently logged in user)
|
||||
*
|
||||
* @return integer|false if > 0 the id of the approval log, if < 0 the error
|
||||
* code, false in case of an sql error
|
||||
*/
|
||||
function addGrpApprover($group, $requestUser) { /* {{{ */
|
||||
if(!$group || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$group->isType('group'))
|
||||
return -1;
|
||||
|
||||
$groupID = $group->getID();
|
||||
|
||||
// Get the list of users and groups with read access to this document.
|
||||
|
@ -4218,25 +4296,34 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
* Then it is check if the approval status is already -2. In both cases
|
||||
* the function returns with an error.
|
||||
*
|
||||
* @see SeedDMS_Core_DocumentContent::setReviewByInd()
|
||||
* @param object $user user in charge for doing the approval
|
||||
* @param object $requestUser user actually calling this function
|
||||
* @see SeedDMS_Core_DocumentContent::setReviewByInd()
|
||||
*
|
||||
* @param object $user user in charge for doing the approval
|
||||
* @param object $requestUser user actually calling this function
|
||||
* @param integer $status the status of the approval, possible values are
|
||||
* 0=unprocessed (maybe used to reset a status)
|
||||
* 1=approved,
|
||||
* -1=rejected,
|
||||
* -2=user is deleted (use {link
|
||||
* SeedDMS_Core_DocumentContent::delIndApprover} instead)
|
||||
* @param string $comment approval comment
|
||||
* @return integer 0 on success, < 0 in case of an error
|
||||
* @param string $comment approval comment
|
||||
*
|
||||
* @return integer|bool new review log id, error code 0 till -4,
|
||||
* false in case of an sql error
|
||||
*/
|
||||
function setApprovalByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
|
||||
if(!$user || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
// Check to see if the user can be removed from the approval list.
|
||||
if(!$user->isType('user'))
|
||||
return -1;
|
||||
|
||||
// Check if the user is on the approval list at all.
|
||||
$approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($approvalStatus) && !$approvalStatus) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (count($approvalStatus["indstatus"])==0) {
|
||||
// User is not assigned to approve this document. No action required.
|
||||
|
@ -4272,14 +4359,18 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
* Add another entry to approval log which resets the status
|
||||
*
|
||||
* This method will not delete anything from the database, but will add
|
||||
* a new review log entry which sets the status to 0. This is only allowed
|
||||
* if the current status is either 1 or -1.
|
||||
* a new approval log entry which sets the status to 0. This is only allowed
|
||||
* if the current status is either 1 (approved) or -1 (rejected).
|
||||
*
|
||||
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
|
||||
* should be called to recalculate the document status.
|
||||
*
|
||||
* @param SeedDMS_Core_User $user
|
||||
* @return int 0 if successful
|
||||
* @param integer $approveid id of approval
|
||||
* @param SeedDMS_Core_User $requestUser user requesting the removal
|
||||
* @param string $comment comment
|
||||
*
|
||||
* @return integer|bool true if successful, error code < 0,
|
||||
* false in case of an sql error
|
||||
*/
|
||||
public function removeApproval($approveid, $requestUser, $comment='') { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
@ -4309,25 +4400,31 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
$requestUser->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
|
||||
/**
|
||||
* Sets approval status of a document content for a group
|
||||
* Sets approval status of a document content for a group
|
||||
*
|
||||
* The functions behaves like
|
||||
* {link SeedDMS_Core_DocumentContent::setApprovalByInd} but does it for
|
||||
* group instead of a user
|
||||
* a group instead of a user
|
||||
*/
|
||||
function setApprovalByGrp($group, $requestUser, $status, $comment, $file='') { /* {{{ */
|
||||
if(!$group || !$requestUser)
|
||||
return -1;
|
||||
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
// Check to see if the user can be removed from the approval list.
|
||||
if(!$group->isType('group'))
|
||||
return -1;
|
||||
|
||||
// Check if the group is on the approval list at all.
|
||||
$approvalStatus = $group->getApprovalStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($approvalStatus) && !$approvalStatus) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (count($approvalStatus)==0) {
|
||||
// User is not assigned to approve this document. No action required.
|
||||
|
@ -4362,10 +4459,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
function delIndReviewer($user, $requestUser, $msg='') { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$user->isType('user'))
|
||||
return -1;
|
||||
|
||||
// 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) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (count($reviewStatus["indstatus"])==0) {
|
||||
// User is not assigned to review this document. No action required.
|
||||
|
@ -4392,12 +4492,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
function delGrpReviewer($group, $requestUser, $msg='') { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$group->isType('group'))
|
||||
return -1;
|
||||
|
||||
$groupID = $group->getID();
|
||||
|
||||
// Check to see if the user can be removed from the review list.
|
||||
$reviewStatus = $group->getReviewStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($reviewStatus) && !$reviewStatus) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (count($reviewStatus)==0) {
|
||||
// User is not assigned to review this document. No action required.
|
||||
|
@ -4423,12 +4526,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
function delIndApprover($user, $requestUser, $msg='') { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$user->isType('user'))
|
||||
return -1;
|
||||
|
||||
$userID = $user->getID();
|
||||
|
||||
// Check to see if the user can be removed from the approval list.
|
||||
// Check if the user is on the approval list at all.
|
||||
$approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($approvalStatus) && !$approvalStatus) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (count($approvalStatus["indstatus"])==0) {
|
||||
// User is not assigned to approve this document. No action required.
|
||||
|
@ -4455,12 +4561,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
function delGrpApprover($group, $requestUser, $msg='') { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$group->isType('group'))
|
||||
return -1;
|
||||
|
||||
$groupID = $group->getID();
|
||||
|
||||
// Check to see if the user can be removed from the approver list.
|
||||
// Check if the group is on the approval list at all.
|
||||
$approvalStatus = $group->getApprovalStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($approvalStatus) && !$approvalStatus) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (count($approvalStatus)==0) {
|
||||
// User is not assigned to approve this document. No action required.
|
||||
|
|
Loading…
Reference in New Issue
Block a user