summaryrefslogtreecommitdiff
path: root/modules/user/user.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-07-04 16:50:02 +0000
committerDries Buytaert <dries@buytaert.net>2004-07-04 16:50:02 +0000
commitfe2b3e7c006a607c2b9fd9a485a7bda13515a94f (patch)
tree1c16960253df2c99488fdd8cf81305ff369884d4 /modules/user/user.module
parent353c05d01536aac26fec7e9cfee0e84838973286 (diff)
downloadbrdo-fe2b3e7c006a607c2b9fd9a485a7bda13515a94f.tar.gz
brdo-fe2b3e7c006a607c2b9fd9a485a7bda13515a94f.tar.bz2
- Patch by Steven and me: refactored the form handling of nodes. The node system is now using form_set_error() and friends like the rest of Drupal does. This makes for both a consistent user experience and consistent code. It simplifies the forms and validation code, however, it does change the node API slightly:
* The _validate hook and the _nodeapi('validate') hook of the node API (1) no longer take an 'error' parameter and (2) should no longer return an error array. To set an error, call form_set_error(). * The _form hook of the node module no longer takes a form hook and should not worry about displaying errors. Ditto for _nodeapi('form_post') and _nodeapi('form_pre').
Diffstat (limited to 'modules/user/user.module')
-rw-r--r--modules/user/user.module10
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 77f3cc3e9..f6bb5d443 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -940,7 +940,7 @@ function user_register($edit = array()) {
if ($edit) {
user_module_invoke('validate', $edit, $edit, 'account');
- if (!form_has_errors()) {
+ if (!form_get_errors()) {
$from = variable_get('site_mail', ini_get('sendmail_from'));
$pass = user_password();
@@ -1078,7 +1078,7 @@ function user_edit($category = 'account') {
if ($_POST['op'] == t('Save account')) {
user_module_invoke('validate', $edit, $account, $category);
- if (!form_has_errors()) {
+ if (!form_get_errors()) {
// Validate input to ensure that non-privileged users can't alter protected data.
if (!user_access('administer users') && array_intersect(array_keys($edit), array('uid', 'roles', 'init', 'session'))) {
watchdog('warning', 'detected malicious attempt to alter a protected database field');
@@ -1242,11 +1242,11 @@ function user_configure_settings() {
// Picture settings.
if (!file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')))) {
- $error = theme('error', t('The picture directory does not exist, or is not writable.'));
+ form_set_error('user_picture_path', t('The picture directory does not exist, or is not writable.'));
}
$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)) . $error);
+ $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)));
$group .= form_textfield(t('Default picture'), 'user_picture_default', variable_get('user_picture_default', ''), 45, 255, t('URL of picture to display for users with no custom picture selected. Leave blank for none.'));
$group .= form_textfield(t('Picture maximum dimensions'), 'user_picture_dimensions', variable_get('user_picture_dimensions', '85x85'), 10, 10, t('Maximum dimensions for pictures.'));
$group .= form_textfield(t('Picture maximum file size'), 'user_picture_file_size', variable_get('user_picture_file_size', '30'), 10, 10, t('Maximum file size for pictures, in kB.'));
@@ -1268,7 +1268,7 @@ function user_admin_create($edit = array()) {
if ($edit) {
user_module_invoke('validate', $edit, $edit, 'account');
- if (!form_has_errors()) {
+ if (!form_get_errors()) {
watchdog('user', 'new user: "'. $edit['name'] .'" &lt;'. $edit['mail'] .'&gt;');
user_save('', array('name' => $edit['name'], 'pass' => $edit['pass'], 'init' => $edit['mail'], 'mail' => $edit['mail'], 'roles' => array(_user_authenticated_id()), 'status' => 1));