summaryrefslogtreecommitdiff
path: root/demos/blog/protected/Pages/Users/NewUser.php
diff options
context:
space:
mode:
authorxue <>2006-05-30 03:26:33 +0000
committerxue <>2006-05-30 03:26:33 +0000
commit6e0338629774fffe5fbe7136dfce34ce83844a5c (patch)
tree9520eaa7c3c278b5ebf525a0d1e09f0a4cdf7779 /demos/blog/protected/Pages/Users/NewUser.php
parent7f508e187e4539a16cdbb1dd6a4b1133c53cf24d (diff)
Blog demo is completed.
Diffstat (limited to 'demos/blog/protected/Pages/Users/NewUser.php')
-rw-r--r--demos/blog/protected/Pages/Users/NewUser.php31
1 files changed, 29 insertions, 2 deletions
diff --git a/demos/blog/protected/Pages/Users/NewUser.php b/demos/blog/protected/Pages/Users/NewUser.php
index 166abf66..50a8100b 100644
--- a/demos/blog/protected/Pages/Users/NewUser.php
+++ b/demos/blog/protected/Pages/Users/NewUser.php
@@ -1,10 +1,33 @@
<?php
+/**
+ * NewUser class file
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ */
+/**
+ * NewUser class
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
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=$this->Username->Text;
+ $username=strtolower($this->Username->Text);
$param->IsValid=$this->DataAccess->queryUserByName($username)===null;
}
@@ -13,13 +36,17 @@ class NewUser extends BlogPage
if($this->IsValid)
{
$userRecord=new UserRecord;
- $userRecord->Name=$this->Username->Text;
+ $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);