最近在研究记事狗微博2.6版的时候,发现对于用户管理分组这块,删除分组,页面不能够做到即时刷新。目前本人找到了解决方法,参考如下:
function GroupDelete()
{
$gid = (int) $this->Get[‘gid’];
$sql = “select `id`,`uid` from `”.TABLE_PREFIX.”group` where `id` ='{$gid}'”;
$query = $this->DatabaseHandler->Query($sql);
$user_group = $query->GetRow();
if($user_group[‘uid’] != MEMBER_ID)
{
$this->Messager(‘分组不存在’,’index.php’,0);
}
$sql = “delete from `”.TABLE_PREFIX.”group` where `id`='{$gid}’ and `uid` =”.MEMBER_ID;
$this->DatabaseHandler->Query($sql);
$sql = “delete from `”.TABLE_PREFIX.”groupfields` where `gid`='{$gid}'”;
$this->DatabaseHandler->Query($sql);
$this->Messager(NULL,’index.php?mod=’.MEMBER_NAME.’&code=follow’,0);
}
主要是因为缺少上面的那个函数,这个函数,在other.mod.php里面是找不到的,但是在公共加载的时候又没有能够成功加载,这个时候有一个解决方法是找到master.mod.php,然后将Messager函数拷贝过来。
function Messager($message, $redirectto=”,$time = -1,$return_msg=false,$js=null)
{
global $rewriteHandler;
ob_start();
if ($time===-1)
{
$time=(is_numeric($this->Config[‘msg_time’])?$this->Config[‘msg_time’]:5);
}
$to_title=($redirectto===” or $redirectto==-1)?”返回上一页”:”跳转到指定页面”;
if($redirectto===null)
{
$return_msg=$return_msg===false?” ”:$return_msg;
}
else
{
$redirectto=($redirectto!==”)?$redirectto:($from_referer=referer());
if(str_exists($redirectto,’mod=login’,’code=register’,’/login’,’/register’))
{
$referer=’&referer=’.urlencode(‘index.php?’.$_SERVER[‘QUERY_STRING’]);
$this->CookieHandler->Setvar(‘referer’,’index.php?’.$_SERVER[‘QUERY_STRING’]);
}
if (is_numeric($redirectto)!==false and $redirectto!==0)
{
if($time!==null){
$url_redirect=”<script language=\”JavaScript\” type=\”text/javascript\”>\r\n”;
$url_redirect.=sprintf(“window.setTimeout(\”history.go(%s)\”,%s);\r\n”,$redirectto,$time*1000);
$url_redirect.=”</script>\r\n”;
}
$redirectto=”javascript:history.go({$redirectto})”;
}
else
{
if($rewriteHandler && null!==$message)
{
$redirectto .= $referer;
if(!$from_referer && !$referer) {
$redirectto=$rewriteHandler->formatURL($redirectto,true);
}
}
if($message===null)
{
$redirectto=rawurldecode(stripslashes(($redirectto)));
@header(“Location: $redirectto”); #HEADER跳转
}
if($time!==null)
{
$url_redirect = ($redirectto?'<meta http-equiv=”refresh” content=”‘ . $time . ‘; URL=’ . $redirectto . ‘”>’:null);
}
}
}
$title=”消息提示:”.(is_array($message)?implode(‘,’,$message):$message);
$title=strip_tags($title);
if($js!=””) {
$js=”<script language=\”JavaScript\” type=\”text/javascript\”>{$js}</script>”;
}
$additional_str = $url_redirect.$js;
include($this->TemplateHandler->Template(‘messager’));
$body=ob_get_clean();
$this->ShowBody($body);
exit;
}
希望对大家有所帮助。