Skip to content

Commit

Permalink
MDL-59392 calendar: Deprecate old event filters
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Sep 11, 2017
1 parent fc60d31 commit 7aaca08
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 177 deletions.
82 changes: 0 additions & 82 deletions calendar/lib.php
Expand Up @@ -1981,88 +1981,6 @@ function calendar_top_controls($type, $data) {
return $content;
}

/**
* Formats a filter control element.
*
* @param moodle_url $url of the filter
* @param int $type constant defining the type filter
* @return string html content of the element
*/
function calendar_filter_controls_element(moodle_url $url, $type) {
global $OUTPUT;

switch ($type) {
case CALENDAR_EVENT_GLOBAL:
$typeforhumans = 'global';
$class = 'calendar_event_global';
break;
case CALENDAR_EVENT_COURSE:
$typeforhumans = 'course';
$class = 'calendar_event_course';
break;
case CALENDAR_EVENT_GROUP:
$typeforhumans = 'groups';
$class = 'calendar_event_group';
break;
case CALENDAR_EVENT_USER:
$typeforhumans = 'user';
$class = 'calendar_event_user';
break;
}

if (calendar_show_event_type($type)) {
$icon = $OUTPUT->pix_icon('t/hide', get_string('hide'));
$str = get_string('hide' . $typeforhumans . 'events', 'calendar');
} else {
$icon = $OUTPUT->pix_icon('t/show', get_string('show'));
$str = get_string('show' . $typeforhumans . 'events', 'calendar');
}
$content = \html_writer::start_tag('li', array('class' => 'calendar_event'));
$content .= \html_writer::start_tag('a', array('href' => $url, 'rel' => 'nofollow'));
$content .= \html_writer::tag('span', $icon, array('class' => $class));
$content .= \html_writer::tag('span', $str, array('class' => 'eventname'));
$content .= \html_writer::end_tag('a');
$content .= \html_writer::end_tag('li');

return $content;
}

/**
* Get the controls filter for calendar.
*
* Filter is used to hide calendar info from the display page.
*
* @param moodle_url $returnurl return-url for filter controls
* @return string $content return filter controls in html
*/
function calendar_filter_controls(moodle_url $returnurl) {
$groupevents = true;

$seturl = new \moodle_url('/calendar/set.php', array('return' => base64_encode($returnurl->out_as_local_url(false)),
'sesskey' => sesskey()));
$content = \html_writer::start_tag('ul');

$seturl->param('var', 'showglobal');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_GLOBAL);

$seturl->param('var', 'showcourses');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_COURSE);

if (isloggedin() && !isguestuser()) {
if ($groupevents) {
// This course MIGHT have group events defined, so show the filter.
$seturl->param('var', 'showgroups');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_GROUP);
}
$seturl->param('var', 'showuser');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_USER);
}
$content .= \html_writer::end_tag('ul');

return $content;
}

/**
* Return the representation day.
*
Expand Down
18 changes: 0 additions & 18 deletions calendar/renderer.php
Expand Up @@ -50,24 +50,6 @@ public function complete_layout() {
return html_writer::end_tag('div');
}

/**
* Produces the content for the filters block (pretend block)
*
* @param int $courseid
* @param int $day
* @param int $month
* @param int $year
* @param int $view
* @param int $courses
* @return string
*/
public function fake_block_filters($courseid, $day, $month, $year, $view, $courses) {
$returnurl = $this->page->url;
$returnurl->param('course', $courseid);
return html_writer::tag('div', calendar_filter_controls($returnurl),
array('class' => 'calendar_filters filters'));
}

/**
* Produces the content for the three months block (pretend block)
*
Expand Down
60 changes: 0 additions & 60 deletions calendar/set.php

This file was deleted.

35 changes: 18 additions & 17 deletions lang/en/calendar.php
Expand Up @@ -136,11 +136,6 @@
$string['group'] = 'Group';
$string['groupevent'] = 'Group event';
$string['groupevents'] = 'Group events';
$string['hidecourseevents'] = 'Hide course events';
$string['hideglobalevents'] = 'Hide global events';
$string['hidegroupsevents'] = 'Hide group events';
$string['hidemoduleevents'] = 'Hide module events';
$string['hideuserevents'] = 'Hide user events';
$string['eventtypeglobal'] = 'global';
$string['eventtypesite'] = 'global';
$string['eventtypecourse'] = 'course';
Expand Down Expand Up @@ -205,10 +200,6 @@
$string['repeatweeksr'] = 'events';
$string['sat'] = 'Sat';
$string['saturday'] = 'Saturday';
$string['showcourseevents'] = 'Show course events';
$string['showglobalevents'] = 'Show global events';
$string['showgroupsevents'] = 'Show group events';
$string['showuserevents'] = 'Show user events';
$string['shown'] = 'shown';
$string['siteevents'] = 'Site events';
$string['spanningevents'] = 'Events underway';
Expand All @@ -229,14 +220,6 @@
$string['tomorrow'] = 'Tomorrow';
$string['tt_deleteevent'] = 'Delete event';
$string['tt_editevent'] = 'Edit event';
$string['tt_hidecourse'] = 'Course events are shown (click to hide)';
$string['tt_hideglobal'] = 'Global events are shown (click to hide)';
$string['tt_hidegroups'] = 'Group events are shown (click to hide)';
$string['tt_hideuser'] = 'User events are shown (click to hide)';
$string['tt_showcourse'] = 'Course events are hidden (click to show)';
$string['tt_showglobal'] = 'Global events are hidden (click to show)';
$string['tt_showgroups'] = 'Group events are hidden (click to show)';
$string['tt_showuser'] = 'User events are hidden (click to show)';
$string['tue'] = 'Tue';
$string['tuesday'] = 'Tuesday';
$string['typeclose'] = 'Close event';
Expand Down Expand Up @@ -264,3 +247,21 @@

// Deprecated since Moodle 3.2.
$string['for'] = 'for';

// Deprecated since Moodle 3.4.
$string['tt_hidecourse'] = 'Course events are shown (click to hide)';
$string['tt_hideglobal'] = 'Global events are shown (click to hide)';
$string['tt_hidegroups'] = 'Group events are shown (click to hide)';
$string['tt_hideuser'] = 'User events are shown (click to hide)';
$string['tt_showcourse'] = 'Course events are hidden (click to show)';
$string['tt_showglobal'] = 'Global events are hidden (click to show)';
$string['tt_showgroups'] = 'Group events are hidden (click to show)';
$string['tt_showuser'] = 'User events are hidden (click to show)';
$string['hidecourseevents'] = 'Hide course events';
$string['hideglobalevents'] = 'Hide global events';
$string['hidegroupsevents'] = 'Hide group events';
$string['hideuserevents'] = 'Hide user events';
$string['showcourseevents'] = 'Show course events';
$string['showglobalevents'] = 'Show global events';
$string['showgroupsevents'] = 'Show group events';
$string['showuserevents'] = 'Show user events';
16 changes: 16 additions & 0 deletions lang/en/deprecated.txt
Expand Up @@ -63,3 +63,19 @@ sectionusedefaultname,core
registermoochtips,core_hub
monthnext,core_access
monthprev,core_access
tt_hidecourse,core_calendar
tt_hideglobal,core_calendar
tt_hidegroups,core_calendar
tt_hideuser,core_calendar
tt_showcourse,core_calendar
tt_showglobal,core_calendar
tt_showgroups,core_calendar
tt_showuser,core_calendar
hidecourseevents,core_calendar
hideglobalevents,core_calendar
hidegroupsevents,core_calendar
hideuserevents,core_calendar
showcourseevents,core_calendar
showglobalevents,core_calendar
showgroupsevents,core_calendar
showuserevents,core_calendar

0 comments on commit 7aaca08

Please sign in to comment.