From a215a5b0fea27f0cef6eabb82abf6b61eddd5ae0 Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Tue, 22 Oct 2013 18:03:44 +0530 Subject: [PATCH] CRM-13619 - allow hooks to be able to configure tabs --- CRM/Event/Form/ManageEvent/TabHeader.php | 111 +++++++++++------------ CRM/Event/Page/ManageEvent.php | 5 +- 2 files changed, 56 insertions(+), 60 deletions(-) diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 57b93405e7..656eb3f8be 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -58,50 +58,50 @@ class CRM_Event_Form_ManageEvent_TabHeader { $tabs = array( 'settings' => array('title' => ts('Info and Settings'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ), 'location' => array('title' => ts('Event Location'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ), 'fee' => array('title' => ts('Fees'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ), 'registration' => array('title' => ts('Online Registration'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ), 'reminder' => array('title' => ts('Schedule Reminders'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ), 'conference' => array('title' => ts('Conference Slots'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ), 'friend' => array('title' => ts('Tell a Friend'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ), 'pcp' => array('title' => ts('Personal Campaigns'), 'link' => NULL, - 'valid' => FALSE, - 'active' => FALSE, + 'valid' => TRUE, + 'active' => TRUE, 'current' => FALSE, ) ); @@ -110,14 +110,49 @@ class CRM_Event_Form_ManageEvent_TabHeader { $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart' ); - if (!$enableCart) { unset($tabs['conference']); } $eventID = $form->getVar('_id'); + if ($eventID) { + // disable tabs based on their configuration status + $sql = " +SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.id as is_pcp, sch.id as is_reminder +FROM civicrm_event e +LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id ) +LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id ) +LEFT JOIN civicrm_action_mapping map ON ( map.entity_value = 'civicrm_event' ) +LEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 ) +WHERE e.id = %1 +"; + $params = array(1 => array($eventID, 'Integer')); + $dao = CRM_Core_DAO::executeQuery($sql, $params); + if (!$dao->fetch()) { + CRM_Core_Error::fatal(); + } + if (!$dao->is_location) { + $tabs['location']['valid'] = FALSE; + } + if (!$dao->is_online_registration) { + $tabs['registration']['valid'] = FALSE; + } + if (!$dao->is_monetary) { + $tabs['fee']['valid'] = FALSE; + } + if (!$dao->is_active) { + $tabs['friend']['valid'] = FALSE; + } + if (!$dao->is_pcp) { + $tabs['pcp']['valid'] = FALSE; + } + if (!$dao->is_reminder) { + $tabs['reminder']['valid'] = FALSE; + } + } // see if any other modules want to add any tabs + // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation. CRM_Utils_Hook::tabset('civicrm/event/manage', $tabs, array('event_id' => $eventID)); @@ -160,49 +195,7 @@ class CRM_Event_Form_ManageEvent_TabHeader { $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", "{$reset}action=update&snippet=5&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}" ); - $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE; - } - - // retrieve info about paid event, tell a friend and online reg - $sql = " -SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.id as is_pcp, sch.id as is_reminder -FROM civicrm_event e -LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id ) -LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id ) -LEFT JOIN civicrm_action_mapping map ON ( map.entity_value = 'civicrm_event' ) -LEFT JOIN civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 ) -WHERE e.id = %1 -"; - $params = array(1 => array($eventID, 'Integer')); - $dao = CRM_Core_DAO::executeQuery($sql, $params); - if (!$dao->fetch()) { - CRM_Core_Error::fatal(); - } - - if (!$dao->is_location) { - $tabs['location']['valid'] = FALSE; - } - - if (!$dao->is_online_registration) { - $tabs['registration']['valid'] = FALSE; - } - - if (!$dao->is_monetary) { - $tabs['fee']['valid'] = FALSE; - } - - if (!$dao->is_active) { - $tabs['friend']['valid'] = FALSE; - } - - if (!$dao->is_pcp) { - $tabs['pcp']['valid'] = FALSE; - } - - if (!$dao->is_reminder) { - $tabs['reminder']['valid'] = FALSE; } - //calculate if the reminder has been configured for this event } return $tabs; diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 33fd345852..f618ba520c 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -119,7 +119,7 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { 'location' => array( 'title' => ts('Location'), 'url' => 'civicrm/event/manage/location', - 'field' => 'is_show_location', + 'field' => 'loc_block_id', ), 'fee' => array( 'title' => ts('Fees'), @@ -348,6 +348,9 @@ ORDER BY start_date desc $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[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType); + + // allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled + CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, array('event_id' => $dao->id)); } } -- 2.25.1