Merge pull request #4893 from colemanw/INFRA-132
[civicrm-core.git] / CRM / Campaign / Form / Task / Interview.php
index b0721677dfb81bcbba5eb9757facc7eb22ab4832..617b887863d8061139b6e9e5900f3aca6ebc3825 100755 (executable)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -47,7 +47,6 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task {
 
   /**
    * Variable to store redirect path
-   *
    */
   private $_userContext;
 
@@ -73,9 +72,8 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task {
    * Build all the data structures needed to build the form
    *
    * @return void
-   * @access public
    */
-  function preProcess() {
+  public function preProcess() {
     $this->_votingTab = $this->get('votingTab');
     $this->_reserveToInterview = $this->get('reserveToInterview');
     if ($this->_reserveToInterview || $this->_votingTab) {
@@ -96,36 +94,32 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task {
       $this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
     }
 
-    if ( $this->_surveyId ) {
+    if ($this->_surveyId) {
       $params = array('id' => $this->_surveyId);
       CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
     }
 
-    $orderClause = false;
+    $orderClause = FALSE;
     $buttonName  = $this->controller->getButtonName();
-    if ( $buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
+    if ($buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
       $orderByParams = CRM_Utils_Array::value('order_bys', $_POST);
     }
-    elseif ( CRM_Core_OptionGroup::getValue('activity_type','WalkList') == $this->_surveyDetails['activity_type_id'] ) {
+    elseif (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
       $orderByParams =
         array(
-          1 =>
-          array(
+          1 => array(
             'column' => 'civicrm_address.street_name',
             'order'  => 'ASC',
           ),
-          2 =>
-          array(
+          2 => array(
             'column' => 'civicrm_address.street_number%2',
             'order' => 'ASC',
           ),
-          3 =>
-          array(
+          3 => array(
             'column' => 'civicrm_address.street_number',
             'order' => 'ASC',
           ),
-          4 =>
-          array(
+          4 => array(
             'column' => 'contact_a.sort_name',
             'order' => 'ASC',
           ),
@@ -133,13 +127,13 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task {
     }
 
     $orderBy = array();
-    if ( !empty($orderByParams) ) {
-      foreach ( $orderByParams as $key => $val ) {
+    if (!empty($orderByParams)) {
+      foreach ($orderByParams as $key => $val) {
         if (!empty($val['column'])) {
           $orderBy[] = "{$val['column']} {$val['order']}";
         }
       }
-      if ( !empty($orderBy) ) {
+      if (!empty($orderBy)) {
         $orderClause = "ORDER BY " . implode(', ', $orderBy);
       }
     }
@@ -161,7 +155,6 @@ WHERE {$clause}
       }
     }
 
-
     //get the contact read only fields to display.
     $readOnlyFields = array_merge(array(
       'contact_type' => '',
@@ -234,7 +227,7 @@ WHERE {$clause}
     $this->assign('surveyValues', $this->_surveyValues);
 
     $result = CRM_Campaign_BAO_Survey::getReportID($this->_surveyId);
-    $this->assign("instanceId",$result);
+    $this->assign("instanceId", $result);
 
     //get the survey result options.
     $this->_resultOptions = $this->get('resultOptions');
@@ -261,8 +254,9 @@ WHERE {$clause}
     CRM_Utils_System::setTitle(ts('Record %1 Responses', array(1 => $activityTypes[$this->_surveyTypeId])));
   }
 
-  function validateIds() {
-    $required = array('surveyId' => ts('Could not find Survey.'),
+  public function validateIds() {
+    $required = array(
+    'surveyId' => ts('Could not find Survey.'),
       'interviewerId' => ts('Could not find Interviewer.'),
       'contactIds' => ts('No respondents are currently reserved for you to interview.'),
       'resultOptions' => ts('Oops. It looks like there is no response option configured.'),
@@ -285,15 +279,15 @@ WHERE {$clause}
   /**
    * Build the form object
    *
-   * @access public
    *
    * @return void
    */
-  function buildQuickForm() {
+  public function buildQuickForm() {
     $this->assign('surveyTypeId', $this->_surveyTypeId);
 
     $options =
-      array('' => ' - none - ',
+      array(
+    '' => ' - none - ',
         'civicrm_address.street_name'     => 'Street Name',
         'civicrm_address.street_number%2' => 'Odd / Even Street Number',
         'civicrm_address.street_number'   => 'Street Number',
@@ -312,7 +306,7 @@ WHERE {$clause}
     foreach ($this->_contactIds as $contactId) {
       //build the profile fields.
       foreach ($this->_surveyFields as $name => $field) {
-        if ($field){
+        if ($field) {
           CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contactId);
         }
       }
@@ -344,7 +338,8 @@ WHERE {$clause}
     }
 
     $buttons = array(
-      array('type' => 'cancel',
+      array(
+    'type' => 'cancel',
         'name' => ts('Done'),
         'subName' => 'interview',
         'isDefault' => TRUE,
@@ -385,11 +380,10 @@ WHERE {$clause}
   /**
    * Set default values for the form.
    *
-   * @access public
    *
    * @return void
    */
-  function setDefaultValues() {
+  public function setDefaultValues() {
     //load default data for only contact fields.
     $contactFields = $defaults = array();
     foreach ($this->_surveyFields as $name => $field) {
@@ -405,26 +399,22 @@ WHERE {$clause}
       }
     }
 
-    if ( CRM_Core_OptionGroup::getValue('activity_type','WalkList') == $this->_surveyDetails['activity_type_id'] ) {
+    if (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
       $defaults['order_bys'] =
         array(
-          1 =>
-          array(
+          1 => array(
             'column' => 'civicrm_address.street_name',
             'order'  => 'ASC',
           ),
-          2 =>
-          array(
+          2 => array(
             'column' => 'civicrm_address.street_number%2',
             'order' => 'ASC',
           ),
-          3 =>
-          array(
+          3 => array(
             'column' => 'civicrm_address.street_number',
             'order' => 'ASC',
           ),
-          4 =>
-          array(
+          4 => array(
             'column' => 'contact_a.sort_name',
             'order' => 'ASC',
           ),
@@ -446,7 +436,6 @@ WHERE {$clause}
   /**
    * Process the form after the input has been submitted and validated
    *
-   * @access public
    *
    * @return void
    */
@@ -474,7 +463,7 @@ WHERE {$clause}
    *
    * @return mixed
    */
-  static function registerInterview($params) {
+  public static function registerInterview($params) {
     $activityId = CRM_Utils_Array::value('activity_id', $params);
     $surveyTypeId = CRM_Utils_Array::value('activity_type_id', $params);
     if (!is_array($params) || !$surveyTypeId || !$activityId) {
@@ -563,7 +552,7 @@ WHERE {$clause}
       'source_contact_id' => 'source_contact',
       'location' => 'activity_location',
       'campaign_id' => 'activity_campaign_id',
-      'duration' => 'activity_duration'
+      'duration' => 'activity_duration',
     );
     foreach ($activityParams as $key => $field) {
       if (!empty($params[$field])) {
@@ -580,7 +569,7 @@ WHERE {$clause}
     return $activityId;
   }
 
-  function getVoterIds() {
+  public function getVoterIds() {
     if (!$this->_interviewerId) {
       $session = CRM_Core_Session::singleton();
       $this->_interviewerId = $session->get('userID');
@@ -607,12 +596,14 @@ WHERE {$clause}
         $statusIds
       );
       $this->_contactIds = array();
-      foreach ($surveyActivities as $val) $this->_contactIds[$val['voter_id']] = $val['voter_id'];
+      foreach ($surveyActivities as $val) {
+        $this->_contactIds[$val['voter_id']] = $val['voter_id'];
+      }
       $this->set('contactIds', $this->_contactIds);
     }
   }
 
-  function filterVoterIds() {
+  public function filterVoterIds() {
     //do the cleanup later on.
     if (!is_array($this->_contactIds)) {
       return;
@@ -663,4 +654,3 @@ INNER JOIN  {$tempTableName} ON ( {$tempTableName}.survey_contact_id = contact.i
     }
   }
 }
-