Ejemplo n.º 1
0
 /**
  * Tests testimonial rejection.
  */
 public function testReject()
 {
     $testi = $this->testimonials('testimonial2');
     $this->assertTrue($testi->reject());
     $updatedTesti = Testimonial::model()->findByPk($testi->id);
     $this->assertEquals(Testimonial::STATUS_REJECTED, $testi->status);
 }
Ejemplo n.º 2
0
 /**
  * Displays the profile page of a student.
  * @param  integer $id the student id
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     $numItems = Yii::app()->params['itemsPerPage'];
     $downloads = new CArrayDataProvider($model->downloadInfos, array('pagination' => array('pageSize' => $numItems)));
     $reviews = new CArrayDataProvider($model->reviews, array('pagination' => array('pageSize' => $numItems)));
     $sql = Yii::app()->db->createCommand()->select(array('id', 'title', 'value', 'note_id', 'timestamp'))->from(array('bk_note note', 'bk_rate rate'))->where(array('and', 'rate.student_id=:sid', 'rate.note_id=note.id'), array(':sid' => $model->id));
     $count = count($model->rates);
     $rates = new CSqlDataProvider($sql, array('totalItemCount' => $count, 'pagination' => array('pageSize' => $numItems)));
     $sql = Yii::app()->db->createCommand()->select(array('id', 'title', 'note_id', 'timestamp'))->from(array('bk_note note', 'bk_report report'))->where(array('and', 'report.student_id=:sid', 'report.note_id=note.id'), array(':sid' => $model->id));
     $count = count($model->reports);
     $reports = new CSqlDataProvider($sql, array('totalItemCount' => $count, 'pagination' => array('pageSize' => $numItems)));
     $uploads = new CArrayDataProvider($model->notes, array('pagination' => array('pageSize' => $numItems)));
     $badges = new CArrayDataProvider($model->badges, array('pagination' => array('pageSize' => 20)));
     if (Yii::app()->user->isAdmin) {
         $finder = Testimonial::model();
     } else {
         $finder = Testimonial::model()->student($model->id);
     }
     $testimonials = new CActiveDataProvider($finder, array('pagination' => array('pageSize' => $numItems)));
     $this->render('view', array('model' => $model, 'downloads' => $downloads, 'reviews' => $reviews, 'rates' => $rates, 'reports' => $reports, 'uploads' => $uploads, 'badges' => $badges, 'testimonials' => $testimonials));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Testimonial::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 4
0
 /**
  * Retrieves testimonial of the month.
  * @return Testimonial the testimonial or null if not found
  */
 public static function getCurrentTestimonial()
 {
     $testimonial = Testimonial::model()->find(array('condition' => 'status=:status', 'params' => array(':status' => self::STATUS_APPROVED), 'order' => 'timestamp DESC'));
     if ($testimonial === null) {
         return null;
     }
     $currentMonth = date('m');
     $testimonialMonth = date('m', strtotime($testimonial->timestamp));
     if ($currentMonth !== $testimonialMonth) {
         return null;
     } else {
         return $testimonial;
     }
 }
Ejemplo n.º 5
0
 /**
  * Loads the testimonial model.
  * @param  int $id the testimonial id
  * @return Note the testimonial object associated with the given id
  */
 public function loadModel($id)
 {
     $model = Testimonial::model()->findByPk($id);
     if ($model === NULL) {
         throw new CHttpException(404, 'Testimonial yang dimaksud tidak ada.');
     }
     return $model;
 }