Merge pull request #5120 from eileenmcnaughton/CRM-15938
[civicrm-core.git] / CRM / Contribute / Form.php
index c9bc305cee21dad1c9429ada139fc31dd7e2fa8a..ddc30aa4a99dd523cb83614dba675c072960d58c 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
 
 /**
- * This class generates form components generic to Mobile provider
+ * This class generates form components generic to Contribution admin
  *
  */
-class CRM_Contribute_Form extends CRM_Core_Form {
-
-  /**
-   * The id of the object being edited / created
-   *
-   * @var int
-   */
-  protected $_id;
+class CRM_Contribute_Form extends CRM_Admin_Form {
 
   /**
-   * The name of the BAO object for this form
-   *
-   * @var string
-   */
-  protected $_BAOName; function preProcess() {
-    $this->_id = $this->get('id');
-    $this->_BAOName = $this->get('BAOName');
-  }
-
-  /**
-   * This function sets the default values for the form. MobileProvider that in edit/view mode
+   * Set default values for the form. Note that in edit/view mode
    * the default values are retrieved from the database
    *
-   * @access public
    *
-   * @return None
+   * @return array
    */
-  function setDefaultValues() {
+  public function setDefaultValues() {
     $defaults = array();
-    $params = array();
 
     if (isset($this->_id)) {
       $params = array('id' => $this->_id);
-      if (!empty( $this->_BAOName)) {
+      if (!empty($this->_BAOName)) {
         $baoName = $this->_BAOName;
         $baoName::retrieve($params, $defaults);
       }
     }
-    if ($this->_action == CRM_Core_Action::DELETE && CRM_Utils_Array::value('name', $defaults)) {
+    if ($this->_action == CRM_Core_Action::DELETE && !empty($defaults['name'])) {
       $this->assign('delName', $defaults['name']);
     }
     elseif ($this->_action == CRM_Core_Action::ADD) {
       $condition = " AND is_default = 1";
-      $values = CRM_Core_OptionGroup::values('financial_account_type', false, false, false, $condition);
+      $values = CRM_Core_OptionGroup::values('financial_account_type', FALSE, FALSE, FALSE, $condition);
       $defaults['financial_account_type_id'] = array_keys($values);
       $defaults['is_active'] = 1;
 
     }
     elseif ($this->_action & CRM_Core_Action::UPDATE) {
-      if (CRM_Utils_Array::value('contact_id', $defaults) || CRM_Utils_Array::value('created_id', $defaults)) {
-        $contactID = CRM_Utils_Array::value('created_id', $defaults) ? $defaults['created_id'] : $defaults['contact_id'];
+      if (!empty($defaults['contact_id']) || !empty($defaults['created_id'])) {
+        $contactID = !empty($defaults['created_id']) ? $defaults['created_id'] : $defaults['contact_id'];
         $this->assign('created_id', $contactID);
         $this->assign('organisationId', $contactID);
       }
@@ -99,40 +80,4 @@ class CRM_Contribute_Form extends CRM_Core_Form {
     return $defaults;
   }
 
-  /**
-   * Function to actually build the form
-   *
-   * @return None
-   * @access public
-   */
-  public function buildQuickForm() {
-    $this->addButtons(array(
-        array(
-          'type' => 'next',
-          'name' => ts('Save'),
-          'isDefault' => TRUE,
-        ),
-        array(
-          'type' => 'cancel',
-          'name' => ts('Cancel'),
-        ),
-      )
-    );
-
-    if ($this->_action & CRM_Core_Action::DELETE) {
-      $this->addButtons(array(
-          array(
-            'type' => 'next',
-            'name' => ts('Delete'),
-            'isDefault' => TRUE,
-          ),
-          array(
-            'type' => 'cancel',
-            'name' => ts('Cancel'),
-          ),
-        )
-      );
-    }
-  }
 }
-