function avatar_selection_roles_page in Avatar Selection 5.2
Same name and namespace in other branches
- 6 avatar_selection.admin.inc \avatar_selection_roles_page()
- 7 avatar_selection.admin.inc \avatar_selection_roles_page()
1 string reference to 'avatar_selection_roles_page'
- avatar_selection_menu in ./
avatar_selection.module - Implementation of hook_menu().
File
- ./
avatar_selection.module, line 622 - The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user, and to the administrator to disable uploading other avatar files by the user.
Code
function avatar_selection_roles_page($op = NULL) {
$output = "";
// Display the form where appropriate.
if (isset($op) && ($op == 'role' || $op == 'og')) {
$output .= drupal_get_form('avatar_selection_edit_form');
}
else {
$avs_access = array();
$og_access = array();
$avs_access[0] = 0;
$og_access[0] = 0;
// Get the list of access roles and initialise the count to 0.
$roles = avatar_selection_handler_filter_role();
foreach ($roles as $rid => $role_name) {
$avs_access[$rid] = 0;
}
// Get the list of organic groups and initialise the count to 0.
if (module_exists("og")) {
$ogroups = og_all_groups_options();
foreach ($ogroups as $ogid => $ogroup_name) {
$og_access[$ogid] = 0;
}
}
// Get the total number of avatars available on the system.
$total_count = 0;
$result = db_query("SELECT count(*) AS count FROM {avatar_selection} avs");
while ($avatar = db_fetch_object($result)) {
$total_count = $avatar->count;
}
$output .= '<p>' . t('There is a total of %count avatars configured.', array(
'%count' => $total_count,
)) . '</p>';
// Get the count of avatars per role.
$result = db_query("SELECT avsr.rid, count(*) AS count FROM {avatar_selection} avs LEFT JOIN {avatar_selection_roles} avsr ON avs.aid = avsr.aid GROUP BY avsr.rid");
while ($avatar = db_fetch_object($result)) {
if (empty($avatar->rid)) {
$avs_access[0] += $avatar->count;
}
else {
$avs_access[$avatar->rid] += $avatar->count;
}
}
// Get the count of avatars per organic group.
$result = db_query("SELECT avso.ogid, count(*) AS count FROM {avatar_selection} avs LEFT JOIN {avatar_selection_og} avso ON avs.aid = avso.aid GROUP BY avso.ogid");
while ($avatar = db_fetch_object($result)) {
if (empty($avatar->ogid)) {
$og_access[0] += $avatar->count;
}
else {
$og_access[$avatar->ogid] += $avatar->count;
}
}
// Format the user roles table.
$avs_rows = array();
$header = array(
t('User Role'),
t('Number of Avatars'),
);
$edit = l(t('edit'), 'admin/settings/avatar_selection/edit/role/0');
$avs_rows[] = array(
t('Available to all roles'),
$avs_access[0],
$edit,
);
foreach ($roles as $rid => $role_name) {
$edit = l(t('edit'), 'admin/settings/avatar_selection/edit/role/' . $rid);
$avs_rows[] = array(
$role_name,
$avs_access[$rid],
$edit,
);
}
$output .= theme('table', $header, $avs_rows);
// Format the organic groups table.
if (module_exists("og")) {
$og_rows = array();
$header = array(
t('Organic Group'),
t('Number of Avatars'),
);
$edit = l(t('edit'), 'admin/settings/avatar_selection/edit/og/0');
$og_rows[] = array(
t('Available to all groups'),
$og_access[0],
$edit,
);
foreach ($ogroups as $ogid => $ogroup_name) {
$edit = l(t('edit'), 'admin/settings/avatar_selection/edit/og/' . $ogid);
$og_rows[] = array(
$ogroup_name,
$og_access[$ogid],
$edit,
);
}
$output .= theme('table', $header, $og_rows);
}
}
return $output;
}