本文整理汇总了PHP中JUser::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::bind方法的具体用法?PHP JUser::bind怎么用?PHP JUser::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAKPaymentNew
/**
* Returns the payment form to be submitted by the user's browser. The form must have an ID of
* "paymentForm" and a visible submit button.
*
* @param string $paymentmethod
* @param JUser $user
* @param AkeebasubsTableLevel $level
* @param AkeebasubsTableSubscription $subscription
* @return string
*/
public function onAKPaymentNew($paymentmethod, $user, $level, $subscription)
{
if ($paymentmethod != $this->ppName) {
return false;
}
// Set the payment status to Pending
$oSub = F0FModel::getTmpInstance('Subscriptions', 'AkeebasubsModel')->setId($subscription->akeebasubs_subscription_id)->getItem();
$updates = array('state' => 'P', 'enabled' => 0, 'processor_key' => md5(time()));
$oSub->save($updates);
// Activate the user account, if the option is selected
$activate = $this->params->get('activate', 0);
if ($activate && $user->block) {
$updates = array('block' => 0, 'activation' => '');
$user->bind($updates);
$user->save($updates);
}
// Render the HTML form
$nameParts = explode(' ', $user->name, 2);
$firstName = $nameParts[0];
if (count($nameParts) > 1) {
$lastName = $nameParts[1];
} else {
$lastName = '';
}
$html = $this->params->get('instructions', '');
if (empty($html)) {
$html = <<<ENDTEMPLATE
<p>Dear Sir/Madam,<br/>
In order to complete your payment, please deposit {AMOUNT}€ to our bank account:</p>
<p>
<b>IBAN</b>: XX00.000000.00000000.00000000<br/>
<b>BIC</b>: XXXXXXXX
</p>
<p>Please reference subscription code {SUBSCRIPTION} in your payment. Make sure that any bank charges are paid by you in full and not deducted from the transferred amount. If you're using e-Banking to transfer the funds, please select the "OUR" bank expenses option.</p>
<p>Thank you in advance,<br/>
The management</p>
ENDTEMPLATE;
}
$html = str_replace('{AMOUNT}', sprintf('%01.02f', $subscription->gross_amount), $html);
$html = str_replace('{SUBSCRIPTION}', sprintf('%06u', $subscription->akeebasubs_subscription_id), $html);
$html = str_replace('{FIRSTNAME}', $firstName, $html);
$html = str_replace('{LASTNAME}', $lastName, $html);
$html = str_replace('{LEVEL}', $level->title, $html);
// Get a preloaded mailer
$mailer = AkeebasubsHelperEmail::getPreloadedMailer($subscription, 'plg_akeebasubs_subscriptionemails_offline');
// Replace custom [INSTRUCTIONS] tag
$body = str_replace('[INSTRUCTIONS]', $html, $mailer->Body);
$mailer->setBody($body);
if ($mailer !== false) {
$mailer->addRecipient($user->email);
$result = $mailer->Send();
$mailer = null;
}
@(include_once JPATH_SITE . '/components/com_akeebasubs/helpers/message.php');
if (class_exists('AkeebasubsHelperMessage')) {
$html = AkeebasubsHelperMessage::processLanguage($html);
}
$html = '<div>' . $html . '</div>';
return $html;
}
示例2: createNewUser
public function createNewUser($params)
{
$user = new JUser(0);
JLoader::import('joomla.application.component.helper');
$usersConfig = JComponentHelper::getParams('com_users');
$newUsertype = $usersConfig->get('new_usertype');
// get the New User Group from com_users' settings
if (empty($newUsertype)) {
$newUsertype = 2;
}
$params['groups'] = array($newUsertype);
$params['sendEmail'] = 0;
// Set the user's default language to whatever the site's current language is
if (version_compare(JVERSION, '3.0', 'ge')) {
$params['params'] = array('language' => JFactory::getConfig()->get('language'));
} else {
$params['params'] = array('language' => JFactory::getConfig()->getValue('config.language'));
}
JLoader::import('joomla.user.helper');
$params['block'] = 0;
$randomString = JUserHelper::genRandomPassword();
if (version_compare(JVERSION, '3.2', 'ge')) {
$hash = JApplication::getHash($randomString);
} else {
$hash = JFactory::getApplication()->getHash($randomString);
}
$params['activation'] = $hash;
$user->bind($params);
$userIsSaved = $user->save();
if ($userIsSaved) {
return $user->id;
} else {
return false;
}
}
示例3: 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);
}
示例4: onMembershipActive
/**
* Run when a membership activated
* @param PlanOsMembership $row
*/
function onMembershipActive($row)
{
if (!$row->user_id && $row->username && $row->user_password) {
//Need to create the account here
$data['name'] = trim($row->first_name . ' ' . $row->last_name);
//Decrypt the password
$data['username'] = $row->username;
//Password
$privateKey = md5(JFactory::getConfig()->get('secret'));
$key = new JCryptKey('simple', $privateKey, $privateKey);
$crypt = new JCrypt(new JCryptCipherSimple(), $key);
$data['password'] = $data['password2'] = $data['password'] = $crypt->decrypt($row->user_password);
$data['email1'] = $data['email2'] = $data['email'] = $row->email;
$params = JComponentHelper::getParams('com_users');
$data['groups'] = array();
$data['groups'][] = $params->get('new_usertype', 2);
$user = new JUser();
if (!$user->bind($data)) {
return false;
}
// Store the data.
if (!$user->save()) {
return false;
}
$row->user_id = $user->get('id');
$row->store();
}
}
示例5: userCreate
/**
* Joomla! user creator.
*
* @access public
* @param string $username the username used for login.
* @param string $name the name of the user.
* @param string $email the user email.
* @return the new user identifier or false if something wrong.
* @since 0.6
*/
function userCreate($username, $name, $email)
{
$user = new JUser();
$data = array("username" => $username, "name" => $name, "email" => $email, "usertype" => "Registered", "gid" => 18);
$user->bind($data);
$user->setParam('admin_language', '');
if ($user->save()) {
return $user->id;
}
return false;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: store
function store(&$error)
{
jimport("joomla.database.table.user");
$db = JFactory::getDBO();
$user = new JUser();
$my = new stdClass();
$item = $this->getTable('Customer');
$id = JRequest::getVar("id", "0");
if ($id != "0") {
$data = JRequest::get('post');
//$data['password2'] = $data['password_confirm'];
//$data['name'] = $data['firstname'];
$data['groups'] = array(2);
$data['block'] = 0;
$user->bind($data);
$user->gid = 18;
$res = true;
$my->id = $data['id'];
if (!$my->id) {
if (!$user->save()) {
$error = $user->getError();
$res = false;
}
} else {
$user->id = $my->id;
}
}
if (intval($id) == "0") {
$sql = 'SELECT id FROM #__users ORDER BY id DESC LIMIT 1';
$db->setQuery($sql);
$data['id'] = intval($db->loadResult());
}
if (!$item->bind($data)) {
$res = false;
}
if (!$item->check()) {
$res = false;
}
if (!$item->store()) {
$res = false;
}
//echo $res;die;
$this->setId($item->id);
$this->getCustomer();
return $res;
}
示例10: 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;
}
示例11: 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);
}
示例12: 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;
}
示例13: 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;
}
示例14: saveUser
protected function saveUser()
{
$user = KunenaUserHelper::get($this->user->id);
// we only allow users to edit few fields
$allow = array('name', 'email', 'password', 'password2', 'params');
if ($this->config->usernamechange) {
if (version_compare(JVERSION, '2.5.5', '<') || JComponentHelper::getParams('com_users')->get('change_login_name', 1)) {
$allow[] = 'username';
}
}
//clean request
$post = JRequest::get('post');
$post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
// RAW input
$post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
// RAW input
if (empty($post['password']) || empty($post['password2'])) {
unset($post['password'], $post['password2']);
}
$post = array_intersect_key($post, array_flip($allow));
// get the redirect
$return = $user->getUrl(false);
$err_return = $user->getUrl(false, 'edit');
// do a password safety check
if (!empty($post['password']) && !empty($post['password2'])) {
if (strlen($post['password']) < 5 && strlen($post['password2']) < 5) {
if ($post['password'] != $post['password2']) {
$msg = JText::_('COM_KUNENA_PROFILE_PASSWORD_MISMATCH');
$this->app->redirect($err_return, $msg, 'error');
}
$msg = JText::_('COM_KUNENA_PROFILE_PASSWORD_NOT_MINIMUM');
$this->app->redirect($err_return, $msg, 'error');
}
}
$username = $this->user->get('username');
$user = new JUser($this->user->id);
// Bind the form fields to the user table
if (!$user->bind($post)) {
return false;
}
// Store user to the database
if (!$user->save(true)) {
$this->app->enqueueMessage($user->getError(), 'notice');
return false;
}
// Reload the user.
$this->user->load($this->user->id);
$session = JFactory::getSession();
$session->set('user', $this->user);
// update session if username has been changed
if ($username && $username != $this->user->username) {
$table = JTable::getInstance('session', 'JTable');
$table->load($session->getId());
$table->username = $this->user->username;
$table->store();
}
return true;
}
示例15: jvsave
private function jvsave($member_id, $post) {
$mainframe = JFactory :: getApplication();
$option = JRequest :: getCmd('option');
// Initialize some variables
$msg = "";
$me = & JFactory :: getUser();
$MailFrom = $mainframe->getCfg('mailfrom');
$FromName = $mainframe->getCfg('fromname');
$SiteName = $mainframe->getCfg('sitename');
// Create a new JUser object
$user = new JUser($member_id);
$original_gid = $user->get('gid');
if (!$user->bind($post)) {
$result = array ();
$result['success'] = false;
$result['title'] = 'Error';
$result['content'] = JText :: _('Failed Updating Member Information');
$result = oseJSON :: encode($result);
oseExit($result);
}
// Are we dealing with a new user which we need to create?
$isNew = ($user->get('id') < 1);
if (!$isNew) {
// if group has been changed and where original group was a Super Admin
if ($user->get('gid') != $original_gid && $original_gid == 25) {
// count number of active super admins
$query = 'SELECT COUNT( id )' . ' FROM #__users' . ' WHERE gid = 25' . ' AND block = 0';
$this->db->setQuery($query);
$count = $this->db->loadResult();
if ($count <= 1) {
$result = array ();
$result['success'] = false;
$result['title'] = 'Error';
$result['content'] = JText :: _('Failed Updating Member Information');
$result = oseJSON :: encode($result);
oseExit($result);
}
}
}
/*
* Lets save the JUser object
*/
if (!$user->save()) {
$result = array ();
$result['success'] = false;
$result['title'] = 'Error';
$result['content'] = $user->getError();
$result = oseJSON :: encode($result);
oseExit($result);
}
// For new users, email username and password
// Capture the new user id
if ($isNew) {
$newUserId = $user->get('id');
} else {
$newUserId = null;
}
return $newUserId;
}