function support_block in Support Ticketing System 6
Implemtation of hook_block().
File
- ./
support.module, line 363 - support.module
Code
function support_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Support client access');
// Too dynamic to cache.
$blocks[0]['cache'] = BLOCK_CACHE_GLOBAL;
return $blocks;
case 'view':
$block = array();
// Only display block on support pages.
if (arg(0) == 'support') {
$clid = _support_current_client();
$access_users = array();
$access_roles = array();
if ($clid) {
$client = db_result(db_query('SELECT name FROM {support_client} WHERE clid = %d', $clid));
// retrieve all roles giving permission to access current tickets
$result = db_query("SELECT p.rid, r.name FROM {permission} p JOIN {role} r ON r.rid = p.rid WHERE perm LIKE '%%%s%%' OR perm LIKE '%%%s%%'", "access {$client} tickets", 'administer support');
$roles = array();
while ($role = db_fetch_object($result)) {
$roles[$role->rid] = $role->rid;
$access_roles[] = l($role->name, "admin/user/permissions/{$role->rid}");
}
if (!empty($roles)) {
$role_sql = "SELECT u.name, u.uid FROM {users} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid IN (%s) AND u.status = 1";
if (variable_get('support_filter_uid1', FALSE)) {
$role_sql .= ' AND u.uid <> 1';
}
$result = db_query($role_sql, implode(', ', $roles));
while ($account = db_fetch_object($result)) {
$access_users[$account->uid] = theme('username', $account);
}
}
}
$block['subject'] = t('Client access');
$block['content'] = theme_item_list($access_roles, t('Roles')) . theme_item_list($access_users, t('Users'));
}
return $block;
}
}