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 | /** | |
19 | * Page for displaying list of event templates. | |
20 | */ | |
21 | class CRM_Admin_Page_EventTemplate extends CRM_Core_Page_Basic { | |
22 | ||
23 | /** | |
eceb18cc | 24 | * The action links that we need to display for the browse screen. |
6a488035 TO |
25 | * |
26 | * @var array | |
6a488035 | 27 | */ |
62d3ee27 | 28 | public static $_links = NULL; |
6a488035 TO |
29 | |
30 | /** | |
eceb18cc | 31 | * Get BAO Name. |
6a488035 | 32 | * |
a6c01b45 CW |
33 | * @return string |
34 | * Classname of BAO. | |
6a488035 | 35 | */ |
00be9182 | 36 | public function getBAOName() { |
6a488035 TO |
37 | return 'CRM_Event_BAO_Event'; |
38 | } | |
39 | ||
40 | /** | |
eceb18cc | 41 | * Get action Links. |
6a488035 | 42 | * |
a6c01b45 CW |
43 | * @return array |
44 | * (reference) of action links | |
6a488035 | 45 | */ |
00be9182 | 46 | public function &links() { |
6a488035 TO |
47 | if (!(self::$_links)) { |
48 | // helper variable for nicer formatting | |
be2fb01f CW |
49 | self::$_links = [ |
50 | CRM_Core_Action::UPDATE => [ | |
6a488035 TO |
51 | 'name' => ts('Edit'), |
52 | 'url' => 'civicrm/event/manage/settings', | |
53 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
54 | 'title' => ts('Edit Event Template'), | |
be2fb01f CW |
55 | ], |
56 | CRM_Core_Action::DELETE => [ | |
6a488035 TO |
57 | 'name' => ts('Delete'), |
58 | 'url' => 'civicrm/event/manage', | |
59 | 'qs' => 'action=delete&id=%%id%%', | |
60 | 'title' => ts('Delete Event Template'), | |
be2fb01f CW |
61 | ], |
62 | ]; | |
6a488035 TO |
63 | } |
64 | ||
65 | return self::$_links; | |
66 | } | |
67 | ||
68 | /** | |
69 | * Browse all event templates. | |
6a488035 | 70 | */ |
00be9182 | 71 | public function browse() { |
6a488035 | 72 | //get all event templates. |
be2fb01f | 73 | $allEventTemplates = []; |
6a488035 TO |
74 | |
75 | $eventTemplate = new CRM_Event_DAO_Event(); | |
76 | ||
353ffa53 TO |
77 | $eventTypes = CRM_Event_PseudoConstant::eventType(); |
78 | $participantRoles = CRM_Event_PseudoConstant::participantRole(); | |
8655187b | 79 | $participantListings = CRM_Event_BAO_Event::buildOptions('participant_listing_id'); |
6a488035 TO |
80 | |
81 | //find all event templates. | |
82 | $eventTemplate->is_template = TRUE; | |
83 | $eventTemplate->find(); | |
84 | while ($eventTemplate->fetch()) { | |
85 | CRM_Core_DAO::storeValues($eventTemplate, $allEventTemplates[$eventTemplate->id]); | |
86 | ||
87 | //get listing types. | |
72e0a297 | 88 | $allEventTemplates[$eventTemplate->id]['participant_listing'] = ts('Disabled'); |
6a488035 TO |
89 | if ($eventTemplate->participant_listing_id) { |
90 | $allEventTemplates[$eventTemplate->id]['participant_listing'] = $participantListings[$eventTemplate->participant_listing_id]; | |
91 | } | |
92 | ||
93 | //get participant role | |
72e0a297 | 94 | $allEventTemplates[$eventTemplate->id]['participant_role'] = ''; |
6a488035 TO |
95 | if ($eventTemplate->default_role_id) { |
96 | $allEventTemplates[$eventTemplate->id]['participant_role'] = $participantRoles[$eventTemplate->default_role_id]; | |
97 | } | |
98 | ||
99 | //get event type. | |
72e0a297 | 100 | $allEventTemplates[$eventTemplate->id]['event_type'] = ''; |
df322c7a | 101 | if (isset($eventTypes[$eventTemplate->event_type_id])) { |
02fc859b | 102 | $allEventTemplates[$eventTemplate->id]['event_type'] = $eventTypes[$eventTemplate->event_type_id]; |
df322c7a | 103 | } |
6a488035 TO |
104 | |
105 | //form all action links | |
106 | $action = array_sum(array_keys($this->links())); | |
107 | ||
108 | //add action links. | |
109 | $allEventTemplates[$eventTemplate->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, | |
be2fb01f | 110 | ['id' => $eventTemplate->id], |
87dab4a4 AH |
111 | ts('more'), |
112 | FALSE, | |
113 | 'eventTemplate.manage.action', | |
114 | 'Event', | |
115 | $eventTemplate->id | |
6a488035 TO |
116 | ); |
117 | } | |
118 | $this->assign('rows', $allEventTemplates); | |
119 | ||
120 | $session = CRM_Core_Session::singleton(); | |
121 | $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), | |
353ffa53 TO |
122 | 'reset=1&action=browse' |
123 | )); | |
6a488035 TO |
124 | } |
125 | ||
126 | /** | |
eceb18cc | 127 | * Get name of edit form. |
6a488035 | 128 | * |
a6c01b45 CW |
129 | * @return string |
130 | * Classname of edit form. | |
6a488035 | 131 | */ |
00be9182 | 132 | public function editForm() { |
6a488035 TO |
133 | return 'CRM_Admin_Form_EventTemplate'; |
134 | } | |
135 | ||
136 | /** | |
eceb18cc | 137 | * Get edit form name. |
6a488035 | 138 | * |
a6c01b45 CW |
139 | * @return string |
140 | * name of this page. | |
6a488035 | 141 | */ |
00be9182 | 142 | public function editName() { |
6a488035 TO |
143 | return 'Event Templates'; |
144 | } | |
145 | ||
146 | /** | |
147 | * Get user context. | |
148 | * | |
da6b46f4 EM |
149 | * @param null $mode |
150 | * | |
a6c01b45 CW |
151 | * @return string |
152 | * user context. | |
6a488035 | 153 | */ |
00be9182 | 154 | public function userContext($mode = NULL) { |
6a488035 TO |
155 | return 'civicrm/admin/eventTemplate'; |
156 | } | |
96025800 | 157 | |
6a488035 | 158 | } |