loadForm('com_admin.profile', 'profile', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } if (!JComponentHelper::getParams('com_users')->get('change_login_name')) { $form->setFieldAttribute('username', 'required', 'false'); $form->setFieldAttribute('username', 'readonly', 'true'); $form->setFieldAttribute('username', 'description', 'COM_ADMIN_USER_FIELD_NOCHANGE_USERNAME_DESC'); } return $form; } /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_users.edit.user.data', array()); if (empty($data)) { $data = $this->getItem(); } // Load the users plugins. JPluginHelper::importPlugin('user'); $this->preprocessData('com_admin.profile', $data); return $data; } /** * Method to get a single record. * * @return mixed Object on success, false on failure. * * @since 1.6 */ public function getItem($pk = null) { $user = JFactory::getUser(); return parent::getItem($user->get('id')); } /** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @since 1.6 */ public function save($data) { $user = JFactory::getUser(); unset($data['id']); unset($data['groups']); unset($data['sendEmail']); unset($data['block']); // Bind the data. if (!$user->bind($data)) { $this->setError($user->getError()); return false; } $user->groups = null; // Store the data. if (!$user->save()) { $this->setError($user->getError()); return false; } $this->setState('user.id', $user->id); return true; } }