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