Now all modules are in core modules folder

This commit is contained in:
Manuel Cillero 2017-08-08 12:14:45 +02:00
parent 5ba1cdfa0b
commit 05b6a91b0c
1907 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,58 @@
<?php
/**
* @file
* Module admin page callbacks.
*/
/****************************************************************************/
/* Password policy password tab settings */
/****************************************************************************/
/**
* Implements the settings page.
*
* @return
* The form structure.
*/
function password_policy_password_tab_admin_settings() {
$form = array();
// Attachments settings.
$form['password_tab'] = array('#type' => 'fieldset', '#title' => t('Password tab settings'), '#collapsible' => FALSE, '#collapsed' => FALSE);
$form['password_tab']['password_policy_password_tab_redirect'] = array(
'#type' => 'textfield',
'#title' => t('Redirect path on password change'),
'#default_value' => variable_get('password_policy_password_tab_redirect', ''),
'#description' => t('Normally, after a user changes their password, they will be taken to their user page. Leave this setting blank if you wish to keep the default behavior. If you wish the user to go to a page of your choosing, then enter the path for it here. For instance, you may redirect them to a static page such as <cite>node/35</cite>, or to the <cite>&lt;front&gt;</cite> page. You may also use <em>%uid</em> as a variable, and the user\'s user ID will be substituted in the path. In the case where users are first creating their own passwords, it is suggested to use <cite>user/%uid/edit</cite> here, so the user may set their over account information immediately after validating their account.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
);
return $form;
}
/**
* Submit hook for the settings form.
*/
function password_policy_password_tab_admin_settings_submit($form, &$form_state) {
$op = $form_state['clicked_button']['#value'];
$values = $form_state['values'];
switch ($op) {
case t('Save configuration'):
variable_set('password_policy_password_tab_redirect', $values['password_policy_password_tab_redirect']);
drupal_set_message(t('The configuration options have been saved.'));
break;
case t('Reset to defaults'):
variable_del('password_policy_password_tab_redirect');
drupal_set_message(t('The configuration options have been reset to their default values.'));
break;
}
}

View file

@ -0,0 +1,12 @@
name = Password change tab
description = Implements a separate password change tab.
package = Security
dependencies[] = password_policy
core = 6.x
; Information added by Drupal.org packaging script on 2015-03-31
version = "6.x-1.11"
core = "6.x"
project = "password_policy"
datestamp = "1427843284"

View file

@ -0,0 +1,39 @@
<?php
/**
* @file
* Password policy password tab module installation and upgrade code.
*/
/****************************************************************************/
/* Module installation/uninstallation */
/****************************************************************************/
/**
* Implements hook_install().
*/
function password_policy_password_tab_install() {
if (variable_get('password_policy_change_url', NULL) == NULL) {
variable_set('password_policy_change_url', 'password');
}
}
/**
* Implements hook_uninstall().
*/
function password_policy_password_tab_uninstall() {
variable_del('password_policy_password_tab_redirect');
if (variable_get('password_policy_change_url', NULL) == 'password') {
variable_del('password_policy_change_url');
}
}
/**
* Set default value for password change URL.
*/
function password_policy_password_tab_6001() {
if (variable_get('password_policy_change_url', NULL) == NULL) {
variable_set('password_policy_change_url', 'password');
}
}

View file

@ -0,0 +1,95 @@
<?php
/**
* @file
* The password policy password tab module adds a separate tab to change
* password.
*/
/****************************************************************************/
/* Core API hooks */
/****************************************************************************/
/**
* Implements hook_menu().
*/
function password_policy_password_tab_menu() {
return array(
'admin/settings/password_policy/password_tab' => array(
'title' => 'Password tab',
'page callback' => 'drupal_get_form',
'page arguments' => array('password_policy_password_tab_admin_settings'),
'access arguments' => array('administer site configuration'),
'file' => 'password_policy_password_tab.admin.inc',
),
'user/%user_category/edit/password' => array(
'title' => 'Password',
'page callback' => 'drupal_get_form',
'page arguments' => array('password_policy_password_tab', 1),
'access callback' => 'user_edit_access',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'load arguments' => array('%map', '%index'),
'file' => 'password_policy_password_tab.pages.inc',
),
);
}
/**
* Implements hook_user().
*/
function password_policy_password_tab_user($op, &$edit, &$account, $category = NULL) {
if ($op === 'categories') {
return array(array(
'name' => 'password',
'title' => t('Password'),
'weight' => 0,
));
}
}
/**
* Implements hook_form_alter().
*/
function password_policy_password_tab_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case "user_profile_form":
// Hide core password field from user edit form.
unset($form['account']['pass']);
// Also hide password field added by Password Confirm module.
if (module_exists('password_change')) {
unset($form['pass_current']);
}
break;
}
}
/**
* Implements hook_exit().
*
* This function acts on a drupal_goto from user_pass_reset form. The user is
* redirected to the password change tab instead of the account edit form.
*/
function password_policy_password_tab_exit($destination = NULL) {
static $processed = FALSE;
// Check if this is a drupal_goto from the password reset page.
if (!$processed && isset($destination) && arg(0) == 'user' && arg(1) == 'reset') {
$url_parts = parse_url($destination);
// Check if the redirect has a path.
if (isset($url_parts['path'])) {
// Check if the redirect path is user/%user/edit.
$path = drupal_substr($url_parts['path'], 1);
$args = arg(NULL, $path);
if (count($args) == 3 && $args[0] == 'user' && $args[2] == 'edit') {
// Prevent loops.
$processed = TRUE;
// Change the drupal_goto to our change password tab.
$path .= '/password';
$query = isset($url_parts['query']) ? $url_parts['query'] : NULL;
$fragment = isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL;
drupal_goto($path, $query, $fragment);
}
}
}
}

View file

@ -0,0 +1,63 @@
<?php
/**
* @file
* The password policy password tab page callbacks.
*/
/**
* Password change form.
*/
function password_policy_password_tab(&$form_state, $account) {
$form['_category'] = array('#type' => 'value', '#value' => 'account');
$form['_account'] = array('#type' => 'value', '#value' => $account);
$form['#uid'] = $account->uid;
$form['account']['pass'] = array(
'#type' => 'password_confirm',
'#description' => t('To change the current user password, enter the new password in both fields.'),
'#size' => 25,
'#required' => TRUE,
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Change'));
$form['#validate'] = array('password_policy_password_tab_validate');
$form['#submit'] = array('password_policy_password_tab_submit');
// Show password field added by Password Change module.
if (module_exists('password_change')) {
password_change_form_user_profile_form_alter($form, $form_state);
}
password_policy_form_alter($form, array(), 'user_profile_form');
return $form;
}
/**
* Password change form validation.
*/
function password_policy_password_tab_validate($form, &$form_state) {
$values = $form_state['values'];
$pass = trim($values['pass']);
if (empty($pass)) {
form_set_error('pass', t('Your password cannot be empty.'));
}
}
/**
* Password change form submit.
*/
function password_policy_password_tab_submit($form, &$form_state) {
$account = $form['_account']['#value'];
user_module_invoke('submit', $form_state['values'], $account, 'account');
user_save($account, array('pass' => $form_state['values']['pass']));
drupal_set_message(t('Password has been changed.'));
if (variable_get('password_policy_password_tab_redirect', '') && !preg_match('/[?&]destination=/', $form['#action'])) {
global $user;
$redirect = parse_url(urldecode(strtr(variable_get('password_policy_password_tab_redirect', ''), array('%uid' => $user->uid))));
$form_state['redirect'] = array($redirect['path'], isset($redirect['query']) ? $redirect['query'] : NULL, isset($redirect['fragment']) ? $redirect['fragment'] : NULL);
}
}