diff options
Diffstat (limited to 'modules/user.module')
-rw-r--r-- | modules/user.module | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/modules/user.module b/modules/user.module index 6c89b24cc..ee8d41512 100644 --- a/modules/user.module +++ b/modules/user.module @@ -182,8 +182,8 @@ function user_validate_picture($file, &$edit, $user) { // Check that uploaded file is an image, with a maximum file size // and maximum height/width. - $extension = strtolower(strrchr($file->name, '.')); - $size = getimagesize($file->path); + $extension = strtolower(strrchr($file->filename, '.')); + $size = getimagesize($file->filepath); list($maxwidth, $maxheight) = explode('x', variable_get('user_picture_dimensions', '85x85')); if ((!in_array($size[2], array(1, 2, 3))) || (!in_array($extension, array('.gif', '.jpg', '.png', '.jpeg')))) { @@ -307,37 +307,13 @@ function user_mail($mail, $subject, $message, $header) { */ return mail( $mail, - user_mail_encode($subject), + mime_header_encode($subject), str_replace("\r", '', $message), "MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $header ); } } -function user_mail_encode($string, $charset = 'UTF-8') { - /* - ** Used to encodes mail headers that contain non US- ASCII - ** characters. - ** http://www.rfc-editor.org/rfc/rfc2047.txt - ** - ** Notes: - ** - Only encode strings that contain non-ASCII characters. - ** - The chunks come in groupings of 4 bytes when using base64 - ** encoded. - ** - trim() is used to ensure that no extra spacing is added by - ** chunk_split() or preg_replace(). - ** - Using \n as the chunk separator may cause problems on some - ** systems and may have to be changed to \r\n or \r. - */ - if (!preg_match('/^[\x20-\x7E]*$/', $string)) { - $chunk_size = 75 - 7 - strlen($charset); - $chunk_size -= $chunk_size % 4; - $string = trim(chunk_split(base64_encode($string), $chunk_size, "\n")); - $string = trim(preg_replace('/^(.*)$/m', " =?$charset?B?\\1?=", $string)); - } - return $string; -} - function user_deny($type, $mask) { $allow = db_fetch_object(db_query("SELECT * FROM {access} WHERE status = 1 AND type = '%s' AND LOWER('%s') LIKE LOWER(mask)", $type, $mask)); $deny = db_fetch_object(db_query("SELECT * FROM {access} WHERE status = 0 AND type = '%s' AND LOWER('%s') LIKE LOWER(mask)", $type, $mask)); @@ -1046,7 +1022,7 @@ function user_edit_validate($uid, &$edit) { // Validate the e-mail address: if ($error = user_validate_mail($edit['mail'])) { - form_set_error('mail', ucfirst($error)); + form_set_error('mail', $error); } else if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) { form_set_error('mail', t('The e-mail address "%s" is already taken.', array('%s' => $edit['mail']))); @@ -1247,9 +1223,7 @@ function user_configure_settings() { $output .= form_group(t('User email settings'), $group); // Picture settings. - if (!file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')))) { - form_set_error('user_picture_path', t('the picture directory does not exist, or is not writable.')); - } + file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')), 1, 'user_picture_path'); $group = form_radios(t('Picture support'), 'user_pictures', variable_get('user_pictures', 0), array(t('Disabled'), t('Enabled')), t('Enable picture support.')); $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR))); @@ -1351,8 +1325,15 @@ function user_admin_access($edit = array()) { return form($output); } -function user_roles($membersonly = 0) { - $result = db_query('SELECT * FROM {role} ORDER BY name'); +function user_roles($membersonly = 0, $permission = 0) { + $roles = array(); + + if ($permission) { + $result = db_query("SELECT r.* FROM {role} r INNER JOIN {permission} p ON r.rid = p.rid WHERE p.perm LIKE '%%%s%%' ORDER BY r.name", $permission); + } + else { + $result = db_query('SELECT * FROM {role} ORDER BY name'); + } while ($role = db_fetch_object($result)) { if (!$membersonly || ($membersonly && $role->name != 'anonymous user')) { $roles[$role->rid] = $role->name; |