Merge pull request #3007 from GinkgoFJG/CRM-14283
[civicrm-core.git] / CRM / Event / Page / EventInfo.php
index 4e6cf32acb286b06cd41b408bf1a70404a6bea7c..2c2eff783c02138d0fa8f2c31299a9900ce567c4 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -88,10 +88,13 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page {
       CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
     }
 
+    // Add Event Type to $values in case folks want to display it
+    $values['event']['event_type'] = CRM_Utils_Array::value($values['event']['event_type_id'], CRM_Event_PseudoConstant::eventType());
+    
     $this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
 
     // show event fees.
-    if ($this->_id && CRM_Utils_Array::value('is_monetary', $values['event'])) {
+    if ($this->_id && !empty($values['event']['is_monetary'])) {
       //CRM-6907
       $config = CRM_Core_Config::singleton();
       $config->defaultCurrency = CRM_Utils_Array::value('currency',
@@ -116,10 +119,16 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page {
           $fieldCnt = 1;
           $visibility = CRM_Core_PseudoConstant::visibility('name');
 
+          // CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
+          $adminFieldVisible = false;
+          if (CRM_Core_Permission::check('administer CiviCRM')) {
+            $adminFieldVisible = true; 
+          }
+
           foreach ($priceSetFields as $fid => $fieldValues) {
             if (!is_array($fieldValues['options']) ||
               empty($fieldValues['options']) ||
-              CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility)
+              (CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility) && $adminFieldVisible == false)
             ) {
               continue;
             }
@@ -160,7 +169,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page {
     $this->assign('action', CRM_Core_Action::VIEW);
     //To show the event location on maps directly on event info page
     $locations = CRM_Event_BAO_Event::getMapInfo($this->_id);
-    if (!empty($locations) && CRM_Utils_Array::value('is_map', $values['event'])) {
+    if (!empty($locations) && !empty($values['event']['is_map'])) {
       $this->assign('locations', $locations);
       $this->assign('mapProvider', $config->mapProvider);
       $this->assign('mapKey', $config->mapAPIKey);
@@ -239,7 +248,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page {
     );
 
     $allowRegistration = FALSE;
-    if (CRM_Utils_Array::value('is_online_registration', $values['event'])) {
+    if (!empty($values['event']['is_online_registration'])) {
       if (CRM_Event_BAO_Event::validRegistrationRequest($values['event'], $this->_id)) {
         // we always generate urls for the front end in joomla
         $action_query = $action === CRM_Core_Action::PREVIEW ? "&action=$action" : '';
@@ -250,7 +259,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page {
         );
         if (!$eventFullMessage || $hasWaitingList) {
           $registerText = ts('Register Now');
-          if (CRM_Utils_Array::value('registration_link_text', $values['event'])) {
+          if (!empty($values['event']['registration_link_text'])) {
             $registerText = $values['event']['registration_link_text'];
           }