/** * Authenticates a dummy user. * @return boolean always true. */ public function authenticate() { $student = Student::model()->findByAttributes(array('username' => $this->username)); if ($student === null) { $student = new Student(); $faculty = Faculty::model()->findByPk(1); if ($faculty === null) { $faculty = new Faculty(); $faculty->id = 1; $faculty->name = 'Dummy Faculty'; $faculty->save(false); } $student->username = $this->username; $student->name = $this->name; $student->is_admin = $this->isAdmin; $student->faculty_id = $faculty->id; $student->photo = Yii::app()->params['defaultProfilePhoto']; } $student->last_login_timestamp = date('Y-m-d H:i:s'); $student->save(); $this->id = $student->id; $this->name = $student->name; $this->setState('isAdmin', $student->is_admin); $this->setState('profilePhoto', $student->photo); return true; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Faculty(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Faculty'])) { $model->attributes = $_POST['Faculty']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }