HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
AccountUsersController.php
Go to the documentation of this file.
1 <?php
2 
4 {
10  public function actionView($id)
11  {
12  $this->render('view', array(
13  'model' => $this->loadModel($id),
14  ));
15  }
16 
21  public function actionCreate()
22  {
23  $model = new AccountUsers();
24 
25  // Uncomment the following line if AJAX validation is needed
26  // $this->performAjaxValidation($model);
27 
28  if (isset($_POST['AccountUsers'])) {
29  $model->attributes = $_POST['AccountUsers'];
30  if ($model->save()) {
31  $this->redirect(array('view', 'id' => $model->UserId));
32  }
33  }
34 
35  $this->render('create', array(
36  'model' => $model,
37  ));
38  }
39 
46  public function actionUpdate($id)
47  {
48  $model = $this->loadModel($id);
49 
50  // Uncomment the following line if AJAX validation is needed
51  // $this->performAjaxValidation($model);
52 
53  if (isset($_POST['AccountUsers'])) {
54  $model->attributes = $_POST['AccountUsers'];
55  if ($model->save()) {
56  $this->redirect(array('view', 'id' => $model->UserId));
57  }
58  }
59 
60  $this->render('update', array(
61  'model' => $model,
62  ));
63  }
64 
71  public function actionDelete($id)
72  {
73  $this->loadModel($id)->delete();
74 
75  // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
76  if (!isset($_GET['ajax'])) {
77  $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
78  }
79  }
80 
84  public function actionIndex()
85  {
86  $dataProvider = new CActiveDataProvider('AccountUsers');
87  $this->render('index', array(
88  'dataProvider' => $dataProvider,
89  ));
90  }
91 
95  public function actionAdmin()
96  {
97  $model = new AccountUsers('search');
98  $model->unsetAttributes(); // clear any default values
99  if (isset($_GET['AccountUsers'])) {
100  $model->attributes = $_GET['AccountUsers'];
101  }
102 
103  $this->render('admin', array(
104  'model' => $model,
105  ));
106  }
107 
118  public function loadModel($id)
119  {
120  $model = AccountUsers::model()->findByPk($id);
121  if ($model === null) {
122  throw new CHttpException(404, 'The requested page does not exist.');
123  }
124 
125  return $model;
126  }
127 
133  protected function performAjaxValidation($model)
134  {
135  if (isset($_POST['ajax']) && $_POST['ajax'] === 'account-users-form') {
136  echo CActiveForm::validate($model);
137  Yii::app()->end();
138  }
139  }
140 }