fix some spelling:
[civicrm-core.git] / CRM / Event / BAO / Event.php
index 5945b2a53425ffcd20852074f387d69626a655c0..80e449da2e766cde9ac7a01635dff19890aad290 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -37,21 +37,22 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
   /**
    * Class constructor
    */
-  function __construct() {
+  public function __construct() {
     parent::__construct();
   }
 
   /**
    * Fetch object based on array of properties
    *
-   * @param array $params   (reference ) an assoc array of name/value pairs
-   * @param array $defaults (reference ) an assoc array to hold the flattened values
+   * @param array $params
+   *   (reference ) an assoc array of name/value pairs.
+   * @param array $defaults
+   *   (reference ) an assoc array to hold the flattened values.
    *
-   * @return CRM_Event_BAO_ManageEvent object
-   * @access public
+   * @return CRM_Event_BAO_ManageEvent
    * @static
    */
-  static function retrieve(&$params, &$defaults) {
+  public static function retrieve(&$params, &$defaults) {
     $event = new CRM_Event_DAO_Event();
     $event->copyValues($params);
     if ($event->find(TRUE)) {
@@ -64,27 +65,30 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
   /**
    * 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_Event_DAO_Event', $id, 'is_active', $is_active);
   }
 
   /**
    * Add the event
    *
-   * @param array $params reference array contains the values submitted by the form
+   * @param array $params
+   *   Reference array contains the values submitted by the form.
    *
-   * @access public
    * @static
    *
    * @return object
    */
-  static function add(&$params) {
+  public static function add(&$params) {
     CRM_Utils_System::flushCache();
     $financialTypeId = NULL;
     if (!empty($params['id'])) {
@@ -117,12 +121,11 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
   /**
    * Create the event
    *
-   * @param array $params reference array contains the values submitted by the form
+   * @param array $params
+   *   Reference array contains the values submitted by the form.
    *
    * @return object
-   * @access public
    * @static
-   *
    */
   public static function create(&$params) {
     $transaction = new CRM_Core_Transaction();
@@ -176,14 +179,13 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
   /**
    * Delete the event
    *
-   * @param int $id event id
+   * @param int $id
+   *   Event id.
    *
    * @return mixed|null
-   * @access public
    * @static
-   *
    */
-  static function del($id) {
+  public static function del($id) {
     if (!$id) {
       return NULL;
     }
@@ -195,7 +197,8 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
     foreach ($groupTree as $values) {
       $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
 
-      $params = array(1 => array($values['table_name'], 'string'),
+      $params = array(
+        1 => array($values['table_name'], 'string'),
         2 => array($id, 'integer'),
       );
 
@@ -227,13 +230,14 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
    * Delete the location block associated with an event,
    * if not being used by any other event.
    *
-   * @param $locBlockId location block id to be deleted
-   * @param int $eventId event with which loc block is associated
+   * @param $locBlockId
+   *   Location block id to be deleted.
+   * @param int $eventId
+   *   Event with which loc block is associated.
    *
-   * @access public
    * @static
    */
-  static function deleteEventLocBlock($locBlockId, $eventId = NULL) {
+  public static function deleteEventLocBlock($locBlockId, $eventId = NULL) {
     $query = "SELECT count(ce.id) FROM civicrm_event ce WHERE ce.loc_block_id = $locBlockId";
 
     if ($eventId) {
@@ -250,19 +254,23 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
   /**
    * Get current/future Events
    *
-   * @param $all              int     0 returns current and future events
+   * @param int $all
+   *   0 returns current and future events.
    *                                  1 if events all are required
    *                                  2 returns events since 3 months ago
-   * @param bool|int $id int     id of a specific event to return
-   * @param $isActive         boolean true if you need only active events
-   * @param $checkPermission  boolean true if you need to check permission else false
+   * @param bool|int $id int id of a specific event to return
+   * @param bool $isActive
+   *   true if you need only active events.
+   * @param bool $checkPermission
+   *   true if you need to check permission else false.
    *
    * @return array
    * @static
    */
-  static function getEvents($all = 0,
-    $id              = FALSE,
-    $isActive        = TRUE,
+  static function getEvents(
+    $all = 0,
+    $id = FALSE,
+    $isActive = TRUE,
     $checkPermission = TRUE
   ) {
     $query = "
@@ -314,9 +322,10 @@ WHERE  ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0 )";
    *
    * @static
    *
-   * @return array Array of event summary values
+   * @return array
+   *   Array of event summary values
    */
-  static function getEventSummary() {
+  public static function getEventSummary() {
     $eventSummary = $eventIds = array();
     $config = CRM_Core_Config::singleton();
 
@@ -376,7 +385,7 @@ WHERE      civicrm_event.is_active = 1 AND
     }
     // Get the event summary display preferences
     $show_max_events = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
-                       'show_events'
+      'show_events'
     );
     // default to 10 if no option is set
     if (is_null($show_max_events)) {
@@ -547,7 +556,8 @@ $event_summary_limit
         $statusCount = self::eventTotalSeats($dao->id, "( participant.status_id = {$statusId} )");
         if ($statusCount) {
           $urlString = "reset=1&force=1&event={$dao->id}&status=$statusId";
-          $statusInfo = array('url' => CRM_Utils_System::url('civicrm/event/search', $urlString),
+          $statusInfo = array(
+            'url' => CRM_Utils_System::url('civicrm/event/search', $urlString),
             'name' => $statusValue['name'],
             'label' => $statusValue['label'],
             'count' => $statusCount,
@@ -577,20 +587,25 @@ $event_summary_limit
    * Get participant count
    *
    * @param int $eventId
-   * @param  boolean $considerStatus consider status for participant count.
-   * @param  boolean $status consider counted participant.
-   * @param  boolean $considerRole consider role for participant count.
-   * @param  boolean $role consider counted( is filter role) participant.
+   * @param bool $considerStatusConsider status for participant count.
+   *   Consider status for participant count.
+   * @param bool $statusConsider counted participant.
+   *   Consider counted participant.
+   * @param bool $considerRoleConsider role for participant count.
+   *   Consider role for participant count.
+   * @param bool $roleConsider counted( is filter role) participant.
+   *   Consider counted( is filter role) participant.
    *
-   * @access public
    *
-   * @return array array with count of participants for each event based on status/role
+   * @return array
+   *   array with count of participants for each event based on status/role
    */
-  public static function getParticipantCount($eventId,
+  public static function getParticipantCount(
+    $eventId,
     $considerStatus = TRUE,
-    $status         = TRUE,
-    $considerRole   = TRUE,
-    $role           = TRUE
+    $status = TRUE,
+    $considerRole = TRUE,
+    $role = TRUE
   ) {
 
     // consider both role and status for counted participants, CRM-4924.
@@ -637,13 +652,14 @@ $event_summary_limit
   /**
    * Get the information to map a event
    *
-   * @param int $id for which we want map info
+   * @param int $id
+   *   For which we want map info.
    *
-   * @return null|string     title of the event
+   * @return null|string
+   *   title of the event
    * @static
-   * @access public
    */
-  static function &getMapInfo(&$id) {
+  public static function &getMapInfo(&$id) {
 
     $sql = "
 SELECT
@@ -686,7 +702,10 @@ WHERE civicrm_address.geo_code_1 IS NOT NULL
 
       $params = array('entity_id' => $id, 'entity_table' => 'civicrm_event');
       $addressValues = CRM_Core_BAO_Location::getValues($params, TRUE);
-      $location['address'] = str_replace(array("\r", "\n"), '', addslashes(nl2br($addressValues['address'][1]['display_text'])));
+      $location['address'] = str_replace(array(
+        "\r",
+        "\n",
+      ), '', addslashes(nl2br($addressValues['address'][1]['display_text'])));
 
       $location['url'] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id);
       $location['location_type'] = $dao->location_type;
@@ -701,15 +720,20 @@ WHERE civicrm_address.geo_code_1 IS NOT NULL
   /**
    * Get the complete information for one or more events
    *
-   * @param  date    $start      get events with start date >= this date
-   * @param  integer $type       get events on the a specific event type (by event_type_id)
-   * @param  integer $eventId    return a single event - by event id
-   * @param  date    $end        also get events with end date >= this date
-   * @param  boolean $onlyPublic include public events only, default TRUE
+   * @param date $start
+   *   Get events with start date >= this date.
+   * @param int $typeGet events on the a specific event type (by event_type_id).
+   *   Get events on the a specific event type (by event_type_id).
+   * @param int $eventIdReturn a single event - by event id.
+   *   Return a single event - by event id.
+   * @param date $end
+   *   Also get events with end date >= this date.
+   * @param bool $onlyPublicInclude public events only, default TRUE.
+   *   Include public events only, default TRUE.
    *
-   * @return  array  $all      array of all the events that are searched
+   * @return array
+   *   array of all the events that are searched
    * @static
-   * @access public
    */
   static function &getCompleteInfo(
     $start = NULL,
@@ -806,10 +830,9 @@ WHERE civicrm_event.is_active = 1
     }
     $query .= " ORDER BY   civicrm_event.start_date ASC";
 
-
     $params = array(1 => array($optionGroupId, 'Integer'));
-    $dao    = CRM_Core_DAO::executeQuery($query, $params);
-    $all    = array();
+    $dao = CRM_Core_DAO::executeQuery($query, $params);
+    $all = array();
     $config = CRM_Core_Config::singleton();
 
     $baseURL = parse_url($config->userFrameworkBaseURL);
@@ -831,7 +854,8 @@ WHERE civicrm_event.is_active = 1
     $enable_cart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
       'enable_cart'
     );
-    if ($enable_cart) {}
+    if ($enable_cart) {
+    }
     while ($dao->fetch()) {
       if (!empty($permissions) && in_array($dao->event_id, $permissions)) {
         $info = array();
@@ -886,32 +910,37 @@ WHERE civicrm_event.is_active = 1
   }
 
   /**
-   * This function is to make a copy of a Event, including
+   * make a copy of a Event, including
    * all the fields in the event Wizard
    *
-   * @param int $id the event id to copy
-   *        obj     $newEvent    object of CRM_Event_DAO_Event
+   * @param int $id
+   *   The event id to copy.
    *        boolean $afterCreate call to copy after the create function
    * @param null $newEvent
    * @param bool $afterCreate
    *
-   * @return void
-   * @access public
+   * @return CRM_Event_DAO_Event
    */
-  static function copy($id, $newEvent = NULL, $afterCreate = FALSE) {
+  public static function copy($id, $newEvent = NULL, $afterCreate = FALSE) {
 
-    $defaults = $eventValues = array();
+    $eventValues = array();
 
     //get the require event values.
     $eventParams = array('id' => $id);
-    $returnProperties = array('loc_block_id', 'is_show_location', 'default_fee_id', 'default_discount_fee_id', 'is_template');
+    $returnProperties = array(
+      'loc_block_id',
+      'is_show_location',
+      'default_fee_id',
+      'default_discount_fee_id',
+      'is_template',
+    );
 
     CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $eventParams, $eventValues, $returnProperties);
 
     // since the location is sharable, lets use the same loc_block_id.
     $locBlockId = CRM_Utils_Array::value('loc_block_id', $eventValues);
 
-    $fieldsFix = ($afterCreate) ? array( ) : array('prefix' => array('title' => ts('Copy of') . ' '));
+    $fieldsFix = ($afterCreate) ? array() : array('prefix' => array('title' => ts('Copy of') . ' '));
     if (empty($eventValues['is_show_location'])) {
       $fieldsFix['prefix']['is_show_location'] = 0;
     }
@@ -923,12 +952,12 @@ WHERE civicrm_event.is_active = 1
     if (!isset($copyEvent)) {
       $copyEvent = &CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event',
         array('id' => $id),
-          array(
-            'loc_block_id' =>
+        array(
+          'loc_block_id' =>
             ($locBlockId) ? $locBlockId : NULL,
-          ),
-         $fieldsFix
-       );
+        ),
+        $fieldsFix
+      );
     }
     CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_event', $id, $copyEvent->id);
     $copyUF = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin',
@@ -990,13 +1019,13 @@ WHERE civicrm_event.is_active = 1
         }
 
         foreach ($table as $tableName => $tableColumns) {
-          $insert          = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
+          $insert = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
           $tableColumns[0] = $copyEvent->id;
-          $select          = 'SELECT ' . implode(', ', $tableColumns);
-          $from            = ' FROM ' . $tableName;
-          $where           = " WHERE {$tableName}.entity_id = {$id}";
-          $query           = $insert . $select . $from . $where;
-          $dao             = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
+          $select = 'SELECT ' . implode(', ', $tableColumns);
+          $from = ' FROM ' . $tableName;
+          $where = " WHERE {$tableName}.entity_id = {$id}";
+          $query = $insert . $select . $from . $where;
+          $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
         }
       }
     }
@@ -1013,7 +1042,7 @@ WHERE civicrm_event.is_active = 1
    * This is sometimes called in a loop (during event search)
    * hence we cache the values to prevent repeated calls to the db
    */
-  static function isMonetary($id) {
+  public static function isMonetary($id) {
     static $isMonetary = array();
     if (!array_key_exists($id, $isMonetary)) {
       $isMonetary[$id] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
@@ -1028,7 +1057,7 @@ WHERE civicrm_event.is_active = 1
    * This is sometimes called in a loop (during event search)
    * hence we cache the values to prevent repeated calls to the db
    */
-  static function usesPriceSet($id) {
+  public static function usesPriceSet($id) {
     static $usesPriceSet = array();
     if (!array_key_exists($id, $usesPriceSet)) {
       $usesPriceSet[$id] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id);
@@ -1046,9 +1075,8 @@ WHERE civicrm_event.is_active = 1
    * @param bool $returnMessageText
    *
    * @return void
-   * @access public
    */
-  static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE) {
+  public static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE) {
 
     $template = CRM_Core_Smarty::singleton();
     $gIds = array(
@@ -1064,34 +1092,34 @@ WHERE civicrm_event.is_active = 1
       foreach ($gIds as $key => $gIdValues) {
         if ($gIdValues) {
           if (!is_array($gIdValues)) {
-            $gIdValues = array( $gIdValues );
+            $gIdValues = array($gIdValues);
           }
 
           foreach ($gIdValues as $gId) {
-          $email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
-          if ($email) {
-            //get values of corresponding profile fields for notification
-            list($profileValues) = self::buildCustomDisplay($gId,
-              NULL,
-              $contactID,
-              $template,
-              $participantId,
-              $isTest,
-              TRUE,
-              $participantParams
-            );
-            list($profileValues) = $profileValues;
-            $val = array(
-              'id' => $gId,
-              'values' => $profileValues,
-              'email' => $email,
-            );
-            CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
+            $email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
+            if ($email) {
+              //get values of corresponding profile fields for notification
+              list($profileValues) = self::buildCustomDisplay($gId,
+                NULL,
+                $contactID,
+                $template,
+                $participantId,
+                $isTest,
+                TRUE,
+                $participantParams
+              );
+              list($profileValues) = $profileValues;
+              $val = array(
+                'id' => $gId,
+                'values' => $profileValues,
+                'email' => $email,
+              );
+              CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
+            }
           }
         }
       }
     }
-    }
 
     if ($values['event']['is_email_confirm'] || $returnMessageText) {
       list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
@@ -1102,8 +1130,8 @@ WHERE civicrm_event.is_active = 1
         $postProfileID = CRM_Utils_Array::value('custom_post_id', $values);
 
         if (!empty($values['params']['additionalParticipant'])) {
-          $preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values, $preProfileID );
-          $postProfileID = CRM_Utils_Array::value('additional_custom_post_id', $values, $postProfileID );
+          $preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values, $preProfileID);
+          $postProfileID = CRM_Utils_Array::value('additional_custom_post_id', $values, $postProfileID);
         }
 
         self::buildCustomDisplay($preProfileID,
@@ -1129,20 +1157,20 @@ WHERE civicrm_event.is_active = 1
         $sessions = CRM_Event_Cart_BAO_Conference::get_participant_sessions($participantId);
 
         $tplParams = array_merge($values, $participantParams, array(
-            'email' => $email,
-            'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']),
-            'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event']),
-            'contributeMode' => CRM_Utils_Array::value('contributeMode', $template->_tpl_vars),
-            'participantID' => $participantId,
-            'conference_sessions' => $sessions,
-            'credit_card_number' =>
-                CRM_Utils_System::mungeCreditCard(
-                    CRM_Utils_Array::value('credit_card_number', $participantParams)),
-            'credit_card_exp_date' =>
-                CRM_Utils_Date::mysqlToIso(
-                    CRM_Utils_Date::format(
-                        CRM_Utils_Array::value('credit_card_exp_date', $participantParams))),
-          ));
+          'email' => $email,
+          'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']),
+          'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event']),
+          'contributeMode' => CRM_Utils_Array::value('contributeMode', $template->_tpl_vars),
+          'participantID' => $participantId,
+          'conference_sessions' => $sessions,
+          'credit_card_number' =>
+            CRM_Utils_System::mungeCreditCard(
+              CRM_Utils_Array::value('credit_card_number', $participantParams)),
+          'credit_card_exp_date' =>
+            CRM_Utils_Date::mysqlToIso(
+              CRM_Utils_Date::format(
+                CRM_Utils_Array::value('credit_card_exp_date', $participantParams))),
+        ));
 
         // CRM-13890 : NOTE wait list condition need to be given so that
         // wait list message is shown properly in email i.e. WRT online event registration template
@@ -1150,6 +1178,10 @@ WHERE civicrm_event.is_active = 1
           $statusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantId, 'status_id', 'id');
           $tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($statusId, NULL, 'label');
         }
+        //CRM-15754 - if participant_status contains status ID
+        elseif (CRM_Utils_Rule::integer($tplParams['participant_status'])) {
+          $tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($tplParams['participant_status'], NULL, 'label');
+        }
 
         $sendTemplateParams = array(
           'groupName' => 'msg_tpl_workflow_event',
@@ -1157,7 +1189,7 @@ WHERE civicrm_event.is_active = 1
           'contactId' => $contactID,
           'isTest' => $isTest,
           'tplParams' => $tplParams,
-          'PDFFilename' => ts('confirmation').'.pdf',
+          'PDFFilename' => ts('confirmation') . '.pdf',
         );
 
         // address required during receipt processing (pdf and email receipt)
@@ -1171,15 +1203,15 @@ WHERE civicrm_event.is_active = 1
           // check if additional prticipant, if so filter only to relevant ones
           // CRM-9902
           if (!empty($values['params']['additionalParticipant'])) {
-            $ownLineItems = array( );
-            foreach ( $lineItem as $liKey => $liValue ) {
-              $firstElement = array_pop( $liValue );
-              if ( $firstElement['entity_id'] == $participantId ) {
+            $ownLineItems = array();
+            foreach ($lineItem as $liKey => $liValue) {
+              $firstElement = array_pop($liValue);
+              if ($firstElement['entity_id'] == $participantId) {
                 $ownLineItems[0] = $lineItem[$liKey];
                 break;
               }
             }
-            if ( ! empty( $ownLineItems ) ) {
+            if (!empty($ownLineItems)) {
               $sendTemplateParams['tplParams']['lineItem'] = $ownLineItems;
             }
           }
@@ -1209,12 +1241,12 @@ WHERE civicrm_event.is_active = 1
             $values['event']
           );
           // append invoice pdf to email
-          $template = CRM_Core_Smarty::singleton( );
+          $template = CRM_Core_Smarty::singleton();
           $taxAmt = $template->get_template_vars('totalTaxAmount');
           $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
           $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
-          if ($taxAmt && (isset($invoicing) && isset($prefixValue['is_email_pdf'])) ) {
-            $sendTemplateParams['isEmailPdf'] = True;
+          if ($taxAmt && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
+            $sendTemplateParams['isEmailPdf'] = TRUE;
             $sendTemplateParams['contributionId'] = $values['contributionId'];
           }
           CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
@@ -1237,9 +1269,9 @@ WHERE civicrm_event.is_active = 1
    * @param array $participantParams
    *
    * @return void
-   * @access public
    */
-  static function buildCustomDisplay($id,
+  static function buildCustomDisplay(
+    $id,
     $name,
     $cid,
     &$template,
@@ -1328,8 +1360,8 @@ WHERE civicrm_event.is_active = 1
           if (!empty($grpIds)) {
             //get the group titles.
             $grpTitles = array();
-            $query     = 'SELECT title FROM civicrm_group where id IN ( ' . implode(',', $grpIds) . ' )';
-            $grp       = CRM_Core_DAO::executeQuery($query);
+            $query = 'SELECT title FROM civicrm_group where id IN ( ' . implode(',', $grpIds) . ' )';
+            $grp = CRM_Core_DAO::executeQuery($query);
             while ($grp->fetch()) {
               $grpTitles[] = $grp->title;
             }
@@ -1411,18 +1443,21 @@ WHERE civicrm_event.is_active = 1
   /**
    * Build the array for display the profile fields
    *
-   * @param array $params key value.
-   * @param int $gid profile Id
-   * @param array $groupTitle Profile Group Title.
-   * @param array $values formatted array of key value
+   * @param array $params
+   *   Key value.
+   * @param int $gid
+   *   Profile Id.
+   * @param array $groupTitle
+   *   Profile Group Title.
+   * @param array $values
+   *   Formatted array of key value.
    *
    * @param array $profileFields
    *
    * @return void
-   * @access public
    * @static
    */
-  static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = array()) {
+  public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = array()) {
     if ($gid) {
       $config = CRM_Core_Config::singleton();
       $session = CRM_Core_Session::singleton();
@@ -1442,8 +1477,8 @@ WHERE civicrm_event.is_active = 1
           break;
         }
       }
-      $customVal     = '';
-      $imProviders   = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
+      $customVal = '';
+      $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
       //start of code to set the default values
       foreach ($fields as $name => $field) {
         $skip = FALSE;
@@ -1489,15 +1524,18 @@ WHERE civicrm_event.is_active = 1
           $values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $name, $params[$name]);
         }
         elseif (in_array($name, array(
-          'addressee', 'email_greeting', 'postal_greeting'))) {
+          'addressee',
+          'email_greeting',
+          'postal_greeting',
+        ))) {
           $filterCondition = array('greeting_type' => $name);
-          $greeting        = CRM_Core_PseudoConstant::greeting($filterCondition);
-          $values[$index]  = $greeting[$params[$name]];
+          $greeting = CRM_Core_PseudoConstant::greeting($filterCondition);
+          $values[$index] = $greeting[$params[$name]];
         }
         elseif ($name === 'preferred_communication_method') {
           $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
-          $compref             = array();
-          $pref                = $params[$name];
+          $compref = array();
+          $pref = $params[$name];
           if (is_array($pref)) {
             foreach ($pref as $k => $v) {
               if ($v) {
@@ -1522,8 +1560,8 @@ WHERE civicrm_event.is_active = 1
         }
         elseif ($name == 'tag') {
           $entityTags = $params[$name];
-          $allTags    = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
-          $title      = array();
+          $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
+          $title = array();
           if (is_array($entityTags)) {
             foreach ($entityTags as $tagId => $dontCare) {
               $title[] = $allTags[$tagId];
@@ -1551,9 +1589,12 @@ WHERE civicrm_event.is_active = 1
           list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2);
           $detailName = str_replace(' ', '_', $name);
           if (in_array($fieldName, array(
-            'state_province', 'country', 'county'))) {
+            'state_province',
+            'country',
+            'county',
+          ))) {
             $values[$index] = $params[$detailName];
-            $idx            = $detailName . '_id';
+            $idx = $detailName . '_id';
             $values[$index] = $params[$idx];
           }
           elseif ($fieldName == 'im') {
@@ -1607,11 +1648,11 @@ WHERE  id = $cfID
                 ) {
                   $v = $params[$name];
                   if (!CRM_Utils_System::isNull($v)) {
-                    $customVal = (int)$v;
+                    $customVal = (int) $v;
                   }
                 }
                 elseif ($dao->data_type == 'Float') {
-                  $customVal = (float )($params[$name]);
+                  $customVal = (float ) ($params[$name]);
                 }
                 elseif ($dao->data_type == 'Date') {
                   //@todo note the currently we are using default date time formatting. Since you can select/set
@@ -1632,10 +1673,10 @@ WHERE  id = $cfID
                 }
                 //take the custom field options
                 $returnProperties = array($name => 1);
-                $query            = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
-                $options          = &$query->_options;
+                $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
+                $options = &$query->_options;
                 if (!$skip) {
-                  $displayValue     = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
+                  $displayValue = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
                 }
                 //Hack since we dont have function to check empty.
                 //FIXME in 2.3 using crmIsEmptyArray()
@@ -1659,7 +1700,10 @@ WHERE  id = $cfID
               $values[$index] = "<a href=\"$url\">{$params[$name]}</a>";
             }
             elseif (in_array($name, array(
-              'birth_date', 'deceased_date', 'participant_register_date'))) {
+              'birth_date',
+              'deceased_date',
+              'participant_register_date',
+            ))) {
               $values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name]));
             }
             else {
@@ -1675,21 +1719,27 @@ WHERE  id = $cfID
   /**
    * Build the array for Additional participant's information  array of priamry and additional Ids
    *
-   * @param int $participantId id of Primary participant
-   * @param array $values key/value event info
-   * @param int $contactId contact id of Primary participant
-   * @param boolean $isTest whether test or live transaction
-   * @param boolean $isIdsArray to return an array of Ids
+   * @param int $participantId
+   *   Id of Primary participant.
+   * @param array $values
+   *   Key/value event info.
+   * @param int $contactId
+   *   Contact id of Primary participant.
+   * @param bool $isTest
+   *   Whether test or live transaction.
+   * @param bool $isIdsArray
+   *   To return an array of Ids.
    *
    * @param bool $skipCancel
    *
-   * @return array $customProfile array of Additional participant's info OR array of Ids.
-   * @access public
+   * @return array
+   *   array of Additional participant's info OR array of Ids.
    */
-  static function buildCustomProfile($participantId,
+  static function buildCustomProfile(
+    $participantId,
     $values,
-    $contactId  = NULL,
-    $isTest     = FALSE,
+    $contactId = NULL,
+    $isTest = FALSE,
     $isIdsArray = FALSE,
     $skipCancel = TRUE
   ) {
@@ -1707,9 +1757,9 @@ WHERE  id = $cfID
     //hack to skip cancelled participants, CRM-4320
     $where = "participant.registered_by_id={$participantId}";
     if ($skipCancel) {
-      $cancelStatusId   = 0;
+      $cancelStatusId = 0;
       $negativeStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
-      $cancelStatusId   = array_search('Cancelled', $negativeStatuses);
+      $cancelStatusId = array_search('Cancelled', $negativeStatuses);
       $where .= " AND participant.status_id != {$cancelStatusId}";
     }
     $query = "
@@ -1735,8 +1785,8 @@ WHERE  id = $cfID
         $template = CRM_Core_Smarty::singleton();
 
         $isCustomProfile = TRUE;
-        $i               = 1;
-        $title           = $groupTitles = array();
+        $i = 1;
+        $title = $groupTitles = array();
         foreach ($additionalIDs as $pId => $cId) {
           //get the params submitted by participant.
           $participantParams = CRM_Utils_Array::value($pId, $values['params'], array());
@@ -1796,12 +1846,13 @@ WHERE  id = $cfID
 
   /* Function to retrieve all events those having location block set.
    *
-   * @return array $events array of all events.
+   * @return array
+   *   array of all events.
    */
   /**
    * @return array
    */
-  static function getLocationEvents() {
+  public static function getLocationEvents() {
     $events = array();
 
     $query = "
@@ -1826,7 +1877,7 @@ ORDER BY sp.name, ca.city, ca.street_address ASC
    *
    * @return int|null|string
    */
-  static function countEventsUsingLocBlockId($locBlockId) {
+  public static function countEventsUsingLocBlockId($locBlockId) {
     if (!$locBlockId) {
       return 0;
     }
@@ -1844,10 +1895,10 @@ WHERE  ce.loc_block_id = $locBlockId";
    * Check if event registration is valid according to permissions AND Dates
    *
    * @param array $values
-   * @param integer $eventID
+   * @param int $eventID
    * @return boolean
    */
-  static function validRegistrationRequest($values, $eventID) {
+  public static function validRegistrationRequest($values, $eventID) {
     // check that the user has permission to register for this event
     $hasPermission = CRM_Core_Permission::event(CRM_Core_Permission::EDIT,
       $eventID, 'register for events'
@@ -1861,12 +1912,12 @@ WHERE  ce.loc_block_id = $locBlockId";
    *
    * @return bool
    */
-  static function validRegistrationDate(&$values) {
+  public static function validRegistrationDate(&$values) {
     // make sure that we are between  registration start date and registration end date
     $startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $values));
-    $endDate   = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $values));
-    $eventEnd  = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $values));
-    $now       = time();
+    $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $values));
+    $eventEnd = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $values));
+    $now = time();
     $validDate = TRUE;
     if ($startDate && $startDate >= $now) {
       $validDate = FALSE;
@@ -1883,19 +1934,20 @@ WHERE  ce.loc_block_id = $locBlockId";
 
   /* Function to Show - Hide the Registration Link.
    *
-   * @param  array   $values key/value event info
-   * @return boolean true if allow registration otherwise false
-   * @access public
+   * @param array $values
+   *   Key/value event info.
+   * @return boolean
+   *   true if allow registration otherwise false
    */
   /**
    * @param $values
    *
    * @return bool
    */
-  static function showHideRegistrationLink($values) {
+  public static function showHideRegistrationLink($values) {
 
-    $session           = CRM_Core_Session::singleton();
-    $contactID         = $session->get('userID');
+    $session = CRM_Core_Session::singleton();
+    $contactID = $session->get('userID');
     $alreadyRegistered = FALSE;
 
     if ($contactID) {
@@ -1920,16 +1972,16 @@ WHERE  ce.loc_block_id = $locBlockId";
 
   /* Function to check if given contact is already registered.
    *
-   * @param  array   $params key/value participant info
-   * @return boolean $alreadyRegistered true/false
-   * @access public
+   * @param array $params
+   *   Key/value participant info.
+   * @return boolean
    */
   /**
    * @param array $params
    *
    * @return bool
    */
-  static function checkRegistration($params) {
+  public static function checkRegistration($params) {
     $alreadyRegistered = FALSE;
     if (empty($params['contact_id'])) {
       return $alreadyRegistered;
@@ -1956,11 +2008,11 @@ WHERE  ce.loc_block_id = $locBlockId";
    * @param int $eventId
    * @param int $type
    *
-   * @return string   the permission that the user has (or null)
-   * @access public
+   * @return string
+   *   the permission that the user has (or null)
    * @static
    */
-  static function checkPermission($eventId = NULL, $type = CRM_Core_Permission::VIEW) {
+  public static function checkPermission($eventId = NULL, $type = CRM_Core_Permission::VIEW) {
     static $permissions = NULL;
 
     if (empty($permissions)) {
@@ -2018,27 +2070,29 @@ WHERE  ce.loc_block_id = $locBlockId";
    * Build From Email as the combination of all the email ids of the logged in user,
    * the domain email id and the email id configured for the event
    *
-   * @param int $eventId   the id of the event
+   * @param int $eventId
+   *   The id of the event.
    *
-   * @return array         an array of email ids
-   * @access public
+   * @return array
+   *   an array of email ids
    * @static
    */
-  static function getFromEmailIds($eventId = NULL) {
+  public static function getFromEmailIds($eventId = NULL) {
     $fromEmailValues['from_email_id'] = CRM_Core_BAO_Email::getFromEmail();
 
     if ($eventId) {
       // add the email id configured for the event
-      $params           = array('id' => $eventId);
+      $params = array('id' => $eventId);
       $returnProperties = array('confirm_from_name', 'confirm_from_email', 'cc_confirm', 'bcc_confirm');
-      $eventEmail       = array();
+      $eventEmail = array();
 
       CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $params, $eventEmail, $returnProperties);
       if (!empty($eventEmail['confirm_from_name']) && !empty($eventEmail['confirm_from_email'])) {
         $eventEmailId = "{$eventEmail['confirm_from_name']} <{$eventEmail['confirm_from_email']}>";
 
         $fromEmailValues['from_email_id'][$eventEmailId] = htmlspecialchars($eventEmailId);
-        $fromEmailId = array('cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail),
+        $fromEmailId = array(
+          'cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail),
           'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventEmail),
         );
         $fromEmailValues = array_merge($fromEmailValues, $fromEmailId);
@@ -2051,14 +2105,16 @@ WHERE  ce.loc_block_id = $locBlockId";
   /**
    * Calculate event total seats occupied.
    *
-   * @param int    $eventId          event id.
-   * @param sting  $extraWhereClause extra filter on participants.
+   * @param int $eventId
+   *   Event id.
+   * @param sting $extraWhereClause
+   *   Extra filter on participants.
    *
-   * @return int   event total seats w/ given criteria.
-   * @access public
+   * @return int
+   *   event total seats w/ given criteria.
    * @static
    */
-  static function eventTotalSeats($eventId, $extraWhereClause = NULL) {
+  public static function eventTotalSeats($eventId, $extraWhereClause = NULL) {
     if (empty($eventId)) {
       return 0;
     }
@@ -2091,18 +2147,20 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
             {$extraWhereClause}
   GROUP BY  participant.event_id";
 
-    return (int)CRM_Core_DAO::singleValueQuery($query, array(1 => array($eventId, 'Positive')));
+    return (int) CRM_Core_DAO::singleValueQuery($query, array(1 => array($eventId, 'Positive')));
   }
 
   /**
    * Retrieve event template default values to be set
    *  as default values for current new event.
    *
-   * @param int $templateId event template id.
+   * @param int $templateId
+   *   Event template id.
    *
-   * @return array of custom data defaults.
+   * @return array
+   *   Array of custom data defaults.
    */
-  static function getTemplateDefaultValues($templateId) {
+  public static function getTemplateDefaultValues($templateId) {
     $defaults = array();
     if (!$templateId) {
       return $defaults;
@@ -2128,7 +2186,7 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
    *
    * @return object
    */
-  static function get_sub_events($event_id) {
+  public static function get_sub_events($event_id) {
     $params = array('parent_event_id' => $event_id);
     $defaults = array();
     return CRM_Event_BAO_Event::retrieve($params, $defaults);
@@ -2137,14 +2195,16 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
   /**
    * Update the Campaign Id of all the participants of the given event
    *
-   * @param int $eventID event id.
-   * @param int $eventCampaignID campaign id of that event
+   * @param int $eventID
+   *   Event id.
+   * @param int $eventCampaignID
+   *   Campaign id of that event.
    */
-  static function updateParticipantCampaignID($eventID, $eventCampaignID) {
+  public static function updateParticipantCampaignID($eventID, $eventCampaignID) {
     $params = array();
     $params[1] = array($eventID, 'Integer');
 
-    if(empty($eventCampaignID)) {
+    if (empty($eventCampaignID)) {
       $query = "UPDATE civicrm_participant SET campaign_id = NULL WHERE event_id = %1";
     }
     else {
@@ -2158,9 +2218,9 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
    * 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
    */
@@ -2171,6 +2231,7 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
       case 'financial_type_id':
         // Fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get
         return CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
+
         break;
     }
     return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);