@@ -958,6 +958,8 @@ function user_search_access() {
|
||||
*/
|
||||
function user_search_execute($keys = NULL, $conditions = NULL) {
|
||||
$find = array();
|
||||
// Escape for LIKE matching.
|
||||
$keys = db_like($keys);
|
||||
// Replace wildcards with MySQL/PostgreSQL wildcards.
|
||||
$keys = preg_replace('!\*+!', '%', $keys);
|
||||
$query = db_select('users')->extend('PagerDefault');
|
||||
@@ -967,13 +969,13 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
|
||||
// and they don't need to be restricted to only active users.
|
||||
$query->fields('users', array('mail'));
|
||||
$query->condition(db_or()->
|
||||
condition('name', '%' . db_like($keys) . '%', 'LIKE')->
|
||||
condition('mail', '%' . db_like($keys) . '%', 'LIKE'));
|
||||
condition('name', '%' . $keys . '%', 'LIKE')->
|
||||
condition('mail', '%' . $keys . '%', 'LIKE'));
|
||||
}
|
||||
else {
|
||||
// Regular users can only search via usernames, and we do not show them
|
||||
// blocked accounts.
|
||||
$query->condition('name', '%' . db_like($keys) . '%', 'LIKE')
|
||||
$query->condition('name', '%' . $keys . '%', 'LIKE')
|
||||
->condition('status', 1);
|
||||
}
|
||||
$uids = $query
|
||||
@@ -1306,10 +1308,12 @@ function user_user_presave(&$edit, $account, $category) {
|
||||
elseif (!empty($edit['picture_delete'])) {
|
||||
$edit['picture'] = NULL;
|
||||
}
|
||||
// Prepare user roles.
|
||||
if (isset($edit['roles'])) {
|
||||
$edit['roles'] = array_filter($edit['roles']);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out roles with empty values to avoid granting extra roles when
|
||||
// processing custom form submissions.
|
||||
if (isset($edit['roles'])) {
|
||||
$edit['roles'] = array_filter($edit['roles']);
|
||||
}
|
||||
|
||||
// Move account cancellation information into $user->data.
|
||||
@@ -1911,13 +1915,13 @@ function user_menu_link_alter(&$link) {
|
||||
// for authenticated users. Authenticated users should see "My account", but
|
||||
// anonymous users should not see it at all. Therefore, invoke
|
||||
// user_translated_menu_link_alter() to conditionally hide the link.
|
||||
if ($link['link_path'] == 'user' && $link['module'] == 'system') {
|
||||
if ($link['link_path'] == 'user' && isset($link['module']) && $link['module'] == 'system') {
|
||||
$link['options']['alter'] = TRUE;
|
||||
}
|
||||
|
||||
// Force the Logout link to appear on the top-level of 'user-menu' menu by
|
||||
// default (i.e., unless it has been customized).
|
||||
if ($link['link_path'] == 'user/logout' && $link['module'] == 'system' && empty($link['customized'])) {
|
||||
if ($link['link_path'] == 'user/logout' && isset($link['module']) && $link['module'] == 'system' && empty($link['customized'])) {
|
||||
$link['plid'] = 0;
|
||||
}
|
||||
}
|
||||
@@ -2225,7 +2229,11 @@ function user_login_final_validate($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password', array('query' => array('name' => $form_state['values']['name']))))));
|
||||
// Use $form_state['input']['name'] here to guarantee that we send
|
||||
// exactly what the user typed in. $form_state['values']['name'] may have
|
||||
// been modified by validation handlers that ran earlier than this one.
|
||||
$query = isset($form_state['input']['name']) ? array('name' => $form_state['input']['name']) : array();
|
||||
form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password', array('query' => $query)))));
|
||||
watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_state['values']['name']));
|
||||
}
|
||||
}
|
||||
@@ -2488,7 +2496,9 @@ function user_cancel($edit, $uid, $method) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Last batch processing step for cancelling a user account.
|
||||
* Implements callback_batch_operation().
|
||||
*
|
||||
* Last step for cancelling a user account.
|
||||
*
|
||||
* Since batch and session API require a valid user account, the actual
|
||||
* cancellation of a user account needs to happen last.
|
||||
@@ -2536,6 +2546,8 @@ function _user_cancel($edit, $account, $method) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Finished batch processing callback for cancelling a user account.
|
||||
*
|
||||
* @see user_cancel()
|
||||
@@ -3039,6 +3051,11 @@ function user_role_delete($role) {
|
||||
$role = user_role_load_by_name($role);
|
||||
}
|
||||
|
||||
// If this is the administrator role, delete the user_admin_role variable.
|
||||
if ($role->rid == variable_get('user_admin_role')) {
|
||||
variable_del('user_admin_role');
|
||||
}
|
||||
|
||||
db_delete('role')
|
||||
->condition('rid', $role->rid)
|
||||
->execute();
|
||||
@@ -3654,12 +3671,7 @@ function user_form_process_password_confirm($element) {
|
||||
);
|
||||
|
||||
$element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
|
||||
// Ensure settings are only added once per page.
|
||||
static $already_added = FALSE;
|
||||
if (!$already_added) {
|
||||
$already_added = TRUE;
|
||||
$element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting');
|
||||
}
|
||||
$element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting');
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user