Example #1
0
 /**
  * 
  * 退出群
  * @param $id
  */
 public function quit($id = 0)
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     $data = $this->get_data();
     $groupId = (int) $id;
     if (empty($id)) {
         $this->send_response(400, NULL, '400401:群ID为空');
     }
     $groupInfo = $this->model->getGroupInfo($groupId);
     if (!$groupInfo) {
         $this->send_response(400, NULL, '400402:群不存在');
     }
     $grade = $this->model->getMemberGrade($groupId, $this->user_id);
     if ($grade < Kohana::config('group.grade.normal')) {
         $this->send_response(400, NULL, '400403:你不是该群成员');
     }
     if ($grade == Kohana::config('group.grade.master')) {
         $this->send_response(400, NULL, '400405:群创建者不允许退出群');
     }
     if ($this->model->delGroupMember($groupId, $this->user_id)) {
         $this->send_response(200);
     }
     $this->send_response(400, NULL, '400404:退出群失败');
 }