<?php
if(!$_SESSION['admin_id']){
	pe_goto("index.php");
}
$menumark = 'noticeclass_list';
switch ($act) {
	/* ====================== 公告分类增加sql ====================== */
	case 'addsql':
		if ($db->pe_insert('noticeclass', pe_dbhold($_p_info))) {
			cache::write('noticeclass', $db->index('noticeclass_id')->pe_selectall('noticeclass', array('order by'=>'noticeclass_order asc, noticeclass_id asc'), '*'));
			pe_success('分类发布成功!', 'admin.php?mod=noticeclass&act=list');
		}
		else {
			pe_error('分类发布失败...');
		}
	break;
	/* ====================== 公告分类修改sql ====================== */
	case 'editsql':
		if ($db->pe_update('noticeclass', array('noticeclass_id'=>$_g_id), pe_dbhold($_p_info))) {
			cache::write('noticeclass', $db->index('noticeclass_id')->pe_selectall('noticeclass', array('order by'=>'noticeclass_order asc, noticeclass_id asc'), '*'));
			pe_success('分类修改成功!', 'admin.php?mod=noticeclass&act=list');
		}
		else {
			pe_error('分类修改失败...');
		}
	break;
	/* ====================== 公告分类删除sql ====================== */
	case 'delsql':
		if ($db->pe_delete('noticeclass', array('noticeclass_id'=>is_array($_p_noticeclass_id) ? $_p_noticeclass_id : $_g_id))) {
			cache::write('noticeclass', $db->index('noticeclass_id')->pe_selectall('noticeclass', array('order by'=>'noticeclass_order asc, noticeclass_id asc'), '*'));
			pe_success('分类删除成功!');
		}
		else {
			pe_error('分类删除失败...');
		}
	break;
	/* ====================== 公告分类列表 ====================== */
	default :	
		$info_list = $db->pe_selectall('noticeclass');

		$action = "admin.php?mod=noticeclass&act=addsql";
		$seo = pe_seo('公告分类', '', '', 'admin');
		if ($act == 'edit') {
			$info = $db->pe_select('noticeclass', array('noticeclass_id'=>$_g_id));
			$action = "admin.php?mod=noticeclass&act=editsql&id={$_g_id}";
			$seo = pe_seo('修改分类', '', '', 'admin');
		}
		$menunav = 'noticeclass_list';
		include(pe_tpl('noticeclass_list.html'));
	break;
}
pe_result();
?>