function support_pm_admin_settings in Support Ticketing System 7
Same name and namespace in other branches
- 6 support_pm/support_pm.admin.inc \support_pm_admin_settings()
1 string reference to 'support_pm_admin_settings'
- support_pm_menu in support_pm/
support_pm.module - Implements hook_menu(). TODO: Include date in 'view' and 'edit' tabs
File
- support_pm/
support_pm.admin.inc, line 366
Code
function support_pm_admin_settings() {
$form = array();
$color_values = variable_get('support_pm_color_values', array());
if (empty($color_values)) {
drupal_set_message(t('You must !url before you can edit colors here.', array(
'!url' => l(t('run a plan report'), 'admin/support/plan_report'),
)));
}
foreach ($color_values as $type => $values) {
arsort($values);
$form[$type] = array(
'#type' => 'fieldset',
'#collapsible' => 'true',
'#title' => check_plain($type),
);
$clients = $users = array();
foreach ($values as $id => $color) {
$object = NULL;
switch ($type) {
case 'client':
if (!empty($id)) {
$object = support_client_load($id);
}
if (is_object($object)) {
$title = check_plain($object->name);
$clients[$id] = $id;
}
else {
// Invalid entry, continue foreach
continue 2;
}
break;
case 'user':
if (!empty($id)) {
$object = user_load($id);
}
if (is_object($object)) {
$title = check_plain($object->name);
$users[$id] = $id;
}
else {
// Invalid entry, continue foreach
continue 2;
}
break;
default:
// Invalid type, continue foreach
continue 2;
}
$form[$type]["{$type}-{$id}"] = array(
'#type' => 'textfield',
'#title' => $title,
'#required' => TRUE,
'#default_value' => $color,
'#description' => "{$title} color: <img src=\"" . url('support_pm/image/') . $color . '" alt="swatch" height="15" width="15" />',
);
}
}
if (!empty($clients)) {
$form['clients'] = array(
'#type' => 'hidden',
'#value' => implode(',', $clients),
);
}
if (!empty($users)) {
$form['users'] = array(
'#type' => 'hidden',
'#value' => implode(',', $users),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update colors'),
);
return $form;
}