Project

General

Profile

Bug #2522 ยป 2522.patch

krileon, 31 May 2011 21:24

View differences:

administrator/components/com_comprofiler/library/cb/cb.acl.php
if ( ! isset( $gids[$gid] ) ) {
if ( checkJversion() == 2 ) {
$query = 'SELECT g1.' . $_CB_database->NameQuote( 'id' ) . ' AS group_id'
. ', g1.' . $_CB_database->NameQuote( 'title' ) . ' AS name'
. "\n FROM " . $_CB_database->NameQuote( '#__usergroups' ) . " AS g1";
if ( $gid != 8 ) {
$query .= "\n LEFT JOIN " . $_CB_database->NameQuote( '#__usergroups' ) . " AS g2"
. ' ON g2.' . $_CB_database->NameQuote( 'rgt' ) . ' <= g1.' . $_CB_database->NameQuote( 'rgt' )
. ' AND g2.' . $_CB_database->NameQuote( 'lft' ) . ' >= g1.' . $_CB_database->NameQuote( 'lft' )
. "\n WHERE g2." . $_CB_database->NameQuote( 'id' ) . " = " . (int) $gid;
static $grps, $paths;
if ( ! isset( $grps ) ) {
$query = 'SELECT *'
. "\n FROM " . $_CB_database->NameQuote( '#__usergroups' )
. "\n ORDER BY " . $_CB_database->NameQuote( 'lft' );
$_CB_database->setQuery( $query );
$grps = $_CB_database->loadObjectList( 'id' );
}
$query .= "\n ORDER BY g1." . $_CB_database->NameQuote( 'title' );
$_CB_database->setQuery( $query );
$groups = $_CB_database->loadResultArray();
if ( ! array_key_exists( $gid, $grps ) ) {
return array();
}
if ( ! isset( $paths[$gid] ) ) {
$paths[$gid] = array();
foreach( $grps as $grp ) {
if ( ( $grp->lft <= $grps[$gid]->lft ) && ( $grp->rgt >= $grps[$gid]->rgt ) ) {
$paths[$gid][] = $grp->id;
}
}
}
$type = $this->get_parent_container( $grps[$gid], $grps );
if ( in_array( $type, array( 2, 3 ) ) ) {
$paths[$gid] = array_merge( $paths[$gid], array_diff( $this->get_group_parent_ids( 2 ), $this->get_group_parent_ids( $gid ) ) );
}
$paths[$gid] = array_values( array_unique( $paths[$gid] ) );
sort( $paths[$gid] );
$groups = $paths[$gid];
} elseif ( checkJversion() == 1 ) {
$query = 'SELECT g1.' . $_CB_database->NameQuote( 'id' ) . ' AS group_id'
. ', g1.' . $_CB_database->NameQuote( 'name' )
......
$groups = array_merge( $groups, $standardlist );
if ( checkJversion() == 2 ) {
sort( $groups );
}
$gids[$gid] = $groups;
}
......
if ( ! isset( $gids[$gid] ) ) {
if ( checkJversion() == 2 ) {
$query = 'SELECT g1.' . $_CB_database->NameQuote( 'id' ) . ' AS group_id'
// . ', g1.' . $_CB_database->NameQuote( 'title' ) . ' AS name'
. "\n FROM " . $_CB_database->NameQuote( '#__usergroups' ) . " AS g1"
. "\n LEFT JOIN " . $_CB_database->NameQuote( '#__usergroups' ) . " AS g2"
. ' ON g2.' . $_CB_database->NameQuote( 'rgt' ) . ' >= g1.' . $_CB_database->NameQuote( 'rgt' )
. ' AND g2.' . $_CB_database->NameQuote( 'lft' ) . ' <= g1.' . $_CB_database->NameQuote( 'lft' )
. "\n WHERE g2." . $_CB_database->NameQuote( 'id' ) . " = " . (int) $gid
. "\n ORDER BY g1." . $_CB_database->NameQuote( 'title' );
$_CB_database->setQuery( $query );
$groups = $_CB_database->loadResultArray();
static $grps, $paths;
if ( in_array( $gid, array( 6, 7 ) ) ) {
// Add the missing super admin if admin or moderator in list, but superadmin is missing, for backwards compatibility:
array_unshift( $groups, '8' );
if ( ! isset( $grps ) ) {
$query = 'SELECT *'
. "\n FROM " . $_CB_database->NameQuote( '#__usergroups' )
. "\n ORDER BY " . $_CB_database->NameQuote( 'lft' );
$_CB_database->setQuery( $query );
$grps = $_CB_database->loadObjectList( 'id' );
}
if ( ! array_key_exists( $gid, $grps ) ) {
return array();
}
if ( ! isset( $paths[$gid] ) ) {
$paths[$gid] = array();
foreach( $grps as $grp ) {
if ( ( $grp->lft >= $grps[$gid]->lft ) && ( $grp->rgt <= $grps[$gid]->rgt ) ) {
$paths[$gid][] = $grp->id;
}
}
}
$type = $this->get_parent_container( $grps[$gid], $grps );
if ( $type === 1 ) {
$paths[$gid] = array_merge( $paths[$gid], $this->get_group_parent_ids( 6 ) );
} elseif ( $type === 2 ) {
$paths[$gid] = array_merge( $paths[$gid], $this->get_group_parent_ids( 8 ) );
}
$paths[$gid] = array_values( array_unique( $paths[$gid] ) );
sort( $paths[$gid] );
$groups = $paths[$gid];
} elseif ( checkJversion() == 1 ) {
$query = 'SELECT g1.' . $_CB_database->NameQuote( 'id' ) . ' AS group_id'
// . ', g1.' . $_CB_database->NameQuote( 'name' )
......
$groups[$i] = (int) $groups[$i];
}
if ( checkJversion() == 2 ) {
sort( $groups );
}
$gids[$gid] = $groups;
}
return $gids[$gid];
}
function get_parent_container( $grp, $groups ) {
if ( $grp && $groups ) foreach ( $groups as $group ) {
$id = (int) $grp->id;
$parent = (int) $grp->parent_id;
$grps = array( $parent, $id );
// Go no further if group has no parent:
if ( $parent ) {
// Determine Joomla version:
if ( checkJversion() == 2 ) {
if ( in_array( 2, $grps ) ) {
return 1; // Registered
} elseif ( in_array( 6, $grps ) ) {
return 2; // Moderators
} elseif ( in_array( 8, $grps ) ) {
return 3; // Super Users
}
} else {
if ( in_array( 29, $grps ) ) {
return 1; // Public Frontend
} elseif ( in_array( 30, $grps ) ) {
return 2; // Public Backend
}
}
// Loop through for deep groups:
return $this->get_parent_container( $groups[$parent], $groups );
} else {
return 0; // Root
}
}
return null; // Unknown
}
function get_groups_below_me() {
global $_CB_framework;
    (1-1/1)