本文整理汇总了PHP中JUser类的典型用法代码示例。如果您正苦于以下问题:PHP JUser类的具体用法?PHP JUser怎么用?PHP JUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getActions
/**
* Gets a list of the actions that can be performed.
*
* @param \JUser $user The user object.
* @param string $component The component access file path, component base path or option name.
* @param string $assetName The asset name
* @param integer $categoryId The category ID.
* @param integer $id The item ID.
*
* @return Object
*/
public static function getActions(\JUser $user, $component, $assetName, $categoryId = 0, $id = 0)
{
$result = new Object();
// New rules: If path is access file
$path = $component;
if (!is_file($path)) {
// New rules: If path is component base path
$path = $path . '/access.xml';
}
if (!is_file($path)) {
$path = PathHelper::getAdmin($component) . '/etc/access.xml';
}
if (!is_file($path)) {
$path = PathHelper::getAdmin($component) . '/access.xml';
}
if (!$id && !$categoryId) {
$section = 'component';
} elseif (!$id && $categoryId) {
$section = 'category';
$assetName .= '.category.' . $categoryId;
} elseif ($id && !$categoryId) {
$section = $assetName;
$assetName .= '.' . $assetName . '.' . $id;
} else {
$section = $assetName;
$assetName .= '.' . $assetName;
}
$actions = \JAccess::getActionsFromFile($path, "/access/section[@name='" . $section . "']/");
foreach ($actions as $action) {
$result->set($action->name, $user->authorise($action->name, $assetName));
}
return $result;
}
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:44,代码来源:ComponentHelper.php
示例2: 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;
}
开发者ID:jonatasmm,项目名称:akeebasubs,代码行数:70,代码来源:offline.php
示例3: 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();
}
}
开发者ID:vstorm83,项目名称:propertease,代码行数:32,代码来源:account.php
示例4: 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;
}
}
开发者ID:jonatasmm,项目名称:akeebasubs,代码行数:35,代码来源:jusers.php
示例5: cancel
public static function cancel($params)
{
$result = array();
$result['success'] = true;
if (empty($params['allow_work'])) {
$result['success'] = false;
$result['title'] = 'Error';
$result['content'] = JText::_("Error");
return $result;
}
unset($params['allow_work']);
$member_id = $params['member_id'];
$user = new JUser($member_id);
$iAmSuperAdmin = $user->authorise('core.admin');
if ($iAmSuperAdmin) {
$result['success'] = true;
$result['title'] = JText::_('Done');
$result['content'] = JText::_("Done");
return $result;
}
$db = oseDB::instance();
$query = "SELECT * FROM `#__extensions` WHERE `name` = 'com_users' AND `type` = 'component'";
$db->setQuery($query);
$data = $db->loadObject();
$data = oseJson::decode($data->params);
$group['groups'] = (array) $data->new_usertype;
$member = oseRegistry::call('member');
$member->instance($member_id);
$Mscs = $member->getAllOwnedMsc(false, 1, 'obj');
foreach ($Mscs as $Msc) {
if ($Msc->msc_id == $params['msc_id']) {
continue;
}
$query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$Msc->msc_id}' AND `type` = 'jgroup'";
$db->setQuery($query);
$ext = $db->loadObject();
if (!empty($ext)) {
$ext = oseJson::decode($ext->params);
$group['groups'] = array_merge($group['groups'], (array) $ext->jgroup_id);
}
}
$group['groups'] = array_unique($group['groups']);
//$user = JUser::getInstance($member_id);
$user->bind($group);
//$user->groups = array_flip($data->jgroup_id);
if (!$user->save()) {
$result['success'] = false;
$result['title'] = 'Error';
$result['content'] = JText::_("Error");
return $result;
}
$result['success'] = true;
$result['title'] = JText::_('Done');
$result['content'] = JText::_("Done");
return $result;
}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:56,代码来源:join.jgroup.php
示例6: create_joomla_user
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);
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:35,代码来源:users.php
示例7: _convertToEntity
/**
* @param \JUser $user
* @return UserEntity
*/
protected function _convertToEntity(\JUser $user)
{
$id = (int) $user->id;
if ($entity = $this->_getEntity($id)) {
return $entity;
}
$isAdmin = $user->authorise('core.login.admin', 'root.1') || $user->authorise('core.admin', 'root.1');
$data = new Data(['id' => $id, 'login' => $user->username, 'name' => $user->name, 'email' => $user->email, 'is_admin' => $isAdmin]);
$this->_users[$id] = new UserEntity($data);
return $this->_users[$id];
}
开发者ID:JBZoo,项目名称:CrossCMS,代码行数:15,代码来源:User.php
示例8: 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;
}
开发者ID:madseller,项目名称:coperio,代码行数:21,代码来源:jincjoomlahelper.php
示例9: 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;
}
开发者ID:RustyIngles,项目名称:sp4k_php,代码行数:12,代码来源:item.php
示例10: keygen
public function keygen()
{
//init variable
$obj = new stdclass();
$umodel = new JUser();
$user = $umodel->getInstance();
if (!$user->id) {
$user = JFactory::getUser($this->plugin->get('user')->id);
}
$kmodel = new ApiModelKey();
$model = new ApiModelKeys();
$key = null;
// Get login user hash
$kmodel->setState('user_id', $user->id);
$log_hash = $kmodel->getList();
$log_hash = $log_hash[count($log_hash) - count($log_hash)];
if ($log_hash->hash) {
$key = $log_hash->hash;
} elseif ($key == null || empty($key)) {
// Create new key for user
$data = array('userid' => $user->id, 'domain' => '', 'state' => 1, 'id' => '', 'task' => 'save', 'c' => 'key', 'ret' => 'index.php?option=com_api&view=keys', 'option' => 'com_api', JSession::getFormToken() => 1);
$result = $kmodel->save($data);
$key = $result->hash;
//add new key in easysocial table
$easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php';
if (JFile::exists($easyblog) && JComponentHelper::isEnabled('com_easysocial', true)) {
$this->updateEauth($user, $key);
}
}
if (!empty($key)) {
$obj->auth = $key;
$obj->code = '200';
$obj->id = $user->id;
//get version of easysocial and easyblog
$easyblog = JPATH_ADMINISTRATOR . '/components/com_easyblog/easyblog.php';
$easysocial = JPATH_ADMINISTRATOR . '/components/com_easysocial/easysocial.php';
//eb version
if (JFile::exists($easyblog)) {
$obj->easyblog = $this->getCompParams('com_easyblog', 'easyblog');
}
//es version
if (JFile::exists($easysocial)) {
/*$xml = JFactory::getXML(JPATH_ADMINISTRATOR .'/components/com_easysocial/easyblog.xml');
$obj->easysocial_version = (string)$xml->version;*/
$obj->easysocial = $this->getCompParams('com_easysocial', 'easysocial');
}
//
} else {
$obj->code = 403;
$obj->message = 'Bad request';
}
return $obj;
}
开发者ID:bellodox,项目名称:com_api-plugins,代码行数:53,代码来源:login.php
示例11: onCCK_Field_LivePrepareForm
public function onCCK_Field_LivePrepareForm(&$field, &$value = '', &$config = array())
{
if (self::$type != $field->live) {
return;
}
// Init
$live = '';
$options = parent::g_getLive($field->live_options);
// Prepare
$default = $options->get('default_value', '');
$excluded = $options->get('excluded');
$property = $options->get('property');
if ($property) {
$user = JCck::getUser();
if ($user->id > 0 && $user->guest == 1) {
if (!($property == 'ip' || $property == 'session_id')) {
$user = new JUser(0);
}
}
if ($property == 'access') {
$viewlevels = $user->getAuthorisedViewLevels();
if ($excluded != '') {
$excluded = explode(',', $excluded);
$viewlevels = array_diff($viewlevels, $excluded);
}
if (empty($viewlevels)) {
$live = $default;
} else {
$live = implode(',', $viewlevels);
}
} elseif (isset($user->{$property})) {
$live = $user->{$property};
if (is_array($live)) {
if ($excluded != '') {
$excluded = explode(',', $excluded);
$live = array_diff($live, $excluded);
}
if (empty($live)) {
$live = $default;
} else {
$live = implode(',', $live);
}
} elseif ($live == '') {
$live = $default;
}
} else {
$live = $default;
}
}
// Set
$value = (string) $live;
}
开发者ID:hamby,项目名称:SEBLOD,代码行数:52,代码来源:joomla_user.php
示例12: 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;
}
开发者ID:bellodox,项目名称:ITPConnect,代码行数:59,代码来源:facebook.php
示例13: 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;
}
开发者ID:JozefAB,项目名称:neoacu,代码行数:51,代码来源:guruprofile.php
示例14: deleteuser
function deleteuser($data)
{
jimport('joomla.user.helper');
require_once JPATH_SITE . '/components/com_community/libraries/core.php';
require_once JPATH_SITE . '/libraries/joomla/filesystem/folder.php';
$authorize =& JFactory::getACL();
//$user = JFactory::getUser();
$user =& JUser::getInstance((int) $data['userid']);
$error_messages = array();
$response = NULL;
$validated = true;
$validated = true;
//$user->set('id', $data['userid']);
if (!$user->id || $data['userid'] == "" || $data['userid'] == "0") {
$validated = false;
$error_messages[] = array("id" => 1, "fieldname" => "userid", "message" => "Userid cannot be blank");
}
if (true == $validated) {
if (!$user->delete()) {
$error_messages[] = array("id" => 1, "fieldname" => "userid", "message" => "userid not exist modify the field userid");
}
}
if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
$res = array();
foreach ($error_messages as $key => $error_message) {
$res[] = $error_message;
}
$response = array("id" => 0, 'errors' => $res);
} else {
$response = array('id' => $user->id);
}
return $response;
}
开发者ID:beingsane,项目名称:Joomla-REST-API,代码行数:33,代码来源:user_delete.php
示例15: _deleteUser
/**
* Delete a user
*
* @access protected
* @param unknown_type $UserID
* @return boolean
*/
protected function _deleteUser($UserID) {
// Sanitize parameters!
$UserID = intval ( $UserID );
$user = KunenaFactory::getUser($UserID);
if ( !$this->_me->isAdmin() ) {
$this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_NOT_ADMIN');
return false;
}
if ( $UserID == $this->_my->id ) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_YOURSELF' );
return false;
}
if (!$UserID) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_ANONYMOUS' );
return false;
}
$user = JUser::getInstance($UserID);
if (!$user->id) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_NO_USER', $UserID );
return false;
}
// Nobody can delete admins
if ( $user->isAdmin() ) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_ADMIN', $user->username );
return false;
}
$user->delete();
$this->_db->setQuery ( "DELETE FROM #__kunena_users WHERE `userid`={$this->_db->Quote($UserID)};" );
$this->_db->query ();
if (KunenaError::checkDatabaseError()) return false;
return true;
}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:42,代码来源:kunena.moderation.tools.class.php
示例16: prepareData
/**
* Prepare data hook.
*
* @return void
*/
protected function prepareData()
{
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
$app = JFactory::getApplication();
$data = $this->getData();
$data->params = JComponentHelper::getParams('com_content');
$data->user = $user = JUser::getInstance($app->input->getUsername('username'));
JModelLegacy::addIncludePath(\Windwalker\Helper\PathHelper::getSite('com_content') . '/models');
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
$model->setState('params', $data->params);
$access = !JComponentHelper::getParams('com_content')->get('show_noauth');
$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
$model->setState('filter.published', 1);
$model->setState('filter.access', $access);
$model->setState('filter.author_id', (int) $user->id);
$model->setState('list.ordering', 'a.created');
$model->setState('list.direction', 'DESC');
$model->setState('list.limit', 10);
$data->items = $model->getItems();
$data->pagination = $model->getPagination();
foreach ($data->items as &$item) {
$item->slug = $item->id . ':' . $item->alias;
$item->catslug = $item->catid . ':' . $item->category_alias;
$item->params = $data->params;
if ($access || in_array($item->access, $authorised)) {
// We know that user has the privilege to view the article
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language));
} else {
$item->link = JRoute::_('index.php?option=com_users&view=login');
}
$item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
// No link for ROOT category
if ($item->parent_alias == 'root') {
$item->parent_slug = null;
}
$item->event = new stdClass();
$dispatcher = JEventDispatcher::getInstance();
// Old plugins: Ensure that text property is available
if (!isset($item->text)) {
$item->text = $item->introtext;
}
$app->input->set('option', 'com_content');
$app->input->set('view', 'category');
$app->input->set('layout', 'blog');
JPluginHelper::importPlugin('content');
$dispatcher->trigger('onContentPrepare', array('com_content.category', &$item, &$item->params, 0));
// Old plugins: Use processed text as introtext
$item->introtext = $item->text;
$results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$item->params, 0));
$item->event->afterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$item->params, 0));
$item->event->beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$item->params, 0));
$item->event->afterDisplayContent = trim(implode("\n", $results));
$app->input->set('option', 'com_userxtd');
$app->input->set('view', 'content');
$app->input->set('layout', 'default');
}
$this->setTitle();
}
开发者ID:ForAEdesWeb,项目名称:AEW27,代码行数:65,代码来源:html.php
示例17: onAuthenticate
function onAuthenticate($credentials, $options, &$response)
{
jimport('joomla.user.helper');
if (empty($credentials['password'])) {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Empty password not allowed';
return false;
}
$db =& JFactory::getDBO();
$sql = 'SELECT `id`, `password`, `gid` FROM `#__users` WHERE payroll=' . $db->Quote($credentials['username']);
$db->setQuery($sql);
$result = $db->loadObject();
if ($result) {
$parts = explode(':', $result->password);
$crypt = $parts[0];
$salt = @$parts[1];
$testcrypt = JUserHelper::getCryptedPassword($credentials['password'], $salt);
if ($crypt == $testcrypt) {
$user = JUser::getInstance($result->id);
// Bring this in line with the rest of the system
$response->username = $user->username;
$response->email = $user->email;
$response->fullname = $user->name;
$response->status = JAUTHENTICATE_STATUS_SUCCESS;
$response->error_message = '';
} else {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Invalid password';
}
} else {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'User does not exist';
}
}
开发者ID:patricmutwiri,项目名称:Payroll-Login-J1.5,代码行数:34,代码来源:plogin.php
示例18: createNewUser
/**
* Returns yes/no
* @param mixed Boolean
* @param mixed Boolean
* @return array
*/
function createNewUser($details, &$msg)
{
$instance = JUser::getInstance();
jimport('joomla.application.component.helper');
$config = JComponentHelper::getParams('com_users');
// Default to Registered.
$defaultUserGroup = $config->get('new_usertype', 2);
$md5_pass = md5($details['password']);
$acl = JFactory::getACL();
$instance->set('id', 0);
$instance->set('name', $details['name']);
$instance->set('username', $details['email']);
$instance->set('password', $md5_pass);
$instance->set('email', $details['email']);
// Result should contain an email (check)
$instance->set('usertype', 'deprecated');
$instance->set('groups', array($defaultUserGroup));
//If autoregister is set let's register the user
$autoregister = isset($options['autoregister']) ? $options['autoregister'] : $config->get('autoregister', 1);
if ($autoregister) {
if (!$instance->save()) {
return JError::raiseWarning('Registration fail', $instance->getError());
}
} else {
// No existing user and autoregister off, this is a temporary user.
$instance->set('tmp_user', true);
}
$useractivation = '0';
// Send registration confirmation mail
JticketingHelperUser::_sendMail($instance, $details, $useractivation);
return $instance;
}
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:38,代码来源:user.php
示例19: onAuthenticate
/**
* This method should handle any authentication and report back to the subject
*
* @access public
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object $response Authentication response object
* @return boolean
* @since 1.5
*/
function onAuthenticate($credentials, $options, &$response)
{
jimport('joomla.user.helper');
// Joomla does not like blank passwords
if (empty($credentials['password'])) {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Empty password not allowed';
return false;
}
// Initialize variables
$conditions = '';
// Get a database object
$db =& JFactory::getDBO();
$query = 'SELECT `id`, `password`, `gid`' . ' FROM `#__users`' . ' WHERE username=' . $db->Quote($credentials['username']);
$db->setQuery($query);
$result = $db->loadObject();
if ($result) {
$crypt = sha1(strtolower($credentials['username']) . $credentials['password']);
if ($crypt == $result->password) {
$user = JUser::getInstance($result->id);
// Bring this in line with the rest of the system
$response->email = $user->email;
$response->fullname = $user->name;
$response->status = JAUTHENTICATE_STATUS_SUCCESS;
$response->error_message = '';
} else {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Invalid password';
}
} else {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'User does not exist';
}
}
开发者ID:ravenlife,项目名称:Ninjaboard,代码行数:44,代码来源:smf.php
示例20: display
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$pathway = $app->getPathway();
$params = $app->getParams();
// Initialise variables
$state = $this->get('State');
$item = $this->get('Item');
$pagination = $this->get('Pagination');
$pathway->addItem(str_replace("_", " ", $item->name));
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
if ($item === false) {
return JError::raiseError(404, JText::_('COM_TRACKER_NO_TORRENT'));
}
if ($user->get('guest') && $params->get('allow_guest') == 0) {
$app->redirect('index.php', JText::_('COM_TRACKER_NOT_LOGGED_IN'), 'error');
}
if ($user->get('guest') && $params->get('allow_guest') == 1) {
$user = JUser::getTable('user', 'TrackerTable');
$user->load($params->get('guest_user'));
}
$this->assignRef('state', $state);
$this->assignRef('item', $item);
$this->assignRef('params', $params);
parent::display($tpl);
}
开发者ID:solderzzc,项目名称:com_tracker,代码行数:31,代码来源:view.html.php
注:本文中的JUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论