summaryrefslogtreecommitdiff
path: root/demos/blog/protected/Pages/Users/NewUser.php
blob: 166abf66df89d6803c1672e9a1b0e31ceeea5c8d (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
<?php

class NewUser extends BlogPage
{
	public function checkUsername($sender,$param)
	{
		$username=$this->Username->Text;
		$param->IsValid=$this->DataAccess->queryUserByName($username)===null;
	}

	public function createUser($sender,$param)
	{
		if($this->IsValid)
		{
			$userRecord=new UserRecord;
			$userRecord->Name=$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;
			$this->DataAccess->insertUser($userRecord);
			$authManager=$this->Application->getModule('auth');
			$authManager->login($this->Username->Text,$this->Password->Text);
			$this->gotoDefaultPage();
		}
	}
}

?>