mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
Merge branch 'MDL-71790-master' of git://github.com/HuongNV13/moodle
This commit is contained in:
commit
be3f3b1283
@ -47,8 +47,6 @@ class managesubscriptions extends \moodleform {
|
||||
print_error('nopermissiontoupdatecalendar');
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'addsubscriptionform', get_string('importcalendarheading', 'calendar'));
|
||||
|
||||
// Name.
|
||||
$mform->addElement('text', 'name', get_string('subscriptionname', 'calendar'), array('maxsize' => '255', 'size' => '40'));
|
||||
$mform->addRule('name', get_string('required'), 'required');
|
||||
@ -86,7 +84,7 @@ class managesubscriptions extends \moodleform {
|
||||
$this->add_event_type_elements($mform, $eventtypes);
|
||||
|
||||
// Eventtype: 0 = user, 1 = site, anything else = course ID.
|
||||
$mform->addElement('submit', 'add', get_string('add'));
|
||||
$mform->addElement('submit', 'add', get_string('importcalendar', 'calendar'));
|
||||
|
||||
// Add the javascript required to enhance this mform.
|
||||
$PAGE->requires->js_call_amd('core_calendar/event_form', 'init', [$mform->getAttribute('id')]);
|
||||
|
131
calendar/import.php
Normal file
131
calendar/import.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Moodle calendar import
|
||||
*
|
||||
* @package core_calendar
|
||||
* @copyright Moodle Pty Ltd
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir . '/bennu/bennu.inc.php');
|
||||
require_once($CFG->dirroot . '/course/lib.php');
|
||||
require_once($CFG->dirroot . '/calendar/lib.php');
|
||||
|
||||
$courseid = optional_param('course', SITEID, PARAM_INT);
|
||||
$groupcourseid = optional_param('groupcourseid', 0, PARAM_INT);
|
||||
$category = optional_param('category', 0, PARAM_INT);
|
||||
$data = [];
|
||||
$pageurl = new moodle_url('/calendar/import.php');
|
||||
$managesubscriptionsurl = new moodle_url('/calendar/managesubscriptions.php');
|
||||
$calendarurl = new moodle_url('/calendar/view.php', ['view' => 'month']);
|
||||
navigation_node::override_active_url($calendarurl);
|
||||
|
||||
if ($courseid != SITEID && !empty($courseid)) {
|
||||
$course = get_course($courseid);
|
||||
$data['eventtype'] = 'course';
|
||||
$data['courseid'] = $course->id;
|
||||
$pageurl->param('course', $course->id);
|
||||
$managesubscriptionsurl->param('course', $course->id);
|
||||
} else {
|
||||
$course = get_site();
|
||||
}
|
||||
require_login($course, false);
|
||||
if (!calendar_user_can_add_event($course)) {
|
||||
throw new \moodle_exception('errorcannotimport', 'calendar');
|
||||
}
|
||||
|
||||
// Populate the 'group' select box based on the given 'groupcourseid', if necessary.
|
||||
$groups = [];
|
||||
if (!empty($groupcourseid)) {
|
||||
require_once($CFG->libdir . '/grouplib.php');
|
||||
$groupcoursedata = groups_get_course_data($groupcourseid);
|
||||
if (!empty($groupcoursedata->groups)) {
|
||||
foreach ($groupcoursedata->groups as $groupid => $groupdata) {
|
||||
$groups[$groupid] = $groupdata->name;
|
||||
}
|
||||
}
|
||||
$data['groupcourseid'] = $groupcourseid;
|
||||
$data['eventtype'] = 'group';
|
||||
$pageurl->param('groupcourseid', $groupcourseid);
|
||||
}
|
||||
if (!empty($category)) {
|
||||
$pageurl->param('category', $category);
|
||||
$managesubscriptionsurl->param('category', $category);
|
||||
$data['category'] = $category;
|
||||
$data['eventtype'] = 'category';
|
||||
}
|
||||
|
||||
$heading = get_string('importcalendar', 'calendar');
|
||||
$pagetitle = $course->shortname . ': ' . get_string('calendar', 'calendar') . ': ' . $heading;
|
||||
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($heading);
|
||||
$PAGE->set_url($pageurl);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'), $managesubscriptionsurl);
|
||||
$PAGE->navbar->add($heading);
|
||||
|
||||
$customdata = [
|
||||
'courseid' => $course->id,
|
||||
'groups' => $groups,
|
||||
];
|
||||
|
||||
$form = new \core_calendar\local\event\forms\managesubscriptions(null, $customdata);
|
||||
$form->set_data($data);
|
||||
|
||||
$formdata = $form->get_data();
|
||||
if (!empty($formdata)) {
|
||||
require_sesskey();
|
||||
$subscriptionid = calendar_add_subscription($formdata);
|
||||
if ($formdata->importfrom == CALENDAR_IMPORT_FROM_FILE) {
|
||||
// Blank the URL if it's a file import.
|
||||
$formdata->url = '';
|
||||
$calendar = $form->get_file_content('importfile');
|
||||
$ical = new iCalendar();
|
||||
$ical->unserialize($calendar);
|
||||
$importresults = calendar_import_icalendar_events($ical, null, $subscriptionid);
|
||||
} else {
|
||||
try {
|
||||
$importresults = calendar_update_subscription_events($subscriptionid);
|
||||
} catch (\moodle_exception $e) {
|
||||
// Delete newly added subscription and show invalid url error.
|
||||
calendar_delete_subscription($subscriptionid);
|
||||
throw new \moodle_exception($e->errorcode, $e->module, $PAGE->url);
|
||||
}
|
||||
}
|
||||
if (!empty($formdata->courseid)) {
|
||||
$managesubscriptionsurl->param('course', $formdata->courseid);
|
||||
}
|
||||
if (!empty($formdata->categoryid)) {
|
||||
$managesubscriptionsurl->param('category', $formdata->categoryid);
|
||||
}
|
||||
redirect($managesubscriptionsurl, $importresults);
|
||||
}
|
||||
|
||||
$calendarsubscriptions = get_string('calendarsubscriptions', 'calendar');
|
||||
|
||||
$renderer = $PAGE->get_renderer('core_calendar');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $renderer->start_layout();
|
||||
echo $OUTPUT->heading($heading);
|
||||
$form->display();
|
||||
echo $OUTPUT->spacer(null, true);
|
||||
echo $OUTPUT->action_link($managesubscriptionsurl, $OUTPUT->larrow() . ' ' . $calendarsubscriptions);
|
||||
echo $renderer->complete_layout();
|
||||
echo $OUTPUT->footer();
|
@ -3101,6 +3101,7 @@ function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid
|
||||
}
|
||||
}
|
||||
|
||||
$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');
|
||||
@ -3115,14 +3116,15 @@ function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid
|
||||
}
|
||||
if (!empty($tobedeleted)) {
|
||||
$DB->delete_records_list('event', 'id', $tobedeleted);
|
||||
$return .= "<p> " . get_string('eventsdeleted', 'calendar') . ": " . count($tobedeleted) . "</p> ";
|
||||
$return .= html_writer::tag('li', get_string('eventsdeleted', 'calendar', count($tobedeleted)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return .= "<p>" . get_string('eventsimported', 'calendar', $eventcount) . "</p> ";
|
||||
$return .= "<p>" . get_string('eventsskipped', 'calendar', $skippedcount) . "</p> ";
|
||||
$return .= "<p>" . get_string('eventsupdated', 'calendar', $updatecount) . "</p>";
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -3931,3 +3933,22 @@ function calendar_get_export_token(stdClass $user): string {
|
||||
|
||||
return sha1($user->id . $DB->get_field('user', 'password', ['id' => $user->id]) . $CFG->calendar_exportsalt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of URL parameters for calendar expport and import links.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function calendar_get_export_import_link_params(): array {
|
||||
global $PAGE;
|
||||
|
||||
$params = [];
|
||||
if ($courseid = $PAGE->url->get_param('course')) {
|
||||
$params['course'] = $courseid;
|
||||
}
|
||||
if ($categoryid = $PAGE->url->get_param('category')) {
|
||||
$params['category'] = $categoryid;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
* @package calendar
|
||||
*/
|
||||
|
||||
use core\notification;
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/bennu/bennu.inc.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
@ -33,7 +35,6 @@ $categoryid = optional_param('category', null, PARAM_INT);
|
||||
// Used for processing subscription actions.
|
||||
$subscriptionid = optional_param('id', 0, PARAM_INT);
|
||||
$pollinterval = optional_param('pollinterval', 0, PARAM_INT);
|
||||
$groupcourseid = optional_param('groupcourseid', 0, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_INT);
|
||||
|
||||
$url = new moodle_url('/calendar/managesubscriptions.php');
|
||||
@ -62,56 +63,15 @@ if (!calendar_user_can_add_event($course)) {
|
||||
print_error('errorcannotimport', 'calendar');
|
||||
}
|
||||
|
||||
// Populate the 'group' select box based on the given 'groupcourseid', if necessary.
|
||||
$groups = [];
|
||||
if (!empty($groupcourseid)) {
|
||||
require_once($CFG->libdir . '/grouplib.php');
|
||||
$groupcoursedata = groups_get_course_data($groupcourseid);
|
||||
if (!empty($groupcoursedata->groups)) {
|
||||
foreach ($groupcoursedata->groups as $groupid => $groupdata) {
|
||||
$groups[$groupid] = $groupdata->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
$customdata = [
|
||||
'courseid' => $course->id,
|
||||
'groups' => $groups,
|
||||
];
|
||||
$form = new \core_calendar\local\event\forms\managesubscriptions($url, $customdata);
|
||||
$form->set_data(array(
|
||||
'course' => $course->id
|
||||
));
|
||||
|
||||
$importresults = '';
|
||||
|
||||
$formdata = $form->get_data();
|
||||
if (!empty($formdata)) {
|
||||
require_sesskey(); // Must have sesskey for all actions.
|
||||
$subscriptionid = calendar_add_subscription($formdata);
|
||||
if ($formdata->importfrom == CALENDAR_IMPORT_FROM_FILE) {
|
||||
// Blank the URL if it's a file import.
|
||||
$formdata->url = '';
|
||||
$calendar = $form->get_file_content('importfile');
|
||||
$ical = new iCalendar();
|
||||
$ical->unserialize($calendar);
|
||||
$importresults = calendar_import_icalendar_events($ical, null, $subscriptionid);
|
||||
} else {
|
||||
try {
|
||||
$importresults = calendar_update_subscription_events($subscriptionid);
|
||||
} catch (moodle_exception $e) {
|
||||
// Delete newly added subscription and show invalid url error.
|
||||
calendar_delete_subscription($subscriptionid);
|
||||
print_error($e->errorcode, $e->module, $PAGE->url);
|
||||
}
|
||||
}
|
||||
// Redirect to prevent refresh issues.
|
||||
redirect($PAGE->url, $importresults);
|
||||
} else if (!empty($subscriptionid)) {
|
||||
if (!empty($subscriptionid)) {
|
||||
// The user is wanting to perform an action upon an existing subscription.
|
||||
require_sesskey(); // Must have sesskey for all actions.
|
||||
if (calendar_can_edit_subscription($subscriptionid)) {
|
||||
try {
|
||||
$importresults = calendar_process_subscription_row($subscriptionid, $pollinterval, $action);
|
||||
notification::add($importresults, \core\output\notification::NOTIFY_INFO);
|
||||
} catch (moodle_exception $e) {
|
||||
// If exception caught, then user should be redirected to page where he/she came from.
|
||||
print_error($e->errorcode, $e->module, $PAGE->url);
|
||||
@ -196,6 +156,7 @@ $PAGE->set_heading($course->fullname);
|
||||
$renderer = $PAGE->get_renderer('core_calendar');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $renderer->render_subscriptions_header();
|
||||
|
||||
// Filter subscriptions which user can't edit.
|
||||
foreach($subscriptions as $subscription) {
|
||||
@ -205,7 +166,9 @@ foreach($subscriptions as $subscription) {
|
||||
}
|
||||
|
||||
// Display a table of subscriptions.
|
||||
echo $renderer->subscription_details($courseid, $subscriptions, $importresults);
|
||||
// Display the add subscription form.
|
||||
$form->display();
|
||||
if (empty($subscription)) {
|
||||
echo $renderer->render_no_calendar_subscriptions();
|
||||
} else {
|
||||
echo $renderer->subscription_details($courseid, $subscriptions);
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -308,15 +308,52 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
return $select;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the subscriptions header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render_subscriptions_header(): string {
|
||||
$importcalendarbutton = new single_button(new moodle_url('/calendar/import.php', calendar_get_export_import_link_params()),
|
||||
get_string('importcalendar', 'calendar'), 'get', true);
|
||||
$importcalendarbutton->class .= ' float-sm-right float-right';
|
||||
$exportcalendarbutton = new single_button(new moodle_url('/calendar/export.php', calendar_get_export_import_link_params()),
|
||||
get_string('exportcalendar', 'calendar'), 'get', true);
|
||||
$exportcalendarbutton->class .= ' float-sm-right float-right';
|
||||
$output = $this->output->heading(get_string('managesubscriptions', 'calendar'));
|
||||
$output .= html_writer::start_div('header d-flex flex-wrap mt-5');
|
||||
$output .= html_writer::tag('h3', get_string('yoursubscriptions', 'calendar'), ['class' => 'mr-auto']);
|
||||
$output .= $this->output->render($importcalendarbutton);
|
||||
$output .= $this->output->render($exportcalendarbutton);
|
||||
$output .= html_writer::end_div();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the subscriptions blank state appearance
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render_no_calendar_subscriptions(): string {
|
||||
$output = html_writer::start_div('mt-5');
|
||||
$importlink = html_writer::link((new moodle_url('/calendar/import.php', calendar_get_export_import_link_params()))->out(),
|
||||
get_string('importcalendarexternal', 'calendar'));
|
||||
$output .= get_string('nocalendarsubscriptions', 'calendar', $importlink);
|
||||
$output .= html_writer::end_div();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a table containing information about calendar subscriptions.
|
||||
*
|
||||
* @param int $unused
|
||||
* @param array $subscriptions
|
||||
* @param string $importresults
|
||||
* @param string $unused2
|
||||
* @return string
|
||||
*/
|
||||
public function subscription_details($unused, $subscriptions, $importresults = '') {
|
||||
public function subscription_details($unused, $subscriptions, $unused2 = '') {
|
||||
$table = new html_table();
|
||||
$table->head = array(
|
||||
get_string('colcalendar', 'calendar'),
|
||||
@ -325,9 +362,10 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
get_string('colpoll', 'calendar'),
|
||||
get_string('colactions', 'calendar')
|
||||
);
|
||||
$table->align = array('left', 'left', 'left', 'center');
|
||||
$table->align = array('left', 'left', 'left', 'left', 'left');
|
||||
$table->width = '100%';
|
||||
$table->data = array();
|
||||
$table->id = 'subscription_details_table';
|
||||
|
||||
if (empty($subscriptions)) {
|
||||
$cell = new html_table_cell(get_string('nocalendarsubscriptions', 'calendar'));
|
||||
@ -346,26 +384,56 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
$lastupdated = userdate($sub->lastupdated, get_string('strftimedatetimeshort', 'langconfig'));
|
||||
}
|
||||
|
||||
$cell = new html_table_cell($this->subscription_action_form($sub));
|
||||
$cell->colspan = 2;
|
||||
$type = $sub->eventtype . 'events';
|
||||
|
||||
$table->data[] = new html_table_row(array(
|
||||
new html_table_cell($label),
|
||||
new html_table_cell($lastupdated),
|
||||
new html_table_cell(get_string($type, 'calendar')),
|
||||
$cell
|
||||
new html_table_cell($this->render_subscription_update_interval($sub)),
|
||||
new html_table_cell($this->subscription_action_form($sub))
|
||||
));
|
||||
}
|
||||
|
||||
$out = $this->output->box_start('generalbox calendarsubs');
|
||||
|
||||
$out .= $importresults;
|
||||
$out .= html_writer::table($table);
|
||||
$out .= $this->output->box_end();
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render subscription update interval form.
|
||||
*
|
||||
* @param stdClass $subscription
|
||||
* @return string
|
||||
*/
|
||||
protected function render_subscription_update_interval(stdClass $subscription): string {
|
||||
// Assemble form for the subscription row.
|
||||
$output = html_writer::start_tag('form',
|
||||
['action' => new moodle_url('/calendar/managesubscriptions.php', calendar_get_export_import_link_params()),
|
||||
'method' => 'post']);
|
||||
if (empty($subscription->url)) {
|
||||
$output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'pollinterval', 'value' => '0']);
|
||||
} else {
|
||||
// Assemble pollinterval control.
|
||||
$output .= html_writer::start_div();
|
||||
$output .= html_writer::start_tag('select', ['name' => 'pollinterval', 'class' => 'custom-select']);
|
||||
foreach (calendar_get_pollinterval_choices() as $k => $v) {
|
||||
$attributes = array();
|
||||
if ($k == $subscription->pollinterval) {
|
||||
$attributes['selected'] = 'selected';
|
||||
}
|
||||
$attributes['value'] = $k;
|
||||
$output .= html_writer::tag('option', $v, $attributes);
|
||||
}
|
||||
$output .= html_writer::end_tag('select');
|
||||
$output .= html_writer::end_div();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to perform actions on a given subscription.
|
||||
*
|
||||
@ -373,37 +441,17 @@ class core_calendar_renderer extends plugin_renderer_base {
|
||||
* @return string
|
||||
*/
|
||||
protected function subscription_action_form($subscription) {
|
||||
// Assemble form for the subscription row.
|
||||
$html = html_writer::start_tag('form', ['action' => $this->page->url->out(false) , 'method' => 'post']);
|
||||
if (empty($subscription->url)) {
|
||||
// Don't update an iCal file, which has no URL.
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'pollinterval', 'value' => '0'));
|
||||
} else {
|
||||
// Assemble pollinterval control.
|
||||
$html .= html_writer::start_tag('div', array('style' => 'float:left;'));
|
||||
$html .= html_writer::start_tag('select', array('name' => 'pollinterval', 'class' => 'custom-select'));
|
||||
foreach (calendar_get_pollinterval_choices() as $k => $v) {
|
||||
$attributes = array();
|
||||
if ($k == $subscription->pollinterval) {
|
||||
$attributes['selected'] = 'selected';
|
||||
}
|
||||
$attributes['value'] = $k;
|
||||
$html .= html_writer::tag('option', $v, $attributes);
|
||||
}
|
||||
$html .= html_writer::end_tag('select');
|
||||
$html .= html_writer::end_tag('div');
|
||||
}
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
$html = html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'id', 'value' => $subscription->id));
|
||||
$html .= html_writer::start_tag('div', array('class' => 'btn-group float-right'));
|
||||
$html .= html_writer::start_tag('div', array('class' => 'btn-group float-left'));
|
||||
if (!empty($subscription->url)) {
|
||||
$html .= html_writer::tag('button', get_string('update'), array('type' => 'submit', 'name' => 'action',
|
||||
'class' => 'btn btn-secondary',
|
||||
'value' => CALENDAR_SUBSCRIPTION_UPDATE));
|
||||
$html .= html_writer::tag('button', get_string('update'), array('type' => 'submit', 'name' => 'action',
|
||||
'class' => 'btn btn-link',
|
||||
'value' => CALENDAR_SUBSCRIPTION_UPDATE));
|
||||
}
|
||||
$html .= html_writer::tag('button', get_string('remove'), array('type' => 'submit', 'name' => 'action',
|
||||
'class' => 'btn btn-secondary',
|
||||
'value' => CALENDAR_SUBSCRIPTION_REMOVE));
|
||||
$html .= html_writer::tag('button', get_string('remove'), array('type' => 'submit', 'name' => 'action',
|
||||
'class' => 'btn btn-link',
|
||||
'value' => CALENDAR_SUBSCRIPTION_REMOVE));
|
||||
$html .= html_writer::end_tag('div');
|
||||
$html .= html_writer::end_tag('form');
|
||||
return $html;
|
||||
|
@ -19,13 +19,14 @@ Feature: Import and edit calendar events
|
||||
Given I log in as "teacher1"
|
||||
And I view the calendar for "1" "2016"
|
||||
And I click on "Manage subscriptions" "link"
|
||||
And I press "Import calendar"
|
||||
And I set the following fields to these values:
|
||||
| Calendar name | Test Import |
|
||||
| Import from | Calendar file (.ics) |
|
||||
| Type of event | User |
|
||||
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
|
||||
And I press "Add"
|
||||
And I should see "Events imported: 2"
|
||||
And I press "Import calendar"
|
||||
And I should see "2 events were imported"
|
||||
And I view the calendar for "2" "2017"
|
||||
And I should see "February 2017"
|
||||
And I should see "Event on 2-15-2017"
|
||||
@ -52,25 +53,28 @@ Feature: Import and edit calendar events
|
||||
Given I log in as "admin"
|
||||
And I view the calendar for "1" "2016"
|
||||
And I click on "Manage subscriptions" "link"
|
||||
And I press "Import calendar"
|
||||
And I set the following fields to these values:
|
||||
| Calendar name | Test Import |
|
||||
| Import from | Calendar file (.ics) |
|
||||
| Type of event | User |
|
||||
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
|
||||
And I press "Add"
|
||||
And I press "Import calendar"
|
||||
And I should see "User events"
|
||||
And I press "Import calendar"
|
||||
And I set the following fields to these values:
|
||||
| Calendar name | Test Import |
|
||||
| Import from | Calendar file (.ics) |
|
||||
| Type of event | Category |
|
||||
| Category | Miscellaneous |
|
||||
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
|
||||
And I press "Add"
|
||||
And I press "Import calendar"
|
||||
And I should see "Category events"
|
||||
And I press "Import calendar"
|
||||
And I set the following fields to these values:
|
||||
| Calendar name | Test Import |
|
||||
| Import from | Calendar file (.ics) |
|
||||
| Type of event | Site |
|
||||
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
|
||||
And I press "Add"
|
||||
And I press "Import calendar"
|
||||
And I should see "Site events"
|
||||
|
@ -242,9 +242,9 @@ class core_calendar_lib_testcase extends advanced_testcase {
|
||||
$sub = calendar_get_subscription($id);
|
||||
$output = calendar_import_icalendar_events($ical, null, $sub->id);
|
||||
$this->assertStringNotContainsString('Events deleted: 17', $output);
|
||||
$this->assertStringContainsString('Events imported: 1', $output);
|
||||
$this->assertStringContainsString('Events skipped: 0', $output);
|
||||
$this->assertStringContainsString('Events updated: 0', $output);
|
||||
$this->assertStringContainsString('1 events were imported', $output);
|
||||
$this->assertStringContainsString('0 events were skipped', $output);
|
||||
$this->assertStringContainsString('0 events were updated', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ $string['calendar'] = 'Calendar';
|
||||
$string['calendarheading'] = '{$a} Calendar';
|
||||
$string['calendarpreferences'] = 'Calendar preferences';
|
||||
$string['calendartypes'] = 'Calendar types';
|
||||
$string['calendarsubscriptions'] = 'Calendar subscriptions';
|
||||
$string['calendarurl'] = 'Calendar URL: {$a}';
|
||||
$string['category'] = 'Category';
|
||||
$string['categoryevent'] = 'Category event';
|
||||
@ -113,11 +114,11 @@ $string['eventnone'] = 'No events';
|
||||
$string['eventrepeat'] = 'Repeats';
|
||||
$string['events'] = 'Events';
|
||||
$string['eventsall'] = 'All events';
|
||||
$string['eventsdeleted'] = 'Events deleted';
|
||||
$string['eventsimported'] = 'Events imported: {$a}';
|
||||
$string['eventsdeleted'] = '{$a} events were deleted';
|
||||
$string['eventsimported'] = '{$a} events were imported';
|
||||
$string['eventsource'] = 'Event source';
|
||||
$string['eventsskipped'] = 'Events skipped: {$a}';
|
||||
$string['eventsupdated'] = 'Events updated: {$a}';
|
||||
$string['eventsskipped'] = '{$a} events were skipped';
|
||||
$string['eventsupdated'] = '{$a} events were updated';
|
||||
$string['eventsfor'] = '{$a} events';
|
||||
$string['eventskey'] = 'Events key';
|
||||
$string['eventspersonal'] = 'My personal events';
|
||||
@ -161,6 +162,7 @@ $string['eventtypeuser'] = 'user';
|
||||
$string['hideeventtype'] = 'Hide {$a} events';
|
||||
$string['showeventtype'] = 'Show {$a} events';
|
||||
$string['hourly'] = 'Hourly';
|
||||
$string['importcalendarexternal'] = 'Import an external calendar?';
|
||||
$string['importcalendar'] = 'Import calendar';
|
||||
$string['importcalendarheading'] = 'Import calendar...';
|
||||
$string['importcalendarfrom'] = 'Import from';
|
||||
@ -187,7 +189,7 @@ $string['never'] = 'Never';
|
||||
$string['newevent'] = 'New event';
|
||||
$string['notitle'] = 'no title';
|
||||
$string['noupcomingevents'] = 'There are no upcoming events';
|
||||
$string['nocalendarsubscriptions'] = 'You have no calendar subscriptions.';
|
||||
$string['nocalendarsubscriptions'] = 'No calendar subscriptions yet. Do you want to {$a}';
|
||||
$string['oneevent'] = '1 event';
|
||||
$string['pollinterval'] = 'Update interval';
|
||||
$string['pollinterval_help'] = 'How often you would like the calendar to update with new events.';
|
||||
@ -234,7 +236,7 @@ $string['subscriptions'] = 'Subscriptions';
|
||||
$string['subscriptionname'] = 'Calendar name';
|
||||
$string['subscriptionremoved'] = 'Calendar subscription {$a} removed';
|
||||
$string['subscriptionsource'] = 'Event source: {$a}';
|
||||
$string['subscriptionupdated'] = 'Calendar subscription {$a} updated';
|
||||
$string['subscriptionupdated'] = 'The \'{$a}\' calendar subscription has been updated';
|
||||
$string['sun'] = 'Sun';
|
||||
$string['sunday'] = 'Sunday';
|
||||
$string['thu'] = 'Thu';
|
||||
@ -274,6 +276,7 @@ $string['when'] = 'When';
|
||||
$string['whendate'] = 'When: {$a}';
|
||||
$string['yesterday'] = 'Yesterday';
|
||||
$string['youcandeleteallrepeats'] = 'This event is part of a repeating event series. You can delete this event only, or all {$a} events in the series at once.';
|
||||
$string['yoursubscriptions'] = 'Your Subscriptions';
|
||||
|
||||
// Deprecated since Moodle 3.8.
|
||||
$string['global'] = 'Global';
|
||||
|
@ -58,7 +58,7 @@ class core_calendar_cron_task_testcase extends advanced_testcase {
|
||||
$subscription->lastupdated = 0;
|
||||
calendar_add_subscription($subscription);
|
||||
|
||||
$this->expectOutputRegex('/Events imported: .* Events skipped: .* Events updated:/');
|
||||
$this->expectOutputRegex('/.* events were imported.* events were skipped.* events were updated/');
|
||||
$task = new \core\task\calendar_cron_task();
|
||||
$task->execute();
|
||||
}
|
||||
|
@ -300,6 +300,16 @@ $calendarEventColor: #0d5ca1 !default;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
table#subscription_details_table {
|
||||
td {
|
||||
vertical-align: middle;
|
||||
|
||||
> .btn-group button {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calendar export.
|
||||
|
@ -13008,6 +13008,11 @@ input[disabled] {
|
||||
word-break: break-all;
|
||||
overflow-wrap: break-word; }
|
||||
|
||||
.path-calendar table#subscription_details_table td {
|
||||
vertical-align: middle; }
|
||||
.path-calendar table#subscription_details_table td > .btn-group button {
|
||||
padding-left: 0; }
|
||||
|
||||
#page-calendar-export .indent {
|
||||
padding-left: 20px; }
|
||||
|
||||
|
@ -13230,6 +13230,11 @@ input[disabled] {
|
||||
word-break: break-all;
|
||||
overflow-wrap: break-word; }
|
||||
|
||||
.path-calendar table#subscription_details_table td {
|
||||
vertical-align: middle; }
|
||||
.path-calendar table#subscription_details_table td > .btn-group button {
|
||||
padding-left: 0; }
|
||||
|
||||
#page-calendar-export .indent {
|
||||
padding-left: 20px; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user