Merge branch 'MDL-36614-master' of git://github.com/ankitagarwal/moodle
Conflicts: calendar/lib.php (MDL-36615) calendar/managesubscriptions_form.php (MDL-36352)
This commit is contained in:
+13
-9
@@ -2696,13 +2696,13 @@ function calendar_get_eventtype_choices($courseid) {
|
||||
calendar_get_allowed_types($allowed, $courseid);
|
||||
|
||||
if ($allowed->user) {
|
||||
$choices[0] = get_string('userevents', 'calendar');
|
||||
$choices['user'] = get_string('userevents', 'calendar');
|
||||
}
|
||||
if ($allowed->site) {
|
||||
$choices[SITEID] = get_string('siteevents', 'calendar');
|
||||
$choices['site'] = get_string('siteevents', 'calendar');
|
||||
}
|
||||
if (!empty($allowed->courses)) {
|
||||
$choices[$courseid] = get_string('courseevents', 'calendar');
|
||||
$choices['course'] = get_string('courseevents', 'calendar');
|
||||
}
|
||||
if (!empty($allowed->groups) and is_array($allowed->groups)) {
|
||||
$choices['group'] = get_string('group');
|
||||
@@ -2718,11 +2718,15 @@ function calendar_get_eventtype_choices($courseid) {
|
||||
* @return int The insert ID, if any.
|
||||
*/
|
||||
function calendar_add_subscription($sub) {
|
||||
global $DB, $USER;
|
||||
global $DB, $USER, $SITE;
|
||||
|
||||
$sub->courseid = $sub->eventtype;
|
||||
if ($sub->eventtype == 'group') {
|
||||
if ($sub->eventtype === 'site') {
|
||||
$sub->courseid = $SITE->id;
|
||||
} else if ($sub->eventtype === 'group' || $sub->eventtype === 'course') {
|
||||
$sub->courseid = $sub->course;
|
||||
} else {
|
||||
// User events.
|
||||
$sub->courseid = 0;
|
||||
}
|
||||
$sub->userid = $USER->id;
|
||||
|
||||
@@ -2798,10 +2802,10 @@ function calendar_add_icalendar_event($event, $courseid, $subscriptionid = null)
|
||||
$eventrecord->userid = $sub->userid;
|
||||
$eventrecord->groupid = $sub->groupid;
|
||||
$eventrecord->courseid = $sub->courseid;
|
||||
$eventrecord->eventtype = $sub->eventtype;
|
||||
} else {
|
||||
$eventrecord->userid = $USER->id;
|
||||
$eventrecord->groupid = 0; // TODO: ???
|
||||
$eventrecord->courseid = $courseid;
|
||||
// We should never do anything with an event without a subscription reference.
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($updaterecord = $DB->get_record('event', array('uuid' => $eventrecord->uuid))) {
|
||||
|
||||
@@ -80,7 +80,7 @@ class calendar_addsubscription_form extends moodleform {
|
||||
list($choices, $groups) = calendar_get_eventtype_choices($courseid);
|
||||
$mform->addElement('select', 'eventtype', get_string('eventkind', 'calendar'), $choices);
|
||||
$mform->addRule('eventtype', get_string('required'), 'required');
|
||||
$mform->setType('eventtype', PARAM_INT);
|
||||
$mform->setType('eventtype', PARAM_ALPHA);
|
||||
|
||||
if (!empty($groups) and is_array($groups)) {
|
||||
$groupoptions = array();
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20121112" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20121116" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -2888,8 +2888,9 @@
|
||||
<FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="courseid"/>
|
||||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="url" NEXT="groupid"/>
|
||||
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="groupid" NEXT="pollinterval"/>
|
||||
<FIELD NAME="pollinterval" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Frequency of checks for new/changed events" PREVIOUS="userid" NEXT="lastupdated"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="groupid" NEXT="eventtype"/>
|
||||
<FIELD NAME="eventtype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="The type of the event" PREVIOUS="userid" NEXT="pollinterval"/>
|
||||
<FIELD NAME="pollinterval" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Frequency of checks for new/changed events" PREVIOUS="eventtype" NEXT="lastupdated"/>
|
||||
<FIELD NAME="lastupdated" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" PREVIOUS="pollinterval" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="lastupdated"/>
|
||||
</FIELDS>
|
||||
|
||||
@@ -1472,6 +1472,20 @@ function xmldb_main_upgrade($oldversion) {
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2012111200.01);
|
||||
}
|
||||
if ($oldversion < 2012111601.01) {
|
||||
|
||||
// Define field eventtype to be added to event_subscriptions.
|
||||
$table = new xmldb_table('event_subscriptions');
|
||||
$field = new xmldb_field('eventtype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, 'userid');
|
||||
|
||||
// Conditionally launch add field eventtype.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2012111601.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2012111601.01) {
|
||||
// Clea up after old shared memory caching support.
|
||||
|
||||
Reference in New Issue
Block a user