printTrail($_REQUEST['subject']); $misc->printTitle($lang['strcreaterule'],'pg.rule.create'); $misc->printMsg($msg); echo "
\n"; } else { if (trim($_POST['name']) == '') createRule(true, $lang['strruleneedsname']); else { $status = $data->createRule($_POST['name'], $_POST['event'], $_POST[$_POST['subject']], $_POST['where'], isset($_POST['instead']), $_POST['type'], $_POST['raction']); if ($status == 0) doDefault($lang['strrulecreated']); else createRule(true, $lang['strrulecreatedbad']); } } } /** * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { global $data, $misc; global $lang; if ($confirm) { $misc->printTrail($_REQUEST['subject']); $misc->printTitle($lang['strdrop'],'pg.rule.drop'); echo "", sprintf($lang['strconfdroprule'], $misc->printVal($_REQUEST['rule']), $misc->printVal($_REQUEST[$_REQUEST['reltype']])), "
\n"; echo "\n"; } else { $status = $data->dropRule($_POST['rule'], $_POST[$_POST['subject']], isset($_POST['cascade'])); if ($status == 0) doDefault($lang['strruledropped']); else doDefault($lang['strruledroppedbad']); } } /** * List all the rules on the table */ function doDefault($msg = '') { global $data, $misc; global $lang; $misc->printTrail($_REQUEST['subject']); $misc->printTabs($_REQUEST['subject'], 'rules'); $misc->printMsg($msg); $rules = $data->getRules($_REQUEST[$_REQUEST['subject']]); $columns = array( 'rule' => array( 'title' => $lang['strname'], 'field' => field('rulename'), ), 'definition' => array( 'title' => $lang['strdefinition'], 'field' => field('definition'), ), 'actions' => array( 'title' => $lang['stractions'], ), ); $subject = urlencode($_REQUEST['subject']); $object = urlencode($_REQUEST[$_REQUEST['subject']]); $actions = array( 'drop' => array( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'rules.php', 'urlvars' => array ( 'action' => 'confirm_drop', 'reltype' => $subject, $subject => $object, 'subject' => 'rule', 'rule' => field('rulename') ) ) ) ), ); $misc->printTable($rules, $columns, $actions, 'rules-rules', $lang['strnorules']); $misc->printNavLinks(array ('create' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'rules.php', 'urlvars' => array ( 'action' => 'create_rule', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], $subject => $object, 'subject' => $subject ) ) ), 'content' => $lang['strcreaterule'] )), 'rules-rules', get_defined_vars()); } function doTree() { global $misc, $data; $rules = $data->getRules($_REQUEST[$_REQUEST['subject']]); $reqvars = $misc->getRequestVars($_REQUEST['subject']); $attrs = array( 'text' => field('rulename'), 'icon' => 'Rule', ); $misc->printTree($rules, $attrs, 'rules'); exit; } if ($action == 'tree') doTree(); // Different header if we're view rules or table rules $misc->printHeader($_REQUEST[$_REQUEST['subject']] . ' - ' . $lang['strrules']); $misc->printBody(); switch ($action) { case 'create_rule': createRule(true); break; case 'save_create_rule': if (isset($_POST['cancel'])) doDefault(); else createRule(false); break; case 'drop': if (isset($_POST['yes'])) doDrop(false); else doDefault(); break; case 'confirm_drop': doDrop(true); break; default: doDefault(); break; } $misc->printFooter(); ?>