Merge pull request #4979 from xurizaemon/codingstandards-12
[civicrm-core.git] / CRM / Contact / Form / Task / AddToHousehold.php
index 75589dab4b7d2452be6af4f82ff1e995d350df0b..f537e23ca0c6d74d65682772f56fdfd69024a1f9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -41,33 +41,29 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task {
   /**
    * Build the form object
    *
-   * @access public
    *
    * @return void
    */
-  function preProcess() {
-    /*
-         * initialize the task and row fields
-         */
-
+  public function preProcess() {
+    // initialize the task and row fields
     parent::preProcess();
   }
 
   /**
    * Build the form object
    *
-   * @access public
    *
    * @return void
    */
-  function buildQuickForm() {
+  public function buildQuickForm() {
 
     CRM_Utils_System::setTitle(ts('Add Members to Household'));
     $this->addElement('text', 'name', ts('Find Target Household'));
 
     $this->add('select', 'relationship_type_id', ts('Relationship Type'),
       array(
-        '' => ts('- select -')) +
+        '' => ts('- select -'),
+      ) +
       CRM_Contact_BAO_Relationship::getRelationType("Household"), TRUE
     );
 
@@ -110,9 +106,8 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task {
   }
 
   /**
-   * process the form after the input has been submitted and validated
+   * Process the form after the input has been submitted and validated
    *
-   * @access public
    *
    * @return void
    */
@@ -148,10 +143,11 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task {
         }
 
         if (CRM_Contact_BAO_Relationship::checkDuplicateRelationship($params,
-            CRM_Utils_Array::value('contact', $ids),
-            // step 2
-            $params['contact_check']
-          )) {
+          CRM_Utils_Array::value('contact', $ids),
+          // step 2
+          $params['contact_check']
+        )
+        ) {
           $duplicate++;
           continue;
         }
@@ -163,29 +159,47 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task {
       list($rtype, $a_b) = explode('_', $data['relationship_type_id'], 2);
       $relationship = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $rtype, "label_$a_b");
 
-      $status = array(ts('%count %2 %3 relationship created', array('count' => $valid, 'plural' => '%count %2 %3 relationships created', 2 => $relationship, 3 => $house)));
+      $status = array(
+        ts('%count %2 %3 relationship created', array(
+            'count' => $valid,
+            'plural' => '%count %2 %3 relationships created',
+            2 => $relationship,
+            3 => $house,
+        )),
+      );
       if ($duplicate) {
-        $status[] = ts('%count was skipped because the contact is already %2 %3', array('count' => $duplicate, 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationship, 3 => $house));
+        $status[] = ts('%count was skipped because the contact is already %2 %3', array(
+            'count' => $duplicate,
+            'plural' => '%count were skipped because the contacts are already %2 %3',
+            2 => $relationship,
+            3 => $house,
+          ));
       }
       if ($invalid) {
-        $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array('count' => $invalid, 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship'));
+        $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array(
+            'count' => $invalid,
+            'plural' => '%count relationships were not created because the contact is not of the right type for this relationship',
+          ));
       }
       $status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
-      CRM_Core_Session::setStatus($status, ts('Relationship created.', array('count' => $valid, 'plural' => 'Relationships created.')), 'success', array('expires' => 0));
+      CRM_Core_Session::setStatus($status, ts('Relationship created.', array(
+            'count' => $valid,
+            'plural' => 'Relationships created.',
+          )), 'success', array('expires' => 0));
     }
   }
 
   /**
-   * This function is to get the result of the search for Add to * forms
+   * get the result of the search for Add to * forms
    *
    * @param CRM_Core_Form $form
-   * @param  array $params This contains elements for search criteria
+   * @param array $params
+   *   This contains elements for search criteria.
    *
-   * @access public
    *
    * @return void
    */
-  function search(&$form, &$params) {
+  public function search(&$form, &$params) {
     //max records that will be listed
     $searchValues = array();
     if (!empty($params['rel_contact'])) {
@@ -238,8 +252,8 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task {
     }
 
     // get the count of contact
-    $contactBAO  = new CRM_Contact_BAO_Contact();
-    $query       = new CRM_Contact_BAO_Query($searchValues);
+    $contactBAO = new CRM_Contact_BAO_Contact();
+    $query = new CRM_Contact_BAO_Query($searchValues);
     $searchCount = $query->searchQuery(0, 0, NULL, TRUE);
     $form->set('searchCount', $searchCount);
     if ($searchCount <= 50) {
@@ -271,8 +285,7 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task {
 
         $contact_type = '<img src="' . $config->resourceBase . 'i/contact_';
 
-        $searchRows[$contactID]['type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ?
-          $result->contact_sub_type : $result->contact_type
+        $searchRows[$contactID]['type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type
         );
       }
 
@@ -286,4 +299,3 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task {
     }
   }
 }
-