function support_overview_page_users in Support Ticketing System 7
Same name and namespace in other branches
- 6 support_overview/support_overview.module \support_overview_page_users()
1 string reference to 'support_overview_page_users'
- support_overview_menu in support_overview/
support_overview.module - Implements hook_menu().
File
- support_overview/
support_overview.module, line 548 - support_overview.module
Code
function support_overview_page_users($all = FALSE) {
drupal_add_css(drupal_get_path('module', 'support_overview') . '/support-overview.css');
$output = '<div class="support-overview">';
$enabled_clients = variable_get('support_overview_clients', array());
$all_clients = _support_available_clients();
if ($all || !is_array($enabled_clients) || empty($enabled_clients)) {
$enabled_clients = array();
foreach ($all_clients as $clid => $client) {
$enabled_clients[] = $clid;
}
$all = TRUE;
}
$enabled_roles = variable_get('support_overview_roles', array());
$sql = db_select('support_ticket', 't')
->fields('t', array(
'assigned',
))
->distinct()
->condition('t.client', $enabled_clients, 'IN');
$sql
->join('users', 'u', 't.assigned = u.uid');
$sql
->join('users_roles', 'r', 'u.uid = r.uid');
$sql
->orderBy('u.name', 'ASC');
if (!empty($enabled_roles)) {
$sql
->condition('r.rid', $enabled_roles, 'IN');
}
else {
$sql
->condition('t.assigned', 0, '!=');
}
$enabled_states = variable_get('support_overview_states', array());
// [0] == 'All'
if (!empty($enabled_states) && !isset($enabled_states[0])) {
$sql
->condition('state', $enabled_states);
}
$result = $sql
->execute();
foreach ($result as $row) {
$uid = $row->assigned;
$account = user_load($uid);
$output .= "<a href='" . url("support/overview/user/{$uid}") . "'><h3>" . check_plain($account->name) . '</h3></a>';
$output .= support_overview_page_user($account, $all, FALSE);
}
$output .= '<div class="support-overview-link">' . l($all ? t('selected clients') : t('all clients'), $all ? "support/overview/user" : "support/overview/user/all") . '</div>';
$output .= '</div>';
return $output;
}