function system_get_module_admin_tasks

Generate a list of tasks offered by a specified module.

Parameters

$module: Module name.

$info: The module's information, as provided by system_get_info().

Return value

An array of task links.

2 calls to system_get_module_admin_tasks()
AdminController::index in drupal/core/modules/system/lib/Drupal/system/Controller/AdminController.php
Prints a listing of admin tasks, organized by module.
HelpController::helpPage in drupal/core/modules/help/lib/Drupal/help/Controller/HelpController.php
Prints a page listing general help for a module.

File

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

Code

function system_get_module_admin_tasks($module, $info) {
  $links =& drupal_static(__FUNCTION__);
  if (!isset($links)) {
    $links = array();
    $menu_links = entity_get_controller('menu_link')
      ->loadModuleAdminTasks();
    foreach ($menu_links as $link) {
      _menu_link_translate($link);
      if ($link['access']) {
        $links[$link['router_path']] = $link;
      }
    }
  }
  $admin_tasks = array();
  $titles = array();
  if ($menu = module_invoke($module, 'menu')) {
    foreach ($menu as $path => $item) {
      if (isset($links[$path])) {
        $task = $links[$path];

        // The link description, either derived from 'description' in
        // hook_menu() or customized via menu module is used as title attribute.
        if (!empty($task['localized_options']['attributes']['title'])) {
          $task['description'] = $task['localized_options']['attributes']['title'];
          unset($task['localized_options']['attributes']['title']);
        }

        // Check the admin tasks for duplicate names. If one is found,
        // append the parent menu item's title to differentiate.
        $duplicate_path = array_search($task['title'], $titles);
        if ($duplicate_path !== FALSE) {
          if ($parent = menu_link_load($task['plid'])) {

            // Append the parent item's title to this task's title.
            $task['title'] = t('@original_title (@parent_title)', array(
              '@original_title' => $task['title'],
              '@parent_title' => $parent['title'],
            ));
          }
          if ($parent = menu_link_load($admin_tasks[$duplicate_path]['plid'])) {

            // Append the parent item's title to the duplicated task's title.
            // We use $links[$duplicate_path] in case there are triplicates.
            $admin_tasks[$duplicate_path]['title'] = t('@original_title (@parent_title)', array(
              '@original_title' => $links[$duplicate_path]['title'],
              '@parent_title' => $parent['title'],
            ));
          }
        }
        else {
          $titles[$path] = $task['title'];
        }
        $admin_tasks[$path] = $task;
      }
    }
  }

  // Append link for permissions.
  if (module_hook($module, 'permission')) {
    $item = menu_get_item('admin/people/permissions');
    if (!empty($item['access'])) {
      $item['link_path'] = $item['href'];
      $item['title'] = t('Configure @module permissions', array(
        '@module' => $info['name'],
      ));
      unset($item['description']);
      $item['localized_options']['fragment'] = 'module-' . $module;
      $item = entity_create('menu_link', $item);
      $admin_tasks["admin/people/permissions#module-{$module}"] = $item;
    }
  }
  return $admin_tasks;
}