www.gusucode.com > 08CMS空白站群系统 3.3 繁体 UTF-8 > upload/admina/commus.inc.php

    <?
(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
load_cache('grouptypes,currencys,fieldwords,rprojects');
load_cache('mtpls',$sid);
include_once M_ROOT."./include/fields.fun.php";
$cclassarr = array(
	'praise' => lang('praise'),
	'debase' => lang('debase'),
	'report' => lang('pickbug'),
	'favorite' => lang('favorite'),
	'comment' => lang('comment'),
	'answer' => lang('answer1 question'),
	'subscribe' => lang('subscribe'),
	'purchase' => lang('purchase goods'),
	);
if($action == 'commusedit'){
	!checkapermission($sid ? 155 : 69) && amessage(lang('no_apermission'));
	$commus = fetch_arr();
	cache_merge($commus,'commus',$sid);
	if(!submitcheck('bcommusedit')){
		a_guide('commusedit');
		tabheader(lang('commu item admin'),'commusedit',"?entry=commus&action=commusedit$param_suffix",'7');
		trcategory(array(lang('delete'),lang('enable'),lang('item cname'),lang('type'),lang('pick url style'),lang('copy'),lang('edit')));
		foreach($commus as $cuid => $commu){
			$cclass = $cclassarr[$commu['cclass']];
			echo "<tr>".
			"<td class=\"item1\" width=\"30\" align=\"center\"><input class=\"checkbox\" type=\"checkbox\" name=\"delete[$cuid]\" value=\"$cuid\"".($commu['issystem'] || $sid ? ' disabled' : '')."></td>\n".
			"<td class=\"item2\" width=\"30\" align=\"center\"><input class=\"checkbox\" type=\"checkbox\" name=\"commusnew[$cuid][available]\" value=\"1\"".(empty($commu['available']) ? '' : ' checked')."></td>\n".
			"<td class=\"item1\" width=\"200\">".($sid ? "$commu[cname]" : "<input type=\"text\" size=\"30\" maxlength=\"30\" name=\"commusnew[$cuid][cname]\" value=\"$commu[cname]\">")."</td>\n".
			"<td class=\"item2\" width=\"80\">$cclass</td>\n".
			"<td class=\"item1\">$commu[url]</td>\n".
			"<td class=\"item2\" width=\"30\" align=\"center\">".($commu['ch'] && !$sid ? "<a href=\"?entry=commus&action=commucopy&cuid=$cuid$param_suffix\">".lang('copy')."</a>" : '-')."</td>\n".
			"<td class=\"item1\" width=\"30\" align=\"center\">".($commu['sortable'] || !$sid ? "<a href=\"?entry=commus&action=commudetail&cuid=$cuid$param_suffix\">".lang('detail')."</a>" : '-')."</td></tr>\n";
		}
		tabfooter('bcommusedit',lang('modify'));
	}else{
		if(!$sid){
			if(!empty($delete)){
				foreach($delete as $cuid){
					if($commus[$cuid]['issystem']) continue;
					if($db->result_one("SELECT COUNT(*) FROM {$tblprefix}channels WHERE cuid='$cuid'")) continue;
					$db->query("DELETE FROM {$tblprefix}commus WHERE cuid='$cuid'");
					del_cache('commu',$cuid);
					unset($commusnew[$cuid]);
				}
			}
			if(!empty($commusnew)){
				foreach($commusnew as $cuid => $communew){
					$communew['cname'] = empty($communew['cname']) ? $commus[$cuid]['cname'] : $communew['cname'];
					$communew['available'] = empty($communew['available']) ? 0 : 1;
					$db->query("UPDATE {$tblprefix}commus SET cname='$communew[cname]',available='$communew[available]' WHERE cuid='$cuid'");
				}
			}
			updatecache('commus');	
		}else{
			$t_commus = empty($subsites[$sid]['commus']) ? array() : $subsites[$sid]['commus'];
			foreach($commus as $k => $v){
				$t_commus[$k]['available'] = empty($commusnew[$k]['available']) ? 0 : 1;
			}
			$t_commus = addslashes(serialize($t_commus));
			$db->query("UPDATE {$tblprefix}subsites SET commus='$t_commus' WHERE sid='$sid'");
			updatecache('subsites');
		}
		adminlog(lang('edit commu item manager list'));
		amessage(lang('item modify finish'), "?entry=commus&action=commusedit$param_suffix");
	}
}elseif($action == 'commucopy' && $cuid){
	!checkapermission(69) && amessage(lang('no_apermission'));
	if($sid && $sid_self) amessage(lang('msite admin item !'));
	$forward = empty($forward) ? M_REFERER : $forward;
	$forwardstr = '&forward='.rawurlencode($forward);
	$commu = fetch_one($cuid);
	(empty($commu) || !$commu['ch']) && amessage(lang('confirmchoose item'), '?entry=commus&action=commusedit');
	if(!submitcheck('bcommucopy')){
		a_guide('commucopy');
		tabheader(lang('commu item copy'),'commucopy',"?entry=commus&action=commucopy&cuid=$cuid$forwardstr");
		trbasic(lang('soc commu item cname'),'',$commu['cname'],'');
		trbasic(lang('soc commu item type'),'',$cclassarr[$commu['cclass']],'');
		trbasic(lang('new commu item cname'),'communew[cname]');
		tabfooter('bcommucopy');
	}else{
		$communew['cname'] = empty($communew['cname']) ? '' : trim(strip_tags($communew['cname']));
		empty($communew['cname']) && amessage(lang('tag data missing'),M_REFERER);
		$commu['cname'] = $communew['cname'];
		$commu['setting'] = serialize($commu['setting']);
		$sqlstr = '';
		foreach(array('cname','url','aurl','customtable','cclass','setting','cutpl','sortable','ch') as $k){
			$sqlstr .= ($sqlstr ? ',' : '').$k."='".addslashes($commu[$k])."'";
		}
		$db->query("INSERT INTO {$tblprefix}commus SET $sqlstr");
		updatecache('commus');
		adminlog(lang('copy commu item'));
		amessage(lang('commu item copy finish'),$forward);
	}
}elseif($action == 'commudetail' && $cuid){
	!checkapermission($sid ? 155 : 69) && amessage(lang('no_apermission'));
	$commu = fetch_one($cuid);
	cache_merge($commu,'commu',$sid);
	empty($commu) && amessage(lang('confirmchoose item'), "?entry=commus&action=commusedit$param_suffix");
	if(!submitcheck('bcommudetail')) {
		a_guide('commudetail');
		view_pickurl($commu['cclass']);
		tabheader(lang('commu item setting'),'commudetail',"?entry=commus&action=commudetail&cuid=$cuid$param_suffix");
		trbasic(lang('item type'),'',$cclassarr[$commu['cclass']],'');
		if(!$sid){
			trbasic(lang('item cname'),'communew[cname]',$commu['cname']);
			commumodule($commu['cclass']);
		}else{
			trbasic(lang('item cname'),'',$commu['cname'],'');
			trbasic(lang('commu list template'),'communew[cutpl]',makeoption(array('' => lang('nosetting')) + mtplsarr('commu'),$commu['cutpl']),'select');
		}
		tabfooter('bcommudetail',lang('modify'));
	}else{
		if(!$sid){
			$communew['cname'] = empty($communew['cname']) ? $commu['cname'] : $communew['cname'];
			if($errorstr = commumodule($commu['cclass'],1)){
				amessage($errorstr,'?entry=commus&action=commudetail&cuid='.$cuid);
			}
			$communew['cutpl'] = empty($communew['cutpl']) ? '' : $communew['cutpl'];
			$communew['setting'] = !empty($communew['setting']) ? addslashes(serialize($communew['setting'])) : '';
			$db->query("UPDATE {$tblprefix}commus SET 
						cname='$communew[cname]',
						setting='$communew[setting]',
						cutpl='$communew[cutpl]'
						WHERE cuid='$cuid'");
			updatecache('commus');
		}else{
			$s_commus = empty($subsites[$sid]['commus']) ? array() : $subsites[$sid]['commus'];
			$s_commus[$cuid]['cutpl'] = $communew['cutpl'];
			$s_commus = addslashes(serialize($s_commus));
			$db->query("UPDATE {$tblprefix}subsites SET commus='$s_commus' WHERE sid='$sid'");
			updatecache('subsites');
		}
		adminlog(lang('detail0 modify commu item'));
		amessage(lang('item modify finish'),"?entry=commus&action=commusedit$param_suffix");
	}

}elseif($action == 'pfieldsedit'){
	!checkapermission(70) && amessage(lang('no_apermission'));
	if($sid && $sid_self) amessage(lang('msite admin item !'));
	load_cache('pfields');
	if(!submitcheck('bpfieldsedit')){
		a_guide('pfieldsedit');
		tabheader(lang('purchase message field manager')."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;>><a href=\"?entry=commus&action=pfieldadd\">".lang('add field')."</a>",'pfieldsedit','?entry=commus&action=pfieldsedit',6);
		trcategory(array(lang('delete'),lang('field cname'),lang('admin_self'),lang('order'),lang('field ename'),lang('field type'),lang('edit')));
		foreach($pfields as $k => $field){
			fieldlist($k,$field,'p');
		}
		tabfooter('bpfieldsedit');
	}else{
		if(!empty($delete)){
			foreach($delete as $id){
				$db->query("ALTER TABLE {$tblprefix}orders DROP $id",'SILENT'); 
				$db->query("DELETE FROM {$tblprefix}cufields WHERE ename='$id' AND cu='1'"); 
				unset($pfields[$id],$fieldsnew[$id]);
			}
		}
		foreach($pfields as $id => $field){
			$fieldsnew[$id]['cname'] = trim(strip_tags($fieldsnew[$id]['cname']));
			$field['cname'] = $fieldsnew[$id]['cname'] ? $fieldsnew[$id]['cname'] : $field['cname'];
			$field['isadmin'] = empty($fieldsnew[$id]['isadmin']) ? 0 : 1;
			$field['vieworder'] = max(0,intval($fieldsnew[$id]['vieworder']));
			$db->query("UPDATE {$tblprefix}cufields SET cname='$field[cname]',vieworder='$field[vieworder]',isadmin='$field[isadmin]' WHERE ename='$id' AND cu='1'");
		}
		updatecache('pfields');
		updatecache('usednames','pfields');
		adminlog(lang('edit purchase message field manager list'));
		amessage(lang('field modify finish'),'?entry=commus&action=pfieldsedit');
	}

}elseif($action == 'pfieldadd'){
	!checkapermission(70) && amessage(lang('no_apermission'));
	if($sid && $sid_self) amessage(lang('msite admin item !'));
	$forward = empty($forward) ? M_REFERER : $forward;
	load_cache('pfields');
	if(!submitcheck('bpfieldadd')){
		a_guide('pfieldadd');
		tabheader(lang('add purchase field'),'pfieldadd',"?entry=commus&action=pfieldadd&forward=".rawurlencode($forward),2,0,1);
		$submitstr = '';
		if(empty($fieldnew['datatype'])){
			trbasic(lang('field type'),'fieldnew[datatype]',makeoption($datatypearr),'select');
			tabfooter('bpfieldaddpre',lang('continue'));
		}else{
			list($fmode,$fnew,$fsave) = array('cu',true,false);
			include_once M_ROOT."./include/fields/$fieldnew[datatype].php";
			tabfooter('bpfieldadd',lang('add'));
		}
		check_submit_func($submitstr);
	}else{
		$enamearr = $usednames['pfields'];
		$fconfigarr = array(
			'errorurl' => $forward,
			'enamearr' => $enamearr,
			'altertable' => $tblprefix.'orders',
			'fieldtable' => $tblprefix.'cufields',
			'sqlstr' => "cu='1'",
		);
		list($fmode,$fnew,$fsave) = array('cu',true,true);
		include_once M_ROOT."./include/fields/$fieldnew[datatype].php";
		updatecache('pfields');
		updatecache('usednames','pfields');
		adminlog(lang('add purchase message field'));
		amessage(lang('field add finish'),$forward);
	}
}elseif($action == 'pfielddetail' && $fieldename){
	!checkapermission(70) && amessage(lang('no_apermission'));
	if($sid && $sid_self) amessage(lang('msite admin item !'));
	load_cache('pfields');
	!isset($pfields[$fieldename]) && amessage(lang('confirmchoose field'),'?entry=commus&action=pfieldsedit');
	$field = $pfields[$fieldename];
	if(!submitcheck('bpfielddetail')){
		a_guide('pfielddetail');
		$submitstr = '';
		tabheader(lang('field edit')."&nbsp;&nbsp;[$field[cname]]",'pfielddetail',"?entry=commus&action=pfielddetail&fieldename=$fieldename",2,0,1);
		list($fmode,$fnew,$fsave) = array('cu',false,false);
		include_once M_ROOT."./include/fields/$field[datatype].php";
		tabfooter('bpfielddetail');
		check_submit_func($submitstr);
	}
	else{
		$fconfigarr = array(
			'altertable' => $tblprefix.'orders',
			'fieldtable' => $tblprefix.'cufields',
			'wherestr' => "WHERE ename='$fieldename' AND cu='1'",
		);
		list($fmode,$fnew,$fsave) = array('cu',false,true);
		include_once M_ROOT."./include/fields/$field[datatype].php";
		updatecache('pfields');
		adminlog(lang('detail0 modify purchase message field'));
		amessage(lang('field modify finish'),'?entry=commus&action=pfieldsedit');
	}
}
function commumodule($cclass='popular',$save=0){
	global $commu,$communew,$ugidsnew,$grouptypes,$currencys;
	switch($cclass){
		case 'praise':
			if(!$save){
				$dealmodearr = array('0' => lang('increase'),'1' => lang('decrease'));
				trbasic(lang('forbid repeat operate'),'communew[setting][norepeat]',isset($commu['setting']['norepeat']) ? $commu['setting']['norepeat'] : 0,'radio');
				trbasic(lang('repeat operate time ( minute )'),'communew[setting][repeattime]',isset($commu['setting']['repeattime']) ? $commu['setting']['repeattime'] : 0);
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),0);
			}else{
				$communew['setting']['repeattime'] = max(0,intval($communew['setting']['repeattime']));
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
		case 'debase':
			if(!$save){
				$dealmodearr = array('0' => lang('increase'),'1' => lang('decrease'));
				trbasic(lang('forbid repeat operate'),'communew[setting][norepeat]',isset($commu['setting']['norepeat']) ? $commu['setting']['norepeat'] : 0,'radio');
				trbasic(lang('repeat operate time ( minute )'),'communew[setting][repeattime]',isset($commu['setting']['repeattime']) ? $commu['setting']['repeattime'] : 0);
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),0);
			}else{
				$communew['setting']['repeattime'] = max(0,intval($communew['setting']['repeattime']));
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
		case 'report':
			if(!$save){
				trbasic(lang('forbid repeat operate'),'communew[setting][norepeat]',isset($commu['setting']['norepeat']) ? $commu['setting']['norepeat'] : 0,'radio');
				trbasic(lang('repeat operate time ( minute )'),'communew[setting][repeattime]',isset($commu['setting']['repeattime']) ? $commu['setting']['repeattime'] : 0);
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),0);
			}else{
				$communew['setting']['repeattime'] = max(0,intval($communew['setting']['repeattime']));
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
		case 'favorite':
			if(!$save){
				trbasic(lang('max favorite amount'),'communew[setting][max]',isset($commu['setting']['max']) ? $commu['setting']['max'] : 0);
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),1);
			}else{
				$communew['setting']['max'] = max(0,intval($communew['setting']['max']));
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
		case 'comment':
			if(!$save){
				trbasic(lang('forbid repeat operate'),'communew[setting][norepeat]',isset($commu['setting']['norepeat']) ? $commu['setting']['norepeat'] : 0,'radio');
				trbasic(lang('repeat operate time ( minute )'),'communew[setting][repeattime]',isset($commu['setting']['repeattime']) ? $commu['setting']['repeattime'] : 0);
				trbasic(lang('comment minlength'),'communew[setting][minlength]',isset($commu['setting']['minlength']) ? $commu['setting']['minlength'] : 0);
				trbasic(lang('comment maxlength'),'communew[setting][maxlength]',isset($commu['setting']['maxlength']) ? $commu['setting']['maxlength'] : 0);
				trbasic(lang('comment minscore'),'communew[setting][minscore]',isset($commu['setting']['minscore']) ? $commu['setting']['minscore'] : 0);
				trbasic(lang('comment maxscore'),'communew[setting][maxscore]',isset($commu['setting']['maxscore']) ? $commu['setting']['maxscore'] : 0);
				trbasic(lang('comment auto check'),'communew[setting][autocheck]',isset($commu['setting']['autocheck']) ? $commu['setting']['autocheck'] : 0,'radio');
				trbasic(lang('comment list template'),'communew[cutpl]',makeoption(array('' => lang('nosetting')) + mtplsarr('commu'),$commu['cutpl']),'select');
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),0);
			}else{
				$communew['setting']['repeattime'] = max(0,intval($communew['setting']['repeattime']));
				$communew['setting']['minlength'] = max(0,intval($communew['setting']['minlength']));
				$communew['setting']['maxlength'] = max(0,intval($communew['setting']['maxlength']));
				$communew['setting']['minscore'] = max(0,intval($communew['setting']['minscore']));
				$communew['setting']['maxscore'] = max(0,intval($communew['setting']['maxscore']));
				$communew['setting']['autocheck'] = max(0,intval($communew['setting']['autocheck']));
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
		case 'answer':
			if(!$save){
				trbasic(lang('forbid repeat vote support'),'communew[setting][norepeatvote]',isset($commu['setting']['norepeatvote']) ? $commu['setting']['norepeatvote'] : 0,'radio');
				trbasic(lang('answer0 minlength'),'communew[setting][minlength]',isset($commu['setting']['minlength']) ? $commu['setting']['minlength'] : 0);
				trbasic(lang('answer0 maxlength'),'communew[setting][maxlength]',isset($commu['setting']['maxlength']) ? $commu['setting']['maxlength'] : 0);
				trbasic(lang('item available days'),'communew[setting][vdays]',isset($commu['setting']['vdays']) ? $commu['setting']['vdays'] : 0);
				trbasic(lang('reward currency type'),'communew[setting][crid]',makeoption(cridsarr(),isset($commu['setting']['crid']) ? $commu['setting']['crid'] : 0),'select');
				trbasic(lang('allow reward mini currency'),'communew[setting][mini]',isset($commu['setting']['mini']) ? $commu['setting']['mini'] : 0);
				trbasic(lang('allow reward max currency'),'communew[setting][max]',isset($commu['setting']['max']) ? $commu['setting']['max'] : 0);
				trbasic(lang('credit value / reward currency'),'communew[setting][credit]',isset($commu['setting']['credit']) ? $commu['setting']['credit'] : 0);
				trbasic(lang('reward enable nota function'),'communew[setting][nota]',isset($commu['setting']['nota']) ? $commu['setting']['nota'] : 0,'radio');
				trbasic(lang('nota allow appeal days'),'communew[setting][apdays]',isset($commu['setting']['apdays']) ? $commu['setting']['apdays'] : 0);
				trbasic(lang('answer list template'),'communew[cutpl]',makeoption(array('' => lang('nosetting')) + mtplsarr('commu'),$commu['cutpl']),'select');
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),0);
			}else{
				if(empty($communew['setting']['crid'])) return lang('confirmchoose reward currency type');
				$communew['setting']['minlength'] = max(0,intval($communew['setting']['minlength']));
				$communew['setting']['maxlength'] = max(0,intval($communew['setting']['maxlength']));
				$communew['setting']['vdays'] = max(0,intval($communew['setting']['vdays']));
				$communew['setting']['apdays'] = max(0,intval($communew['setting']['apdays']));
				$communew['setting']['mini'] = max(0,intval($communew['setting']['mini']));
				$communew['setting']['max'] = max(0,intval($communew['setting']['max']));
				$communew['setting']['credit'] = max(0,intval($communew['setting']['credit']));
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
		case 'purchase':
			global $pfields,$fieldsnew;
			if(!$save){
				load_cache('pfields');
				$fieldsarr = array();
				foreach($pfields as $k => $v){
					$fieldsarr[$k] = $v['cname'];
				}
				$dcmodearr = array('0' => lang('discount noavailable'),'1' => lang('maxmode'),'2' => lang('addmode'));
				$pmodearr = array('0' => lang('cart mode'),'1' => lang('single goods mode'),);
				trbasic(lang('goods purchase mode'),'communew[setting][pmode]',makeradio('communew[setting][pmode]',$pmodearr,isset($commu['setting']['pmode']) ? $commu['setting']['pmode'] : 0),'');
				trbasic(lang('discount 1&nbsp;&nbsp;&nbsp; commu item discount (%)'),'communew[setting][discount]',isset($commu['setting']['discount']) ? $commu['setting']['discount'] : 0,'text');
				trbasic(lang('discount 2&nbsp;&nbsp;&nbsp; usergroup discount'),'communew[setting][gtmode]',makeoption($dcmodearr,isset($commu['setting']['gtmode']) ? $commu['setting']['gtmode'] : '0'),'select');
				trbasic(lang('discount 3&nbsp;&nbsp;&nbsp; catas discount'),'communew[setting][cnmode]',makeoption($dcmodearr,isset($commu['setting']['cnmode']) ? $commu['setting']['cnmode'] : '0'),'select');
				trbasic(lang('alldcmode'),'communew[setting][allmode]',makeoption($dcmodearr,isset($commu['setting']['allmode']) ? $commu['setting']['allmode'] : '0'),'select');
				trbasic(lang('available message field'),'fieldsnew[]',makecheckbox('fieldsnew[]',$fieldsarr,empty($commu['setting']['fields']) ? array() : explode(',',$commu['setting']['fields']),5),'');
				trbasic(lang('purchase list template'),'communew[cutpl]',makeoption(array('' => lang('nosetting')) + mtplsarr('commu'),$commu['cutpl']),'select');
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),1);
			}else{
				$communew['setting']['discount'] = round(min(100,max(0,floatval($communew['setting']['discount']))),2);
				$communew['setting']['fields'] = empty($fieldsnew) ? '' : implode(',',$fieldsnew);
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
		case 'subscribe':
			if(!$save){
				$autoarcarr = array(0 => lang('auto purchase'),1 => lang('confirm purchase'),);
				trbasic(lang('archive purchase mode'),'',makeradio('communew[setting][autoarc]',$autoarcarr,isset($commu['setting']['autoarc']) ? $commu['setting']['autoarc'] : 0),'');
				trbasic(lang('attachment purchase mode'),'',makeradio('communew[setting][autoatm]',$autoarcarr,isset($commu['setting']['autoatm']) ? $commu['setting']['autoatm'] : 0),'');
				tabfooter();
				ugids_table(lang('commu permission setting'),'nofooter',empty($commu['setting']['ugids']) ? array() : explode(',',$commu['setting']['ugids']),1);
			}else{
				$communew['setting']['ugids'] = !empty($ugidsnew) ? implode(',',$ugidsnew) : '';
				return '';
			}
		break;
	}
}
function view_pickurl($cclass){
	global $commu;
	if(!in_array($cclass,array('comment','answer','purchase'))) return;
	tabheader(lang('more pick url'));
	switch($cclass){
		case 'comment':
			trbasic(lang('comment pick url'),'',$commu['url'],'');
			trbasic(lang('delete comment url'),'',$commu['url'].'&action=del&cid={$cid}','');
		break;
		case 'answer':
			trbasic(lang('answer pick url'),'',$commu['url'],'');
			trbasic(lang('delete answer0 url'),'',$commu['url'].'&action=del&cid={$cid}','');
			trbasic(lang('vote support answer0 url'),'',$commu['url'].'&action=vote&cid={$cid}','');
			trbasic(lang('answer0 appeal url'),'',$commu['url'].'&action=appeal&cid={$cid}','');
			trbasic(lang('question admin url'),'','{$cms_abs}adminm.php?action=questions&aid={$aid}','');
		break;
		case 'purchase':
			trbasic(lang('purchase pick url'),'',$commu['url'],'');
			trbasic(lang('cart pick url'),'','{$cms_abs}adminm.php?action=cart','');
			trbasic(lang('goods purchase record url'),'','{$cms_abs}purchases.php?aid={$aid}','');
		break;
		case 'subscribe':
			trbasic(lang('archive subscribe pick url'),'',$commu['url'],'');
			trbasic(lang('attachment subscribe pick url'),'',$commu['url'].'&isatm=1','');
		break;
	}
	tabfooter();
}
function fetch_arr(){
	global $db,$tblprefix;
	$commus = array();
	$query = $db->query("SELECT * FROM {$tblprefix}commus ORDER BY issystem DESC,cuid ASC");
	while($commu = $db->fetch_array($query)){
		if($commu['setting'] && is_array($setting = unserialize($commu['setting']))){$commu['setting'] = $setting;}
		else{$commu['setting'] = array();}
		$commus[$commu['cuid']] = $commu;
	}
	return $commus;
}
function fetch_one($cuid){
	global $db,$tblprefix;
	$commu = $db->fetch_one("SELECT * FROM {$tblprefix}commus WHERE cuid='$cuid'");
	if($commu['setting'] && is_array($setting = unserialize($commu['setting']))){$commu['setting'] = $setting;}
	else{$commu['setting'] = array();}
	return $commu;
}
?>