- remove global variables

- more documentation
This commit is contained in:
steinm 2010-11-24 15:43:08 +00:00
parent b3a79e21ff
commit 2581f438e4
2 changed files with 753 additions and 789 deletions

View File

@ -21,30 +21,28 @@
| Group-Klasse | | Group-Klasse |
\**********************************************************************/ \**********************************************************************/
class LetoDMS_Group class LetoDMS_Group {
{
var $_id; var $_id;
var $_name; var $_name;
var $_dms; var $_dms;
function LetoDMS_Group($id, $name, $comment) function LetoDMS_Group($id, $name, $comment) { /* {{{ */
{
$this->_id = $id; $this->_id = $id;
$this->_name = $name; $this->_name = $name;
$this->_comment = $comment; $this->_comment = $comment;
} $this->_dms = null;
} /* }}} */
function setDMS($dms) { function setDMS($dms) { /* {{{ */
$this->_dms = $dms; $this->_dms = $dms;
} } /* }}} */
function getID() { return $this->_id; } function getID() { return $this->_id; }
function getName() { return $this->_name; } function getName() { return $this->_name; }
function setName($newName) function setName($newName) { /* {{{ */
{ $db = $this->_dms->getDB();
global $db;
$queryStr = "UPDATE tblGroups SET name = '" . $newName . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblGroups SET name = '" . $newName . "' WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
@ -52,13 +50,12 @@ class LetoDMS_Group
$this->_name = $newName; $this->_name = $newName;
return true; return true;
} } /* }}} */
function getComment() { return $this->_comment; } function getComment() { return $this->_comment; }
function setComment($newComment) function setComment($newComment) { /* {{{ */
{ $db = $this->_dms->getDB();
global $db;
$queryStr = "UPDATE tblGroups SET comment = '" . $newComment . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblGroups SET comment = '" . $newComment . "' WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
@ -66,14 +63,12 @@ class LetoDMS_Group
$this->_comment = $newComment; $this->_comment = $newComment;
return true; return true;
} } /* }}} */
function getUsers() function getUsers() { /* {{{ */
{ $db = $this->_dms->getDB();
global $db;
if (!isset($this->_users)) if (!isset($this->_users)) {
{
$queryStr = "SELECT `tblUsers`.* FROM `tblUsers` ". $queryStr = "SELECT `tblUsers`.* FROM `tblUsers` ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`userID`=`tblUsers`.`id` ". "LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`userID`=`tblUsers`.`id` ".
"WHERE `tblGroupMembers`.`groupID` = '". $this->_id ."'"; "WHERE `tblGroupMembers`.`groupID` = '". $this->_id ."'";
@ -83,18 +78,16 @@ class LetoDMS_Group
$this->_users = array(); $this->_users = array();
foreach ($resArr as $row) foreach ($resArr as $row) {
{
$user = new LetoDMS_User($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["isAdmin"]); $user = new LetoDMS_User($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["isAdmin"]);
array_push($this->_users, $user); array_push($this->_users, $user);
} }
} }
return $this->_users; return $this->_users;
} } /* }}} */
function addUser($user,$asManager=false) function addUser($user,$asManager=false) { /* {{{ */
{ $db = $this->_dms->getDB();
global $db;
$queryStr = "INSERT INTO tblGroupMembers (groupID, userID, manager) VALUES (".$this->_id.", ".$user->getID(). ", " . ($asManager?"1":"0") ." )"; $queryStr = "INSERT INTO tblGroupMembers (groupID, userID, manager) VALUES (".$this->_id.", ".$user->getID(). ", " . ($asManager?"1":"0") ." )";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -103,11 +96,10 @@ class LetoDMS_Group
unset($this->_users); unset($this->_users);
return true; return true;
} } /* }}} */
function removeUser($user) function removeUser($user) { /* {{{ */
{ $db = $this->_dms->getDB();
global $db;
$queryStr = "DELETE FROM tblGroupMembers WHERE groupID = ".$this->_id." AND userID = ".$user->getID(); $queryStr = "DELETE FROM tblGroupMembers WHERE groupID = ".$this->_id." AND userID = ".$user->getID();
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -115,21 +107,19 @@ class LetoDMS_Group
if ($res) return false; if ($res) return false;
unset($this->_users); unset($this->_users);
return true; return true;
} } /* }}} */
// $asManager=false: verify if user is in group // $asManager=false: verify if user is in group
// $asManager=true : verify if user is in group as manager // $asManager=true : verify if user is in group as manager
function isMember($user,$asManager=false) function isMember($user,$asManager=false) { /* {{{ */
{ if (isset($this->_users)&&!$asManager) {
if (isset($this->_users)&&!$asManager)
{
foreach ($this->_users as $usr) foreach ($this->_users as $usr)
if ($usr->getID() == $user->getID()) if ($usr->getID() == $user->getID())
return true; return true;
return false; return false;
} }
global $db; $db = $this->_dms->getDB();
if ($asManager) $queryStr = "SELECT * FROM tblGroupMembers WHERE groupID = " . $this->_id . " AND userID = " . $user->getID() . " AND manager = 1"; if ($asManager) $queryStr = "SELECT * FROM tblGroupMembers WHERE groupID = " . $this->_id . " AND userID = " . $user->getID() . " AND manager = 1";
else $queryStr = "SELECT * FROM tblGroupMembers WHERE groupID = " . $this->_id . " AND userID = " . $user->getID(); else $queryStr = "SELECT * FROM tblGroupMembers WHERE groupID = " . $this->_id . " AND userID = " . $user->getID();
@ -139,11 +129,10 @@ class LetoDMS_Group
if (count($resArr) != 1) return false; if (count($resArr) != 1) return false;
return true; return true;
} } /* }}} */
function toggleManager($user) function toggleManager($user) { /* {{{ */
{ $db = $this->_dms->getDB();
global $db;
if (!$this->isMember($user)) return false; if (!$this->isMember($user)) return false;
@ -152,7 +141,7 @@ class LetoDMS_Group
if (!$db->getResult($queryStr)) return false; if (!$db->getResult($queryStr)) return false;
return true; return true;
} } /* }}} */
/** /**
* Entfernt die Gruppe aus dem System. * Entfernt die Gruppe aus dem System.
@ -160,9 +149,9 @@ class LetoDMS_Group
* muss dafür gesorgt werden, dass die Gruppe nirgendwo mehr auftaucht. D.h. auch die Tabellen tblACLs, * muss dafür gesorgt werden, dass die Gruppe nirgendwo mehr auftaucht. D.h. auch die Tabellen tblACLs,
* tblNotify und tblGroupMembers müssen berücksichtigt werden. * tblNotify und tblGroupMembers müssen berücksichtigt werden.
*/ */
function remove() function remove() { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAl $db, $user; $user = $this->_dms->user;
$queryStr = "DELETE FROM tblGroups WHERE id = " . $this->_id; $queryStr = "DELETE FROM tblGroups WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
@ -201,10 +190,10 @@ class LetoDMS_Group
} }
return true; return true;
} } /* }}} */
function getReviewStatus($documentID=null, $version=null) { function getReviewStatus($documentID=null, $version=null) { /* {{{ */
global $db; $db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttreviewid")) { if (!$db->createTemporaryTable("ttreviewid")) {
return false; return false;
@ -232,10 +221,10 @@ class LetoDMS_Group
$status[] = $res; $status[] = $res;
} }
return $status; return $status;
} } /* }}} */
function getApprovalStatus($documentID=null, $version=null) { function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
global $db; $db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttapproveid")) { if (!$db->createTemporaryTable("ttapproveid")) {
return false; return false;
@ -264,6 +253,6 @@ class LetoDMS_Group
} }
return $status; return $status;
} } /* }}} */
} }
?> ?>

View File

@ -33,9 +33,9 @@ class LetoDMS_User {
var $_comment; var $_comment;
var $_isAdmin; var $_isAdmin;
var $_isHidden; var $_isHidden;
var $_dms;
function LetoDMS_User($id, $login, $pwd, $fullName, $email, $language, $theme, $comment, $isAdmin, $isHidden=0) function LetoDMS_User($id, $login, $pwd, $fullName, $email, $language, $theme, $comment, $isAdmin, $isHidden=0) {
{
$this->_id = $id; $this->_id = $id;
$this->_login = $login; $this->_login = $login;
$this->_pwd = $pwd; $this->_pwd = $pwd;
@ -46,6 +46,7 @@ class LetoDMS_User {
$this->_comment = $comment; $this->_comment = $comment;
$this->_isAdmin = $isAdmin; $this->_isAdmin = $isAdmin;
$this->_isHidden = $isHidden; $this->_isHidden = $isHidden;
$this->_dms = null;
} }
function setDMS($dms) { function setDMS($dms) {
@ -56,9 +57,8 @@ class LetoDMS_User {
function getLogin() { return $this->_login; } function getLogin() { return $this->_login; }
function setLogin($newLogin) function setLogin($newLogin) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "UPDATE tblUsers SET login ='" . $newLogin . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET login ='" . $newLogin . "' WHERE id = " . $this->_id;
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -67,13 +67,12 @@ class LetoDMS_User {
$this->_login = $newLogin; $this->_login = $newLogin;
return true; return true;
} } /* }}} */
function getFullName() { return $this->_fullName; } function getFullName() { return $this->_fullName; }
function setFullName($newFullName) function setFullName($newFullName) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "UPDATE tblUsers SET fullname = '" . $newFullName . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET fullname = '" . $newFullName . "' WHERE id = " . $this->_id;
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -82,13 +81,12 @@ class LetoDMS_User {
$this->_fullName = $newFullName; $this->_fullName = $newFullName;
return true; return true;
} } /* }}} */
function getPwd() { return $this->_pwd; } function getPwd() { return $this->_pwd; }
function setPwd($newPwd) function setPwd($newPwd) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "UPDATE tblUsers SET pwd ='" . $newPwd . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET pwd ='" . $newPwd . "' WHERE id = " . $this->_id;
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -97,13 +95,12 @@ class LetoDMS_User {
$this->_pwd = $newPwd; $this->_pwd = $newPwd;
return true; return true;
} } /* }}} */
function getEmail() { return $this->_email; } function getEmail() { return $this->_email; }
function setEmail($newEmail) function setEmail($newEmail) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "UPDATE tblUsers SET email ='" . $newEmail . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET email ='" . $newEmail . "' WHERE id = " . $this->_id;
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -112,13 +109,12 @@ class LetoDMS_User {
$this->_email = $newEmail; $this->_email = $newEmail;
return true; return true;
} } /* }}} */
function getLanguage() { return $this->_language; } function getLanguage() { return $this->_language; }
function setLanguage($newLanguage) function setLanguage($newLanguage) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "UPDATE tblUsers SET language ='" . $newLanguage . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET language ='" . $newLanguage . "' WHERE id = " . $this->_id;
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -127,13 +123,12 @@ class LetoDMS_User {
$this->_language = $newLanguage; $this->_language = $newLanguage;
return true; return true;
} } /* }}} */
function getTheme() { return $this->_theme; } function getTheme() { return $this->_theme; }
function setTheme($newTheme) function setTheme($newTheme) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "UPDATE tblUsers SET theme ='" . $newTheme . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET theme ='" . $newTheme . "' WHERE id = " . $this->_id;
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -142,13 +137,12 @@ class LetoDMS_User {
$this->_theme = $newTheme; $this->_theme = $newTheme;
return true; return true;
} } /* }}} */
function getComment() { return $this->_comment; } function getComment() { return $this->_comment; }
function setComment($newComment) function setComment($newComment) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "UPDATE tblUsers SET comment ='" . $newComment . "' WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET comment ='" . $newComment . "' WHERE id = " . $this->_id;
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -157,13 +151,12 @@ class LetoDMS_User {
$this->_comment = $newComment; $this->_comment = $newComment;
return true; return true;
} } /* }}} */
function isAdmin() { return $this->_isAdmin; } function isAdmin() { return $this->_isAdmin; }
function setAdmin($isAdmin) function setAdmin($isAdmin) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$isAdmin = ($isAdmin) ? "1" : "0"; $isAdmin = ($isAdmin) ? "1" : "0";
$queryStr = "UPDATE tblUsers SET isAdmin = " . $isAdmin . " WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET isAdmin = " . $isAdmin . " WHERE id = " . $this->_id;
@ -172,13 +165,12 @@ class LetoDMS_User {
$this->_isAdmin = $isAdmin; $this->_isAdmin = $isAdmin;
return true; return true;
} } /* }}} */
function isHidden() { return $this->_isHidden; } function isHidden() { return $this->_isHidden; }
function setHidden($isHidden) function setHidden($isHidden) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$isHidden = ($isHidden) ? "1" : "0"; $isHidden = ($isHidden) ? "1" : "0";
$queryStr = "UPDATE tblUsers SET hidden = " . $isHidden . " WHERE id = " . $this->_id; $queryStr = "UPDATE tblUsers SET hidden = " . $isHidden . " WHERE id = " . $this->_id;
@ -187,7 +179,7 @@ class LetoDMS_User {
$this->_isHidden = $isAdmin; $this->_isHidden = $isAdmin;
return true; return true;
} } /* }}} */
/** /**
* Remove the user and also remove all its keywords, notifies, etc. * Remove the user and also remove all its keywords, notifies, etc.
@ -199,7 +191,8 @@ class LetoDMS_User {
* @return boolean true on success or false in case of an error * @return boolean true on success or false in case of an error
*/ */
function remove( $assignToUser=null ) { /* {{{ */ function remove( $assignToUser=null ) { /* {{{ */
GLOBAL $db, $user; $db = $this->_dms->getDB();
$user = $this->_dms->user;
/* Records like folders and documents that formely have belonged to /* Records like folders and documents that formely have belonged to
* the user will assign to another user. If no such user is set, * the user will assign to another user. If no such user is set,
@ -336,7 +329,7 @@ class LetoDMS_User {
} /* }}} */ } /* }}} */
function getGroups() { /* {{{ */ function getGroups() { /* {{{ */
GLOBAL $db; $db = $this->_dms->getDB();
if (!isset($this->_groups)) if (!isset($this->_groups))
{ {
@ -372,9 +365,8 @@ class LetoDMS_User {
* @return boolean true if user has a picture of itself * @return boolean true if user has a picture of itself
*/ */
function hasImage() { /* {{{ */ function hasImage() { /* {{{ */
if (!isset($this->_hasImage)) if (!isset($this->_hasImage)) {
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "SELECT COUNT(*) AS num FROM tblUserImages WHERE userID = " . $this->_id; $queryStr = "SELECT COUNT(*) AS num FROM tblUserImages WHERE userID = " . $this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
@ -388,20 +380,8 @@ class LetoDMS_User {
return $this->_hasImage; return $this->_hasImage;
} /* }}} */ } /* }}} */
/* FIXME: This function should not be a method of the class but rather function setImage($tmpfile, $mimeType) { /* {{{ */
* implemented in the calling application $db = $this->_dms->getDB();
*/
function getImageURL() { /* {{{ */
GLOBAL $settings;
// if (!$this->hasImage())
// return false;
return $settings->_httpRoot . "out/out.UserImage.php?userid=" . $this->_id;
} /* }}} */
function setImage($tmpfile, $mimeType)
{
GLOBAL $db;
$fp = fopen($tmpfile, "rb"); $fp = fopen($tmpfile, "rb");
if (!$fp) return false; if (!$fp) return false;
@ -417,10 +397,10 @@ class LetoDMS_User {
$this->_hasImage = true; $this->_hasImage = true;
return true; return true;
} } /* }}} */
function getReviewStatus($documentID=null, $version=null) { function getReviewStatus($documentID=null, $version=null) { /* {{{ */
GLOBAL $db; $db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttreviewid")) { if (!$db->createTemporaryTable("ttreviewid")) {
return false; return false;
@ -470,10 +450,10 @@ class LetoDMS_User {
$status["grpstatus"][] = $res; $status["grpstatus"][] = $res;
} }
return $status; return $status;
} } /* }}} */
function getApprovalStatus($documentID=null, $version=null) { function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
GLOBAL $db; $db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttapproveid")) { if (!$db->createTemporaryTable("ttapproveid")) {
return false; return false;
@ -523,31 +503,28 @@ class LetoDMS_User {
$status["grpstatus"][] = $res; $status["grpstatus"][] = $res;
} }
return $status; return $status;
} } /* }}} */
function getMandatoryReviewers() function getMandatoryReviewers() { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "SELECT * FROM tblMandatoryReviewers WHERE userID = " . $this->_id; $queryStr = "SELECT * FROM tblMandatoryReviewers WHERE userID = " . $this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
return $resArr; return $resArr;
} } /* }}} */
function getMandatoryApprovers() function getMandatoryApprovers() { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "SELECT * FROM tblMandatoryApprovers WHERE userID = " . $this->_id; $queryStr = "SELECT * FROM tblMandatoryApprovers WHERE userID = " . $this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
return $resArr; return $resArr;
} } /* }}} */
function setMandatoryReviewer($id, $isgroup=false) function setMandatoryReviewer($id, $isgroup=false) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
if ($isgroup){ if ($isgroup){
@ -570,11 +547,10 @@ class LetoDMS_User {
if (is_bool($resArr) && !$resArr) return false; if (is_bool($resArr) && !$resArr) return false;
} }
} } /* }}} */
function setMandatoryApprover($id, $isgroup=false) function setMandatoryApprover($id, $isgroup=false) { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
if ($isgroup){ if ($isgroup){
@ -596,20 +572,19 @@ class LetoDMS_User {
$resArr = $db->getResult($queryStr); $resArr = $db->getResult($queryStr);
if (is_bool($resArr) && !$resArr) return false; if (is_bool($resArr) && !$resArr) return false;
} }
} } /* }}} */
function delMandatoryReviewers() function delMandatoryReviewers() { /* {{{ */
{ $db = $this->_dms->getDB();
GLOBAL $db;
$queryStr = "DELETE FROM tblMandatoryReviewers WHERE userID = " . $this->_id; $queryStr = "DELETE FROM tblMandatoryReviewers WHERE userID = " . $this->_id;
if (!$db->getResult($queryStr)) return false; if (!$db->getResult($queryStr)) return false;
} } /* }}} */
function delMandatoryApprovers() { /* {{{ */
$db = $this->_dms->getDB();
function delMandatoryApprovers()
{
GLOBAL $db;
$queryStr = "DELETE FROM tblMandatoryApprovers WHERE userID = " . $this->_id; $queryStr = "DELETE FROM tblMandatoryApprovers WHERE userID = " . $this->_id;
if (!$db->getResult($queryStr)) return false; if (!$db->getResult($queryStr)) return false;
} } /* }}} */
} }
?> ?>