| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* EditUser 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: EditUser.php 1398 2006-09-08 19:31:03Z xue $
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* EditUser 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 EditUser extends BlogPage
|
|
|
21 |
{
|
|
|
22 |
private $_userRecord=null;
|
|
|
23 |
|
|
|
24 |
public function onInit($param)
|
|
|
25 |
{
|
|
|
26 |
parent::onInit($param);
|
|
|
27 |
if(($id=$this->Request['id'])!==null)
|
|
|
28 |
{
|
|
|
29 |
$id=TPropertyValue::ensureInteger($id);
|
|
|
30 |
if(!$this->User->IsAdmin && $this->User->ID!==$id)
|
|
|
31 |
throw new BlogException(500,'profile_edit_disallowed',$id);
|
|
|
32 |
}
|
|
|
33 |
else
|
|
|
34 |
$id=$this->User->ID;
|
|
|
35 |
if(($this->_userRecord=$this->DataAccess->queryUserByID($id))===null)
|
|
|
36 |
throw new BlogException(500,'profile_id_invalid',$id);
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
public function onLoad($param)
|
|
|
40 |
{
|
|
|
41 |
parent::onLoad($param);
|
|
|
42 |
if(!$this->IsPostBack)
|
|
|
43 |
{
|
|
|
44 |
$userRecord=$this->_userRecord;
|
|
|
45 |
$this->Username->Text=$userRecord->Name;
|
|
|
46 |
$this->FullName->Text=$userRecord->FullName;
|
|
|
47 |
$this->Email->Text=$userRecord->Email;
|
|
|
48 |
$this->Website->Text=$userRecord->Website;
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
public function saveButtonClicked($sender,$param)
|
|
|
53 |
{
|
|
|
54 |
if($this->IsValid)
|
|
|
55 |
{
|
|
|
56 |
$userRecord=$this->_userRecord;
|
|
|
57 |
if($this->Password->Text!=='')
|
|
|
58 |
$userRecord->Password=md5($this->Password->Text);
|
|
|
59 |
$userRecord->FullName=$this->FullName->Text;
|
|
|
60 |
$userRecord->Email=$this->Email->Text;
|
|
|
61 |
$userRecord->Website=$this->Website->Text;
|
|
|
62 |
$this->DataAccess->updateUser($userRecord);
|
|
|
63 |
$authManager=$this->Application->getModule('auth');
|
|
|
64 |
$this->gotoPage('Users.ViewUser',array('id'=>$userRecord->ID));
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
?>
|