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();
@ -160,6 +193,7 @@ class SeedDMS_Core_Group { /* {{{ */
$classname = $this->_dms->getClassname('user');
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();
@ -181,12 +218,18 @@ class SeedDMS_Core_Group { /* {{{ */
$classname = $this->_dms->getClassname('user');
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,8 +372,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getLanguage() { return $this->_language; }
/**
* @param $newLanguage
* @return bool
*/
function setLanguage($newLanguage) { /* {{{ */
$db = $this->_dms->getDB();
@ -311,8 +393,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getTheme() { return $this->_theme; }
/**
* @param string $newTheme
* @return bool
*/
function setTheme($newTheme) { /* {{{ */
$db = $this->_dms->getDB();
@ -325,8 +414,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getComment() { return $this->_comment; }
/**
* @param $newComment
* @return bool
*/
function setComment($newComment) { /* {{{ */
$db = $this->_dms->getDB();
@ -339,8 +435,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getRole() { return $this->_role; }
/**
* @param $newrole
* @return bool
*/
function setRole($newrole) { /* {{{ */
$db = $this->_dms->getDB();
@ -352,9 +455,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @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;
} /* }}} */
/**
* @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,8 +493,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return bool|int
*/
function isHidden() { return $this->_isHidden; }
/**
* @param $isHidden
* @return bool
*/
function setHidden($isHidden) { /* {{{ */
$db = $this->_dms->getDB();
@ -392,8 +514,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return bool|int
*/
function isDisabled() { return $this->_isDisabled; }
/**
* @param $isDisabled
* @return bool
*/
function setDisabled($isDisabled) { /* {{{ */
$db = $this->_dms->getDB();
@ -406,6 +535,9 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return bool|int
*/
function addLoginFailure() { /* {{{ */
$db = $this->_dms->getDB();
@ -417,6 +549,9 @@ class SeedDMS_Core_User { /* {{{ */
return $this->_loginFailures;
} /* }}} */
/**
* @return bool
*/
function clearLoginFailures() { /* {{{ */
$db = $this->_dms->getDB();
@ -447,8 +582,15 @@ class SeedDMS_Core_User { /* {{{ */
return $resArr[0]['sum'];
} /* }}} */
/**
* @return int
*/
function getQuota() { return $this->_quota; }
/**
* @param $quota
* @return bool
*/
function setQuota($quota) { /* {{{ */
$db = $this->_dms->getDB();
@ -461,8 +603,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return null|SeedDMS_Core_Folder
*/
function getHomeFolder() { return $this->_homeFolder; }
/**
* @param $homefolder
* @return bool
*/
function setHomeFolder($homefolder) { /* {{{ */
$db = $this->_dms->getDB();
@ -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,7 +819,8 @@ class SeedDMS_Core_User { /* {{{ */
* anymore.
*/
if(!$assignToUser)
return;
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,6 +1090,11 @@ class SeedDMS_Core_User { /* {{{ */
return $resArr;
} /* }}} */
/**
* @param $tmpfile
* @param $mimeType
* @return bool
*/
function setImage($tmpfile, $mimeType) { /* {{{ */
$db = $this->_dms->getDB();
@ -960,9 +1116,7 @@ class SeedDMS_Core_User { /* {{{ */
/**
* Returns all documents of a given user
*
* @param object $user
* @return array list of documents
* @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,14 +70,27 @@ class SeedDMS_Core_Workflow { /* {{{ */
$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; }
/**
* @param $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
@ -84,8 +103,15 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
/**
* @return SeedDMS_Core_Workflow_State
*/
function getInitState() { return $this->_initstate; }
/**
* @param SeedDMS_Core_Workflow_State $state
* @return bool
*/
function setInitState($state) { /* {{{ */
$db = $this->_dms->getDB();
@ -98,6 +124,9 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
/**
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getTransitions() { /* {{{ */
$db = $this->_dms->getDB();
@ -121,7 +150,11 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $this->_transitions;
} /* }}} */
/**
* @return array
*/
function getStates() { /* {{{ */
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
if(!$this->_transitions)
@ -142,9 +175,10 @@ class SeedDMS_Core_Workflow { /* {{{ */
* Get the transition by its id
*
* @param integer $id id of transition
* @param object transition
* @return bool|SeedDMS_Core_Workflow_Transition
*/
function getTransition($id) { /* {{{ */
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
if(!$this->_transitions)
@ -159,8 +193,8 @@ class SeedDMS_Core_Workflow { /* {{{ */
/**
* Get the transitions that can be triggered while being in the given state
*
* @param object $state current workflow state
* @param array list of transitions
* @param SeedDMS_Core_Workflow_State $state current workflow state
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getNextTransitions($state) { /* {{{ */
$db = $this->_dms->getDB();
@ -183,8 +217,8 @@ class SeedDMS_Core_Workflow { /* {{{ */
/**
* Get the transitions that lead to the given state
*
* @param object $state current workflow state
* @param array list of transitions
* @param SeedDMS_Core_Workflow_State $state current workflow state
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getPreviousTransitions($state) { /* {{{ */
$db = $this->_dms->getDB();
@ -207,9 +241,9 @@ class SeedDMS_Core_Workflow { /* {{{ */
/**
* 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
* @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,6 +335,10 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
/**
* @param SeedDMS_Core_Workflow_State[] $laststates
* @return SeedDMS_Core_Workflow_State[]|bool
*/
private function penetrate($laststates) {
$state = end($laststates);
$transitions = $this->getNextTransitions($state);
@ -323,6 +361,7 @@ class SeedDMS_Core_Workflow { /* {{{ */
* @return boolean list of states if workflow contains cycles, otherwise false
*/
function checkForCycles() { /* {{{ */
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
$initstate = $this->getInitState();
@ -389,40 +428,48 @@ 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;
/**
* 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;
@ -432,14 +479,27 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
$this->_dms = null;
}
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
/**
* @return int
*/
function getID() { return $this->_id; }
/**
* @return string
*/
function getName() { return $this->_name; }
/**
* @param string $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
@ -452,8 +512,15 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
return true;
} /* }}} */
/**
* @return int maximum
*/
function getMaxTime() { return $this->_maxtime; }
/**
* @param $maxtime
* @return bool
*/
function setMaxTime($maxtime) { /* {{{ */
$db = $this->_dms->getDB();
@ -466,8 +533,15 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
return true;
} /* }}} */
/**
* @return int maximum
*/
function getPreCondFunc() { return $this->_precondfunc; }
/**
* @param $precondfunc
* @return bool
*/
function setPreCondFunc($precondfunc) { /* {{{ */
$db = $this->_dms->getDB();
@ -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,6 +565,10 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
*/
function getDocumentStatus() { return $this->_documentstatus; }
/**
* @param $docstatus
* @return bool
*/
function setDocumentStatus($docstatus) { /* {{{ */
$db = $this->_dms->getDB();
@ -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,33 +665,51 @@ 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;
/**
* SeedDMS_Core_Workflow_Action constructor.
* @param $id
* @param $name
*/
function __construct($id, $name) {
$this->_id = $id;
$this->_name = $name;
$this->_dms = null;
}
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
/**
* @return int
*/
function getID() { return $this->_id; }
/**
* @return string name
*/
function getName() { return $this->_name; }
/**
* @param $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
@ -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,61 +806,70 @@ 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;
/**
* 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;
@ -774,14 +880,27 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
$this->_dms = null;
}
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
/**
* @return int
*/
function getID() { return $this->_id; }
/**
* @return SeedDMS_Core_Workflow
*/
function getWorkflow() { return $this->_workflow; }
/**
* @param SeedDMS_Core_Workflow $newWorkflow
* @return bool
*/
function setWorkflow($newWorkflow) { /* {{{ */
$db = $this->_dms->getDB();
@ -794,8 +913,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
/**
* @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();
@ -808,8 +935,15 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
/**
* @return SeedDMS_Core_Workflow_State
*/
function getNextState() { return $this->_nextstate; }
/**
* @param SeedDMS_Core_Workflow_State $newNextState
* @return bool
*/
function setNextState($newNextState) { /* {{{ */
$db = $this->_dms->getDB();
@ -822,8 +956,15 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
/**
* @return SeedDMS_Core_Workflow_Action
*/
function getAction() { return $this->_action; }
/**
* @param SeedDMS_Core_Workflow_Action $newAction
* @return bool
*/
function setAction($newAction) { /* {{{ */
$db = $this->_dms->getDB();
@ -836,8 +977,15 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
/**
* @return int
*/
function getMaxTime() { return $this->_maxtime; }
/**
* @param $maxtime
* @return bool
*/
function setMaxTime($maxtime) { /* {{{ */
$db = $this->_dms->getDB();
@ -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,12 +1117,21 @@ class SeedDMS_Core_Workflow_Transition_User { /* {{{ */
*/
var $_dms;
/**
* 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;
}
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
@ -1043,6 +1200,13 @@ class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */
*/
var $_dms;
/**
* 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;
@ -1050,6 +1214,9 @@ class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */
$this->_numOfUsers = $numOfUsers;
} /* }}} */
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
@ -1156,6 +1323,17 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */
*/
var $_dms;
/**
* 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;
@ -1168,26 +1346,44 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */
$this->_dms = null;
}
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
/**
* @return object
*/
function getTransition() { /* {{{ */
return $this->_transition;
} /* }}} */
/**
* @return object
*/
function getWorkflow() { /* {{{ */
return $this->_workflow;
} /* }}} */
/**
* @return object
*/
function getUser() { /* {{{ */
return $this->_user;
} /* }}} */
/**
* @return string
*/
function getComment() { /* {{{ */
return $this->_comment;
} /* }}} */
/**
* @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
@ -65,7 +66,7 @@ class SeedDMS_Core_DatabaseAccess {
* @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
* @param bool|string $database name of database
*/
function __construct($driver, $hostname, $user, $passw, $database = false) {
$this->_driver = $driver;
@ -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,9 +142,10 @@ 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) { /* {{{ */
/** @noinspection PhpUnusedLocalVariableInspection */
$resArr = array();
$res = $this->_conn->Execute($queryStr);
@ -163,11 +165,11 @@ class SeedDMS_Core_DatabaseAccess {
* 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
* @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
* @return boolean true if query could be executed otherwise false
*/
function getResult($queryStr, $silent=false) { /* {{{ */
function getResult($queryStr) { /* {{{ */
$res = $this->_conn->Execute($queryStr);
if(!$res) {
if($this->_debug)
@ -217,6 +219,9 @@ class SeedDMS_Core_DatabaseAccess {
/**
* 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")) {
@ -310,5 +315,3 @@ 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) {
@ -139,7 +140,7 @@ class SeedDMS_Core_DatabaseAccess {
* @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
* @param bool|string $database name of database
*/
function __construct($driver, $hostname, $user, $passw, $database = false) { /* {{{ */
$this->_driver = $driver;
@ -212,6 +213,7 @@ class SeedDMS_Core_DatabaseAccess {
$dsn = $this->_driver.":".$this->_database;
break;
}
/** @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,7 +258,7 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Replace back ticks by '"'
*
* @param string text
* @param string $text
* @return string sanitized string
*/
function rbt($text) { /* {{{ */
@ -269,7 +271,8 @@ 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
* @param bool $retick
* @return array|bool data if query could be executed otherwise false
*/
function getResultArray($queryStr, $retick=true) { /* {{{ */
$resArr = array();
@ -344,7 +347,9 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Return the id of the last instert record
*
* @return integer id used in last autoincrement
* @param string $tablename
* @param string $fieldname
* @return int id used in last autoincrement
*/
function getInsertID($tablename='', $fieldname='id') { /* {{{ */
if($this->_driver == 'pgsql')
@ -364,6 +369,9 @@ class SeedDMS_Core_DatabaseAccess {
/**
* 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")) {
@ -538,6 +546,7 @@ class SeedDMS_Core_DatabaseAccess {
* 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') { /* {{{ */
@ -606,6 +615,7 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Return sql statement for returning the current timestamp
*
* @param $field
* @return string sql code
*/
function castToText($field) { /* {{{ */
@ -617,5 +627,3 @@ class SeedDMS_Core_DatabaseAccess {
return $field;
} /* }}} */
}
?>

View File

@ -25,24 +25,49 @@
* @version Release: @package_version@
*/
class SeedDMS_Core_File {
/**
* @param $old
* @param $new
* @return bool
*/
static function renameFile($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
/**
* @param $file
* @return bool
*/
static function removeFile($file) { /* {{{ */
return @unlink($file);
} /* }}} */
/**
* @param $source
* @param $target
* @return bool
*/
static function copyFile($source, $target) { /* {{{ */
return @copy($source, $target);
} /* }}} */
/**
* @param $source
* @param $target
* @return bool
*/
static function moveFile($source, $target) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!@copyFile($source, $target))
return false;
/** @noinspection PhpUndefinedFunctionInspection */
return @removeFile($source);
} /* }}} */
/**
* @param $file
* @return bool|int
*/
static function fileSize($file) { /* {{{ */
if(!$a = fopen($file, 'r'))
return false;
@ -52,11 +77,21 @@ class SeedDMS_Core_File {
return $filesize;
} /* }}} */
/**
* @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');
/** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
} /* }}} */
/**
* @param $str
* @return bool|int
*/
static function parse_filesize($str) { /* {{{ */
preg_replace('/\s\s+/', ' ', $str);
if(strtoupper(substr($str, -1)) == 'B') {
@ -80,17 +115,31 @@ class SeedDMS_Core_File {
return $value;
break;
}
/** @noinspection PhpUnreachableStatementInspection */
return false;
} /* }}} */
/**
* @param $file
* @return string
*/
static function checksum($file) { /* {{{ */
return md5_file($file);
} /* }}} */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameDir($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
/**
* @param $path
* @return bool
*/
static function makeDir($path) { /* {{{ */
if( !is_dir( $path ) ){
@ -146,6 +195,10 @@ class SeedDMS_Core_File {
*/
} /* }}} */
/**
* @param $path
* @return bool
*/
static function removeDir($path) { /* {{{ */
$handle = @opendir($path);
while ($entry = @readdir($handle) )
@ -167,6 +220,11 @@ class SeedDMS_Core_File {
return @rmdir($path);
} /* }}} */
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function copyDir($sourcePath, $targetPath) { /* {{{ */
if (mkdir($targetPath, 0777)) {
$handle = @opendir($sourcePath);
@ -189,13 +247,25 @@ class SeedDMS_Core_File {
return true;
} /* }}} */
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function moveDir($sourcePath, $targetPath) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!copyDir($sourcePath, $targetPath))
return false;
/** @noinspection PhpUndefinedFunctionInspection */
return removeDir($sourcePath);
} /* }}} */
// code by Kioob (php.net manual)
/**
* @param $source
* @param bool $level
* @return bool|string
*/
static function gzcompressfile($source, $level=false) { /* {{{ */
$dest=$source.'.gz';
$mode='wb'.$level;
@ -215,4 +285,3 @@ class SeedDMS_Core_File {
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"),
@ -63,6 +69,11 @@ 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
* @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(