SeedDMS_Core

This commit is contained in:
Jörg Neugebauer 2017-11-08 13:54:49 +01:00
parent 3f2e24f80d
commit fd5f341cb9
9 changed files with 818 additions and 285 deletions

View File

@ -90,5 +90,3 @@ require_once('Core/inc.AccessUtils.php');
* @uses SeedDMS_File
*/
require_once('Core/inc.FileUtils.php');
?>

View File

@ -36,6 +36,11 @@ class SeedDMS_Core_Group { /* {{{ */
*/
protected $_name;
/**
* @var SeedDMS_Core_User[]
*/
protected $_users;
/**
* The comment of the user group
*
@ -46,7 +51,7 @@ class SeedDMS_Core_Group { /* {{{ */
/**
* Back reference to DMS this user group belongs to
*
* @var object
* @var SeedDMS_Core_DMS
*/
protected $_dms;
@ -62,10 +67,10 @@ class SeedDMS_Core_Group { /* {{{ */
*
* @param string|integer $id Id, name of group, depending
* on the 3rd parameter.
* @param object $dms instance of dms
* @param SeedDMS_Core_DMS $dms instance of dms
* @param string $by search by group name if set to 'name'.
* Search by Id of group if left empty.
* @return object instance of class SeedDMS_Core_Group
* @return SeedDMS_Core_Group|false instance of class SeedDMS_Core_Group
*/
public static function getInstance($id, $dms, $by='') { /* {{{ */
$db = $dms->getDB();
@ -91,6 +96,11 @@ class SeedDMS_Core_Group { /* {{{ */
return $group;
} /* }}} */
/**
* @param $orderby
* @param SeedDMS_Core_DMS $dms
* @return array|bool
*/
public static function getAllInstances($orderby, $dms) { /* {{{ */
$db = $dms->getDB();
@ -113,14 +123,27 @@ class SeedDMS_Core_Group { /* {{{ */
return $groups;
} /* }}} */
/**
* @param SeedDMS_Core_DMS $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
/**
* @return int
*/
function getID() { return $this->_id; }
/**
* @return string
*/
function getName() { return $this->_name; }
/**
* @param $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
@ -132,8 +155,15 @@ class SeedDMS_Core_Group { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getComment() { return $this->_comment; }
/**
* @param $newComment
* @return bool
*/
function setComment($newComment) { /* {{{ */
$db = $this->_dms->getDB();
@ -145,6 +175,9 @@ class SeedDMS_Core_Group { /* {{{ */
return true;
} /* }}} */
/**
* @return SeedDMS_Core_User[]|bool
*/
function getUsers() { /* {{{ */
$db = $this->_dms->getDB();
@ -159,7 +192,8 @@ class SeedDMS_Core_Group { /* {{{ */
$this->_users = array();
$classname = $this->_dms->getClassname('user');
foreach ($resArr as $row) {
foreach ($resArr as $row) {
/** @var SeedDMS_Core_User $user */
$user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["role"], $row['hidden']);
array_push($this->_users, $user);
}
@ -167,6 +201,9 @@ class SeedDMS_Core_Group { /* {{{ */
return $this->_users;
} /* }}} */
/**
* @return SeedDMS_Core_User[]|bool
*/
function getManagers() { /* {{{ */
$db = $this->_dms->getDB();
@ -180,13 +217,19 @@ class SeedDMS_Core_Group { /* {{{ */
$managers = array();
$classname = $this->_dms->getClassname('user');
foreach ($resArr as $row) {
foreach ($resArr as $row) {
/** @var SeedDMS_Core_User $user */
$user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["role"], $row['hidden']);
array_push($managers, $user);
}
return $managers;
} /* }}} */
/**
* @param SeedDMS_Core_User $user
* @param bool $asManager
* @return bool
*/
function addUser($user,$asManager=false) { /* {{{ */
$db = $this->_dms->getDB();
@ -199,6 +242,10 @@ class SeedDMS_Core_Group { /* {{{ */
return true;
} /* }}} */
/**
* @param SeedDMS_Core_User $user
* @return bool
*/
function removeUser($user) { /* {{{ */
$db = $this->_dms->getDB();
@ -213,7 +260,7 @@ class SeedDMS_Core_Group { /* {{{ */
/**
* Check if user is member of group
*
* @param object $user user to be checked
* @param SeedDMS_Core_User $user user to be checked
* @param boolean $asManager also check whether user is manager of group if
* set to true, otherwise does not care about manager status
* @return boolean true if user is member, otherwise false
@ -241,7 +288,7 @@ class SeedDMS_Core_Group { /* {{{ */
/**
* Toggle manager status of user
*
* @param object $user
* @param SeedDMS_Core_User $user
* @return boolean true if operation was successful, otherwise false
*/
function toggleManager($user) { /* {{{ */
@ -261,7 +308,7 @@ class SeedDMS_Core_Group { /* {{{ */
* This function deletes the user group and all it references, like access
* control lists, notifications, as a child of other groups, etc.
*
* @param object $user the user doing the removal (needed for entry in
* @param SeedDMS_Core_User $user the user doing the removal (needed for entry in
* review log.
* @return boolean true on success or false in case of an error
*/
@ -405,7 +452,7 @@ class SeedDMS_Core_Group { /* {{{ */
* @param int $documentID optional document id for which to retrieve the
* reviews
* @param int $version optional version of the document
* @return array list of all workflows
* @return bool|array list of all workflows
*/
function getWorkflowStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
@ -432,7 +479,7 @@ class SeedDMS_Core_Group { /* {{{ */
* Get all notifications of group
*
* @param integer $type type of item (T_DOCUMENT or T_FOLDER)
* @return array array of notifications
* @return SeedDMS_Core_Notification[]|bool array of notifications
*/
function getNotifications($type=0) { /* {{{ */
$db = $this->_dms->getDB();
@ -457,4 +504,3 @@ class SeedDMS_Core_Group { /* {{{ */
} /* }}} */
} /* }}} */
?>

View File

@ -42,11 +42,17 @@ class SeedDMS_Core_KeywordCategory {
protected $_name;
/**
* @var object $_dms reference to dms this category belongs to
* @var SeedDMS_Core_DMS $_dms reference to dms this category belongs to
* @access protected
*/
protected $_dms;
/**
* SeedDMS_Core_KeywordCategory constructor.
* @param $id
* @param $ownerID
* @param $name
*/
function __construct($id, $ownerID, $name) {
$this->_id = $id;
$this->_name = $name;
@ -54,20 +60,36 @@ class SeedDMS_Core_KeywordCategory {
$this->_dms = null;
}
/**
* @param SeedDMS_Core_DMS $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
/**
* @return int
*/
function getID() { return $this->_id; }
/**
* @return string
*/
function getName() { return $this->_name; }
/**
* @return bool|SeedDMS_Core_User
*/
function getOwner() {
if (!isset($this->_owner))
$this->_owner = $this->_dms->getUser($this->_ownerID);
return $this->_owner;
}
/**
* @param $newName
* @return bool
*/
function setName($newName) {
$db = $this->_dms->getDB();
@ -79,6 +101,10 @@ class SeedDMS_Core_KeywordCategory {
return true;
}
/**
* @param SeedDMS_Core_User $user
* @return bool
*/
function setOwner($user) {
$db = $this->_dms->getDB();
@ -91,6 +117,9 @@ class SeedDMS_Core_KeywordCategory {
return true;
}
/**
* @return array
*/
function getKeywordLists() {
$db = $this->_dms->getDB();
@ -98,6 +127,11 @@ class SeedDMS_Core_KeywordCategory {
return $db->getResultArray($queryStr);
}
/**
* @param $listID
* @param $keywords
* @return bool
*/
function editKeywordList($listID, $keywords) {
$db = $this->_dms->getDB();
@ -105,6 +139,10 @@ class SeedDMS_Core_KeywordCategory {
return $db->getResult($queryStr);
}
/**
* @param $keywords
* @return bool
*/
function addKeywordList($keywords) {
$db = $this->_dms->getDB();
@ -112,6 +150,10 @@ class SeedDMS_Core_KeywordCategory {
return $db->getResult($queryStr);
}
/**
* @param $listID
* @return bool
*/
function removeKeywordList($listID) {
$db = $this->_dms->getDB();
@ -119,6 +161,9 @@ class SeedDMS_Core_KeywordCategory {
return $db->getResult($queryStr);
}
/**
* @return bool
*/
function remove() {
$db = $this->_dms->getDB();
@ -139,5 +184,3 @@ class SeedDMS_Core_KeywordCategory {
return true;
}
}
?>

View File

@ -117,23 +117,51 @@ class SeedDMS_Core_User { /* {{{ */
var $_loginFailures;
/**
* @var object home folder
* @var SeedDMS_Core_Folder home folder
*
* @access protected
*/
var $_homeFolder;
/**
* @var object reference to the dms instance this user belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this user belongs to
*
* @access protected
*/
var $_dms;
/**
* @var int
*/
private $_quota;
/**
* @var bool
*/
private $_hasImage;
const role_user = '0';
const role_admin = '1';
const role_guest = '2';
/**
* SeedDMS_Core_User constructor.
* @param $id
* @param $login
* @param $pwd
* @param $fullName
* @param $email
* @param $language
* @param $theme
* @param $comment
* @param $role
* @param int $isHidden
* @param int $isDisabled
* @param string $pwdExpiration
* @param int $loginFailures
* @param int $quota
* @param null $homeFolder
*/
function __construct($id, $login, $pwd, $fullName, $email, $language, $theme, $comment, $role, $isHidden=0, $isDisabled=0, $pwdExpiration='', $loginFailures=0, $quota=0, $homeFolder=null) {
$this->_id = $id;
$this->_login = $login;
@ -158,12 +186,12 @@ class SeedDMS_Core_User { /* {{{ */
*
* @param string|integer $id Id, login name, or email of user, depending
* on the 3rd parameter.
* @param object $dms instance of dms
* @param SeedDMS_Core_DMS $dms instance of dms
* @param string $by search by [name|email]. If 'name' is passed, the method
* will check for the 4th paramater and also filter by email. If this
* parameter is left empty, the user will be search by its Id.
* @param string $email optional email address if searching for name
* @return object instance of class SeedDMS_Core_User
* @return SeedDMS_Core_User|bool instance of class SeedDMS_Core_User
*/
public static function getInstance($id, $dms, $by='', $email='') { /* {{{ */
$db = $dms->getDB();
@ -192,6 +220,11 @@ class SeedDMS_Core_User { /* {{{ */
return $user;
} /* }}} */
/**
* @param $orderby
* @param SeedDMS_Core_DMS $dms
* @return SeedDMS_Core_User[]|bool
*/
public static function getAllInstances($orderby, $dms) { /* {{{ */
$db = $dms->getDB();
@ -207,6 +240,7 @@ class SeedDMS_Core_User { /* {{{ */
$users = array();
for ($i = 0; $i < count($resArr); $i++) {
/** @var SeedDMS_Core_User $user */
$user = new self($resArr[$i]["id"], $resArr[$i]["login"], $resArr[$i]["pwd"], $resArr[$i]["fullName"], $resArr[$i]["email"], (isset($resArr[$i]["language"])?$resArr[$i]["language"]:NULL), (isset($resArr[$i]["theme"])?$resArr[$i]["theme"]:NULL), $resArr[$i]["comment"], $resArr[$i]["role"], $resArr[$i]["hidden"], $resArr[$i]["disabled"], $resArr[$i]["pwdExpiration"], $resArr[$i]["loginfailures"], $resArr[$i]["quota"], $resArr[$i]["homefolder"]);
$user->setDMS($dms);
$users[$i] = $user;
@ -215,14 +249,27 @@ class SeedDMS_Core_User { /* {{{ */
return $users;
} /* }}} */
/**
* @param SeedDMS_Core_DMS $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
/**
* @return int
*/
function getID() { return $this->_id; }
/**
* @return string
*/
function getLogin() { return $this->_login; }
/**
* @param $newLogin
* @return bool
*/
function setLogin($newLogin) { /* {{{ */
$db = $this->_dms->getDB();
@ -235,8 +282,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getFullName() { return $this->_fullName; }
/**
* @param $newFullName
* @return bool
*/
function setFullName($newFullName) { /* {{{ */
$db = $this->_dms->getDB();
@ -249,8 +303,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getPwd() { return $this->_pwd; }
/**
* @param $newPwd
* @return bool
*/
function setPwd($newPwd) { /* {{{ */
$db = $this->_dms->getDB();
@ -263,8 +324,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getPwdExpiration() { return $this->_pwdExpiration; }
/**
* @param $newPwdExpiration
* @return bool
*/
function setPwdExpiration($newPwdExpiration) { /* {{{ */
$db = $this->_dms->getDB();
@ -283,8 +351,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getEmail() { return $this->_email; }
/**
* @param $newEmail
* @return bool
*/
function setEmail($newEmail) { /* {{{ */
$db = $this->_dms->getDB();
@ -297,9 +372,16 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function getLanguage() { return $this->_language; }
/**
* @return string
*/
function getLanguage() { return $this->_language; }
function setLanguage($newLanguage) { /* {{{ */
/**
* @param $newLanguage
* @return bool
*/
function setLanguage($newLanguage) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblUsers` SET `language` =".$db->qstr($newLanguage)." WHERE `id` = " . $this->_id;
@ -311,9 +393,16 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function getTheme() { return $this->_theme; }
/**
* @return string
*/
function getTheme() { return $this->_theme; }
function setTheme($newTheme) { /* {{{ */
/**
* @param string $newTheme
* @return bool
*/
function setTheme($newTheme) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblUsers` SET `theme` =".$db->qstr($newTheme)." WHERE `id` = " . $this->_id;
@ -325,9 +414,16 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function getComment() { return $this->_comment; }
/**
* @return string
*/
function getComment() { return $this->_comment; }
function setComment($newComment) { /* {{{ */
/**
* @param $newComment
* @return bool
*/
function setComment($newComment) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblUsers` SET `comment` =".$db->qstr($newComment)." WHERE `id` = " . $this->_id;
@ -339,9 +435,16 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function getRole() { return $this->_role; }
/**
* @return string
*/
function getRole() { return $this->_role; }
function setRole($newrole) { /* {{{ */
/**
* @param $newrole
* @return bool
*/
function setRole($newrole) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblUsers` SET `role` = " . $newrole . " WHERE `id` = " . $this->_id;
@ -352,9 +455,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function isAdmin() { return ($this->_role == SeedDMS_Core_User::role_admin); }
/**
* @return bool
*/
function isAdmin() { return ($this->_role == SeedDMS_Core_User::role_admin); }
function setAdmin($isAdmin) { /* {{{ */
/**
* @return bool
*/
function setAdmin() { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblUsers` SET `role` = " . SeedDMS_Core_User::role_admin . " WHERE `id` = " . $this->_id;
@ -365,9 +474,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function isGuest() { return ($this->_role == SeedDMS_Core_User::role_guest); }
/**
* @return bool
*/
function isGuest() { return ($this->_role == SeedDMS_Core_User::role_guest); }
function setGuest($isGuest) { /* {{{ */
/**
* @return bool
*/
function setGuest() { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblUsers` SET `role` = " . SeedDMS_Core_User::role_guest . " WHERE `id` = " . $this->_id;
@ -378,9 +493,16 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function isHidden() { return $this->_isHidden; }
/**
* @return bool|int
*/
function isHidden() { return $this->_isHidden; }
function setHidden($isHidden) { /* {{{ */
/**
* @param $isHidden
* @return bool
*/
function setHidden($isHidden) { /* {{{ */
$db = $this->_dms->getDB();
$isHidden = ($isHidden) ? "1" : "0";
@ -392,9 +514,16 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function isDisabled() { return $this->_isDisabled; }
/**
* @return bool|int
*/
function isDisabled() { return $this->_isDisabled; }
function setDisabled($isDisabled) { /* {{{ */
/**
* @param $isDisabled
* @return bool
*/
function setDisabled($isDisabled) { /* {{{ */
$db = $this->_dms->getDB();
$isDisabled = ($isDisabled) ? "1" : "0";
@ -406,7 +535,10 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function addLoginFailure() { /* {{{ */
/**
* @return bool|int
*/
function addLoginFailure() { /* {{{ */
$db = $this->_dms->getDB();
$this->_loginFailures++;
@ -417,7 +549,10 @@ class SeedDMS_Core_User { /* {{{ */
return $this->_loginFailures;
} /* }}} */
function clearLoginFailures() { /* {{{ */
/**
* @return bool
*/
function clearLoginFailures() { /* {{{ */
$db = $this->_dms->getDB();
$this->_loginFailures = 0;
@ -447,9 +582,16 @@ class SeedDMS_Core_User { /* {{{ */
return $resArr[0]['sum'];
} /* }}} */
function getQuota() { return $this->_quota; }
/**
* @return int
*/
function getQuota() { return $this->_quota; }
function setQuota($quota) { /* {{{ */
/**
* @param $quota
* @return bool
*/
function setQuota($quota) { /* {{{ */
$db = $this->_dms->getDB();
$quota = intval($quota);
@ -461,9 +603,16 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
function getHomeFolder() { return $this->_homeFolder; }
/**
* @return null|SeedDMS_Core_Folder
*/
function getHomeFolder() { return $this->_homeFolder; }
function setHomeFolder($homefolder) { /* {{{ */
/**
* @param $homefolder
* @return bool
*/
function setHomeFolder($homefolder) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblUsers` SET `homefolder` = " . ($homefolder ? (int) $homefolder : NULL) . " WHERE `id` = " . $this->_id;
@ -655,9 +804,9 @@ class SeedDMS_Core_User { /* {{{ */
* Do not remove folders and documents of the user, but assign them
* to a different user.
*
* @param object $user the user doing the removal (needed for entry in
* @param SeedDMS_Core_User $user the user doing the removal (needed for entry in
* review and approve log).
* @param object $assignToUser the user who is new owner of folders and
* @param SeedDMS_Core_User $assignToUser the user who is new owner of folders and
* documents which previously were owned by the delete user.
* @return boolean true on success or false in case of an error
*/
@ -670,8 +819,9 @@ class SeedDMS_Core_User { /* {{{ */
* anymore.
*/
if(!$assignToUser)
return;
$assignTo = $assignToUser->getID();
return false;
/** @noinspection PhpUnusedLocalVariableInspection */
$assignTo = $assignToUser->getID();
$db->startTransaction();
@ -827,7 +977,7 @@ class SeedDMS_Core_User { /* {{{ */
* This function uses {@link SeedDMS_Group::addUser} but checks before if
* the user is already a member of the group.
*
* @param object $group group to be the member of
* @param SeedDMS_Core_Group $group group to be the member of
* @return boolean true on success or false in case of an error or the user
* is already a member of the group
*/
@ -847,7 +997,7 @@ class SeedDMS_Core_User { /* {{{ */
* This function uses {@link SeedDMS_Group::removeUser} but checks before if
* the user is a member of the group at all.
*
* @param object $group group to leave
* @param SeedDMS_Core_Group $group group to leave
* @return boolean true on success or false in case of an error or the user
* is not a member of the group
*/
@ -865,7 +1015,7 @@ class SeedDMS_Core_User { /* {{{ */
/**
* Get all groups the user is a member of
*
* @return array list of groups
* @return SeedDMS_Core_Group[]|bool list of groups
*/
function getGroups() { /* {{{ */
$db = $this->_dms->getDB();
@ -882,6 +1032,7 @@ class SeedDMS_Core_User { /* {{{ */
$this->_groups = array();
$classname = $this->_dms->getClassname('group');
foreach ($resArr as $row) {
/** @var SeedDMS_Core_Group $group */
$group = new $classname($row["id"], $row["name"], $row["comment"]);
$group->setDMS($this->_dms);
array_push($this->_groups, $group);
@ -893,7 +1044,7 @@ class SeedDMS_Core_User { /* {{{ */
/**
* Checks if user is member of a given group
*
* @param object $group
* @param SeedDMS_Core_Group $group
* @return boolean true if user is member of the given group otherwise false
*/
function isMemberOfGroup($group) { /* {{{ */
@ -924,7 +1075,7 @@ class SeedDMS_Core_User { /* {{{ */
/**
* Get the image from the users profile
*
* @return array image data
* @return array|bool image data
*/
function getImage() { /* {{{ */
$db = $this->_dms->getDB();
@ -939,7 +1090,12 @@ class SeedDMS_Core_User { /* {{{ */
return $resArr;
} /* }}} */
function setImage($tmpfile, $mimeType) { /* {{{ */
/**
* @param $tmpfile
* @param $mimeType
* @return bool
*/
function setImage($tmpfile, $mimeType) { /* {{{ */
$db = $this->_dms->getDB();
$fp = fopen($tmpfile, "rb");
@ -958,12 +1114,10 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* Returns all documents of a given user
*
* @param object $user
* @return array list of documents
*/
/**
* Returns all documents of a given user
* @return SeedDMS_Core_Document[]|bool list of documents
*/
function getDocuments() { /* {{{ */
$db = $this->_dms->getDB();
@ -979,6 +1133,7 @@ class SeedDMS_Core_User { /* {{{ */
$documents = array();
$classname = $this->_dms->getClassname('document');
foreach ($resArr as $row) {
/** @var SeedDMS_Core_Document $document */
$document = new $classname($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], $row["lockUser"], $row["keywords"], $row["sequence"]);
$document->setDMS($this->_dms);
$documents[] = $document;
@ -989,8 +1144,7 @@ class SeedDMS_Core_User { /* {{{ */
/**
* Returns all documents locked by a given user
*
* @param object $user
* @return array list of documents
* @return bool|SeedDMS_Core_Document[] list of documents
*/
function getDocumentsLocked() { /* {{{ */
$db = $this->_dms->getDB();
@ -1007,6 +1161,7 @@ class SeedDMS_Core_User { /* {{{ */
$documents = array();
$classname = $this->_dms->getClassname('document');
foreach ($resArr as $row) {
/** @var SeedDMS_Core_Document $document */
$document = new $classname($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], $row["lockUser"], $row["keywords"], $row["sequence"]);
$document->setDMS($this->_dms);
$documents[] = $document;
@ -1032,7 +1187,7 @@ class SeedDMS_Core_User { /* {{{ */
* @param int $documentID optional document id for which to retrieve the
* reviews
* @param int $version optional version of the document
* @return array list of all reviews
* @return array|bool list of all reviews
*/
function getReviewStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
@ -1125,7 +1280,7 @@ class SeedDMS_Core_User { /* {{{ */
* @param int $documentID optional document id for which to retrieve the
* approvals
* @param int $version optional version of the document
* @return array list of all approvals
* @return array|bool list of all approvals
*/
function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
@ -1195,7 +1350,7 @@ class SeedDMS_Core_User { /* {{{ */
* @param int $documentID optional document id for which to retrieve the
* reviews
* @param int $version optional version of the document
* @return array list of all workflows
* @return array|bool list of all workflows
*/
function getWorkflowStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
@ -1237,7 +1392,7 @@ class SeedDMS_Core_User { /* {{{ */
/**
* Get a list of workflows this user is involved as in individual
*
* @return array list of all workflows
* @return array|bool list of all workflows
*/
function getWorkflowsInvolved() { /* {{{ */
$db = $this->_dms->getDB();
@ -1297,7 +1452,7 @@ class SeedDMS_Core_User { /* {{{ */
* This method is the reverse function of getMandatoryReviewers(). It returns
* those user where the current user is a mandatory reviewer.
*
* @return array list of users where this user is a mandatory reviewer.
* @return SeedDMS_Core_User[]|bool list of users where this user is a mandatory reviewer.
*/
function isMandatoryReviewerOf() { /* {{{ */
$db = $this->_dms->getDB();
@ -1320,7 +1475,7 @@ class SeedDMS_Core_User { /* {{{ */
* This method is the reverse function of getMandatoryApprovers(). It returns
* those user where the current user is a mandatory approver.
*
* @return array list of users where this user is a mandatory approver.
* @return SeedDMS_Core_User[]|bool list of users where this user is a mandatory approver.
*/
function isMandatoryApproverOf() { /* {{{ */
$db = $this->_dms->getDB();
@ -1344,7 +1499,7 @@ class SeedDMS_Core_User { /* {{{ */
* Whenever the user inserts a new document the mandatory workflow is
* filled in as the workflow.
*
* @return object workflow
* @return SeedDMS_Core_Workflow|bool workflow
*/
function getMandatoryWorkflow() { /* {{{ */
$db = $this->_dms->getDB();
@ -1367,7 +1522,7 @@ class SeedDMS_Core_User { /* {{{ */
* Whenever the user inserts a new document the mandatory workflow is
* filled in as the workflow.
*
* @return object workflow
* @return SeedDMS_Core_Workflow[]|bool workflow
*/
function getMandatoryWorkflows() { /* {{{ */
$db = $this->_dms->getDB();
@ -1418,6 +1573,7 @@ class SeedDMS_Core_User { /* {{{ */
if (is_bool($resArr) && !$resArr) return false;
}
return false;
} /* }}} */
/**
@ -1435,7 +1591,7 @@ class SeedDMS_Core_User { /* {{{ */
$queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverGroupID` = " . (int) $id;
$resArr = $db->getResultArray($queryStr);
if (count($resArr)!=0) return;
if (count($resArr)!=0) return true;
$queryStr = "INSERT INTO `tblMandatoryApprovers` (`userID`, `approverGroupID`) VALUES (" . $this->_id . ", " . $id .")";
$resArr = $db->getResult($queryStr);
@ -1445,12 +1601,14 @@ class SeedDMS_Core_User { /* {{{ */
$queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverUserID` = " . (int) $id;
$resArr = $db->getResultArray($queryStr);
if (count($resArr)!=0) return;
if (count($resArr)!=0) return true;
$queryStr = "INSERT INTO `tblMandatoryApprovers` (`userID`, `approverUserID`) VALUES (" . $this->_id . ", " . $id .")";
$resArr = $db->getResult($queryStr);
if (is_bool($resArr) && !$resArr) return false;
}
return false;
} /* }}} */
/**
@ -1465,18 +1623,20 @@ class SeedDMS_Core_User { /* {{{ */
$queryStr = "SELECT * FROM `tblWorkflowMandatoryWorkflow` WHERE `userid` = " . $this->_id . " AND `workflow` = " . (int) $workflow->getID();
$resArr = $db->getResultArray($queryStr);
if (count($resArr)!=0) return;
if (count($resArr)!=0) return true;
$queryStr = "INSERT INTO `tblWorkflowMandatoryWorkflow` (`userid`, `workflow`) VALUES (" . $this->_id . ", " . $workflow->getID() .")";
$resArr = $db->getResult($queryStr);
if (is_bool($resArr) && !$resArr) return false;
return false;
} /* }}} */
/**
* Set a mandatory workflows
* This function sets a list of mandatory workflows.
*
* @param array $workflows list of workflow objects
* @param SeedDMS_Core_Workflow[] $workflows list of workflow objects
* @return boolean true on success, otherwise false
*/
function setMandatoryWorkflows($workflows) { /* {{{ */
@ -1543,7 +1703,7 @@ class SeedDMS_Core_User { /* {{{ */
* Get all notifications of user
*
* @param integer $type type of item (T_DOCUMENT or T_FOLDER)
* @return array array of notifications
* @return SeedDMS_Core_Notification[]|bool array of notifications
*/
function getNotifications($type=0) { /* {{{ */
$db = $this->_dms->getDB();
@ -1570,7 +1730,7 @@ class SeedDMS_Core_User { /* {{{ */
/**
* Return list of personal keyword categories
*
* @return array/boolean list of categories or false in case of an error
* @return SeedDMS_Core_KeywordCategory[]|bool list of categories or false in case of an error
*/
function getKeywordCategories() { /* {{{ */
$db = $this->_dms->getDB();
@ -1592,4 +1752,3 @@ class SeedDMS_Core_User { /* {{{ */
} /* }}} */
} /* }}} */
?>

View File

@ -29,33 +29,39 @@ class SeedDMS_Core_Workflow { /* {{{ */
var $_id;
/**
* @var name of the workflow
* @var string name of the workflow
*
* @access protected
*/
var $_name;
/**
* @var initial state of the workflow
* @var SeedDMS_Core_Workflow_State initial state of the workflow
*
* @access protected
*/
var $_initstate;
/**
* @var name of the workflow state
* @var SeedDMS_Core_Workflow_Transition[] name of the workflow state
*
* @access protected
*/
var $_transitions;
/**
* @var object reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
var $_dms;
/**
* SeedDMS_Core_Workflow constructor.
* @param int $id
* @param string $name
* @param SeedDMS_Core_Workflow_State $initstate
*/
function __construct($id, $name, $initstate) { /* {{{ */
$this->_id = $id;
$this->_name = $name;
@ -64,15 +70,28 @@ class SeedDMS_Core_Workflow { /* {{{ */
$this->_dms = null;
} /* }}} */
function setDMS($dms) { /* {{{ */
/**
* @param SeedDMS_Core_DMS $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
function getID() { return $this->_id; }
/**
* @return int
*/
function getID() { return $this->_id; }
function getName() { return $this->_name; }
/**
* @return string
*/
function getName() { return $this->_name; }
function setName($newName) { /* {{{ */
/**
* @param $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflows` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id;
@ -84,9 +103,16 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
function getInitState() { return $this->_initstate; }
/**
* @return SeedDMS_Core_Workflow_State
*/
function getInitState() { return $this->_initstate; }
function setInitState($state) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow_State $state
* @return bool
*/
function setInitState($state) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflows` SET `initstate` = ".$state->getID()." WHERE `id` = " . $this->_id;
@ -98,7 +124,10 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
function getTransitions() { /* {{{ */
/**
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getTransitions() { /* {{{ */
$db = $this->_dms->getDB();
if($this->_transitions)
@ -121,8 +150,12 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $this->_transitions;
} /* }}} */
function getStates() { /* {{{ */
$db = $this->_dms->getDB();
/**
* @return array
*/
function getStates() { /* {{{ */
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
if(!$this->_transitions)
$this->getTransitions();
@ -138,14 +171,15 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $states;
} /* }}} */
/**
* Get the transition by its id
*
* @param integer $id id of transition
* @param object transition
*/
/**
* Get the transition by its id
*
* @param integer $id id of transition
* @return bool|SeedDMS_Core_Workflow_Transition
*/
function getTransition($id) { /* {{{ */
$db = $this->_dms->getDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
if(!$this->_transitions)
$this->getTransitions();
@ -156,12 +190,12 @@ class SeedDMS_Core_Workflow { /* {{{ */
return false;
} /* }}} */
/**
* Get the transitions that can be triggered while being in the given state
*
* @param object $state current workflow state
* @param array list of transitions
*/
/**
* Get the transitions that can be triggered while being in the given state
*
* @param SeedDMS_Core_Workflow_State $state current workflow state
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getNextTransitions($state) { /* {{{ */
$db = $this->_dms->getDB();
@ -180,12 +214,12 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $wkftransitions;
} /* }}} */
/**
* Get the transitions that lead to the given state
*
* @param object $state current workflow state
* @param array list of transitions
*/
/**
* Get the transitions that lead to the given state
*
* @param SeedDMS_Core_Workflow_State $state current workflow state
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getPreviousTransitions($state) { /* {{{ */
$db = $this->_dms->getDB();
@ -204,13 +238,13 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $wkftransitions;
} /* }}} */
/**
* Get all transitions from one state into another state
*
* @param object $state state to start from
* @param object $nextstate state after transition
* @param array list of transitions
*/
/**
* Get all transitions from one state into another state
*
* @param SeedDMS_Core_Workflow_State $state state to start from
* @param SeedDMS_Core_Workflow_State $nextstate state after transition
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getTransitionsByStates($state, $nextstate) { /* {{{ */
$db = $this->_dms->getDB();
@ -233,7 +267,7 @@ class SeedDMS_Core_Workflow { /* {{{ */
* Remove a transition from a workflow
* Deprecated! User SeedDMS_Core_Workflow_Transition::remove() instead.
*
* @param object $transition
* @param SeedDMS_Core_Workflow_Transition $transition
* @return boolean true if no error occured, otherwise false
*/
function removeTransition($transition) { /* {{{ */
@ -243,12 +277,12 @@ class SeedDMS_Core_Workflow { /* {{{ */
/**
* Add new transition to workflow
*
* @param object $state
* @param object $action
* @param object $nextstate
* @param array $users
* @param array $groups
* @return object instance of new transition
* @param SeedDMS_Core_Workflow_State $state
* @param SeedDMS_Core_Workflow_Action $action
* @param SeedDMS_Core_Workflow_State $nextstate
* @param SeedDMS_Core_User[] $users
* @param SeedDMS_Core_Group[] $groups
* @return SeedDMS_Core_Workflow_Transition|bool instance of new transition
*/
function addTransition($state, $action, $nextstate, $users, $groups) { /* {{{ */
$db = $this->_dms->getDB();
@ -301,7 +335,11 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
private function penetrate($laststates) {
/**
* @param SeedDMS_Core_Workflow_State[] $laststates
* @return SeedDMS_Core_Workflow_State[]|bool
*/
private function penetrate($laststates) {
$state = end($laststates);
$transitions = $this->getNextTransitions($state);
foreach($transitions as $transition) {
@ -323,7 +361,8 @@ class SeedDMS_Core_Workflow { /* {{{ */
* @return boolean list of states if workflow contains cycles, otherwise false
*/
function checkForCycles() { /* {{{ */
$db = $this->_dms->getDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
$initstate = $this->getInitState();
@ -389,41 +428,49 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
var $_id;
/**
* @var name of the workflow state
* @var string name of the workflow state
*
* @access protected
*/
var $_name;
/**
* @var maximum of seconds allowed in this state
* @var int maximum of seconds allowed in this state
*
* @access protected
*/
var $_maxtime;
/**
* @var maximum of seconds allowed in this state
* @var int maximum of seconds allowed in this state
*
* @access protected
*/
var $_precondfunc;
/**
* @var matching documentstatus when this state is reached
* @var int matching documentstatus when this state is reached
*
* @access protected
*/
var $_documentstatus;
/**
* @var object reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
var $_dms;
function __construct($id, $name, $maxtime, $precondfunc, $documentstatus) {
/**
* SeedDMS_Core_Workflow_State constructor.
* @param $id
* @param $name
* @param $maxtime
* @param $precondfunc
* @param $documentstatus
*/
function __construct($id, $name, $maxtime, $precondfunc, $documentstatus) {
$this->_id = $id;
$this->_name = $name;
$this->_maxtime = $maxtime;
@ -432,15 +479,28 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
$this->_dms = null;
}
function setDMS($dms) {
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
function getID() { return $this->_id; }
/**
* @return int
*/
function getID() { return $this->_id; }
function getName() { return $this->_name; }
/**
* @return string
*/
function getName() { return $this->_name; }
function setName($newName) { /* {{{ */
/**
* @param string $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id;
@ -452,9 +512,16 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
return true;
} /* }}} */
function getMaxTime() { return $this->_maxtime; }
/**
* @return int maximum
*/
function getMaxTime() { return $this->_maxtime; }
function setMaxTime($maxtime) { /* {{{ */
/**
* @param $maxtime
* @return bool
*/
function setMaxTime($maxtime) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id;
@ -466,9 +533,16 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
return true;
} /* }}} */
function getPreCondFunc() { return $this->_precondfunc; }
/**
* @return int maximum
*/
function getPreCondFunc() { return $this->_precondfunc; }
function setPreCondFunc($precondfunc) { /* {{{ */
/**
* @param $precondfunc
* @return bool
*/
function setPreCondFunc($precondfunc) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `precondfunc` = ".$db->qstr($precondfunc)." WHERE id = " . $this->_id;
@ -476,7 +550,8 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
if (!$res)
return false;
$this->_maxtime = $maxtime;
/** @noinspection PhpUndefinedVariableInspection */
$this->_maxtime = $maxtime; /* @todo fix me */
return true;
} /* }}} */
@ -490,7 +565,11 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
*/
function getDocumentStatus() { return $this->_documentstatus; }
function setDocumentStatus($docstatus) { /* {{{ */
/**
* @param $docstatus
* @return bool
*/
function setDocumentStatus($docstatus) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `documentstatus` = ".intval($docstatus)." WHERE id = " . $this->_id;
@ -520,7 +599,7 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
/**
* Return workflow transitions the status is being used in
*
* @return array/boolean array of workflow transitions or false in case of an error
* @return SeedDMS_Core_Workflow_Transition[]|boolean array of workflow transitions or false in case of an error
*/
function getTransitions() { /* {{{ */
$db = $this->_dms->getDB();
@ -586,34 +665,52 @@ class SeedDMS_Core_Workflow_Action { /* {{{ */
var $_id;
/**
* @var name of the workflow action
* @var string name of the workflow action
*
* @access protected
*/
var $_name;
/**
* @var object reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
var $_dms;
function __construct($id, $name) {
/**
* SeedDMS_Core_Workflow_Action constructor.
* @param $id
* @param $name
*/
function __construct($id, $name) {
$this->_id = $id;
$this->_name = $name;
$this->_dms = null;
}
function setDMS($dms) {
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
function getID() { return $this->_id; }
/**
* @return int
*/
function getID() { return $this->_id; }
function getName() { return $this->_name; }
/**
* @return string name
*/
function getName() { return $this->_name; }
function setName($newName) { /* {{{ */
/**
* @param $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowActions` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id;
@ -643,7 +740,7 @@ class SeedDMS_Core_Workflow_Action { /* {{{ */
/**
* Return workflow transitions the action is being used in
*
* @return array/boolean array of workflow transitions or false in case of an error
* @return SeedDMS_Core_Workflow_Transition[]|boolean array of workflow transitions or false in case of an error
*/
function getTransitions() { /* {{{ */
$db = $this->_dms->getDB();
@ -709,62 +806,71 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
var $_id;
/**
* @var workflow this transition belongs to
* @var SeedDMS_Core_Workflow workflow this transition belongs to
*
* @access protected
*/
var $_workflow;
/**
* @var state of the workflow transition
* @var SeedDMS_Core_Workflow_State of the workflow transition
*
* @access protected
*/
var $_state;
/**
* @var next state of the workflow transition
* @var SeedDMS_Core_Workflow_State next state of the workflow transition
*
* @access protected
*/
var $_nextstate;
/**
* @var action of the workflow transition
* @var SeedDMS_Core_Workflow_Action of the workflow transition
*
* @access protected
*/
var $_action;
/**
* @var maximum of seconds allowed until this transition must be triggered
* @var integer maximum of seconds allowed until this transition must be triggered
*
* @access protected
*/
var $_maxtime;
/**
* @var list of users allowed to trigger this transaction
* @var SeedDMS_Core_User[] of users allowed to trigger this transaction
*
* @access protected
*/
var $_users;
/**
* @var list of groups allowed to trigger this transaction
* @var SeedDMS_Core_Group[] of groups allowed to trigger this transaction
*
* @access protected
*/
var $_groups;
/**
* @var object reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
var $_dms;
function __construct($id, $workflow, $state, $action, $nextstate, $maxtime) {
/**
* SeedDMS_Core_Workflow_Transition constructor.
* @param $id
* @param $workflow
* @param $state
* @param $action
* @param $nextstate
* @param $maxtime
*/
function __construct($id, $workflow, $state, $action, $nextstate, $maxtime) {
$this->_id = $id;
$this->_workflow = $workflow;
$this->_state = $state;
@ -774,15 +880,28 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
$this->_dms = null;
}
function setDMS($dms) {
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
function getID() { return $this->_id; }
/**
* @return int
*/
function getID() { return $this->_id; }
function getWorkflow() { return $this->_workflow; }
/**
* @return SeedDMS_Core_Workflow
*/
function getWorkflow() { return $this->_workflow; }
function setWorkflow($newWorkflow) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow $newWorkflow
* @return bool
*/
function setWorkflow($newWorkflow) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `workflow` = ".$newWorkflow->getID()." WHERE `id` = " . $this->_id;
@ -794,9 +913,17 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getState() { return $this->_state; }
function setState($newState) { /* {{{ */
/**
* @return SeedDMS_Core_Workflow_State
*/
function getState() { return $this->_state; }
/**
* @param SeedDMS_Core_Workflow_State $newState
* @return bool
*/
function setState($newState) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `state` = ".$newState->getID()." WHERE `id` = " . $this->_id;
@ -808,9 +935,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getNextState() { return $this->_nextstate; }
/**
* @return SeedDMS_Core_Workflow_State
*/
function getNextState() { return $this->_nextstate; }
function setNextState($newNextState) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow_State $newNextState
* @return bool
*/
function setNextState($newNextState) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `nextstate` = ".$newNextState->getID()." WHERE `id` = " . $this->_id;
@ -822,9 +956,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getAction() { return $this->_action; }
/**
* @return SeedDMS_Core_Workflow_Action
*/
function getAction() { return $this->_action; }
function setAction($newAction) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow_Action $newAction
* @return bool
*/
function setAction($newAction) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `action` = ".$newAction->getID()." WHERE `id` = " . $this->_id;
@ -836,9 +977,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getMaxTime() { return $this->_maxtime; }
/**
* @return int
*/
function getMaxTime() { return $this->_maxtime; }
function setMaxTime($maxtime) { /* {{{ */
/**
* @param $maxtime
* @return bool
*/
function setMaxTime($maxtime) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id;
@ -853,7 +1001,7 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
/**
* Get all users allowed to trigger this transition
*
* @return array list of users
* @return SeedDMS_Core_User[]|bool list of users
*/
function getUsers() { /* {{{ */
$db = $this->_dms->getDB();
@ -881,7 +1029,7 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
/**
* Get all users allowed to trigger this transition
*
* @return array list of users
* @return SeedDMS_Core_Group[]|bool list of users
*/
function getGroups() { /* {{{ */
$db = $this->_dms->getDB();
@ -969,13 +1117,22 @@ class SeedDMS_Core_Workflow_Transition_User { /* {{{ */
*/
var $_dms;
function __construct($id, $transition, $user) {
/**
* SeedDMS_Core_Workflow_Transition_User constructor.
* @param $id
* @param $transition
* @param $user
*/
function __construct($id, $transition, $user) {
$this->_id = $id;
$this->_transition = $transition;
$this->_user = $user;
}
function setDMS($dms) { /* {{{ */
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
@ -1043,14 +1200,24 @@ class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */
*/
var $_dms;
function __construct($id, $transition, $group, $numOfUsers) { /* {{{ */
/**
* SeedDMS_Core_Workflow_Transition_Group constructor.
* @param $id
* @param $transition
* @param $group
* @param $numOfUsers
*/
function __construct($id, $transition, $group, $numOfUsers) { /* {{{ */
$this->_id = $id;
$this->_transition = $transition;
$this->_group = $group;
$this->_numOfUsers = $numOfUsers;
} /* }}} */
function setDMS($dms) { /* {{{ */
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
@ -1156,7 +1323,18 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */
*/
var $_dms;
function __construct($id, $document, $version, $workflow, $user, $transition, $date, $comment) {
/**
* SeedDMS_Core_Workflow_Log constructor.
* @param $id
* @param $document
* @param $version
* @param $workflow
* @param $user
* @param $transition
* @param $date
* @param $comment
*/
function __construct($id, $document, $version, $workflow, $user, $transition, $date, $comment) {
$this->_id = $id;
$this->_document = $document;
$this->_version = $version;
@ -1168,27 +1346,45 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */
$this->_dms = null;
}
function setDMS($dms) { /* {{{ */
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
function getTransition() { /* {{{ */
/**
* @return object
*/
function getTransition() { /* {{{ */
return $this->_transition;
} /* }}} */
function getWorkflow() { /* {{{ */
/**
* @return object
*/
function getWorkflow() { /* {{{ */
return $this->_workflow;
} /* }}} */
function getUser() { /* {{{ */
/**
* @return object
*/
function getUser() { /* {{{ */
return $this->_user;
} /* }}} */
function getComment() { /* {{{ */
/**
* @return string
*/
function getComment() { /* {{{ */
return $this->_comment;
} /* }}} */
function getDate() { /* {{{ */
/**
* @return string
*/
function getDate() { /* {{{ */
return $this->_date;
} /* }}} */

View File

@ -16,6 +16,7 @@
* Include the adodb database abstraction
*/
require_once "adodb/adodb.inc.php";
/** @noinspection PhpUndefinedClassInspection */
/**
* Class to represent the database access for the document management
@ -54,19 +55,19 @@ class SeedDMS_Core_DatabaseAccess {
*/
function TableList() {
return $this->_conn->MetaTables("TABLES");
}
}
/**
* Constructor of SeedDMS_Core_DatabaseAccess
*
* Sets all database parameters but does not connect.
*
* @param string $driver the database type e.g. mysql, sqlite
* @param string $hostname host of database server
* @param string $user name of user having access to database
* @param string $passw password of user
* @param string $database name of database
*/
/**
* Constructor of SeedDMS_Core_DatabaseAccess
*
* Sets all database parameters but does not connect.
*
* @param string $driver the database type e.g. mysql, sqlite
* @param string $hostname host of database server
* @param string $user name of user having access to database
* @param string $passw password of user
* @param bool|string $database name of database
*/
function __construct($driver, $hostname, $user, $passw, $database = false) {
$this->_driver = $driver;
$this->_hostname = $hostname;
@ -127,7 +128,7 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Sanitize String used in database operations
*
* @param string text
* @param string $text
* @return string sanitized string
*/
function qstr($text) { /* {{{ */
@ -141,10 +142,11 @@ class SeedDMS_Core_DatabaseAccess {
* Call this function only with sql query which return data records.
*
* @param string $queryStr sql query
* @return array/boolean data if query could be executed otherwise false
* @return array|boolean data if query could be executed otherwise false
*/
function getResultArray($queryStr) { /* {{{ */
$resArr = array();
/** @noinspection PhpUnusedLocalVariableInspection */
$resArr = array();
$res = $this->_conn->Execute($queryStr);
if (!$res) {
@ -157,17 +159,17 @@ class SeedDMS_Core_DatabaseAccess {
return $resArr;
} /* }}} */
/**
* Execute SQL query
*
* Call this function only with sql query which do not return data records.
*
* @param string $queryStr sql query
* @param boolean $silent not used anymore. This was used when this method
* still issued an error message
* @return boolean true if query could be executed otherwise false
*/
function getResult($queryStr, $silent=false) { /* {{{ */
/**
* Execute SQL query
*
* Call this function only with sql query which do not return data records.
*
* @param string $queryStr sql query
* @return bool true if query could be executed otherwise false
* @internal param bool $silent not used anymore. This was used when this method
* still issued an error message
*/
function getResult($queryStr) { /* {{{ */
$res = $this->_conn->Execute($queryStr);
if(!$res) {
if($this->_debug)
@ -215,9 +217,12 @@ class SeedDMS_Core_DatabaseAccess {
return $this->_conn->ErrorNo();
} /* }}} */
/**
* Create various temporary tables to speed up and simplify sql queries
*/
/**
* Create various temporary tables to speed up and simplify sql queries
* @param $tableName
* @param bool $override
* @return bool
*/
function createTemporaryTable($tableName, $override=false) { /* {{{ */
if (!strcasecmp($tableName, "ttreviewid")) {
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttreviewid` (PRIMARY KEY (`reviewID`), INDEX (`maxLogID`)) ".
@ -309,6 +314,4 @@ class SeedDMS_Core_DatabaseAccess {
}
return false;
} /* }}} */
}
?>
}

View File

@ -10,6 +10,7 @@
* @copyright Copyright (C) 2012 Uwe Steinmann
* @version Release: @package_version@
*/
/** @noinspection PhpUndefinedClassInspection */
/**
* Class to represent the database access for the document management
@ -107,7 +108,7 @@ class SeedDMS_Core_DatabaseAccess {
*
* This function is used to retrieve a list of database tables for backup
*
* @return array list of table names
* @return string[]|bool list of table names
*/
function TableList() { /* {{{ */
switch($this->_driver) {
@ -130,17 +131,17 @@ class SeedDMS_Core_DatabaseAccess {
return $res;
} /* }}} */
/**
* Constructor of SeedDMS_Core_DatabaseAccess
*
* Sets all database parameters but does not connect.
*
* @param string $driver the database type e.g. mysql, sqlite
* @param string $hostname host of database server
* @param string $user name of user having access to database
* @param string $passw password of user
* @param string $database name of database
*/
/**
* Constructor of SeedDMS_Core_DatabaseAccess
*
* Sets all database parameters but does not connect.
*
* @param string $driver the database type e.g. mysql, sqlite
* @param string $hostname host of database server
* @param string $user name of user having access to database
* @param string $passw password of user
* @param bool|string $database name of database
*/
function __construct($driver, $hostname, $user, $passw, $database = false) { /* {{{ */
$this->_driver = $driver;
$tmp = explode(":", $hostname);
@ -212,7 +213,8 @@ class SeedDMS_Core_DatabaseAccess {
$dsn = $this->_driver.":".$this->_database;
break;
}
$this->_conn = new PDO($dsn, $this->_user, $this->_passw);
/** @noinspection PhpUndefinedVariableInspection */
$this->_conn = new PDO($dsn, $this->_user, $this->_passw);
if (!$this->_conn)
return false;
@ -246,7 +248,7 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Sanitize String used in database operations
*
* @param string text
* @param string $text
* @return string sanitized string
*/
function qstr($text) { /* {{{ */
@ -256,21 +258,22 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Replace back ticks by '"'
*
* @param string text
* @param string $text
* @return string sanitized string
*/
function rbt($text) { /* {{{ */
return str_replace('`', '"', $text);
} /* }}} */
/**
* Execute SQL query and return result
*
* Call this function only with sql query which return data records.
*
* @param string $queryStr sql query
* @return array/boolean data if query could be executed otherwise false
*/
/**
* Execute SQL query and return result
*
* Call this function only with sql query which return data records.
*
* @param string $queryStr sql query
* @param bool $retick
* @return array|bool data if query could be executed otherwise false
*/
function getResultArray($queryStr, $retick=true) { /* {{{ */
$resArr = array();
@ -341,11 +344,13 @@ class SeedDMS_Core_DatabaseAccess {
$this->_intransaction--;
} /* }}} */
/**
* Return the id of the last instert record
*
* @return integer id used in last autoincrement
*/
/**
* Return the id of the last instert record
*
* @param string $tablename
* @param string $fieldname
* @return int id used in last autoincrement
*/
function getInsertID($tablename='', $fieldname='id') { /* {{{ */
if($this->_driver == 'pgsql')
return $this->_conn->lastInsertId('"'.$tablename.'_'.$fieldname.'_seq"');
@ -362,9 +367,12 @@ class SeedDMS_Core_DatabaseAccess {
return $this->_conn->errorCode();
} /* }}} */
/**
* Create various temporary tables to speed up and simplify sql queries
*/
/**
* Create various temporary tables to speed up and simplify sql queries
* @param $tableName
* @param bool $override
* @return bool
*/
function createTemporaryTable($tableName, $override=false) { /* {{{ */
if (!strcasecmp($tableName, "ttreviewid")) {
switch($this->_driver) {
@ -533,13 +541,14 @@ class SeedDMS_Core_DatabaseAccess {
return false;
} /* }}} */
/**
* Return sql statement for extracting the date part from a field
* containing a unix timestamp
*
* @param string $fieldname name of field containing the timestamp
* @return string sql code
*/
/**
* Return sql statement for extracting the date part from a field
* containing a unix timestamp
*
* @param string $fieldname name of field containing the timestamp
* @param string $format
* @return string sql code
*/
function getDateExtract($fieldname, $format='%Y-%m-%d') { /* {{{ */
switch($this->_driver) {
case 'mysql':
@ -603,11 +612,12 @@ class SeedDMS_Core_DatabaseAccess {
return '';
} /* }}} */
/**
* Return sql statement for returning the current timestamp
*
* @return string sql code
*/
/**
* Return sql statement for returning the current timestamp
*
* @param $field
* @return string sql code
*/
function castToText($field) { /* {{{ */
switch($this->_driver) {
case 'pgsql':
@ -617,5 +627,3 @@ class SeedDMS_Core_DatabaseAccess {
return $field;
} /* }}} */
}
?>

View File

@ -25,25 +25,50 @@
* @version Release: @package_version@
*/
class SeedDMS_Core_File {
static function renameFile($old, $new) { /* {{{ */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameFile($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
static function removeFile($file) { /* {{{ */
/**
* @param $file
* @return bool
*/
static function removeFile($file) { /* {{{ */
return @unlink($file);
} /* }}} */
static function copyFile($source, $target) { /* {{{ */
/**
* @param $source
* @param $target
* @return bool
*/
static function copyFile($source, $target) { /* {{{ */
return @copy($source, $target);
} /* }}} */
static function moveFile($source, $target) { /* {{{ */
if (!@copyFile($source, $target))
/**
* @param $source
* @param $target
* @return bool
*/
static function moveFile($source, $target) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!@copyFile($source, $target))
return false;
return @removeFile($source);
/** @noinspection PhpUndefinedFunctionInspection */
return @removeFile($source);
} /* }}} */
static function fileSize($file) { /* {{{ */
/**
* @param $file
* @return bool|int
*/
static function fileSize($file) { /* {{{ */
if(!$a = fopen($file, 'r'))
return false;
fseek($a, 0, SEEK_END);
@ -52,12 +77,22 @@ class SeedDMS_Core_File {
return $filesize;
} /* }}} */
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
/**
* @param $size
* @param array $sizes
* @return string
*/
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
if ($size == 0) return('0 Bytes');
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
/** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
} /* }}} */
static function parse_filesize($str) { /* {{{ */
/**
* @param $str
* @return bool|int
*/
static function parse_filesize($str) { /* {{{ */
preg_replace('/\s\s+/', ' ', $str);
if(strtoupper(substr($str, -1)) == 'B') {
$value = (int) substr($str, 0, -2);
@ -80,18 +115,32 @@ class SeedDMS_Core_File {
return $value;
break;
}
return false;
/** @noinspection PhpUnreachableStatementInspection */
return false;
} /* }}} */
static function checksum($file) { /* {{{ */
/**
* @param $file
* @return string
*/
static function checksum($file) { /* {{{ */
return md5_file($file);
} /* }}} */
static function renameDir($old, $new) { /* {{{ */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameDir($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
static function makeDir($path) { /* {{{ */
/**
* @param $path
* @return bool
*/
static function makeDir($path) { /* {{{ */
if( !is_dir( $path ) ){
$res=@mkdir( $path , 0777, true);
@ -146,7 +195,11 @@ class SeedDMS_Core_File {
*/
} /* }}} */
static function removeDir($path) { /* {{{ */
/**
* @param $path
* @return bool
*/
static function removeDir($path) { /* {{{ */
$handle = @opendir($path);
while ($entry = @readdir($handle) )
{
@ -167,7 +220,12 @@ class SeedDMS_Core_File {
return @rmdir($path);
} /* }}} */
static function copyDir($sourcePath, $targetPath) { /* {{{ */
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function copyDir($sourcePath, $targetPath) { /* {{{ */
if (mkdir($targetPath, 0777)) {
$handle = @opendir($sourcePath);
while ($entry = @readdir($handle) ) {
@ -189,14 +247,26 @@ class SeedDMS_Core_File {
return true;
} /* }}} */
static function moveDir($sourcePath, $targetPath) { /* {{{ */
if (!copyDir($sourcePath, $targetPath))
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function moveDir($sourcePath, $targetPath) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!copyDir($sourcePath, $targetPath))
return false;
return removeDir($sourcePath);
/** @noinspection PhpUndefinedFunctionInspection */
return removeDir($sourcePath);
} /* }}} */
// code by Kioob (php.net manual)
static function gzcompressfile($source,$level=false) { /* {{{ */
/**
* @param $source
* @param bool $level
* @return bool|string
*/
static function gzcompressfile($source, $level=false) { /* {{{ */
$dest=$source.'.gz';
$mode='wb'.$level;
$error=false;
@ -214,5 +284,4 @@ class SeedDMS_Core_File {
if($error) return false;
else return $dest;
} /* }}} */
}
?>
}

View File

@ -24,6 +24,12 @@
*/
class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
/**
* @param $cmd
* @param int $timeout
* @return string
* @throws Exception
*/
static function execWithTimeout($cmd, $timeout=2) { /* {{{ */
$descriptorspec = array(
0 => array("pipe", "r"),
@ -60,10 +66,15 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
}
} /* }}} */
/**
* Constructor. Creates our indexable document and adds all
* necessary fields to it using the passed in document
*/
/**
* Constructor. Creates our indexable document and adds all
* necessary fields to it using the passed in document
* @param SeedDMS_Core_DMS $dms
* @param SeedDMS_Core_Document $document
* @param null $convcmd
* @param bool $nocontent
* @param int $timeout
*/
public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) {
$_convcmd = array(
'application/pdf' => 'pdftotext -enc UTF-8 -nopgbrk %s - |sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'',