printTrail('schema'); $misc->printTabs('schema', 'sequences'); $misc->printMsg($msg); // Get all sequences $sequences = $data->getSequences(); $columns = array( 'sequence' => array( 'title' => $lang['strsequence'], 'field' => field('seqname'), 'url' => "sequences.php?action=properties&{$misc->href}&", 'vars' => array('sequence' => 'seqname'), ), 'owner' => array( 'title' => $lang['strowner'], 'field' => field('seqowner'), ), 'actions' => array( 'title' => $lang['stractions'], ), 'comment' => array( 'title' => $lang['strcomment'], 'field' => field('seqcomment'), ), ); $actions = array( 'multiactions' => array( 'keycols' => array('sequence' => 'seqname'), 'url' => 'sequences.php', ), 'alter' => array( 'title' => $lang['stralter'], 'url' => "sequences.php?action=confirm_alter&{$misc->href}&subject=sequence&", 'vars' => array('sequence' => 'seqname'), ), 'drop' => array( 'title' => $lang['strdrop'], 'url' => "sequences.php?action=confirm_drop&{$misc->href}&", 'vars' => array('sequence' => 'seqname'), 'multiaction' => 'confirm_drop', ), 'privileges' => array( 'title' => $lang['strprivileges'], 'url' => "privileges.php?{$misc->href}&subject=sequence&", 'vars' => array('sequence' => 'seqname'), ), ); $misc->printTable($sequences, $columns, $actions, $lang['strnosequences']); echo "
href}\">{$lang['strcreatesequence']}
\n"; } /** * Generate XML for the browser tree. */ function doTree() { global $misc, $data; $sequences = $data->getSequences(); $reqvars = $misc->getRequestVars('sequence'); $attrs = array( 'text' => field('seqname'), 'icon' => 'Sequence', 'toolTip'=> field('seqcomment'), 'action' => url('sequences.php', $reqvars, array ( 'action' => 'properties', 'sequence' => field('seqname') ) ) ); $misc->printTreeXML($sequences, $attrs); exit; } /** * Display the properties of a sequence */ function doProperties($msg = '') { global $data, $misc; global $lang; $misc->printTrail('sequence'); $misc->printTitle($lang['strproperties'],'pg.sequence'); $misc->printMsg($msg); // Fetch the sequence information $sequence = $data->getSequence($_REQUEST['sequence']); if (is_object($sequence) && $sequence->recordCount() > 0) { $sequence->fields['is_cycled'] = $data->phpBool($sequence->fields['is_cycled']); $sequence->fields['is_called'] = $data->phpBool($sequence->fields['is_called']); // Show comment if any if ($sequence->fields['seqcomment'] !== null) echo "", $misc->printVal($sequence->fields['seqcomment']), "
\n"; echo "{$lang['strname']} | "; if ($data->hasAlterSequenceStart()) { echo "{$lang['strstartvalue']} | "; } echo "{$lang['strlastvalue']} | "; echo "{$lang['strincrementby']} | "; echo "{$lang['strmaxvalue']} | "; echo "{$lang['strminvalue']} | "; echo "{$lang['strcachevalue']} | "; echo "{$lang['strlogcount']} | "; echo "{$lang['strcancycle']} | "; echo "{$lang['striscalled']} |
---|---|---|---|---|---|---|---|---|---|
", $misc->printVal($sequence->fields['seqname']), " | "; if ($data->hasAlterSequenceStart()) { echo "", $misc->printVal($sequence->fields['start_value']), " | "; } echo "", $misc->printVal($sequence->fields['last_value']), " | "; echo "", $misc->printVal($sequence->fields['increment_by']), " | "; echo "", $misc->printVal($sequence->fields['max_value']), " | "; echo "", $misc->printVal($sequence->fields['min_value']), " | "; echo "", $misc->printVal($sequence->fields['cache_value']), " | "; echo "", $misc->printVal($sequence->fields['log_cnt']), " | "; echo "", ($sequence->fields['is_cycled'] ? $lang['stryes'] : $lang['strno']), " | "; echo "", ($sequence->fields['is_called'] ? $lang['stryes'] : $lang['strno']), " | "; echo "
{$lang['strnodata']}
\n"; } /** * Drop a sequence */ function doDrop($confirm, $msg = '') { global $data, $misc; global $lang; if (empty($_REQUEST['sequence']) && empty($_REQUEST['ma'])) { doDefault($lang['strspecifysequencetodrop']); exit(); } if ($confirm) { $misc->printTrail('sequence'); $misc->printTitle($lang['strdrop'],'pg.sequence.drop'); $misc->printMsg($msg); echo "\n"; } else { if (is_array($_POST['sequence'])) { $msg=''; $status = $data->beginTransaction(); if ($status == 0) { foreach($_POST['sequence'] as $s) { $status = $data->dropSequence($s, isset($_POST['cascade'])); if ($status == 0) $msg.= sprintf('%s: %s{$lang['strnodata']}
\n"; } /** * Function to save after altering a sequence */ function doSaveAlter() { global $data, $lang, $_reload_browser, $misc; if (!isset($_POST['owner'])) $_POST['owner'] = null; if (!isset($_POST['newschema'])) $_POST['newschema'] = null; if (!isset($_POST['formIncrement'])) $_POST['formIncrement'] = null; if (!isset($_POST['formMinValue'])) $_POST['formMinValue'] = null; if (!isset($_POST['formMaxValue'])) $_POST['formMaxValue'] = null; if (!isset($_POST['formStartValue'])) $_POST['formStartValue'] = null; if (!isset($_POST['formRestartValue'])) $_POST['formRestartValue'] = null; if (!isset($_POST['formCacheValue'])) $_POST['formCacheValue'] = null; if (!isset($_POST['formCycledValue'])) $_POST['formCycledValue'] = null; $status = $data->alterSequence($_POST['sequence'], $_POST['name'], $_POST['comment'], $_POST['owner'], $_POST['newschema'], $_POST['formIncrement'], $_POST['formMinValue'], $_POST['formMaxValue'], $_POST['formRestartValue'], $_POST['formCacheValue'], isset($_POST['formCycledValue']), $_POST['formStartValue']); if ($status == 0) { if ($_POST['sequence'] != $_POST['name']) { // Jump them to the new view name $_REQUEST['sequence'] = $_POST['name']; // Force a browser reload $_reload_browser = true; } if (!empty($_POST['newschema']) && ($_POST['newschema'] != $data->_schema)) { // Jump them to the new sequence schema $misc->setCurrentSchema($_POST['newschema']); $_reload_browser = true; } doProperties($lang['strsequencealtered']); } else doProperties($lang['strsequencealteredbad']); } /** * Function to allow altering of a sequence */ function doAlter($msg = '') { global $data, $misc; global $lang; $misc->printTrail('sequence'); $misc->printTitle($lang['stralter'], 'pg.sequence.alter'); $misc->printMsg($msg); // Fetch the sequence information $sequence = $data->getSequence($_REQUEST['sequence']); if (is_object($sequence) && $sequence->recordCount() > 0) { if (!isset($_POST['name'])) $_POST['name'] = $_REQUEST['sequence']; if (!isset($_POST['comment'])) $_POST['comment'] = $sequence->fields['seqcomment']; if (!isset($_POST['owner'])) $_POST['owner'] = $sequence->fields['seqowner']; if (!isset($_POST['newschema'])) $_POST['newschema'] = $sequence->fields['nspname']; // Handle Checkbox Value $sequence->fields['is_cycled'] = $data->phpBool($sequence->fields['is_cycled']); if ($sequence->fields['is_cycled']) $_POST['formCycledValue'] = 'on'; echo "\n"; } else echo "{$lang['strnodata']}
\n"; } if ($action == 'tree') doTree(); // Print header $misc->printHeader($lang['strsequences']); $misc->printBody(); switch($action) { case 'create': doCreateSequence(); break; case 'save_create_sequence': if (isset($_POST['create'])) doSaveCreateSequence(); else doDefault(); break; case 'properties': doProperties(); break; case 'drop': if (isset($_POST['drop'])) doDrop(false); else doDefault(); break; case 'confirm_drop': doDrop(true); break; case 'restart': doRestart(); break; case 'reset': doReset(); break; case 'nextval': doNextval(); break; case 'setval': if (isset($_POST['setval'])) doSaveSetval(); else doDefault(); break; case 'confirm_setval': doSetval(); break; case 'alter': if (isset($_POST['alter'])) doSaveAlter(); else doDefault(); break; case 'confirm_alter': doAlter(); break; default: doDefault(); break; } // Print footer $misc->printFooter(); ?>