From aecbea304ee2b38bac47506fff243817deb1eca2 Mon Sep 17 00:00:00 2001 From: chriskl Date: Wed, 30 Jul 2003 03:36:37 +0000 Subject: [PATCH] forgot domain file --- domains.php | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 domains.php diff --git a/domains.php b/domains.php new file mode 100644 index 00000000..e34c47b2 --- /dev/null +++ b/domains.php @@ -0,0 +1,282 @@ +setDomain($_POST['domain'], $_POST['formDefinition']); + if ($status == 0) + doProperties($lang['strdomainupdated']); + else + doEdit($lang['strdomainupdatedbad']); + } + + /** + * Function to allow editing of a domain + */ + function doEdit($msg = '') { + global $data, $localData, $misc; + global $PHP_SELF, $lang; + + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: ", $misc->printVal($_REQUEST['domain']), ": {$lang['stredit']}

\n"; + $misc->printMsg($msg); + + $domaindata = &$localData->getDomain($_REQUEST['domain']); + + if ($domaindata->recordCount() > 0) { + + if (!isset($_POST['formDefinition'])) $_POST['formDefinition'] = $domaindata->f[$data->vwFields['vwdef']]; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
{$lang['strname']}
", $misc->printVal($domaindata->f[$data->vwFields['vwname']]), "
{$lang['strdefinition']}
\n"; + echo "\n"; + echo "\n"; + echo $misc->form; + echo "\n"; + echo "\n"; + echo "
\n"; + } + else echo "

{$lang['strnodata']}

\n"; + + echo "

href}\">{$lang['strshowalldomains']} |\n"; + echo "href}&domain=", + urlencode($_REQUEST['domain']), "\">{$lang['strproperties']}

\n"; + } + + /** + * Show read only properties for a domain + */ + function doProperties($msg = '') { + global $data, $localData, $misc; + global $PHP_SELF, $lang; + + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: ", $misc->printVal($_REQUEST['domain']), ": {$lang['strproperties']}

\n"; + $misc->printMsg($msg); + + $domaindata = &$localData->getDomain($_REQUEST['domain']); + + if ($domaindata->recordCount() > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
{$lang['strname']}
", $misc->printVal($domaindata->f[$data->vwFields['vwname']]), "
{$lang['strdefinition']}
", $misc->printVal($domaindata->f[$data->vwFields['vwdef']]), "
\n"; + } + else echo "

{$lang['strnodata']}

\n"; + + echo "

href}\">{$lang['strshowalldomains']} |\n"; + echo "href}&domain=", + urlencode($_REQUEST['domain']), "\">{$lang['stredit']}

\n"; + } + + /** + * Show confirmation of drop and perform actual drop + */ + function doDrop($confirm) { + global $localData, $misc; + global $PHP_SELF, $lang; + + if ($confirm) { + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: ", $misc->printVal($_REQUEST['domain']), ": {$lang['strdrop']}

\n"; + + echo "

", sprintf($lang['strconfdropdomain'], $misc->printVal($_REQUEST['domain'])), "

\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo $misc->form; + // Show cascade drop option if supportd + if ($localData->hasDropBehavior()) { + echo "

{$lang['strcascade']}

\n"; + } + echo " \n"; + echo "
\n"; + } + else { + $status = $localData->dropDomain($_POST['domain'], isset($_POST['cascade'])); + if ($status == 0) + doDefault($lang['strdomaindropped']); + else + doDefault($lang['strdomaindroppedbad']); + } + + } + + /** + * Displays a screen where they can enter a new domain + */ + function doCreate($msg = '') { + global $data, $localData, $misc; + global $PHP_SELF, $lang; + + if (!isset($_POST['domname'])) $_POST['domname'] = ''; + if (!isset($_POST['domtype'])) $_POST['domtype'] = ''; + if (!isset($_POST['domdefault'])) $_POST['domdefault'] = ''; + if (!isset($_POST['domcheck'])) $_POST['domcheck'] = ''; + + $types = &$localData->getTypes(true); + + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: {$lang['strcreatedomain']}

\n"; + $misc->printMsg($msg); + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($data->hasDomainConstraints()) { + echo "\n"; + echo "\n"; + } + echo "
{$lang['strname']}_maxNameLen}\" value=\"", + htmlspecialchars($_POST['domname']), "\" />
{$lang['strtype']}\n"; + // Output return type list + echo "\n"; + echo "
{$lang['strnotnull']}
{$lang['strdefault']}_maxNameLen}\" value=\"", + htmlspecialchars($_POST['domdefault']), "\" />
{$lang['strconstraints']}CHECK (_maxNameLen}\" value=\"", + htmlspecialchars($_POST['domcheck']), "\" />)
\n"; + echo "\n"; + echo $misc->form; + echo "

\n"; + echo "

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

href}\">{$lang['strshowalldomains']}

\n"; + } + + /** + * Actually creates the new domain in the database + */ + function doSaveCreate() { + global $localData, $lang; + + if (!isset($_POST['domcheck'])) $_POST['domcheck'] = ''; + + // Check that they've given a name and a definition + if ($_POST['domname'] == '') doCreate($lang['strdomainneedsname']); + else { + $status = $localData->createDomain($_POST['domname'], $_POST['domtype'], + isset($_POST['domnotnull']), $_POST['domdefault'], $_POST['domcheck']); + if ($status == 0) + doDefault($lang['strdomaincreated']); + else + doCreate($lang['strdomaincreatedbad']); + } + } + + /** + * Show default list of domains in the database + */ + function doDefault($msg = '') { + global $data, $localData, $misc; + global $PHP_SELF, $lang; + + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}

\n"; + $misc->printMsg($msg); + + $domains = &$localData->getDomains(); + + if ($domains->recordCount() > 0) { + echo "\n"; + echo ""; + echo ""; + echo "\n"; + $i = 0; + while (!$domains->EOF) { + $domains->f['domnotnull'] = $data->phpBool($domains->f['domnotnull']); + $id = (($i % 2) == 0 ? '1' : '2'); + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $domains->moveNext(); + $i++; + } + echo "
{$lang['strdomain']}{$lang['strnotnull']}{$lang['strdefault']}{$lang['strowner']}{$lang['stractions']}
", $misc->printVal($domains->f['domname']), "", ($domains->f['domnotnull'] ? 'NOT NULL' : ''), "", $misc->printVal($domains->f['domdef']), "", $misc->printVal($domains->f['domowner']), "href}&domain=", urlencode($domains->f['domname']), "\">{$lang['strproperties']}href}&domain=", urlencode($domains->f['domname']), "\">{$lang['strdrop']}
\n"; + } + else { + echo "

{$lang['strnodomains']}

\n"; + } + + echo "

href}\">{$lang['strcreatedomain']}

\n"; + + } + + $misc->printHeader($lang['strdomains']); + $misc->printBody(); + + switch ($action) { + case 'selectrows': + if (!isset($_POST['cancel'])) doSelectRows(false); + else doDefault(); + break; + case 'confselectrows': + doSelectRows(true); + break; + case 'save_create': + doSaveCreate(); + break; + case 'create': + doCreate(); + break; + case 'drop': + if (isset($_POST['yes'])) doDrop(false); + else doDefault(); + break; + case 'confirm_drop': + doDrop(true); + break; + case 'save_edit': + doSaveEdit(); + break; + case 'edit': + doEdit(); + break; + case 'properties': + doProperties(); + break; + default: + doDefault(); + break; + } + + $misc->printFooter(); + +?> -- 2.39.5