Merge pull request #15944 from magnolia61/Sort_CMS_tables_alphabetically
[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 * $Id$
18 *
19 */
20
21 /**
22 * This class generates form components for scheduling reminders for Event
23 *
24 */
25 class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_ManageEvent {
26
27 /**
28 * Set variables up before form is built.
29 *
30 * @return void
31 */
32 public function preProcess() {
33 parent::preProcess();
34 $this->setSelectedChild('reminder');
35 $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0);
36
37 $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([
38 'id' => ($this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID),
39 ]));
40 $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id);
41 if ($reminderList && is_array($reminderList)) {
42 // Add action links to each of the reminders
43 foreach ($reminderList as & $format) {
44 $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
45 if ($format['is_active']) {
46 $action += CRM_Core_Action::DISABLE;
47 }
48 else {
49 $action += CRM_Core_Action::ENABLE;
50 }
51 $scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
52 $links = $scheduleReminder->links();
53 $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
54 $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
55 $format['action'] = CRM_Core_Action::formLink(
56 $links,
57 $action,
58 ['id' => $format['id']],
59 ts('more'),
60 FALSE,
61 'actionSchedule.manage.action',
62 'ActionSchedule',
63 $this->_id
64 );
65 }
66 }
67
68 $this->assign('rows', $reminderList);
69 $this->assign('setTab', $setTab);
70 $this->assign('component', 'event');
71
72 // Update tab "disabled" css class
73 $this->ajaxResponse['tabValid'] = is_array($reminderList) && (count($reminderList) > 0);
74 $this->setPageTitle(ts('Scheduled Reminder'));
75 }
76
77 /**
78 * @return string
79 */
80 public function getTemplateFileName() {
81 return 'CRM/Admin/Page/ScheduleReminders.tpl';
82 }
83
84 }