当前位置: 首页>>代码示例>>PHP>>正文


PHP JUser::get方法代码示例

本文整理汇总了PHP中JUser::get方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::get方法的具体用法?PHP JUser::get怎么用?PHP JUser::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUser的用法示例。


在下文中一共展示了JUser::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onUserAuthenticate

 /**
  * Handles authentication via Twitter and reports back to the subject
  *
  * @param   array   $credentials  Array holding the user credentials
  * @param   array   $options      Array of extra options
  * @param   object  &$response    Authentication response object
  *
  * @return  boolean
  */
 public function onUserAuthenticate($credentials, $options, &$response)
 {
     $response->type = $this->_name;
     if (JArrayHelper::getValue($options, 'action') == 'core.login.site') {
         $username = JArrayHelper::getValue($credentials, 'username');
         $name = JArrayHelper::getValue($credentials, 'name');
         $email = JArrayHelper::getValue($credentials, 'email');
         if (!$username) {
             $response->status = JAuthentication::STATUS_FAILURE;
             $response->error_message = JText::_('JGLOBAL_AUTH_NO_USER');
             return false;
         }
         if ($user = new JUser(JUserHelper::getUserId($username))) {
             if ($user->get('block') || $user->get('activation')) {
                 $response->status = JAuthentication::STATUS_FAILURE;
                 $response->error_message = JText::_('JGLOBAL_AUTH_ACCESS_DENIED');
                 return;
             }
         }
         $response->email = $email;
         $response->fullname = $name;
         $response->username = $username;
         $response->status = JAuthentication::STATUS_SUCCESS;
         $response->error_message = '';
     }
 }
开发者ID:knowledgearc,项目名称:plugin-authentication-twitter,代码行数:35,代码来源:twitter.php

示例2: 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

示例3: edit

 function edit()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $me = JFactory::getUser();
     $user_id = JRequest::getInt("user_id");
     $user = JTable::getInstance('userShop', 'jshop');
     $user->load($user_id);
     $user_site = new JUser($user_id);
     $_countries = $this->getModel("countries");
     $countries = $_countries->getAllCountries(0);
     $lists['country'] = JHTML::_('select.genericlist', $countries, 'country', 'class = "inputbox" size = "1"', 'country_id', 'name', $user->country);
     $lists['d_country'] = JHTML::_('select.genericlist', $countries, 'd_country', 'class = "inputbox endes" size = "1"', 'country_id', 'name', $user->d_country);
     $user->birthday = getDisplayDate($user->birthday, $jshopConfig->field_birthday_format);
     $user->d_birthday = getDisplayDate($user->d_birthday, $jshopConfig->field_birthday_format);
     $option_title = array();
     foreach ($jshopConfig->user_field_title as $key => $value) {
         $option_title[] = JHTML::_('select.option', $key, $value, 'title_id', 'title_name');
     }
     $lists['select_titles'] = JHTML::_('select.genericlist', $option_title, 'title', 'class = "inputbox"', 'title_id', 'title_name', $user->title);
     $lists['select_d_titles'] = JHTML::_('select.genericlist', $option_title, 'd_title', 'class = "inputbox endes"', 'title_id', 'title_name', $user->d_title);
     $client_types = array();
     foreach ($jshopConfig->user_field_client_type as $key => $value) {
         $client_types[] = JHTML::_('select.option', $key, $value, 'id', 'name');
     }
     $lists['select_client_types'] = JHTML::_('select.genericlist', $client_types, 'client_type', 'class = "inputbox" ', 'id', 'name', $user->client_type);
     $_usergroups = $this->getModel("userGroups");
     $usergroups = $_usergroups->getAllUsergroups();
     $lists['usergroups'] = JHTML::_('select.genericlist', $usergroups, 'usergroup_id', 'class = "inputbox" size = "1"', 'usergroup_id', 'usergroup_name', $user->usergroup_id);
     $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user_site->get('block'));
     filterHTMLSafe($user, ENT_QUOTES);
     $tmp_fields = $jshopConfig->getListFieldsRegister();
     $config_fields = $tmp_fields['editaccount'];
     $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('editaccount');
     JHTML::_('behavior.calendar');
     $view = $this->getView("users", 'html');
     $view->setLayout("edit");
     $view->assign('config', $jshopConfig);
     $view->assign('user', $user);
     $view->assign('me', $me);
     $view->assign('user_site', $user_site);
     $view->assign('lists', $lists);
     $view->assign('etemplatevar', '');
     $view->assign('config_fields', $config_fields);
     $view->assign('count_filed_delivery', $count_filed_delivery);
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeEditUsers', array(&$view));
     $view->displayEdit();
 }
开发者ID:ngogiangthanh,项目名称:damtvnewversion,代码行数:51,代码来源:users.php

示例4: isLiked

 /**
  * Checks if the content is liked.
  *
  * @return  boolean  True if user liked the content, false otherwise.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function isLiked()
 {
     // Assert the object is loaded.
     $this->assertIsLoaded();
     // Build a database query to check the liked state.
     $query = $this->db->getQuery(true);
     $query->select('*');
     $query->from($this->db->qn('#__content_likes'));
     $query->where('content_id = ' . (int) $this->content_id);
     $query->where('user_id = ' . (int) $this->user->get('id'));
     // Check the liked state.
     $this->db->setQuery($query);
     $result = $this->db->loadObject();
     return empty($result) ? false : true;
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:24,代码来源:content.php

示例5: edit

 function edit()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $me = JFactory::getUser();
     $user_id = JRequest::getInt("user_id");
     $user = JSFactory::getTable('userShop', 'jshop');
     $user->load($user_id);
     $user->loadDataFromEdit();
     $user_site = new JUser($user_id);
     $lists['country'] = JshopHelpersSelects::getCountry($user->country);
     $lists['d_country'] = JshopHelpersSelects::getCountry($user->d_country, 'class = "inputbox endes"', 'd_country');
     $lists['select_titles'] = JshopHelpersSelects::getTitle($user->title);
     $lists['select_d_titles'] = JshopHelpersSelects::getTitle($user->d_title, 'class = "inputbox endes"', 'd_title');
     $lists['select_client_types'] = JshopHelpersSelects::getClientType($user->client_type);
     $usergroups = JSFactory::getModel("userGroups")->getAllUsergroups();
     $lists['usergroups'] = JHTML::_('select.genericlist', $usergroups, 'usergroup_id', 'class = "inputbox" size = "1"', 'usergroup_id', 'usergroup_name', $user->usergroup_id);
     $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user_site->get('block'));
     filterHTMLSafe($user, ENT_QUOTES);
     $tmp_fields = $jshopConfig->getListFieldsRegister();
     $config_fields = $tmp_fields['editaccount'];
     $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('editaccount');
     JHTML::_('behavior.calendar');
     $view = $this->getView("users", 'html');
     $view->setLayout("edit");
     $view->assign('config', $jshopConfig);
     $view->assign('user', $user);
     $view->assign('me', $me);
     $view->assign('user_site', $user_site);
     $view->assign('lists', $lists);
     $view->assign('etemplatevar', '');
     $view->assign('config_fields', $config_fields);
     $view->assign('count_filed_delivery', $count_filed_delivery);
     JDispatcher::getInstance()->trigger('onBeforeEditUsers', array(&$view));
     $view->displayEdit();
 }
开发者ID:panickylemon,项目名称:joomlastayn,代码行数:37,代码来源:users.php

示例6: onLoginUser

 function onLoginUser($user, $options)
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return true;
     }
     $user_id = 0;
     if (empty($user['id'])) {
         if (!empty($user['username'])) {
             jimport('joomla.user.helper');
             $instance = new JUser();
             if ($id = intval(JUserHelper::getUserId($user['username']))) {
                 $instance->load($id);
             }
             if ($instance->get('block') == 0) {
                 $user_id = $instance->id;
             }
         }
     } else {
         $user_id = $user['id'];
     }
     $this->restoreSession($user_id);
     if (empty($user_id)) {
         return true;
     }
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
         return true;
     }
     $userClass = hikashop_get('class.user');
     $hika_user_id = $userClass->getID($user_id, 'cms');
     if (empty($hika_user_id)) {
         return true;
     }
     $addressClass = hikashop_get('class.address');
     $addresses = $addressClass->getByUser($hika_user_id);
     if (empty($addresses) || !count($addresses)) {
         return true;
     }
     $address = reset($addresses);
     $field = 'address_country';
     if (!empty($address->address_state)) {
         $field = 'address_state';
     }
     $app->setUserState(HIKASHOP_COMPONENT . '.shipping_address', $address->address_id);
     $app->setUserState(HIKASHOP_COMPONENT . '.billing_address', $address->address_id);
     $zoneClass = hikashop_get('class.zone');
     $zone = $zoneClass->get($address->{$field});
     if (!empty($zone)) {
         $zone_id = $zone->zone_id;
         $app->setUserState(HIKASHOP_COMPONENT . '.zone_id', $zone->zone_id);
     }
 }
开发者ID:rodhoff,项目名称:MNW,代码行数:55,代码来源:hikashopuser.php

示例7: saveJanrainEngageUser

function saveJanrainEngageUser($auth_info) 
{
	global $mainframe;
	jimport('joomla.user.helper');
	$db		=& JFactory::getDBO();
	$my 	=& JFactory::getUser();
	$uri 	=& JFactory::getURI();
	$host 	= $uri->getHost();

	// process the auth_info response
	$profileValues 	= $auth_info['profile'];
	$identifier 	= $profileValues['identifier'];	
	
	if( !isset($auth_info['profile']['email'] )) 
	{
		$nameDisp = str_replace(' ','_',$auth_info['profile']['displayName']);
		$auth_info['profile']['email'] = $nameDisp.'@'.$host;
	}
	
	$query = "SELECT `id` FROM #__users WHERE `email`='".$auth_info['profile']['email']."'";
	$db->setQuery($query);
	$userid = $db->loadResult();
	
	$newuser = true;
	if( isset($userid) ) 
	{
		$user =& JFactory::getUser($userid);
		if ($user->id == $userid) 
		{
            $newuser = false;
        }
	}
	if($newuser == true) 
	{
		//save the user
		$user 			= new JUser();
		$authorize 		=& JFactory::getACL();
		$date 			=& JFactory::getDate();
		$uriInfo 		= JFactory::getURI();
		$host 			= $uriInfo->getHost();
		$usersConfig	=& JComponentHelper::getParams( 'com_users' );
		$newUsertype	= $usersConfig->get( 'new_usertype' );
		
		$user->set('id', 0);
		$user->set('usertype', $newUsertype);
		$user->set('gid', $authorize->get_group_id('',$newUsertype, 'ARO'));
		$user->set('registerDate', $date->toMySQL());
		
		if(isset($auth_info['profile']['displayName'])) 
		{
			$displayName = $auth_info['profile']['displayName'];
		} 
		elseif(isset($auth_info['profile']['name']['displayName'])) 
		{
			$displayName = $auth_info['profile']['name']['displayName'];
		}
		
		if(isset($auth_info['profile']['preferredUsername'])) 
		{
			$preferredUsername = $auth_info['profile']['preferredUsername'];
		} 
		elseif(isset($auth_info['profile']['name']['preferredUsername'])) 
		{
			$preferredUsername = $auth_info['profile']['name']['preferredUsername'];
		}

		$user->set('name', $displayName);
		// if username already exists, just add an index to it
		$nameexists = true;
		$index 		= 0;
		$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);
		
//.........这里部分代码省略.........
开发者ID:rkern21,项目名称:videoeditor,代码行数:101,代码来源:mod_janrainengage.php

示例8: save

 /**
  * Saves the record
  */
 function save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $option = JRequest::getCmd('option');
     // Initialize some variables
     $db =& JFactory::getDBO();
     $me =& JFactory::getUser();
     $acl =& JFactory::getACL();
     $MailFrom = $mainframe->getCfg('mailfrom');
     $FromName = $mainframe->getCfg('fromname');
     $SiteName = $mainframe->getCfg('sitename');
     // Create a new JUser object
     $user = new JUser(JRequest::getVar('id', 0, 'post', 'int'));
     $original_gid = $user->get('gid');
     $post = JRequest::get('post');
     $post['username'] = JRequest::getVar('username', '', 'post', 'username');
     $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if (!$user->bind($post)) {
         $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
         $mainframe->enqueueMessage($user->getError(), 'error');
         //$mainframe->redirect( 'index.php?option=com_users', $user->getError() );
         //return false;
         return $this->execute('edit');
     }
     $objectID = $acl->get_object_id('users', $user->get('id'), 'ARO');
     $groups = $acl->get_object_groups($objectID, 'ARO');
     $this_group = strtolower($acl->get_group_name($groups[0], 'ARO'));
     if ($user->get('id') == $me->get('id') && $user->get('block') == 1) {
         $msg = JText::_('You cannot block Yourself!');
         $mainframe->enqueueMessage($msg, 'message');
         return $this->execute('edit');
     } else {
         if ($this_group == 'super administrator' && $user->get('block') == 1) {
             $msg = JText::_('You cannot block a Super Administrator');
             $mainframe->enqueueMessage($msg, 'message');
             return $this->execute('edit');
         } else {
             if ($this_group == 'administrator' && $me->get('gid') == 24 && $user->get('block') == 1) {
                 $msg = JText::_('WARNBLOCK');
                 $mainframe->enqueueMessage($msg, 'message');
                 return $this->execute('edit');
             } else {
                 if ($this_group == 'super administrator' && $me->get('gid') != 25) {
                     $msg = JText::_('You cannot edit a super administrator account');
                     $mainframe->enqueueMessage($msg, 'message');
                     return $this->execute('edit');
                 }
             }
         }
     }
     // 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';
             $db->setQuery($query);
             $count = $db->loadResult();
             if ($count <= 1) {
                 // disallow change if only one Super Admin exists
                 $this->setRedirect('index.php?option=com_users', JText::_('WARN_ONLY_SUPER'));
                 return false;
             }
         }
     }
     /*
      * Lets save the JUser object
      */
     if (!$user->save()) {
         $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
         $mainframe->enqueueMessage($user->getError(), 'error');
         return $this->execute('edit');
     }
     /*
      * Time for the email magic so get ready to sprinkle the magic dust...
      */
     if ($isNew) {
         $adminEmail = $me->get('email');
         $adminName = $me->get('name');
         $subject = JText::_('NEW_USER_MESSAGE_SUBJECT');
         $message = sprintf(JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear);
         if ($MailFrom != '' && $FromName != '') {
             $adminName = $FromName;
             $adminEmail = $MailFrom;
         }
         JUtility::sendMail($adminEmail, $adminName, $user->get('email'), $subject, $message);
     }
     // If updating self, load the new user object into the session
     if ($user->get('id') == $me->get('id')) {
         // Get an ACL object
         $acl =& JFactory::getACL();
         // Get the user group from the ACL
         $grp = $acl->getAroGroup($user->get('id'));
//.........这里部分代码省略.........
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:101,代码来源:controller.php

示例9: storeVM25

 /**
  * Bind the post data to the JUser object and the VM tables, then saves it
  * It is used to register new users
  * This function can also change already registered users, this is important when a registered user changes his email within the checkout.
  *
  * @author Max Milbers
  * @author Oscar van Eijk
  * @return boolean True is the save was successful, false otherwise.
  */
 public static function storeVM25(&$data, $checkToken = TRUE, &$userModel, $opc_no_activation = false, &$opc)
 {
     $message = '';
     $user = '';
     $newId = 0;
     if ($checkToken) {
         JRequest::checkToken() or jexit('Invalid Token, while trying to save user');
     }
     $mainframe = JFactory::getApplication();
     if (empty($data)) {
         vmError('Developer notice, no data to store for user');
         return false;
     }
     //To find out, if we have to register a new user, we take a look on the id of the usermodel object.
     //The constructor sets automatically the right id.
     $user = JFactory::getUser();
     $user_id = $user->id;
     $new = $user->id < 1;
     if (empty($user_id)) {
         $user = new JUser();
         //thealmega http://forum.virtuemart.net/index.php?topic=99755.msg393758#msg393758
     } else {
         $user = JFactory::getUser($user_id);
     }
     $gid = $user->get('gid');
     // Save original gid
     // Preformat and control user datas by plugin
     JPluginHelper::importPlugin('vmuserfield');
     $dispatcher = JDispatcher::getInstance();
     $valid = true;
     $dispatcher->trigger('plgVmOnBeforeUserfieldDataSave', array(&$valid, $user_id, &$data, $user));
     // $valid must be false if plugin detect an error
     if ($valid == false) {
         return false;
     }
     // Before I used this "if($cart && !$new)"
     // This construction is necessary, because this function is used to register a new JUser, so we need all the JUser data in $data.
     // On the other hand this function is also used just for updating JUser data, like the email for the BT address. In this case the
     // name, username, password and so on is already stored in the JUser and dont need to be entered again.
     if (empty($data['email'])) {
         $email = $user->get('email');
         if (!empty($email)) {
             $data['email'] = $email;
         }
     }
     $data['email'] = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $data['email']);
     unset($data['isRoot']);
     unset($data['groups']);
     unset($data['_authGroups']);
     //This is important, when a user changes his email address from the cart,
     //that means using view user layout edit_address (which is called from the cart)
     $user->set('email', $data['email']);
     if (empty($data['name'])) {
         $name = $user->get('name');
         if (!empty($name)) {
             $data['name'] = $name;
         }
     }
     if (empty($data['name'])) {
         $data['name'] = '';
         if (!empty($data['first_name'])) {
             $data['name'] = $data['first_name'];
         }
         if ($data['name'] == '_') {
             $data['name'] = '';
         }
         if (!empty($data['last_name'])) {
             $data['name'] = $data['last_name'];
         }
         if ($data['name'] == '_') {
             $data['name'] = '';
         }
         if (empty($data['name'])) {
             $data['name'] = $data['username'];
         }
         if ($data['name'] == '_') {
             $data['name'] = '';
         }
         if (empty($data['name'])) {
             $data['name'] = $data['email'];
         }
     }
     if (empty($data['username'])) {
         $username = $user->get('username');
         if (!empty($username)) {
             $data['username'] = $username;
         } else {
             $data['username'] = JRequest::getVar('username', '', 'post', 'username');
             if (empty($data['username'])) {
                 $data['username'] = $data['email'];
             }
//.........这里部分代码省略.........
开发者ID:aldegtyarev,项目名称:stelsvelo,代码行数:101,代码来源:user.php

示例10: juserRegister

	public static function juserRegister($juser) {
		$result = array();
		$oseMscconfig = oseRegistry::call('msc')->getConfig('', 'obj');
		$config = JFactory::getConfig();
		$params = JComponentHelper::getParams('com_users');
		$newUserType = self::getNewUserType($params->get('new_usertype'));
		$juser['gid'] = $newUserType;
		$data = (array) self::getJuserData($juser);
		// Initialise the table with JUser.
		$user = new JUser;
		foreach ($juser as $k => $v) {
			$data[$k] = $v;
		}
		// Prepare the data for the user object.
		$useractivation = $params->get('useractivation');
		// Check if the user needs to activate their account.
		if (($useractivation == 1) || ($useractivation == 2)) {
			jimport('joomla.user.helper');
			$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
			$data['block'] = 1;
		}
		// Bind the data.
		if (!$user->bind($data)) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError());
		}
		// Load the users plugin group.
		JPluginHelper::importPlugin('user');
		if (!$user->save()) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['reload'] = ($oseMscconfig->error_registration == 'refresh') ? true : false;
			;
			$result['content'] = JText::_($user->getError());
		} else {
			// Mark the user_id in order to user in payment form
			if (($useractivation == 1) || ($useractivation == 2)) {
				$session = JFactory::getSession();
				$oseUser = array();
				$oseUser['user_id'] = $user->id;
				$oseUser['block'] = true;
				$oseUser['activation'] = true;
				$session->set('ose_user', $oseUser);
			}
			$result['success'] = true;
			$result['user'] = $user;
			$result['title'] = 'Done';
			$result['content'] = 'Juser saved successfully';
			// 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();
			if (JOOMLA16 == true) {
				// 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_OSEMSC_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
					$emailBody = JText::sprintf('COM_USERS_OSEMSC_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']);
				} else if ($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_OSEMSC_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
					$emailBody = JText::sprintf('COM_USERS_OSEMSC_EMAIL_REGISTERED_WITH_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']);
				} else {
					$emailSubject = "";
					$emailBody = "";
				}
				// Send the registration email.
				if (!empty($emailSubject) && !empty($emailBody)) {
					if (JOOMLA30 == true) {
						$mailer = new JMail();
						$return = $mailer->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
					} else {
						$return = JUtility::sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
					}
				} else {
					$return = true;
				}
				// Check for an error.
				if ($return !== true) {
					$this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED'));
					// Send a system message to administrators receiving system mails
					$db = JFactory::getDBO();
					$q = "SELECT id
						FROM #__users
						WHERE block = 0
						AND sendEmail = 1";
					$db->setQuery($q);
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:oseMscPublic.php

示例11: jimport

 /** Check to see if the user may access (see/download) the attachments
  * @param JUser $user : the current user object
  * @param int $id : The id of the attachment
  * @return true if access is okay (false if not)
  */
 function user_may_access_attachment($user, $id)
 {
     // NOTE: This implementation is pretty dumb...
     // Get the component parameters
     jimport('joomla.application.component.helper');
     $params = JComponentHelper::getParams('com_attachments');
     $who_can_see = $params->get('who_can_see', 'logged_in');
     $logged_in = $user->get('username') != '';
     if ($who_can_see == 'anyone' || $who_can_see == 'logged_in' && $logged_in) {
         return true;
     }
     return false;
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:18,代码来源:permissions.php

示例12: doUserLogIn

function doUserLogIn($username)
{
    $my = new JUser();
    jimport('joomla.user.helper');
    if ($id = intval(JUserHelper::getUserId($username))) {
        $my->load($id);
    } else {
        return JError::raiseWarning('SOME_ERROR_CODE', 'MigrationAssistant (doUserLogIn): Failed to load user');
    }
    // If the user is blocked, redirect with an error
    if ($my->get('block') == 1) {
        return JError::raiseWarning('SOME_ERROR_CODE', JText::_('E_NOLOGIN_BLOCKED'));
    }
    //Mark the user as logged in
    $my->set('guest', 0);
    // Discover the access group identifier
    // NOTE : this is a very basic for of permission handling, will be replaced by a full ACL in 1.6
    jimport('joomla.factory');
    $acl =& JFactory::getACL();
    $grp = $acl->getAroGroup($my->get('id'));
    $my->set('aid', 1);
    if ($acl->is_group_child_of($grp->name, 'Registered', 'ARO') || $acl->is_group_child_of($grp->name, 'Public Backend', 'ARO')) {
        // fudge Authors, Editors, Publishers and Super Administrators into the special access group
        $my->set('aid', 2);
    }
    //Set the usertype based on the ACL group name
    $my->set('usertype', $grp->name);
    // Register the needed session variables
    $session =& JFactory::getSession();
    $session->set('user', $my);
    // Get the session object
    $table =& JTable::getInstance('session');
    $table->load($session->getId());
    $table->guest = $my->get('guest');
    $table->username = $my->get('username');
    $table->userid = intval($my->get('id'));
    $table->usertype = $my->get('usertype');
    $table->gid = intval($my->get('gid'));
    $table->update();
    // Hit the user last visit field
    $my->setLastVisit();
    // Set remember me option
    $lifetime = time() + 365 * 24 * 60 * 60;
    setcookie('usercookie[username]', $my->get('username'), $lifetime, '/');
    setcookie('usercookie[password]', $my->get('password'), $lifetime, '/');
}
开发者ID:planetangel,项目名称:Planet-Angel-Website,代码行数:46,代码来源:tasks.php

示例13: save

 /**
  * Saves the record
  */
 function save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     #-Kobby edits this section
     #-Insert the user redirects urls over here
     #-User Detail for our Redirects
     $redirect_URL_FRONT = JRequest::getVar('redirect_URL_FRONT');
     $redirect_URL_ADMIN = JRequest::getVar('redirect_URL_ADMIN');
     $user = new JUser(JRequest::getVar('id', 0, 'post', 'int'));
     $option = JRequest::getCmd('option');
     // Initialize some variables
     $db =& JFactory::getDBO();
     $me =& JFactory::getUser();
     $acl =& JFactory::getACL();
     $MailFrom = $mainframe->getCfg('mailfrom');
     $FromName = $mainframe->getCfg('fromname');
     $SiteName = $mainframe->getCfg('sitename');
     // Create a new JUser object
     $user = new JUser(JRequest::getVar('id', 0, 'post', 'int'));
     $original_gid = $user->get('gid');
     $post = JRequest::get('post');
     $post['username'] = JRequest::getVar('username', '', 'post', 'username');
     $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if (!$user->bind($post)) {
         $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
         $mainframe->enqueueMessage($user->getError(), 'error');
         //$mainframe->redirect( 'index.php?option=com_users', $user->getError() );
         //return false;
         return $this->execute('edit');
     }
     $objectID = $acl->get_object_id('users', $user->get('id'), 'ARO');
     $groups = $acl->get_object_groups($objectID, 'ARO');
     $this_group = strtolower($acl->get_group_name($groups[0], 'ARO'));
     if ($user->get('id') == $me->get('id') && $user->get('block') == 1) {
         $msg = JText::_('You cannot block Yourself!');
         $mainframe->enqueueMessage($msg, 'message');
         return $this->execute('edit');
     } else {
         if ($this_group == 'super administrator' && $user->get('block') == 1) {
             $msg = JText::_('You cannot block a Super Administrator');
             $mainframe->enqueueMessage($msg, 'message');
             return $this->execute('edit');
         } else {
             if ($this_group == 'administrator' && $me->get('gid') == 24 && $user->get('block') == 1) {
                 $msg = JText::_('WARNBLOCK');
                 $mainframe->enqueueMessage($msg, 'message');
                 return $this->execute('edit');
             } else {
                 if ($this_group == 'super administrator' && $me->get('gid') != 25) {
                     $msg = JText::_('You cannot edit a super administrator account');
                     $mainframe->enqueueMessage($msg, 'message');
                     return $this->execute('edit');
                 }
             }
         }
     }
     // 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';
             $db->setQuery($query);
             $count = $db->loadResult();
             if ($count <= 1) {
                 // disallow change if only one Super Admin exists
                 $this->setRedirect('index.php?option=com_community_acl&mode=manage_users', JText::_('WARN_ONLY_SUPER'));
                 return false;
             }
         }
     }
     /*
      * Lets save the JUser object
      */
     if (!$user->save()) {
         $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message');
         $mainframe->enqueueMessage($user->getError(), 'error');
         return $this->execute('edit');
     }
     /*
      * Time for the email magic so get ready to sprinkle the magic dust...
      */
     if ($isNew) {
         $adminEmail = $me->get('email');
         $adminName = $me->get('name');
         $subject = JText::_('NEW_USER_MESSAGE_SUBJECT');
         $message = sprintf(JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear);
         if ($MailFrom != '' && $FromName != '') {
             $adminName = $FromName;
             $adminEmail = $MailFrom;
         }
         JUtility::sendMail($adminEmail, $adminName, $user->get('email'), $subject, $message);
     }
//.........这里部分代码省略.........
开发者ID:vincethecoder,项目名称:community_acl,代码行数:101,代码来源:controller.php

示例14: onAfterInitialise

  function onAfterInitialise() {
    $lrdata = array(); $user_id = ''; $id = ''; $email = ''; $msg = ''; $defaultUserGroups = ''; $lr_settings = array();
    $lr_settings = plgSystemSocialLoginTools::sociallogin_getsettings ();

	// Get module configration option value
	$mainframe = JFactory::getApplication();
	$db = JFactory::getDBO();
    $config = JFactory::getConfig();
    $language = JFactory::getLanguage();
	$session = JFactory::getSession();
	$language->load('com_users');
	$language->load('com_socialloginandsocialshare', JPATH_ADMINISTRATOR);
	$authorize = JFactory::getACL();
	$input = JFactory::getApplication()->input;
	$code = $input->get('code', null, 'STRING');
	$provider = $input->get('provider', null, 'STRING');
	// Checking user is logged in.
	if (isset($code) && !empty($code)) {
		if($provider=='google'){
			$userprofile = googlelogin::acsses_token($code, $lr_settings);
			$lrdata = googlelogin::userprofile_data($userprofile);
		}elseif($provider=='facebook'){
			$userprofile = facebooklogin::acsses_token($code, $lr_settings);
			$lrdata = facebooklogin::userprofile_data($userprofile);
		}
	}

	// User is not logged in trying to make log in user.
	if (isset($lrdata) && !empty($lrdata) && !JFactory::getUser()->id) {

	  // Remove the session if any.
	  if ($session->get('tmpuser')) {
	    $session->clear('tmpuser');
	  }
	  //$lrdata = plgSystemSocialLoginTools::facebook_userprofile_data($userprofile);
	  // Find the not activate user.
	   $query = "SELECT u.id FROM #__users AS u INNER JOIN #__LoginRadius_users AS lu ON lu.id = u.id WHERE lu.LoginRadius_id = '".$lrdata['id']."' AND u.activation != '' AND u.activation != 0";
	   $db->setQuery($query);
	   $block_id = $db->loadResult();
	   if (!empty($block_id) || $block_id) {
	     JError::raiseWarning ('', JText::_ ('COM_SOCIALLOGIN_USER_NOTACTIVATE'));
		 return false;
	   }  

	  // Find the block user.
	   $query = "SELECT u.id FROM #__users AS u INNER JOIN #__LoginRadius_users AS lu ON lu.id = u.id WHERE lu.LoginRadius_id = '".$lrdata['id']."' AND u.block = 1";
	   $db->setQuery($query);
	   $block_id = $db->loadResult();
	   if (!empty($block_id) || $block_id) {
	     JError::raiseWarning ('', JText::_ ('COM_SOCIALLOGIN_USER_BLOCK'));
		 return false;
	   }
	 }

	// Checking user click on popup cancel button.
	if (isset($lrdata['id']) && !empty($lrdata['id']) && !empty($lrdata['email'])) {
	  // Filter username form data.
	  if (!empty($lrdata['fname']) && !empty($lrdata['lname'])) {
	    $username = $lrdata['fname'].$lrdata['lname'];
	    $name = $lrdata['fname'];

	  }
	  else {
	    $username = plgSystemSocialLoginTools::get_filter_username($lrdata);
	    $name = plgSystemSocialLoginTools::get_filter_username($lrdata);
	  }
	 $query="SELECT u.id FROM #__users AS u INNER JOIN #__LoginRadius_users AS lu ON lu.id = u.id WHERE lu.LoginRadius_id = '".$lrdata['id']."'";
	 $db->setQuery($query);
	 $user_id = $db->loadResult();      

	  // If not then check for email exist.
	  if (empty($user_id)) {
        $query = "SELECT id FROM #__users WHERE email='".$lrdata['email']."'";
        $db->setQuery($query);
        $user_id = $db->loadResult(); 
		if (!empty($user_id)) {
		  $query = "SELECT LoginRadius_id from #__LoginRadius_users WHERE LoginRadius_id=".$db->Quote ($lrdata['id'])." AND id = " . $user_id;
          $db->setQuery($query);
          $check_id = $db->loadResult();
	      if (empty($check_id)) {

		    // Add new id to db.
		    $userImage = $lrdata['thumbnail'];
		    $sql = "INSERT INTO #__LoginRadius_users SET id = " . $user_id . ", LoginRadius_id = " . $db->Quote ($lrdata['id']).", provider = " . $db->Quote ($lrdata['Provider']) . ", lr_picture = " . $db->Quote ($userImage);
            $db->setQuery ($sql);
	        $db->execute();
		  }
		}
	  }
	  $newuser = true;
      if (isset($user_id)) {
	    $user = JFactory::getUser($user_id);
        if ($user->id == $user_id) {
          $newuser = false;
        }
	  }
	  if ($newuser == true) {
	  $user = new JUser;
	  $need_verification = false;
	  
//.........这里部分代码省略.........
开发者ID:networksoft,项目名称:seekerplus2.com,代码行数:101,代码来源:socialloginandsocialshare.php

示例15: register

 public function register($temp, $configuration = array())
 {
     $config = JFactory::getConfig();
     $params = JComponentHelper::getParams('com_users');
     ## Initialise the table with JUser.
     $user = new JUser();
     $data = (array) $this->getUserData();
     ## Merge in the registration data.
     foreach ($temp as $k => $v) {
         $data[$k] = $v;
     }
     ## If we want autologin this is needed.
     $userlogin['username'] = $data[username];
     $userlogin['password'] = $data[password];
     $useractivation = $params->get('useractivation');
     ## Check if the user needs to activate their account.
     if ($useractivation == 1 || $useractivation == 2) {
         jimport('joomla.user.helper');
         $data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
         $data['block'] = 1;
         $db = JFactory::getDBO();
         $sql = "SELECT activation_email, companyname \n\t\t\t\t\tFROM #__ticketmaster_config \n\t\t\t\t\tWHERE configid = 1";
         $db->setQuery($sql);
         $configuration = $db->loadObject();
         ## We need to send an email to let the user activate their account.
         ## Getting the desired info from the configuration table
         $sql = "SELECT * FROM #__ticketmaster_emails WHERE emailid = " . (int) $configuration->activation_email . "";
         $db->setQuery($sql);
         $config = $db->loadObject();
         $actvivation = JURI::base() . 'index.php?option=com_ticketmaster&controller=checkout&task=activate&token=' . $data['activation'];
         $message = str_replace('%%ACTIVATION_CODE%%', $actvivation, $config->mailbody);
         $message = str_replace('%%NAME%%', $data['name'], $message);
         $message = str_replace('%%FIRSTNAME%%', $data['firstname'], $message);
         $message = str_replace('%%COMPANY%%', $configuration->companyname, $message);
         $message = str_replace('%%EMAIL%%', $data['email'], $message);
         $message = str_replace('%%USERNAME%%', $userlogin['username'], $message);
         $message = str_replace('%%PASSWORD%%', $userlogin['password'], $message);
         $message = str_replace('%%CODE_ONLY%%', $data['activation'], $message);
         ## Imaport mail functions:
         jimport('joomla.mail.mail');
         ## Set the sender of the email:
         $sender[0] = $config->from_email;
         $sender[1] = $config->from_name;
         ## Compile mailer function:
         $obj = JFactory::getMailer();
         $obj->setSender($sender);
         $obj->isHTML(true);
         $obj->setBody($message);
         $obj->addRecipient($data['email']);
         ## Send blind copy to site admin?
         if ($config->receive_bcc == 1) {
             if ($config->reply_to_email != '') {
                 $obj->addRecipient($mail->reply_to_email);
             }
         }
         ## Add reply to and subject:
         $obj->addReplyTo($config->reply_to_email);
         $obj->setSubject($config->mailsubject);
         if ($config->published == 1) {
             $sent = $obj->Send();
         }
     } else {
         $data['activation'] = '';
         $data['block'] = 0;
     }
     ## 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.
     $user->save();
     ## getting the userid.
     $userid = $user->get('id');
     return $userid;
 }
开发者ID:novalnetuser,项目名称:Jeremiah-s-Ranch,代码行数:78,代码来源:checkout.php


注:本文中的JUser::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。