From 2c5c3e62a74e35d266e5c0db850393a292fc12f0 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 14 Sep 2003 12:30:09 +0000 Subject: [PATCH] New module: Label. This is a sort of "dummy" activity that allows HTML to be placed anywhere in the course sections ... --- mod/label/db/mysql.php | 12 ++++++ mod/label/db/mysql.sql | 7 ++++ mod/label/db/postgres7.php | 12 ++++++ mod/label/db/postgres7.sql | 6 +++ mod/label/icon.gif | Bin 0 -> 112 bytes mod/label/index.php | 10 +++++ mod/label/lib.php | 75 +++++++++++++++++++++++++++++++++++++ mod/label/mod.html | 56 +++++++++++++++++++++++++++ mod/label/version.php | 11 ++++++ mod/label/view.php | 38 +++++++++++++++++++ 10 files changed, 227 insertions(+) create mode 100644 mod/label/db/mysql.php create mode 100644 mod/label/db/mysql.sql create mode 100644 mod/label/db/postgres7.php create mode 100644 mod/label/db/postgres7.sql create mode 100755 mod/label/icon.gif create mode 100644 mod/label/index.php create mode 100644 mod/label/lib.php create mode 100644 mod/label/mod.html create mode 100644 mod/label/version.php create mode 100644 mod/label/view.php diff --git a/mod/label/db/mysql.php b/mod/label/db/mysql.php new file mode 100644 index 0000000000..dbcb913986 --- /dev/null +++ b/mod/label/db/mysql.php @@ -0,0 +1,12 @@ + diff --git a/mod/label/db/mysql.sql b/mod/label/db/mysql.sql new file mode 100644 index 0000000000..aa8beb630e --- /dev/null +++ b/mod/label/db/mysql.sql @@ -0,0 +1,7 @@ +CREATE TABLE `prefix_label` ( + `id` int(10) unsigned NOT NULL auto_increment, + `name` varchar(255) NOT NULL default '', + `content` text NOT NULL, + `timemodified` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`id`) +) COMMENT='Defines labels'; diff --git a/mod/label/db/postgres7.php b/mod/label/db/postgres7.php new file mode 100644 index 0000000000..dbcb913986 --- /dev/null +++ b/mod/label/db/postgres7.php @@ -0,0 +1,12 @@ + diff --git a/mod/label/db/postgres7.sql b/mod/label/db/postgres7.sql new file mode 100644 index 0000000000..2ec33ec578 --- /dev/null +++ b/mod/label/db/postgres7.sql @@ -0,0 +1,6 @@ +CREATE TABLE prefix_label ( + id SERIAL PRIMARY KEY, + name varchar(255) default NULL, + content text, + timemodified integer NOT NULL default '0' +); diff --git a/mod/label/icon.gif b/mod/label/icon.gif new file mode 100755 index 0000000000000000000000000000000000000000..2653d97a4a04684daa032b7fa6e92653e94ce76b GIT binary patch literal 112 zcmZ?wbhEHb6krfwSi}GXca4qHjMLJLXQmxEaNz&{|K;W7KvBh?EQ|~cEDSmzB_Op7 z%%&c@?))>@dSt|{&eHH=b&}fFU~pxYdLCUV LCv&W%IT@@0{Rk$C literal 0 HcmV?d00001 diff --git a/mod/label/index.php b/mod/label/index.php new file mode 100644 index 0000000000..0ee6428cc1 --- /dev/null +++ b/mod/label/index.php @@ -0,0 +1,10 @@ +wwwroot/course/view.php?id=$id"); + +?> diff --git a/mod/label/lib.php b/mod/label/lib.php new file mode 100644 index 0000000000..2dbf56fafe --- /dev/null +++ b/mod/label/lib.php @@ -0,0 +1,75 @@ +name = strip_tags($label->content); + if (strlen($label->name) > LABEL_MAX_NAME_LENGTH) { + $label->name = substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."..."; + } + $label->timemodified = time(); + + return insert_record("label", $label); +} + + +function label_update_instance($label) { +/// Given an object containing all the necessary data, +/// (defined by the form in mod.html) this function +/// will update an existing instance with new data. + + $label->name = strip_tags($label->content); + if (strlen($label->name) > LABEL_MAX_NAME_LENGTH) { + $label->name = substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."..."; + } + $label->timemodified = time(); + $label->id = $label->instance; + + return update_record("label", $label); +} + + +function label_delete_instance($id) { +/// Given an ID of an instance of this module, +/// this function will permanently delete the instance +/// and any data that depends on it. + + if (! $label = get_record("label", "id", "$id")) { + return false; + } + + $result = true; + + if (! delete_records("label", "id", "$label->id")) { + $result = false; + } + + return $result; +} + +function label_user_outline($course, $user, $mod, $label) { +/// Return a small object with summary information about what a +/// user has done with a given particular instance of this module +/// Used for user activity reports. +/// $return->time = the time they did it +/// $return->info = a short text description + + return NULL; +} + +function label_user_complete($course, $user, $mod, $label) { +/// Print a detailed representation of what a user has done with +/// a given particular instance of this module, for user activity reports. + + return false; +} + +?> diff --git a/mod/label/mod.html b/mod/label/mod.html new file mode 100644 index 0000000000..cb811eafcf --- /dev/null +++ b/mod/label/mod.html @@ -0,0 +1,56 @@ + + + + + +
action="mod.php"> +
+ + + + + + +

:

+ + "; + if ($usehtmleditor) { + helpbutton("richtext", get_string("helprichtext"), "moodle", true, true); + } else { + emoticonhelpbutton("form", "description"); + } + ?> +
+
+
+ content); + ?> +
+ + + + + + + + +"> +
+
+ + diff --git a/mod/label/version.php b/mod/label/version.php new file mode 100644 index 0000000000..44252fff31 --- /dev/null +++ b/mod/label/version.php @@ -0,0 +1,11 @@ +version = 2003091300; // The current module version (Date: YYYYMMDDXX) +$module->cron = 0; // Period for cron to check this module (secs) + +?> diff --git a/mod/label/view.php b/mod/label/view.php new file mode 100644 index 0000000000..8e115c698d --- /dev/null +++ b/mod/label/view.php @@ -0,0 +1,38 @@ +course)) { + error("Course is misconfigured"); + } + + if (! $label = get_record("label", "id", $cm->instance)) { + error("Course module is incorrect"); + } + + } else { + if (! $label = get_record("label", "id", $l)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $label->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("label", $label->id, $course->id)) { + error("Course Module ID was incorrect"); + } + } + + require_login($course->id); + + redirect("$CFG->wwwroot/course/view.php?id=$course->id"); + +?> + -- 2.39.5