本文整理汇总了PHP中JUser::setParam方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::setParam方法的具体用法?PHP JUser::setParam怎么用?PHP JUser::setParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::setParam方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: testParameter
/**
* Tests JUser Parameter setting and retrieval.
*
* @return void
*
* @since 12.1
*
* @covers JUser::defParam
* @covers JUser::getParam
* @covers JUser::setParam
*/
public function testParameter()
{
$this->assertThat($this->object->getParam('holy', 'fred'), $this->equalTo('fred'));
$this->object->defParam('holy', 'batman');
$this->assertThat($this->object->getParam('holy', 'fred'), $this->equalTo('batman'));
$this->object->setParam('holy', 'batman');
$this->assertThat($this->object->getParam('holy', 'fred'), $this->equalTo('batman'));
}
示例3: 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;
}
示例4: 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);
}
示例5: 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;
}
示例6: setParam
/**
* Method to set a parameter
*
* @param string $key Parameter key
* @param mixed $value Parameter value
*
* @return self For chaining
*/
public function setParam($key, $value)
{
$this->cmsOwnUser->setParam($key, $value);
return $this;
}
示例7: storeVM25
//.........这里部分代码省略.........
if (JVM_VERSION === 1) {
if ($useractivation == '1') {
$doUserActivation = true;
}
} else {
if ($useractivation == '1' or $useractivation == '2') {
$doUserActivation = true;
}
}
vmdebug('user', $useractivation, $doUserActivation);
if ($doUserActivation) {
jimport('joomla.user.helper');
if (method_exists('JApplication', 'getHash')) {
$user->set('activation', JApplication::getHash(JUserHelper::genRandomPassword()));
} else {
$user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword()));
}
//$user->set('activation', JUtility::getHash( JUserHelper::genRandomPassword()) );
$user->set('block', '1');
//$user->set('lastvisitDate', '0000-00-00 00:00:00');
}
}
$option = JRequest::getCmd('option');
// If an exising superadmin gets a new group, make sure enough admins are left...
if (!$new && $user->get('gid') != $gid && $gid == __SUPER_ADMIN_GID) {
if (method_exists($userModel, 'getSuperAdminCount')) {
if ($userModel->getSuperAdminCount() <= 1) {
vmError(JText::_('COM_VIRTUEMART_USER_ERR_ONLYSUPERADMIN'));
return false;
}
}
}
if (isset($data['language'])) {
$user->setParam('language', $data['language']);
} else {
if (isset($data['order_language'])) {
$user->setParam('language', $data['order_language']);
}
}
// Save the JUser object
$regfail = false;
if (!$user->save()) {
vmError(JText::_($user->getError()), JText::_($user->getError()));
$regfail = true;
}
//vmdebug('my user, why logged in? ',$user);
if (!$regfail) {
$newId = $user->get('id');
} else {
$newId = 0;
}
$data['virtuemart_user_id'] = $newId;
//We need this in that case, because data is bound to table later
$regid = $user->get('id');
if (!empty($regid)) {
$GLOBALS['opc_new_user'] = $user->get('id');
} else {
$GLOBALS['opc_new_user'] = $newId;
}
//$this->setUserId($newId);
$userModel->_id = $newId;
$userModel->_data = null;
//Save the VM user stuff
if (!empty($data['quite'])) {
$msgqx1 = JFactory::getApplication()->get('messageQueue', array());
$msgqx2 = JFactory::getApplication()->get('_messageQueue', array());
示例8: purgeParams
/**
* Purge all JBZoo params
* @return bool
*/
public function purgeParams()
{
$this->_user->setParam(self::PARAM_NAMESPACE, array());
return $this->_user->save(true);
}
示例9: published
function published($publish)
{
$db = JFactory::getDBO();
$ids = JRequest::getVar('cid', array());
$ids = implode(',', $ids);
$query = "UPDATE #__jav_items" . " SET published = " . intval($publish) . " WHERE id IN ( {$ids} )";
$db->setQuery($query);
if (!$db->query()) {
return false;
}
foreach (JRequest::getVar('cid', array()) as $id) {
$item = $this->getItem(array($id));
$logs = $this->getLogs(" and item_id={$id}");
if ($logs) {
foreach ($logs as $log) {
$user = JFactory::getUser($log->user_id);
$user_no_session = new JUser($log->user_id);
$total_voted = (int) $user_no_session->getParam('total-voted-' . $item->voice_types_id);
if ($publish == 0) {
$total_voted = (int) ($total_voted - abs($log->votes));
} else {
$total_voted = (int) ($total_voted + abs($log->votes));
}
if ($total_voted < 0) {
$total_voted = 0;
}
$user_no_session->setParam('total-voted-' . $item->voice_types_id, $total_voted);
$user_no_session->save();
}
}
}
return true;
}
示例10: JUser
function register_save()
{
$otherlanguage = JFactory::getLanguage();
$otherlanguage->load('com_user', JPATH_SITE);
$usersConfig = JComponentHelper::getParams('com_users');
if ($usersConfig->get('allowUserRegistration') == '0') {
JError::raiseError(403, JText::_('Access Forbidden'));
return;
}
$authorize = JFactory::getACL();
$user = new JUser();
$system = 2;
// ID of Registered
$user->groups = array();
$user->groups[] = $system;
// Bind the post array to the user object
$post = JRequest::get('post');
if (!$user->bind($post, 'usertype')) {
JError::raiseError(500, $user->getError());
}
// Set some initial user values
$user->set('id', 0);
$date = JFactory::getDate();
$user->set('registerDate', $date->toSql());
$parent = JFactory::getUser();
$user->setParam('u' . $parent->id . '_parent_id', $parent->id);
// If user activation is turned on, we need to set the activation information
$useractivation = $usersConfig->get('useractivation');
if ($useractivation == 1 || $useractivation == 2) {
jimport('joomla.user.helper');
$user->set('activation', JApplication::getHash(JUserHelper::genRandomPassword()));
$user->set('block', '1');
}
// If there was an error with registration, set the message and display form
if (!$user->save()) {
JError::raiseWarning('', JText::_($user->getError()));
$this->setRedirect('index.php?option=com_joomdle&view=register');
return false;
}
// Add to profile type if needed
$params = JComponentHelper::getParams('com_joomdle');
$children_pt = $params->get('children_profiletype');
if ($children_pt) {
JoomdleHelperProfiletypes::add_user_to_profile($user->id, $children_pt);
}
// Send registration confirmation mail
$password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
$password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
//Disallow control chars in the email
// UserController::_sendMail($user, $password);
JoomdleHelperSystem::send_registration_email($user->username, $password);
$parent_user = JFactory::getUser();
// Set parent role in Moodle
JoomdleHelperContent::call_method("add_parent_role", $user->username, $parent_user->username);
$message = JText::_('COM_JOOMDLE_USER_CREATED');
$this->setRedirect('index.php?option=com_joomdle&view=register', $message);
//XXX poenr un get current uri
}
示例11: onOauthAuthorize
/**
* Swap the authorization code for a persistent token and authorize access
* to Joomla!.
*
* @return bool True if the authorization is successful, false otherwise.
*/
public function onOauthAuthorize()
{
$oauth = new JTwitterOAuth();
$oauth->setOption('consumer_key', $this->params->get('clientid'));
$oauth->setOption('consumer_secret', $this->params->get('clientsecret'));
$oauth->setOption('sendheaders', true);
$oauth->authenticate();
$twitter = new JTwitter($oauth);
$token = $twitter->oauth->getToken();
$settings = $twitter->profile->getSettings();
// Get the log in credentials.
$credentials = array();
$credentials['username'] = $this->_name . '/' . $settings->screen_name;
$credentials['name'] = $settings->screen_name;
if (isset($settings->email)) {
$credentials['email'] = $settings->email;
} else {
// we need an email for the auto-register to succeed.
$credentials['email'] = $settings->screen_name . '@twitter.com';
}
$options = array();
$app = JFactory::getApplication();
// Perform the log in.
if (true === $app->login($credentials, $options)) {
$user = new JUser(JUserHelper::getUserId($credentials['username']));
$user->setParam('twitter.token.key', JArrayHelper::getValue($token, 'key'));
$user->setParam('twitter.token.secret', JArrayHelper::getValue($token, 'secret'));
$user->save();
return true;
} else {
return false;
}
}