[Aimmath-commit] moodle/mod/math_assignment saveconfig.php,NONE,1.1
Brought to you by:
gustav_delius,
npstrick
|
From: <ma...@us...> - 2003-09-19 00:01:13
|
Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv31247/mod/math_assignment
Added Files:
saveconfig.php
Log Message:
Changed to one aim subject per course
--- NEW FILE: saveconfig.php ---
<?PHP // $Id: saveconfig.php,v 1.1 2003/09/19 00:01:10 madalex Exp $
/* This page saves the options from config.html
We can't just use the standard action provided by moodle because of the
course specific options which relate to the aim subjects
*/
require_once("../../config.php");
require_once("lib.php");
if (! $site = get_site()) {
redirect("$CFG->wwwroot/$CFG->admin/index.php");
}
if (!isadmin()) {
error(get_string("adminonly", "math_assignment"));
}
// process variables passed
$subjects = array();
foreach ($_POST as $name => $value) {
if (preg_match("/server([0-9]*)/", $name, $matches))
$subjects[$matches[1]]->server = $value;
else if (preg_match("/name([0-9]*)/", $name, $matches))
$subjects[$matches[1]]->name = $value;
else if (preg_match("/password([0-9]*)/", $name, $matches))
$subjects[$matches[1]]->password = $value;
else
set_config($name, $value);
}
// save course specific options
/* Note that ALL courses appear on the form so we assume that $subjects is comlete. Hence we
simply truncate the table and write it out again to save testing for existence before doing an insert
or an update as required since I am lazy :-) */
if (!$db->Execute("TRUNCATE TABLE `{$CFG->prefix}math_assignment_subject`")) {
error(get_string("failed", "math_assignment"), "$CFG->wwwroot/$CFG->admin/module.php?module=math_assignment");
}
$result = true;
foreach ($subjects as $course => $subject) {
$subject->course = $course;
if (!insert_record("math_assignment_subject", $subject))
$return = false;
}
if (!$result) {
error(get_string("failed", "math_assignment"), "$CFG->wwwroot/$CFG->admin/module.php?module=math_assignment");
}
redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
?>
|