3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * This class holds all the Pseudo constants that are specific to Event. This avoids
38 * polluting the core class and isolates the Event
40 class CRM_Event_PseudoConstant
extends CRM_Core_PseudoConstant
{
48 private static $event;
56 private static $participantStatus;
64 private static $participantRole;
72 private static $participantListing;
80 private static $eventType;
83 * Event template titles
86 private static $eventTemplates;
89 * Personal campaign pages
93 private static $pcPage;
96 * Get all the n events
101 * @param null $condition
104 * array of all events if any
107 public static function event($id = NULL, $all = FALSE, $condition = NULL) {
108 $key = "{$id}_{$all}_{$condition}";
110 if (!isset(self
::$event[$key])) {
111 self
::$event[$key] = array();
114 if (!self
::$event[$key]) {
115 CRM_Core_PseudoConstant
::populate(self
::$event[$key],
116 'CRM_Event_DAO_Event',
117 $all, 'title', 'is_active', $condition, NULL
122 if (array_key_exists($id, self
::$event[$key])) {
123 return self
::$event[$key][$id];
129 return self
::$event[$key];
133 * Get all the n participant statuses
138 * @param string $retColumn
139 * Tells populate() whether to return 'name' (default) or 'label' values.
142 * array reference of all participant statuses if any
145 public static function &participantStatus($id = NULL, $cond = NULL, $retColumn = 'name') {
146 if (self
::$participantStatus === NULL) {
147 self
::$participantStatus = array();
150 $index = $cond ?
$cond : 'No Condition';
151 $index = "{$index}_{$retColumn}";
152 if (!CRM_Utils_Array
::value($index, self
::$participantStatus)) {
153 self
::$participantStatus[$index] = array();
154 CRM_Core_PseudoConstant
::populate(self
::$participantStatus[$index],
155 'CRM_Event_DAO_ParticipantStatusType',
156 FALSE, $retColumn, 'is_active', $cond, 'weight'
161 return self
::$participantStatus[$index][$id];
164 return self
::$participantStatus[$index];
167 public static function participantStatusClassOptions() {
169 'Positive' => ts('Positive'),
170 'Pending' => ts('Pending'),
171 'Waiting' => ts('Waiting'),
172 'Negative' => ts('Negative'),
177 * Return a status-type-keyed array of status classes
180 * of status classes, keyed by status type
182 public static function &participantStatusClass() {
183 static $statusClasses = NULL;
185 if ($statusClasses === NULL) {
186 self
::populate($statusClasses, 'CRM_Event_DAO_ParticipantStatusType', TRUE, 'class');
189 return $statusClasses;
193 * Get all the n participant roles
200 * array reference of all participant roles if any
203 public static function &participantRole($id = NULL, $cond = NULL) {
204 $index = $cond ?
$cond : 'No Condition';
205 if (!CRM_Utils_Array
::value($index, self
::$participantRole)) {
206 self
::$participantRole[$index] = array();
211 $condition = "AND $cond";
214 self
::$participantRole[$index] = CRM_Core_OptionGroup
::values('participant_role', FALSE, FALSE,
220 return self
::$participantRole[$index][$id];
222 return self
::$participantRole[$index];
226 * Get all the participant listings
232 * array reference of all participant listings if any
235 public static function &participantListing($id = NULL) {
236 if (!self
::$participantListing) {
237 self
::$participantListing = array();
238 self
::$participantListing = CRM_Core_OptionGroup
::values('participant_listing');
242 return self
::$participantListing[$id];
245 return self
::$participantListing;
249 * Get all event types.
254 * array reference of all event types.
257 public static function &eventType($id = NULL) {
258 if (!self
::$eventType) {
259 self
::$eventType = array();
260 self
::$eventType = CRM_Core_OptionGroup
::values('event_type');
264 return self
::$eventType[$id];
267 return self
::$eventType;
271 * Get event template titles
276 * of event id → template title pairs
278 public static function &eventTemplates($id = NULL) {
279 if (!self
::$eventTemplates) {
280 CRM_Core_PseudoConstant
::populate(self
::$eventTemplates,
281 'CRM_Event_DAO_Event',
289 return self
::$eventTemplates[$id];
291 return self
::$eventTemplates;
295 * Flush given pseudoconstant so it can be reread from db
296 * nex time it's requested.
300 * @param bool|string $name pseudoconstant to be flushed
302 public static function flush($name = 'cache') {
303 if (isset(self
::$
$name)) {
309 * Get all the Personal campaign pages
314 * array reference of all pcp if any
317 public static function &pcPage($id = NULL) {
318 if (!self
::$pcPage) {
319 CRM_Core_PseudoConstant
::populate(self
::$pcPage,
325 return CRM_Utils_Array
::value($id, self
::$pcPage);
327 return self
::$pcPage;