Bei den Modulen und Layouts funktioniert ebenfalls die Auflistung
Das Diskussionsforum zum Open Source Content Management System
https://forum.contenido.org/
Code: Alles auswählen
if ( $perm->have_perm_item($area, $db->f("idtpl")) ) { //idarea of area tpl is 12
Code: Alles auswählen
if ( $perm->have_perm_item($area, $db->f("idtpl")) ||
$perm->have_perm_area_action("tpl" , "tpl_delete") ||
$perm->have_perm_area_action("tpl" , "tpl_duplicate") ||
$perm->have_perm_area_action("tpl_edit" , "tpl_edit") ||
$perm->have_perm_area_action("tpl_edit" , "tpl_new")
) {
Code: Alles auswählen
if ( $perm->have_perm_item($area, $db->f("idtpl")) ||
$perm->have_perm_area_action("tpl" , "tpl_delete") ||
$perm->have_perm_area_action("tpl" , "tpl_duplicate") ||
$perm->have_perm_area_action("tpl_edit" , "tpl_edit") ||
$perm->have_perm_area_action("tpl_edit" , "tpl_new") ||
$perm->have_perm_area_action("tpl_visual" , "tpl_visedit")
) {
Code: Alles auswählen
if ($perm->have_perm_area_action_item($area, $db->f("name"), $idcat) || $perm->have_perm_area_action($area, $db->f("name"))) {
$this->actions[$area][$db->f('name')] = $db->f('code');
}
Code: Alles auswählen
global $idcat, $idtpl, $idmod, $idlay;
if (isset($idcat)) {
$itemid = $idcat;
} elseif (isset($idtpl)) {
$itemid = $idtpl;
} elseif (isset($idmod)) {
$itemid = $idmod;
} elseif (isset($idlay)) {
$itemid = $idlay;
} else {
$itemid = 0;
}
Code: Alles auswählen
if ($perm->have_perm_area_action_item($area, $db->f("name"), $idcat) || $perm->have_perm_area_action($area, $db->f("name"))) {
Code: Alles auswählen
if ($perm->have_perm_area_action_item($area, $db->f("name"), $itemid) || $perm->have_perm_area_action($area, $db->f("name"))) {
Code: Alles auswählen
/* the right_list array:
[client] => Array => parent area
(
[client] => Array => area name
(
[perm] => client => areaname = permission
[location] => navigation/administration/clients => location for the name in the languagefile only for the main areaid
[action] => Array
(
[0] => client_delete => actionnames
)
)
[client_edit] => Array => area name
(
[perm] => client_edit
[location] =>
[action] => Array
(
[0] => client_edit
[1] => client_new
)
)
)
*/
Code: Alles auswählen
function saverights() {
global $rights_list, $rights_list_old, $db;
global $cfg, $userid, $rights_client, $rights_lang;
global $perm, $sess, $notification;
//if no checkbox is checked
if (!is_array($rights_list)) {
$rights_list = array ();
}
/*
echo "<pre>old:";
print_r($rights_list_old);
echo "new:";
print_r($rights_list);
echo "</pre>";
*/
//search all checks which are not in the new Rights_list for deleting
$arraydel = array_diff(array_keys($rights_list_old), array_keys($rights_list));
//search all checks which are not in the Rights_list_old for saving
$arraysave = array_diff(array_keys($rights_list), array_keys($rights_list_old));
if (is_array($arraydel)) {
foreach ($arraydel as $value) {
$data = explode("|", $value);
$data[0] = $perm->getIDForArea($data[0]);
$data[1] = $perm->getIDForAction($data[1]);
$sql = "DELETE FROM ".$cfg["tab"]["rights"]." WHERE user_id='$userid' AND idclient='$rights_client' AND idlang='$rights_lang' AND idarea='$data[0]' AND idcat='$data[2]' AND idaction='$data[1]' AND type=0";
$db->query($sql);
//echo $sql."<br>";
}
}
unset($data);
//search for all mentioned checkboxes
if (is_array($arraysave)) {
foreach ($arraysave as $value) {
//explodes the key it consits areait+actionid+itemid
$data = explode("|", $value);
// Since areas are stored in a numeric form in the rights table, we have
// to convert them from strings into numbers
$data[0] = $perm->getIDForArea($data[0]);
$data[1] = $perm->getIDForAction($data[1]);
if (!isset ($data[1])) {
$data[1] = 0;
}
// Insert new right
$sql = "INSERT INTO ".$cfg["tab"]["rights"]."
(idright, user_id,idarea,idaction,idcat,idclient,idlang,type)
VALUES ('".$db->nextid($cfg["tab"]["rights"])."', '$userid','$data[0]','$data[1]','$data[2]','$rights_client','$rights_lang',0)";
$db->query($sql);
//echo $sql."<br>";
}
}
$rights_list_old = $rights_list;
$notification->displayNotification("info", i18n("Changes saved"));
}
Code: Alles auswählen
function saverights() {
global $rights_list, $rights_list_old, $db;
global $cfg, $groupid, $rights_client, $rights_lang;
global $perm, $sess, $notification;
//if no checkbox is checked
if (!is_array($rights_list)) {
$rights_list = array ();
}
/*
echo "<pre>old:";
print_r($rights_list_old);
echo "new:";
print_r($rights_list);
echo "</pre>";
*/
//search all checks which are not in the new Rights_list for deleting
$arraydel = array_diff(array_keys($rights_list_old), array_keys($rights_list));
//search all checks which are not in the Rights_list_old for saving
$arraysave = array_diff(array_keys($rights_list), array_keys($rights_list_old));
if (is_array($arraydel)) {
foreach ($arraydel as $value) {
$data = explode("|", $value);
$data[0] = $perm->getIDForArea($data[0]);
$data[1] = $perm->getIDForAction($data[1]);
$sql = "DELETE FROM ".$cfg["tab"]["rights"]." WHERE user_id='$groupid' AND idclient='$rights_client' AND idlang='$rights_lang' AND idarea='$data[0]' AND idcat='$data[2]' AND idaction='$data[1]' AND type=1";
$db->query($sql);
//echo $sql."<br>";
}
}
unset($data);
//search for all mentioned checkboxes
if (is_array($arraysave)) {
foreach ($arraysave as $value) {
//explodes the key it consits areait+actionid+itemid
$data = explode("|", $value);
// Since areas are stored in a numeric form in the rights table, we have
// to convert them from strings into numbers
$data[0] = $perm->getIDForArea($data[0]);
$data[1] = $perm->getIDForAction($data[1]);
if (!isset ($data[1])) {
$data[1] = 0;
}
// Insert new right
$sql = "INSERT INTO ".$cfg["tab"]["rights"]."
(idright, user_id,idarea,idaction,idcat,idclient,idlang, type)
VALUES ('".$db->nextid($cfg["tab"]["rights"])."', '$groupid','$data[0]','$data[1]','$data[2]','$rights_client','$rights_lang',1)";
$db->query($sql);
//echo $sql."<br>";
}
}
$rights_list_old = $rights_list;
$notification->displayNotification("info", i18n("Changes saved"));
}
Code: Alles auswählen
if (($perm->have_perm_area_action($area, $action)) && ($action == "user_edit")) {
saverights();
} else {
if (!$perm->have_perm_area_action($area, $action)) {
$notification->displayNotification("error", i18n("Permission denied"));
}
}
Code: Alles auswählen
//set the areas which are in use fore selecting these
$sql = "SELECT A.idarea, A.idaction, A.idcat, B.name, C.name FROM ".$cfg["tab"]["rights"]." AS A, ".$cfg["tab"]["area"]." AS B, ".$cfg["tab"]["actions"]." AS C WHERE user_id='$userid' AND idclient='$rights_client' AND idlang='$rights_lang' AND idcat='0' AND A.idaction = C.idaction AND A.idarea = B.idarea";
$db->query($sql);
$rights_list_old = array ();
while ($db->next_record()) { //set a new rights list fore this user
$rights_list_old[$db->f(3)."|".$db->f(4)."|".$db->f("idcat")] = "x";
}
Code: Alles auswählen
//If rights_list is not set or you browse from a other site make a new rights_list from this user
if(!isset($rights_list_old)||$action==""||!isset($action)){
...
}
Code: Alles auswählen
user_id='$userid'
Code: Alles auswählen
user_id='$groupid'
Code: Alles auswählen
//set the areas which are in use fore selecting these
$possible_area = "'".implode("','", $area_tree[showareas("tpl")])."'";
$sql = "SELECT A.idarea, A.idaction, A.idcat, B.name, C.name FROM ".$cfg["tab"]["rights"]." AS A, ".$cfg["tab"]["area"]." AS B, ".$cfg["tab"]["actions"]." AS C WHERE user_id='$userid' AND idclient='$rights_client' AND A.type = 0 AND idlang='$rights_lang' AND B.idarea IN ($possible_area) AND idcat!='0' AND A.idaction = C.idaction AND A.idarea = C.idarea AND A.idarea = B.idarea";
$db->query($sql);
$rights_list_old = array ();
while ($db->next_record()) { //set a new rights list fore this user
$rights_list_old[$db->f(3)."|".$db->f(4)."|".$db->f("idcat")] = "x";
}
Code: Alles auswählen
//If rights_list is not set or you browse from a other site make a new rights_list from this user
if(!isset($rights_list_old)||$action==""||!isset($action)){
...
}
Code: Alles auswählen
user_id='$userid'
Code: Alles auswählen
user_id='$groupid'
Code: Alles auswählen
A.type = 0
Code: Alles auswählen
A.type = 1
Code: Alles auswählen
if (isset($action) && $backend->getCode($action) != '') {
eval($backend->getCode($action));
}
Code: Alles auswählen
if (isset($action)) {
if ($backend->getCode($action) != '') {
if ($backend->debug == 1) {
echo '<pre style="font-family: verdana; font-size: 10px"><b>Executing:</b>'."\n";
echo $backend->getCode($action)."\n";
echo '</pre>';
}
eval($backend->getCode($action));
} else {
if ($backend->debug == 1) {
echo '<pre style="font-family: verdana; font-size: 10px"><b>Executing:</b>'."\n";
echo "no code available in action\n";
echo '</pre>';
}
}
}
Code: Alles auswählen
function have_perm_area_action_anyitem($area, $action = 0) {
if ($this->have_perm_area_action($area,$action)) {
return true;
}
$area = $this->getIDForArea($area);
$action = $this->getIDForAction($action);
global $item_rights;
if (isset($item_rights[$area][$action])) {
return true;
} else {
return false;
}
}
Code: Alles auswählen
if (($action == "tpl_new") && (!$perm->have_perm_area_action_anyitem($area, $action)))
Code: Alles auswählen
//******** if layout is changed stay at 'tpl_edit' otherwise go to 'tpl'
if ($changelayout != 1) {
$url = $sess->url("main.php?area=tpl_edit&idtpl=$idtpl&frame=4");
header("location: $url");
}
return $idtpl;
Code: Alles auswählen
# Save the action only access to
# the desired action is granted.
# If this action is relevant for rights
# check if the user has permission to
# execute this action
if ($db->f("relevant_action") == 1 && $db->f("relevant_area") == 1) {
if ($perm->have_perm_area_action_item($area, $db->f("name"), $itemid) || $perm->have_perm_area_action($area, $db->f("name"))) {
$this->actions[$area][$db->f('name')] = $db->f('code');
}
} else {
$this->actions[$area][$db->f('name')] = $db->f('code');
}
Code: Alles auswählen
# Save the action only access to
# the desired action is granted.
# If this action is relevant for rights
# check if the user has permission to
# execute this action
if ($db->f("relevant_action") == 1 && $db->f("relevant_area") == 1) {
if ($perm->have_perm_area_action_item($area, $db->f("name"), $itemid) || $perm->have_perm_area_action($area, $db->f("name"))) {
$this->actions[$area][$db->f('name')] = $db->f('code');
}
if ($itemid == 0) {
// itemid not available, since its impossible the get the correct rights out
// we only check if userrights are given for these three items on any item
if ($action=="mod_edit" || $action=="tpl_edit" || $action=="lay_edit") {
if ($perm->have_perm_area_action_anyitem($area, $db->f("name"))) {
$this->actions[$area][$db->f('name')] = $db->f('code');
}
}
}
} else {
$this->actions[$area][$db->f('name')] = $db->f('code');
}
Keine Ahnung, aber so grob gesprochen funktioniert das so:emergence hat geschrieben:ad. windows rechte system
gibts da irgendwo im netz ne info wie das aufgebaut ist ?
hmm... das hört sich nach einem komplett anders aufgebauten cms an...timo hat geschrieben:Jedes "Objekt" (also Verzeichnis oder File) hat Berechtigungen (nicht nur lesen und schreiben, sondern auch "Spezialberechtigungen" sind möglich). Weiterhin ist es recht elegant gelöst:
Möchte man von einem Objekt wissen, welche Rechte es hat, dann macht man einen Rechtsklick drauf und sieht, welche Berechtigungen für das Objekt aktiv sind und welche eingestellt wurden. Weiterhin kann man entweder explizit zulassen oder sperren, egal, was das übergeordnete Objekt für Berechtigungen hat - alles auf Benutzer- oder Gruppenbasis.
gut...makemyday hat geschrieben:Ich hab auch noch mal ein bißchen rumgetestet. Totz diesem Fehler, den ich pro Template 1x im linken Fenster der Templatebearbeitung bekomme, funktioniert alles:
Code: Alles auswählen
Warning: Invalid argument supplied for foreach() in /var/www/contenido-4.4.4/conlib/perm.inc on line 426