You are here

function fpa_l in Fast Permissions Administration 7.2

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

File

./fpa.module, line 76
Main module file for FPA.

Code

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

  // Available modal module system names in order of priority.
  $supported_modules = array(
    'ctools',
  );
  if (is_null($text)) {
    $text = t('Manage Permissions');
  }

  // Find the most preferred modal method from the available methods.
  $modules = array_intersect($supported_modules, array_keys(module_list()));
  $method = array_shift($modules);
  $path = 'fpa_modal/nojs/permissions';
  $query = array(
    'fpa_perm' => $permission,
    'fpa_method' => $method,
  );
  $attributes = array();
  switch ($method) {
    case 'ctools':
      ctools_include('ajax');
      ctools_include('modal');
      ctools_modal_add_js();
      $attributes['class'] = 'ctools-use-modal';
      break;
    default:
      $path = 'admin/people/permissions';
      $attributes['target'] = '_blank';
      $query['fpa_method'] = '_blank';
      break;
  }
  $options = array_merge_recursive(array(
    'query' => $query,
    'attributes' => $attributes,
  ), $options);
  return l($text, $path, $options);
}