Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-06-23-18-25-12
[civicrm-core.git] / CRM / Admin / Page / ScheduleReminders.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06b69b18 4 | CiviCRM version 4.5 |
6a488035
TO
5 +--------------------------------------------------------------------+
6 | Copyright (C) 2011 Marty Wright |
7 | Licensed to CiviCRM under the Academic Free License version 3.0. |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27*/
28
29/**
30 *
31 * @package CRM
06b69b18 32 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
33 * $Id$
34 *
35 */
36
37/**
38 * Page for displaying list of Reminders
39 */
40class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic {
41
96f50de2
CW
42 public $useLivePageJS = TRUE;
43
6a488035
TO
44 /**
45 * The action links that we need to display for the browse screen
46 *
47 * @var array
48 * @static
49 */
50 static $_links = NULL;
51
52 /**
53 * Get BAO Name
54 *
55 * @return string Classname of BAO.
56 */
57 function getBAOName() {
58 return 'CRM_Core_BAO_ActionSchedule';
59 }
60
61 /**
62 * Get action Links
63 *
64 * @return array (reference) of action links
65 */
f306fd82 66 public function &links() {
6a488035
TO
67 if (!(self::$_links)) {
68 // helper variable for nicer formatting
69 self::$_links = array(
70 CRM_Core_Action::UPDATE => array(
71 'name' => ts('Edit'),
72 'url' => 'civicrm/admin/scheduleReminders',
73 'qs' => 'action=update&id=%%id%%&reset=1',
74 'title' => ts('Edit Schedule Reminders'),
8f0332b0 75 'class' => 'no-popup',
6a488035
TO
76 ),
77 CRM_Core_Action::ENABLE => array(
78 'name' => ts('Enable'),
4d17a233 79 'ref' => 'crm-enable-disable',
6a488035
TO
80 'title' => ts('Enable Label Format'),
81 ),
82 CRM_Core_Action::DISABLE => array(
83 'name' => ts('Disable'),
4d17a233 84 'ref' => 'crm-enable-disable',
6a488035
TO
85 'title' => ts('Disable Label Format'),
86 ),
87 CRM_Core_Action::DELETE => array(
88 'name' => ts('Delete'),
89 'url' => 'civicrm/admin/scheduleReminders',
90 'qs' => 'action=delete&id=%%id%%',
91 'title' => ts('Delete Schedule Reminders'),
92 ),
93 );
94 }
95
96 return self::$_links;
97 }
98
99 /**
100 * Get name of edit form
101 *
102 * @return string Classname of edit form.
103 */
104 function editForm() {
105 return 'CRM_Admin_Form_ScheduleReminders';
106 }
107
108 /**
109 * Get edit form name
110 *
111 * @return string name of this page.
112 */
113 function editName() {
114 return 'ScheduleReminders';
115 }
116
117 /**
118 * Get user context.
119 *
77b97be7
EM
120 * @param null $mode
121 *
6a488035
TO
122 * @return string user context.
123 */
124 function userContext($mode = NULL) {
125 return 'civicrm/admin/scheduleReminders';
126 }
127
128 /**
129 * Browse all Scheduled Reminders settings.
130 *
fd31fa4c
EM
131 * @param null $action
132 *
6a488035
TO
133 * @return void
134 * @access public
135 * @static
136 */
137 function browse($action = NULL) {
138 // Get list of configured reminders
139 $reminderList = CRM_Core_BAO_ActionSchedule::getList();
140
141 if (is_array($reminderList)) {
142 // Add action links to each of the reminders
143 foreach ($reminderList as & $format) {
144 $action = array_sum(array_keys($this->links()));
145 if ($format['is_active']) {
146 $action -= CRM_Core_Action::ENABLE;
147 }
148 else {
149 $action -= CRM_Core_Action::DISABLE;
150 }
87dab4a4
AH
151 $format['action'] = CRM_Core_Action::formLink(
152 self::links(),
153 $action,
154 array('id' => $format['id']),
155 ts('more'),
156 FALSE,
157 'actionSchedule.manage.action',
158 'ActionSchedule',
159 $format['id']
160 );
6a488035
TO
161 }
162 }
163
164 $this->assign('rows', $reminderList);
165 }
166}
167