joomlaǵעȨ©

©

¶״̬



2012-03-24 ϵ̲ҵȴУϸڲ⹫
 2012-05-08 Ѿ©ϸڹ


Ҫ

joomlaûע̴һ©Ե¹ֱעԱȨʺš

ϸ˵

/components/com_users/controllers/registration.php
 
public function register()
{
// token
JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
... ...
// ʼûעģ
$app = JFactory::getApplication();
$model = $this->getModel('Registration', 'UsersModel');
// طȡûעϢPOSTjform飬ûϸָ
$requestData = JRequest::getVar('jform', array(), 'post', 'array');
... ...
// ֤
$data = $model->validate($form, $requestData);
... ...
// ûעύregisterģ鴦һ
$return = $model->register($data);
... ...
// ҳ
if ($return === 'adminactivate'){
$this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY'));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
} elseif ($return === 'useractivate') {
$this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE'));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
} else {
$this->setMessage(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS'));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
}

 
/components/com_users/models/registration.php
 
public function getData()
{
if ($this->data === null) {
$this->data = new stdClass();
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_users');
... ...
/* ĬûidΪ2joomlaṹ
mysql> select * from ilpy2_usergroups;
+----+-----------+-----+-----+--------------------------+
| id | parent_id | lft | rgt | title                    |
+----+-----------+-----+-----+--------------------------+
|  1 |         0 |   1 |  20 | Public                   |
|  2 |         1 |   6 |  17 | Registered               |
|  3 |         2 |   7 |  14 | Author                   |
|  4 |         3 |   8 |  11 | Editor                   |
|  5 |         4 |   9 |  10 | Publisher                |
|  6 |         1 |   2 |   5 | Manager                  |
|  7 |         6 |   3 |   4 | Administrator            |
|  8 |         1 |  18 |  19 | Super Users              |
| 12 |         2 |  15 |  16 | Customer Group (Example) |
| 10 |         3 |  12 |  13 | Shop Suppliers (Example) |
+----+-----------+-----+-----+--------------------------+
*/
$system = $params->get('new_usertype', 2);
$this->data->groups[] = $system;
... ...
public function register($temp)
{
$config = JFactory::getConfig();
$db= $this->getDbo();
$params = JComponentHelper::getParams('com_users');
// Initialise the table with JUser.
$user = new JUser;
//ע⣬ڱûעϢǰ˵
$data = (array)$this->getData();
// עϢ
foreach ($temp as $k => $v) {
$data[$k] = $v;
}
... ...
// 
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');
// ûע
if (!$user->save()) {
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
return false;
}

 
libraries/joomla/user/user.php
 
public function save($updateOnly = false)
        {
                $table = $this->getTable();
                $this->params = (string) $this->_params;
                //$this->getProperties()ﱣľûעϢ
                $table->bind($this->getProperties());
                //joomlaиƣֻsuper userܴsuper userȨ˳ףֻܸjoomlaƽһеȨAdministratoridΪ7
                        $iAmSuperAdmin = $my->authorise('core.admin');

                        // We are only worried about edits to this account if I am not a Super Admin.
                        if ($iAmSuperAdmin != true)
                        {
                                if ($isNew)
                                //治ˣʵ̫

©֤

ΪgroupsʼΪ2ҲRegisteredעʱύжһά飬jfrom[groups][]=7foreach⸲ǵgroups飬7Administrator
 
