You are here

function uc_file_menu in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_file/uc_file.module \uc_file_menu()
  2. 7.3 uc_file/uc_file.module \uc_file_menu()

Implementation of hook_menu().

File

uc_file/uc_file.module, line 37
Allows products to be associated with downloadable files.

Code

function uc_file_menu($may_cache) {
  global $user;
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => '_autocomplete_file',
      'callback' => '_autocomplete_filename',
      'access' => user_access('administer product features'),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/store/products/files',
      'callback' => 'uc_file_files_admin',
      'title' => t('View file downloads'),
      'description' => t('View all file download features on products.'),
      'access' => user_access('administer products'),
      'type' => MENU_NORMAL_ITEM,
    );
  }
  else {
    if (module_exists('uc_notify')) {
      $items[] = array(
        'path' => 'admin/store/settings/notify/edit/file',
        'title' => t('File download'),
        'access' => user_access('administer store'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'uc_file_notify_settings',
        ),
        'description' => t('Edit the notification settings for purchased file downloads.'),
        'type' => MENU_LOCAL_TASK,
      );
    }
    $items[] = array(
      'path' => 'user/' . arg(1) . '/files',
      'title' => t('Files'),
      'description' => t('View your purchased files.'),
      'callback' => 'uc_file_user_downloads',
      'callback arguments' => array(
        arg(1),
      ),
      'access' => (user_access('view all downloads') || $user->uid == arg(1)) && $user->uid,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'download/' . arg(1) . '/' . arg(2),
      'callback' => '_file_download',
      'callback arguments' => array(
        arg(1),
        arg(2),
      ),
      'access' => user_access('download file'),
      'type' => MENU_CALLBACK,
    );
    drupal_add_css(drupal_get_path('module', 'uc_file') . '/uc_file.css');
  }
  return $items;
}