Source for file profile.php
Documentation is available at profile.php
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Profile model class for Users.
* @var object The user profile data.
parent::__construct($config);
// Load the Joomla! RAD layer
// Load the helper and model used for two factor authentication
* Method to check in a user.
* @param integer The id of the row to check out.
* @return boolean True on success, false on failure.
public function checkin($userId =
null)
$userId =
(!empty($userId)) ?
$userId : (int)
$this->getState('user.id');
// Initialise the table with JUser.
// Attempt to check the row in.
if (!$table->checkin($userId))
* Method to check out a user for editing.
* @param integer The id of the row to check out.
* @return boolean True on success, false on failure.
public function checkout($userId =
null)
$userId =
(!empty($userId)) ?
$userId : (int)
$this->getState('user.id');
// Initialise the table with JUser.
// Get the current user object.
// Attempt to check the row out.
if (!$table->checkout($user->get('id'), $userId))
* Method to get the profile form data.
* The base form data is loaded and then an event is fired
* for users plugins to extend the data.
* @return mixed Data object on success, false on failure.
if ($this->data ===
null) {
// Initialise the table with JUser.
// Set the base user data.
$this->data->email1 =
$this->data->get('email');
$this->data->email2 =
$this->data->get('email');
// Override the base user data with any data in the session.
foreach ($temp as $k =>
$v)
unset
($this->data->password1);
unset
($this->data->password2);
$this->data->params =
$registry->toArray();
// Get the dispatcher and load the users plugins.
// Trigger the data preparation event.
$results =
$dispatcher->trigger('onContentPrepareData', array('com_users.profile', $this->data));
// Check for errors encountered while preparing the data.
$this->setError($dispatcher->getError());
* Method to get the profile form.
* The base form is loaded from XML and then an event is fired
* for users plugins to extend the form with extra fields.
* @param array $data An optional array of data for the form to interogate.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return JForm A JForm object on success, false on failure
public function getForm($data =
array(), $loadData =
true)
$form =
$this->loadForm('com_users.profile', 'profile', array('control' =>
'jform', 'load_data' =>
$loadData));
// Check for username compliance and parameter set
$isUsernameCompliant =
true;
$this->setState('user.username.compliant', $isUsernameCompliant);
if (!JComponentHelper::getParams('com_users')->get('change_login_name') &&
$isUsernameCompliant)
$form->setFieldAttribute('username', 'class', '');
$form->setFieldAttribute('username', 'filter', '');
$form->setFieldAttribute('username', 'description', 'COM_USERS_PROFILE_NOCHANGE_USERNAME_DESC');
$form->setFieldAttribute('username', 'validate', '');
$form->setFieldAttribute('username', 'message', '');
$form->setFieldAttribute('username', 'readonly', 'true');
$form->setFieldAttribute('username', 'required', 'false');
* Method to get the data that should be injected in the form.
* @return mixed The data for the form.
* Override preprocessForm to load the user plugin group instead of content.
* @param object A form object.
* @param mixed The data expected for the form.
* @throws Exception if there is an error in the form event.
protected function preprocessForm(JForm $form, $data, $group =
'user')
$form->loadFile('frontend', false);
$form->loadFile('frontend_admin', false);
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
// Get the application object.
$userId =
!empty($userId) ?
$userId : (int)
JFactory::getUser()->get('id');
* Method to save the form data.
* @param array The form data.
* @return mixed The user id on success, false on failure.
public function save($data)
$userId =
(!empty($data['id'])) ?
$data['id'] : (int)
$this->getState('user.id');
$user =
new JUser($userId);
// Prepare the data for the user object.
$data['password'] =
$data['password1'];
// Unset the username if it should not be overwritten
$username =
$data['username'];
$isUsernameCompliant =
$this->getState('user.username.compliant');
if (!JComponentHelper::getParams('com_users')->get('change_login_name') &&
$isUsernameCompliant)
unset
($data['username']);
// Unset the block so it does not get overwritten
// Unset the sendEmail so it does not get overwritten
unset
($data['sendEmail']);
// handle the two factor authentication setup
$twoFactorMethod =
$data['twofactor']['method'];
// Get the current One Time Password (two factor auth) configuration
$otpConfig =
$model->getOtpConfig($userId);
if ($twoFactorMethod !=
'none')
$otpConfigReplies =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorApplyConfiguration', array($twoFactorMethod));
// Look for a valid reply
foreach ($otpConfigReplies as $reply)
if (!is_object($reply) ||
empty($reply->method) ||
($reply->method !=
$twoFactorMethod))
$otpConfig->method =
$reply->method;
$otpConfig->config =
$reply->config;
// Save OTP configuration.
$model->setOtpConfig($userId, $otpConfig);
// Generate one time emergency passwords if required (depleted or not set)
if (empty($otpConfig->otep))
$oteps =
$model->generateOteps($userId);
$otpConfig->method =
'none';
$otpConfig->config =
array();
$model->setOtpConfig($userId, $otpConfig);
unset
($data['twofactor']);
// Reload the user record with the updated OTP configuration
// Load the users plugin group.
// Null the user groups so they don't get overwritten
$user->tags->getTagIds($user->id, 'com_users.user');
* Gets the configuration forms for all two-factor authentication methods
* @param integer $user_id The user ID to load the forms for (optional)
$user_id =
(!empty($user_id)) ?
$user_id : (int)
$this->getState('user.id');
$otpConfig =
$model->getOtpConfig($user_id);
return FOFPlatform::getInstance()->runPlugins('onUserTwofactorShowConfiguration', array($otpConfig, $user_id));
$user_id =
(!empty($user_id)) ?
$user_id : (int)
$this->getState('user.id');
return $model->getOtpConfig($user_id);
Documentation generated on Tue, 19 Nov 2013 15:11:18 +0100 by phpDocumentor 1.4.3