Merge pull request #23509 from eileenmcnaughton/import_except
[civicrm-core.git] / CRM / Admin / Page / 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 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Page for displaying list of Reminders.
20 */
21 class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic {
22
23 public $useLivePageJS = TRUE;
24
25 /**
26 * The action links that we need to display for the browse screen.
27 *
28 * @var array
29 */
30 public static $_links = NULL;
31
32 /**
33 * Get BAO Name.
34 *
35 * @return string
36 * Classname of BAO.
37 */
38 public function getBAOName() {
39 return 'CRM_Core_BAO_ActionSchedule';
40 }
41
42 /**
43 * Get action Links.
44 *
45 * @return array
46 * (reference) of action links
47 */
48 public function &links() {
49 if (!(self::$_links)) {
50 // helper variable for nicer formatting
51 self::$_links = [
52 CRM_Core_Action::UPDATE => [
53 'name' => ts('Edit'),
54 'class' => 'no-popup',
55 'url' => 'civicrm/admin/scheduleReminders',
56 'qs' => 'action=update&id=%%id%%&reset=1',
57 'title' => ts('Edit Schedule Reminders'),
58 ],
59 CRM_Core_Action::ENABLE => [
60 'name' => ts('Enable'),
61 'ref' => 'crm-enable-disable',
62 'title' => ts('Enable Label Format'),
63 ],
64 CRM_Core_Action::DISABLE => [
65 'name' => ts('Disable'),
66 'ref' => 'crm-enable-disable',
67 'title' => ts('Disable Label Format'),
68 ],
69 CRM_Core_Action::DELETE => [
70 'name' => ts('Delete'),
71 'url' => 'civicrm/admin/scheduleReminders',
72 'qs' => 'action=delete&id=%%id%%',
73 'title' => ts('Delete Schedule Reminders'),
74 ],
75 ];
76 }
77
78 return self::$_links;
79 }
80
81 /**
82 * Get name of edit form.
83 *
84 * @return string
85 * Classname of edit form.
86 */
87 public function editForm() {
88 return 'CRM_Admin_Form_ScheduleReminders';
89 }
90
91 /**
92 * Get edit form name.
93 *
94 * @return string
95 * name of this page.
96 */
97 public function editName() {
98 return 'ScheduleReminders';
99 }
100
101 /**
102 * Get user context.
103 *
104 * @param null $mode
105 *
106 * @return string
107 * user context.
108 */
109 public function userContext($mode = NULL) {
110 return 'civicrm/admin/scheduleReminders';
111 }
112
113 /**
114 * Browse all Scheduled Reminders settings.
115 *
116 * @param null $action
117 *
118 * @throws \CRM_Core_Exception
119 */
120 public function browse($action = NULL) {
121 //CRM-16777: Do not permit access to user, for page 'Administer->Communication->Schedule Reminder',
122 //when do not have 'administer CiviCRM' permission.
123 if (!CRM_Core_Permission::check('administer CiviCRM')) {
124 CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
125 }
126
127 // Get list of configured reminders
128 $reminderList = CRM_Core_BAO_ActionSchedule::getList();
129
130 // Add action links to each of the reminders
131 foreach ($reminderList as & $format) {
132 $action = array_sum(array_keys($this->links()));
133 if ($format['is_active']) {
134 $action -= CRM_Core_Action::ENABLE;
135 }
136 else {
137 $action -= CRM_Core_Action::DISABLE;
138 }
139 $format['action'] = CRM_Core_Action::formLink(
140 self::links(),
141 $action,
142 ['id' => $format['id']],
143 ts('more'),
144 FALSE,
145 'actionSchedule.manage.action',
146 'ActionSchedule',
147 $format['id']
148 );
149 }
150
151 $this->assign('rows', $reminderList);
152 }
153
154 }