Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_resource_custom_access()

Parameters

ColumnTypeDefaultDescription
$resource

Location

include/resource_functions.php lines 3648 to 3679

Definition

 
function get_resource_custom_access($resource)
    {
    
/*Return a list of usergroups with the custom access level for resource $resource (if set).
    The standard usergroup names are translated using $lang. Custom usergroup names are i18n translated.*/
    
$sql '';
    if(
checkperm('E'))
        {
        
// Restrict to this group and children groups only.
        
global $usergroup$usergroupparent;

        
$sql "WHERE g.parent = '{$usergroup}' OR g.ref = '{$usergroup}' OR g.ref = '{$usergroupparent}'";
        }

    
$resource_custom_access sql_query("
                   SELECT g.ref,
                          g.name,
                          g.permissions,
                          c.access
                     FROM usergroup AS g
          LEFT OUTER JOIN resource_custom_access AS c ON g.ref = c.usergroup AND c.resource = '
{$resource}'
                     
$sql
                 GROUP BY g.ref
                 ORDER BY (g.permissions LIKE '%v%') DESC, g.name
     "
);

    for(
$n 0$n count($resource_custom_access); $n++)
        {
        
$resource_custom_access[$n]['name'] = lang_or_i18n_get_translated($resource_custom_access[$n]['name'], 'usergroup-');
        }

    return 
$resource_custom_access;
    }

This article was last updated 28th November 2020 22:35 Europe/London time based on the source file dated 27th November 2020 14:50 Europe/London time.