/** * 修改联系人分组顺序 */ public function order() { if ($this->get_method() != 'POST') { $this->send_response(405, NULL, Kohana::lang('contact.method_not_exist')); } $data = $this->get_data(); $ids = !empty($data['ids']) ? $data['ids'] : array(); if (empty($ids)) { $this->send_response(400, NULL, Kohana::lang('contact.group_ids_empty')); } else { $ids = explode(',', $ids); $list = $this->model->get($this->user_id); $old_ids = array(); foreach ($list as $value) { $old_ids[] = $value['id']; } if (array_intersect($old_ids, $ids) != $old_ids) { $this->send_response(400, NULL, Kohana::lang('contact.group_ids_not_complete')); } else { if ($this->model->change_order($this->user_id, $ids)) { $this->send_response(200); } else { $this->send_response(500, NULL, Kohana::lang('contact.operation_fail')); } } } }