mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-36614 calendar: Add support for storing the submitted event type
This commit is contained in:
parent
7133a88d06
commit
35ad5fc6bb
2 changed files with 14 additions and 11 deletions
|
@ -2692,13 +2692,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('globalevents', 'calendar');
|
||||
$choices['site'] = get_string('globalevents', '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');
|
||||
|
@ -2714,11 +2714,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;
|
||||
|
||||
|
@ -2794,10 +2798,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))) {
|
||||
|
|
|
@ -74,11 +74,10 @@ class calendar_addsubscription_form extends moodleform {
|
|||
$mform->addHelpButton('pollinterval', 'pollinterval', 'calendar');
|
||||
$mform->setType('pollinterval', PARAM_INT);
|
||||
|
||||
// Eventtype: 0 = user, 1 = global, anything else = course ID.
|
||||
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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue