INFRA-132 - CRM/Event - Misc
authorTim Otten <totten@civicrm.org>
Tue, 6 Jan 2015 22:15:07 +0000 (14:15 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 6 Jan 2015 23:07:47 +0000 (15:07 -0800)
CRM/Event/BAO/Event.php
CRM/Event/BAO/Participant.php
CRM/Event/BAO/Query.php
CRM/Event/Form/ManageEvent/Fee.php
CRM/Event/Form/Registration/Confirm.php
CRM/Event/Import/Parser.php
CRM/Event/Selector/Search.php

index b21113f0cbc0cf400999e6c7d0151f9097eb6950..a41c375459e70f5031d13662a5f2f80c4ced067e 100644 (file)
@@ -199,7 +199,7 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
       $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
 
       $params = array(
-      1 => array($values['table_name'], 'string'),
+        1 => array($values['table_name'], 'string'),
         2 => array($id, 'integer'),
       );
 
@@ -268,10 +268,11 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
    * @return array
    * @static
    */
-  static function getEvents($all = 0,
-    $id = FALSE,
-    $isActive = TRUE,
-    $checkPermission = TRUE
+  static function getEvents(
+    $all = 0,
+                            $id = FALSE,
+                            $isActive = TRUE,
+                            $checkPermission = TRUE
   ) {
     $query = "
 SELECT `id`, `title`, `start_date`
@@ -384,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)) {
@@ -556,7 +557,7 @@ $event_summary_limit
         if ($statusCount) {
           $urlString = "reset=1&force=1&event={$dao->id}&status=$statusId";
           $statusInfo = array(
-          'url' => CRM_Utils_System::url('civicrm/event/search', $urlString),
+            'url' => CRM_Utils_System::url('civicrm/event/search', $urlString),
             'name' => $statusValue['name'],
             'label' => $statusValue['label'],
             'count' => $statusCount,
@@ -598,11 +599,12 @@ $event_summary_limit
    *
    * @return array array with count of participants for each event based on status/role
    */
-  public static function getParticipantCount($eventId,
-    $considerStatus = TRUE,
-    $status = TRUE,
-    $considerRole = TRUE,
-    $role = TRUE
+  public static function getParticipantCount(
+    $eventId,
+                                             $considerStatus = TRUE,
+                                             $status = TRUE,
+                                             $considerRole = TRUE,
+                                             $role = TRUE
   ) {
 
     // consider both role and status for counted participants, CRM-4924.
@@ -698,7 +700,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;
@@ -823,8 +828,8 @@ 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);
@@ -846,7 +851,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();
@@ -919,7 +925,13 @@ WHERE civicrm_event.is_active = 1
 
     //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);
 
@@ -938,12 +950,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',
@@ -1005,13 +1017,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);
         }
       }
     }
@@ -1078,7 +1090,7 @@ 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) {
@@ -1086,19 +1098,19 @@ WHERE civicrm_event.is_active = 1
             if ($email) {
               //get values of corresponding profile fields for notification
               list($profileValues) = self::buildCustomDisplay($gId,
-              NULL,
-              $contactID,
-              $template,
-              $participantId,
-              $isTest,
-              TRUE,
-              $participantParams
+                NULL,
+                $contactID,
+                $template,
+                $participantId,
+                $isTest,
+                TRUE,
+                $participantParams
               );
               list($profileValues) = $profileValues;
               $val = array(
-              'id' => $gId,
-              'values' => $profileValues,
-              'email' => $email,
+                'id' => $gId,
+                'values' => $profileValues,
+                'email' => $email,
               );
               CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
             }
@@ -1116,8 +1128,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,
@@ -1143,20 +1155,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
@@ -1175,7 +1187,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)
@@ -1190,14 +1202,14 @@ WHERE civicrm_event.is_active = 1
           // CRM-9902
           if (!empty($values['params']['additionalParticipant'])) {
             $ownLineItems = array();
-            foreach ( $lineItem as $liKey => $liValue ) {
-              $firstElement = array_pop( $liValue );
-              if ( $firstElement['entity_id'] == $participantId ) {
+            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;
             }
           }
@@ -1227,11 +1239,11 @@ 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'])) ) {
+          if ($taxAmt && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
             $sendTemplateParams['isEmailPdf'] = TRUE;
             $sendTemplateParams['contributionId'] = $values['contributionId'];
           }
@@ -1256,7 +1268,8 @@ WHERE civicrm_event.is_active = 1
    *
    * @return void
    */
-  static function buildCustomDisplay($id,
+  static function buildCustomDisplay(
+    $id,
     $name,
     $cid,
     &$template,
@@ -1345,8 +1358,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;
             }
@@ -1462,8 +1475,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;
@@ -1509,15 +1522,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) {
@@ -1542,8 +1558,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];
@@ -1571,9 +1587,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') {
@@ -1652,10 +1671,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()
@@ -1679,7 +1698,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 {
@@ -1710,7 +1732,8 @@ WHERE  id = $cfID
    *
    * @return array $customProfile array of Additional participant's info OR array of Ids.
    */
-  static function buildCustomProfile($participantId,
+  static function buildCustomProfile(
+    $participantId,
     $values,
     $contactId = NULL,
     $isTest = FALSE,
@@ -1731,9 +1754,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 = "
@@ -1759,8 +1782,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());
@@ -1888,9 +1911,9 @@ WHERE  ce.loc_block_id = $locBlockId";
   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;
@@ -1918,8 +1941,8 @@ WHERE  ce.loc_block_id = $locBlockId";
    */
   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) {
@@ -2052,9 +2075,9 @@ WHERE  ce.loc_block_id = $locBlockId";
 
     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'])) {
@@ -2062,7 +2085,7 @@ WHERE  ce.loc_block_id = $locBlockId";
 
         $fromEmailValues['from_email_id'][$eventEmailId] = htmlspecialchars($eventEmailId);
         $fromEmailId = array(
-        'cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail),
+          'cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail),
           'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventEmail),
         );
         $fromEmailValues = array_merge($fromEmailValues, $fromEmailId);
@@ -2172,7 +2195,7 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
     $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 {
@@ -2187,8 +2210,8 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_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 $context : @see CRM_Core_DAO::buildOptionsContext
+   * @param array $props : whatever is known about this dao object
    *
    * @return array|bool
    */
index 2a1fcd0b56efdd2ffef04f736acd38f7370e6e19..01c738d53b513292a131fdd4445e0c1a5db0fdad 100644 (file)
@@ -243,7 +243,9 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
     $noteValue = NULL;
     $hasNoteField = FALSE;
     foreach (array(
-      'note', 'participant_note') as $noteFld) {
+               'note',
+               'participant_note'
+             ) as $noteFld) {
       if (array_key_exists($noteFld, $params)) {
         $noteValue = $params[$noteFld];
         $hasNoteField = TRUE;
@@ -370,9 +372,9 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
     // It might be case there are some empty spaces and still event
     // is full, as waitlist might represent group require spaces > empty.
 
-    $participantRoles   = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
-    $countedStatuses    = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
-    $waitingStatuses    = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
+    $participantRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
+    $countedStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
+    $waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
     $onWaitlistStatusId = array_search('On waitlist', $waitingStatuses);
 
     //when we do require only waiting count don't consider counted.
@@ -394,8 +396,8 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
     if ($includeWaitingList && $onWaitlistStatusId) {
 
       //build the where clause.
-      $whereClause     = ' WHERE ' . implode(' AND ', $where);
-      $whereClause    .= " AND participant.status_id = $onWaitlistStatusId ";
+      $whereClause = ' WHERE ' . implode(' AND ', $where);
+      $whereClause .= " AND participant.status_id = $onWaitlistStatusId ";
       $eventSeatsWhere = implode(' AND ', $where) . " AND ( participant.status_id = $onWaitlistStatusId )";
 
       $query = "
@@ -419,8 +421,8 @@ INNER JOIN  civicrm_event event ON ( event.id = participant.event_id )
     }
 
     //consider only counted participants.
-    $where[]         = ' participant.status_id IN ( ' . implode(', ', array_keys($countedStatuses)) . ' ) ';
-    $whereClause     = ' WHERE ' . implode(' AND ', $where);
+    $where[] = ' participant.status_id IN ( ' . implode(', ', array_keys($countedStatuses)) . ' ) ';
+    $whereClause = ' WHERE ' . implode(' AND ', $where);
     $eventSeatsWhere = implode(' AND ', $where);
 
     $query = "
@@ -433,7 +435,7 @@ INNER JOIN  civicrm_event event ON ( event.id = participant.event_id )
 
     $eventMaxSeats = NULL;
     $eventFullText = ts('This event is full.');
-    $participants  = CRM_Core_DAO::executeQuery($query, $eventParams);
+    $participants = CRM_Core_DAO::executeQuery($query, $eventParams);
     while ($participants->fetch()) {
       if ($participants->event_full_text) {
         $eventFullText = $participants->event_full_text;
@@ -644,7 +646,8 @@ GROUP BY  participant.event_id
           'title' => ts('Participant Note'),
           'name' => 'participant_note',
           'headerPattern' => '/(participant.)?note$/i',
-        ));
+        )
+      );
 
       // Split status and status id into 2 fields
       // Fixme: it would be better to leave as 1 field and intelligently handle both during import
@@ -653,7 +656,8 @@ GROUP BY  participant.event_id
           'title' => ts('Participant Status'),
           'name' => 'participant_status',
           'data_type' => CRM_Utils_Type::T_STRING,
-        ));
+        )
+      );
       $tmpFields['participant_status_id']['title'] = ts('Participant Status Id');
 
       // Split role and role id into 2 fields
@@ -663,7 +667,8 @@ GROUP BY  participant.event_id
           'title' => ts('Participant Role'),
           'name' => 'participant_role',
           'data_type' => CRM_Utils_Type::T_STRING,
-        ));
+        )
+      );
       $tmpFields['participant_role_id']['title'] = ts('Participant Role Id');
 
       $eventType = array(
@@ -671,7 +676,8 @@ GROUP BY  participant.event_id
           'title' => ts('Event Type'),
           'name' => 'event_type',
           'data_type' => CRM_Utils_Type::T_STRING,
-        ));
+        )
+      );
 
       $tmpContactField = $contactFields = array();
       $contactFields = array();
@@ -681,7 +687,7 @@ GROUP BY  participant.event_id
         // Using new Dedupe rule.
         $ruleParams = array(
           'contact_type' => $contactType,
-          'used'         => 'Unsupervised',
+          'used' => 'Unsupervised',
         );
         $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
 
@@ -742,35 +748,40 @@ GROUP BY  participant.event_id
       $participantFields = CRM_Event_DAO_Participant::export();
       $noteField = array(
         'participant_note' => array(
-      'title' => 'Participant Note',
+          'title' => 'Participant Note',
           'name' => 'participant_note',
-        ));
+        )
+      );
 
       $participantStatus = array(
         'participant_status' => array(
-      'title' => 'Participant Status',
+          'title' => 'Participant Status',
           'name' => 'participant_status',
-        ));
+        )
+      );
 
       $participantRole = array(
         'participant_role' => array(
-      'title' => 'Participant Role',
+          'title' => 'Participant Role',
           'name' => 'participant_role',
-        ));
+        )
+      );
 
       //CRM-13595 add event id to participant export
       $eventid = array(
         'event_id' => array(
-      'title' => 'Event ID',
+          'title' => 'Event ID',
           'name' => 'event_id',
-        ));
+        )
+      );
       $eventtitle = array(
         'event_title' => array(
-      'title' => 'Event Title',
+          'title' => 'Event Title',
           'name' => 'event_title',
-        ));
+        )
+      );
 
-      $discountFields  = CRM_Core_DAO_Discount::export();
+      $discountFields = CRM_Core_DAO_Discount::export();
 
       $fields = array_merge($participantFields, $participantStatus, $participantRole, $eventid, $eventtitle, $noteField, $discountFields);
 
@@ -787,7 +798,6 @@ GROUP BY  participant.event_id
    *
    * @param int $participantId
    *   Id of the participant.
-
    *
    * @return array $name associated array with sort_name and event title
    * @static
@@ -804,9 +814,9 @@ WHERE  civicrm_participant.id = {$participantId}
 
     $details = array();
     while ($dao->fetch()) {
-      $details['name']  = $dao->name;
+      $details['name'] = $dao->name;
       $details['title'] = $dao->title;
-      $details['cid']   = $dao->cid;
+      $details['cid'] = $dao->cid;
     }
 
     return $details;
@@ -888,8 +898,8 @@ WHERE  civicrm_participant.id = {$participantId}
     CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
 
     // cleanup line items.
-    $participantsId   = array();
-    $participantsId   = self::getAdditionalParticipantIds($id);
+    $participantsId = array();
+    $participantsId = self::getAdditionalParticipantIds($id);
     $participantsId[] = $id;
     CRM_Price_BAO_LineItem::deleteLineItems($participantsId, 'civicrm_participant');
 
@@ -954,8 +964,8 @@ WHERE  civicrm_participant.id = {$participantId}
 
     $clause = implode(' AND ', $clause);
 
-    $query  = "SELECT id FROM civicrm_participant WHERE $clause";
-    $dao    = CRM_Core_DAO::executeQuery($query, $input);
+    $query = "SELECT id FROM civicrm_participant WHERE $clause";
+    $dao = CRM_Core_DAO::executeQuery($query, $input);
     $result = FALSE;
     while ($dao->fetch()) {
       $duplicates[] = $dao->id;
@@ -990,13 +1000,13 @@ WHERE  civicrm_participant.id = {$participantId}
     }
     elseif ((substr($eventLevel, 0, 1) == CRM_Core_DAO::VALUE_SEPARATOR)) {
       $eventLevel = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR,
-          substr($eventLevel, 0, 1)
-        ));
+        substr($eventLevel, 0, 1)
+      ));
     }
     elseif ((substr($eventLevel, -1, 1) == CRM_Core_DAO::VALUE_SEPARATOR)) {
       $eventLevel = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR,
-          substr($eventLevel, 0, -1)
-        ));
+        substr($eventLevel, 0, -1)
+      ));
     }
   }
 
@@ -1021,9 +1031,9 @@ WHERE  civicrm_participant.id = {$participantId}
 
     $where = "participant.registered_by_id={$primaryParticipantId}";
     if ($excludeCancel) {
-      $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}";
     }
 
@@ -1089,12 +1099,20 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
     $where = 'WHERE participant.id IN ( ' . implode(', ', $participantIds) . ' )';
     $query = "$select $from  $where";
 
-    $feeInfo        = CRM_Core_DAO::executeQuery($query);
-    $feeProperties  = array('fee_level', 'fee_amount');
+    $feeInfo = CRM_Core_DAO::executeQuery($query);
+    $feeProperties = array('fee_level', 'fee_amount');
     $lineProperties = array(
-      'lineId', 'label', 'qty', 'unit_price',
-      'line_total', 'field_title', 'html_type',
-      'price_field_id', 'participant_count', 'price_field_value_id', 'description',
+      'lineId',
+      'label',
+      'qty',
+      'unit_price',
+      'line_total',
+      'field_title',
+      'html_type',
+      'price_field_id',
+      'participant_count',
+      'price_field_value_id',
+      'description',
     );
     while ($feeInfo->fetch()) {
       if ($hasLineItems) {
@@ -1103,7 +1121,8 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
         }
       }
       else {
-        foreach ($feeProperties as $property) { $feeDetails[$feeInfo->id][$property] = $feeInfo->$property;
+        foreach ($feeProperties as $property) {
+          $feeDetails[$feeInfo->id][$property] = $feeInfo->$property;
         }
       }
     }
@@ -1232,7 +1251,8 @@ UPDATE  civicrm_participant
    * @return array
    * @static
    */
-  static function transitionParticipants($participantIds, $toStatusId,
+  static function transitionParticipants(
+    $participantIds, $toStatusId,
     $fromStatusId = NULL, $returnResult = FALSE, $skipCascadeRule = FALSE
   ) {
     if (!is_array($participantIds) || empty($participantIds) || !$toStatusId) {
@@ -1268,9 +1288,9 @@ UPDATE  civicrm_participant
 
     $contactIds = $eventIds = $participantDetails = array();
 
-    $statusTypes      = CRM_Event_PseudoConstant::participantStatus();
+    $statusTypes = CRM_Event_PseudoConstant::participantStatus();
     $participantRoles = CRM_Event_PseudoConstant::participantRole();
-    $pendingStatuses  = CRM_Event_PseudoConstant::participantStatus(NULL,
+    $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL,
       "class = 'Pending'"
     );
 
@@ -1306,7 +1326,7 @@ UPDATE  civicrm_participant
       // making all tokens available to templates.
       $domain = CRM_Core_BAO_Domain::getDomain();
       $tokens = array(
-      'domain' => array('name', 'phone', 'address', 'email'),
+        'domain' => array('name', 'phone', 'address', 'email'),
         'contact' => CRM_Core_SelectValues::contactTokens(),
       );
 
@@ -1347,8 +1367,8 @@ UPDATE  civicrm_participant
     //now we are ready w/ all required data.
     //take a decision as per statuses.
 
-    $emailType  = NULL;
-    $toStatus   = $statusTypes[$toStatusId];
+    $emailType = NULL;
+    $toStatus = $statusTypes[$toStatusId];
     $fromStatus = CRM_Utils_Array::value($fromStatusId, $statusTypes);
 
     switch ($toStatus) {
@@ -1538,8 +1558,8 @@ UPDATE  civicrm_participant
 
       // 3. create activity record.
       if ($mailSent) {
-        $now            = date('YmdHis');
-        $activityType   = 'Event Registration';
+        $now = date('YmdHis');
+        $activityType = 'Event Registration';
         $activityParams = array(
           'subject' => $subject,
           'source_contact_id' => $contactId,
@@ -1587,11 +1607,11 @@ UPDATE  civicrm_participant
             array_key_exists($processedId, $results['mailedParticipants'])
           ) {
             $statusMsg .= '<br /> ' . ts("Participant status has been updated to '%1'. An email has been sent to %2.",
-              array(
-                1 => $allStatuses[$statusChangeTo],
-                2 => $results['mailedParticipants'][$processedId],
-              )
-            );
+                array(
+                  1 => $allStatuses[$statusChangeTo],
+                  2 => $results['mailedParticipants'][$processedId],
+                )
+              );
           }
         }
       }
@@ -1629,7 +1649,8 @@ UPDATE  civicrm_participant
     if (is_string($emptySeats) && $emptySeats !== NULL) {
       $maxParticipants = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'max_participants');
       $eventfullMsg = ts("This event currently has the maximum number of participants registered (%1). However, you can still override this limit and register additional participants using this form.", array(
-        1 => $maxParticipants)) . '<br />';
+          1 => $maxParticipants
+        )) . '<br />';
     }
 
     $hasWaiting = FALSE;
@@ -1751,9 +1772,10 @@ WHERE    civicrm_participant.contact_id = {$contactID} AND
     // get additional participant ids (including cancelled)
     if ($participantId) {
       $ids = array_merge(array(
-        $participantId), self::getAdditionalParticipantIds($participantId,
-          $excludeCancelled
-        ));
+        $participantId
+      ), self::getAdditionalParticipantIds($participantId,
+        $excludeCancelled
+      ));
     }
 
     return $ids;
@@ -1770,7 +1792,7 @@ WHERE    civicrm_participant.contact_id = {$contactID} AND
    */
   public static function getAdditionalParticipantUrl($participantIds) {
     foreach ($participantIds as $value) {
-      $links   = array();
+      $links = array();
       $details = self::participantDetails($value);
       $viewUrl = CRM_Utils_System::url('civicrm/contact/view/participant',
         "action=view&reset=1&id={$value}&cid={$details['cid']}"
@@ -1806,8 +1828,9 @@ WHERE    civicrm_participant.contact_id = {$contactID} AND
 LEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id
 WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
       $params = array(
-      1 => array($priceSetId, 'Integer'),
-        2 => array($feeLevel, 'String'));
+        1 => array($priceSetId, 'Integer'),
+        2 => array($feeLevel, 'String')
+      );
       $mainAmount = CRM_Core_DAO::singleValueQuery($query, $params);
       $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Discounts Account is' "));
       $contributionParams['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType(
@@ -1815,8 +1838,8 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
       if (!empty($contributionParams['trxnParams']['from_financial_account_id'])) {
         $contributionParams['trxnParams']['total_amount'] = $mainAmount - $contributionParams['total_amount'];
         $contributionParams['trxnParams']['payment_processor_id'] = $contributionParams['trxnParams']['payment_instrument_id'] =
-          $contributionParams['trxnParams']['check_number'] = $contributionParams['trxnParams']['trxn_id'] =
-          $contributionParams['trxnParams']['net_amount'] = $contributionParams['trxnParams']['fee_amount'] = NULL;
+        $contributionParams['trxnParams']['check_number'] = $contributionParams['trxnParams']['trxn_id'] =
+        $contributionParams['trxnParams']['net_amount'] = $contributionParams['trxnParams']['fee_amount'] = NULL;
 
         CRM_Core_BAO_FinancialTrxn::create($contributionParams['trxnParams']);
       }
@@ -1879,7 +1902,8 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
           unset($insertLines[$previousLineItem['price_field_value_id']]);
           // for updating the line items i.e. use-case - once deselect-option selecting again
           if (($previousLineItem['line_total'] != $submittedLineItems[$previousLineItem['price_field_value_id']]['line_total']) ||
-            ($submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] == 0 && $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'] == 1)) {
+            ($submittedLineItems[$previousLineItem['price_field_value_id']]['line_total'] == 0 && $submittedLineItems[$previousLineItem['price_field_value_id']]['qty'] == 1)
+          ) {
             $updateLines[$previousLineItem['price_field_value_id']] = $submittedLineItems[$previousLineItem['price_field_value_id']];
             $updateLines[$previousLineItem['price_field_value_id']]['id'] = $id;
           }
@@ -1924,11 +1948,11 @@ GROUP BY li.entity_table, li.entity_id, price_field_value_id
         // if not submitted and difference is not 0 make it negative
         if (!in_array($updateFinancialItemInfoValues['price_field_value_id'], $submittedFieldValueIds) && $updateFinancialItemInfoValues['differenceAmt'] != 0) {
           // INSERT negative financial_items
-          $updateFinancialItemInfoValues['amount'] = - $updateFinancialItemInfoValues['amount'];
+          $updateFinancialItemInfoValues['amount'] = -$updateFinancialItemInfoValues['amount'];
           CRM_Financial_BAO_FinancialItem::create($updateFinancialItemInfoValues, NULL, $trxnId);
           // INSERT negative financial_items for tax amount
           if ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']) {
-            $updateFinancialItemInfoValues['amount'] = - ($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
+            $updateFinancialItemInfoValues['amount'] = -($previousLineItems[$updateFinancialItemInfoValues['entity_id']]['tax_amount']);
             $updateFinancialItemInfoValues['description'] = $taxTerm;
             if ($updateFinancialItemInfoValues['financial_type_id']) {
               $updateFinancialItemInfoValues['financial_account_id'] = CRM_Contribute_BAO_Contribution::getFinancialAccountId($updateFinancialItemInfoValues['financial_type_id']);
@@ -1954,7 +1978,7 @@ GROUP BY li.entity_table, li.entity_id, price_field_value_id
         }
       }
     }
-    elseif (empty($submittedFields) && empty($submittedFieldValues)){
+    elseif (empty($submittedFields) && empty($submittedFieldValues)) {
       $updateLineItem = "UPDATE civicrm_line_item li
         INNER JOIN civicrm_financial_item fi
         ON (li.id = fi.entity_id AND fi.entity_table = 'civicrm_line_item')
@@ -2038,7 +2062,7 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
     $partUpdateFeeAmt['id'] = $participantId;
     foreach ($lineItems as $lineValue) {
       if ($lineValue['price_field_value_id']) {
-        $line[$lineValue['price_field_value_id']] = $lineValue['label'] . ' - '. $lineValue['qty'];
+        $line[$lineValue['price_field_value_id']] = $lineValue['label'] . ' - ' . $lineValue['qty'];
       }
     }
 
index e1aef626e2020440bb316d70191f39be1dae9d65..a40e68ec84a33a7d8320c8a97d9f2d888ea21d30 100644 (file)
@@ -559,7 +559,8 @@ class CRM_Event_BAO_Query {
    *
    * @return array|null
    */
-  static function defaultReturnProperties($mode,
+  static function defaultReturnProperties(
+    $mode,
     $includeCustomFields = TRUE
   ) {
     $properties = NULL;
index 871e6c87191f3d649143e89a71b4578d2b3ac8ef..8437c35669b993b3d8164186cc199ff35bba612a 100644 (file)
@@ -666,7 +666,8 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent {
               $fieldParams['option_label'] = $params['label'];
               $fieldParams['option_amount'] = $params['value'];
               $fieldParams['financial_type_id'] = $params['financial_type_id'];
-              foreach ($options as $value) { $fieldParams['option_weight'][$value['weight']] = $value['weight'];
+              foreach ($options as $value) {
+                $fieldParams['option_weight'][$value['weight']] = $value['weight'];
               }
               $fieldParams['default_option'] = $params['default'];
               $priceField = CRM_Price_BAO_PriceField::create($fieldParams);
index b288f681abd416f8725ad2a79963bd98c734ccd2..d4ebee428bcab6c7b3c3f3428d3900fda4038d87 100644 (file)
@@ -955,7 +955,8 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
    *
    * @return void
    */
-  static function processContribution(&$form, $params, $result, $contactID,
+  static function processContribution(
+    &$form, $params, $result, $contactID,
     $pending = FALSE, $isAdditionalAmount = FALSE
   ) {
     $transaction = new CRM_Core_Transaction();
index ed65ddd493d3107d4d03365c96ad7cfb03651086..f7c0a6ba22e9e57519a810c40a8276e961fd9a08 100644 (file)
@@ -76,7 +76,8 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser {
    * @return mixed
    * @throws Exception
    */
-  function run($fileName,
+  function run(
+    $fileName,
     $seperator = ',',
     &$mapper,
     $skipColumnHeader = FALSE,
index 4988f5b53408af464851e0d594d1d815845a6977..21a61abb840876ecad68a502e6ff6a4cfe541d96 100644 (file)
@@ -161,7 +161,8 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
    * @return \CRM_Event_Selector_Search
   @access public
    */
-  function __construct(&$queryParams,
+  function __construct(
+    &$queryParams,
     $action = CRM_Core_Action::NONE,
     $eventClause = NULL,
     $single = FALSE,