diff --git a/backup/backuplib.php b/backup/backuplib.php index ba6ce1bbf8a..aa80ff6f483 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -530,6 +530,7 @@ fwrite ($bf,full_tag("ADDED",6,false,$course_module[$tok]->added)); fwrite ($bf,full_tag("DELETED",6,false,$course_module[$tok]->deleted)); fwrite ($bf,full_tag("SCORE",6,false,$course_module[$tok]->score)); + fwrite ($bf,full_tag("INDENT",6,false,$course_module[$tok]->indent)); fwrite ($bf,full_tag("VISIBLE",6,false,$course_module[$tok]->visible)); fwrite ($bf,end_tag("MOD",5,true)); } diff --git a/backup/restorelib.php b/backup/restorelib.php index 1d20d2b481f..bcd6c973ac8 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -394,6 +394,7 @@ $course_module->added = $mod->added; $course_module->deleted = $mod->deleted; $course_module->score = $mod->score; + $course_module->indent = $mod->indent; $course_module->visible = $mod->visible; $course_module->instance = null; //NOTE: The instance (new) is calculated and updated in db in the @@ -1320,6 +1321,8 @@ $this->info->tempmod->deleted; $this->info->tempsection->mods[$this->info->tempmod->id]->score = $this->info->tempmod->score; + $this->info->tempsection->mods[$this->info->tempmod->id]->indent = + $this->info->tempmod->indent; $this->info->tempsection->mods[$this->info->tempmod->id]->visible = $this->info->tempmod->visible; unset($this->info->tempmod); @@ -1345,6 +1348,9 @@ case "SCORE": $this->info->tempmod->score = $this->getContents(); break; + case "INDENT": + $this->info->tempmod->indent = $this->getContents(); + break; case "VISIBLE": $this->info->tempmod->visible = $this->getContents(); break; diff --git a/course/lib.php b/course/lib.php index d476ace0614..3af0aa7bdf6 100644 --- a/course/lib.php +++ b/course/lib.php @@ -637,8 +637,18 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false, $extra = ""; } + if ($mod->indent) { + print_spacer(12, 20 * $mod->indent, false); + } + if ($mod->modname == "label") { + if (!$mod->visible) { + echo ""; + } echo format_text($extra, FORMAT_HTML); + if (!$mod->visible) { + echo ""; + } } else { // Normal activity $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; @@ -650,7 +660,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false, echo ""; if ($isediting) { echo ""; - echo make_editing_buttons($mod->id, $absolute, $mod->visible); + echo make_editing_buttons($mod->id, $absolute, $mod->visible, true, $mod->indent); echo " "; } echo ""; @@ -1508,7 +1518,7 @@ function move_module($cm, $move) { } } -function make_editing_buttons($moduleid, $absolute=false, $visible=true, $moveselect=true) { +function make_editing_buttons($moduleid, $absolute=false, $visible=true, $moveselect=true, $indent=-1) { global $CFG, $THEME; static $str = ''; @@ -1517,6 +1527,8 @@ function make_editing_buttons($moduleid, $absolute=false, $visible=true, $movese $str->move = get_string("move"); $str->moveup = get_string("moveup"); $str->movedown = get_string("movedown"); + $str->moveright = get_string("moveright"); + $str->moveleft = get_string("moveleft"); $str->update = get_string("update"); $str->hide = get_string("hide"); $str->show = get_string("show"); @@ -1552,7 +1564,17 @@ function make_editing_buttons($moduleid, $absolute=false, $visible=true, $movese " src=\"$pixpath/t/down.gif\" height=11 width=11 border=0> "; } - return "delete\" href=\"$path/mod.php?delete=$moduleid\"> 0) { + $leftright .= "moveleft\" href=\"$path/mod.php?id=$moduleid&indent=-1\"> "; + } + if ($indent >= 0) { + $leftright .= "moveright\" href=\"$path/mod.php?id=$moduleid&indent=1\"> "; + } + + return "$leftrightdelete\" href=\"$path/mod.php?delete=$moduleid\"> $move". "update\" href=\"$path/mod.php?update=$moduleid\"> $hideshow"; diff --git a/course/mod.php b/course/mod.php index 73d4a331d55..86a0da95288 100644 --- a/course/mod.php +++ b/course/mod.php @@ -103,7 +103,7 @@ } - if (isset($move)) { + if (isset($_GET['move'])) { require_variable($id); @@ -115,7 +115,7 @@ error("You can't modify this course!"); } - move_module($cm, $move); + move_module($cm, $_GET['move']); rebuild_course_cache($cm->course); @@ -127,20 +127,20 @@ } exit; - } else if (isset($movetosection) or isset($moveto)) { + } else if (isset($_GET['movetosection']) or isset($_GET['moveto'])) { if (! $cm = get_record("course_modules", "id", $USER->activitycopy)) { error("The copied course module doesn't exist!"); } - if (isset($movetosection)) { - if (! $section = get_record("course_sections", "id", $movetosection)) { + if (isset($_GET['movetosection'])) { + if (! $section = get_record("course_sections", "id", $_GET['movetosection'])) { error("This section doesn't exist"); } $beforecm = NULL; } else { // normal moveto - if (! $beforecm = get_record("course_modules", "id", $moveto)) { + if (! $beforecm = get_record("course_modules", "id", $_GET['moveto'])) { error("The destination course module doesn't exist"); } if (! $section = get_record("course_sections", "id", $beforecm->section)) { @@ -171,9 +171,35 @@ redirect("view.php?id=$section->course"); } - } else if (isset($hide)) { + } else if (isset($_GET['indent'])) { - if (! $cm = get_record("course_modules", "id", $hide)) { + require_variable($id); + + if (! $cm = get_record("course_modules", "id", $id)) { + error("This course module doesn't exist"); + } + + $cm->indent += $_GET['indent']; + + if ($cm->indent < 0) { + $cm->indent = 0; + } + + if (!set_field("course_modules", "indent", $cm->indent, "id", $cm->id)) { + error("Could not update the indent level on that course module"); + } + + $site = get_site(); + if ($site->id == $cm->course) { + redirect($CFG->wwwroot); + } else { + redirect("view.php?id=$cm->course"); + } + exit; + + } else if (isset($_GET['hide'])) { + + if (! $cm = get_record("course_modules", "id", $_GET['hide'])) { error("This course module doesn't exist"); } @@ -193,9 +219,9 @@ } exit; - } else if (isset($show)) { + } else if (isset($_GET['show'])) { - if (! $cm = get_record("course_modules", "id", $show)) { + if (! $cm = get_record("course_modules", "id", $_GET['show'])) { error("This course module doesn't exist"); } @@ -225,9 +251,9 @@ } exit; - } else if (isset($copy)) { // value = course module + } else if (isset($_GET['copy'])) { // value = course module - if (! $cm = get_record("course_modules", "id", $copy)) { + if (! $cm = get_record("course_modules", "id", $_GET['copy'])) { error("This course module doesn't exist"); } @@ -253,7 +279,7 @@ redirect("view.php?id=$cm->course"); - } else if (isset($cancelcopy)) { // value = course module + } else if (isset($_GET['cancelcopy'])) { // value = course module $courseid = $USER->activitycopycourse; @@ -263,9 +289,9 @@ redirect("view.php?id=$courseid"); - } else if (isset($delete)) { // value = course module + } else if (isset($_GET['delete'])) { // value = course module - if (! $cm = get_record("course_modules", "id", $delete)) { + if (! $cm = get_record("course_modules", "id", $_GET['delete'])) { error("This course module doesn't exist"); } @@ -293,7 +319,7 @@ "$CFG->wwwroot/course/view.php?id=$course->id"); } - $fullmodulename = strtolower(get_string("modulename", $module->name)); + $fullmodulename = get_string("modulename", $module->name); $form->coursemodule = $cm->id; $form->section = $cm->section; @@ -319,9 +345,9 @@ exit; - } else if (isset($update)) { // value = course module + } else if (isset($_GET['update'])) { // value = course module - if (! $cm = get_record("course_modules", "id", $update)) { + if (! $cm = get_record("course_modules", "id", $_GET['update'])) { error("This course module doesn't exist"); } @@ -369,9 +395,9 @@ } - } else if (isset($add)) { + } else if (isset($_GET['add'])) { - if (!$add) { + if (empty($_GET['add'])) { redirect($_SERVER["HTTP_REFERER"]); die; } @@ -383,7 +409,7 @@ error("This course doesn't exist"); } - if (! $module = get_record("modules", "name", $add)) { + if (! $module = get_record("modules", "name", $_GET['add'])) { error("This module type doesn't exist"); } diff --git a/lib/db/mysql.php b/lib/db/mysql.php index 71a209820c0..d5b6ef09180 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -501,6 +501,10 @@ function main_upgrade($oldversion=0) { execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'user report', 'user', 'CONCAT(firstname,\" \",lastname)') "); } + if ($oldversion < 2003091400) { + table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score"); + } + return $result; } diff --git a/lib/db/mysql.sql b/lib/db/mysql.sql index dd3e025eb70..9b8b2a9b3b4 100644 --- a/lib/db/mysql.sql +++ b/lib/db/mysql.sql @@ -104,6 +104,7 @@ CREATE TABLE `prefix_course_modules` ( `added` int(10) unsigned NOT NULL default '0', `deleted` tinyint(1) unsigned NOT NULL default '0', `score` tinyint(4) NOT NULL default '0', + `indent` int(5) unsigned NOT NULL default '0', `visible` tinyint(1) NOT NULL default '1', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php index e4ce8369257..89e6a89a030 100644 --- a/lib/db/postgres7.php +++ b/lib/db/postgres7.php @@ -250,6 +250,11 @@ function main_upgrade($oldversion=0) { table_column("course", "", "showrecent", "integer", "10", "unsigned", "1", "", "numsections"); } + if ($oldversion < 2003091400) { + table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score"); + } + + return $result; } ?> diff --git a/lib/db/postgres7.sql b/lib/db/postgres7.sql index dee9e0793ad..5e4fe2d3217 100644 --- a/lib/db/postgres7.sql +++ b/lib/db/postgres7.sql @@ -62,6 +62,7 @@ CREATE TABLE prefix_course_modules ( added integer NOT NULL default '0', deleted integer NOT NULL default '0', score integer NOT NULL default '0', + indent integer NOT NULL default '0', visible integer NOT NULL default '1' ); diff --git a/version.php b/version.php index d5c1f71c142..3049095b820 100644 --- a/version.php +++ b/version.php @@ -5,7 +5,7 @@ // database to determine whether upgrades should // be performed (see lib/db/*.php) -$version = 2003091111; // The current version is a date (YYYYMMDDXX) +$version = 2003091400; // The current version is a date (YYYYMMDDXX) $release = "1.2 development"; // User-friendly version number