table_column("course_modules", "", "groupmode", "integer", "4", "unsigned", "0", "", "visible");
}
+ if ($oldversion < 2004011700) {
+ modify_database("", "CREATE TABLE `prefix_event` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name` varchar(255) NOT NULL default '',
+ `description` text NOT NULL,
+ `courseid` int(10) unsigned NOT NULL default '0',
+ `groupid` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
+ `modulename` varchar(20) NOT NULL default '',
+ `instance` int(10) unsigned NOT NULL default '0',
+ `eventtype` varchar(20) NOT NULL default '',
+ `timestart` int(10) unsigned NOT NULL default '0',
+ `timeduration` int(10) unsigned NOT NULL default '0',
+ `timemodified` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`),
+ KEY `courseid` (`courseid`),
+ KEY `userid` (`userid`)
+ ) TYPE=MyISAM COMMENT='For everything with a time associated to it'; ");
+ }
+
return $result;
}
) TYPE=MyISAM;
# --------------------------------------------------------
+#
+# Table structure for table `event`
+#
+
+CREATE TABLE `prefix_event` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name` varchar(255) NOT NULL default '',
+ `description` text NOT NULL,
+ `courseid` int(10) unsigned NOT NULL default '0',
+ `groupid` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
+ `modulename` varchar(20) NOT NULL default '',
+ `instance` int(10) unsigned NOT NULL default '0',
+ `eventtype` varchar(20) NOT NULL default '',
+ `timestart` int(10) unsigned NOT NULL default '0',
+ `timeduration` int(10) unsigned NOT NULL default '0',
+ `timemodified` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`),
+ KEY `courseid` (`courseid`),
+ KEY `userid` (`userid`)
+) TYPE=MyISAM COMMENT='For everything with a time associated to it';
+
#
# Table structure for table `group`
#
`timecreated` int(10) unsigned NOT NULL default '0',
`timemodified` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`),
KEY `courseid` (`courseid`)
) TYPE=MyISAM COMMENT='Each record is a group in a course.';
# --------------------------------------------------------
`userid` int(10) unsigned NOT NULL default '0',
`timeadded` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`),
KEY `groupid` (`groupid`)
) TYPE=MyISAM COMMENT='Lists memberships of users to groups';
# --------------------------------------------------------
table_column("course_modules", "", "groupmode", "integer", "4", "unsigned", "0", "", "visible");
}
+ if ($oldversion < 2004011700) {
+ modify_database("", "CREATE TABLE prefix_event (
+ id SERIAL PRIMARY KEY,
+ name varchar(255) NOT NULL default '',
+ description text,
+ courseid integer NOT NULL default '0',
+ groupid integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
+ modulename varchar(20) NOT NULL default '',
+ instance integer NOT NULL default '0',
+ eventtype varchar(20) NOT NULL default '',
+ timestart integer NOT NULL default '0',
+ timeduration integer NOT NULL default '0',
+ timemodified integer NOT NULL default '0'
+ ); ");
+
+ modify_database("", "CREATE INDEX prefix_event_courseid_idx ON prefix_event (courseid);");
+ modify_database("", "CREATE INDEX prefix_event_userid_idx ON prefix_event (userid);");
+ }
+
+
return $result;
}
visible integer NOT NULL default '1'
);
+CREATE TABLE prefix_event (
+ id SERIAL PRIMARY KEY,
+ name varchar(255) NOT NULL default '',
+ description text,
+ courseid integer NOT NULL default '0',
+ groupid integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
+ modulename varchar(20) NOT NULL default '',
+ instance integer NOT NULL default '0',
+ eventtype varchar(20) NOT NULL default '',
+ timestart integer NOT NULL default '0',
+ timeduration integer NOT NULL default '0',
+ timemodified integer NOT NULL default '0'
+);
+
+CREATE INDEX prefix_event_courseid_idx ON prefix_event (courseid);
+CREATE INDEX prefix_event_userid_idx ON prefix_event (userid);
+
CREATE TABLE prefix_groups (
id SERIAL PRIMARY KEY,
courseid integer NOT NULL default '0',
}
+/// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
+
+
+function add_event($event) {
+/// call this function to add an event to the calendar table
+/// and to call any calendar plugins
+/// The function returns the id number of the resulting record
+/// The object event should include the following:
+/// $event->name Name for the event
+/// $event->description Description of the event (defaults to '')
+/// $event->courseid The id of the course this event belongs to (0 = all courses)
+/// $event->groupid The id of the group this event belongs to (0 = no group)
+/// $event->userid The id of the user this event belongs to (0 = no user)
+/// $event->modulename Name of the module that creates this event
+/// $event->instance Instance of the module that owns this event
+/// $event->eventtype The type info together with the module info could
+/// be used by calendar plugins to decide how to display event
+/// $event->timestart Timestamp for start of event
+/// $event->timeduration Duration (defaults to zero)
+
+ global $CFG;
+
+ $event->timemodified = time();
+
+ if (!$event->id = insert_record("event", $event)) {
+ return false;
+ }
+
+ if (!empty($CFG->calendar)) { // call the add_event function of the selected calendar
+ if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
+ include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ $calendar_add_event = $CFG->calendar.'_add_event';
+ if (function_exists($calendar_add_event)) {
+ $calendar_add_event($event);
+ }
+ }
+ }
+
+ return $event->id;
+}
+
+
+function update_event($event) {
+/// call this function to update an event in the calendar table
+/// the event will be identified by the id field of the $event object
+
+ global $CFG;
+
+ $event->timemodified = time();
+
+ if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
+ if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
+ include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ $calendar_update_event = $CFG->calendar.'_update_event';
+ if (function_exists($calendar_update_event)) {
+ $calendar_update_event($event);
+ }
+ }
+ }
+ return update_record("event", $event);
+}
+
+
+function delete_event($id) {
+/// call this function to delete the event with id $id from calendar table
+
+ global $CFG;
+
+ if (!empty($CFG->calendar)) { // call the delete_event function of the selected calendar
+ if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
+ include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+ $calendar_delete_event = $CFG->calendar.'_delete_event';
+ if (function_exists($calendar_delete_event)) {
+ $calendar_delete_event($id);
+ }
+ }
+ }
+ return delete_records("event", 'id', $id);
+}
+
+
+
+
/// ENVIRONMENT CHECKING ////////////////////////////////////////////////////////////
function get_list_of_plugins($plugin="mod") {
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2004010900; // The current version is a date (YYYYMMDDXX)
+$version = 2004011700; // The current version is a date (YYYYMMDDXX)
$release = "1.2 development"; // User-friendly version number