assign('action_id',$action_id); $condition['is_delete'] = 1; $this->assign("default_map",$condition); $map = $this->_search (); //追加默认参数 if($this->get("default_map")) $map = array_merge($map,$this->get("default_map")); if (method_exists ( $this, '_filter' )) { $this->_filter ( $map ); } $name="Role"; $model = D ($name); if (! empty ( $model )) { $this->_list ( $model, $map ); } $this->display (); return; } //相关操作 public function set_effect() { $id = intval($_REQUEST['id']); $ajax = intval($_REQUEST['ajax']); $info = M("Role")->where("id=".$id)->getField("name"); $c_is_effect = M("Role")->where("id=".$id)->getField("is_effect"); //当前状态 $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态 M("Role")->where("id=".$id)->setField("is_effect",$n_is_effect); save_log($info.l("SET_EFFECT_".$n_is_effect),1); $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1) ; } public function delete() { //删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST ['id']; if (isset ( $id )) { $condition = array ('id' => array ('in', explode ( ',', $id ) ) ); $rel_data = M("Role")->where($condition)->findAll(); foreach($rel_data as $data) { $info[] = $data['name']; //开始验证分组下是否存在管理员 if(M("Admin")->where("is_effect = 1 and is_delete = 0 and role_id=".$data['id'])->count()>0) { $this->error ($data['name'].l("EXIST_ADMIN"),$ajax); } } if($info) $info = implode(",",$info); $list = M("Role")->where ( $condition )->setField ( 'is_delete', 1 ); if ($list!==false) { save_log($info.l("DELETE_SUCCESS"),1); $this->success (l("DELETE_SUCCESS"),$ajax); } else { save_log($info.l("DELETE_FAILED"),0); $this->error (l("DELETE_FAILED"),$ajax); } } else { $this->error (l("INVALID_OPERATION"),$ajax); } } public function restore() { //删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST ['id']; if (isset ( $id )) { $condition = array ('id' => array ('in', explode ( ',', $id ) ) ); $rel_data = M("Role")->where($condition)->findAll(); foreach($rel_data as $data) { $info[] = $data['name']; } if($info) $info = implode(",",$info); $list = M("Role")->where ( $condition )->setField ( 'is_delete', 0 ); if ($list!==false) { save_log($info.l("RESTORE_SUCCESS"),1); $this->success (l("RESTORE_SUCCESS"),$ajax); } else { save_log($info.l("RESTORE_FAILED"),0); $this->error (l("RESTORE_FAILED"),$ajax); } } else { $this->error (l("INVALID_OPERATION"),$ajax); } } public function foreverdelete() { //彻底删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST ['id']; if (isset ( $id )) { $condition = array ('id' => array ('in', explode ( ',', $id ) ) ); $role_access_condition = array ('role_id' => array ('in', explode ( ',', $id ) ) ); $rel_data = M("Role")->where($condition)->findAll(); foreach($rel_data as $data) { $info[] = $data['name']; //开始验证分组下是否存在管理员 if(M("Admin")->where("is_effect = 1 and is_delete = 0 and role_id=".$data['id'])->count()>0) { $this->error ($data['name'].l("EXIST_ADMIN"),$ajax); } } if($info) $info = implode(",",$info); $list = M("Role")->where ( $condition )->delete(); M("RoleAccess")->where($role_access_condition)->delete(); M("Admin")->where($role_access_condition)->delete(); if ($list!==false) { save_log($info.l("FOREVER_DELETE_SUCCESS"),1); $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax); } else { save_log($info.l("FOREVER_DELETE_FAILED"),0); $this->error (l("FOREVER_DELETE_FAILED"),$ajax); } } else { $this->error (l("INVALID_OPERATION"),$ajax); } } } ?>