summaryrefslogtreecommitdiff
path: root/modules/user
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-06-17 13:44:45 +0000
committerDries Buytaert <dries@buytaert.net>2010-06-17 13:44:45 +0000
commitcb043e8c489f033f7435e7fd5d18325155465c77 (patch)
tree716cdfe743aa99a01a1dce97cc800c00119af896 /modules/user
parent3620310d7c8a5d487f7b6826a89f8a4816149333 (diff)
downloadbrdo-cb043e8c489f033f7435e7fd5d18325155465c77.tar.gz
brdo-cb043e8c489f033f7435e7fd5d18325155465c77.tar.bz2
- Patch #735800 by effulgentsia, fago, Frando: node form triggers form level submit functions on button level submits, without validation. Oh yeah.
Diffstat (limited to 'modules/user')
-rw-r--r--modules/user/user.pages.inc25
1 files changed, 19 insertions, 6 deletions
diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc
index 32c20a4d7..24b9a2b72 100644
--- a/modules/user/user.pages.inc
+++ b/modules/user/user.pages.inc
@@ -243,6 +243,18 @@ function template_preprocess_user_profile_category(&$variables) {
function user_profile_form($form, &$form_state, $account, $category = 'account') {
global $user;
+ // During initial form build, add the entity to the form state for use during
+ // form building and processing. During a rebuild, use what is in the form
+ // state.
+ if (!isset($form_state['user'])) {
+ $form_state['user'] = $account;
+ }
+ else {
+ $account = $form_state['user'];
+ }
+
+ // @todo Legacy support. Modules are encouraged to access the entity using
+ // $form_state. Remove in Drupal 8.
$form['#user'] = $account;
$form['#user_category'] = $category;
@@ -278,22 +290,23 @@ function user_profile_form($form, &$form_state, $account, $category = 'account')
* Validation function for the user account and profile editing form.
*/
function user_profile_form_validate($form, &$form_state) {
- $edit = (object) $form_state['values'];
- field_attach_form_validate('user', $edit, $form, $form_state);
+ entity_form_field_validate('user', $form, $form_state);
}
/**
* Submit function for the user account and profile editing form.
*/
function user_profile_form_submit($form, &$form_state) {
- $account = $form['#user'];
+ $account = $form_state['user'];
$category = $form['#user_category'];
// Remove unneeded values.
form_state_values_clean($form_state);
- $edit = (object) $form_state['values'];
- field_attach_submit('user', $edit, $form, $form_state);
- $edit = (array) $edit;
+ entity_form_submit_build_entity('user', $account, $form, $form_state);
+
+ // Populate $edit with the properties of $account, which have been edited on
+ // this form by taking over all values, which appear in the form values too.
+ $edit = array_intersect_key((array) $account, $form_state['values']);
user_save($account, $edit, $category);
$form_state['values']['uid'] = $account->uid;