| [ Index ] |
PHP Cross Reference of Joomla 1.5.25 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: user.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage User 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant to the 9 * GNU General Public License, and as distributed it includes or is derivative 10 * of works licensed under the GNU General Public License or other free or open 11 * source software licenses. See COPYRIGHT.php for copyright notices and 12 * details. 13 */ 14 15 // Check to ensure this file is included in Joomla! 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 jimport('joomla.application.component.model'); 19 20 /** 21 * User Component User Model 22 * 23 * @package Joomla 24 * @subpackage User 25 * @since 1.5 26 */ 27 class UserModelUser extends JModel 28 { 29 /** 30 * User id 31 * 32 * @var int 33 */ 34 var $_id = null; 35 36 /** 37 * User data 38 * 39 * @var array 40 */ 41 var $_data = null; 42 43 /** 44 * Constructor 45 * 46 * @since 1.5 47 */ 48 function __construct() 49 { 50 parent::__construct(); 51 52 $id = JRequest::getVar('id', 0, '', 'int'); 53 $this->setId($id); 54 } 55 56 /** 57 * Method to set the weblink identifier 58 * 59 * @access public 60 * @param int Weblink identifier 61 */ 62 function setId($id) 63 { 64 // Set weblink id and wipe data 65 $this->_id = $id; 66 $this->_data = null; 67 } 68 69 /** 70 * Method to get a user 71 * 72 * @since 1.5 73 */ 74 function &getData() 75 { 76 // Load the weblink data 77 if ($this->_loadData()) { 78 //do nothing 79 } 80 81 return $this->_data; 82 } 83 84 /** 85 * Method to store the user data 86 * 87 * @access public 88 * @return boolean True on success 89 * @since 1.5 90 */ 91 function store($data) 92 { 93 $user = JFactory::getUser(); 94 $username = $user->get('username'); 95 96 // Bind the form fields to the user table 97 if (!$user->bind($data)) { 98 $this->setError($this->_db->getErrorMsg()); 99 return false; 100 } 101 102 // Store the web link table to the database 103 if (!$user->save()) { 104 $this->setError( $user->getError() ); 105 return false; 106 } 107 108 $session =& JFactory::getSession(); 109 $session->set('user', $user); 110 111 // check if username has been changed 112 if ( $username != $user->get('username') ) 113 { 114 $table = $this->getTable('session', 'JTable'); 115 $table->load($session->getId()); 116 $table->username = $user->get('username'); 117 $table->store(); 118 119 } 120 121 return true; 122 } 123 124 /** 125 * Method to load user data 126 * 127 * @access private 128 * @return boolean True on success 129 * @since 1.5 130 */ 131 function _loadData() 132 { 133 // Lets load the content if it doesn't already exist 134 if (empty($this->_data)) 135 { 136 $this->_data =& JFactory::getUser(); 137 return (boolean) $this->_data; 138 } 139 return true; 140 } 141 } 142 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Nov 14 16:47:20 2011 | Cross-referenced by PHPXref 0.7.1 |