/** * Saves changes to user record. You must make sure all required user fields are set before calling this method. If errors occur you can use the standard Table class error handling methods to figure out what went wrong. * * Required fields are user_name, password, fname and lname. * * If you do not call this method at the end of your request changed user vars will not be saved! If you are also using the Auth class, the Auth->close() method will call this for you. * * @access public * @return bool Returns true if no error, false if error occurred */ public function update($pa_options = null) { $this->clearErrors(); if ($this->changed('email')) { if (!caCheckEmailAddress($this->get('email'))) { $this->postError(922, _t("Invalid email address"), 'ca_users->update()'); return false; } } if ($this->changed('password')) { try { $vs_backend_password = AuthenticationManager::updatePassword($this->get('user_name'), $this->get('password')); $this->set('password', $vs_backend_password); $this->removePendingPasswordReset(true); } catch (AuthClassFeatureException $e) { $this->postError(922, $e->getMessage(), 'ca_users->update()'); return false; // maybe don't barf here? } } # set user vars (the set() method automatically serializes the vars array) if ($this->opa_user_vars_have_changed) { $this->set("vars", $this->opa_user_vars); } if ($this->opa_volatile_user_vars_have_changed) { $this->set("volatile_vars", $this->opa_volatile_user_vars); } unset(ca_users::$s_user_role_cache[$this->getPrimaryKey()]); unset(ca_users::$s_group_role_cache[$this->getPrimaryKey()]); return parent::update(); }