Bug #3038 » 3038-pt2_rev7.patch
administrator/components/com_comprofiler/library/cb/cb.acl.php | ||
---|---|---|
return null; // Unknown
|
||
}
|
||
|
||
function get_groups_below_me( $myId = null, $raw = false ) {
|
||
function get_groups_below_me( $myId = null, $raw = false, $exact = false ) {
|
||
global $_CB_framework;
|
||
|
||
static $gids = array();
|
||
... | ... | |
$myId = (int) $myId;
|
||
}
|
||
|
||
if ( ! isset( $gids[$myId] ) ) {
|
||
$id = (int) $myId . '_'. (int) $exact;
|
||
|
||
if ( ! isset( $gids[$id] ) ) {
|
||
if ( checkJversion() == 2 ) {
|
||
$my_groups = $this->get_object_groups( $myId );
|
||
} elseif ( checkJversion() == 1 ) {
|
||
... | ... | |
$my_gids = array();
|
||
} else {
|
||
cbArrayToInts( $my_gids );
|
||
|
||
if ( $exact ) foreach ( $my_gids as $k => $v ) {
|
||
if ( in_array( $v, $my_groups ) ) {
|
||
unset( $my_gids[$k] );
|
||
}
|
||
}
|
||
}
|
||
|
||
$groups = $this->get_group_children_tree( null, 'USERS', false );
|
||
... | ... | |
}
|
||
}
|
||
|
||
$gids[$myId] = array_values( $groups );
|
||
$gids[$id] = array_values( $groups );
|
||
}
|
||
|
||
$rows = $gids[$myId];
|
||
$rows = $gids[$id];
|
||
|
||
if ( $rows ) {
|
||
if ( $raw ) {
|
||
... | ... | |
return $rows;
|
||
}
|
||
|
||
function get_groups_above_me( $myId = null, $raw = false ) {
|
||
global $_CB_framework;
|
||
|
||
static $gids = array();
|
||
|
||
if ( $myId === null ) {
|
||
$myId = $_CB_framework->myId();
|
||
} else {
|
||
$myId = (int) $myId;
|
||
}
|
||
|
||
if ( ! isset( $gids[$myId] ) ) {
|
||
if ( checkJversion() == 2 ) {
|
||
$my_groups = $this->get_object_groups( $myId );
|
||
} elseif ( checkJversion() == 1 ) {
|
||
$aro_id = $this->get_object_id( 'users', $myId, 'ARO' );
|
||
$my_groups = $this->get_object_groups( $aro_id, 'ARO' );
|
||
} else {
|
||
$my_groups = $this->get_object_groups( 'users', $myId, 'ARO' );
|
||
}
|
||
|
||
$my_gids = array();
|
||
|
||
if ( $my_groups ) foreach ( $my_groups as $gid ) {
|
||
$my_gids = array_unique( array_merge( $my_gids, $this->get_group_parent_ids( $gid ) ) );
|
||
|
||
if ( checkJversion() == 2 ) {
|
||
$my_gids = array_unique( array_merge( $my_gids, $this->get_object_groups( $myId, null, 'RECURSE' ) ) );
|
||
}
|
||
}
|
||
|
||
if ( ( ! is_array( $my_gids ) ) || empty( $my_gids ) ) {
|
||
$my_gids = array();
|
||
} else {
|
||
cbArrayToInts( $my_gids );
|
||
|
||
$below_me = $this->get_groups_below_me( $myId, true );
|
||
|
||
if ( $below_me ) foreach ( $my_gids as $k => $v ) {
|
||
if ( in_array( $v, $below_me ) ) {
|
||
unset( $my_gids[$k] );
|
||
}
|
||
}
|
||
}
|
||
|
||
$groups = $this->get_group_children_tree( null, 'USERS', false );
|
||
|
||
if ( $groups ) foreach ( $groups as $k => $v ) {
|
||
if ( ! in_array( (int) $v->value, $my_gids ) ) {
|
||
unset( $groups[$k] );
|
||
}
|
||
}
|
||
|
||
$gids[$myId] = array_values( $groups );
|
||
}
|
||
|
||
$rows = $gids[$myId];
|
||
|
||
if ( $rows ) {
|
||
if ( $raw ) {
|
||
$grps = array();
|
||
|
||
foreach ( $rows as $row ) {
|
||
$grps[] = (int) $row->value;
|
||
}
|
||
|
||
$rows = $grps;
|
||
}
|
||
} else {
|
||
$rows = array();
|
||
}
|
||
|
||
return $rows;
|
||
}
|
||
|
||
/**
|
||
* Prepare top most GID from array of IDs
|
||
*
|
||
... | ... | |
if ( ( ! $allow_myself ) && ( $user_id == $_CB_framework->myId() ) ){
|
||
$msg .= "You cannot $action Yourself! ";
|
||
} else {
|
||
//// OLD WAY:
|
||
$myGid = $this->get_user_group_id( $_CB_framework->myId() );
|
||
if ( checkJversion() == 2 ) {
|
||
$userGroups = $this->get_object_groups( $user_id );
|
||
$myGroups = $this->get_object_groups( $_CB_framework->myId() );
|
||
$myGids = $this->get_groups_below_me( $_CB_framework->myId(), true, ( ( $user_id == $_CB_framework->myId() ) || array_intersect( $myGroups, $cms_admins ) ? false : true ) );
|
||
|
||
if ( $myGid != $cms_super_admin ) {
|
||
if ( ( ( $obj->gid == $myGid ) && ! in_array( $myGid, $cms_admins ) ) || ( $user_id && $obj->gid && ! in_array( $obj->gid, $this->get_group_children_ids( $myGid ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
}
|
||
}
|
||
//// NEW WAY:
|
||
$myGids = $this->get_groups_below_me( $_CB_framework->myId(), true );
|
||
if ( ! in_array( $cms_super_admin, $myGroups ) ) {
|
||
if ( ( ( array_values( $userGroups ) == array_values( $myGroups ) ) && ( ! array_intersect( $myGroups, $cms_admins ) ) ) || ( $user_id && $userGroups && ( ! array_intersect( $userGroups, $myGids ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
}
|
||
}
|
||
} else {
|
||
$myGid = $this->get_user_group_id( $_CB_framework->myId() );
|
||
|
||
if ( ! in_array( $cms_super_admin, $myGids ) ) {
|
||
if ( ( ( ! array_intersect( $myGids, $obj->gids ) ) && ( ! array_intersect( $myGids, $cms_admins ) ) ) || ( $user_id && $obj->gids && ( ! array_intersect( $obj->gids, $myGids ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
}
|
||
}
|
||
//// END.
|
||
if ( $myGid != $cms_super_admin ) {
|
||
if ( ( ( $obj->gid == $myGid ) && ! in_array( $myGid, $cms_admins ) ) || ( $user_id && $obj->gid && ! in_array( $obj->gid, $this->get_group_children_ids( $myGid ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
$this_group = 'Registered';
|
||
$gid = $this->get_group_id( $this_group, 'ARO' );
|
||
//// OLD WAY:
|
||
$myGid = $this->get_user_group_id( $_CB_framework->myId() );
|
||
|
||
if ( ( ( $gid == $myGid ) && ! in_array( $myGid, $cms_admins ) ) || ( $gid && ! in_array( $gid, $this->get_group_children_ids( $myGid ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
}
|
||
//// NEW WAY:
|
||
$myGids = $this->get_groups_below_me( $_CB_framework->myId(), true );
|
||
if ( checkJversion() == 2 ) {
|
||
$myGids = $this->get_groups_below_me( $_CB_framework->myId(), true );
|
||
$myGroups = $this->get_object_groups( $_CB_framework->myId() );
|
||
|
||
if ( ( ! array_intersect( $myGids, array( $gid ) ) && ( ! array_intersect( $myGids, $cms_admins ) ) ) || ( $gid && ( ! array_intersect( array( $gid ), $myGids ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
if ( ( ( array( $gid ) == array_values( $myGroups ) ) && ( ! array_intersect( $myGroups, $cms_admins ) ) ) || ( $gid && ( ! in_array( $gid, $myGids ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
}
|
||
} else {
|
||
$myGid = $this->get_user_group_id( $_CB_framework->myId() );
|
||
|
||
if ( ( ( $gid == $myGid ) && ! in_array( $myGid, $cms_admins ) ) || ( $gid && ! in_array( $gid, $this->get_group_children_ids( $myGid ) ) ) ) {
|
||
$msg .= "You cannot $action a `$this_group`. Only higher-level users have this power. ";
|
||
}
|
||
}
|
||
//// END.
|
||
}
|
||
|
||
return $msg;
|
- « Previous
- 1
- …
- 8
- 9
- 10
- Next »