- added method getDocumentsByUser()

This commit is contained in:
steinm 2010-11-22 14:49:29 +00:00
parent d9f7bb09bc
commit b11cb60de7

View File

@ -204,6 +204,29 @@ class LetoDMS_DMS {
return $document; return $document;
} /* }}} */ } /* }}} */
/**
* Returns all documents of a given user
*
* @param object $user
* @return array list of documents
*/
function getDocumentsByUser($user) { /* {{{ */
$queryStr = "SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser` ".
"FROM `tblDocuments` ".
"LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id`=`tblDocumentLocks`.`document` ".
"WHERE `tblDocuments`.`owner` = " . $user->getID() . " ORDER BY `sequence`";
$resArr = $this->db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
$documents = array();
foreach ($resArr as $row) {
array_push($documents, new LetoDMS_Document($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], $row["lockUser"], $row["keywords"], $row["sequence"]));
}
return $documents;
} /* }}} */
/* /*
* Search the database for documents * Search the database for documents
* *