public function actionHistory()
 {
     $model = new StudentEvent('search');
     $model->user_id = Yii::app()->user->id;
     $model->is_active = true;
     $model->unsetAttributes();
     if (isset($_GET['ajax'])) {
         $model->attributes = $_GET['StudentEvent'];
     }
     $this->render('history', array('model' => $model));
 }
 public function actionSignup($id)
 {
     if (isset($id)) {
         if (Yii::app()->request->isPostRequest) {
             $event = Event::model()->findByPk($id);
             if ($event != null) {
                 if (!$event->isPublic()) {
                     $isStuFromCollege = Student::model()->exists('user_id=:user_id AND college_id=:college_id', array(':user_id' => Yii::app()->user->id, ':college_id' => $event->college_id));
                     if (!$isStuFromCollege) {
                         throw new CHttpException(400, 'Sorry, you cannot sign up for this event.');
                     }
                 }
                 $studentEvent = new StudentEvent();
                 $studentEvent->user_id = Yii::app()->user->id;
                 $studentEvent->post_item_id = $id;
                 if ($studentEvent->save()) {
                     Yii::app()->user->setFlash('success', Yii::t('app', 'msg.success.event_signup'));
                     $this->redirect(array('view', 'id' => $id));
                 }
             } else {
                 throw new CHttpException(400, 'Event not found.');
             }
         } else {
             throw new CHttpException(400, 'Invalid Request');
         }
     } else {
         throw new CHttpException(400, 'Event not found.');
     }
 }