INFRA-132 - Docblock @param and @return tag fixes
[civicrm-core.git] / CRM / Campaign / BAO / Survey.php
index 4fb907220f2b48142b4fa94f2808ea16065d77c7..888a96cc278e0969a0afc1926c2a51c7dbd5e2a5 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -44,10 +44,10 @@ class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
    * retrieves the relevant objects. Typically the valid params are only
    * campaign_id.
    *
-   * @param array  $params   (reference ) an assoc array of name/value pairs
-   * @param array  $defaults (reference ) an assoc array to hold the flattened values
-   *
-   * @access public
+   * @param array $params
+   *   (reference ) an assoc array of name/value pairs.
+   * @param array $defaults
+   *   (reference ) an assoc array to hold the flattened values.
    */
 
   /**
@@ -58,7 +58,7 @@ class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
    *
    * @return CRM_Campaign_DAO_Survey|null
    */
-  static function retrieve(&$params, &$defaults) {
+  public static function retrieve(&$params, &$defaults) {
     $dao = new CRM_Campaign_DAO_Survey();
 
     $dao->copyValues($params);
@@ -80,12 +80,11 @@ class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
    * @param array $params
    *
    * @return CRM_Survey_DAO_Survey object
-   * @access public
    * @static
    */
-  static function create(&$params) {
+  public static function create(&$params) {
     if (empty($params)) {
-      return false;
+      return FALSE;
     }
 
     if (!empty($params['is_default'])) {
@@ -121,7 +120,7 @@ class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
    *
    * @static
    */
-  static function getSurveySummary($params = array(), $onlyCount = FALSE) {
+  public static function getSurveySummary($params = array(), $onlyCount = FALSE) {
     //build the limit and order clause.
     $limitClause = $orderByClause = $lookupTableJoins = NULL;
     if (!$onlyCount) {
@@ -213,13 +212,21 @@ SELECT  survey.id                         as id,
 
     //return only count.
     if ($onlyCount) {
-      return (int)CRM_Core_DAO::singleValueQuery($query, $queryParams);
+      return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
     }
 
     $surveys = array();
     $properties = array(
-      'id', 'title', 'campaign_id', 'is_active', 'is_default', 'result_id', 'activity_type_id',
-      'release_frequency', 'max_number_of_contacts', 'default_number_of_contacts',
+      'id',
+      'title',
+      'campaign_id',
+      'is_active',
+      'is_default',
+      'result_id',
+      'activity_type_id',
+      'release_frequency',
+      'max_number_of_contacts',
+      'default_number_of_contacts',
     );
 
     $survey = CRM_Core_DAO::executeQuery($query, $queryParams);
@@ -237,21 +244,25 @@ SELECT  survey.id                         as id,
    *
    * @static
    */
-  static function getSurveyCount() {
-    return (int)CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_survey');
+  public static function getSurveyCount() {
+    return (int) CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_survey');
   }
 
   /**
    * Get Surveys
    *
-   * @param boolean $onlyActive  retrieve only active surveys.
-   * @param boolean $onlyDefault retrieve only default survey.
-   * @param boolean $forceAll    retrieve all surveys.
-   * @param boolean $includePetition include or exclude petitions
+   * @param bool $onlyActive
+   *   Retrieve only active surveys.
+   * @param bool $onlyDefault
+   *   Retrieve only default survey.
+   * @param bool $forceAll
+   *   Retrieve all surveys.
+   * @param bool $includePetition
+   *   Include or exclude petitions.
    *
    * @static
    */
-  static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $forceAll = FALSE, $includePetition = FALSE ) {
+  public static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $forceAll = FALSE, $includePetition = FALSE) {
     $cacheKey = 0;
     $cacheKeyParams = array('onlyActive', 'onlyDefault', 'forceAll', 'includePetition');
     foreach ($cacheKeyParams as $param) {
@@ -304,7 +315,8 @@ SELECT  survey.id    as id,
    *
    * @static
    */
-  static function getSurveyActivityType($returnColumn = 'label',
+  static function getSurveyActivityType(
+    $returnColumn = 'label',
     $includePetitionActivityType = FALSE
   ) {
     static $activityTypes;
@@ -336,12 +348,13 @@ SELECT  survey.id    as id,
   /**
    * Get Surveys custom groups
    *
-   * @param $surveyTypes array an array of survey type id.
+   * @param array $surveyTypes
+   *   an array of survey type id.
    *
    * @return array
    * @static
    */
-  static function getSurveyCustomGroups($surveyTypes = array()) {
+  public static function getSurveyCustomGroups($surveyTypes = array()) {
     $customGroups = array();
     if (!is_array($surveyTypes)) {
       $surveyTypes = array($surveyTypes);
@@ -376,32 +389,34 @@ SELECT  survey.id    as id,
   /**
    * Update the is_active flag in the db
    *
-   * @param int      $id        id of the database record
-   * @param boolean  $is_active value we want to set the is_active field
+   * @param int $id
+   *   Id of the database record.
+   * @param bool $is_active
+   *   Value we want to set the is_active field.
    *
-   * @return Object             DAO object on sucess, null otherwise
+   * @return Object
+   *   DAO object on sucess, null otherwise
    * @static
    */
-  static function setIsActive($id, $is_active) {
+  public static function setIsActive($id, $is_active) {
     return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Survey', $id, 'is_active', $is_active);
   }
 
   /**
    * Delete the survey
    *
-   * @param int $id survey id
+   * @param int $id
+   *   Survey id.
    *
    * @return mixed|null
-   * @access public
    * @static
-   *
    */
-  static function del($id) {
+  public static function del($id) {
     if (!$id) {
       return NULL;
     }
     $reportId = CRM_Campaign_BAO_Survey::getReportID($id);
-    if($reportId){
+    if ($reportId) {
       CRM_Report_BAO_ReportInstance::del($reportId);
     }
     $dao = new CRM_Campaign_DAO_Survey();
@@ -413,12 +428,14 @@ SELECT  survey.id    as id,
    * This function retrieve contact information.
    *
    * @param array $voterIds
-   * @param array $returnProperties an array of return elements.
+   * @param array $returnProperties
+   *   An array of return elements.
    *
-   * @return array $voterDetails array of contact info.
+   * @return array
+   *   array of contact info.
    * @static
    */
-  static function voterDetails($voterIds, $returnProperties = array()) {
+  public static function voterDetails($voterIds, $returnProperties = array()) {
     $voterDetails = array();
     if (!is_array($voterIds) || empty($voterIds)) {
       return $voterDetails;
@@ -429,18 +446,20 @@ SELECT  survey.id    as id,
         'contact_autocomplete_options'
       );
       $returnProperties = array_fill_keys(array_merge(array(
-        'contact_type',
-            'contact_sub_type',
-            'sort_name',
-          ),
-          array_keys($autocompleteContactSearch)
-        ), 1);
+          'contact_type',
+          'contact_sub_type',
+          'sort_name',
+        ),
+        array_keys($autocompleteContactSearch)
+      ), 1);
     }
 
     $select = $from = array();
     foreach ($returnProperties as $property => $ignore) {
       $value = (in_array($property, array(
-        'city', 'street_address'))) ? 'address' : $property;
+        'city',
+        'street_address'
+      ))) ? 'address' : $property;
       switch ($property) {
         case 'sort_name':
         case 'contact_type':
@@ -470,9 +489,9 @@ SELECT  survey.id    as id,
 
     //finally retrieve contact details.
     if (!empty($select) && !empty($from)) {
-      $fromClause   = implode(' ', $from);
+      $fromClause = implode(' ', $from);
       $selectClause = implode(', ', $select);
-      $whereClause  = "contact.id IN (" . implode(',', $voterIds) . ')';
+      $whereClause = "contact.id IN (" . implode(',', $voterIds) . ')';
 
       $query = "
   SELECT  contact.id as contactId, $selectClause
@@ -486,8 +505,7 @@ Group By  contact.id";
         foreach ($returnProperties as $property => $ignore) {
           $voterDetails[$contact->contactId][$property] = $contact->$property;
         }
-        $image = CRM_Contact_BAO_Contact_Utils::getImage($contact->contact_sub_type ?
-          $contact->contact_sub_type : $contact->contact_type,
+        $image = CRM_Contact_BAO_Contact_Utils::getImage($contact->contact_sub_type ? $contact->contact_sub_type : $contact->contact_type,
           FALSE,
           $contact->contactId
         );
@@ -502,16 +520,21 @@ Group By  contact.id";
   /**
    * This function retrieve survey related activities w/ for give voter ids.
    *
-   * @param int $surveyId survey id.
-   * @param array $voterIds voterIds.
+   * @param int $surveyId
+   *   Survey id.
+   * @param array $voterIds
+   *   VoterIds.
    *
    * @param int $interviewerId
    * @param array $statusIds
    *
-   * @return array $activityDetails array of survey activity.@static
+   * @return array
+   *   array of survey activity.
+   * @static
    */
-  static function voterActivityDetails($surveyId, $voterIds, $interviewerId = NULL,
-                                       $statusIds = array()) {
+  static function voterActivityDetails(
+    $surveyId, $voterIds, $interviewerId = NULL,
+    $statusIds = array()) {
     $activityDetails = array();
     if (!$surveyId ||
       !is_array($voterIds) || empty($voterIds)
@@ -541,7 +564,7 @@ INNER JOIN  civicrm_activity_contact activityAssignment
   ON ( activityAssignment.activity_id = activity.id AND activityAssignment.record_type_id = $assigneeID )
      WHERE  activity.source_record_id = %1
      AND  ( activity.is_deleted IS NULL OR activity.is_deleted = 0 ) ";
-    if(!empty($interviewerId)) {
+    if (!empty($interviewerId)) {
       $query .= "AND activityAssignment.contact_id = %2 ";
       $params[2] = array($interviewerId, 'Integer');
     }
@@ -563,19 +586,22 @@ INNER JOIN  civicrm_activity_contact activityAssignment
   /**
    * This function retrieve survey related activities.
    *
-   * @param int $surveyId survey id.
-   *
+   * @param int $surveyId
    * @param int $interviewerId
-   * @param null $statusIds
-   * @param null $voterIds
+   * @param array $statusIds
+   * @param array $voterIds
    * @param bool $onlyCount
-   * @return array $activities an array of survey activity.@static
+   *
+   * @return array
+   *   An array of survey activity.
+   * @static
    */
-  static function getSurveyActivities($surveyId,
+  static function getSurveyActivities(
+    $surveyId,
     $interviewerId = NULL,
-    $statusIds     = NULL,
-    $voterIds      = NULL,
-    $onlyCount     = FALSE
+    $statusIds = NULL,
+    $voterIds = NULL,
+    $onlyCount = FALSE
   ) {
     $activities = array();
     $surveyActivityCount = 0;
@@ -636,7 +662,8 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
        AND  ( activity.is_deleted IS NULL OR activity.is_deleted = 0 )
             $whereClause";
 
-    $params = array(1 => array($surveyId, 'Integer'),
+    $params = array(
+      1 => array($surveyId, 'Integer'),
       2 => array($actTypeId, 'Integer'),
     );
 
@@ -655,7 +682,7 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
         'status_id' => $activity->status_id,
         'interviewer_id' => $activity->interviewer_id,
         'result' => $activity->result,
-        'activity_date_time' => $activity->activity_date_time
+        'activity_date_time' => $activity->activity_date_time,
       );
     }
 
@@ -663,16 +690,20 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
   }
 
   /**
-   * This function retrieve survey voter information.
+   * Retrieve survey voter information.
    *
-   * @param int    $surveyId       survey id.
-   * @param int    $interviewerId  interviewer id.
-   * @param array  $statusIds      survey status ids.
+   * @param int $surveyId
+   *   Survey id.
+   * @param int $interviewerId
+   *   Interviewer id.
+   * @param array $statusIds
+   *   Survey status ids.
    *
-   * @return array $$contactIds survey related contact ids.
+   * @return array
+   *   Survey related contact ids.
    * @static
    */
-  static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $statusIds = array( )) {
+  public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $statusIds = array()) {
     $voterIds = array();
     if (!$surveyId) {
       return $voterIds;
@@ -702,14 +733,16 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    * This function retrieve all option groups which are created as a result set
    *
    * @param string $valueColumnName
-   * @return array $resultSets an array of option groups.@static
+   * @return array
+   *   an array of option groups.
+   * @static
    */
-  static function getResultSets( $valueColumnName = 'title' ) {
+  public static function getResultSets($valueColumnName = 'title') {
     $resultSets = array();
     $valueColumnName = CRM_Utils_Type::escape($valueColumnName, 'String');
 
-    $query      = "SELECT id, {$valueColumnName} FROM civicrm_option_group WHERE name LIKE 'civicrm_survey_%' AND is_active=1";
-    $dao        = CRM_Core_DAO::executeQuery($query);
+    $query = "SELECT id, {$valueColumnName} FROM civicrm_option_group WHERE name LIKE 'civicrm_survey_%' AND is_active=1";
+    $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
       $resultSets[$dao->id] = $dao->$valueColumnName;
     }
@@ -718,13 +751,14 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
   }
 
   /**
-   * This function is to check survey activity.
+   * check survey activity.
    *
-   * @param int $activityId activity id.
-   * @return boolean $isSurveyActivity true/false
+   * @param int $activityId
+   *   Activity id.
+   * @return boolean
    * @static
    */
-  static function isSurveyActivity($activityId) {
+  public static function isSurveyActivity($activityId) {
     $isSurveyActivity = FALSE;
     if (!$activityId) {
       return $isSurveyActivity;
@@ -748,10 +782,13 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
   /**
    * This function retrive all response options of survey
    *
-   * @param int $surveyId survey id.
-   * @return array $responseOptions an array of option values@static
+   * @param int $surveyId
+   *   Survey id.
+   * @return array
+   *   an array of option values
+   * @static
    */
-  static function getResponsesOptions($surveyId) {
+  public static function getResponsesOptions($surveyId) {
     $responseOptions = array();
     if (!$surveyId) {
       return $responseOptions;
@@ -771,9 +808,11 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    * @param int $surveyId
    * @param bool $enclosedInUL
    * @param string $extraULName
-   * @return array|string $url array of permissioned links@static
+   * @return array|string
+   *   $url array of permissioned links
+   * @static
    */
-  static function buildPermissionLinks($surveyId, $enclosedInUL = FALSE, $extraULName = 'more') {
+  public static function buildPermissionLinks($surveyId, $enclosedInUL = FALSE, $extraULName = 'more') {
     $menuLinks = array();
     if (!$surveyId) {
       return $menuLinks;
@@ -819,11 +858,11 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
       if ($reportID) {
         $voterLinks['report'] =
           array(
-                'name' => 'report',
-                'url'  => "civicrm/report/instance/{$reportID}",
-                'qs'   => 'reset=1',
-                'title' => ts('View Survey Report'),
-                );
+            'name' => 'report',
+            'url' => "civicrm/report/instance/{$reportID}",
+            'qs' => 'reset=1',
+            'title' => ts('View Survey Report'),
+          );
       }
     }
 
@@ -855,7 +894,6 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
 
   /**
    * Retrieve survey associated profile id.
-   *
    */
   public static function getSurveyProfileId($surveyId) {
     if (!$surveyId) {
@@ -894,7 +932,7 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
 
     if (!array_key_exists($surveyId, $reportIds)) {
       $query = "SELECT MAX(id) as id FROM civicrm_report_instance WHERE name = %1";
-      $reportID = CRM_Core_DAO::singleValueQuery($query, array(1 => array("survey_{$surveyId}",'String')));
+      $reportID = CRM_Core_DAO::singleValueQuery($query, array(1 => array("survey_{$surveyId}", 'String')));
       $reportIds[$surveyId] = $reportID;
     }
     return $reportIds[$surveyId];
@@ -902,7 +940,6 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
 
   /**
    * Decides the contact type for given survey.
-   *
    */
   public static function getSurveyContactType($surveyId) {
     $contactType = NULL;
@@ -921,14 +958,13 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
 
   /**
    * Get survey supportable profile types
-   *
    */
   public static function surveyProfileTypes() {
     static $profileTypes;
 
     if (!isset($profileTypes)) {
       $profileTypes = array_merge(array('Activity', 'Contact'), CRM_Contact_BAO_ContactType::basicTypes());
-      $profileTypes = array_diff($profileTypes, array('Organization','Household'));
+      $profileTypes = array_diff($profileTypes, array('Organization', 'Household'));
     }
 
     return $profileTypes;
@@ -938,10 +974,13 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    * Get the valid survey response fields those
    * are configured with profile and custom fields.
    *
-   * @param int $surveyId     survey id.
-   * @param int $surveyTypeId survey activity type id.
+   * @param int $surveyId
+   *   Survey id.
+   * @param int $surveyTypeId
+   *   Survey activity type id.
    *
-   * @return array an array of valid survey response fields.
+   * @return array
+   *   an array of valid survey response fields.
    */
   public static function getSurveyResponseFields($surveyId, $surveyTypeId = NULL) {
     if (empty($surveyId)) {
@@ -1008,7 +1047,8 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
   /**
    * Get all interviewers of surveys.
    *
-   * @return array an array of valid survey response fields.
+   * @return array
+   *   an array of valid survey response fields.
    */
   public static function getInterviewers() {
     static $interviewers;
@@ -1049,7 +1089,8 @@ INNER JOIN  civicrm_survey survey ON ( activity.source_record_id = survey.id )
    *
    * @param array $params
    *
-   * @return array success message
+   * @return array
+   *   success message
    */
   public static function releaseRespondent($params) {
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
@@ -1109,9 +1150,9 @@ UPDATE  civicrm_activity
    * Get options for a given field.
    * @see CRM_Core_DAO::buildOptions
    *
-   * @param String $fieldName
-   * @param String $context: @see CRM_Core_DAO::buildOptionsContext
-   * @param Array  $props: whatever is known about this dao object
+   * @param string $fieldName
+   * @param string $context : @see CRM_Core_DAO::buildOptionsContext
+   * @param array $props : whatever is known about this dao object
    *
    * @return array|bool
    */
@@ -1129,4 +1170,3 @@ UPDATE  civicrm_activity
     return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
   }
 }
-