Merge pull request #11772 from michaelmcandrew/CRM-21821-respect-nav-item-weight
[civicrm-core.git] / CRM / Event / Form / ManageEvent / ScheduleReminders.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2018
33 * $Id$
34 *
35 */
36
37 /**
38 * This class generates form components for scheduling reminders for Event
39 *
40 */
41 class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_ManageEvent {
42
43 /**
44 * Set variables up before form is built.
45 *
46 * @return void
47 */
48 public function preProcess() {
49 parent::preProcess();
50 $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0);
51
52 $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array(
53 'id' => ($this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID),
54 )));
55 $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id);
56 if ($reminderList && is_array($reminderList)) {
57 // Add action links to each of the reminders
58 foreach ($reminderList as & $format) {
59 $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
60 if ($format['is_active']) {
61 $action += CRM_Core_Action::DISABLE;
62 }
63 else {
64 $action += CRM_Core_Action::ENABLE;
65 }
66 $scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
67 $links = $scheduleReminder->links();
68 $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
69 $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
70 $format['action'] = CRM_Core_Action::formLink(
71 $links,
72 $action,
73 array('id' => $format['id']),
74 ts('more'),
75 FALSE,
76 'actionSchedule.manage.action',
77 'ActionSchedule',
78 $this->_id
79 );
80 }
81 }
82
83 $this->assign('rows', $reminderList);
84 $this->assign('setTab', $setTab);
85 $this->assign('component', 'event');
86
87 // Update tab "disabled" css class
88 $this->ajaxResponse['tabValid'] = is_array($reminderList) && (count($reminderList) > 0);
89 $this->setPageTitle(ts('Scheduled Reminder'));
90 }
91
92 /**
93 * @return string
94 */
95 public function getTemplateFileName() {
96 return 'CRM/Admin/Page/ScheduleReminders.tpl';
97 }
98
99 }