コード例 #1
0
ファイル: Posts.php プロジェクト: huynt57/image_chooser
 public function reportPost($attr)
 {
     $check = Reports::model()->findByAttributes(array('post_id' => $attr['post_id']));
     if ($check) {
         return 1;
     } else {
         $model = new Reports();
         $model->setAttributes($attr);
         $model->created_at = time();
         $model->status = 0;
         $model->updated_at = time();
         // $model->type = Yii::app()->params['USER_REPORT'];
         $rel = new UserPostRelationship();
         $rel->user_id = $attr['from'];
         $rel->post_id = $attr['post_id'];
         $rel->created_at = time();
         $rel->updated_at = time();
         $rel->type = Yii::app()->params['USER_REPORT'];
         if ($model->save(FALSE) && $rel->save(FALSE)) {
             return 2;
         }
     }
     return 3;
 }