function library_admin_action in Library 7
Same name and namespace in other branches
- 5.2 library.admin.inc \library_admin_action()
- 6.2 library.admin.inc \library_admin_action()
- 6 library.admin.inc \library_admin_action()
Menu callback: Edit Library Action.
See also
library_admin_action_validate()
theme_library_admin_new_action()
2 string references to 'library_admin_action'
- library_forms in ./
library.module - Implements hook_forms().
- library_menu in ./
library.module - Implements hook_menu().
File
- ./
library.admin.inc, line 272 - Administrative settings for the library module
Code
function library_admin_action() {
$aid = arg(6);
if ($aid) {
// Display the edit action form.
$action = library_get_action($aid);
$show_delete = TRUE;
if ($action && $action->status_change > 0) {
// Make sure the library always has at least one check in and
// one check out action.
$actions_of_same_type = db_select('library_actions', 'la')
->fields('la', array(
'aid',
))
->condition('aid', $action->aid, '<>')
->condition('status_change', $action->status_change)
->execute();
$actions_of_same_type_count = $actions_of_same_type
->rowCount();
if ($actions_of_same_type_count == 0) {
$show_delete = FALSE;
}
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Action name'),
'#default_value' => $action->name,
'#size' => 20,
'#required' => TRUE,
'#maxlength' => 60,
'#description' => t('The name for this action.'),
);
$form['status_change'] = array(
'#type' => 'radios',
'#title' => t('Status Change'),
'#description' => t('How this action changes the status of a library item.'),
'#default_value' => isset($action->status_change) ? $action->status_change : 0,
'#options' => array(
LIBRARY_ACTION_NO_CHANGE => t('No Change'),
LIBRARY_ACTION_TYPE_UNAVAILABLE => t('Unavailable'),
LIBRARY_ACTION_TYPE_AVAILABLE => t('Available'),
),
);
$form['aid'] = array(
'#type' => 'value',
'#value' => $aid,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save action'),
);
if ($show_delete) {
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete action'),
);
}
}
else {
$form['name'] = array(
'#type' => 'textfield',
'#size' => 20,
'#maxlength' => 60,
);
$form['status_change'] = array(
'#type' => 'radios',
'#default_value' => 0,
'#options' => array(
LIBRARY_ACTION_NO_CHANGE => t('No Change'),
LIBRARY_ACTION_TYPE_UNAVAILABLE => t('Unavailable'),
LIBRARY_ACTION_TYPE_AVAILABLE => t('Available'),
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Add action'),
);
$form['#submit'][] = 'library_admin_action_submit';
$form['#validate'][] = 'library_admin_action_validate';
}
return $form;
}