This commit is contained in:
Sara Arjona 2024-01-10 17:00:02 +01:00
commit 502e1a8329
No known key found for this signature in database
4 changed files with 42 additions and 296 deletions

View File

@ -1,6 +1,11 @@
This files describes API changes in /calendar/* ,
information provided here is intended especially for developers.
=== 4.4 ===
* The following previously deprecated methods have been removed and can no longer be used:
- `calendar_process_subscription_row`
- `calendar_import_icalendar_events`
=== 4.3 ===
* The `navigation` property has been removed from `\core_calendar\external\day_exporter` as it is not being used by any of the
calendar templates.

View File

@ -8,6 +8,10 @@ information provided here is intended especially for developers.
* The external function core_course::get_courses_by_field now returns the communication tool configuration for the course.
- communicationroomname: the room name
- communicationroomurl: the tool url
* The following previously deprecated methods have been removed and can no longer be used:
- `course_purge_section_cache`
- `course_purge_module_cache`
- `get_array_of_activities`
=== 4.3 ===
* The `core_course_renderer::course_section_cm_completion` method has been removed, and can no longer be used

View File

@ -14,6 +14,9 @@ Information provided here is intended especially for developers.
for validation.
* The function get_gradable_users() in grade/lib.php has extra param now to retrieve only active enrolments.
* A new webservice core_grades_get_gradable_users has been added to retrieve gradable users for a course.
* The following previously deprecated methods have been removed and can no longer be used:
- `grade_print_tabs`
- `print_grade_plugin_selector`
=== 4.3 ===
* The $showtitle parameter in the print_grade_page_head function located inside grade/lib.php has been deprecated and is not used anymore.

View File

@ -2814,323 +2814,57 @@ function profile_edit_field() {
}
/**
* Update a subscription from the form data in one of the rows in the existing subscriptions table.
*
* @param int $subscriptionid The ID of the subscription we are acting upon.
* @param int $pollinterval The poll interval to use.
* @param int $action The action to be performed. One of update or remove.
* @throws dml_exception if invalid subscriptionid is provided
* @return string A log of the import progress, including errors
* @deprecated since Moodle 4.0 MDL-71953
*/
function calendar_process_subscription_row($subscriptionid, $pollinterval, $action) {
debugging('calendar_process_subscription_row() is deprecated.', DEBUG_DEVELOPER);
// Fetch the subscription from the database making sure it exists.
$sub = calendar_get_subscription($subscriptionid);
// Update or remove the subscription, based on action.
switch ($action) {
case CALENDAR_SUBSCRIPTION_UPDATE:
// Skip updating file subscriptions.
if (empty($sub->url)) {
break;
}
$sub->pollinterval = $pollinterval;
calendar_update_subscription($sub);
// Update the events.
return "<p>" . get_string('subscriptionupdated', 'calendar', $sub->name) . "</p>" .
calendar_update_subscription_events($subscriptionid);
case CALENDAR_SUBSCRIPTION_REMOVE:
calendar_delete_subscription($subscriptionid);
return get_string('subscriptionremoved', 'calendar', $sub->name);
break;
default:
break;
}
return '';
function calendar_process_subscription_row() {
throw new coding_exception(__FUNCTION__ . '() has been removed.');
}
/**
* Import events from an iCalendar object into a course calendar.
*
* @param iCalendar $ical The iCalendar object.
* @param int $unused Deprecated
* @param int $subscriptionid The subscription ID.
* @return string A log of the import progress, including errors.
* @deprecated since Moodle 4.0 MDL-71953
*/
function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid = null) {
debugging('calendar_import_icalendar_events() is deprecated. Please use calendar_import_events_from_ical() instead.',
DEBUG_DEVELOPER);
global $DB;
$return = '';
$eventcount = 0;
$updatecount = 0;
$skippedcount = 0;
// Large calendars take a while...
if (!CLI_SCRIPT) {
\core_php_time_limit::raise(300);
}
// Grab the timezone from the iCalendar file to be used later.
if (isset($ical->properties['X-WR-TIMEZONE'][0]->value)) {
$timezone = $ical->properties['X-WR-TIMEZONE'][0]->value;
} else {
$timezone = 'UTC';
}
$icaluuids = [];
foreach ($ical->components['VEVENT'] as $event) {
$icaluuids[] = $event->properties['UID'][0]->value;
$res = calendar_add_icalendar_event($event, null, $subscriptionid, $timezone);
switch ($res) {
case CALENDAR_IMPORT_EVENT_UPDATED:
$updatecount++;
break;
case CALENDAR_IMPORT_EVENT_INSERTED:
$eventcount++;
break;
case CALENDAR_IMPORT_EVENT_SKIPPED:
$skippedcount++;
break;
case 0:
$return .= '<p>' . get_string('erroraddingevent', 'calendar') . ': ';
if (empty($event->properties['SUMMARY'])) {
$return .= '(' . get_string('notitle', 'calendar') . ')';
} else {
$return .= $event->properties['SUMMARY'][0]->value;
}
$return .= "</p>\n";
break;
}
}
$return .= html_writer::start_tag('ul');
$existing = $DB->get_field('event_subscriptions', 'lastupdated', ['id' => $subscriptionid]);
if (!empty($existing)) {
$eventsuuids = $DB->get_records_menu('event', ['subscriptionid' => $subscriptionid], '', 'id, uuid');
$icaleventscount = count($icaluuids);
$tobedeleted = [];
if (count($eventsuuids) > $icaleventscount) {
foreach ($eventsuuids as $eventid => $eventuuid) {
if (!in_array($eventuuid, $icaluuids)) {
$tobedeleted[] = $eventid;
}
}
if (!empty($tobedeleted)) {
$DB->delete_records_list('event', 'id', $tobedeleted);
$return .= html_writer::tag('li', get_string('eventsdeleted', 'calendar', count($tobedeleted)));
}
}
}
$return .= html_writer::tag('li', get_string('eventsimported', 'calendar', $eventcount));
$return .= html_writer::tag('li', get_string('eventsskipped', 'calendar', $skippedcount));
$return .= html_writer::tag('li', get_string('eventsupdated', 'calendar', $updatecount));
$return .= html_writer::end_tag('ul');
return $return;
function calendar_import_icalendar_events() {
throw new coding_exception(__FUNCTION__ . '() has been removed. Please use calendar_import_events_from_ical() instead.');
}
/**
* Print grading plugin selection tab-based navigation.
*
* @deprecated since Moodle 4.0. Tabs navigation has been replaced with tertiary navigation.
* @param string $active_type type of plugin on current page - import, export, report or edit
* @param string $active_plugin active plugin type - grader, user, cvs, ...
* @param array $plugin_info Array of plugins
* @param boolean $return return as string
*
* @return nothing or string if $return true
*/
function grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=false) {
global $CFG, $COURSE;
debugging('grade_print_tabs() has been deprecated. Tabs navigation has been replaced with tertiary navigation.',
DEBUG_DEVELOPER);
if (!isset($currenttab)) { //TODO: this is weird
$currenttab = '';
}
$tabs = array();
$top_row = array();
$bottom_row = array();
$inactive = array($active_plugin);
$activated = array($active_type);
$count = 0;
$active = '';
foreach ($plugin_info as $plugin_type => $plugins) {
if ($plugin_type == 'strings') {
continue;
}
// If $plugins is actually the definition of a child-less parent link:
if (!empty($plugins->id)) {
$string = $plugins->string;
if (!empty($plugin_info[$active_type]->parent)) {
$string = $plugin_info[$active_type]->parent->string;
}
$top_row[] = new tabobject($plugin_type, $plugins->link, $string);
continue;
}
$first_plugin = reset($plugins);
$url = $first_plugin->link;
if ($plugin_type == 'report') {
$url = $CFG->wwwroot.'/grade/report/index.php?id='.$COURSE->id;
}
$top_row[] = new tabobject($plugin_type, $url, $plugin_info['strings'][$plugin_type]);
if ($active_type == $plugin_type) {
foreach ($plugins as $plugin) {
$bottom_row[] = new tabobject($plugin->id, $plugin->link, $plugin->string);
if ($plugin->id == $active_plugin) {
$inactive = array($plugin->id);
}
}
}
}
// Do not display rows that contain only one item, they are not helpful.
if (count($top_row) > 1) {
$tabs[] = $top_row;
}
if (count($bottom_row) > 1) {
$tabs[] = $bottom_row;
}
if (empty($tabs)) {
return;
}
$rv = html_writer::div(print_tabs($tabs, $active_plugin, $inactive, $activated, true), 'grade-navigation');
if ($return) {
return $rv;
} else {
echo $rv;
}
function grade_print_tabs() {
throw new coding_exception(__FUNCTION__ . '() has been removed.');
}
/**
* Print grading plugin selection popup form.
*
* @deprecated since Moodle 4.0. Dropdown box navigation has been replaced with tertiary navigation.
* @param array $plugin_info An array of plugins containing information for the selector
* @param boolean $return return as string
*
* @return nothing or string if $return true
*/
function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return=false) {
global $CFG, $OUTPUT, $PAGE;
debugging('print_grade_plugin_selector() has been deprecated. Dropdown box navigation has been replaced ' .
'with tertiary navigation.', DEBUG_DEVELOPER);
$menu = array();
$count = 0;
$active = '';
foreach ($plugin_info as $plugin_type => $plugins) {
if ($plugin_type == 'strings') {
continue;
}
$first_plugin = reset($plugins);
$sectionname = $plugin_info['strings'][$plugin_type];
$section = array();
foreach ($plugins as $plugin) {
$link = $plugin->link->out(false);
$section[$link] = $plugin->string;
$count++;
if ($plugin_type === $active_type and $plugin->id === $active_plugin) {
$active = $link;
}
}
if ($section) {
$menu[] = array($sectionname=>$section);
}
}
// finally print/return the popup form
if ($count > 1) {
$select = new url_select($menu, $active, null, 'choosepluginreport');
$select->set_label(get_string('gradereport', 'grades'), array('class' => 'accesshide'));
if ($return) {
return $OUTPUT->render($select);
} else {
echo $OUTPUT->render($select);
}
} else {
// only one option - no plugin selector needed
return '';
}
/**
* Purge the cache of a course section.
*
* $sectioninfo must have following attributes:
* - course: course id
* - section: section number
*
* @param object $sectioninfo section info
* @return void
* @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_section_cache_by_id()}
* or {@link course_modinfo::purge_course_section_cache_by_number()} instead.
*/
function course_purge_section_cache(object $sectioninfo): void {
debugging(__FUNCTION__ . '() is deprecated. ' .
'Please use course_modinfo::purge_course_section_cache_by_id() ' .
'or course_modinfo::purge_course_section_cache_by_number() instead.',
DEBUG_DEVELOPER);
$sectionid = $sectioninfo->section;
$courseid = $sectioninfo->course;
course_modinfo::purge_course_section_cache_by_id($courseid, $sectionid);
}
/**
* Purge the cache of a course module.
*
* $cm must have following attributes:
* - id: cmid
* - course: course id
*
* @param cm_info|stdClass $cm course module
* @return void
* @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_module_cache()} instead.
*/
function course_purge_module_cache($cm): void {
debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::purge_course_module_cache() instead.',
DEBUG_DEVELOPER);
$cmid = $cm->id;
$courseid = $cm->course;
course_modinfo::purge_course_module_cache($courseid, $cmid);
}
function print_grade_plugin_selector() {
throw new coding_exception(__FUNCTION__ . '() has been removed.');
}
/**
* @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_section_cache_by_id()}
* or {@link course_modinfo::purge_course_section_cache_by_number()} instead.
*/
function course_purge_section_cache() {
throw new coding_exception(__FUNCTION__ . '() has been removed. ' .
'Please use course_modinfo::purge_course_section_cache_by_id() ' .
'or course_modinfo::purge_course_section_cache_by_number() instead.');
}
/**
* @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_module_cache()} instead.
*/
function course_purge_module_cache() {
throw new coding_exception(__FUNCTION__ . '() has been removed. ' .
'Please use course_modinfo::purge_course_module_cache() instead.');
}
/**
* For a given course, returns an array of course activity objects
* Each item in the array contains he following properties:
*
* @param int $courseid course id
* @param bool $usecache get activities from cache if modinfo exists when $usecache is true
* @return array list of activities
* @deprecated since Moodle 4.0. Please use {@link course_modinfo::get_array_of_activities()} instead.
*/
function get_array_of_activities(int $courseid, bool $usecache = false): array {
debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::get_array_of_activities() instead.',
DEBUG_DEVELOPER);
return course_modinfo::get_array_of_activities(get_course($courseid), $usecache);
function get_array_of_activities() {
throw new coding_exception(__FUNCTION__ . '() has been removed. ' .
'Please use course_modinfo::get_array_of_activities() instead.');
}
/**