Merge pull request #5883 from mallezie/addfield-website
authorEileen McNaughton <eileen@mcnaughty.com>
Sun, 24 May 2015 11:29:01 +0000 (23:29 +1200)
committerEileen McNaughton <eileen@mcnaughty.com>
Sun, 24 May 2015 11:29:01 +0000 (23:29 +1200)
CRM-16178 use addfield in website form

CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/ContributionBase.php
CRM/Contribute/Form/UpdateBilling.php
CRM/Core/BAO/Location.php
CRM/Core/Form.php
CRM/Event/Cart/Form/Cart.php
CRM/Event/Form/Registration.php
CRM/Event/Form/Registration/AdditionalParticipant.php
CRM/Event/Form/Registration/Register.php
tests/phpunit/api/v3/SyntaxConformanceTest.php

index b698b30c9cf91c9cc48b673603e3b5e1fb433ee4..f7cc453199942e57729ca8243fae16c1ebb354b1 100644 (file)
@@ -412,22 +412,6 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
 
   }
 
-  /**
-   * Assign billing type id to bltID.
-   *
-   * @throws CRM_Core_Exception
-   * @return void
-   */
-  public function assignBillingType() {
-    $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
-    $this->_bltID = array_search('Billing', $locationTypes);
-    if (!$this->_bltID) {
-      throw new CRM_Core_Exception(ts('Please set a location type of %1', array(1 => 'Billing')));
-    }
-    $this->set('bltID', $this->_bltID);
-    $this->assign('bltID', $this->_bltID);
-  }
-
   /**
    * Assign $this->processors, $this->recurPaymentProcessors, and related Smarty variables
    */
index facfe844596435e90b3acd3f6f8b202417ba6764..ba850bd534e4ad76f0d5f7986a956c9974da5924 100644 (file)
@@ -303,16 +303,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
         throw new CRM_Contribute_Exception_InactiveContributionPageException(ts('The page you requested is currently unavailable.'), $this->_id);
       }
 
-      // also check for billing information.
-      // get the billing location type
-      $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
-      // CRM-8108 remove ts around Billing location type
-      //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
-      $this->_bltID = array_search('Billing', $locationTypes);
-      if (!$this->_bltID) {
-        CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
-      }
-      $this->set('bltID', $this->_bltID);
+      $this->assignBillingType();
 
       // check for is_monetary status
       $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
index ae33a8a464d501a724a204da6deb75d41dafa6e3..0241423f9b33dbf86824e2adde039cb883ea2e9e 100644 (file)
@@ -111,13 +111,7 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Core_Form {
     }
     $this->assign('paymentProcessor', $this->_paymentProcessor);
 
-    // get the billing location type
-    $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
-    $this->_bltID = array_search('Billing', $locationTypes);
-    $this->assign('bltID', $this->_bltID);
-    if (!$this->_bltID) {
-      CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
-    }
+    $this->assignBillingType();
 
     $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
     $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
index e12c0398ebbdac3593d88dd48ad4b48180807dee..cfc74cd982e0b2e33a233f7955d68f1be313db40 100644 (file)
@@ -94,6 +94,26 @@ class CRM_Core_BAO_Location extends CRM_Core_DAO {
     return $location;
   }
 
+  /**
+   * Get the ID of the database billing location.
+   *
+   * @return int
+   *   Billing location type id.
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public static function getBillingLocationId() {
+    static $billingTypeID = NULL;
+    if ($billingTypeID) {
+      return $billingTypeID;
+    }
+    $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
+    $billingTypeID = array_search('Billing', $locationTypes);
+    if (!$billingTypeID) {
+      throw new CRM_Core_Exception(ts('Please set a location type of %1', array(1 => 'Billing')));
+    }
+    return $billingTypeID;
+  }
   /**
    * Creates the entry in the civicrm_loc_block.
    */
index d5e95ef4337eaf4396d74d710be5cbdd90c58350..49f96e639b66027ee8615de9e92735200dd912c9 100644 (file)
@@ -620,13 +620,22 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    *
    * @param string $title
    *   The title of the form.
-   *
-   * @return void
    */
   public function setTitle($title) {
     $this->_title = $title;
   }
 
+  /**
+   * Assign billing type id to bltID.
+   *
+   * @throws CRM_Core_Exception
+   */
+  public function assignBillingType() {
+    $this->_bltID = CRM_Core_BAO_Location::getBillingLocationId();
+    $this->set('bltID', $this->_bltID);
+    $this->assign('bltID', $this->_bltID);
+  }
+
   /**
    * Setter function for options.
    *
@@ -1263,7 +1272,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
         break;
 
       case 'hidden':
-        $this->add('hidden', $name, $label, $props, $required);
+        $this->add('hidden', $name, NULL, $props, $required);
         break;
 
       case 'TextArea':
index a8413db4218751732b097b8a622b42716f1ba60e..f7a874203005ba0e2edbf51b1c78b9df0f4e6216 100644 (file)
@@ -19,9 +19,7 @@ class CRM_Event_Cart_Form_Cart extends CRM_Core_Form {
 
     $this->checkWaitingList();
 
-    $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
-    $this->_bltID = array_search('Billing', $locationTypes);
-    $this->assign('bltID', $this->_bltID);
+    $this->assignBillingType();
 
     $event_titles = array();
     foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) {
index 432a01bbdd59dbb929035eb3912109012a6f53a3..55566e1b3ad17bf99c04325a99439c6b397849a5 100644 (file)
@@ -374,15 +374,8 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
           unset($this->_values['additional_custom_post_id']);
         }
       }
-      // get the billing location type
-      $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
-      // CRM-8108 remove ts from Billing as the location type can not be translated in CiviCRM!
-      //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
-      $this->_bltID = array_search('Billing', $locationTypes);
-      if (!$this->_bltID) {
-        CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
-      }
-      $this->set('bltID', $this->_bltID);
+
+      $this->assignBillingType();
 
       if ($this->_values['event']['is_monetary']) {
         CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
index e77b9158893b3b36edcad3f23ac015fd87981522..5c46aa8d0d285e5afffe165a9b21fdbe9cf8edc2 100644 (file)
@@ -370,6 +370,7 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R
     }
     $this->addButtons($buttons);
     $this->addFormRule(array('CRM_Event_Form_Registration_AdditionalParticipant', 'formRule'), $this);
+    $this->unsavedChangesWarn = TRUE;
   }
 
   /**
index 8611fd155c5b11031f7248f229dc160cd4848693..33fc16c1dea7465c13e9b260ddac3ebddc8a4bdb 100644 (file)
@@ -548,6 +548,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     }
 
     $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this);
+    $this->unsavedChangesWarn = TRUE;
 
     // add pcp fields
     if ($this->_pcpId) {
index 2af8c8b677511e7ee67bbf775a92b86b1b42c4d1..6c126107d6f9f3ff9c40350e4f9636e24458691d 100644 (file)
@@ -1125,11 +1125,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
           break;
 
         case CRM_Utils_Type::T_TIMESTAMP:
-          // 4.6 doesn't support timestamp updates from 4.7 we should uncomment this. See CRM-16431.
-          continue;
-
-        //case CRM_Utils_Type::T_DATETIME:
-
         case 12:
           $entity[$fieldName] = '2012-05-20 03:05:20';
           break;