HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
LoginController.php
Go to the documentation of this file.
1 <?php
2 
4 {
5  public $defaultAction = 'login';
6 
10  public function actionLogin($tryIt = false)
11  {
12  if ($tryIt) {
14  $this->redirect('/');
15  }
16 
17  $model = new UserLogin();
18  if (UserModule::isGuest()) {
19  // collect user input data
20  if (isset($_POST['UserLogin'])) {
21  $attributes = $_POST['UserLogin'];
22  }
23 
24  if (!empty($attributes)) {
25  $model->attributes = $attributes;
26  // validate user input and redirect to previous page if valid
27  if ($model->validate()) {
28  $this->lastViset();
29 
30  if (Yii::app()->user->returnUrl == '/index.php') {
31  $this->redirect(Yii::app()->controller->module->returnUrl);
32  } else {
33  $this->redirect(Yii::app()->user->returnUrl);
34  }
35  }
36  }
37  // display the login form
38  $this->render('/user/login', array('model' => $model));
39  } else {
40  $this->redirect(Yii::app()->controller->module->returnUrl);
41  }
42  }
43 
44  private function lastViset()
45  {
46  $lastVisit = User::model()->notsafe()->findByPk(Yii::app()->user->id);
47  $lastVisit->lastvisit = time();
48  $lastVisit->save();
49  }
50 }