summaryrefslogtreecommitdiff
path: root/modules/user/user.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user/user.module')
-rw-r--r--modules/user/user.module90
1 files changed, 45 insertions, 45 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 4b6c65ae2..9314ccd32 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -17,7 +17,7 @@ define('EMAIL_MAX_LENGTH', 64);
*/
function user_module_invoke($type, &$array, &$user, $category = NULL) {
foreach (module_list() as $module) {
- $function = $module .'_user';
+ $function = $module . '_user';
if (function_exists($function)) {
$function($type, $array, $user, $category);
}
@@ -164,7 +164,7 @@ function user_load($array = array()) {
$params[] = $value;
}
}
- $result = db_query('SELECT * FROM {users} u WHERE '. implode(' AND ', $query), $params);
+ $result = db_query('SELECT * FROM {users} u WHERE ' . implode(' AND ', $query), $params);
if ($user = db_fetch_object($result)) {
$user = drupal_unpack($user);
@@ -354,14 +354,14 @@ function user_validate_name($name) {
if (substr($name, -1) == ' ') return t('The username cannot end with a space.');
if (strpos($name, ' ') !== FALSE) return t('The username cannot contain multiple spaces in a row.');
if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.');
- if (preg_match('/[\x{80}-\x{A0}'. // Non-printable ISO-8859-1 + NBSP
- '\x{AD}'. // Soft-hyphen
- '\x{2000}-\x{200F}'. // Various space characters
- '\x{2028}-\x{202F}'. // Bidirectional text overrides
- '\x{205F}-\x{206F}'. // Various text hinting characters
- '\x{FEFF}'. // Byte order mark
- '\x{FF01}-\x{FF60}'. // Full-width latin
- '\x{FFF9}-\x{FFFD}'. // Replacement characters
+ if (preg_match('/[\x{80}-\x{A0}' . // Non-printable ISO-8859-1 + NBSP
+ '\x{AD}' . // Soft-hyphen
+ '\x{2000}-\x{200F}' . // Various space characters
+ '\x{2028}-\x{202F}' . // Bidirectional text overrides
+ '\x{205F}-\x{206F}' . // Various text hinting characters
+ '\x{FEFF}' . // Byte order mark
+ '\x{FF01}-\x{FF60}' . // Full-width latin
+ '\x{FFF9}-\x{FFFD}' . // Replacement characters
'\x{0}]/u', // NULL byte
$name)) {
return t('The username contains an illegal character.');
@@ -394,7 +394,7 @@ function user_validate_picture(&$form, &$form_state) {
// files table as a temporary file. We'll make a copy and let the garbage
// collector delete the original upload.
$info = image_get_info($file->filepath);
- $destination = variable_get('user_picture_path', 'pictures') .'/picture-'. $form['#uid'] .'.'. $info['extension'];
+ $destination = variable_get('user_picture_path', 'pictures') . '/picture-' . $form['#uid'] . '.' . $info['extension'];
if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
$form_state['values']['picture'] = $file->filepath;
}
@@ -470,7 +470,7 @@ function user_access($string, $account = NULL, $reset = FALSE) {
// To reduce the number of SQL queries, we cache the user's permissions
// in a static variable.
if (!isset($perm[$account->uid])) {
- $result = db_query("SELECT p.perm FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (". db_placeholders($account->roles) .")", array_keys($account->roles));
+ $result = db_query("SELECT p.perm FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (" . db_placeholders($account->roles) . ")", array_keys($account->roles));
$perms = array();
while ($row = db_fetch_object($result)) {
@@ -511,9 +511,9 @@ function user_perm() {
* Ensure that user pictures (avatars) are always downloadable.
*/
function user_file_download($file) {
- if (strpos($file, variable_get('user_picture_path', 'pictures') .'/picture-') === 0) {
+ if (strpos($file, variable_get('user_picture_path', 'pictures') . '/picture-') === 0) {
$info = image_get_info(file_create_path($file));
- return array('Content-type: '. $info['mime_type']);
+ return array('Content-type: ' . $info['mime_type']);
}
}
@@ -535,13 +535,13 @@ function user_search($op = 'search', $keys = NULL, $skip_access_check = FALSE) {
// Administrators can also search in the otherwise private email field.
$result = pager_query("SELECT name, uid, mail FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%') OR LOWER(mail) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys, $keys);
while ($account = db_fetch_object($result)) {
- $find[] = array('title' => $account->name .' ('. $account->mail .')', 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
+ $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE)));
}
}
else {
$result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
while ($account = db_fetch_object($result)) {
- $find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
+ $find[] = array('title' => $account->name, 'link' => url('user/' . $account->uid, array('absolute' => TRUE)));
}
}
return $find;
@@ -1011,7 +1011,7 @@ function user_menu() {
foreach ($categories as $key => $category) {
// 'account' is already handled by the MENU_DEFAULT_LOCAL_TASK.
if ($category['name'] != 'account') {
- $items['user/%user_category/edit/'. $category['name']] = array(
+ $items['user/%user_category/edit/' . $category['name']] = array(
'title callback' => 'check_plain',
'title arguments' => array($category['title']),
'page callback' => 'user_edit',
@@ -1031,7 +1031,7 @@ function user_menu() {
}
function user_init() {
- drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
+ drupal_add_css(drupal_get_path('module', 'user') . '/user.css', 'module');
}
function user_current_load($arg) {
@@ -1153,7 +1153,7 @@ function user_login(&$form_state) {
// If we are already logged on, go to the user page instead.
if ($user->uid) {
- drupal_goto('user/'. $user->uid);
+ drupal_goto('user/' . $user->uid);
}
// Display login form:
@@ -1296,7 +1296,7 @@ function user_authenticate_finalize(&$edit) {
function user_login_submit($form, &$form_state) {
global $user;
if ($user->uid) {
- $form_state['redirect'] = 'user/'. $user->uid;
+ $form_state['redirect'] = 'user/' . $user->uid;
return;
}
}
@@ -1327,13 +1327,13 @@ function user_external_login_register($name, $module) {
}
user_set_authmaps($account, array("authname_$module" => $name));
$user = $account;
- watchdog('user', 'New external user: %name using module %module.', array('%name' => $name, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
+ watchdog('user', 'New external user: %name using module %module.', array('%name' => $name, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $user->uid . '/edit'));
}
}
function user_pass_reset_url($account) {
$timestamp = time();
- return url("user/reset/$account->uid/$timestamp/". user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
+ return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
}
function user_pass_rehash($password, $timestamp, $login) {
@@ -1441,7 +1441,7 @@ function user_edit_form(&$form_state, $uid, $edit, $register = FALSE) {
else {
$form['picture']['picture_delete'] = array('#type' => 'hidden');
}
- $form['picture']['picture_upload'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', ''));
+ $form['picture']['picture_upload'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) . ' ' . variable_get('user_picture_guidelines', ''));
$form['#validate'][] = 'user_validate_picture';
}
$form['#uid'] = $uid;
@@ -1497,7 +1497,7 @@ function user_delete($edit, $uid) {
db_query('DELETE FROM {users} WHERE uid = %d', $uid);
db_query('DELETE FROM {users_roles} WHERE uid = %d', $uid);
db_query('DELETE FROM {authmap} WHERE uid = %d', $uid);
- $variables = array('%name' => $account->name, '%email' => '<'. $account->mail .'>');
+ $variables = array('%name' => $account->name, '%email' => '<' . $account->mail . '>');
watchdog('user', 'Deleted user: %name %email.', $variables, WATCHDOG_NOTICE);
module_invoke_all('user', 'delete', $edit, $account);
}
@@ -1526,8 +1526,8 @@ function user_build_content(&$account) {
function user_mail($key, &$message, $params) {
$language = $message['language'];
$variables = user_mail_tokens($params['account'], $language);
- $message['subject'] .= _user_mail_text($key .'_subject', $language, $variables);
- $message['body'][] = _user_mail_text($key .'_body', $language, $variables);
+ $message['subject'] .= _user_mail_text($key . '_subject', $language, $variables);
+ $message['body'][] = _user_mail_text($key . '_body', $language, $variables);
}
/**
@@ -1538,7 +1538,7 @@ function user_mail($key, &$message, $params) {
function _user_mail_text($key, $language = NULL, $variables = array()) {
$langcode = isset($language) ? $language->language : NULL;
- if ($admin_setting = variable_get('user_mail_'. $key, FALSE)) {
+ if ($admin_setting = variable_get('user_mail_' . $key, FALSE)) {
// An admin setting overrides the default string.
return strtr($admin_setting, $variables);
}
@@ -1653,12 +1653,12 @@ function user_user_operations($form_state = array()) {
$add_roles = array();
foreach ($roles as $key => $value) {
- $add_roles['add_role-'. $key] = $value;
+ $add_roles['add_role-' . $key] = $value;
}
$remove_roles = array();
foreach ($roles as $key => $value) {
- $remove_roles['remove_role-'. $key] = $value;
+ $remove_roles['remove_role-' . $key] = $value;
}
if (count($roles)) {
@@ -1763,7 +1763,7 @@ function user_multiple_delete_confirm(&$form_state) {
// array_filter() returns only elements with TRUE values.
foreach (array_filter($edit['accounts']) as $uid => $value) {
$user = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid));
- $form['accounts'][$uid] = array('#type' => 'hidden', '#value' => $uid, '#prefix' => '<li>', '#suffix' => check_plain($user) ."</li>\n");
+ $form['accounts'][$uid] = array('#type' => 'hidden', '#value' => $uid, '#prefix' => '<li>', '#suffix' => check_plain($user) . "</li>\n");
}
$form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
@@ -1792,18 +1792,18 @@ function user_help($path, $arg) {
switch ($path) {
case 'admin/help#user':
- $output = '<p>'. t('The user module allows users to register, login, and log out. Users benefit from being able to sign on because it associates content they create with their account and allows various permissions to be set for their roles. The user module supports user roles which establish fine grained permissions allowing each role to do only what the administrator wants them to. Each user is assigned to one or more roles. By default there are two roles <em>anonymous</em> - a user who has not logged in, and <em>authenticated</em> a user who has signed up and who has been authorized.') .'</p>';
- $output .= '<p>'. t("Users can use their own name or handle and can specify personal configuration settings through their individual <em>My account</em> page. Users must authenticate by supplying a local username and password or through their OpenID, an optional and secure method for logging into many websites with a single username and password. In some configurations, users may authenticate using a username and password from another Drupal site, or through some other site-specific mechanism.") .'</p>';
- $output .= '<p>'. t('A visitor accessing your website is assigned a unique ID, or session ID, which is stored in a cookie. The cookie does not contain personal information, but acts as a key to retrieve information from your site. Users should have cookies enabled in their web browser when using your site.') .'</p>';
- $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@user">User module</a>.', array('@user' => 'http://drupal.org/handbook/modules/user/')) .'</p>';
+ $output = '<p>' . t('The user module allows users to register, login, and log out. Users benefit from being able to sign on because it associates content they create with their account and allows various permissions to be set for their roles. The user module supports user roles which establish fine grained permissions allowing each role to do only what the administrator wants them to. Each user is assigned to one or more roles. By default there are two roles <em>anonymous</em> - a user who has not logged in, and <em>authenticated</em> a user who has signed up and who has been authorized.') . '</p>';
+ $output .= '<p>' . t("Users can use their own name or handle and can specify personal configuration settings through their individual <em>My account</em> page. Users must authenticate by supplying a local username and password or through their OpenID, an optional and secure method for logging into many websites with a single username and password. In some configurations, users may authenticate using a username and password from another Drupal site, or through some other site-specific mechanism.") . '</p>';
+ $output .= '<p>' . t('A visitor accessing your website is assigned a unique ID, or session ID, which is stored in a cookie. The cookie does not contain personal information, but acts as a key to retrieve information from your site. Users should have cookies enabled in their web browser when using your site.') . '</p>';
+ $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@user">User module</a>.', array('@user' => 'http://drupal.org/handbook/modules/user/')) . '</p>';
return $output;
case 'admin/user/user':
- return '<p>'. t('Drupal allows users to register, login, log out, maintain user profiles, etc. Users of the site may not use their own names to post content until they have signed up for a user account.') .'</p>';
+ return '<p>' . t('Drupal allows users to register, login, log out, maintain user profiles, etc. Users of the site may not use their own names to post content until they have signed up for a user account.') . '</p>';
case 'admin/user/user/create':
case 'admin/user/user/account/create':
- return '<p>'. t("This web page allows administrators to register new users. Users' e-mail addresses and usernames must be unique.") .'</p>';
+ return '<p>' . t("This web page allows administrators to register new users. Users' e-mail addresses and usernames must be unique.") . '</p>';
case 'admin/user/permissions':
- return '<p>'. t('Permissions let you control what users can do on your site. Each user role (defined on the <a href="@role">user roles page</a>) has its own set of permissions. For example, you could give users classified as "Administrators" permission to "administer nodes" but deny this power to ordinary, "authenticated" users. You can use permissions to reveal new features to privileged users (those with subscriptions, for example). Permissions also allow trusted users to share the administrative burden of running a busy site.', array('@role' => url('admin/user/roles'))) .'</p>';
+ return '<p>' . t('Permissions let you control what users can do on your site. Each user role (defined on the <a href="@role">user roles page</a>) has its own set of permissions. For example, you could give users classified as "Administrators" permission to "administer nodes" but deny this power to ordinary, "authenticated" users. You can use permissions to reveal new features to privileged users (those with subscriptions, for example). Permissions also allow trusted users to share the administrative burden of running a busy site.', array('@role' => url('admin/user/roles'))) . '</p>';
case 'admin/user/roles':
return t('<p>Roles allow you to fine tune the security and administration of Drupal. A role defines a group of users that have certain privileges as defined in <a href="@permissions">user permissions</a>. Examples of roles include: anonymous user, authenticated user, moderator, administrator and so on. In this area you will define the <em>role names</em> of the various roles. To delete a role choose "edit".</p><p>By default, Drupal comes with two user roles:</p>
<ul>
@@ -1811,7 +1811,7 @@ function user_help($path, $arg) {
<li>Authenticated user: this role is automatically granted to all logged in users.</li>
</ul>', array('@permissions' => url('admin/user/permissions')));
case 'admin/user/search':
- return '<p>'. t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username or e-mail address. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda@example.com".') .'</p>';
+ return '<p>' . t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username or e-mail address. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda@example.com".') . '</p>';
}
}
@@ -1906,8 +1906,8 @@ function user_build_filter_query() {
$args[] = $value;
$join[] = $filters[$key]['join'];
}
- $where = !empty($where) ? 'AND '. implode(' AND ', $where) : '';
- $join = !empty($join) ? ' '. implode(' ', array_unique($join)) : '';
+ $where = !empty($where) ? 'AND ' . implode(' AND ', $where) : '';
+ $join = !empty($join) ? ' ' . implode(' ', array_unique($join)) : '';
return array('where' => $where,
'join' => $join,
@@ -1979,7 +1979,7 @@ function user_mail_tokens($account, $language) {
'!mailto' => $account->mail,
'!date' => format_date(time(), 'medium', '', NULL, $language->language),
'!login_uri' => url('user', array('absolute' => TRUE, 'language' => $language)),
- '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE, 'language' => $language)),
+ '!edit_uri' => url('user/' . $account->uid . '/edit', array('absolute' => TRUE, 'language' => $language)),
);
if (!empty($account->password)) {
$tokens['!password'] = $account->password;
@@ -2038,7 +2038,7 @@ function user_preferred_language($account, $default = NULL) {
function _user_mail_notify($op, $account, $language = NULL) {
// By default, we always notify except for deleted and blocked.
$default_notify = ($op != 'status_deleted' && $op != 'status_blocked');
- $notify = variable_get('user_mail_'. $op .'_notify', $default_notify);
+ $notify = variable_get('user_mail_' . $op . '_notify', $default_notify);
if ($notify) {
$params['account'] = $account;
$language = $language ? $language : user_preferred_language($account);
@@ -2064,7 +2064,7 @@ function _user_password_dynamic_validation() {
global $user;
// Only need to do once per page.
if (!$complete) {
- drupal_add_js(drupal_get_path('module', 'user') .'/user.js', 'module');
+ drupal_add_js(drupal_get_path('module', 'user') . '/user.js', 'module');
drupal_add_js(array(
'password' => array(
@@ -2202,7 +2202,7 @@ function user_register_submit($form, &$form_state) {
}
$form_state['user'] = $account;
- watchdog('user', 'New user: %name (%email).', array('%name' => $name, '%email' => $mail), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));
+ watchdog('user', 'New user: %name (%email).', array('%name' => $name, '%email' => $mail), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $account->uid . '/edit'));
// The first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) {
@@ -2270,7 +2270,7 @@ function user_register() {
// If we aren't admin but already logged on, go to the user page instead.
if (!$admin && $user->uid) {
- drupal_goto('user/'. $user->uid);
+ drupal_goto('user/' . $user->uid);
}
$form = array();