| @@ -1,0 +1,94 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @package VikBooking | |
| 4 | + * @subpackage com_vikbooking | |
| 5 | + * @author Alessio Gaggii - e4j - Extensionsforjoomla.com | |
| 6 | + * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. | |
| 7 | + * @license GNU General Public License version 2 or later; see LICENSE | |
| 8 | + * @link https://vikwp.com | |
| 9 | + */ | |
| 10 | + | |
| 11 | +defined('ABSPATH') or die('No script kiddies please!'); | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Class handler for conditional rule "extra email". | |
| 15 | + * | |
| 16 | + * @since 1.4.0 | |
| 17 | + */ | |
| 18 | +class VikBookingConditionalRuleExtraEmail extends VikBookingConditionalRule | |
| 19 | +{ | |
| 20 | + /** | |
| 21 | + * Class constructor will define the rule name, description and identifier. | |
| 22 | + */ | |
| 23 | + public function __construct() | |
| 24 | + { | |
| 25 | + // call parent constructor | |
| 26 | + parent::__construct(); | |
| 27 | + | |
| 28 | + $this->ruleName = JText::translate('VBO_CONDTEXT_RULE_EXTRAMAIL'); | |
| 29 | + $this->ruleDescr = JText::translate('VBO_CONDTEXT_RULE_EXTRAMAIL_DESCR'); | |
| 30 | + $this->ruleId = basename(__FILE__); | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * Displays the rule parameters. | |
| 35 | + * | |
| 36 | + * @return void | |
| 37 | + */ | |
| 38 | + public function renderParams() | |
| 39 | + { | |
| 40 | + ?> | |
| 41 | + <div class="vbo-param-container"> | |
| 42 | + <div class="vbo-param-label"><?php echo JText::translate('VBCUSTOMEREMAIL'); ?></div> | |
| 43 | + <div class="vbo-param-setting"> | |
| 44 | + <input type="text" name="<?php echo $this->inputName('extra_email'); ?>" value="<?php echo $this->getParam('extra_email', ''); ?>" /> | |
| 45 | + <span class="vbo-param-setting-comment"><?php echo JText::translate('VBO_CONDTEXT_RULE_SEPEMAIL'); ?></span> | |
| 46 | + </div> | |
| 47 | + </div> | |
| 48 | + <div class="vbo-param-container"> | |
| 49 | + <div class="vbo-param-label"><?php echo JText::translate('VBO_CONDTEXT_RULE_BCCEMAIL'); ?></div> | |
| 50 | + <div class="vbo-param-setting"> | |
| 51 | + <?php echo $this->vbo_app->printYesNoButtons($this->inputName('bcc'), JText::translate('VBYES'), JText::translate('VBNO'), (int)$this->getParam('bcc', 0), 1, 0); ?> | |
| 52 | + </div> | |
| 53 | + </div> | |
| 54 | + <?php | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Tells whether the rule is compliant. | |
| 59 | + * | |
| 60 | + * @return bool True on success, false otherwise. | |
| 61 | + */ | |
| 62 | + public function isCompliant() | |
| 63 | + { | |
| 64 | + // this is not a real filter-rule, so we always return true | |
| 65 | + return true; | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Override callback action method to set the additional email addresses. | |
| 70 | + * | |
| 71 | + * @return void | |
| 72 | + */ | |
| 73 | + public function callbackAction() | |
| 74 | + { | |
| 75 | + $extra_recipients = $this->getParam('extra_email', ''); | |
| 76 | + if (empty($extra_recipients)) { | |
| 77 | + return; | |
| 78 | + } | |
| 79 | + | |
| 80 | + if (strpos($extra_recipients, ',') !== false) { | |
| 81 | + $extra_recipients = explode(',', $extra_recipients); | |
| 82 | + } elseif (strpos($extra_recipients, ';') !== false) { | |
| 83 | + $extra_recipients = explode(';', $extra_recipients); | |
| 84 | + } else { | |
| 85 | + $extra_recipients = array($extra_recipients); | |
| 86 | + } | |
| 87 | + | |
| 88 | + // register additional email recipients | |
| 89 | + VikBooking::addAdminEmailRecipient($extra_recipients, (bool)$this->getParam('bcc', 0)); | |
| 90 | + | |
| 91 | + return; | |
| 92 | + } | |
| 93 | + | |
| 94 | +} | |