当选择城市自动加入或者创建群组(试试看)
在source/cp_profile.php里查找updatetable('spacefield', $setarr, array('uid'=>$_SGLOBAL['supe_uid']));下面增加/*begin 当选择城市自动加入或者创建群组*/$city_name = $setarr['residecity'];
//如果是直辖市则直接为直辖市名
if($setarr['resideprovince']=='北京'||$setarr['resideprovince']=='上海'||$setarr['resideprovince']=='天津'||$setarr['resideprovince']=='重庆')
{
$city_name = $setarr['resideprovince'];
}
$sql = "SELECT * FROM ".tname('mtag')." WHERE tagname='$city_name' AND fieldid=2";
//var_dump($sql);
$query = $_SGLOBAL['db']->query($sql);
$rs=($_SGLOBAL['db']->fetch_array($query));
//处理城市群组
if($rs)
{
//如果有该城市的群组
$tagid = $rs['tagid'];
//先查找当前用户是否已经加入了该群组
$sql = "SELECT * FROM `" .tname('tagspace'). "` WHERE tagid=$tagid AND uid=".$_SGLOBAL;
$query = $_SGLOBAL['db']->query($sql);
$found_user_tagspace=($_SGLOBAL['db']->fetch_array($query));
//如果没有加入,更新群组人数
if(!$found_user_tagspace)
{
$setarr=array('membernum'=>$rs['membernum']+1);
updatetable('mtag',$setarr,array('tagid'=>$tagid));
unset($setarr);
}
}
else if($_POST['residecity'] != "")
{
//否则首先创建群组
$setarr = array(
'tagname' => $city_name,
'fieldid' => 2,
'membernum' => 1
);
$tagid = inserttable('mtag', $setarr, 1);
unset($setarr);
}
//var_dump($tagid);
//加入城市群组
$setarr = array(
'tagid' => $tagid,
'uid' => $_SGLOBAL,
'username' => $_SGLOBAL,
'grade' => 0
);
//如果当前用户没有加入,则加入
if(!$found_user_tagspace)
{
$tagspaceid=inserttable('tagspace',$setarr,1);
}
//var_dump($tagspaceid);
//$sql = ""
//die('修改完毕~');
/*end 当选择城市自动加入或者创建群组 */不过yoho版的已经有这种功能了 ~晕!
不过yoho版的已经有这种功能了~
页:
[1]