printHeader(); $this->printBody(); switch ($this->action) { case 'save_create': if (isset($_REQUEST['cancel'])) { $this->doDefault(); } else { $this->doSaveCreate(); } break; case 'create': $this->doCreate(); break; case 'drop': if (isset($_REQUEST['cancel'])) { $this->doDefault(); } else { $this->doDrop(false); } break; case 'confirm_drop': $this->doDrop(true); break; case 'save_edit': if (isset($_REQUEST['cancel'])) { $this->doDefault(); } else { $this->doSaveAlter(); } break; case 'edit': $this->doAlter(); break; default: $this->doDefault(); break; } $this->printFooter(); } /** * Show default list of tablespaces in the cluster. * * @param mixed $msg */ public function doDefault($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('server'); $this->printTabs('server', 'tablespaces'); $this->printMsg($msg); $tablespaces = $data->getTablespaces(); $columns = [ 'database' => [ 'title' => $this->lang['strname'], 'field' => \PHPPgAdmin\Decorators\Decorator::field('spcname'), ], 'owner' => [ 'title' => $this->lang['strowner'], 'field' => \PHPPgAdmin\Decorators\Decorator::field('spcowner'), ], 'location' => [ 'title' => $this->lang['strlocation'], 'field' => \PHPPgAdmin\Decorators\Decorator::field('spclocation'), ], 'actions' => [ 'title' => $this->lang['stractions'], ], ]; if ($data->hasSharedComments()) { $columns['comment'] = [ 'title' => $this->lang['strcomment'], 'field' => \PHPPgAdmin\Decorators\Decorator::field('spccomment'), ]; } $actions = [ 'alter' => [ 'content' => $this->lang['stralter'], 'attr' => [ 'href' => [ 'url' => 'tablespaces', 'urlvars' => [ 'action' => 'edit', 'tablespace' => \PHPPgAdmin\Decorators\Decorator::field('spcname'), ], ], ], ], 'drop' => [ 'content' => $this->lang['strdrop'], 'attr' => [ 'href' => [ 'url' => 'tablespaces', 'urlvars' => [ 'action' => 'confirm_drop', 'tablespace' => \PHPPgAdmin\Decorators\Decorator::field('spcname'), ], ], ], ], 'privileges' => [ 'content' => $this->lang['strprivileges'], 'attr' => [ 'href' => [ 'url' => 'privileges', 'urlvars' => [ 'subject' => 'tablespace', 'tablespace' => \PHPPgAdmin\Decorators\Decorator::field('spcname'), ], ], ], ], ]; echo $this->printTable($tablespaces, $columns, $actions, 'tablespaces-tablespaces', $this->lang['strnotablespaces']); $this->printNavLinks(['create' => [ 'attr' => [ 'href' => [ 'url' => 'tablespaces', 'urlvars' => [ 'action' => 'create', 'server' => $_REQUEST['server'], ], ], ], 'content' => $this->lang['strcreatetablespace'], ]], 'tablespaces-tablespaces', get_defined_vars()); } /** * Function to allow altering of a tablespace. * * @param mixed $msg */ public function doAlter($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('tablespace'); $this->printTitle($this->lang['stralter'], 'pg.tablespace.alter'); $this->printMsg($msg); // Fetch tablespace info $tablespace = $data->getTablespace($_REQUEST['tablespace']); // Fetch all users $users = $data->getUsers(); if ($tablespace->recordCount() > 0) { $this->coalesceArr($_POST, 'name', $tablespace->fields['spcname']); $this->coalesceArr($_POST, 'owner', $tablespace->fields['spcowner']); $this->coalesceArr($_POST, 'comment', ($data->hasSharedComments()) ? $tablespace->fields['spccomment'] : ''); echo '
'.PHP_EOL; echo $this->misc->form; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; if ($data->hasSharedComments()) { echo "".PHP_EOL; echo ''.PHP_EOL; } echo '
{$this->lang['strname']}'; echo "_maxNameLen}\" value=\"", htmlspecialchars($_POST['name']), '" />
{$this->lang['strowner']}
{$this->lang['strcomment']}'; echo '
'.PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo "lang['stralter']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { echo "

{$this->lang['strnodata']}

".PHP_EOL; } } /** * Function to save after altering a tablespace. */ public function doSaveAlter() { $data = $this->misc->getDatabaseAccessor(); // Check data if ('' == trim($_POST['name'])) { $this->doAlter($this->lang['strtablespaceneedsname']); } else { $status = $data->alterTablespace($_POST['tablespace'], $_POST['name'], $_POST['owner'], $_POST['comment']); if (0 == $status) { // If tablespace has been renamed, need to change to the new name if ($_POST['tablespace'] != $_POST['name']) { // Jump them to the new table name $_REQUEST['tablespace'] = $_POST['name']; } $this->doDefault($this->lang['strtablespacealtered']); } else { $this->doAlter($this->lang['strtablespacealteredbad']); } } } /** * Show confirmation of drop and perform actual drop. * * @param mixed $confirm */ public function doDrop($confirm) { $data = $this->misc->getDatabaseAccessor(); if ($confirm) { $this->printTrail('tablespace'); $this->printTitle($this->lang['strdrop'], 'pg.tablespace.drop'); echo '

', sprintf($this->lang['strconfdroptablespace'], $this->misc->printVal($_REQUEST['tablespace'])), '

'.PHP_EOL; echo '
'.PHP_EOL; echo $this->misc->form; echo ''.PHP_EOL; echo ''.PHP_EOL; echo "lang['strdrop']}\" />".PHP_EOL; echo "lang['strcancel']}\" />".PHP_EOL; echo '
'.PHP_EOL; } else { $status = $data->droptablespace($_REQUEST['tablespace']); if (0 == $status) { $this->doDefault($this->lang['strtablespacedropped']); } else { $this->doDefault($this->lang['strtablespacedroppedbad']); } } } /** * Displays a screen where they can enter a new tablespace. * * @param mixed $msg */ public function doCreate($msg = '') { $data = $this->misc->getDatabaseAccessor(); $server_info = $this->misc->getServerInfo(); $this->coalesceArr($_POST, 'formSpcname', ''); $this->coalesceArr($_POST, 'formOwner', $server_info['username']); $this->coalesceArr($_POST, 'formLoc', ''); $this->coalesceArr($_POST, 'formComment', ''); // Fetch all users $users = $data->getUsers(); $this->printTrail('server'); $this->printTitle($this->lang['strcreatetablespace'], 'pg.tablespace.create'); $this->printMsg($msg); echo '
'.PHP_EOL; echo $this->misc->form; echo ''.PHP_EOL; echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Comments (if available) if ($data->hasSharedComments()) { echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; } echo '
{$this->lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_POST['formSpcname']), "\" />
{$this->lang['strowner']}
{$this->lang['strlocation']}
{$this->lang['strcomment']}
'.PHP_EOL; echo '

'.PHP_EOL; echo "lang['strcreate']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } /** * Actually creates the new tablespace in the cluster. */ public function doSaveCreate() { $data = $this->misc->getDatabaseAccessor(); // Check data if ('' == trim($_POST['formSpcname'])) { $this->doCreate($this->lang['strtablespaceneedsname']); } elseif ('' == trim($_POST['formLoc'])) { $this->doCreate($this->lang['strtablespaceneedsloc']); } else { // Default comment to blank if it isn't set $this->coalesceArr($_POST, 'formComment', null); $status = $data->createTablespace($_POST['formSpcname'], $_POST['formOwner'], $_POST['formLoc'], $_POST['formComment']); if (0 == $status) { $this->doDefault($this->lang['strtablespacecreated']); } else { $this->doCreate($this->lang['strtablespacecreatedbad']); } } } }