<?php

require_once XOOPS_TRUST_PATH . '/libs/xoonips/class/core/Request.class.php';
require_once XOOPS_TRUST_PATH . '/libs/xoonips/class/core/Response.class.php';
require_once XOOPS_TRUST_PATH . '/libs/xoonips/class/core/Utils.class.php';
require_once XOOPS_ROOT_PATH . '/include/cp_header.php';
require_once 'actions/PolicyItemSortAction.class.php';

$request = new Xoonips_Request();
$response = new Xoonips_Response();
$op = $request->getParameter('op');
if ($op == null) {
	$op = 'init';
}

if ($op=='deleteconfirm' || $op=='delete'){
	require_once XOOPS_ROOT_PATH . '/modules/legacyRender/kernel/Legacy_AdminRenderSystem.class.php';	
}

// check request
if (!in_array($op, array('init', 'edit', 'save', 'delete'))) {
	die('illegal reuest');
}

// set action map
$actionMap = array();
$actionMap['init_success'] = 'policy_itemsort.html';
$actionMap['edit_success'] = 'policy_itemsort_edit.html';
$actionMap['save_success'] = 'redirect_header';
$actionMap['delete_success'] = 'redirect_header';

if (!($op=='deleteconfirm' || $op=='delete')){
	include XOOPS_ROOT_PATH . '/header.php';	
}

// do action
$action = new Xoonips_PolicyItemSortAction();
$action->doAction($request, $response);

// forward
if ($op=='deleteconfirm' || $op=='delete'){
	$response->forwardLayeredWindow($actionMap,true);    
} else {
	$response->forward($actionMap,true);
}

if (!($op=='deleteconfirm' || $op=='delete')){
	include XOOPS_ROOT_PATH . '/footer.php';	
}

