本文整理汇总了PHP中JUser::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::getError方法的具体用法?PHP JUser::getError怎么用?PHP JUser::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::getError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addJoomlaUser
private function addJoomlaUser($username, $name, $email, $password)
{
$data = array("name" => $name, "username" => $username, "password" => $password, "password2" => $password, "email" => $email, "block" => 0, "groups" => array("1", "2", "300"));
$user = new JUser();
if (!$user->bind($data)) {
throw new Exception("Could not bind data. Error: " . $user->getError());
}
if (!$user->save()) {
throw new Exception("Could not save user. Error: " . $user->getError());
}
return $user->id;
}
示例2: JUser
static function create_joomla_user($user_info)
{
$usersConfig = JComponentHelper::getParams('com_users');
$authorize = JFactory::getACL();
$user = new JUser();
// Initialize new usertype setting
$newUsertype = $usersConfig->get('new_usertype');
if (!$newUsertype) {
$newUsertype = 'Registered';
}
// Bind the user_info array to the user object
if (!$user->bind($user_info)) {
JError::raiseError(500, $user->getError());
}
// Set some initial user values
$user->set('id', 0);
$user->set('usertype', $newUsertype);
$system = 2;
// ID of Registered
$user->groups = array();
$user->groups[] = $system;
$date = JFactory::getDate();
$user->set('registerDate', $date->toSql());
$parent = JFactory::getUser();
$user->setParam('u' . $parent->id . '_parent_id', $parent->id);
if ($user_info['block']) {
$user->set('block', '1');
}
// If there was an error with registration
if (!$user->save()) {
return false;
}
/* Update profile additional data */
return JoomdleHelperMappings::save_user_info($user_info);
}
示例3: addUserToGroup
/**
* Method to add a user to a group.
*
* @param integer $userId The id of the user.
* @param integer $groupId The id of the group.
*
* @return mixed Boolean true on success, JException on error.
* @since 11.1
*/
public static function addUserToGroup($userId, $groupId)
{
// Get the user object.
$user = new JUser((int) $userId);
// Add the user to the group if necessary.
if (!in_array($groupId, $user->groups)) {
// Get the title of the group.
$db = JFactory::getDbo();
$db->setQuery('SELECT title' . ' FROM #__usergroups' . ' WHERE id = ' . (int) $groupId);
$title = $db->loadResult();
// Check for a database error.
if ($db->getErrorNum()) {
return new JException($db->getErrorMsg());
}
// If the group does not exist, return an exception.
if (!$title) {
return new JException(JText::_('JLIB_USER_EXCEPTION_ACCESS_USERGROUP_INVALID'));
}
// Add the group data to the user object.
$user->groups[$title] = $groupId;
// Store the user object.
if (!$user->save()) {
return new JException($user->getError());
}
}
// Set the group data for any preloaded user objects.
$temp = JFactory::getUser((int) $userId);
$temp->groups = $user->groups;
// Set the group data for the user object in the session.
$temp = JFactory::getUser();
if ($temp->id == $userId) {
$temp->groups = $user->groups;
}
return true;
}
示例4: addUserToGroup
/**
* Method to add a user to a group.
*
* @param integer $userId The id of the user.
* @param integer $groupId The id of the group.
* @return mixed Boolean true on success, JException on error.
* @since 1.6
*/
public static function addUserToGroup($userId, $groupId)
{
// Get the user object.
$user = new JUser((int) $userId);
// Add the user to the group if necessary.
if (!array_key_exists($groupId, $user->groups)) {
// Get the title of the group.
$db =& JFactory::getDbo();
$db->setQuery('SELECT `title`' . ' FROM `#__usergroups`' . ' WHERE `id` = ' . (int) $groupId);
$title = $db->loadResult();
// Check for a database error.
if ($db->getErrorNum()) {
return new JException($db->getErrorMsg());
}
// If the group does not exist, return an exception.
if (!$title) {
return new JException(JText::_('Access_Usergroup_Invalid'));
}
// Add the group data to the user object.
$user->groups[$groupId] = $title;
// Store the user object.
if (!$user->save()) {
return new JException($user->getError());
}
}
// Set the group data for any preloaded user objects.
$temp =& JFactory::getUser((int) $userId);
$temp->groups = $user->groups;
// Set the group data for the user object in the session.
$temp =& JFactory::getUser();
if ($temp->id == $userId) {
$temp->groups = $user->groups;
}
return true;
}
示例5: JUser
static function create_joomla_user($user_info)
{
$usersConfig = JComponentHelper::getParams('com_users');
$authorize = JFactory::getACL();
$user = new JUser();
// Initialize new usertype setting
$newUsertype = $usersConfig->get('new_usertype');
if (!$newUsertype) {
$newUsertype = 2;
}
// Password comes hashed
// On bind, Joomla hashes it again, so we save it before
$password = $user_info['password'];
// Bind the user_info array to the user object
if (!$user->bind($user_info)) {
JError::raiseError(500, $user->getError());
}
// Manually set original hashed password
$user->password = $password;
// Set some initial user values
$user->set('id', 0);
$user->groups = array();
$user->groups[] = $newUsertype;
$date = JFactory::getDate();
$user->set('registerDate', $date->toSql());
$parent = JFactory::getUser();
$user->setParam('u' . $parent->id . '_parent_id', $parent->id);
if ($user_info['block']) {
$user->set('block', '1');
}
// If there was an error with registration
if (!$user->save()) {
JError::raiseError(500, $user->getError());
return false;
}
// Set password in crypted form
// $u = new JObject ();
// $u->id = $user->id;
// $u->password = $password;
/* Update profile additional data */
return JoomdleHelperMappings::save_user_info($user_info, false);
}
示例6: store
/**
* Create a new user
*
* @param $fbUserId A Facebook User ID
*
* @return User id
*/
public function store($fbUserId, $fbUserData)
{
settype($fbUserId, "string");
$fbUserId = JString::trim($fbUserId);
if (!$fbUserId) {
throw new ItpException(JText::_('ITP_ERROR_FB_ID'), 404);
}
// Check for existing e-mail (user)
$userId = ItpcHelper::getJUserIdByEmail($fbUserData['email']);
// Initialise the table with JUser.
$user = JUser::getInstance();
if (!$userId) {
$config = JFactory::getConfig();
// Initialise the table with JUser.
$user = new JUser();
$data = (array) $this->getData();
jimport('joomla.user.helper');
// Prepare the data for the user object.
$data['name'] = $fbUserData['name'];
$data['email'] = $fbUserData['email'];
$data['username'] = substr($fbUserData['email'], 0, strpos($fbUserData['email'], "@"));
$data['password'] = $password = JUserHelper::genRandomPassword();
$data['block'] = 0;
// Bind the data.
if (!$user->bind($data)) {
throw new ItpException($user->getError(), 500);
}
// Load the users plugin group.
JPluginHelper::importPlugin('user');
// Store the data.
if (!$user->save()) {
throw new ItpException($user->getError(), 500);
}
// Send a confirmation mail
$this->sendConfirmationMail($data, $password);
} else {
$user->load($userId);
}
// Loads a record from database
$row = $this->getTable("itpcuser", "ItpConnectTable");
$row->load($fbUserId, "facebook");
// Initialize object for new record
if (!$row->id) {
$row = $this->getTable("itpcuser", "ITPConnectTable");
}
$row->set("users_id", $user->id);
$row->set("fbuser_id", $fbUserId);
if (!$row->store()) {
throw new ItpException($row->getError(), 500);
}
return $row->users_id;
}
示例7: store
function store()
{
jimport("joomla.database.table.user");
$my = JFactory::getUser();
$new_user = "0";
if (!$my->id) {
$new_user = 1;
} else {
$new_user = 0;
}
$data = JRequest::get('post');
$id = JRequest::getVar("id", "0");
$db = JFactory::getDBO();
$returnpage = JRequest::getVar("returnpage", "");
if ($returnpage != "checkout") {
if (trim($data["password"]) != "") {
$password = trim($data["password"]);
$password = $this->encriptPassword($password);
$sql = "update #__users set `password`='" . trim($password) . "' where `id`=" . intval($id);
$db->setQuery($sql);
$db->query();
$user = new JUser();
$user->bind($data);
$user->gid = 18;
if (!$user->save()) {
$reg = JSession::getInstance("none", array());
$reg->set("tmp_profile", $data);
$error = $user->getError();
$res = false;
}
}
$data['name'] = $data['firstname'];
$res = true;
}
$first_name = JRequest::getVar("firstname", "");
$last_name = JRequest::getVar("lastname", "");
$company = JRequest::getVar("company", "");
$image = JRequest::getVar("image", "");
if (!$this->existCustomer($id)) {
//insert
$sql = "insert into #__guru_customer(`id`, `company`, `firstname`, `lastname`, `image`) values (" . intval($id) . ", '" . addslashes(trim($company)) . "', '" . addslashes(trim($first_name)) . "', '" . addslashes(trim($last_name)) . "', '" . addslashes(trim($image)) . "')";
} else {
//update
$sql = "update #__guru_customer set company='" . addslashes(trim($company)) . "', firstname='" . addslashes(trim($first_name)) . "', lastname='" . addslashes(trim($last_name)) . "', image='" . addslashes(trim($image)) . "' where id=" . intval($id);
}
$db->setQuery($sql);
if ($db->query()) {
return true;
}
return false;
}
示例8: JUser
function addUser16($values, $source = 'subscribe')
{
$config = EasyBlogHelper::getConfig();
$usersConfig = JComponentHelper::getParams('com_users');
$canRegister = $source == 'comment' ? $config->get('comment_registeroncomment', 0) : $config->get('main_registeronsubscribe', 0);
if ($usersConfig->get('allowUserRegistration') == '0' || !$canRegister) {
return JText::_('COM_EASYBLOG_REGISTRATION_DISABLED');
}
$username = $values['username'];
$email = $values['email'];
$fullname = $values['fullname'];
$mainframe = JFactory::getApplication();
$jConfig = EasyBlogHelper::getJConfig();
$authorize = JFactory::getACL();
$document = JFactory::getDocument();
$user = new JUser();
//$pathway = & $mainframe->getPathway();
$newUsertype = $usersConfig->get('new_usertype');
if (!$newUsertype) {
$newUsertype = 'Registered';
}
$pwdClear = $username . '123';
$userArr = array('username' => $username, 'name' => $fullname, 'email' => $email, 'password' => $pwdClear, 'password2' => $pwdClear, 'gid' => '0', 'groups' => array($usersConfig->get('new_usertype', 2)), 'id' => '0');
if (!$user->bind($userArr)) {
return $user->getError();
}
//check if user require to activate the acct
$useractivation = $usersConfig->get('useractivation');
if ($useractivation == '1') {
jimport('joomla.user.helper');
$user->set('activation', md5(JUserHelper::genRandomPassword()));
$user->set('block', '1');
}
JPluginHelper::importPlugin('user');
$user->save();
// Send registration confirmation mail
$password = $pwdClear;
$password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
//Disallow control chars in the email
//load com_user language file
$lang = JFactory::getLanguage();
$lang->load('com_users');
//UserController::_sendMail($user, $password);
return $user->id;
}
示例9: registerUser
public function registerUser($data)
{
$jxConfig = new JXConfig();
$verifyEmail = $jxConfig->cleanEmailList(array($data['email']));
if (!is_array($verifyEmail)) {
$this->setError($verifyEmail);
return false;
} elseif ($data['password'] == $data['conf_pass']) {
$user = new JUser();
$temp = new stdClass();
$temp->name = $data['name'];
$temp->username = $data['username'];
$temp->password = $data['password'];
$temp->block = 0;
$temp->sendEmail = 0;
$temp->email = $data['email'];
// set the default new user group, Registered
$temp->groups[] = 2;
$bindData = (array) $temp;
$user->bind($bindData);
if (isset($data['group_limited'])) {
$user->setParam('groups_member_limited', $data['group_limited']);
}
if ($user->save()) {
$activity = JTable::getInstance('Activity', 'StreamTable');
$activity->addUser($user->id);
return $user->id;
} else {
$this->setError($user->getError());
return false;
}
} else {
$this->setError(JText::_('COM_REGISTER_ERRMSG_PASSWORD_MISMATCH'));
return false;
}
return false;
}
示例10: store
//.........这里部分代码省略.........
$autoapprove[4] = 'Y';
if ($userParams->get('useractivation') != 0) {
$data["block"] = 1;
$user->block = 1;
$autoapprove[4] = 'P';
}
$data["groups"] = array($advgroup);
$user->bind($data);
if (isset($autoapprove[4]) && $autoapprove[4] == 'Y') {
$user->block = 0;
$user->activation = '';
$data['approved'] = 'Y';
} else {
$data['approved'] = 'P';
$useractivation = $usersConfig->get('useractivation');
if ($useractivation == '1') {
jimport('joomla.user.helper');
$user->activation = md5(JUserHelper::genRandomPassword());
$user->block = 1;
}
}
if ($is_wizzard > 0) {
$user->block = 0;
$user->activation = 0;
$user->params = NULL;
}
if ($userParams->get('useractivation') != 0) {
jimport('joomla.user.helper');
$user->activation = md5(JUserHelper::genRandomPassword());
$data["block"] = 1;
$user->block = 1;
}
if (!$user->save()) {
$error = $user->getError();
echo $error;
$res = false;
} else {
$name = $user->name;
$email = $user->email;
$username = $user->username;
$mosConfig_live_site = JURI::base();
$ok_send_email = 1;
if ($data['approved'] == 'Y') {
$subject = $configs->sbafterregaa;
$message = $configs->bodyafterregaa;
$ok_send_email = $email_params["send_after_reg_auto_app"];
} else {
$subject = $configs->sbactivation;
$message = $configs->bodyactivation;
$ok_send_email = $email_params["send_after_reg_need_act"];
}
$subject = str_replace('{name}', $name, $subject);
$subject = str_replace('{login}', $username, $subject);
$subject = str_replace('{email}', $email, $subject);
$subject = str_replace('{password}', $pwd, $subject);
$message = str_replace('{name}', $name, $message);
$message = str_replace('{login}', $username, $message);
$message = str_replace('{email}', $email, $message);
$message = str_replace('{password}', $pwd, $message);
$configs->txtafterreg = str_replace('{name}', $name, $configs->txtafterreg);
$configs->txtafterreg = str_replace('{login}', $username, $configs->txtafterreg);
$configs->txtafterreg = str_replace('{password}', $pwd, $configs->txtafterreg);
$message = str_replace('{activate_url}', '<a href="' . $mosConfig_live_site . 'index.php?option=com_users&task=registration.activate&token=' . $user->activation . '" target="_blank">' . $mosConfig_live_site . 'index.php?option=com_users&task=registration.activate&token=' . $user->activation . '</a>', $message);
$message = html_entity_decode($message, ENT_QUOTES);
if ($ok_send_email == 1) {
JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $email, $subject, $message, 1);
示例11: save
/**
* Method to save the form data.
*
* @param array The form data.
* @return mixed The user id on success, false on failure.
* @since 1.6
*/
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['email'] = JStringPunycode::emailToPunycode($data['email1']);
$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($data['block']);
// Unset the sendEmail so it does not get overwritten
unset($data['sendEmail']);
// handle the two factor authentication setup
if (array_key_exists('twofactor', $data)) {
$model = new UsersModelUser();
$twoFactorMethod = $data['twofactor']['method'];
// Get the current One Time Password (two factor auth) configuration
$otpConfig = $model->getOtpConfig($userId);
if ($twoFactorMethod != 'none') {
// Run the plugins
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$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) {
continue;
}
$otpConfig->method = $reply->method;
$otpConfig->config = $reply->config;
break;
}
// 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);
}
} else {
$otpConfig->method = 'none';
$otpConfig->config = array();
$model->setOtpConfig($userId, $otpConfig);
}
// Unset the raw data
unset($data['twofactor']);
// Reload the user record with the updated OTP configuration
$user->load($userId);
}
// Bind the data.
if (!$user->bind($data)) {
$this->setError(JText::sprintf('COM_USERS_PROFILE_BIND_FAILED', $user->getError()));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('user');
// Null the user groups so they don't get overwritten
$user->groups = null;
// Store the data.
if (!$user->save()) {
$this->setError($user->getError());
return false;
}
$user->tags = new JHelperTags();
$user->tags->getTagIds($user->id, 'com_users.user');
return $user->id;
}
示例12: saveJanrainEngageUser
//.........这里部分代码省略.........
$userName = $preferredUsername;
while ($nameexists == true)
{
if(JUserHelper::getUserId($userName) != 0)
{
$index++;
$userName = $preferredUsername.$index;
}
else
{
$nameexists = false;
}
}
$user->set('username', $userName);
$sEmail = '';
if(isset($auth_info['profile']['email']))
{
$sEmail = $auth_info['profile']['email'];
$user->set('email', $auth_info['profile']['email']);
}
elseif (isset($auth_info['profile']['name']['email']))
{
$sEmail = $auth_info['profile']['email'];
$user->set('email', $auth_info['profile']['email']);
}
$pwd = JUserHelper::genRandomPassword();
$user->set('password', $pwd);
if (!$user->save())
{
echo "ERROR: ";
echo $user->getError();
}
// admin users gid
$gid = 25;
$query = "SELECT `email`, `name` FROM `#__users` WHERE `gid` = '".$gid."'";
$db->setQuery( $query );
$adminRows = $db->loadObjectList();
// send email notification to admins
if( !empty($adminRows) )
{
foreach($adminRows as $adminRow)
{
$sitename = $mainframe->getCfg( 'sitename' );
$siteRoot = JURI::base();
$userName = $user->get('username');
$userID = $user->get('id');
$userTupe = $user->get('usertype');
$userEmail = $user->get('email');
$adminName = $adminRow->name;
$adminEmail = $adminRow->email;
$subject = JText::_('New user registered via JAINARAIN ENGANGE at')." ".$sitename;
$subject = html_entity_decode($subject, ENT_QUOTES);
$message = JText::_('Hello')." ".$adminName."\n";
$message .= JText::_('New user registered via JAINARAIN ENGANGE at')." ".$siteRoot."\n\n";
$message .= JText::_('User Detail:')."\n";
$message .= JText::_('User ID :')." ".$userID."\n";
$message .= JText::_('Usertype :')." ".$userTupe."\n";
$message .= JText::_('Name :')." ".$displayName."\n";
示例13: register
/**
* Method to save the form data.
*
* @param array The form data.
* @return mixed The user id on success, false on failure.
* @since 1.6
*/
public function register($temp)
{
$config = JFactory::getConfig();
$params = JComponentHelper::getParams('com_users');
// Initialise the table with JUser.
$user = new JUser;
$data = (array)$this->getData();
// Merge in the registration data.
foreach ($temp as $k => $v) {
$data[$k] = $v;
}
// Prepare the data for the user object.
$data['email'] = $data['email1'];
$data['password'] = $data['password1'];
$useractivation = $params->get('useractivation');
// Check if the user needs to activate their account.
if (($useractivation == 1) || ($useractivation == 2)) {
jimport('joomla.user.helper');
$data['activation'] = JUtility::getHash(JUserHelper::genRandomPassword());
$data['block'] = 1;
}
// echo "<pre>";
// print_r($data); die;
// Bind the data.
if (!$user->bind($data)) {
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('user');
// Store the data.
if (!$user->save()) {
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
return false;
}
// Compile the notification mail values.
$data = $user->getProperties();
$data['fromname'] = $config->get('fromname');
$data['mailfrom'] = $config->get('mailfrom');
$data['sitename'] = $config->get('sitename');
$data['siteurl'] = JUri::base();
// Handle account activation/confirmation emails.
if ($useractivation == 2)
{
// Set the link to confirm the user email.
$uri = JURI::getInstance();
$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
$data['activate'] = $base.JRoute::_('index.php?option=com_users&task=registration.activate&token='.$data['activation'], false);
$emailSubject = JText::sprintf(
'COM_USERS_EMAIL_ACCOUNT_DETAILS',
$data['name'],
$data['sitename']
);
$emailBody = JText::sprintf(
'COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY',
$data['name'],
$data['sitename'],
$data['siteurl'].'index.php?option=com_users&task=registration.activate&token='.$data['activation'],
$data['siteurl'],
$data['username'],
$data['password_clear']
);
}
elseif ($useractivation == 1)
{
// Set the link to activate the user account.
$uri = JURI::getInstance();
$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
$data['activate'] = $base.JRoute::_('index.php?option=com_users&task=registration.activate&token='.$data['activation'], false);
$emailSubject = JText::sprintf(
'COM_USERS_EMAIL_ACCOUNT_DETAILS',
$data['name'],
$data['sitename']
);
$emailBody = JText::sprintf(
//.........这里部分代码省略.........
示例14: array
function &_getUser($user, $options = array())
{
$instance = new JUser();
if($id = intval(JUserHelper::getUserId($user['username']))) {
$instance->load($id);
return $instance;
}
//TODO : move this out of the plugin
jimport('joomla.application.component.helper');
$config = &JComponentHelper::getParams( 'com_users' );
$usertype = $config->get( 'new_usertype', 'Registered' );
$acl =& JFactory::getACL();
$instance->set( 'id' , 0 );
$instance->set( 'name' , $user['fullname'] );
$instance->set( 'username' , $user['username'] );
$instance->set( 'password_clear' , $user['password_clear'] );
$instance->set( 'email' , $user['email'] ); // Result should contain an email (check)
$instance->set( 'gid' , $acl->get_group_id( '', $usertype));
$instance->set( 'usertype' , $usertype );
//If autoregister is set let's register the user
$autoregister = isset($options['autoregister']) ? $options['autoregister'] : $this->params->get('autoregister', 1);
if($autoregister)
{
if(!$instance->save()) {
return JError::raiseWarning('SOME_ERROR_CODE', $instance->getError());
}
} else {
// No existing user and autoregister off, this is a temporary user
$instance->set( 'tmp_user', true );
}
return $instance;
}
示例15: onBeforeStore
//.........这里部分代码省略.........
$data['email'] = $this->emailvalue;
$ok = $this->check($data, $formModel, $params);
if (!$ok) {
// @TODO - add some error reporting
return false;
}
// Set the registration timestamp
if ($isNew) {
$now = JFactory::getDate();
$user->set('registerDate', $now->toSql());
}
if ($isNew) {
// If user activation is turned on, we need to set the activation information
$useractivation = $usersConfig->get('useractivation');
if ($useractivation == '1' && !$bypassActivation) {
jimport('joomla.user.helper');
$data['activation'] = JUtility::getHash(JUserHelper::genRandomPassword());
$data['block'] = 1;
}
}
// Check that username is not greater than 150 characters
$username = $data['username'];
if (strlen($username) > 150) {
$username = substr($username, 0, 150);
$user->set('username', $username);
}
// Check that password is not greater than 100 characters
if (strlen($data['password']) > 100) {
$data['password'] = substr($data['password'], 0, 100);
}
// end new
if (!$user->bind($data)) {
$app->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
$app->enqueueMessage($user->getError(), 'error');
return false;
}
/*
* Lets save the JUser object
*/
if (!$user->save()) {
$app->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
$app->enqueueMessage($user->getError(), 'error');
return false;
}
$session = JFactory::getSession();
JRequest::setVar('newuserid', $user->id);
JRequest::setVar('newuserid', $user->id, 'cookie');
$session->set('newuserid', $user->id);
JRequest::setVar('newuserid_element', $this->useridfield);
JRequest::setVar('newuserid_element', $this->useridfield, 'cookie');
$session->set('newuserid_element', $this->useridfield);
/*
* Time for the email magic so get ready to sprinkle the magic dust...
*/
$emailSubject = '';
if ($isNew) {
// Compile the notification mail values.
$data = $user->getProperties();
$data['fromname'] = $config->get('fromname');
$data['mailfrom'] = $config->get('mailfrom');
$data['sitename'] = $config->get('sitename');
$data['siteurl'] = JUri::base();
$uri = JURI::getInstance();
$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
// Handle account activation/confirmation emails.
if ($useractivation == 2 && !$bypassActivation) {