mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
- moved functions to create users and groups completely in LetoDMS_DMS
This commit is contained in:
parent
4678218f1a
commit
0a116adc88
|
@ -82,10 +82,31 @@ class LetoDMS_DMS {
|
|||
*/
|
||||
public $adminID;
|
||||
|
||||
/**
|
||||
* @var integer $rootFolderID ID of root folder
|
||||
* @access public
|
||||
*/
|
||||
public $rootFolderID;
|
||||
|
||||
function __construct($db, $contentDir, $contentOffsetDir) { /* {{{ */
|
||||
$this->db = $db;
|
||||
$this->contentDir = $contentDir;
|
||||
$this->contentOffsetDir = $contentOffsetDir;
|
||||
$this->rootFolderID = 1;
|
||||
$this->adminID = 1;
|
||||
$this->guestID = 2;
|
||||
} /* }}} */
|
||||
|
||||
function setRootFolderID($id) { /* {{{ */
|
||||
$this->rootFolderID = $id;
|
||||
} /* }}} */
|
||||
|
||||
function setAdminID($id) { /* {{{ */
|
||||
$this->adminID = $id;
|
||||
} /* }}} */
|
||||
|
||||
function setGuestID($id) { /* {{{ */
|
||||
$this->guestID = $id;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
@ -368,7 +389,9 @@ class LetoDMS_DMS {
|
|||
|
||||
$resArr = $resArr[0];
|
||||
|
||||
return new LetoDMS_User($resArr["id"], $resArr["login"], $resArr["pwd"], $resArr["fullName"], $resArr["email"], $resArr["language"], $resArr["theme"], $resArr["comment"], $resArr["isAdmin"], $resArr["hidden"]);
|
||||
$user = new LetoDMS_User($resArr["id"], $resArr["login"], $resArr["pwd"], $resArr["fullName"], $resArr["email"], $resArr["language"], $resArr["theme"], $resArr["comment"], $resArr["isAdmin"], $resArr["hidden"]);
|
||||
$user->setDMS($this);
|
||||
return $user;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
@ -388,7 +411,9 @@ class LetoDMS_DMS {
|
|||
|
||||
$resArr = $resArr[0];
|
||||
|
||||
return new LetoDMS_User($resArr["id"], $resArr["login"], $resArr["pwd"], $resArr["fullName"], $resArr["email"], $resArr["language"], $resArr["theme"], $resArr["comment"], $resArr["isAdmin"], $resArr["hidden"]);
|
||||
$user = new LetoDMS_User($resArr["id"], $resArr["login"], $resArr["pwd"], $resArr["fullName"], $resArr["email"], $resArr["language"], $resArr["theme"], $resArr["comment"], $resArr["isAdmin"], $resArr["hidden"]);
|
||||
$user->setDMS($this);
|
||||
return $user;
|
||||
} /* }}} */
|
||||
|
||||
function getAllUsers() { /* {{{ */
|
||||
|
@ -400,8 +425,11 @@ class LetoDMS_DMS {
|
|||
|
||||
$users = array();
|
||||
|
||||
for ($i = 0; $i < count($resArr); $i++)
|
||||
$users[$i] = new LetoDMS_User($resArr[$i]["id"], $resArr[$i]["login"], $resArr[$i]["pwd"], $resArr[$i]["fullName"], $resArr[$i]["email"], (isset($resArr["language"])?$resArr["language"]:NULL), (isset($resArr["theme"])?$resArr["theme"]:NULL), $resArr[$i]["comment"], $resArr[$i]["isAdmin"], $resArr[$i]["hidden"]);
|
||||
for ($i = 0; $i < count($resArr); $i++) {
|
||||
$user = new LetoDMS_User($resArr[$i]["id"], $resArr[$i]["login"], $resArr[$i]["pwd"], $resArr[$i]["fullName"], $resArr[$i]["email"], (isset($resArr["language"])?$resArr["language"]:NULL), (isset($resArr["theme"])?$resArr["theme"]:NULL), $resArr[$i]["comment"], $resArr[$i]["isAdmin"], $resArr[$i]["hidden"]);
|
||||
$user->setDMS($this);
|
||||
$users[$i] = $user;
|
||||
}
|
||||
|
||||
return $users;
|
||||
} /* }}} */
|
||||
|
@ -432,7 +460,9 @@ class LetoDMS_DMS {
|
|||
|
||||
$resArr = $resArr[0];
|
||||
|
||||
return new LetoDMS_Group($resArr["id"], $resArr["name"], $resArr["comment"]);
|
||||
$group = new LetoDMS_Group($resArr["id"], $resArr["name"], $resArr["comment"]);
|
||||
$group->setDMS($this);
|
||||
return $group;
|
||||
} /* }}} */
|
||||
|
||||
function getGroupByName($name) { /* {{{ */
|
||||
|
@ -446,7 +476,28 @@ class LetoDMS_DMS {
|
|||
|
||||
$resArr = $resArr[0];
|
||||
|
||||
return new LetoDMS_Group($resArr["id"], $resArr["name"], $resArr["comment"]);
|
||||
$group = new LetoDMS_Group($resArr["id"], $resArr["name"], $resArr["comment"]);
|
||||
$group->setDMS($this);
|
||||
return $group;
|
||||
} /* }}} */
|
||||
|
||||
function getAllGroups() { /* {{{ */
|
||||
$queryStr = "SELECT * FROM tblGroups ORDER BY name";
|
||||
$resArr = $this->db->getResultArray($queryStr);
|
||||
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
$groups = array();
|
||||
|
||||
for ($i = 0; $i < count($resArr); $i++) {
|
||||
|
||||
$group = new LetoDMS_Group($resArr[$i]["id"], $resArr[$i]["name"], $resArr[$i]["comment"]);
|
||||
$group->setDMS($this);
|
||||
$groups[$i] = $group;
|
||||
}
|
||||
|
||||
return $groups;
|
||||
} /* }}} */
|
||||
|
||||
function addGroup($name, $comment) { /* {{{ */
|
||||
|
|
|
@ -18,19 +18,6 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
function getFolder($id) {
|
||||
return LetoDMS_Folder::getFolder($id);
|
||||
}
|
||||
|
||||
function getFolderPathHTML($folder, $tagAll=false) {
|
||||
return $folder->getFolderPathHTML($tagAll);
|
||||
}
|
||||
|
||||
function getFolderPathPlain($folder) {
|
||||
return $folder->getFolderPathPlain();
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************\
|
||||
| Folder-Klasse |
|
||||
\**********************************************************************/
|
||||
|
@ -49,35 +36,17 @@ class LetoDMS_Folder
|
|||
var $_dms;
|
||||
|
||||
function LetoDMS_Folder($id, $name, $parentID, $comment, $ownerID, $inheritAccess, $defaultAccess, $sequence)
|
||||
{
|
||||
$this->_id = $id;
|
||||
$this->_name = $name;
|
||||
$this->_parentID = $parentID;
|
||||
$this->_comment = $comment;
|
||||
$this->_ownerID = $ownerID;
|
||||
$this->_inheritAccess = $inheritAccess;
|
||||
$this->_defaultAccess = $defaultAccess;
|
||||
$this->_sequence = $sequence;
|
||||
$this->_notifier = null;
|
||||
$this->_dms = null;
|
||||
}
|
||||
|
||||
function getFolder($id)
|
||||
{
|
||||
GLOBAL $db;
|
||||
|
||||
if (!is_numeric($id)) return false;
|
||||
|
||||
$queryStr = "SELECT * FROM tblFolders WHERE id = " . $id;
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
else if (count($resArr) != 1)
|
||||
return false;
|
||||
|
||||
$resArr = $resArr[0];
|
||||
return new LetoDMS_Folder($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["owner"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["sequence"]);
|
||||
$this->_id = $id;
|
||||
$this->_name = $name;
|
||||
$this->_parentID = $parentID;
|
||||
$this->_comment = $comment;
|
||||
$this->_ownerID = $ownerID;
|
||||
$this->_inheritAccess = $inheritAccess;
|
||||
$this->_defaultAccess = $defaultAccess;
|
||||
$this->_sequence = $sequence;
|
||||
$this->_notifier = null;
|
||||
$this->_dms = null;
|
||||
}
|
||||
|
||||
function setDMS($dms) {
|
||||
|
@ -163,7 +132,7 @@ class LetoDMS_Folder
|
|||
}
|
||||
|
||||
if (!isset($this->_parent)) {
|
||||
$this->_parent = getFolder($this->_parentID);
|
||||
$this->_parent = $this->_dms->getFolder($this->_parentID);
|
||||
}
|
||||
return $this->_parent;
|
||||
}
|
||||
|
@ -416,7 +385,7 @@ class LetoDMS_Folder
|
|||
"VALUES ('".$name."', ".$this->_id.", '".$comment."', ".$owner->getID().", 1, ".M_READ.", ".$sequence.")";
|
||||
if (!$db->getResult($queryStr))
|
||||
return false;
|
||||
$newFolder = getFolder($db->getInsertID());
|
||||
$newFolder = $this->_dms->getFolder($db->getInsertID());
|
||||
unset($this->_subFolders);
|
||||
|
||||
// Send notification to subscribers.
|
||||
|
@ -573,7 +542,7 @@ class LetoDMS_Folder
|
|||
$message = getMLText("new_document_email")."\r\n";
|
||||
$message .=
|
||||
getMLText("name").": ".$name."\r\n".
|
||||
getMLText("folder").": ".getFolderPathPlain($this)."\r\n".
|
||||
getMLText("folder").": ".$this->getFolderPathPlain()."\r\n".
|
||||
getMLText("comment").": ".$comment."\r\n".
|
||||
getMLText("comment_for_current_version").": ".$version_comment."\r\n".
|
||||
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
|
||||
|
@ -633,7 +602,7 @@ class LetoDMS_Folder
|
|||
$message = getMLText("folder_deleted_email")."\r\n";
|
||||
$message .=
|
||||
getMLText("name").": ".$this->_name."\r\n".
|
||||
getMLText("folder").": ".getFolderPathPlain($this)."\r\n".
|
||||
getMLText("folder").": ".$this->getFolderPathPlain()."\r\n".
|
||||
getMLText("comment").": ".$this->_comment."\r\n".
|
||||
"URL: ###URL_PREFIX###out/out.ViewFolder.php?folderid=".$this->_id."\r\n";
|
||||
|
||||
|
|
|
@ -17,20 +17,6 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
/**********************************************************************\
|
||||
| statische, Group-bezogene Funktionen |
|
||||
\**********************************************************************/
|
||||
|
||||
|
||||
function getAllGroups() {
|
||||
return LetoDMS_Group::getAllGroups();
|
||||
}
|
||||
|
||||
function addGroup($name, $comment) {
|
||||
return LetoDMS_Group::addGroup($name, $comment);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************\
|
||||
| Group-Klasse |
|
||||
\**********************************************************************/
|
||||
|
@ -39,6 +25,7 @@ class LetoDMS_Group
|
|||
{
|
||||
var $_id;
|
||||
var $_name;
|
||||
var $_dms;
|
||||
|
||||
function LetoDMS_Group($id, $name, $comment)
|
||||
{
|
||||
|
@ -46,25 +33,10 @@ class LetoDMS_Group
|
|||
$this->_name = $name;
|
||||
$this->_comment = $comment;
|
||||
}
|
||||
|
||||
function getAllGroups()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$queryStr = "SELECT * FROM tblGroups ORDER BY name";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
$groups = array();
|
||||
|
||||
for ($i = 0; $i < count($resArr); $i++)
|
||||
$groups[$i] = new LetoDMS_Group($resArr[$i]["id"], $resArr[$i]["name"], $resArr[$i]["comment"]);
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
function setDMS($dms) {
|
||||
$this->_dms = $dms;
|
||||
}
|
||||
|
||||
function getID() { return $this->_id; }
|
||||
|
||||
|
|
|
@ -48,6 +48,10 @@ class LetoDMS_User {
|
|||
$this->_isHidden = $isHidden;
|
||||
}
|
||||
|
||||
function setDMS($dms) {
|
||||
$this->_dms = $dms;
|
||||
}
|
||||
|
||||
function getID() { return $this->_id; }
|
||||
|
||||
function getLogin() { return $this->_login; }
|
||||
|
|
|
@ -22,4 +22,7 @@ $db = new LetoDMS_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $
|
|||
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
|
||||
|
||||
$dms = new LetoDMS_DMS($db, $settings->_contentDir, $settings->_contentOffsetDir);
|
||||
$dms->setRootFolderID($settings->_rootFolderID);
|
||||
$dms->setAdminID($settings->_adminID);
|
||||
$dms->setGuestID($settings->_guestID);
|
||||
?>
|
||||
|
|
|
@ -48,7 +48,7 @@ if ($action == "addgroup") {
|
|||
UI::exitError(getMLText("admin_tools"),getMLText("group_exists"));
|
||||
}
|
||||
|
||||
$newGroup = addGroup($name, $comment);
|
||||
$newGroup = $dms->addGroup($name, $comment);
|
||||
if (!$newGroup) {
|
||||
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ if (!$user->isAdmin()) {
|
|||
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
$allUsers = getAllUsers();
|
||||
$allUsers = $dms->getAllUsers();
|
||||
|
||||
if (is_bool($allUsers)) {
|
||||
UI::exitError(getMLText("admin_tools"),getMLText("internal_error"));
|
||||
}
|
||||
|
||||
$groups = getAllGroups();
|
||||
$groups = $dms->getAllGroups();
|
||||
|
||||
if (is_bool($groups)) {
|
||||
UI::exitError(getMLText("admin_tools"),getMLText("internal_error"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user