[Aimmath-commit] moodle/mod/math_assignment saveconfig.php,1.3,1.4
Brought to you by:
gustav_delius,
npstrick
|
From: <ma...@us...> - 2003-09-26 11:27:44
|
Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv22497/mod/math_assignment
Modified Files:
saveconfig.php
Log Message:
Optimised the saving of course settings.
Index: saveconfig.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/saveconfig.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** saveconfig.php 23 Sep 2003 17:53:10 -0000 1.3
--- saveconfig.php 26 Sep 2003 11:27:40 -0000 1.4
***************
*** 31,49 ****
// 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) {
! if ($subject->server) {
! $subject->course = $course;
! if (!insert_record("math_assignment_subject", $subject, false))
! $result = false;
! }
}
if (!$result) {
--- 31,58 ----
// save course specific options
$result = true;
! switch(strtolower($CFG->dbtype)) {
! case 'mysql':
! foreach ($subjects as $course => $subject) {
! if ($subject->server) {
! $subject->course = $course;
! if (!$db->Execute("REPLACE `{$CFG->prefix}math_assignment_subject` SET `course` = '$subject->course', `name` = '$subject->name', `server` = '$subject->server', `password` = '$subject->password'"))
! $result = false;
! }
! else
! delete_records("math_assignment_subject", "course", $subject->course);
! }
! break;
! default:
! foreach ($subjects as $course => $subject) {
! if ($subject->server) {
! $subject->course = $course;
! if (!insert_record("math_assignment_subject", $subject, false)) {
! if (!update_record("math_assignment_subject", $subject, false))
! $result = false;
! }
! }
! }
! break;
}
if (!$result) {
|