public function blockPost($user_block, $post_id) { $model = UserPostRelationship::model()->findByAttributes(array('user_id' => $user_block, 'post_id' => $post_id)); if ($model) { return 1; } else { $rel = new UserPostRelationship(); $rel->user_id = $user_block; $rel->post_id = $post_id; $rel->created_at = time(); $rel->updated_at = time(); $rel->type = Yii::app()->params['USER_BLOCK']; if ($rel->save(FALSE)) { return 2; } else { return 0; } } }
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; }