Beispiel #1
0
 public function actionV()
 {
     $model = Inbox::model()->findByPk($_GET['id']);
     if ($model == null && ($model->source_id != User()->id || $model->dest_id != User()->id)) {
         throw new CHttpException(404, 'The requested Node does not exist.');
     }
     $nmodel = new Inbox();
     $nmodel->dest_id = User()->id == $model->source_id ? $model->dest_id : $model->source_id;
     $nmodel->parent_id = $model->id;
     $u =& $this->iuser;
     if ($u->id == $model->dest_id) {
         // dest user read the mail
         $model->is_read = 1;
         $model->save(false);
     }
     Inbox::model()->updateAll(array('is_read' => 1), " dest_id = {$u->id} AND parent_id = {$model->id} ");
     $this->render('view', array('m' => $u, 'model' => $model, 'nmodel' => $nmodel), false, true);
 }
Beispiel #2
0
 public function getUnread_inbox_count()
 {
     $a = Inbox::model()->count("is_read =0 AND dest_id = " . User()->id . " AND parent_id = {$this->id} ");
     $b = $this->is_read ? 0 : 1;
     return $a + $b;
 }
 /**
  * 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 = Inbox::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Inbox::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Beispiel #5
0
 public function getUnread_inbox_count()
 {
     $list = Inbox::model()->findAll("dest_id = {$this->id} AND parent_id = 0");
     $ids = '';
     foreach ($list as $l) {
         $ids .= $l->id . ',';
     }
     $a = Inbox::model()->count(" is_read = 0 AND dest_id = {$this->id} AND find_in_set(parent_id, '{$ids}' )");
     $b = Inbox::model()->count(" is_read = 0 AND dest_id = {$this->id} AND parent_id = 0 ");
     return $a + $b;
 }