/** * 编辑分组名 * @param int $user_id 用户ID * @param string $name 分组名 * @param int $id 分组ID * @return bool */ public function edit($user_id, $name, $id) { if ($old_name = $this->contact_mapper->get_category_name($user_id, $id)) { if ($old_name != $name) { $ids = $this->contact_mapper->get_category_contact($user_id, $id); //分组中有联系人,保存快照,更新分组名和联系人 if ($ids and $this->contact_model->save_snapshot($user_id) and $this->contact_mapper->update_category($user_id, $id, $name)) { $this->contact_model->update_contact_modified($user_id, $ids); $this->clear_cache($user_id, array('type' => 'update', 'id' => $id, 'name' => $name)); return TRUE; } elseif ($this->contact_mapper->update_category($user_id, $id, $name)) { $this->clear_cache($user_id, array('type' => 'update', 'id' => $id, 'name' => $name)); return TRUE; } } else { return TRUE; } } return FALSE; }