Beispiel #1
0
 public function getIsCreateUser($pk, $model)
 {
     if ($model == "diary" && Diary::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
         return true;
     } else {
         if ($model == "photo" && Photo::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
             return true;
         } else {
             if ($model == "recent" && Recent::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
                 return true;
             } else {
                 if ($model == "timeline" && Timeline::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
                     return true;
                 } else {
                     if ($model == "pictue" && Picture::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
Beispiel #2
0
 /**
  * 获取JSON Portal数据
  */
 public static function getCommentJSONData($type = "")
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'remind_time desc';
     $criteria->condition = '(to_id = :to_id and remind_flag != :to_remind_flag and delete_flag != :to_delete_flag)';
     $criteria->params = array(':to_id' => Yii::app()->user->id, ':to_remind_flag' => $type == "" ? 1 : 2, ':to_delete_flag' => 1);
     $models = self::model()->findAll($criteria);
     $data = array();
     foreach ($models as $model) {
         $contentModel = NotificationContent::model()->findByPk($model->content_id);
         if ($contentModel->notification_type != "attention" && $contentModel->notification_type != "report") {
             $pk_id = Comment::model()->findByPk($contentModel->pk_id)->pk_id;
             if ($contentModel->notification_type == "answer") {
                 $dataUrl = Yii::app()->controller->createUrl("diary", array("action" => "view", "id" => $pk_id, "pk_id" => $model->id));
             } else {
                 if ($contentModel->notification_type == "topic") {
                     $dataUrl = Yii::app()->controller->createUrl("topic", array("id" => $pk_id, "pk_id" => $model->id));
                 } else {
                     if ($contentModel->notification_type == "picture") {
                         $dataUrl = Yii::app()->controller->createUrl("picturewall", array("type" => "sharepicture", "id" => $pk_id, "pk_id" => $model->id));
                     } else {
                         if ($contentModel->notification_type == "recent") {
                             $user_id = Recent::model()->findByPk($pk_id)->create_user;
                             $dataUrl = Yii::app()->controller->createUrl("recent", array("type" => "other", "action" => "view", "id" => $pk_id, "user_id" => $user_id, "pk_id" => $model->id));
                         } else {
                             if ($contentModel->notification_type == "timeline") {
                                 $dataUrl = Yii::app()->controller->createUrl("timeline", array("type" => "action", "action" => "view", "id" => $pk_id, "pk_id" => $model->id));
                             }
                         }
                     }
                 }
             }
             $data[] = array('id' => $model->id, 'desc' => Comment::model()->findByPk($contentModel->pk_id)->content, 'content' => $contentModel->content, 'remindFlag' => $model->remind_flag, 'createUserId' => $contentModel->from_id, 'createUser' => User::getNameById($contentModel->from_id), 'createTime' => Comment::model()->timeintval($contentModel->send_time), 'avatarSrc' => User::getAvatarById($contentModel->from_id), 'dataUrl' => $dataUrl);
         }
     }
     return $type == "" ? CJSON::encode($data) : $data;
 }