@@ 313-366 (lines=54) @@ | ||
310 | /** |
|
311 | * Confirm and then actually add a CHECK constraint |
|
312 | */ |
|
313 | public function addCheck($confirm, $msg = '') |
|
314 | { |
|
315 | $conf = $this->conf; |
|
316 | $misc = $this->misc; |
|
317 | $lang = $this->lang; |
|
318 | $data = $misc->getDatabaseAccessor(); |
|
319 | ||
320 | if (!isset($_POST['name'])) { |
|
321 | $_POST['name'] = ''; |
|
322 | } |
|
323 | ||
324 | if (!isset($_POST['definition'])) { |
|
325 | $_POST['definition'] = ''; |
|
326 | } |
|
327 | ||
328 | if ($confirm) { |
|
329 | $this->printTrail('domain'); |
|
330 | $this->printTitle($lang['straddcheck'], 'pg.constraint.check'); |
|
331 | $this->printMsg($msg); |
|
332 | ||
333 | echo '<form action="' . SUBFOLDER . "/src/views/domains.php\" method=\"post\">\n"; |
|
334 | echo "<table>\n"; |
|
335 | echo "<tr><th class=\"data\">{$lang['strname']}</th>\n"; |
|
336 | echo "<th class=\"data required\">{$lang['strdefinition']}</th></tr>\n"; |
|
337 | ||
338 | echo "<tr><td class=\"data1\"><input name=\"name\" size=\"16\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
|
339 | htmlspecialchars($_POST['name']), "\" /></td>\n"; |
|
340 | ||
341 | echo '<td class="data1">(<input name="definition" size="32" value="', |
|
342 | htmlspecialchars($_POST['definition']), "\" />)</td></tr>\n"; |
|
343 | echo "</table>\n"; |
|
344 | ||
345 | echo "<p><input type=\"hidden\" name=\"action\" value=\"save_add_check\" />\n"; |
|
346 | echo '<input type="hidden" name="domain" value="', htmlspecialchars($_REQUEST['domain']), "\" />\n"; |
|
347 | echo $misc->form; |
|
348 | echo "<input type=\"submit\" name=\"add\" value=\"{$lang['stradd']}\" />\n"; |
|
349 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
|
350 | echo "</form>\n"; |
|
351 | } else { |
|
352 | if (trim($_POST['definition']) == '') { |
|
353 | $this->addCheck(true, $lang['strcheckneedsdefinition']); |
|
354 | } else { |
|
355 | $status = $data->addDomainCheckConstraint($_POST['domain'], |
|
356 | $_POST['definition'], $_POST['name']); |
|
357 | if ($status == 0) { |
|
358 | $this->doProperties($lang['strcheckadded']); |
|
359 | } else { |
|
360 | $this->addCheck(true, $lang['strcheckaddedbad']); |
|
361 | } |
|
362 | } |
|
363 | } |
|
364 | } |
|
365 | ||
366 | /** |
|
367 | * Show confirmation of drop constraint and perform actual drop |
|
368 | */ |
|
369 | public function doDropConstraint($confirm, $msg = '') |
@@ 619-672 (lines=54) @@ | ||
616 | /** |
|
617 | * Confirm and then actually add a CHECK constraint |
|
618 | */ |
|
619 | public function addCheck($confirm, $msg = '') |
|
620 | { |
|
621 | $conf = $this->conf; |
|
622 | $misc = $this->misc; |
|
623 | $lang = $this->lang; |
|
624 | $data = $misc->getDatabaseAccessor(); |
|
625 | ||
626 | if (!isset($_POST['name'])) { |
|
627 | $_POST['name'] = ''; |
|
628 | } |
|
629 | ||
630 | if (!isset($_POST['definition'])) { |
|
631 | $_POST['definition'] = ''; |
|
632 | } |
|
633 | ||
634 | if ($confirm) { |
|
635 | $this->printTrail('table'); |
|
636 | $this->printTitle($lang['straddcheck'], 'pg.constraint.check'); |
|
637 | $this->printMsg($msg); |
|
638 | ||
639 | echo '<form action="' . SUBFOLDER . "/src/views/constraints.php\" method=\"post\">\n"; |
|
640 | echo "<table>\n"; |
|
641 | echo "<tr><th class=\"data\">{$lang['strname']}</th>\n"; |
|
642 | echo "<th class=\"data required\">{$lang['strdefinition']}</th></tr>\n"; |
|
643 | ||
644 | echo "<tr><td class=\"data1\"><input name=\"name\" size=\"24\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
|
645 | htmlspecialchars($_POST['name']), "\" /></td>\n"; |
|
646 | ||
647 | echo '<td class="data1">(<input name="definition" size="64" value="', |
|
648 | htmlspecialchars($_POST['definition']), "\" />)</td></tr>\n"; |
|
649 | echo "</table>\n"; |
|
650 | ||
651 | echo "<input type=\"hidden\" name=\"action\" value=\"save_add_check\" />\n"; |
|
652 | echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n"; |
|
653 | echo $misc->form; |
|
654 | echo "<p><input type=\"submit\" name=\"ok\" value=\"{$lang['stradd']}\" />\n"; |
|
655 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
|
656 | echo "</form>\n"; |
|
657 | } else { |
|
658 | if (trim($_POST['definition']) == '') { |
|
659 | $this->addCheck(true, $lang['strcheckneedsdefinition']); |
|
660 | } else { |
|
661 | $status = $data->addCheckConstraint($_POST['table'], |
|
662 | $_POST['definition'], $_POST['name']); |
|
663 | if ($status == 0) { |
|
664 | $this->doDefault($lang['strcheckadded']); |
|
665 | } else { |
|
666 | $this->addCheck(true, $lang['strcheckaddedbad']); |
|
667 | } |
|
668 | } |
|
669 | } |
|
670 | } |
|
671 | ||
672 | /** |
|
673 | * Show confirmation of drop and perform actual drop |
|
674 | */ |
|
675 | public function doDrop($confirm) |