<?php
	!defined('DIRCMS_MANAGE') && exit('Access Denied!');
	$r=cache_read('module.cache.php',DIRCMS_ROOT.'data/cache_module/');
	$r=$r['order']['roleid']; 
	if(!in_array($_roleid,$r) && $_userid!=ADMIN_FOUNDERS)showmsg_nourl('您没有该操作的权限!');
	$action=empty($action)?'manage':trim($action);

	$c=new cache();
	switch($action)
	{
		case 'manage':
			$result=$db->fetch_all("SELECT * FROM `".DB_PRE."pay_method` ORDER BY `".DB_PRE."pay_method`.`orderby` ASC");
			include admin_tlp('paymethod_manage');
			unset($result);
			break;
		case 'install':
			if($db->query("UPDATE ".DB_PRE."pay_method SET ".DB_PRE."pay_method.enabled=".intval($enabled)." WHERE ".DB_PRE."pay_method.id=".intval($id),true))
			{
				$c->cache_paymethod();
				showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=paymethod&action=manage');
			}
			else 
			{
				showmsg($LANG['MANAGE_ERROR'],ADMIN_FILE.'?file=paymethod&action=manage');
			}
			break;
		case 'edit':
			if(isset($do_submit))
			{
				$config=$config?$config:array();
				$config=var_export($config,true);
				$info['config']=mysql_escape_string($config);
				$db->update(DB_PRE.'pay_method',$info,DB_PRE.'pay_method.id='.intval($id));
				$c->cache_paymethod();
				showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=paymethod&action=manage');
			}
			$val=$db->fetch_one("SELECT * FROM `".DB_PRE."pay_method` WHERE `".DB_PRE."pay_method`.`id`=".intval($id));
			$config=string2array($val['config']);
			include admin_tlp('paymethod_edit');
			unset($val);
			break;
	}
?>
