From 94b39ff32f6cc9566de651f35994d877634d7317 Mon Sep 17 00:00:00 2001 From: M Date: Sun, 6 Dec 2015 02:16:46 -0500 Subject: * Implemented the "save" action for MVC sysconf --- app/controller/sysconf.control.php | 18 +++++++++++++++- app/model/sysconf.mod.php | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controller/sysconf.control.php b/app/controller/sysconf.control.php index f96c97e..a7db1e8 100644 --- a/app/controller/sysconf.control.php +++ b/app/controller/sysconf.control.php @@ -14,7 +14,17 @@ class Sysconf extends Controller function handle($argv) { $mod = new SysconfModel(); - $this->action_default($mod); + + switch ($_REQUEST['input']['action']) + { + case "save": + $this->action_save($mod); + break; + + default: + $this->action_default($mod); + break; + } } function action_default($mod) @@ -22,6 +32,12 @@ class Sysconf extends Controller $mod->deflt(); include "view/sysconf/default.view.php"; } + + function action_save($mod) + { + $mod->save($_REQUEST['input']); + $this->action_default($mod); + } } ?> diff --git a/app/model/sysconf.mod.php b/app/model/sysconf.mod.php index 754d1a6..d86f589 100644 --- a/app/model/sysconf.mod.php +++ b/app/model/sysconf.mod.php @@ -1,15 +1,58 @@ field_text("dbAddress"); + $form->field_text("dbName"); + $form->field_text("dbUser"); + $form->field_text("dbPass", null, false); + $form->field_enum("settSSL", array("force", "neither", "forbid")); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $f = fopen($this->CONF_FILE, "w"); + + if (!$f) + { + $this->logError("Can not create configuration file"); + return; + } + + fwrite($f, "dbAddress . "';\n"); + fwrite($f, "\$_SCROTT['dbName'] = '" . $form->dbName . "';\n"); + fwrite($f, "\$_SCROTT['dbUser'] = '" . $form->dbUser . "';\n"); + fwrite($f, "\$_SCROTT['dbPass'] = '" . $form->dbPass . "';\n"); + fwrite($f, "\$_SCROTT['settSSL'] = '" . $form->settSSL . "';\n"); + fwrite($f, "?>\n"); + + fclose($f); + $this->redirectTo($this->ar()); + } } ?> -- cgit v1.2.3