You are here

function system_actions_manage in Drupal 6

Same name and namespace in other branches
  1. 7 modules/system/system.admin.inc \system_actions_manage()

Menu callback. Display an overview of available and configured actions.

1 string reference to 'system_actions_manage'
system_menu in modules/system/system.module
Implementation of hook_menu().

File

modules/system/system.module, line 1395
Configuration system that lets administrators modify the workings of the site.

Code

function system_actions_manage() {
  $output = '';
  $actions = actions_list();
  actions_synchronize($actions);
  $actions_map = actions_actions_map($actions);
  $options = array(
    t('Choose an advanced action'),
  );
  $unconfigurable = array();
  foreach ($actions_map as $key => $array) {
    if ($array['configurable']) {
      $options[$key] = $array['description'] . '...';
    }
    else {
      $unconfigurable[] = $array;
    }
  }
  $row = array();
  $instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters <> ''"));
  $header = array(
    array(
      'data' => t('Action type'),
      'field' => 'type',
    ),
    array(
      'data' => t('Description'),
      'field' => 'description',
    ),
    array(
      'data' => $instances_present ? t('Operations') : '',
      'colspan' => '2',
    ),
  );
  $sql = 'SELECT * FROM {actions}';
  $result = pager_query($sql . tablesort_sql($header), 50);
  while ($action = db_fetch_object($result)) {
    $row[] = array(
      array(
        'data' => $action->type,
      ),
      array(
        'data' => filter_xss_admin($action->description),
      ),
      array(
        'data' => $action->parameters ? l(t('configure'), "admin/settings/actions/configure/{$action->aid}") : '',
      ),
      array(
        'data' => $action->parameters ? l(t('delete'), "admin/settings/actions/delete/{$action->aid}") : '',
      ),
    );
  }
  if ($row) {
    $pager = theme('pager', NULL, 50, 0);
    if (!empty($pager)) {
      $row[] = array(
        array(
          'data' => $pager,
          'colspan' => '3',
        ),
      );
    }
    $output .= '<h3>' . t('Actions available to Drupal:') . '</h3>';
    $output .= theme('table', $header, $row);
  }
  if ($actions_map) {
    $output .= drupal_get_form('system_actions_manage_form', $options);
  }
  return $output;
}