Menu callback; Displays an overview of available and configured actions.
function action_admin_manage() {
action_synchronize();
$actions = action_list();
$actions_map = action_actions_map($actions);
$options = array();
$unconfigurable = array();
foreach ($actions_map as $key => $array) {
if ($array['configurable']) {
$options[$key] = $array['label'] . '...';
}
else {
$unconfigurable[] = $array;
}
}
$row = array();
$instances_present = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")
->fetchField();
$header = array(
array(
'data' => t('Action type'),
'field' => 'type',
),
array(
'data' => t('Label'),
'field' => 'label',
),
$instances_present ? t('Operations') : '',
);
$query = db_select('actions')
->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
->extend('Drupal\\Core\\Database\\Query\\TableSortExtender');
$result = $query
->fields('actions')
->limit(50)
->orderByHeader($header)
->execute();
foreach ($result as $action) {
$row = array();
$row[] = $action->type;
$row[] = check_plain($action->label);
$links = array();
if ($action->parameters) {
$links['configure'] = array(
'title' => t('configure'),
'href' => "admin/config/system/actions/configure/{$action->aid}",
);
$links['delete'] = array(
'title' => t('delete'),
'href' => "admin/config/system/actions/delete/{$action->aid}",
);
}
$row[] = array(
'data' => array(
'#type' => 'operations',
'#links' => $links,
),
);
$rows[] = $row;
}
if ($rows) {
$pager = theme('pager');
if (!empty($pager)) {
$rows[] = array(
array(
'data' => $pager,
'colspan' => '3',
),
);
}
$build['action_header'] = array(
'#markup' => '<h3>' . t('Available actions:') . '</h3>',
);
$build['action_table'] = array(
'#markup' => theme('table', array(
'header' => $header,
'rows' => $rows,
)),
);
}
if ($actions_map) {
$build['action_admin_manage_form'] = drupal_get_form('action_admin_manage_form', $options);
}
return $build;
}