Merge pull request #18400 from aydun/class_api_tweak_2
[civicrm-core.git] / CRM / Event / Form / ManageEvent / ScheduleReminders.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 */
18
19 /**
20 * This class generates form components for scheduling reminders for Event
21 *
22 */
23 class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_ManageEvent {
24
25 /**
26 * Set variables up before form is built.
27 *
28 * @return void
29 */
30 public function preProcess() {
31 parent::preProcess();
32 $this->setSelectedChild('reminder');
33 $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0);
34
35 $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([
36 'id' => ($this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID),
37 ]));
38 $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id);
39 if ($reminderList && is_array($reminderList)) {
40 // Add action links to each of the reminders
41 foreach ($reminderList as & $format) {
42 $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
43 if ($format['is_active']) {
44 $action += CRM_Core_Action::DISABLE;
45 }
46 else {
47 $action += CRM_Core_Action::ENABLE;
48 }
49 $scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
50 $links = $scheduleReminder->links();
51 $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
52 $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
53 $format['action'] = CRM_Core_Action::formLink(
54 $links,
55 $action,
56 ['id' => $format['id']],
57 ts('more'),
58 FALSE,
59 'actionSchedule.manage.action',
60 'ActionSchedule',
61 $this->_id
62 );
63 }
64 }
65
66 $this->assign('rows', $reminderList);
67 $this->assign('setTab', $setTab);
68 $this->assign('component', 'event');
69
70 // Update tab "disabled" css class
71 $this->ajaxResponse['tabValid'] = is_array($reminderList) && (count($reminderList) > 0);
72 $this->setPageTitle(ts('Scheduled Reminder'));
73 }
74
75 /**
76 * @return string
77 */
78 public function getTemplateFileName() {
79 return 'CRM/Admin/Page/ScheduleReminders.tpl';
80 }
81
82 }