You are here

function fpa_l in Fast Permissions Administration 6.2

Same name and namespace in other branches
  1. 7.2 fpa.module \fpa_l()
1 call to fpa_l()
fpa_fieldset in ./fpa.module

File

./fpa.module, line 24

Code

function fpa_l($permission = '', $text = NULL, $options = array()) {

  // available modal modules in order of priority
  $supported_modules = array(
    //'dialog', // dialog api is buggy
    'ctools',
    'modalframe',
  );
  if (is_null($text)) {
    $text = t('Manage Permissions');
  }

  // gets the most prefered modal method from the available methods
  $modules = array_intersect($supported_modules, array_keys(module_list()));
  $method = array_shift($modules);
  $path = 'fpa_modal/nojs/permissions';
  $attributes = array();
  $query = array(
    'fpa_perm' => $permission,
    'fpa_method' => $method,
  );
  switch ($method) {
    case 'dialog':
      dialog_add_js();
      $attributes['class'] = 'ctools-use-dialog';
      break;
    case 'ctools':
      ctools_include('ajax');
      ctools_include('modal');
      ctools_modal_add_js();
      $attributes['class'] = 'ctools-use-modal';
      break;
    case 'modalframe':
      modalframe_parent_js();
      drupal_add_js(drupal_get_path('module', 'fpa') . '/js/fpa.js', 'module');
      $attributes['class'] = 'fpa_modalframe';
      break;
    default:
      $path = 'admin/user/permissions';
      $attributes['target'] = '_blank';
      $query['fpa_method'] = '_blank';
      break;
  }
  $options = array_merge_recursive(array(
    'query' => $query,
    'attributes' => $attributes,
  ), $options);
  return l($text, $path, $options);
}