perm.inc
Code: Alles auswählen
function have_perm_item($mainarea, $itemid)
{
global $cfg, $item_rights, $cfg, $client, $lang, $auth, $area_tree, $sess;
$mainarea = $this->getIDForArea($mainarea);
// if is not admin or sysadmin
if (!$this->have_perm())
{
$db = new DB_Contenido;
$this->showareas($mainarea);
$flg = false;
// check if there are any rights for this areas
foreach ($area_tree[$mainarea] as $value)
{
// if the flag noright is set there are no rights in this area
if ($item_rights[$value] == 'noright')
return false;
elseif (is_array($item_rights[$value]))
{
// if there are any rights
foreach ($item_rights[$value] as $value2)
if (in_array($itemid, $value2))
return true;
}
elseif ($item_rights[$value] != 'noright')
{
$groupsForUser = $this->getGroupsForUser($auth->auth['uid']);
$groupsForUser[] = $auth->auth['uid'];
// else search for rights for this user in this area
$sql = '
SELECT
*
FROM
'.$cfg['tab']['rights'].'
WHERE
user_id IN ("'.implode('","', $groupsForUser).'")
AND
idclient = "'.$client.'"
AND
idlang = "'.$lang.'"
AND
idarea = "'.$value.'"
AND
idcat != "0"
';
$db->query($sql);
// if there are no rights for this area set the flag norights
if ($db->affected_rows() == 0)
$item_rights[$value] = 'noright';
// set the rights
while ($db->next_record())
{
if ($db->f('idcat') == $itemid)
$flg = true;
$item_rights[$db->f('idarea')][$db->f('idaction')][$db->f('idcat')] = $db->f('idcat');
}
} //end if
} //end foreach
return $flg;
} //end if
return true;
}
include.con_str_overview.php
um folgende Zeilen
Code: Alles auswählen
unset($objects[0]);
foreach ($objects as $key => $value)
dieses:
Code: Alles auswählen
$groupsForUser = $perm->getGroupsForUser($auth->auth['uid']);
$groupsForUser[] = $auth->auth['uid'];
$tmp_userstring = implode('","', $groupsForUser);
unset($objects[0]);
foreach ($objects as $key => $value)
{
# Check global rights
$check_rights = $perm->have_perm_area_action('con', 'con_makestart');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con', 'con_makeonline');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con', 'con_deleteart');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con', 'con_tplcfg_edit');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con', 'con_makecatonline');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con', 'con_changetemplate');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con_editcontent', 'con_editart');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con_editart', 'con_edit');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con_editart', 'con_newart');
if (!$check_rights) $check_rights = $perm->have_perm_area_action('con_editart', 'con_saveart');
# Check rights per cat
if (!$check_rights)
{
# Check if any rights are applied to current user or his groups
$sql = '
SELECT
*
FROM
'.$cfg['tab']['rights'].'
WHERE
user_id IN ("'.$tmp_userstring.'")
AND
idclient = "'.$client.'"
AND
idlang = "'.$lang.'"
AND
idcat = "'.$value->id.'"
';
$db->query($sql);
if ($db->num_rows() != 0)
{
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con', 'con_makestart', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con', 'con_makeonline', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con', 'con_deleteart', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con', 'con_tplcfg_edit', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con', 'con_makecatonline', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con', 'con_changetemplate', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con_editcontent', 'con_editart', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con_editart', 'con_edit', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con_editart', 'con_newart', $value->id);
if (!$check_rights) $check_rights = $perm->have_perm_area_action_item('con_editart', 'con_saveart', $value->id);
}
}