MDL-62944 calendar: Fix actionevent logic on template

During the calendar work, we have added the feature of
drag and drop activity event or "action events".

The problem at that time was, action events could not be
editable through the calendar UI, but should be allowed
to drag and drop. So, we couldn't use the return of
calendar_edit_event_allowed() because it can return true
(in case of teachers, that have permission to change the
activity) and the attribute isactionevent was created to
control on the UI if the user is viewing an action event.

So what my patch does is just add the check if we are
viewing an action event, and in this case, it won't display
the cog to edit that event.
This commit is contained in:
Simey Lameze 2018-08-06 12:55:17 +08:00 committed by Neill Magill
parent bbf1fde412
commit baedf0662a
2 changed files with 8 additions and 3 deletions

View File

@ -255,6 +255,9 @@ class event_exporter_base extends exporter {
$values['iscourseevent'] = false;
$values['iscategoryevent'] = false;
if ($moduleproxy = $event->get_course_module()) {
// We need a separate property to flag if an event is action event.
// That's required because canedit return true but action action events cannot be edited on the calendar UI.
// But they are considered editable because you can drag and drop the event on the month view.
$values['isactionevent'] = true;
} else if ($event->get_type() == 'course') {
$values['iscourseevent'] = true;

View File

@ -49,9 +49,11 @@
{{#pix}}t/delete, core, {{#str}}delete{{/str}}{{/pix}}
</a>
{{/candelete}}
<a href="{{editurl}}" data-action="edit">
{{#pix}}t/edit, core, {{#str}}edit{{/str}}{{/pix}}
</a>
{{^isactionevent}}
<a href="{{editurl}}" data-action="edit">
{{#pix}}t/edit, core, {{#str}}edit{{/str}}{{/pix}}
</a>
{{/isactionevent}}
{{/canedit}}
</div>
{{#icon}}<div class="d-inline-block mt-1 align-top">{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}</div>{{/icon}}