Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
ce064e4f | 19 | * Page for displaying list of Reminders. |
6a488035 TO |
20 | */ |
21 | class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic { | |
22 | ||
96f50de2 CW |
23 | public $useLivePageJS = TRUE; |
24 | ||
6a488035 | 25 | /** |
eceb18cc | 26 | * The action links that we need to display for the browse screen. |
6a488035 TO |
27 | * |
28 | * @var array | |
6a488035 | 29 | */ |
62d3ee27 | 30 | public static $_links = NULL; |
6a488035 TO |
31 | |
32 | /** | |
eceb18cc | 33 | * Get BAO Name. |
6a488035 | 34 | * |
a6c01b45 CW |
35 | * @return string |
36 | * Classname of BAO. | |
6a488035 | 37 | */ |
00be9182 | 38 | public function getBAOName() { |
6a488035 TO |
39 | return 'CRM_Core_BAO_ActionSchedule'; |
40 | } | |
41 | ||
42 | /** | |
eceb18cc | 43 | * Get action Links. |
6a488035 | 44 | * |
a6c01b45 CW |
45 | * @return array |
46 | * (reference) of action links | |
6a488035 | 47 | */ |
f306fd82 | 48 | public function &links() { |
6a488035 TO |
49 | if (!(self::$_links)) { |
50 | // helper variable for nicer formatting | |
be2fb01f CW |
51 | self::$_links = [ |
52 | CRM_Core_Action::UPDATE => [ | |
6a488035 TO |
53 | 'name' => ts('Edit'), |
54 | 'url' => 'civicrm/admin/scheduleReminders', | |
55 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
56 | 'title' => ts('Edit Schedule Reminders'), | |
be2fb01f CW |
57 | ], |
58 | CRM_Core_Action::ENABLE => [ | |
6a488035 | 59 | 'name' => ts('Enable'), |
4d17a233 | 60 | 'ref' => 'crm-enable-disable', |
6a488035 | 61 | 'title' => ts('Enable Label Format'), |
be2fb01f CW |
62 | ], |
63 | CRM_Core_Action::DISABLE => [ | |
6a488035 | 64 | 'name' => ts('Disable'), |
4d17a233 | 65 | 'ref' => 'crm-enable-disable', |
6a488035 | 66 | 'title' => ts('Disable Label Format'), |
be2fb01f CW |
67 | ], |
68 | CRM_Core_Action::DELETE => [ | |
6a488035 TO |
69 | 'name' => ts('Delete'), |
70 | 'url' => 'civicrm/admin/scheduleReminders', | |
71 | 'qs' => 'action=delete&id=%%id%%', | |
72 | 'title' => ts('Delete Schedule Reminders'), | |
be2fb01f CW |
73 | ], |
74 | ]; | |
6a488035 TO |
75 | } |
76 | ||
77 | return self::$_links; | |
78 | } | |
79 | ||
80 | /** | |
eceb18cc | 81 | * Get name of edit form. |
6a488035 | 82 | * |
a6c01b45 CW |
83 | * @return string |
84 | * Classname of edit form. | |
6a488035 | 85 | */ |
00be9182 | 86 | public function editForm() { |
6a488035 TO |
87 | return 'CRM_Admin_Form_ScheduleReminders'; |
88 | } | |
89 | ||
90 | /** | |
eceb18cc | 91 | * Get edit form name. |
6a488035 | 92 | * |
a6c01b45 CW |
93 | * @return string |
94 | * name of this page. | |
6a488035 | 95 | */ |
00be9182 | 96 | public function editName() { |
6a488035 TO |
97 | return 'ScheduleReminders'; |
98 | } | |
99 | ||
100 | /** | |
101 | * Get user context. | |
102 | * | |
77b97be7 EM |
103 | * @param null $mode |
104 | * | |
a6c01b45 CW |
105 | * @return string |
106 | * user context. | |
6a488035 | 107 | */ |
00be9182 | 108 | public function userContext($mode = NULL) { |
6a488035 TO |
109 | return 'civicrm/admin/scheduleReminders'; |
110 | } | |
111 | ||
112 | /** | |
113 | * Browse all Scheduled Reminders settings. | |
114 | * | |
fd31fa4c | 115 | * @param null $action |
beb414cc | 116 | * |
117 | * @throws \CRM_Core_Exception | |
6a488035 | 118 | */ |
00be9182 | 119 | public function browse($action = NULL) { |
e68f2900 WA |
120 | //CRM-16777: Do not permit access to user, for page 'Administer->Communication->Schedule Reminder', |
121 | //when do not have 'administer CiviCRM' permission. | |
122 | if (!CRM_Core_Permission::check('administer CiviCRM')) { | |
beb414cc | 123 | CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); |
e68f2900 WA |
124 | } |
125 | ||
6a488035 TO |
126 | // Get list of configured reminders |
127 | $reminderList = CRM_Core_BAO_ActionSchedule::getList(); | |
128 | ||
129 | if (is_array($reminderList)) { | |
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 | } | |
87dab4a4 AH |
139 | $format['action'] = CRM_Core_Action::formLink( |
140 | self::links(), | |
141 | $action, | |
be2fb01f | 142 | ['id' => $format['id']], |
87dab4a4 AH |
143 | ts('more'), |
144 | FALSE, | |
145 | 'actionSchedule.manage.action', | |
146 | 'ActionSchedule', | |
147 | $format['id'] | |
148 | ); | |
6a488035 TO |
149 | } |
150 | } | |
151 | ||
152 | $this->assign('rows', $reminderList); | |
153 | } | |
96025800 | 154 | |
6a488035 | 155 | } |