mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-06 21:29:27 +00:00
clean up parameters passed to getDocumentList()
This commit is contained in:
parent
d9d5c98c5f
commit
8126d6d3fe
|
@ -201,7 +201,7 @@ class SeedDMS_Core_DMS {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a list of objects contains a single object
|
* Checks if a list of objects contains a single object
|
||||||
*
|
*
|
||||||
* This function is only applicable on list containing objects which have
|
* This function is only applicable on list containing objects which have
|
||||||
* a method getID() because it is used to check if two objects are equal.
|
* a method getID() because it is used to check if two objects are equal.
|
||||||
|
@ -728,12 +728,14 @@ class SeedDMS_Core_DMS {
|
||||||
* @param string $listtype type of document list, can be 'AppRevByMe',
|
* @param string $listtype type of document list, can be 'AppRevByMe',
|
||||||
* 'AppRevOwner', 'ReceiptByMe', 'ReviseByMe', 'LockedByMe', 'MyDocs'
|
* 'AppRevOwner', 'ReceiptByMe', 'ReviseByMe', 'LockedByMe', 'MyDocs'
|
||||||
* @param object $param1 user
|
* @param object $param1 user
|
||||||
* @param string $param2 sort list if listtype='MyDocs', set to true
|
* @param string $param2 set to true
|
||||||
* if 'AppRevByMe', 'ReviseByMe', 'ReceiptByMe' shall return even documents
|
* if 'AppRevByMe', 'ReviseByMe', 'ReceiptByMe' shall return even documents
|
||||||
* І have already taken care of.
|
* І have already taken care of.
|
||||||
|
* @param string $param3 sort list by this field
|
||||||
|
* @param string $param4 order direction
|
||||||
* @return array list of documents
|
* @return array list of documents
|
||||||
*/
|
*/
|
||||||
function getDocumentList($listtype, $param1=null, $param2='', $param3='') { /* {{{ */
|
function getDocumentList($listtype, $param1=null, $param2=false, $param3='', $param4='') { /* {{{ */
|
||||||
/* The following query will get all documents and lots of additional
|
/* The following query will get all documents and lots of additional
|
||||||
* information. It requires the two temporary tables ttcontentid and
|
* information. It requires the two temporary tables ttcontentid and
|
||||||
* ttstatid.
|
* ttstatid.
|
||||||
|
@ -741,6 +743,9 @@ class SeedDMS_Core_DMS {
|
||||||
if (!$this->db->createTemporaryTable("ttstatid") || !$this->db->createTemporaryTable("ttcontentid")) {
|
if (!$this->db->createTemporaryTable("ttstatid") || !$this->db->createTemporaryTable("ttcontentid")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/* The following statement retrieves the status of the last version of all
|
||||||
|
* documents. It must be restricted by further where clauses.
|
||||||
|
*/
|
||||||
$queryStr = "SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser`, ".
|
$queryStr = "SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser`, ".
|
||||||
"`tblDocumentContent`.`version`, `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ".
|
"`tblDocumentContent`.`version`, `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ".
|
||||||
"`tblDocumentStatusLog`.`comment` AS `statusComment`, `tblDocumentStatusLog`.`date` as `statusDate`, ".
|
"`tblDocumentStatusLog`.`comment` AS `statusComment`, `tblDocumentStatusLog`.`date` as `statusDate`, ".
|
||||||
|
@ -758,12 +763,12 @@ class SeedDMS_Core_DMS {
|
||||||
"AND `ttcontentid`.`maxVersion` = `tblDocumentContent`.`version` ";
|
"AND `ttcontentid`.`maxVersion` = `tblDocumentContent`.`version` ";
|
||||||
|
|
||||||
switch($listtype) {
|
switch($listtype) {
|
||||||
case 'AppRevByMe': // Documents I have to review/approve
|
case 'AppRevByMe': // Documents I have to review/approve {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
// Get document list for the current user.
|
// Get document list for the current user.
|
||||||
$reviewStatus = $user->getReviewStatus();
|
$reviewStatus = $user->getReviewStatus();
|
||||||
$approvalStatus = $user->getApprovalStatus();
|
$approvalStatus = $user->getApprovalStatus();
|
||||||
|
|
||||||
// Create a comma separated list of all the documentIDs whose information is
|
// Create a comma separated list of all the documentIDs whose information is
|
||||||
// required.
|
// required.
|
||||||
// Take only those documents into account which hasn't be touched by the user
|
// Take only those documents into account which hasn't be touched by the user
|
||||||
|
@ -792,7 +797,7 @@ class SeedDMS_Core_DMS {
|
||||||
foreach ($dList as $d) {
|
foreach ($dList as $d) {
|
||||||
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($docCSV)>0) {
|
if (strlen($docCSV)>0) {
|
||||||
$queryStr .= "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.", ".S_EXPIRED.") ".
|
$queryStr .= "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.", ".S_EXPIRED.") ".
|
||||||
"AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
"AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
||||||
|
@ -800,14 +805,82 @@ class SeedDMS_Core_DMS {
|
||||||
} else {
|
} else {
|
||||||
$queryStr = '';
|
$queryStr = '';
|
||||||
}
|
}
|
||||||
break;
|
break; // }}}
|
||||||
case 'ReceiptByMe': // Documents I have to receipt
|
case 'ReviewByMe': // Documents I have to review {{{
|
||||||
|
$user = $param1;
|
||||||
|
// Get document list for the current user.
|
||||||
|
$reviewStatus = $user->getReviewStatus();
|
||||||
|
|
||||||
|
// Create a comma separated list of all the documentIDs whose information is
|
||||||
|
// required.
|
||||||
|
// Take only those documents into account which hasn't be touched by the user
|
||||||
|
// ($st["status"]==0)
|
||||||
|
$dList = array();
|
||||||
|
foreach ($reviewStatus["indstatus"] as $st) {
|
||||||
|
if (($st["status"]==0 || $param2) && !in_array($st["documentID"], $dList)) {
|
||||||
|
$dList[] = $st["documentID"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($reviewStatus["grpstatus"] as $st) {
|
||||||
|
if (($st["status"]==0 || $param2) && !in_array($st["documentID"], $dList)) {
|
||||||
|
$dList[] = $st["documentID"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$docCSV = "";
|
||||||
|
foreach ($dList as $d) {
|
||||||
|
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($docCSV)>0) {
|
||||||
|
$queryStr .= "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_EXPIRED.") ".
|
||||||
|
"AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
||||||
|
"ORDER BY `statusDate` DESC";
|
||||||
|
} else {
|
||||||
|
$queryStr = '';
|
||||||
|
}
|
||||||
|
break; // }}}
|
||||||
|
case 'ApproveByMe': // Documents I have to approve {{{
|
||||||
|
$user = $param1;
|
||||||
|
// Get document list for the current user.
|
||||||
|
$approvalStatus = $user->getApprovalStatus();
|
||||||
|
|
||||||
|
// Create a comma separated list of all the documentIDs whose information is
|
||||||
|
// required.
|
||||||
|
// Take only those documents into account which hasn't be touched by the user
|
||||||
|
// ($st["status"]==0)
|
||||||
|
$dList = array();
|
||||||
|
foreach ($approvalStatus["indstatus"] as $st) {
|
||||||
|
if (($st["status"]==0 || $param2) && !in_array($st["documentID"], $dList)) {
|
||||||
|
$dList[] = $st["documentID"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($approvalStatus["grpstatus"] as $st) {
|
||||||
|
if (($st["status"]==0 || $param2) && !in_array($st["documentID"], $dList)) {
|
||||||
|
$dList[] = $st["documentID"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$docCSV = "";
|
||||||
|
foreach ($dList as $d) {
|
||||||
|
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($docCSV)>0) {
|
||||||
|
$queryStr .= "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_APP.", ".S_EXPIRED.") ".
|
||||||
|
"AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
||||||
|
"ORDER BY `statusDate` DESC";
|
||||||
|
} else {
|
||||||
|
$queryStr = '';
|
||||||
|
}
|
||||||
|
break; // }}}
|
||||||
|
case 'ReceiptByMe': // Documents I have to receipt {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
// Get document list for the current user.
|
// Get document list for the current user.
|
||||||
$receiptStatus = $user->getReceiptStatus();
|
$receiptStatus = $user->getReceiptStatus();
|
||||||
|
|
||||||
// Create a comma separated list of all the documentIDs whose information is
|
// Create a comma separated list of all the documentIDs whose information is
|
||||||
// required.
|
// required.
|
||||||
|
// Take only those documents into account which hasn't be touched by the user
|
||||||
|
// ($st["status"]==0)
|
||||||
$dList = array();
|
$dList = array();
|
||||||
foreach ($receiptStatus["indstatus"] as $st) {
|
foreach ($receiptStatus["indstatus"] as $st) {
|
||||||
if (($st["status"]==0 || $param2) && !in_array($st["documentID"], $dList)) {
|
if (($st["status"]==0 || $param2) && !in_array($st["documentID"], $dList)) {
|
||||||
|
@ -823,19 +896,19 @@ class SeedDMS_Core_DMS {
|
||||||
foreach ($dList as $d) {
|
foreach ($dList as $d) {
|
||||||
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($docCSV)>0) {
|
if (strlen($docCSV)>0) {
|
||||||
$queryStr .= "AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
$queryStr .= "AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
||||||
"ORDER BY `statusDate` DESC";
|
"ORDER BY `statusDate` DESC";
|
||||||
} else {
|
} else {
|
||||||
$queryStr = '';
|
$queryStr = '';
|
||||||
}
|
}
|
||||||
break;
|
break; // }}}
|
||||||
case 'ReviseByMe': // Documents I have to receipt
|
case 'ReviseByMe': // Documents I have to receipt {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
// Get document list for the current user.
|
// Get document list for the current user.
|
||||||
$revisionStatus = $user->getRevisionStatus();
|
$revisionStatus = $user->getRevisionStatus();
|
||||||
|
|
||||||
// Create a comma separated list of all the documentIDs whose information is
|
// Create a comma separated list of all the documentIDs whose information is
|
||||||
// required.
|
// required.
|
||||||
$dList = array();
|
$dList = array();
|
||||||
|
@ -853,19 +926,19 @@ class SeedDMS_Core_DMS {
|
||||||
foreach ($dList as $d) {
|
foreach ($dList as $d) {
|
||||||
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($docCSV)>0) {
|
if (strlen($docCSV)>0) {
|
||||||
$queryStr .= "AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
$queryStr .= "AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
||||||
"ORDER BY `statusDate` DESC";
|
"ORDER BY `statusDate` DESC";
|
||||||
} else {
|
} else {
|
||||||
$queryStr = '';
|
$queryStr = '';
|
||||||
}
|
}
|
||||||
break;
|
break; // }}}
|
||||||
case 'WorkflowByMe': // Documents I to trigger in Worklflow
|
case 'WorkflowByMe': // Documents I to trigger in Worklflow {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
// Get document list for the current user.
|
// Get document list for the current user.
|
||||||
$workflowStatus = $user->getWorkflowStatus();
|
$workflowStatus = $user->getWorkflowStatus();
|
||||||
|
|
||||||
// Create a comma separated list of all the documentIDs whose information is
|
// Create a comma separated list of all the documentIDs whose information is
|
||||||
// required.
|
// required.
|
||||||
$dList = array();
|
$dList = array();
|
||||||
|
@ -883,20 +956,20 @@ class SeedDMS_Core_DMS {
|
||||||
foreach ($dList as $d) {
|
foreach ($dList as $d) {
|
||||||
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
$docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($docCSV)>0) {
|
if (strlen($docCSV)>0) {
|
||||||
$queryStr .=
|
$queryStr .=
|
||||||
//"AND `tblDocumentStatusLog`.`status` IN (".S_IN_WORKFLOW.", ".S_EXPIRED.") ".
|
//"AND `tblDocumentStatusLog`.`status` IN (".S_IN_WORKFLOW.", ".S_EXPIRED.") ".
|
||||||
"AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
"AND `tblDocuments`.`id` IN (" . $docCSV . ") ".
|
||||||
"ORDER BY `statusDate` DESC";
|
"ORDER BY `statusDate` DESC";
|
||||||
} else {
|
} else {
|
||||||
$queryStr = '';
|
$queryStr = '';
|
||||||
}
|
}
|
||||||
break;
|
break; // }}}
|
||||||
case 'AppRevOwner': // Documents waiting for review/approval I'm owning
|
case 'AppRevOwner': // Documents waiting for review/approval I'm owning {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
$orderby = $param2;
|
$orderby = $param3;
|
||||||
if($param3 == 'desc')
|
if($param4 == 'desc')
|
||||||
$orderdir = 'DESC';
|
$orderdir = 'DESC';
|
||||||
else
|
else
|
||||||
$orderdir = 'ASC';
|
$orderdir = 'ASC';
|
||||||
|
@ -910,28 +983,28 @@ class SeedDMS_Core_DMS {
|
||||||
// $queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
|
// $queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
|
||||||
// "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.") ".
|
// "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.") ".
|
||||||
// "ORDER BY `statusDate` DESC";
|
// "ORDER BY `statusDate` DESC";
|
||||||
break;
|
break; // }}}
|
||||||
case 'RejectOwner': // Documents that has been rejected and I'm owning
|
case 'RejectOwner': // Documents that has been rejected and I'm owning {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
$queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
|
$queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
|
||||||
"AND `tblDocumentStatusLog`.`status` IN (".S_REJECTED.") ".
|
"AND `tblDocumentStatusLog`.`status` IN (".S_REJECTED.") ".
|
||||||
"ORDER BY `statusDate` DESC";
|
"ORDER BY `statusDate` DESC";
|
||||||
break;
|
break; // }}}
|
||||||
case 'LockedByMe': // Documents locked by me
|
case 'LockedByMe': // Documents locked by me {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
$queryStr .= "AND `tblDocumentLocks`.`userID` = '".$user->getID()."' ".
|
$queryStr .= "AND `tblDocumentLocks`.`userID` = '".$user->getID()."' ".
|
||||||
"ORDER BY `statusDate` DESC";
|
"ORDER BY `statusDate` DESC";
|
||||||
break;
|
break; // }}}
|
||||||
case 'WorkflowOwner': // Documents waiting for workflow trigger I'm owning
|
case 'WorkflowOwner': // Documents waiting for workflow trigger I'm owning {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
$queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
|
$queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
|
||||||
"AND `tblDocumentStatusLog`.`status` IN (".S_IN_WORKFLOW.") ".
|
"AND `tblDocumentStatusLog`.`status` IN (".S_IN_WORKFLOW.") ".
|
||||||
"ORDER BY `statusDate` DESC";
|
"ORDER BY `statusDate` DESC";
|
||||||
break;
|
break; // }}}
|
||||||
case 'MyDocs': // Documents owned by me
|
case 'MyDocs': // Documents owned by me {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
$orderby = $param2;
|
$orderby = $param3;
|
||||||
if($param3 == 'desc')
|
if($param4 == 'desc')
|
||||||
$orderdir = 'DESC';
|
$orderdir = 'DESC';
|
||||||
else
|
else
|
||||||
$orderdir = 'ASC';
|
$orderdir = 'ASC';
|
||||||
|
@ -941,8 +1014,8 @@ class SeedDMS_Core_DMS {
|
||||||
else if ($orderby=='s') $queryStr .= "ORDER BY `status`";
|
else if ($orderby=='s') $queryStr .= "ORDER BY `status`";
|
||||||
else $queryStr .= "ORDER BY `name`";
|
else $queryStr .= "ORDER BY `name`";
|
||||||
$queryStr .= " ".$orderdir;
|
$queryStr .= " ".$orderdir;
|
||||||
break;
|
break; // }}}
|
||||||
case 'CheckedOutByMe': // Documents I have checked out
|
case 'CheckedOutByMe': // Documents I have checked out {{{
|
||||||
$user = $param1;
|
$user = $param1;
|
||||||
|
|
||||||
$qs = 'SELECT document FROM tblDocumentCheckOuts WHERE userID='.$user->getID();
|
$qs = 'SELECT document FROM tblDocumentCheckOuts WHERE userID='.$user->getID();
|
||||||
|
@ -954,14 +1027,14 @@ class SeedDMS_Core_DMS {
|
||||||
foreach($ra as $d) {
|
foreach($ra as $d) {
|
||||||
$docs[] = $d['document'];
|
$docs[] = $d['document'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($docs) {
|
if ($docs) {
|
||||||
$queryStr .= "AND `tblDocuments`.`id` IN (" . implode(',', $docs) . ") ".
|
$queryStr .= "AND `tblDocuments`.`id` IN (" . implode(',', $docs) . ") ".
|
||||||
"ORDER BY `statusDate` DESC";
|
"ORDER BY `statusDate` DESC";
|
||||||
} else {
|
} else {
|
||||||
$queryStr = '';
|
$queryStr = '';
|
||||||
}
|
}
|
||||||
break;
|
break; // }}}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($queryStr) {
|
if($queryStr) {
|
||||||
|
@ -2523,7 +2596,7 @@ class SeedDMS_Core_DMS {
|
||||||
$versions[] = $version;
|
$versions[] = $version;
|
||||||
}
|
}
|
||||||
return $versions;
|
return $versions;
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2547,7 +2620,7 @@ class SeedDMS_Core_DMS {
|
||||||
$versions[] = $version;
|
$versions[] = $version;
|
||||||
}
|
}
|
||||||
return $versions;
|
return $versions;
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2571,7 +2644,7 @@ class SeedDMS_Core_DMS {
|
||||||
$versions[] = $version;
|
$versions[] = $version;
|
||||||
}
|
}
|
||||||
return $versions;
|
return $versions;
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2599,7 +2672,7 @@ class SeedDMS_Core_DMS {
|
||||||
$versions[$row['dupid']]['duplicates'][] = $version;
|
$versions[$row['dupid']]['duplicates'][] = $version;
|
||||||
}
|
}
|
||||||
return $versions;
|
return $versions;
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2755,11 +2828,11 @@ class SeedDMS_Core_DMS {
|
||||||
foreach ($record as $column) {
|
foreach ($record as $column) {
|
||||||
if (is_numeric($column)) $values .= $column;
|
if (is_numeric($column)) $values .= $column;
|
||||||
else $values .= $this->db->qstr($column);
|
else $values .= $this->db->qstr($column);
|
||||||
|
|
||||||
if ($i<(count($record))) $values .= ",";
|
if ($i<(count($record))) $values .= ",";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite($h, "INSERT INTO `".$table."` VALUES (".$values.");\n");
|
fwrite($h, "INSERT INTO `".$table."` VALUES (".$values.");\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user