Source for file mambo.php
Documentation is available at mambo.php
* @author Mambo Foundation Inc see README.php
* @copyright Mambo Foundation Inc.
* See COPYRIGHT.php for copyright notices and details.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
* Mambo is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2 of the
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
echo
"<script> alert('".
$this->connection->getErrorMsg().
"'); window.history.go(-1); </script>\n";
$sql =
"SELECT a.*, p.control, p.action, p.subject_type, p.subject_id, p.system FROM #__assignments AS a LEFT JOIN #__permissions AS p ON p.role=a.role WHERE a.access_type='$type'";
if (isset
($this->perm_found[$type])) $sql .=
" AND a.access_id='$id'";
else $sql .=
" AND (a.access_id='$id' OR a.access_id='*' OR a.access_id='+')";
$new_permissions =
$this->connection->loadObjectList();
AND ($role->access_id ==
$id OR $role->access_id ==
'*' OR ($role->access_id ==
'+' AND $id !=
0))
AND !in_array($role->role,$rolenames)) $rolenames[] =
$role->role;
if ((strcasecmp($permission->access_type,$a_type) ==
0 OR $permission->access_type ==
'*')
AND (strcasecmp($permission->access_id,$a_id) ==
0 OR $permission->access_id ==
'*')
AND (strcasecmp($permission->action,$action)==
0 OR $permission->action ==
'*' OR $action ==
'*')
AND (strcasecmp($permission->subject_type,$s_type)==
0 OR $s_type==
'*')
AND (strcasecmp($permission->subject_id,$s_id)==
0 OR $permission->subject_id ==
'*')
AND ($permission->control&$mask)) return 1;
function checkPermission ($a_type, $a_id, $action, $s_type=
'*', $s_id=
'*') {
function checkControl ($a_type, $a_id, $action, $s_type=
'*', $s_id=
'*') {
function checkGrant ($a_type, $a_id, $action, $s_type=
'*', $s_id=
'*') {
$sql =
"SELECT * FROM #__permissions WHERE role='$role'";
$permissions =
$this->connection->loadObjectList();
foreach ($permissions as $permission) {
AND (strcasecmp($permission->action,$action)==
0 OR $permission->action ==
'*')
AND (strcasecmp($permission->subject_type,$s_type)==
0)
AND (strcasecmp($permission->subject_id,$s_id)==
0 OR $permission->subject_id ==
'*')
AND ($permission->control&$mask)) return 1;
if (strcasecmp($permission->access_type,$a_type) ==
0
AND (strcasecmp($permission->access_id,$a_id) ==
0 OR $permission->access_id ==
'*' OR ($permission->access_id ==
'+' AND $a_id !=
0))
AND (strcasecmp($permission->action,$action) ==
0 OR $permission->action ==
'*')
AND $permission->subject_type !=
null AND $permission->subject_id !=
null) {
$results[] =
$permission->$property;
echo
"<script> alert('".
$this->connection->getErrorMsg().
"'); window.history.go(-1); </script>\n";
$sql =
"SELECT DISTINCT role FROM #__assignments";
$sql =
"SELECT DISTINCT role FROM #__permissions";
foreach ($more as $role) $this->addRole($role);
if ($key !==
false) unset
($this->roles[$key]);
$sql =
"SELECT role, action, control FROM #__permissions";
if ($subject_type !=
'*') $where[] =
"(subject_type='$subject_type' OR subject_type='*')";
if ($subject_id !=
'*') $where[] =
"(subject_id='$subject_id' OR subject_id='*')";
if (isset
($where)) $sql .=
" WHERE ".
implode(' AND ', $where);
if (!$result) $result =
array();
$sql =
"SELECT role, action, control FROM #__permissions WHERE (action='*' OR subject_type='*' OR subject_id='*') AND ((subject_type='$subject_type' OR subject_type='*') AND (subject_id='$subject_id' OR subject_id='*'))";
if (!$result) $result =
array();
function permitSQL ($role, $control, $action, $subject_type, $subject_id) {
$sql =
"REPLACE INTO #__permissions (role, control, action, subject_type, subject_id) VALUES ('$role', '$control', '$action', '$subject_type', '$subject_id');";
function permit ($role, $control, $action, $subject_type, $subject_id) {
$sql =
$this->permitSQL($role, $control, $action, $subject_type, $subject_id);
function assign ($role, $access_type, $access_id) {
$sql =
"REPLACE INTO #__assignments (role, access_type, access_id) VALUES ('$role', '$access_type', '$access_id')";
$sql =
"DELETE FROM #__assignments WHERE access_type='$access_type' AND access_id='$access_id'";
function &getControllingRoles ($access_type, $access_id, $action, $subject_type, $subject_id) {
$sql =
"SELECT a.role FROM #__permissions AS p, #__assignments AS a WHERE a.access_type='$access_type'"
.
" AND a.access_id='$access_id' AND a.role=p.role AND (p.control&1)"
.
" AND p.action='$action' AND p.subject_type='$subject_type' AND p.subject_id='$subject_id'";
$sql =
'SELECT p.action, p.subject_type, p.subject_id, control FROM #__permissions AS p, #__assignments AS a'
.
" WHERE p.role=a.role AND a.access_type='$access_type' AND (a.access_id='$access_id' OR a.access_id='*')"
$permissions =
& $this->connection->loadObjectList();
$sql =
"SELECT p2.control AS hiscontrol, p1.control AS mycontrol, p1.action, p1.subject_type, p1.subject_id"
.
" FROM `#__assignments` AS a, `#__permissions` AS p1 LEFT JOIN `#__permissions` AS p2"
.
" ON (p2.role='$role' AND p1.action=p2.action AND p1.subject_type=p2.subject_type AND p1.subject_id=p2.subject_id)"
.
" WHERE (p1.control&1) AND p1.role=a.role AND a.access_type='$access_type' AND (a.access_id='$access_id' OR a.access_id='*')";
$permissions =
& $this->connection->loadObjectList();
function getAccessLists ($access_type, $access_id, $action, $subject_type, $subject_id) {
if ($authoriser->checkControl($access_type, $access_id, $action, $subject_type, $subject_id)) {
$cangrant =
$authoriser->checkGrant($access_type, $access_id, $action, $subject_type, $subject_id);
foreach ($allroles as $role) {
foreach ($permissions as $permission) {
if (($permission->action ==
'*' OR $permission->action ==
$action) AND $permission->role ==
$role) {
if ($permission->control & 1) $cselected[] =
$optionc;
if ($permission->control & 2) $aselected[] =
$optiona;
if ($cangrant AND $permission->control & 4) $gselected[] =
$optiong;
$results[] =
mosHTML::selectList($itema, $action.
'_arole[]', 'multiple="multiple"', 'value', 'text', $aselected);
$results[] =
mosHTML::selectList($itemc, $action.
'_crole[]', 'multiple="multiple"', 'value', 'text', $cselected);
if ($cangrant) $results[] =
mosHTML::selectList($itemg, $action.
'_grole[]', 'multiple="multiple"', 'value', 'text', $gselected);
$control_types =
array ('crole', 'arole', 'grole');
$control_values =
array (1,2,4);
foreach ($control_types as $i=>
$type) {
$key =
$action.
'_'.
$type;
if (isset
($_POST[$key])) {
foreach ($_POST[$key] as $role) {
$value = isset
($newpermits[$role]) ?
$newpermits[$role] :
0;
$newpermits[$role] =
$value |
$control_values[$i];
foreach ($newpermits as $role=>
$value) {
foreach ($permissions as $permission) {
if (($permission->action ==
'*' OR $permission->action ==
$action) AND $permission->role ==
$role) {
if (($value & $permission->control) ===
$value) {
if ($needed) $sql .=
$this->permitSQL ($role, $value, $action, $subject_type, $subject_id);
if ($sql) $this->doSQL($sql);
$sql =
"SELECT COUNT(role) FROM #__permissions WHERE role='$role' GROUP BY role";
$sql =
"SELECT COUNT(role) FROM #__assignments WHERE role='$role' GROUP BY role";
$sql =
"DELETE FROM #__permissions WHERE action='administer' AND subject_type='$role' AND system=0";
$sql =
"DELETE a FROM #__assignments AS a LEFT JOIN #__permissions AS p ON a.role=p.role WHERE a.role='$role' AND (p.system=0 OR p.system=NULL)";
$sql =
"DELETE FROM #__permissions WHERE role='$role' AND system=0";
$sql =
"DELETE FROM #__permissions WHERE action='$action' AND subject_type='$subject_type'AND subject_id='$subject_id' AND system=0";
// ----- NO MORE CLASSES OR FUNCTIONS PASSED THIS POINT -----
// Post class declaration initialisations
// some version of PHP don't allow the instantiation of classes
// before they are defined
Documentation generated on Mon, 05 May 2008 16:20:58 +0400 by phpDocumentor 1.4.0