Merge branch 'MDL-67152-38' of git://github.com/rezaies/moodle into MOODLE_38_STABLE
This commit is contained in:
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core_calendar/repository",["jquery","core/ajax"],function(a,b){return{getEventById:function getEventById(a){return b.call([{methodname:"core_calendar_get_calendar_event_by_id",args:{eventid:a}}])[0]},deleteEvent:function deleteEvent(a,c){if("undefined"==typeof c){c=!1}var d={methodname:"core_calendar_delete_calendar_events",args:{events:[{eventid:a,repeat:c}]}};return b.call([d])[0]},updateEventStartDay:function updateEventStartDay(a,c){return b.call([{methodname:"core_calendar_update_event_start_day",args:{eventid:a,daytimestamp:c}}])[0]},submitCreateUpdateForm:function submitCreateUpdateForm(a){return b.call([{methodname:"core_calendar_submit_create_update_form",args:{formdata:a}}])[0]},getCalendarMonthData:function getCalendarMonthData(a,c,d,e,f,g){return b.call([{methodname:"core_calendar_get_calendar_monthly_view",args:{year:a,month:c,courseid:d,categoryid:e,includenavigation:f,mini:g}}])[0]},getCalendarDayData:function getCalendarDayData(a,c,d,e,f){return b.call([{methodname:"core_calendar_get_calendar_day_view",args:{year:a,month:c,day:d,courseid:e,categoryid:f}}])[0]},getCalendarUpcomingData:function getCalendarUpcomingData(a,c){return b.call([{methodname:"core_calendar_get_calendar_upcoming_view",args:{courseid:a,categoryid:c}}])[0]},getCourseGroupsData:function getCourseGroupsData(a){return b.call([{methodname:"core_group_get_course_groups",args:{courseid:a}}])[0]}}});
|
||||
define ("core_calendar/repository",["jquery","core/ajax"],function(a,b){return{getEventById:function getEventById(a){return b.call([{methodname:"core_calendar_get_calendar_event_by_id",args:{eventid:a}}])[0]},deleteEvent:function deleteEvent(a,c){if("undefined"==typeof c){c=!1}var d={methodname:"core_calendar_delete_calendar_events",args:{events:[{eventid:a,repeat:c}]}};return b.call([d])[0]},updateEventStartDay:function updateEventStartDay(a,c){return b.call([{methodname:"core_calendar_update_event_start_day",args:{eventid:a,daytimestamp:c}}])[0]},submitCreateUpdateForm:function submitCreateUpdateForm(a){return b.call([{methodname:"core_calendar_submit_create_update_form",args:{formdata:a}}])[0]},getCalendarMonthData:function getCalendarMonthData(a,c,d,e,f,g,h){h=h||1;var i={methodname:"core_calendar_get_calendar_monthly_view",args:{year:a,month:c,courseid:d,categoryid:e,includenavigation:f,mini:g,day:h}};return b.call([i])[0]},getCalendarDayData:function getCalendarDayData(a,c,d,e,f){return b.call([{methodname:"core_calendar_get_calendar_day_view",args:{year:a,month:c,day:d,courseid:e,categoryid:f}}])[0]},getCalendarUpcomingData:function getCalendarUpcomingData(a,c){return b.call([{methodname:"core_calendar_get_calendar_upcoming_view",args:{courseid:a,categoryid:c}}])[0]},getCourseGroupsData:function getCourseGroupsData(a){return b.call([{methodname:"core_group_get_course_groups",args:{courseid:a}}])[0]}}});
|
||||
//# sourceMappingURL=repository.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -94,11 +94,13 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
|
||||
* @param {Number} month Month
|
||||
* @param {Number} courseid The course id.
|
||||
* @param {Number} categoryid The category id.
|
||||
* @param {Bool} includenavigation Whether to include navigation.
|
||||
* @param {Bool} mini Whether the month is in mini view.
|
||||
* @param {Boolean} includenavigation Whether to include navigation.
|
||||
* @param {Boolean} mini Whether the month is in mini view.
|
||||
* @param {Number} day Day (optional)
|
||||
* @return {promise} Resolved with the month view data.
|
||||
*/
|
||||
var getCalendarMonthData = function(year, month, courseid, categoryid, includenavigation, mini) {
|
||||
var getCalendarMonthData = function(year, month, courseid, categoryid, includenavigation, mini, day) {
|
||||
day = day || 1;
|
||||
var request = {
|
||||
methodname: 'core_calendar_get_calendar_monthly_view',
|
||||
args: {
|
||||
@@ -107,7 +109,8 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
|
||||
courseid: courseid,
|
||||
categoryid: categoryid,
|
||||
includenavigation: includenavigation,
|
||||
mini: mini
|
||||
mini: mini,
|
||||
day: day
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ define([
|
||||
var link = $(e.currentTarget);
|
||||
|
||||
if (view === 'month') {
|
||||
changeMonth(root, link.attr('href'), link.data('year'), link.data('month'), courseId, categoryId);
|
||||
changeMonth(root, link.attr('href'), link.data('year'), link.data('month'), courseId, categoryId,
|
||||
link.data('day'));
|
||||
e.preventDefault();
|
||||
} else if (view === 'day') {
|
||||
changeDay(root, link.attr('href'), link.data('year'), link.data('month'), link.data('day'),
|
||||
@@ -124,7 +125,7 @@ define([
|
||||
categoryId = option.data('categoryid');
|
||||
|
||||
if (view == 'month') {
|
||||
refreshMonthContent(root, year, month, courseId, categoryId, root, 'core_calendar/calendar_month')
|
||||
refreshMonthContent(root, year, month, courseId, categoryId, root, 'core_calendar/calendar_month', day)
|
||||
.then(function() {
|
||||
return window.history.pushState({}, '', '?view=month');
|
||||
}).fail(Notification.exception);
|
||||
@@ -153,17 +154,19 @@ define([
|
||||
* @param {Number} categoryid The id of the category whose events are shown
|
||||
* @param {object} target The element being replaced. If not specified, the calendarwrapper is used.
|
||||
* @param {String} template The template to be rendered.
|
||||
* @param {Number} day Day (optional)
|
||||
* @return {promise}
|
||||
*/
|
||||
var refreshMonthContent = function(root, year, month, courseid, categoryid, target, template) {
|
||||
var refreshMonthContent = function(root, year, month, courseid, categoryid, target, template, day) {
|
||||
startLoading(root);
|
||||
|
||||
target = target || root.find(CalendarSelectors.wrapper);
|
||||
template = template || root.attr('data-template');
|
||||
day = day || 1;
|
||||
M.util.js_pending([root.get('id'), year, month, courseid].join('-'));
|
||||
var includenavigation = root.data('includenavigation');
|
||||
var mini = root.data('mini');
|
||||
return CalendarRepository.getCalendarMonthData(year, month, courseid, categoryid, includenavigation, mini)
|
||||
return CalendarRepository.getCalendarMonthData(year, month, courseid, categoryid, includenavigation, mini, day)
|
||||
.then(function(context) {
|
||||
context.viewingmonth = true;
|
||||
return Templates.render(template, context);
|
||||
@@ -191,10 +194,12 @@ define([
|
||||
* @param {Number} month Month
|
||||
* @param {Number} courseid The id of the course whose events are shown
|
||||
* @param {Number} categoryid The id of the category whose events are shown
|
||||
* @param {Number} day Day (optional)
|
||||
* @return {promise}
|
||||
*/
|
||||
var changeMonth = function(root, url, year, month, courseid, categoryid) {
|
||||
return refreshMonthContent(root, year, month, courseid, categoryid)
|
||||
var changeMonth = function(root, url, year, month, courseid, categoryid, day) {
|
||||
day = day || 1;
|
||||
return refreshMonthContent(root, year, month, courseid, categoryid, null, null, day)
|
||||
.then(function() {
|
||||
if (url.length && url !== '#') {
|
||||
window.history.pushState({}, '', url);
|
||||
@@ -218,6 +223,7 @@ define([
|
||||
var reloadCurrentMonth = function(root, courseId, categoryId) {
|
||||
var year = root.find(CalendarSelectors.wrapper).data('year');
|
||||
var month = root.find(CalendarSelectors.wrapper).data('month');
|
||||
var day = root.find(CalendarSelectors.wrapper).data('day');
|
||||
|
||||
if (typeof courseId === 'undefined') {
|
||||
courseId = root.find(CalendarSelectors.wrapper).data('courseid');
|
||||
@@ -227,7 +233,7 @@ define([
|
||||
categoryId = root.find(CalendarSelectors.wrapper).data('categoryid');
|
||||
}
|
||||
|
||||
return refreshMonthContent(root, year, month, courseId, categoryId);
|
||||
return refreshMonthContent(root, year, month, courseId, categoryId, null, null, day);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -988,10 +988,11 @@ class core_calendar_external extends external_api {
|
||||
* @param int $categoryid The category to be included
|
||||
* @param bool $includenavigation Whether to include navigation
|
||||
* @param bool $mini Whether to return the mini month view or not
|
||||
* @param int $day The day we want to keep as the current day
|
||||
* @return array
|
||||
*/
|
||||
public static function get_calendar_monthly_view($year, $month, $courseid, $categoryid, $includenavigation, $mini) {
|
||||
global $DB, $USER, $PAGE;
|
||||
public static function get_calendar_monthly_view($year, $month, $courseid, $categoryid, $includenavigation, $mini, $day) {
|
||||
global $USER, $PAGE;
|
||||
|
||||
// Parameter validation.
|
||||
$params = self::validate_parameters(self::get_calendar_monthly_view_parameters(), [
|
||||
@@ -1001,6 +1002,7 @@ class core_calendar_external extends external_api {
|
||||
'categoryid' => $categoryid,
|
||||
'includenavigation' => $includenavigation,
|
||||
'mini' => $mini,
|
||||
'day' => $day,
|
||||
]);
|
||||
|
||||
$context = \context_user::instance($USER->id);
|
||||
@@ -1009,7 +1011,7 @@ class core_calendar_external extends external_api {
|
||||
|
||||
$type = \core_calendar\type_factory::get_calendar_instance();
|
||||
|
||||
$time = $type->convert_to_timestamp($params['year'], $params['month'], 1);
|
||||
$time = $type->convert_to_timestamp($params['year'], $params['month'], $params['day']);
|
||||
$calendar = \calendar_information::create($time, $params['courseid'], $params['categoryid']);
|
||||
self::validate_context($calendar->context);
|
||||
|
||||
@@ -1045,6 +1047,7 @@ class core_calendar_external extends external_api {
|
||||
false,
|
||||
NULL_ALLOWED
|
||||
),
|
||||
'day' => new external_value(PARAM_INT, 'Day to be viewed', VALUE_DEFAULT, 1),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
}} data-categoryid="{{categoryid}}"{{!
|
||||
}} data-month="{{date.mon}}"{{!
|
||||
}} data-year="{{date.year}}"{{!
|
||||
}} data-day="{{date.mday}}"{{!
|
||||
}} data-view="month"{{!
|
||||
}}>
|
||||
{{> core/overlay_loading}}
|
||||
|
||||
@@ -2372,7 +2372,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
|
||||
$data = external_api::clean_returnvalue(
|
||||
core_calendar_external::get_calendar_monthly_view_returns(),
|
||||
core_calendar_external::get_calendar_monthly_view($timestart->format('Y'), $timestart->format('n'),
|
||||
$course->id, null, false, true)
|
||||
$course->id, null, false, true, $timestart->format('d'))
|
||||
);
|
||||
$this->assertEquals($data['courseid'], $course->id);
|
||||
// User enrolled in the course can load the course calendar.
|
||||
@@ -2380,7 +2380,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
|
||||
$data = external_api::clean_returnvalue(
|
||||
core_calendar_external::get_calendar_monthly_view_returns(),
|
||||
core_calendar_external::get_calendar_monthly_view($timestart->format('Y'), $timestart->format('n'),
|
||||
$course->id, null, false, true)
|
||||
$course->id, null, false, true, $timestart->format('d'))
|
||||
);
|
||||
$this->assertEquals($data['courseid'], $course->id);
|
||||
// User not enrolled in the course cannot load the course calendar.
|
||||
@@ -2389,10 +2389,26 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
|
||||
$data = external_api::clean_returnvalue(
|
||||
core_calendar_external::get_calendar_monthly_view_returns(),
|
||||
core_calendar_external::get_calendar_monthly_view($timestart->format('Y'), $timestart->format('n'),
|
||||
$course->id, null, false, false)
|
||||
$course->id, null, false, false, $timestart->format('d'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_calendar_monthly_view when a day parameter is provided.
|
||||
*/
|
||||
public function test_get_calendar_monthly_view_with_day_provided() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$timestart = new DateTime();
|
||||
$data = external_api::clean_returnvalue(
|
||||
core_calendar_external::get_calendar_monthly_view_returns(),
|
||||
core_calendar_external::get_calendar_monthly_view($timestart->format('Y'), $timestart->format('n'),
|
||||
SITEID, null, false, true, $timestart->format('d'))
|
||||
);
|
||||
$this->assertEquals($data['date']['mday'], $timestart->format('d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* A user should not be able load the calendar day view for a course they cannot access.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user