-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-744 Create first integrated template to ship booking with preconfi…
…gured rules-templates
- Loading branch information
1 parent
cce2a69
commit c8b897b
Showing
6 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
classes/booking_rules/rules/templates/ruletemplate_confirmbooking.php
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,94 @@ | ||
<?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/>. | ||
|
||
namespace mod_booking\booking_rules\rules\templates; | ||
|
||
use context; | ||
use mod_booking\booking_rules\actions_info; | ||
use mod_booking\booking_rules\conditions_info; | ||
use mod_booking\singleton_service; | ||
use MoodleQuickForm; | ||
use stdClass; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->dirroot . '/mod/booking/lib.php'); | ||
|
||
/** | ||
* Rule do something a specified number of days before a chosen date. | ||
* | ||
* @package mod_booking | ||
* @copyright 2022 Wunderbyte GmbH <[email protected]> | ||
* @author Georg Maißer | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class ruletemplate_confirmbooking { | ||
/** @var int $templateid */ | ||
public static $templateid = 1; | ||
|
||
/** @var int $eventtype */ | ||
public static $eventtype = 'rule_react_on_event'; | ||
|
||
/** | ||
* Returns the localized name of this template | ||
* | ||
* @return string | ||
* | ||
*/ | ||
public static function get_name() { | ||
return get_string('ruletemplateconfirmbooking', 'booking'); | ||
} | ||
|
||
/** | ||
* Returns the template as if it came from DB. | ||
* | ||
* @return object | ||
* | ||
*/ | ||
public static function return_template() { | ||
|
||
$rulejson = (object)[ | ||
"conditionname" => "select_user_from_event", | ||
"conditiondata" => [ | ||
"userfromeventtype" => "relateduserid", | ||
], | ||
"name" => self::get_name(), | ||
"actionname" => "send_mail", | ||
"actiondata" => [ | ||
"subject" => get_string('ruletemplateconfirmbookingsubject', 'booking'), | ||
"template" => get_string('ruletemplateconfirmbookingbody', 'booking'), | ||
"templateformat" => "1", | ||
], | ||
"rulename" => "rule_react_on_event", | ||
"ruledata" => [ | ||
"boevent" => "\\mod_booking\\event\bookingoption_booked", | ||
"condition" => "0", | ||
"aftercompletion" => 0, | ||
"cancelrules" => [], | ||
], | ||
]; | ||
|
||
$returnobject = [ | ||
'id' => self::$templateid, | ||
'rulename' => self::$eventtype, | ||
'rulejson' => json_encode($rulejson), | ||
'eventname' => "\\mod_booking\\event\bookingoption_booked", | ||
'contextid' => 1, | ||
'useastemplate' => 0, | ||
]; | ||
return (object) $returnobject; | ||
} | ||
} |
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