- renamed class Document to LetoDMS_Document

- add static function getDocument() to LetoDMS_Document but kept the
  old function getDocument() until all calls has been changed to
	LetoDMS_Document::getDocument()
This commit is contained in:
steinm 2010-10-29 14:16:25 +00:00
parent b5bc621318
commit 5af290a527
5 changed files with 36 additions and 31 deletions

View File

@ -27,36 +27,12 @@ define("S_EXPIRED", -3);
function getDocument($id)
{
GLOBAL $db;
if (!is_numeric($id)) return false;
$queryStr = "SELECT * FROM tblDocuments WHERE id = " . $id;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
if (count($resArr) != 1)
return false;
$resArr = $resArr[0];
// New Locking mechanism uses a separate table to track the lock.
$queryStr = "SELECT * FROM tblDocumentLocks WHERE document = " . $id;
$lockArr = $db->getResultArray($queryStr);
if ((is_bool($lockArr) && $lockArr==false) || (count($lockArr)==0)) {
// Could not find a lock on the selected document.
$lock = -1;
}
else {
// A lock has been identified for this document.
$lock = $lockArr[0]["userID"];
}
return new Document($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr["inheritAccess"], $resArr["defaultAccess"], $lock, $resArr["keywords"], $resArr["sequence"]);
return LetoDMS_Document::getDocument($id);
}
// these are the document information (all versions)
class Document
class LetoDMS_Document
{
var $_id;
var $_name;
@ -70,7 +46,7 @@ class Document
var $_keywords;
var $_sequence;
function Document($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence)
function LetoDMS_Document($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence)
{
$this->_id = $id;
$this->_name = $name;
@ -86,6 +62,35 @@ class Document
$this->_sequence = $sequence;
}
function getDocument($id)
{
GLOBAL $db;
if (!is_numeric($id)) return false;
$queryStr = "SELECT * FROM tblDocuments WHERE id = " . $id;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
if (count($resArr) != 1)
return false;
$resArr = $resArr[0];
// New Locking mechanism uses a separate table to track the lock.
$queryStr = "SELECT * FROM tblDocumentLocks WHERE document = " . $id;
$lockArr = $db->getResultArray($queryStr);
if ((is_bool($lockArr) && $lockArr==false) || (count($lockArr)==0)) {
// Could not find a lock on the selected document.
$lock = -1;
}
else {
// A lock has been identified for this document.
$lock = $lockArr[0]["userID"];
}
return new LetoDMS_Document($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr["inheritAccess"], $resArr["defaultAccess"], $lock, $resArr["keywords"], $resArr["sequence"]);
}
function getDir() {
global $settings;
return $settings->_contentOffsetDir."/".$this->_id."/";

View File

@ -490,7 +490,7 @@ class Folder
$this->_documents = array();
foreach ($resArr as $row) {
array_push($this->_documents, new Document($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], isset($row["lockUser"])?$row["lockUser"]:NULL, $row["keywords"], $row["sequence"]));
array_push($this->_documents, new LetoDMS_Document($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], isset($row["lockUser"])?$row["lockUser"]:NULL, $row["keywords"], $row["sequence"]));
}
}
return $this->_documents;

View File

@ -609,7 +609,7 @@ class LetoDMS_User
$this->_documents = array();
foreach ($resArr as $row) {
array_push($this->_documents, new 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"]));
array_push($this->_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 $this->_documents;

View File

@ -78,7 +78,7 @@ $resArr = $db->getResultArray($searchQuery);
if (!is_bool($resArr) && count($resArr)>0) {
echo "<ol>";
foreach($resArr as $docArr) {
$doc = new Document($docArr["id"],
$doc = new LetoDMS_Document($docArr["id"],
$docArr["name"],
$docArr["comment"],
$docArr["date"],

View File

@ -420,7 +420,7 @@ print "</tr>\n</thead>\n<tbody>\n";
$resultsFilteredByAccess = false;
foreach ($resArr as $docArr) {
$document = new Document(
$document = new LetoDMS_Document(
$docArr["id"], $docArr["name"],
$docArr["comment"], $docArr["date"],
$docArr["expires"], $docArr["owner"],