You are here

function _ajax_register_ajax_links in Ajax Login/Register 7.4

Return ajax links for user login, register or password request.

Parameters

$links_enabled: Array with possible links could be enabled ('login', 'register', 'password).

null $form_id: Form where this links are builded.

Return value

array List of ajax links.

2 calls to _ajax_register_ajax_links()
ajax_register_block_view in ./ajax_register.module
Implements hook_block_view().
ajax_register_form_alter in ./ajax_register.module
Implements hook_form_alter().

File

./ajax_register.module, line 379

Code

function _ajax_register_ajax_links($links_enabled, $form_id = NULL) {
  $links = array();

  // Build classes for ajax modal link.
  $classes = array();
  $classes[] = 'ctools-use-modal';
  $classes[] = 'ctools-modal-ctools-ajax-register-style';

  // Provide default options for ajax modal link.
  $options = array(
    'attributes' => array(
      'class' => $classes,
      'rel' => 'nofollow',
    ),
  );

  // Add login button.
  if (in_array('login', $links_enabled) && stripos($form_id, 'user_login') === FALSE) {
    $options['attributes']['title'] = t('Login');
    $links[] = l(t('Login'), 'ajax_register/login/nojs', $options);
  }

  // Add register button.
  $user_registration_allowed = variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
  if (in_array('register', $links_enabled) && $form_id != 'user_register_form' && $user_registration_allowed) {
    $options['attributes']['title'] = t('Create new account');
    $links[] = l(t('Create new account'), 'ajax_register/register/nojs', $options);
  }

  // Add request password button.
  if (in_array('password', $links_enabled) && $form_id != 'user_pass') {
    $options['attributes']['title'] = t('Request new password');
    $links[] = l(t('Request new password'), 'ajax_register/password/nojs', $options);
  }
  return $links;
}