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
{
47 private static $event;
54 private static $participantStatus;
61 private static $participantRole;
68 private static $participantListing;
75 private static $eventType;
78 * Event template titles
81 private static $eventTemplates;
84 * Personal campaign pages
87 private static $pcPage;
90 * Get all the n events
95 * @param null $condition
98 * array of all events if any
100 public static function event($id = NULL, $all = FALSE, $condition = NULL) {
101 $key = "{$id}_{$all}_{$condition}";
103 if (!isset(self
::$event[$key])) {
104 self
::$event[$key] = array();
107 if (!self
::$event[$key]) {
108 CRM_Core_PseudoConstant
::populate(self
::$event[$key],
109 'CRM_Event_DAO_Event',
110 $all, 'title', 'is_active', $condition, NULL
115 if (array_key_exists($id, self
::$event[$key])) {
116 return self
::$event[$key][$id];
122 return self
::$event[$key];
126 * Get all the n participant statuses.
131 * @param string $retColumn
132 * Tells populate() whether to return 'name' (default) or 'label' values.
135 * array reference of all participant statuses if any
137 public static function &participantStatus($id = NULL, $cond = NULL, $retColumn = 'name') {
138 if (self
::$participantStatus === NULL) {
139 self
::$participantStatus = array();
142 $index = $cond ?
$cond : 'No Condition';
143 $index = "{$index}_{$retColumn}";
144 if (!CRM_Utils_Array
::value($index, self
::$participantStatus)) {
145 self
::$participantStatus[$index] = array();
146 CRM_Core_PseudoConstant
::populate(self
::$participantStatus[$index],
147 'CRM_Event_DAO_ParticipantStatusType',
148 FALSE, $retColumn, 'is_active', $cond, 'weight'
153 return self
::$participantStatus[$index][$id];
156 return self
::$participantStatus[$index];
160 * Get participant status class options.
164 public static function participantStatusClassOptions() {
166 'Positive' => ts('Positive'),
167 'Pending' => ts('Pending'),
168 'Waiting' => ts('Waiting'),
169 'Negative' => ts('Negative'),
174 * Return a status-type-keyed array of status classes
177 * Array of status classes, keyed by status type
179 public static function &participantStatusClass() {
180 static $statusClasses = NULL;
182 if ($statusClasses === NULL) {
183 self
::populate($statusClasses, 'CRM_Event_DAO_ParticipantStatusType', TRUE, 'class');
186 return $statusClasses;
190 * Get all the n participant roles.
197 * array reference of all participant roles if any
199 public static function &participantRole($id = NULL, $cond = NULL) {
200 $index = $cond ?
$cond : 'No Condition';
201 if (!CRM_Utils_Array
::value($index, self
::$participantRole)) {
202 self
::$participantRole[$index] = array();
207 $condition = "AND $cond";
210 self
::$participantRole[$index] = CRM_Core_OptionGroup
::values('participant_role', FALSE, FALSE,
216 return self
::$participantRole[$index][$id];
218 return self
::$participantRole[$index];
222 * Get all the participant listings.
228 * array reference of all participant listings if any
230 public static function &participantListing($id = NULL) {
231 if (!self
::$participantListing) {
232 self
::$participantListing = array();
233 self
::$participantListing = CRM_Core_OptionGroup
::values('participant_listing');
237 return self
::$participantListing[$id];
240 return self
::$participantListing;
244 * Get all event types.
249 * array reference of all event types.
251 public static function &eventType($id = NULL) {
252 if (!self
::$eventType) {
253 self
::$eventType = array();
254 self
::$eventType = CRM_Core_OptionGroup
::values('event_type');
258 return self
::$eventType[$id];
261 return self
::$eventType;
265 * Get event template titles.
270 * Array of event id → template title pairs
272 public static function &eventTemplates($id = NULL) {
273 if (!self
::$eventTemplates) {
274 CRM_Core_PseudoConstant
::populate(self
::$eventTemplates,
275 'CRM_Event_DAO_Event',
283 return self
::$eventTemplates[$id];
285 return self
::$eventTemplates;
289 * Flush given pseudoconstant so it can be reread from db
290 * nex time it's requested.
293 * @param bool|string $name pseudoconstant to be flushed
295 public static function flush($name = 'cache') {
296 if (isset(self
::$
$name)) {
302 * Get all the Personal campaign pages.
307 * array reference of all pcp if any
309 public static function &pcPage($id = NULL) {
310 if (!self
::$pcPage) {
311 CRM_Core_PseudoConstant
::populate(self
::$pcPage,
317 return CRM_Utils_Array
::value($id, self
::$pcPage);
319 return self
::$pcPage;