createAggregate($_REQUEST['name'], $_REQUEST['basetype'], $_REQUEST['sfunc'], $_REQUEST['stype'], $_REQUEST['ffunc'], $_REQUEST['initcond'], $_REQUEST['sortop'], $_REQUEST['aggrcomment']); if ($status == 0) { $_reload_browser = true; doDefault($lang['straggrcreated']); } else { doCreate($lang['straggrcreatedbad']); } } /** * Displays a screen for create a new aggregate function */ function doCreate($msg = '') { global $data, $misc; global $lang; if (!isset($_REQUEST['name'])) $_REQUEST['name'] = ''; if (!isset($_REQUEST['basetype'])) $_REQUEST['basetype'] = ''; if (!isset($_REQUEST['sfunc'])) $_REQUEST['sfunc'] = ''; if (!isset($_REQUEST['stype'])) $_REQUEST['stype'] = ''; if (!isset($_REQUEST['ffunc'])) $_REQUEST['ffunc'] = ''; if (!isset($_REQUEST['initcond'])) $_REQUEST['initcond'] = ''; if (!isset($_REQUEST['sortop'])) $_REQUEST['sortop'] = ''; if (!isset($_REQUEST['aggrcomment'])) $_REQUEST['aggrcomment'] = ''; $misc->printTrail('schema'); $misc->printTitle($lang['strcreateaggregate'], 'pg.aggregate.create'); $misc->printMsg($msg); echo "
\n"; echo "\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "
{$lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['name']), "\" />
{$lang['straggrbasetype']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['basetype']), "\" />
{$lang['straggrsfunc']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['sfunc']), "\" />
{$lang['straggrstype']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['stype']), "\" />
{$lang['straggrffunc']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['ffunc']), "\" />
{$lang['straggrinitcond']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['initcond']), "\" />
{$lang['straggrsortop']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['sortop']), "\" />
{$lang['strcomment']}
\n"; echo "

\n"; echo $misc->form; echo "\n"; echo "

\n"; echo "
\n"; } /** * Function to save after altering an aggregate */ function doSaveAlter() { global $data, $lang; // Check inputs if (trim($_REQUEST['aggrname']) == '') { doAlter($lang['straggrneedsname']); return; } $status = $data->alterAggregate($_REQUEST['aggrname'], $_REQUEST['aggrtype'], $_REQUEST['aggrowner'], $_REQUEST['aggrschema'], $_REQUEST['aggrcomment'], $_REQUEST['newaggrname'], $_REQUEST['newaggrowner'], $_REQUEST['newaggrschema'], $_REQUEST['newaggrcomment']); if ($status == 0) doDefault($lang['straggraltered']); else { doAlter($lang['straggralteredbad']); return; } } /** * Function to allow editing an aggregate function */ function doAlter($msg = '') { global $data, $misc; global $lang; $misc->printTrail('aggregate'); $misc->printTitle($lang['stralter'], 'pg.aggregate.alter'); $misc->printMsg($msg); echo "
\n"; $aggrdata = $data->getAggregate($_REQUEST['aggrname'], $_REQUEST['aggrtype']); if($aggrdata->recordCount() > 0 ) { // Output table header echo "\n"; echo "\t\n\t\t"; echo ""; echo "\n\t\n"; // Display aggregate's name, owner and schema echo "\t\n\t\t"; echo ""; echo "\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "
{$lang['strname']}{$lang['strowner']}{$lang['strschema']}
fields['usename']), "\" />
{$lang['strcomment']}
\n"; echo "

\n"; echo $misc->form; echo "\n"; echo "\n"; echo "fields['usename']), "\" />\n"; echo "\n"; echo "fields['aggrcomment']), "\" />\n"; echo "\n"; echo "

\n"; } else { echo "

{$lang['strnodata']}

\n"; echo "

\n"; } echo "
\n"; } /** * Show confirmation of drop and perform actual drop of the aggregate function selected */ function doDrop($confirm) { global $data, $misc; global $lang, $_reload_browser; if ($confirm) { $misc->printTrail('aggregate'); $misc->printTitle($lang['strdrop'], 'pg.aggregate.drop'); echo "

", sprintf($lang['strconfdropaggregate'], htmlspecialchars($_REQUEST['aggrname'])), "

\n"; echo "
\n"; echo "

\n"; echo "

\n"; echo "\n"; echo "\n"; echo $misc->form; echo "\n"; echo "

\n"; echo "
\n"; } else { $status = $data->dropAggregate($_POST['aggrname'], $_POST['aggrtype'], isset($_POST['cascade'])); if ($status == 0) { $_reload_browser = true; doDefault($lang['straggregatedropped']); } else doDefault($lang['straggregatedroppedbad']); } } /** * Show the properties of an aggregate */ function doProperties($msg = '') { global $data, $misc; global $lang; $misc->printTrail('aggregate'); $misc->printTitle($lang['strproperties'],'pg.aggregate'); $misc->printMsg($msg); $aggrdata = $data->getAggregate($_REQUEST['aggrname'], $_REQUEST['aggrtype']); if($aggrdata->recordCount() > 0 ) { // Display aggregate's info echo "\n"; echo "\n\t\n"; echo "\t\n\n"; echo "\n\t\n"; echo "\t\n\n"; echo "\n\t\n"; echo "\t\n\n"; echo "\n\t\n"; echo "\t\n\n"; echo "\n\t\n"; echo "\t\n\n"; echo "\n\t\n"; echo "\t\n\n"; if($data->hasAggregateSortOp()) { echo "\n\t\n"; echo "\t\n\n"; } echo "\n\t\n"; echo "\t\n\n"; echo "\n\t\n"; echo "\t\n\n"; echo "
{$lang['strname']}", htmlspecialchars($_REQUEST['aggrname']), "
{$lang['straggrbasetype']}", htmlspecialchars($_REQUEST['aggrtype']), "
{$lang['straggrsfunc']}", htmlspecialchars($aggrdata->fields['aggtransfn']), "
{$lang['straggrstype']}", htmlspecialchars($aggrdata->fields['aggstype']), "
{$lang['straggrffunc']}", htmlspecialchars($aggrdata->fields['aggfinalfn']), "
{$lang['straggrinitcond']}", htmlspecialchars($aggrdata->fields['agginitval']), "
{$lang['straggrsortop']}", htmlspecialchars($aggrdata->fields['aggsortop']), "
{$lang['strowner']}", htmlspecialchars($aggrdata->fields['usename']), "
{$lang['strcomment']}", $misc->printVal($aggrdata->fields['aggrcomment']), "
\n"; } else echo "

{$lang['strnodata']}

\n"; $navlinks = array ( 'showall' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'aggregates.php', 'urlvars' => array ( 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'] ) ) ), 'content' => $lang['straggrshowall'] ) ); if ($data->hasAlterAggregate()) { $navlinks['alter'] = array ( 'attr'=> array ( 'href' => array ( 'url' => 'aggregates.php', 'urlvars' => array ( 'action' => 'alter', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], 'aggrname' => $_REQUEST['aggrname'], 'aggrtype' => $_REQUEST['aggrtype'] ) ) ), 'content' => $lang['stralter'] ); } $navlinks['drop'] = array ( 'attr'=> array ( 'href' => array ( 'url' => 'aggregates.php', 'urlvars' => array ( 'action' => 'confirm_drop', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], 'aggrname' => $_REQUEST['aggrname'], 'aggrtype' => $_REQUEST['aggrtype'] ) ) ), 'content' => $lang['strdrop'] ); $misc->printNavLinks($navlinks, 'aggregates-properties', get_defined_vars()); } /** * Show default list of aggregate functions in the database */ function doDefault($msg = '') { global $data, $conf, $misc; global $lang; $misc->printTrail('schema'); $misc->printTabs('schema', 'aggregates'); $misc->printMsg($msg); $aggregates = $data->getAggregates(); $columns = array( 'aggrname' => array( 'title' => $lang['strname'], 'field' => field('proname'), 'url' => "redirect.php?subject=aggregate&action=properties&{$misc->href}&", 'vars' => array('aggrname' => 'proname', 'aggrtype' => 'proargtypes'), ), 'aggrtype' => array( 'title' => $lang['strtype'], 'field' => field('proargtypes'), ), 'aggrtransfn' => array( 'title' => $lang['straggrsfunc'], 'field' => field('aggtransfn'), ), 'owner' => array( 'title' => $lang['strowner'], 'field' => field('usename'), ), 'actions' => array( 'title' => $lang['stractions'], ), 'comment' => array( 'title' => $lang['strcomment'], 'field' => field('aggrcomment'), ), ); $actions = array( 'alter' => array( 'content' => $lang['stralter'], 'attr'=> array ( 'href' => array ( 'url' => 'aggregates.php', 'urlvars' => array ( 'action' => 'alter', 'aggrname' => field('proname'), 'aggrtype' => field('proargtypes') ) ) ) ), 'drop' => array( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'aggregates.php', 'urlvars' => array ( 'action' => 'confirm_drop', 'aggrname' => field('proname'), 'aggrtype' => field('proargtypes') ) ) ) ) ); if (!$data->hasAlterAggregate()) unset($actions['alter']); $misc->printTable($aggregates, $columns, $actions, 'aggregates-aggregates', $lang['strnoaggregates']); $navlinks = array ( 'create' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'aggregates.php', 'urlvars' => array ( 'action' => 'create', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], ) ) ), 'content' => $lang['strcreateaggregate'] ) ); $misc->printNavLinks($navlinks, 'aggregates-aggregates', get_defined_vars()); } /** * Generate XML for the browser tree. */ function doTree() { global $misc, $data; $aggregates = $data->getAggregates(); $proto = concat(field('proname'), ' (', field('proargtypes'), ')'); $reqvars = $misc->getRequestVars('aggregate'); $attrs = array( 'text' => $proto, 'icon' => 'Aggregate', 'toolTip' => field('aggcomment'), 'action' => url('redirect.php', $reqvars, array( 'action' => 'properties', 'aggrname' => field('proname'), 'aggrtype' => field('proargtypes') ) ) ); $misc->printTree($aggregates, $attrs, 'aggregates'); exit; } if ($action == 'tree') doTree(); $misc->printHeader($lang['straggregates']); $misc->printBody(); switch ($action) { case 'create': doCreate(); break; case 'save_create': if (isset($_POST['cancel'])) doDefault(); else doSaveCreate(); break; case 'alter': doAlter(); break; case 'save_alter': if (isset($_POST['alter'])) doSaveAlter(); else doProperties(); break; case 'drop': if (isset($_POST['drop'])) doDrop(false); else doDefault(); break; case 'confirm_drop': doDrop(true); break; default: doDefault(); break; case 'properties': doProperties(); break; } $misc->printFooter(); ?>