| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class AdminUser extends TPage
|
|
|
4 |
{
|
|
|
5 |
/**
|
|
|
6 |
* Populates the datagrid with user lists.
|
|
|
7 |
* This method is invoked by the framework when initializing the page
|
|
|
8 |
* @param mixed event parameter
|
|
|
9 |
*/
|
|
|
10 |
public function onInit($param)
|
|
|
11 |
{
|
|
|
12 |
parent::onInit($param);
|
|
|
13 |
// fetches all data account information
|
|
|
14 |
$this->UserGrid->DataSource=UserRecord::finder()->findAll();
|
|
|
15 |
// binds the data to interface components
|
|
|
16 |
$this->UserGrid->dataBind();
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Deletes a specified user record.
|
|
|
21 |
* This method responds to the datagrid's OnDeleteCommand event.
|
|
|
22 |
* @param TDataGrid the event sender
|
|
|
23 |
* @param TDataGridCommandEventParameter the event parameter
|
|
|
24 |
*/
|
|
|
25 |
public function deleteButtonClicked($sender,$param)
|
|
|
26 |
{
|
|
|
27 |
// obtains the datagrid item that contains the clicked delete button
|
|
|
28 |
$item=$param->Item;
|
|
|
29 |
// obtains the primary key corresponding to the datagrid item
|
|
|
30 |
$username=$this->UserGrid->DataKeys[$item->ItemIndex];
|
|
|
31 |
// deletes the user record with the specified username primary key
|
|
|
32 |
UserRecord::finder()->deleteByPk($username);
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
?>
|