printTrail('database'); $misc->printTabs('database','schemas'); $misc->printMsg($msg); // Check that the DB actually supports schemas $schemas = $data->getSchemas(); $columns = array( 'schema' => array( 'title' => $lang['strschema'], 'field' => field('nspname'), 'url' => "redirect.php?subject=schema&{$misc->href}&", 'vars' => array('schema' => 'nspname'), ), 'owner' => array( 'title' => $lang['strowner'], 'field' => field('nspowner'), ), 'actions' => array( 'title' => $lang['stractions'], ), 'comment' => array( 'title' => $lang['strcomment'], 'field' => field('nspcomment'), ), ); $actions = array( 'multiactions' => array( 'keycols' => array('nsp' => 'nspname'), 'url' => 'schemas.php', ), 'drop' => array( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'schemas.php', 'urlvars' => array ( 'action' => 'drop', 'nsp' => field('nspname') ) ) ), 'multiaction' => 'drop', ), 'privileges' => array( 'content' => $lang['strprivileges'], 'attr'=> array ( 'href' => array ( 'url' => 'privileges.php', 'urlvars' => array ( 'subject' => 'schema', 'schema' => field('nspname') ) ) ) ), 'alter' => array( 'content' => $lang['stralter'], 'attr'=> array ( 'href' => array ( 'url' => 'schemas.php', 'urlvars' => array ( 'action' => 'alter', 'schema' => field('nspname') ) ) ) ) ); if (!$data->hasAlterSchema()) unset($actions['alter']); $misc->printTable($schemas, $columns, $actions, 'schemas-schemas', $lang['strnoschemas']); $misc->printNavLinks(array ('create' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'schemas.php', 'urlvars' => array ( 'action' => 'create', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'] ) ) ), 'content' => $lang['strcreateschema'] )), 'schemas-schemas', get_defined_vars()); } /** * Displays a screen where they can enter a new schema */ function doCreate($msg = '') { global $data, $misc; global $lang; $server_info = $misc->getServerInfo(); if (!isset($_POST['formName'])) $_POST['formName'] = ''; if (!isset($_POST['formAuth'])) $_POST['formAuth'] = $server_info['username']; if (!isset($_POST['formSpc'])) $_POST['formSpc'] = ''; if (!isset($_POST['formComment'])) $_POST['formComment'] = ''; // Fetch all users from the database $users = $data->getUsers(); $misc->printTrail('database'); $misc->printTitle($lang['strcreateschema'],'pg.schema.create'); $misc->printMsg($msg); echo "
\n"; } /** * Actually creates the new schema in the database */ function doSaveCreate() { global $data, $lang, $_reload_browser; // Check that they've given a name if ($_POST['formName'] == '') doCreate($lang['strschemaneedsname']); else { $status = $data->createSchema($_POST['formName'], $_POST['formAuth'], $_POST['formComment']); if ($status == 0) { $_reload_browser = true; doDefault($lang['strschemacreated']); } else doCreate($lang['strschemacreatedbad']); } } /** * Display a form to permit editing schema properties. * TODO: permit changing owner */ function doAlter($msg = '') { global $data, $misc, $lang; $misc->printTrail('schema'); $misc->printTitle($lang['stralter'],'pg.schema.alter'); $misc->printMsg($msg); $schema = $data->getSchemaByName($_REQUEST['schema']); if ($schema->recordCount() > 0) { if (!isset($_POST['comment'])) $_POST['comment'] = $schema->fields['nspcomment']; if (!isset($_POST['schema'])) $_POST['schema'] = $_REQUEST['schema']; if (!isset($_POST['name'])) $_POST['name'] = $_REQUEST['schema']; if (!isset($_POST['owner'])) $_POST['owner'] = $schema->fields['ownername']; echo "\n"; } else { echo "{$lang['strnodata']}
\n"; } } /** * Save the form submission containing changes to a schema */ function doSaveAlter($msg = '') { global $data, $misc, $lang, $_reload_browser; $status = $data->updateSchema($_POST['schema'], $_POST['comment'], $_POST['name'], $_POST['owner']); if ($status == 0) { $_reload_browser = true; doDefault($lang['strschemaaltered']); } else doAlter($lang['strschemaalteredbad']); } /** * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { global $data, $misc; global $lang, $_reload_browser; if (empty($_REQUEST['nsp']) && empty($_REQUEST['ma'])) { doDefault($lang['strspecifyschematodrop']); exit(); } if ($confirm) { $misc->printTrail('schema'); $misc->printTitle($lang['strdrop'],'pg.schema.drop'); echo "\n"; } else { if (is_array($_POST['nsp'])) { $msg = ''; $status = $data->beginTransaction(); if ($status == 0) { foreach($_POST['nsp'] as $s) { $status = $data->dropSchema($s, isset($_POST['cascade'])); if ($status == 0) $msg.= sprintf('%s: %s