You are here

function radioactivity_menu in Radioactivity 5

Same name and namespace in other branches
  1. 6 radioactivity.module \radioactivity_menu()
  2. 7.2 radioactivity.module \radioactivity_menu()
  3. 7 radioactivity.module \radioactivity_menu()

File

./radioactivity.module, line 30

Code

function radioactivity_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/radioactivity',
      'title' => t('Radioactivity'),
      'description' => t('Configure settings for radioactivity.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'radioactivity_admin_general_form',
      ),
      'access' => user_access(RADIOACTIVITY_PERM_ADMIN),
      'type' => MENU_NORMAL_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/radioactivity/general',
      'title' => t('General'),
      'description' => t('Configure settings for radioactivity.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'radioactivity_admin_general_form',
      ),
      'access' => user_access(RADIOACTIVITY_PERM_ADMIN),
      'weight' => 0,
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/radioactivity/list_profiles',
      'title' => t('Decay profiles'),
      'description' => t('List of decay profiles.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'radioactivity_admin_profile_list',
      ),
      'access' => user_access(RADIOACTIVITY_PERM_ADMIN),
      'weight' => 1,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/radioactivity/profile_new',
      'title' => t('New profile'),
      'description' => t('Add new decay profile.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'radioactivity_admin_profile_form',
        0,
      ),
      'access' => user_access(RADIOACTIVITY_PERM_ADMIN),
      'weight' => 2,
      'type' => MENU_LOCAL_TASK,
    );
  }
  else {

    // decay profile edit pages, cannot be cached
    if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'radioactivity' && substr(arg(3), 0, 8) == 'profile_' && is_numeric(substr(arg(3), 8))) {
      $decay_profile_id = substr(arg(3), 8);
      $decay_profiles = _radioactivity_get_decay_profiles();
      $decay_profile = $decay_profiles[$decay_profile_id];
      $items[] = array(
        'path' => 'admin/settings/radioactivity/profile_' . $decay_profile_id,
        'title' => t('Edit decay profile @label', array(
          '@label' => $decay_profile["label"],
        )),
        'description' => t('Configure settings for decay profile @label.', array(
          '@label' => $decay_profile["label"],
        )),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'radioactivity_admin_profile_form',
          $decay_profile_id,
        ),
        'access' => user_access(RADIOACTIVITY_PERM_ADMIN),
        'weight' => 3,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'admin/settings/radioactivity/profile_' . $decay_profile_id . '/delete',
        'title' => t('Delete profile'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'radioactivity_admin_delete_profile_form',
          $decay_profile_id,
        ),
        'access' => user_access(RADIOACTIVITY_PERM_ADMIN),
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}