Skip to content
Snippets Groups Projects
Commit cfd1dbe6 authored by harish137's avatar harish137 Committed by Neslee
Browse files

Issue #2804771 by harish b: noreqnewpass|coder review|Drupal code standards missing

parent c3181355
No related branches found
No related tags found
No related merge requests found
......@@ -3,18 +3,18 @@
/**
* Implementation of hook_menu().
*/
function noreqnewpass_menu () {
function noreqnewpass_menu() {
$items = array();
$items['admin/people/noreqnewpass'] = array(
'title' => t('No Request New Password'),
'description' => t('Manage password preferences'),
'title' => 'No Request New Password',
'description' => 'Manage password preferences',
'access arguments' => array('administer noreqnewpass'),
'page callback' => 'drupal_get_form',
'page arguments' => array('noreqnewpass_admin_form'),
'page arguments' => array('noreqnewpass_admin_form'),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
......@@ -48,29 +48,28 @@ function noreqnewpass_permission() {
);
}
/**
* Implementation of hook_form_alter().
*/
function noreqnewpass_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'user_login_block' && variable_get('noreqnewpass_disabled', true)) {
if ($form_id == 'user_login_block' && variable_get('noreqnewpass_disabled', TRUE)) {
$items = array();
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
$items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
}
$form['links'] = array('#markup' => theme('item_list', array('items' => $items)));
}
if (($form_id == 'user_login_block' || $form_id == 'user_login') && variable_get('noreqnewpass_disabled', true)) {
if (($form_id == 'user_login_block' || $form_id == 'user_login') && variable_get('noreqnewpass_disabled', TRUE)) {
$key = array_search('user_login_final_validate', $form['#validate']);
$form['#validate'][$key] = 'noreqnewpass_user_login_final_validate';
}
// Remove pass field from user edit form if he cant change
if ($form_id == 'user_profile_form' && !user_access("can change your own password")) {
$form['account']['current_pass']['#access'] = false;
$form['account']['pass']['#access'] = false;
$form['account']['current_pass']['#access'] = FALSE;
$form['account']['pass']['#access'] = FALSE;
}
}
......@@ -81,18 +80,17 @@ function noreqnewpass_form_alter(&$form, $form_state, $form_id) {
*/
function noreqnewpass_admin_form() {
$form = array();
$form['noreqnewpass_disabled'] = array(
'#title' => t('Disable Request new password link'),
'#type' => 'checkbox',
'#default_value' => variable_get('noreqnewpass_disabled', true),
'#default_value' => variable_get('noreqnewpass_disabled', TRUE),
'#description' => t('If checked, Request new password link will be disabled.')
);
return system_settings_form($form);
}
/**
* Just for remove request password url at error messages.
*/
......
<?php
/*
* @file
*/
class NoreqnewpassMenuTestCase extends DrupalWebTestCase {
public static function getInfo() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment