--- /dev/null
+<?PHP\r
+\r
+function label_upgrade($oldversion) {\r
+/// This function does anything necessary to upgrade \r
+/// older versions to match current functionality \r
+\r
+ global $CFG;\r
+\r
+ return true;\r
+}\r
+\r
+?>\r
--- /dev/null
+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';
--- /dev/null
+<?PHP\r
+\r
+function label_upgrade($oldversion) {\r
+/// This function does anything necessary to upgrade \r
+/// older versions to match current functionality \r
+\r
+ global $CFG;\r
+\r
+ return true;\r
+}\r
+\r
+?>\r
--- /dev/null
+CREATE TABLE prefix_label (
+ id SERIAL PRIMARY KEY,
+ name varchar(255) default NULL,
+ content text,
+ timemodified integer NOT NULL default '0'
+);
--- /dev/null
+<?PHP // $Id$
+
+ require_once("../../config.php");
+ require_once("lib.php");
+
+ require_variable($id); // course
+
+ redirect("$CFG->wwwroot/course/view.php?id=$id");
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+/// Library of functions and constants for module label
+
+
+define("LABEL_MAX_NAME_LENGTH", 50);
+
+function label_add_instance($label) {
+/// Given an object containing all the necessary data,
+/// (defined by the form in mod.html) this function
+/// will create a new instance and return the id number
+/// of the new instance.
+
+ $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();
+
+ 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;
+}
+
+?>
--- /dev/null
+<!-- This page defines the form to create or edit an instance of this module -->
+<!-- It is used from /course/mod.php. The whole instance is available as $form. -->
+
+<?php
+ if ($usehtmleditor = can_use_richtext_editor()) {
+ $defaultformat = FORMAT_HTML;
+ $onsubmit = "onsubmit=\"copyrichtext(document.form.content);\"";
+ } else {
+ $defaultformat = FORMAT_MOODLE;
+ $onsubmit = "";
+ }
+?>
+
+<form name="form" method="post" <?php echo $onsubmit ?> action="mod.php">
+<center>
+<table cellpadding=5>
+<tr valign=top>
+ <td align=right><p><b><?php print_string("labeltext", "label") ?>:</b></p>
+ <font size="1">
+ <?php
+ helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
+ echo "<br />";
+ if ($usehtmleditor) {
+ helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
+ } else {
+ emoticonhelpbutton("form", "description");
+ }
+ ?>
+ <br />
+ </font>
+ </td>
+ <td>
+ <?php
+ print_textarea($usehtmleditor, 20, 60, 680, 400, "content", $form->content);
+ ?>
+ </td>
+</tr>
+
+</table>
+<!-- these hidden variables are always the same -->
+<input type="hidden" name=course value="<?php p($form->course) ?>">
+<input type="hidden" name=coursemodule value="<?php p($form->coursemodule) ?>">
+<input type="hidden" name=section value="<?php p($form->section) ?>">
+<input type="hidden" name=module value="<?php p($form->module) ?>">
+<input type="hidden" name=modulename value="<?php p($form->modulename) ?>">
+<input type="hidden" name=instance value="<?php p($form->instance) ?>">
+<input type="hidden" name=mode value="<?php p($form->mode) ?>">
+<input type="submit" value="<?php print_string("savechanges") ?>">
+</center>
+</form>
+
+<?php
+ if ($usehtmleditor) {
+ print_richedit_javascript("form", "content", "yes");
+ }
+?>
--- /dev/null
+<?PHP // $Id$
+
+/////////////////////////////////////////////////////////////////////////////////
+/// Code fragment to define the version of label
+/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
+/////////////////////////////////////////////////////////////////////////////////
+
+$module->version = 2003091300; // The current module version (Date: YYYYMMDDXX)
+$module->cron = 0; // Period for cron to check this module (secs)
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+ require_once("../../config.php");
+
+ optional_variable($id); // Course Module ID, or
+ optional_variable($l); // Label ID
+
+ if ($id) {
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ if (! $course = get_record("course", "id", $cm->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");
+
+?>
+