From d7d7d5ab517f0f13035dc2213074e0422162b6f6 Mon Sep 17 00:00:00 2001 From: yashodha Date: Mon, 24 Jun 2013 18:18:00 +0530 Subject: [PATCH] (generalised the links in tpl to use hooks)CRM-12864 --- CRM/Event/BAO/Event.php | 29 +++++---- CRM/Event/Page/DashBoard.php | 4 ++ CRM/Event/Page/ManageEvent.php | 81 ++++++++++++++++++++---- templates/CRM/Event/Page/DashBoard.tpl | 36 +++++------ templates/CRM/Event/Page/ManageEvent.tpl | 62 +++--------------- 5 files changed, 119 insertions(+), 93 deletions(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 151f3b1dc9..5f852a9dbc 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -339,8 +339,8 @@ WHERE civicrm_event.is_active = 1 AND } //get the participant status type values. - $query = 'SELECT id, name, class FROM civicrm_participant_status_type'; - $status = CRM_Core_DAO::executeQuery($query); + $query = 'SELECT id, name, class FROM civicrm_participant_status_type'; + $status = CRM_Core_DAO::executeQuery($query); $statusValues = array(); while ($status->fetch()) { $statusValues[$status->id]['id'] = $status->id; @@ -380,10 +380,15 @@ LIMIT 0, 10 $eventParticipant = array(); $properties = array( - 'eventTitle' => 'event_title', 'isPublic' => 'is_public', - 'maxParticipants' => 'max_participants', 'startDate' => 'start_date', - 'endDate' => 'end_date', 'eventType' => 'event_type', - 'isMap' => 'is_map', 'participants' => 'participants', + 'id' => 'id', + 'eventTitle' => 'event_title', + 'isPublic' => 'is_public', + 'maxParticipants' => 'max_participants', + 'startDate' => 'start_date', + 'endDate' => 'end_date', + 'eventType' => 'event_type', + 'isMap' => 'is_map', + 'participants' => 'participants', 'notCountedDueToRole' => 'notCountedDueToRole', 'notCountedDueToStatus' => 'notCountedDueToStatus', 'notCountedParticipants' => 'notCountedParticipants', @@ -408,9 +413,9 @@ LIMIT 0, 10 case 'is_map': if ($dao->$name && $config->mapAPIKey) { - $values = array(); - $ids = array(); - $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event'); + $values = array(); + $ids = array(); + $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event'); $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); if (is_numeric(CRM_Utils_Array::value('geo_code_1', $values['location']['address'][1])) || ($config->mapGeoCoding && @@ -514,9 +519,9 @@ LIMIT 0, 10 } } - $countedRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1'); - $nonCountedRoles = CRM_Event_PseudoConstant::participantRole(NULL, '( filter = 0 OR filter IS NULL )'); - $countedStatus = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); + $countedRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1'); + $nonCountedRoles = CRM_Event_PseudoConstant::participantRole(NULL, '( filter = 0 OR filter IS NULL )'); + $countedStatus = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $nonCountedStatus = CRM_Event_PseudoConstant::participantStatus(NULL, '( is_counted = 0 OR is_counted IS NULL )'); $countedStatusANDRoles = array_merge($countedStatus, $countedRoles); diff --git a/CRM/Event/Page/DashBoard.php b/CRM/Event/Page/DashBoard.php index 71c6258ded..53e949a956 100644 --- a/CRM/Event/Page/DashBoard.php +++ b/CRM/Event/Page/DashBoard.php @@ -50,6 +50,10 @@ class CRM_Event_Page_DashBoard extends CRM_Core_Page { CRM_Utils_System::setTitle(ts('CiviEvent')); $eventSummary = CRM_Event_BAO_Event::getEventSummary(); + $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, + 'enable_cart' + ); + $eventSummary['tab'] = CRM_Event_Page_ManageEvent::tabs($enableCart); $actionColumn = FALSE; if (!empty($eventSummary) && diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 95ad8a2334..51fb063208 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -48,6 +48,8 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { static $_links = NULL; + static $_tabLinks = NULL; + protected $_pager = NULL; protected $_sortByCharacter; @@ -97,6 +99,65 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { return self::$_actionLinks; } + /** + * Get tab Links for events + * + * @return array (reference) of tab links + */ + function &tabs($enableCart) { + if (!(self::$_tabLinks)) { + self::$_tabLinks = array( + 'settings' => array( + 'title' => ts('Info and Settings'), + 'url' => 'civicrm/event/manage/settings', + 'field' => 'id' + ), + 'location' => array( + 'title' => ts('Location'), + 'url' => 'civicrm/event/manage/location', + 'field' => 'is_show_location', + ), + 'fee' => array( + 'title' => ts('Fees'), + 'url' => 'civicrm/event/manage/fee', + 'field' => 'is_monetary', + ), + 'registration' => array( + 'title' => ts('Online Registration'), + 'url' => 'civicrm/event/manage/registration', + 'field' => 'is_online_registration', + ), + 'reminder' => array( + 'title' => ts('Schedule Reminders'), + 'url' => 'civicrm/event/manage/reminder', + 'field' => 'reminder', + ), + 'conference' => array( + 'title' => ts('Conference Slots'), + 'url' => 'civicrm/event/manage/conference', + 'field' => 'slot_label_id', + ), + 'friend' => array( + 'title' => ts('Tell a Friend'), + 'url' => 'civicrm/event/manage/friend', + 'field' => 'friend', + ), + 'pcp' => array( + 'title' => ts('Personal Campaign Pages'), + 'url' => 'civicrm/event/manage/pcp', + 'field' => 'is_pcp_enabled', + ), + ); + } + + if (!$enableCart) { + unset(self::$_tabLinks['conference']); + } + + CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks, array()); + return self::$_tabLinks; + } + /** * Run the page. * @@ -181,8 +242,6 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { $this->search(); - $config = CRM_Core_Config::singleton(); - $params = array(); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE @@ -227,6 +286,12 @@ ORDER BY start_date desc while ($pcpDao->fetch()) { $eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id; } + // check if we're in shopping cart mode for events + $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, + 'enable_cart' + ); + $this->assign('eventCartEnabled', $enableCart); + $mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'civicrm_event', 'id', 'entity_value'); while ($dao->fetch()) { if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) { @@ -276,11 +341,11 @@ ORDER BY start_date desc //show campaigns on selector. $manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); - $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, 3); - + $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mappingID); $manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS); } } + $manageEvent['tab'] = self::tabs($enableCart); $this->assign('rows', $manageEvent); $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); @@ -288,12 +353,6 @@ ORDER BY start_date desc $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes)); $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending)); $this->assign('findParticipants', $findParticipants); - - // check if we're in shopping cart mode for events - $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, - 'enable_cart' - ); - $this->assign('eventCartEnabled', $enableCart); } /** @@ -409,7 +468,7 @@ ORDER BY start_date desc $clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )'; } - // dont do a the below assignment when doing a + // don't do a the below assignment when doing a // AtoZ pager clause if ($sortBy) { if (count($clauses) > 1 || $eventsByDates) { diff --git a/templates/CRM/Event/Page/DashBoard.tpl b/templates/CRM/Event/Page/DashBoard.tpl index fc46f647cf..18fcf31683 100644 --- a/templates/CRM/Event/Page/DashBoard.tpl +++ b/templates/CRM/Event/Page/DashBoard.tpl @@ -97,28 +97,28 @@ {/foreach} {if $values.maxParticipants}{ts 1=$values.maxParticipants}(max %1){/ts}{/if} - {if $actionColumn} + {if $actionColumn} - {if $values.isMap} - » {ts}Map{/ts} |  - {/if} - {if $values.configure} -
+ {if $values.isMap} + » {ts}Map{/ts} +  |  + {/if} + {if $values.configure} +
{ts}Configure{/ts} -
- {/if} +
+ {/if} - {/if} + {/if} {/foreach} diff --git a/templates/CRM/Event/Page/ManageEvent.tpl b/templates/CRM/Event/Page/ManageEvent.tpl index f44ec0ed18..3f5ca8fe9c 100644 --- a/templates/CRM/Event/Page/ManageEvent.tpl +++ b/templates/CRM/Event/Page/ManageEvent.tpl @@ -80,8 +80,9 @@ - {foreach from=$rows item=row} - + {foreach from=$rows key=keys item=row} + {if $keys neq 'tab'} + {$row.title}  ({ts}ID:{/ts} {$row.id}) @@ -101,56 +102,12 @@
{ts}Configure{/ts}
@@ -220,6 +177,7 @@ {$row.start_date|crmDate} {$row.end_date|crmDate} + {/if} {/foreach} {include file="CRM/common/pager.tpl" location="bottom"} -- 2.25.1