Exemple #1
0
 /**
  * 更新群信息
  * @param int $id 群组ID
  */
 public function update($id = NULL)
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     if (empty($id)) {
         $this->send_response(400, NULL, '400409:群ID为空');
     }
     $grade = $this->model->getMemberGrade($id, $this->user_id);
     if ($grade < Kohana::config('group.grade.manager')) {
         $this->send_response(400, NULL, '400404:非群管理员,无权限更新群信息');
     }
     $data = $this->get_data();
     if (isset($data['name']) && (strlen($data['name']) < 2 || strlen($data['name']) > 70)) {
         $this->send_response(400, NULL, '400404:群名称长度非法');
     }
     if (isset($data['notice']) && (strlen($data['notice']) < 1 || strlen($data['name']) > 500)) {
         $this->send_response(400, NULL, '400406:群公告长度非法');
     }
     $data['gname'] = $data['name'];
     if ($this->model->update($id, $data)) {
         $this->send_response(200);
     }
     $this->send_response(400, NULL, '400414:更新失败');
 }