- inc.ClassKeywords.php is now included by inc.ClassDMS.php

- moved all static functions to get and add keywords in LetoDMS_DMS
This commit is contained in:
steinm 2010-11-27 20:52:03 +00:00
parent f81a7063df
commit d3744c0264
8 changed files with 98 additions and 26 deletions

View File

@ -18,11 +18,12 @@
require_once("inc.AccessUtils.php");
require_once("inc.FileUtils.php");
require_once("inc.ClassAccess.php");
require_once("inc.ClassAccess.php");
require_once("inc.ClassFolder.php");
require_once("inc.ClassDocument.php");
require_once("inc.ClassGroup.php");
require_once("inc.ClassUser.php");
require_once("inc.ClassGroup.php");
require_once("inc.ClassUser.php");
require_once("inc.ClassKeywords.php");
/**
* Class to represent the complete document management
@ -606,5 +607,81 @@ class LetoDMS_DMS {
return $this->getGroup($this->db->getInsertID());
} /* }}} */
function getKeywordCategory($id) { /* {{{ */
if (!is_numeric($id))
die ("invalid id");
$queryStr = "SELECT * FROM tblKeywordCategories WHERE id = " . $id;
$resArr = $this->db->getResultArray($queryStr);
if ((is_bool($resArr) && !$resArr) || (count($resArr) != 1))
return false;
$resArr = $resArr[0];
$cat = new LetoDMS_Keywordcategory($resArr["id"], $resArr["owner"], $resArr["name"]);
$cat->setDMS($this);
return $cat;
} /* }}} */
function getKeywordCategoryByName($name, $owner) { /* {{{ */
$queryStr = "SELECT * FROM tblKeywordCategories WHERE name = '" . $name . "' AND owner = '" . $owner. "'";
$resArr = $this->db->getResultArray($queryStr);
if ((is_bool($resArr) && !$resArr) || (count($resArr) != 1))
return false;
$resArr = $resArr[0];
$cat = new LetoDMS_Keywordcategory($resArr["id"], $resArr["owner"], $resArr["name"]);
$cat->setDMS($this);
return $cat;
} /* }}} */
function getAllKeywordCategories($userIDs = array()) { /* {{{ */
$queryStr = "SELECT * FROM tblKeywordCategories";
if ($userIDs)
$queryStr .= " WHERE owner in (".implode(',', $userIDs).")";
$resArr = $this->db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
$categories = array();
foreach ($resArr as $row) {
$cat = new LetoDMS_KeywordCategory($row["id"], $row["owner"], $row["name"]);
$cat->setDMS($this);
array_push($categories, $cat);
}
return $categories;
} /* }}} */
function getAllUserKeywordCategories($userID) { /* {{{ */
$queryStr = "SELECT * FROM tblKeywordCategories";
if ($userID != -1)
$queryStr .= " WHERE owner = " . $userID;
$resArr = $this->db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
$categories = array();
foreach ($resArr as $row) {
$cat = new LetoDMS_KeywordCategory($row["id"], $row["owner"], $row["name"]);
$cat->setDMS($this);
array_push($categories, $cat);
}
return $categories;
} /* }}} */
function addKeywordCategory($owner, $name) { /* {{{ */
if (is_object($this->getKeywordCategoryByName($name, $owner))) {
return false;
}
$queryStr = "INSERT INTO tblKeywordCategories (owner, name) VALUES ($owner, '$name')";
if (!$this->db->getResult($queryStr))
return false;
return $this->getKeywordCategory($this->db->getInsertID());
} /* }}} */
}
?>

View File

@ -61,7 +61,7 @@ foreach ($tables as $table){
fclose($h);
if (gzcompressfile($dump_name,9)) unlink($dump_name);
if (LetoDMS_File::gzcompressfile($dump_name,9)) unlink($dump_name);
else UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
add_log_line();

View File

@ -190,7 +190,7 @@ if (!createFolderTar($folder,$ark)) {
TarAddFooter($ark);
fclose($ark);
if (gzcompressfile($ark_name,9)) unlink($ark_name);
if (LetoDMS_File::gzcompressfile($ark_name,9)) unlink($ark_name);
else UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
add_log_line();

View File

@ -19,7 +19,6 @@
include("../inc/inc.Settings.php");
include("../inc/inc.ClassDMS.php");
include("../inc/inc.ClassKeywords.php");
include("../inc/inc.DBAccess.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
@ -37,10 +36,10 @@ $action = $_GET["action"];
if ($action == "addcategory") {
$name = sanitizeString($_GET["name"]);
if (is_object(getKeywordCategoryByName($name, $settings->_adminID))) {
if (is_object($dms->getKeywordCategoryByName($name, $settings->_adminID))) {
UI::exitError(getMLText("admin_tools"),getMLText("keyword_exists"));
}
$newCategory = addKeywordCategory($settings->_adminID, $name);
$newCategory = $dms->addKeywordCategory($settings->_adminID, $name);
if (!$newCategory) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
@ -54,7 +53,7 @@ else if ($action == "removecategory") {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
}
$categoryid = $_GET["categoryid"];
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (!is_object($category)) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
}
@ -76,7 +75,7 @@ else if ($action == "editcategory") {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
}
$categoryid = $_GET["categoryid"];
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (!is_object($category)) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
}
@ -96,7 +95,7 @@ else if ($action == "editcategory") {
else if ($action == "newkeywords") {
$categoryid = sanitizeString($_GET["categoryid"]);
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
$owner = $category->getOwner();
if ($owner->getID() != $settings->_adminID) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
@ -116,7 +115,7 @@ else if ($action == "editkeywords")
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
}
$categoryid = $_GET["categoryid"];
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (!is_object($category)) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
@ -145,7 +144,7 @@ else if ($action == "removekeywords") {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
}
$categoryid = $_GET["categoryid"];
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (!is_object($category)) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_keyword_category"));
}

View File

@ -19,7 +19,6 @@
include("../inc/inc.Settings.php");
include("../inc/inc.ClassDMS.php");
include("../inc/inc.ClassKeywords.php");
include("../inc/inc.DBAccess.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
@ -47,7 +46,7 @@ if ($action == "addcategory") {
$name = sanitizeString($_GET["name"]);
}
$newCategory = addKeywordCategory($user->getID(), $name);
$newCategory = $dms->addKeywordCategory($user->getID(), $name);
if (!$newCategory) {
UI::exitError(getMLText("personal_default_keywords"),getMLText("error_occured"));
}
@ -64,7 +63,7 @@ else if ($action == "removecategory") {
else {
$categoryid = sanitizeString($_GET["categoryid"]);
}
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (is_object($category)) {
$owner = $category->getOwner();
if ($owner->getID() != $user->getID()) {
@ -87,7 +86,7 @@ else if ($action == "editcategory") {
else {
$categoryid = sanitizeString($_GET["categoryid"]);
}
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (is_object($category)) {
$owner = $category->getOwner();
if ($owner->getID() != $user->getID()) {
@ -116,7 +115,7 @@ else if ($action == "newkeywords") {
else {
$categoryid = sanitizeString($_GET["categoryid"]);
}
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (is_object($category)) {
$owner = $category->getOwner();
if ($owner->getID() != $user->getID()) {
@ -145,7 +144,7 @@ else if ($action == "editkeywords") {
else {
$categoryid = sanitizeString($_GET["categoryid"]);
}
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (is_object($category)) {
$owner = $category->getOwner();
if ($owner->getID() != $user->getID()) {
@ -178,7 +177,7 @@ else if ($action == "removekeywords") {
else {
$categoryid = sanitizeString($_GET["categoryid"]);
}
$category = getKeywordCategory($categoryid);
$category = $dms->getKeywordCategory($categoryid);
if (is_object($category)) {
$owner = $category->getOwner();
if ($owner->getID() != $user->getID()) {

View File

@ -20,7 +20,6 @@
include("../inc/inc.Settings.php");
include("../inc/inc.ClassDMS.php");
include("../inc/inc.ClassKeywords.php");
include("../inc/inc.DBAccess.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
@ -35,7 +34,7 @@ UI::htmlStartPage(getMLText("admin_tools"));
UI::globalNavigation();
UI::pageNavigation(getMLText("admin_tools"), "admin_tools");
$categories = getAllUserKeywordCategories($settings->_adminID);
$categories = $dms->getAllUserKeywordCategories($settings->_adminID);
?>
<script language="JavaScript">

View File

@ -20,14 +20,13 @@
include("../inc/inc.Settings.php");
include("../inc/inc.ClassDMS.php");
include("../inc/inc.ClassKeywords.php");
include("../inc/inc.DBAccess.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$categories = getAllKeywordCategories(array($user->getID(), $settings->_adminID));
$categories = $dms->getAllKeywordCategories(array($user->getID(), $settings->_adminID));
UI::htmlStartPage(getMLText("use_default_keywords"));

View File

@ -19,7 +19,6 @@
include("../inc/inc.Settings.php");
include("../inc/inc.ClassDMS.php");
include("../inc/inc.ClassKeywords.php");
include("../inc/inc.DBAccess.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
@ -30,7 +29,7 @@ if ($user->getID() == $settings->_guestID) {
UI::exitError(getMLText("edit_default_keywords"),getMLText("access_denied"));
}
$categories = getAllUserKeywordCategories($user->getID());
$categories = $dms->getAllUserKeywordCategories($user->getID());
UI::htmlStartPage(getMLText("edit_default_keywords"));
UI::globalNavigation();