mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-59750 core_calendar: better handling of event subscription
- Loading branch information
Showing
10 changed files
with
151 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Contains event class for displaying a calendar event's subscription. | ||
* | ||
* @package core_calendar | ||
* @copyright 2017 Simey Lameze <simey@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace core_calendar\external; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
use \core\external\exporter; | ||
use \core_calendar\local\event\entities\event_interface; | ||
|
||
/** | ||
* Class for displaying a calendar event's subscription. | ||
* | ||
* @package core_calendar | ||
* @copyright 2017 Simey Lameze <simey@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class event_subscription_exporter extends exporter { | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param event_interface $event | ||
*/ | ||
public function __construct(event_interface $event) { | ||
global $CFG; | ||
|
||
$data = new \stdClass(); | ||
$data->displayeventsource = false; | ||
if ($event->get_subscription()) { | ||
$subscription = calendar_get_subscription($event->get_subscription()->get('id')); | ||
if (!empty($subscription) && $CFG->calendar_showicalsource) { | ||
$data->displayeventsource = true; | ||
if (!empty($subscription->url)) { | ||
$data->url = $subscription->url; | ||
} | ||
$data->name = $subscription->name; | ||
} | ||
} | ||
|
||
parent::__construct($data); | ||
} | ||
|
||
/** | ||
* Return the list of properties. | ||
* | ||
* @return array | ||
*/ | ||
protected static function define_properties() { | ||
return [ | ||
'displayeventsource' => [ | ||
'type' => PARAM_BOOL | ||
], | ||
'name' => [ | ||
'type' => PARAM_RAW, | ||
'optional' => true | ||
], | ||
'url' => [ | ||
'type' => PARAM_URL, | ||
'optional' => true | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{{! | ||
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/>. | ||
}} | ||
{{! | ||
@template calendar/event_subscription | ||
Calendar event subscription. | ||
The purpose of this template is to render the event subscription data. | ||
Classes required for JS: | ||
* none | ||
Data attributes required for JS: | ||
* none | ||
Example context (json): | ||
{ | ||
} | ||
}} | ||
|
||
{{#subscription}} | ||
{{#displayeventsource}} | ||
<div> | ||
{{#name}} | ||
<p>{{#str}}subscriptionsource, core_calendar, {{name}}{{/str}}</p> | ||
{{/name}} | ||
{{#url}} | ||
<p><a href="{{url}}">{{#str}}subscriptionsource, core_calendar, {{name}}{{/str}}</a></p> | ||
{{/url}} | ||
</div> | ||
{{/displayeventsource}} | ||
{{/subscription}} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters