diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000000000..6a8d44476c790 --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +All the documention is in the "doc" subdirectory. :-) diff --git a/README b/README new file mode 100644 index 0000000000000..6a8d44476c790 --- /dev/null +++ b/README @@ -0,0 +1 @@ +All the documention is in the "doc" subdirectory. :-) diff --git a/admin/cron.php b/admin/cron.php new file mode 100644 index 0000000000000..7b2851cfc5fc3 --- /dev/null +++ b/admin/cron.php @@ -0,0 +1,48 @@ +\n"; + + if (!isset($p)) { + $p = $GLOBALS[argv][1]; + } + + if ($p <> $PASSWORD) { + add_to_log("Error: bad cron password!"); + echo "Error: bad password.\n"; + die; + } + + $timenow = time(); + + if ($mods = get_records_sql("SELECT * FROM modules WHERE cron > 0 AND (($timenow - lastcron) > cron)")) { + foreach ($mods as $mod) { + $cronfile = "$CFG->dirroot/mod/$mod->name/cron.php"; + if (file_exists($cronfile)) { + include($cronfile); + if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) { + echo "Error: could not update timestamp for $mod->fullname\n"; + } + } + } + } + echo "Cron script completed correctly\n"; + +?> diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000000000..7a9bb9d64329e --- /dev/null +++ b/admin/index.php @@ -0,0 +1,97 @@ +wwwroot == "http://example.com") { + error("Moodle has not been configured yet. You need to to edit config.php first."); + } + + // Check databases and modules and install as needed. + if (! $db->Metatables() ) { + print_header("Setting up database", "Setting up database", "Setting up databases for the first time", ""); + if (modify_database("$CFG->dirroot/admin/moodle-core.sql")) { + notify("Main databases set up successfully"); + } else { + error("Error: Main databases NOT set up successfully"); + } + print_heading("Continue"); + die; + } + + // Find and check all modules and load them up. + $dir = opendir("$CFG->dirroot/mod"); + while ($mod = readdir($dir)) { + if ($mod == "." || $mod == "..") { + continue; + } + + $fullmod = "$CFG->dirroot/mod/$mod"; + if (filetype($fullmod) != "dir") { + continue; + } + + unset($module); + + include_once("$CFG->dirroot/mod/$mod/module.php"); # defines $module + + if (!isset($module)) { + continue; + } + + $module->name = $mod; // The name MUST match the directory + + if ($currmodule = get_record("modules", "name", $module->name)) { + if ($currmodule->version == $module->version) { + // do nothing + } else if ($currmodule->version < $module->version) { + notify("$module->name module needs upgrading"); // XXX do the upgrade here + } else { + error("Version mismatch: $module->name can't downgrade $currmodule->version -> $module->version !"); + } + + } else { // module not installed yet, so install it + if (modify_database("$fullmod/install.sql")) { + if ($module->id = insert_record("modules", $module)) { + notify("$module->name tables have been set up correctly"); + } else { + error("$module->name module could not be added to the module list!"); + } + } else { + error("$module->name tables could NOT be set up successfully!"); + } + } + } + + // Set up the overall site name etc. + if (! $course = get_record("course", "category", 0)) { + redirect("site.php"); + } + + if (!isadmin()) { + if (record_exists_sql("SELECT * FROM user_admins")) { + require_login(); + } else { + redirect("user.php"); + } + } + + + // At this point, the databases exist, and the user is an admin + + print_header("$course->fullname: Administration Page","$course->fullname: Administration Page", "Admin"); + + echo "
".date("l, j F Y, g:i A T", $log->time); + echo " | email\">$log->firstname $log->lastname"; + echo " | $log->ip"; + echo " | $log->url"; + echo " | $log->message"; + echo " |
+ +diff --git a/course/editweek.php b/course/editweek.php new file mode 100644 index 0000000000000..7684ef1f3f7c0 --- /dev/null +++ b/course/editweek.php @@ -0,0 +1,50 @@ +course)) { + error("Could not find the course!"); + } + + require_login($course->id); + + add_to_log("Edit week", $course->id); + + if (!isteacher($course->id)) { + error("Only teachers can edit this!"); + } + + +/// If data submitted, then process and store. + + if (match_referer() && isset($HTTP_POST_VARS)) { + + $timenow = time(); + + if (! set_field("course_weeks", "summary", $summary, "id", $week->id)) { + error("Could not update the summary!"); + } + + redirect("view.php?id=$course->id"); + exit; + } + +/// Otherwise fill and print the form. + + if (! $form ) { + $form = $week; + } + + print_header("Edit week $week->week", "Edit week $week->week", "", "form.summary"); + + include("editweek.html"); + + print_footer($course); + +?> diff --git a/course/email.html b/course/email.html new file mode 100644 index 0000000000000..919acff06951f --- /dev/null +++ b/course/email.html @@ -0,0 +1,32 @@ + diff --git a/course/email.php b/course/email.php new file mode 100644 index 0000000000000..c8f220c071cb0 --- /dev/null +++ b/course/email.php @@ -0,0 +1,48 @@ +id); + + if (!isteacher($course->id)) { + error("Only teachers can send mail this way!"); + } + + +/// If data submitted, then process and store. + + if (match_referer() && isset($HTTP_POST_VARS)) { + + $link = "$CFG->wwwroot/course/view.php?id=$course->id"; + + + if (! email_to_course($USER, $course, true, $subject, $message, "$link")) { + error("An error occurred while trying to send mail!"); + } + + add_to_log("Sent mail to everyone", $course->id); + + redirect("view.php?id=$course->id", "Email sent", 1); + exit; + } + + + $form->id = $course->id; + + print_header("$course->shortname: Mail", "$course->fullname", + "wwwroot/course/view.php?id=$course->id\">$course->shortname -> Send mail"); + + print_heading("Send an email to all participants"); + + include("email.html"); + + print_footer($course); + + +?> diff --git a/course/index.php b/course/index.php new file mode 100644 index 0000000000000..21a667956fc85 --- /dev/null +++ b/course/index.php @@ -0,0 +1,25 @@ + $course) { + print_course($course); + echo "
Displaying ".count($logs)." records
"; + echo "".date("l", $log->time)." | "; + echo "".date("j M Y, h:i A", $log->time)." | "; + echo "$log->firstname $log->lastname | "; + echo ""; + $log->message = addslashes($log->message); + link_to_popup_window("$log->url","popup","$log->message", 400, 600); + echo " | "; + echo "
";
+ echo "";
+ if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t
+ WHERE u.id = t.user AND t.course = '$course->id'
+ ORDER BY t.authority DESC")) {
+
+ echo " \n";
+ foreach ($teachers as $teacher) {
+ echo "$course->teacher: id&course=$site->id\">$teacher->firstname $teacher->lastname | ";
+ echo " ".text_to_html($course->summary)." "; + echo " |
+ This course requires a "course entry key" - a one-time |
+
|
+
+
+ |
";
+ echo "
"; + if ($USER->teacher[$course->id]) { + if ($USER->editing) { + echo "id&edit=off\">Turn editing off"; + } else { + echo "id&edit=on\">Turn editing on"; + } + } + //if ($USER->help) { + //echo " id&help=off\">Turn help off"; + //} else { + //echo " id&help=on\">Turn help on"; + //} + echo " |
cellheading\">";
+ echo "Forums"; + + echo "
| cellheading\">";
+ echo "Readings"; + + echo "
| cellheading\">";
+ echo "Participants"; + + echo "
|
"; + include($userfile); + echo ""; + echo "
$heading | |
"; + if ($icons[$key]) { + echo $icons[$key]; + } else { + echo ""; + } + echo " | \n";
+ echo " $string "; + echo " |
$footer |
";
+ echo " "; + + // Layout the left column + + print_side_block("id\">What's New!", + "", "...since your last login"); + + // Then, print all the news items. + + include("../mod/discuss/lib.php"); + if ($news = get_course_news_forum($course->id)) { + print_simple_box_start("CENTER", "100%", "#FFFFFF", 5); + echo " Latest News | ";
+
+ // Now all the weekly modules
+
+
+ $timenow = time();
+ $weekdate = $course->startdate; // this should be 0:00 Monday of that week
+ $week = 1;
+ $weekofseconds = 604800;
+
+ echo "
|
$REQUEST_URI", "center", "", "$THEME->cellheading"); + +?> + +
If you have time, please let us know what you were trying + to do when the error occurred: +