/**\r
* Manage views in a database\r
*\r
- * $Id: views.php,v 1.3 2002/05/15 09:57:55 chriskl Exp $\r
+ * $Id: views.php,v 1.4 2002/07/11 06:01:14 chriskl Exp $\r
*/\r
\r
// Include application functions\r
* Function to save after editing a view\r
*/\r
function doSaveEdit() {\r
- global $localData, $view, $formDefinition;\r
+ global $localData;\r
\r
- $status = $localData->setView($view, $formDefinition);\r
+ $status = $localData->setView($_POST['view'], $_POST['formDefinition']);\r
if ($status == 0)\r
doProperties('View updated.');\r
else\r
* Function to allow editing of a view\r
*/\r
function doEdit($msg = '') {\r
- global $data, $localData, $misc, $database, $view;\r
+ global $data, $localData, $misc;\r
global $PHP_SELF, $strName, $strDefinition;\r
\r
- echo "<h2>", htmlspecialchars($database), ": Views: ", htmlspecialchars($view), ": Edit</h2>\n";\r
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Views: ", htmlspecialchars($_REQUEST['view']), ": Edit</h2>\n";\r
$misc->printMsg($msg);\r
\r
- $viewdata = &$localData->getView($view);\r
+ $viewdata = &$localData->getView($_REQUEST['view']);\r
\r
if ($viewdata->recordCount() > 0) {\r
echo "<form action=\"$PHP_SELF\" method=post>\n";\r
htmlspecialchars($viewdata->f[$data->vwFields['vwdef']]), "</textarea></td></tr>\n";\r
echo "</table>\n";\r
echo "<input type=hidden name=action value=save_edit>\n";\r
- echo "<input type=hidden name=view value=\"", htmlspecialchars($view), "\">\n";\r
- echo "<input type=hidden name=database value=\"", htmlspecialchars($database), "\">\n";\r
+ echo "<input type=hidden name=view value=\"", htmlspecialchars($_REQUEST['view']), "\">\n";\r
+ echo "<input type=hidden name=database value=\"", htmlspecialchars($_REQUEST['database']), "\">\n";\r
echo "<input type=submit value=Save> <input type=reset>\n";\r
echo "</form>\n";\r
}\r
else echo "<p>No data.</p>\n";\r
\r
- echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($database), "\">Show All Views</a> |\n";\r
- echo "<a class=navlink href=\"$PHP_SELF?action=properties&database=", urlencode($database), "&view=", \r
- urlencode($view), "\">Properties</a></p>\n";\r
+ echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($_REQUEST['database']), "\">Show All Views</a> |\n";\r
+ echo "<a class=navlink href=\"$PHP_SELF?action=properties&database=", urlencode($_REQUEST['database']), "&view=", \r
+ urlencode($_REQUEST['view']), "\">Properties</a></p>\n";\r
}\r
\r
/**\r
* Show read only properties for a view\r
*/\r
function doProperties($msg = '') {\r
- global $data, $localData, $misc, $database, $view;\r
+ global $data, $localData, $misc;\r
global $PHP_SELF, $strName, $strDefinition;\r
\r
- echo "<h2>", htmlspecialchars($database), ": Views: ", htmlspecialchars($view), ": Properties</h2>\n";\r
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Views: ", htmlspecialchars($_REQUEST['view']), ": Properties</h2>\n";\r
$misc->printMsg($msg);\r
\r
- $viewdata = &$localData->getView($view);\r
+ $viewdata = &$localData->getView($_REQUEST['view']);\r
\r
if ($viewdata->recordCount() > 0) {\r
echo "<table width=100%>\n";\r
}\r
else echo "<p>No data.</p>\n";\r
\r
- echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($database), "\">Show All Views</a> |\n";\r
- echo "<a class=navlink href=\"$PHP_SELF?action=edit&database=", urlencode($database), "&view=", \r
- urlencode($view), "\">Edit</a></p>\n";\r
+ echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($_REQUEST['database']), "\">Show All Views</a> |\n";\r
+ echo "<a class=navlink href=\"$PHP_SELF?action=edit&database=", urlencode($_REQUEST['database']), "&view=", \r
+ urlencode($_REQUEST['view']), "\">Edit</a></p>\n";\r
}\r
\r
/**\r
* Show confirmation of drop and perform actual drop\r
*/\r
function doDrop($confirm) {\r
- global $localData, $database, $view;\r
+ global $localData, $database;\r
global $PHP_SELF;\r
\r
if ($confirm) { \r
- echo "<h2>", htmlspecialchars($database), ": Views: ", htmlspecialchars($view), ": Drop</h2>\n";\r
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Views: ", htmlspecialchars($_REQUEST['view']), ": Drop</h2>\n";\r
\r
- echo "<p>Are you sure you want to drop the view \"", htmlspecialchars($view), "\"?</p>\n";\r
+ echo "<p>Are you sure you want to drop the view \"", htmlspecialchars($_REQUEST['view']), "\"?</p>\n";\r
\r
echo "<form action=\"$PHP_SELF\" method=\"post\">\n";\r
echo "<input type=hidden name=action value=drop>\n";\r
- echo "<input type=hidden name=view value=\"", htmlspecialchars($view), "\">\n";\r
- echo "<input type=hidden name=database value=\"", htmlspecialchars($database), "\">\n";\r
+ echo "<input type=hidden name=view value=\"", htmlspecialchars($_REQUEST['view']), "\">\n";\r
+ echo "<input type=hidden name=database value=\"", htmlspecialchars($_REQUEST['database']), "\">\n";\r
echo "<input type=submit name=choice value=\"Yes\"> <input type=submit name=choice value=\"No\">\n";\r
echo "</form>\n";\r
}\r
else {\r
- $status = $localData->dropView($view);\r
+ $status = $localData->dropView($_POST['view']);\r
if ($status == 0)\r
doDefault('View dropped.');\r
else\r
* Displays a screen where they can enter a new view\r
*/\r
function doCreate($msg = '') {\r
- global $data, $localData, $misc, $database, $view;\r
+ global $data, $localData, $misc;\r
global $PHP_SELF, $strName, $strDefinition;\r
- global $formView, $formDefinition;\r
\r
- if (!isset($formView)) $formView = '';\r
- if (!isset($formDefinition)) $formDefinition = '';\r
+ if (!isset($_POST['formView'])) $_POST['formView'] = '';\r
+ if (!isset($_POST['formDefinition'])) $_POST['formDefinition'] = '';\r
\r
- echo "<h2>", htmlspecialchars($database), ": Views: Create View</h2>\n";\r
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Views: Create View</h2>\n";\r
$misc->printMsg($msg);\r
\r
echo "<form action=\"$PHP_SELF\" method=post>\n";\r
echo "<table width=100%>\n";\r
echo "<tr><th class=data>{$strName}</th></tr>\n";\r
echo "<tr><td class=data1><input name=formView size={$data->_maxNameLen} maxlength={$data->_maxNameLen} value=\"", \r
- htmlspecialchars($formView), "\"></td></tr>\n";\r
+ htmlspecialchars($_POST['formView']), "\"></td></tr>\n";\r
echo "<tr><th class=data>{$strDefinition}</th></tr>\n";\r
echo "<tr><td class=data1><textarea style=\"width:100%;\" rows=20 cols=50 name=formDefinition wrap=virtual>", \r
- htmlspecialchars($formDefinition), "</textarea></td></tr>\n";\r
+ htmlspecialchars($_POST['formDefinition']), "</textarea></td></tr>\n";\r
echo "</table>\n";\r
echo "<input type=hidden name=action value=save_create>\n";\r
- echo "<input type=hidden name=database value=\"", htmlspecialchars($database), "\">\n";\r
+ echo "<input type=hidden name=database value=\"", htmlspecialchars($_REQUEST['database']), "\">\n";\r
echo "<input type=submit value=Save> <input type=reset>\n";\r
echo "</form>\n";\r
\r
- echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($database), "\">Show All Views</a></p>\n";\r
+ echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($_REQUEST['database']), "\">Show All Views</a></p>\n";\r
}\r
\r
/**\r
* Actually creates the new view in the database\r
*/\r
function doSaveCreate() {\r
- global $localData, $formView, $formDefinition;\r
+ global $localData, $strViewNeedsName, $strViewNeedsDef;\r
\r
- $status = $localData->createView($formView, $formDefinition);\r
- if ($status == 0)\r
- doDefault('View created.');\r
- else\r
- doCreate('View creation failed.');\r
+ // Check that they've given a name and a definition\r
+ if ($_POST['formView'] == '') doCreate($strViewNeedsName);\r
+ elseif ($_POST['formDefinition'] == '') doCreate($strViewNeedsDef);\r
+ else { \r
+ $status = $localData->createView($_POST['formView'], $_POST['formDefinition']);\r
+ if ($status == 0)\r
+ doDefault('View created.');\r
+ else\r
+ doCreate('View creation failed.');\r
+ }\r
} \r
\r
/**\r
global $data, $localData, $misc, $database, $view;\r
global $PHP_SELF, $strView, $strOwner, $strActions, $strNoViews;\r
\r
- echo "<h2>", htmlspecialchars($database), ": Views</h2>\n";\r
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Views</h2>\n";\r
$misc->printMsg($msg);\r
\r
$views = &$localData->getViews();\r
echo "<tr><td class=data{$id}>", htmlspecialchars($views->f[$data->vwFields['vwname']]), "</td>\n";\r
echo "<td class=data{$id}>", htmlspecialchars($views->f[$data->vwFields['vwowner']]), "</td>\n";\r
echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=browse&offset=0&limit=30&database=", \r
- htmlspecialchars($database), "&table=", urlencode($views->f[$data->vwFields['vwname']]), "\">Browse</a></td>\n";\r
+ htmlspecialchars($_REQUEST['database']), "&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">Browse</a></td>\n";\r
echo "<td class=opbutton{$id}>Select</td>\n";\r
echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=properties&database=", \r
- htmlspecialchars($database), "&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">Properties</a></td>\n";\r
+ htmlspecialchars($_REQUEST['database']), "&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">Properties</a></td>\n";\r
echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&database=", \r
- htmlspecialchars($database), "&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">Drop</a></td>\n";\r
+ htmlspecialchars($_REQUEST['database']), "&view=", urlencode($views->f[$data->vwFields['vwname']]), "\">Drop</a></td>\n";\r
echo "</tr>\n";\r
$views->moveNext();\r
$i++;\r
echo "<p>{$strNoViews}</p>\n";\r
}\r
\r
- echo "<p><a class=navlink href=\"$PHP_SELF?action=create&database=", urlencode($database), "\">Create View</a></p>\n";\r
+ echo "<p><a class=navlink href=\"$PHP_SELF?action=create&database=", urlencode($_REQUEST['database']), "\">Create View</a></p>\n";\r
\r
}\r
\r
doCreate();\r
break;\r
case 'drop':\r
- if ($choice == 'Yes') doDrop(false);\r
+ if ($_POST['choice'] == 'Yes') doDrop(false);\r
else doDefault();\r
break;\r
case 'confirm_drop':\r