- more replacement of former global settings variable _adminID

This commit is contained in:
steinm 2010-12-10 13:38:03 +00:00
parent 2903e30f08
commit 5650c23595
4 changed files with 20 additions and 27 deletions

View File

@ -36,10 +36,10 @@ $action = $_GET["action"];
if ($action == "addcategory") { if ($action == "addcategory") {
$name = sanitizeString($_GET["name"]); $name = sanitizeString($_GET["name"]);
if (is_object($dms->getKeywordCategoryByName($name, $settings->_adminID))) { if (is_object($dms->getKeywordCategoryByName($name, $user->getID()))) {
UI::exitError(getMLText("admin_tools"),getMLText("keyword_exists")); UI::exitError(getMLText("admin_tools"),getMLText("keyword_exists"));
} }
$newCategory = $dms->addKeywordCategory($settings->_adminID, $name); $newCategory = $dms->addKeywordCategory($user->getID(), $name);
if (!$newCategory) { if (!$newCategory) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
} }
@ -59,7 +59,7 @@ else if ($action == "removecategory") {
} }
$owner = $category->getOwner(); $owner = $category->getOwner();
if ($owner->getID() != $settings->_adminID) { if (!$owner->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
} }
if (!$category->remove()) { if (!$category->remove()) {
@ -81,7 +81,7 @@ else if ($action == "editcategory") {
} }
$owner = $category->getOwner(); $owner = $category->getOwner();
if ($owner->getID() != $settings->_adminID) { if (!$owner->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
} }
@ -97,7 +97,7 @@ else if ($action == "newkeywords") {
$categoryid = sanitizeString($_GET["categoryid"]); $categoryid = sanitizeString($_GET["categoryid"]);
$category = $dms->getKeywordCategory($categoryid); $category = $dms->getKeywordCategory($categoryid);
$owner = $category->getOwner(); $owner = $category->getOwner();
if ($owner->getID() != $settings->_adminID) { if (!$owner->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
} }
@ -122,7 +122,7 @@ else if ($action == "editkeywords")
} }
$owner = $category->getOwner(); $owner = $category->getOwner();
if ($owner->getID() != $settings->_adminID) { if (!$owner->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
} }
@ -150,7 +150,7 @@ else if ($action == "removekeywords") {
} }
$owner = $category->getOwner(); $owner = $category->getOwner();
if ($owner->getID() != $settings->_adminID) { if (!$owner->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
} }

View File

@ -105,16 +105,20 @@ else if ($action == "removeuser") {
else if (isset($_GET["userid"])) { else if (isset($_GET["userid"])) {
$userid = $_GET["userid"]; $userid = $_GET["userid"];
} }
if ($userid==$settings->_adminID) {
UI::exitError(getMLText("admin_tools"),getMLText("cannot_delete_admin"));
}
if (!isset($userid) || !is_numeric($userid) || intval($userid)<1) { if (!isset($userid) || !is_numeric($userid) || intval($userid)<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
/* This used to be a check if an admin is deleted. Now it checks if one
* wants to delete herself.
*/
if ($userid==$user->getID()) {
UI::exitError(getMLText("admin_tools"),getMLText("cannot_delete_yourself"));
} }
$userToRemove = $dms->getUser($userid); $userToRemove = $dms->getUser($userid);
if (!is_object($userToRemove) || ($userToRemove->getID() == $settings->_adminID)) { if (!is_object($userToRemove)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id")); UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
} }

View File

@ -37,7 +37,7 @@ if (!isset($_GET["userid"]) || !is_numeric($_GET["userid"]) || intval($_GET["use
$userid = $_GET["userid"]; $userid = $_GET["userid"];
$currUser = $dms->getUser($userid); $currUser = $dms->getUser($userid);
if (($userid==$settings->_adminID) || $currUser->isGuest()) { if ($userid==$user->getID()) {
UI::exitError(getMLText("rm_user"),getMLText("access_denied")); UI::exitError(getMLText("rm_user"),getMLText("access_denied"));
} }
@ -62,14 +62,12 @@ UI::contentContainerStart();
<p> <p>
<?php printMLText("assign_user_property_to"); ?> : <?php printMLText("assign_user_property_to"); ?> :
<select name="assignTo"> <select name="assignTo">
<option value="<?php print $settings->_adminID; ?>"><?php echo getMLText("admin")?>
<?php <?php
$users = $dms->getAllUsers(); $users = $dms->getAllUsers();
foreach ($users as $currUser) { foreach ($users as $currUser) {
if (($currUser->getID() == $settings->_adminID) || $currUser->isGuest() || ($currUser->getID() == $userid) ) if ($currUser->isGuest() || ($currUser->getID() == $userid) )
continue; continue;
if (isset($_GET["userid"]) && $currUser->getID()==$_GET["userid"]) $selected=$count; if (isset($_GET["userid"]) && $currUser->getID()==$_GET["userid"]) $selected=$count;
print "<option value=\"".$currUser->getID()."\">" . $currUser->getLogin(); print "<option value=\"".$currUser->getID()."\">" . $currUser->getLogin();
} }

View File

@ -101,10 +101,6 @@ UI::contentContainerStart();
$selected=0; $selected=0;
$count=2; $count=2;
foreach ($users as $currUser) { foreach ($users as $currUser) {
/*
if (($currUser->getID() == $settings->_adminID) || $currUser->isGuest())
continue;
*/
if (isset($_GET["userid"]) && $currUser->getID()==$_GET["userid"]) $selected=$count; if (isset($_GET["userid"]) && $currUser->getID()==$_GET["userid"]) $selected=$count;
print "<option value=\"".$currUser->getID()."\">" . $currUser->getLogin(); print "<option value=\"".$currUser->getID()."\">" . $currUser->getLogin();
$count++; $count++;
@ -231,11 +227,6 @@ UI::contentContainerStart();
<?php <?php
foreach ($users as $currUser) { foreach ($users as $currUser) {
/*
if (($currUser->getID() == $settings->_adminID) || $currUser->isGuest())
continue;
*/
print "<td id=\"keywords".$currUser->getID()."\" style=\"display : none;\">"; print "<td id=\"keywords".$currUser->getID()."\" style=\"display : none;\">";
UI::contentSubHeading(getMLText("user")." : ".$currUser->getLogin()); UI::contentSubHeading(getMLText("user")." : ".$currUser->getLogin());