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. | |
88 | if ($eventTemplate->participant_listing_id) { | |
89 | $allEventTemplates[$eventTemplate->id]['participant_listing'] = $participantListings[$eventTemplate->participant_listing_id]; | |
90 | } | |
91 | ||
92 | //get participant role | |
93 | if ($eventTemplate->default_role_id) { | |
94 | $allEventTemplates[$eventTemplate->id]['participant_role'] = $participantRoles[$eventTemplate->default_role_id]; | |
95 | } | |
96 | ||
97 | //get event type. | |
df322c7a | 98 | if (isset($eventTypes[$eventTemplate->event_type_id])) { |
02fc859b | 99 | $allEventTemplates[$eventTemplate->id]['event_type'] = $eventTypes[$eventTemplate->event_type_id]; |
df322c7a | 100 | } |
6a488035 TO |
101 | |
102 | //form all action links | |
103 | $action = array_sum(array_keys($this->links())); | |
104 | ||
105 | //add action links. | |
106 | $allEventTemplates[$eventTemplate->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, | |
be2fb01f | 107 | ['id' => $eventTemplate->id], |
87dab4a4 AH |
108 | ts('more'), |
109 | FALSE, | |
110 | 'eventTemplate.manage.action', | |
111 | 'Event', | |
112 | $eventTemplate->id | |
6a488035 TO |
113 | ); |
114 | } | |
115 | $this->assign('rows', $allEventTemplates); | |
116 | ||
117 | $session = CRM_Core_Session::singleton(); | |
118 | $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), | |
353ffa53 TO |
119 | 'reset=1&action=browse' |
120 | )); | |
6a488035 TO |
121 | } |
122 | ||
123 | /** | |
eceb18cc | 124 | * Get name of edit form. |
6a488035 | 125 | * |
a6c01b45 CW |
126 | * @return string |
127 | * Classname of edit form. | |
6a488035 | 128 | */ |
00be9182 | 129 | public function editForm() { |
6a488035 TO |
130 | return 'CRM_Admin_Form_EventTemplate'; |
131 | } | |
132 | ||
133 | /** | |
eceb18cc | 134 | * Get edit form name. |
6a488035 | 135 | * |
a6c01b45 CW |
136 | * @return string |
137 | * name of this page. | |
6a488035 | 138 | */ |
00be9182 | 139 | public function editName() { |
6a488035 TO |
140 | return 'Event Templates'; |
141 | } | |
142 | ||
143 | /** | |
144 | * Get user context. | |
145 | * | |
da6b46f4 EM |
146 | * @param null $mode |
147 | * | |
a6c01b45 CW |
148 | * @return string |
149 | * user context. | |
6a488035 | 150 | */ |
00be9182 | 151 | public function userContext($mode = NULL) { |
6a488035 TO |
152 | return 'civicrm/admin/eventTemplate'; |
153 | } | |
96025800 | 154 | |
6a488035 | 155 | } |