Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-01-26-14-28-00
[civicrm-core.git] / CRM / Contact / Form / Task.php
index c905d054f2826ff77d3dff41ae1ad13272579c3c..1d1228e9f12bf5ab10a6fa431399ebb8b6511d76 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | 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-2014
  * $Id$
- *
  */
 
 /**
  * This class generates form components for search-result tasks
- *
  */
 class CRM_Contact_Form_Task extends CRM_Core_Form {
 
@@ -87,22 +85,19 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
   static protected $_searchFormValues;
 
   /**
-   * Build all the data structures needed to build the form
-   *
-   * @param
-   *
-   * @return void
-   * @access public
+   * Build all the data structures needed to build the form.
    */
-  function preProcess() {
+  public function preProcess() {
     self::preProcessCommon($this);
   }
 
   /**
+   * Common pre-processing function.
+   *
    * @param CRM_Core_Form $form
    * @param bool $useTable
    */
-  static function preProcessCommon(&$form, $useTable = FALSE) {
+  public static function preProcessCommon(&$form, $useTable = FALSE) {
 
     $form->_contactIds = array();
     $form->_contactTypes = array();
@@ -259,7 +254,6 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
       }
     }
 
-
     if (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_sel'
       && ($form->_action != CRM_Core_Action::COPY)
     ) {
@@ -278,8 +272,9 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
   }
 
   /**
-   * Get the contact id for custom search
-   * we are not using prev/next table incase of custom search
+   * Get the contact id for custom search.
+   *
+   * we are not using prev/next table in case of custom search
    */
   public function getContactIds() {
     // need to perform action on all contacts
@@ -292,7 +287,7 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
     }
 
     $selectorName = $this->controller->selectorName();
-    require_once(str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php');
+    require_once str_replace('_', DIRECTORY_SEPARATOR, $selectorName) . '.php';
 
     $fv = $this->get('formValues');
     $customClass = $this->get('customSearchClass');
@@ -327,60 +322,49 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
 
 
   /**
-   * Set default values for the form. Relationship that in edit/view action
-   * the default values are retrieved from the database
+   * Set default values for the form. Relationship that in edit/view action.
    *
-   * @access public
+   * The default values are retrieved from the database.
    *
    * @return array
    */
-  function setDefaultValues() {
+  public function setDefaultValues() {
     $defaults = array();
     return $defaults;
   }
 
   /**
-   * This function is used to add the rules for form.
-   *
-   * @return void
-   * @access public
+   * Add the rules for form.
    */
-  function addRules() {
+  public function addRules() {
   }
 
   /**
-   * Build the form object
-   *
-   * @return void
-   * @access public
+   * Build the form object.
    */
   public function buildQuickForm() {
     $this->addDefaultButtons(ts('Confirm Action'));
   }
 
   /**
-   * Process the form after the input has been submitted and validated
-   *
-   * @access public
-   *
-   * @return void
+   * Process the form after the input has been submitted and validated.
    */
   public function postProcess() {
   }
 
   /**
-   * Simple shell that derived classes can call to add buttons to
-   * the form with a customized title for the main Submit
+   * Simple shell that derived classes can call to add form buttons.
+   *
+   * Allows customized title for the main Submit
    *
-   * @param string $title title of the main button
-   * @param string $nextType button type for the form after processing
+   * @param string $title
+   *   Title of the main button.
+   * @param string $nextType
+   *   Button type for the form after processing.
    * @param string $backType
    * @param bool $submitOnce
-   *
-   * @return void
-   * @access public
    */
-  function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
+  public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
     $this->addButtons(array(
         array(
           'type' => $nextType,
@@ -397,11 +381,8 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
 
   /**
    * Replace ids of household members in $this->_contactIds with the id of their household.
-   * CRM-8338
    *
-   * @access public
-   *
-   * @return void
+   * CRM-8338
    */
   public function mergeContactIdsByHousehold() {
     if (empty($this->_contactIds)) {
@@ -439,15 +420,15 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
       }
 
       // Find related households.
-      $relationSelect      = "SELECT contact_household.id as household_id, {$contactA} as refContact ";
+      $relationSelect = "SELECT contact_household.id as household_id, {$contactA} as refContact ";
       $relationFrom = " FROM civicrm_contact contact_household
               INNER JOIN civicrm_relationship crel ON crel.{$contactB} = contact_household.id AND crel.relationship_type_id = {$id} ";
 
       // Check for active relationship status only.
-      $today               = date('Ymd');
-      $relationActive      = " AND (crel.is_active = 1 AND ( crel.end_date is NULL OR crel.end_date >= {$today} ) )";
-      $relationWhere       = " WHERE contact_household.is_deleted = 0  AND crel.{$contactA} IN ( {$relID} ) {$relationActive}";
-      $relationGroupBy     = " GROUP BY crel.{$contactA}";
+      $today = date('Ymd');
+      $relationActive = " AND (crel.is_active = 1 AND ( crel.end_date is NULL OR crel.end_date >= {$today} ) )";
+      $relationWhere = " WHERE contact_household.is_deleted = 0  AND crel.{$contactA} IN ( {$relID} ) {$relationActive}";
+      $relationGroupBy = " GROUP BY crel.{$contactA}";
       $relationQueryString = "$relationSelect $relationFrom $relationWhere $relationGroupBy";
 
       $householdsDAO = CRM_Core_DAO::executeQuery($relationQueryString);
@@ -463,5 +444,5 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
       $householdsDAO->free();
     }
   }
-}
 
+}