3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for displaying list of event templates.
21 class CRM_Admin_Page_EventTemplate
extends CRM_Core_Page_Basic
{
24 * The action links that we need to display for the browse screen.
28 public static $_links = NULL;
36 public function getBAOName() {
37 return 'CRM_Event_BAO_Event';
44 * (reference) of action links
46 public function &links() {
47 if (!(self
::$_links)) {
48 // helper variable for nicer formatting
50 CRM_Core_Action
::UPDATE
=> [
52 'url' => 'civicrm/event/manage/settings',
53 'qs' => 'action=update&id=%%id%%&reset=1',
54 'title' => ts('Edit Event Template'),
56 CRM_Core_Action
::DELETE
=> [
57 'name' => ts('Delete'),
58 'url' => 'civicrm/event/manage',
59 'qs' => 'action=delete&id=%%id%%',
60 'title' => ts('Delete Event Template'),
69 * Browse all event templates.
71 public function browse() {
72 //get all event templates.
73 $allEventTemplates = [];
75 $eventTemplate = new CRM_Event_DAO_Event();
77 $eventTypes = CRM_Event_PseudoConstant
::eventType();
78 $participantRoles = CRM_Event_PseudoConstant
::participantRole();
79 $participantListings = CRM_Event_BAO_Event
::buildOptions('participant_listing_id');
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
]);
88 if ($eventTemplate->participant_listing_id
) {
89 $allEventTemplates[$eventTemplate->id
]['participant_listing'] = $participantListings[$eventTemplate->participant_listing_id
];
92 //get participant role
93 if ($eventTemplate->default_role_id
) {
94 $allEventTemplates[$eventTemplate->id
]['participant_role'] = $participantRoles[$eventTemplate->default_role_id
];
98 if (isset($eventTypes[$eventTemplate->event_type_id
])) {
99 $allEventTemplates[$eventTemplate->id
]['event_type'] = $eventTypes[$eventTemplate->event_type_id
];
102 //form all action links
103 $action = array_sum(array_keys($this->links()));
106 $allEventTemplates[$eventTemplate->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
107 ['id' => $eventTemplate->id
],
110 'eventTemplate.manage.action',
115 $this->assign('rows', $allEventTemplates);
117 $session = CRM_Core_Session
::singleton();
118 $session->pushUserContext(CRM_Utils_System
::url(CRM_Utils_System
::currentPath(),
119 'reset=1&action=browse'
124 * Get name of edit form.
127 * Classname of edit form.
129 public function editForm() {
130 return 'CRM_Admin_Form_EventTemplate';
134 * Get edit form name.
139 public function editName() {
140 return 'Event Templates';
151 public function userContext($mode = NULL) {
152 return 'civicrm/admin/eventTemplate';