| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* NewUser class file
|
|
|
4 |
*
|
|
|
5 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2006 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: NewUser.php 1398 2006-09-08 19:31:03Z xue $
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* NewUser class
|
|
|
14 |
*
|
|
|
15 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
16 |
* @link http://www.pradosoft.com/
|
|
|
17 |
* @copyright Copyright © 2006 PradoSoft
|
|
|
18 |
* @license http://www.pradosoft.com/license/
|
|
|
19 |
*/
|
|
|
20 |
class NewUser extends BlogPage
|
|
|
21 |
{
|
|
|
22 |
public function onInit($param)
|
|
|
23 |
{
|
|
|
24 |
if(!$this->User->IsAdmin && !TPropertyValue::ensureBoolean($this->Application->Parameters['MultipleUser']))
|
|
|
25 |
throw new BlogException(500,'newuser_registration_disallowed');
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
public function checkUsername($sender,$param)
|
|
|
29 |
{
|
|
|
30 |
$username=strtolower($this->Username->Text);
|
|
|
31 |
$param->IsValid=$this->DataAccess->queryUserByName($username)===null;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
public function createUser($sender,$param)
|
|
|
35 |
{
|
|
|
36 |
if($this->IsValid)
|
|
|
37 |
{
|
|
|
38 |
$userRecord=new UserRecord;
|
|
|
39 |
$userRecord->Name=strtolower($this->Username->Text);
|
|
|
40 |
$userRecord->FullName=$this->FullName->Text;
|
|
|
41 |
$userRecord->Role=0;
|
|
|
42 |
$userRecord->Password=md5($this->Password->Text);
|
|
|
43 |
$userRecord->Email=$this->Email->Text;
|
|
|
44 |
$userRecord->CreateTime=time();
|
|
|
45 |
$userRecord->Website=$this->Website->Text;
|
|
|
46 |
if(TPropertyValue::ensureBoolean($this->Application->Parameters['AccountApproval']))
|
|
|
47 |
$userRecord->Status=UserRecord::STATUS_PENDING;
|
|
|
48 |
else
|
|
|
49 |
$userRecord->Status=UserRecord::STATUS_NORMAL;
|
|
|
50 |
$this->DataAccess->insertUser($userRecord);
|
|
|
51 |
$authManager=$this->Application->getModule('auth');
|
|
|
52 |
$authManager->login($this->Username->Text,$this->Password->Text);
|
|
|
53 |
$this->gotoDefaultPage();
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
?>
|