Merge pull request #7965 from eileenmcnaughton/comments
authorEileen McNaughton <eileen@mcnaughty.com>
Mon, 14 Mar 2016 03:58:07 +0000 (16:58 +1300)
committerEileen McNaughton <eileen@mcnaughty.com>
Mon, 14 Mar 2016 03:58:07 +0000 (16:58 +1300)
minor comment tidyups

99 files changed:
CRM/Activity/BAO/Activity.php
CRM/Activity/BAO/Query.php
CRM/Admin/Form/PaymentProcessor.php
CRM/Campaign/Form/Petition.php
CRM/Campaign/Form/Survey.php
CRM/Case/BAO/Case.php
CRM/Case/BAO/Query.php
CRM/Case/Form/Activity.php
CRM/Contact/BAO/Group.php
CRM/Contact/BAO/GroupContactCache.php
CRM/Contact/BAO/Query.php
CRM/Contact/Form/Edit/CommunicationPreferences.php
CRM/Contact/Form/Merge.php
CRM/Contact/Form/Search.php
CRM/Contact/Form/Search/Advanced.php
CRM/Contact/Form/Search/Builder.php
CRM/Contact/Page/View/Sunlight.php [deleted file]
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/ContributionRecur.php
CRM/Contribute/BAO/ContributionSoft.php
CRM/Contribute/BAO/Query.php
CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Contribute/Form/ContributionPage/Settings.php
CRM/Contribute/Form/SoftCredit.php
CRM/Contribute/Form/Task/PDF.php
CRM/Contribute/Page/Tab.php
CRM/Contribute/Selector/Search.php
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/Dashboard.php
CRM/Core/BAO/MessageTemplate.php
CRM/Core/BAO/UFJoin.php
CRM/Core/DAO.php
CRM/Core/Error.php
CRM/Core/Payment/PayPalImpl.php
CRM/Core/Payment/ProcessorForm.php
CRM/Core/Permission.php
CRM/Core/PseudoConstant.php
CRM/Core/Resources.php
CRM/Core/SelectValues.php
CRM/Core/xml/Menu/Contact.xml
CRM/Dedupe/Merger.php
CRM/Event/BAO/Query.php
CRM/Event/Form/Search.php
CRM/Export/BAO/Export.php
CRM/Financial/BAO/ExportFormat/CSV.php
CRM/Group/Form/Edit.php
CRM/Group/Form/Search.php
CRM/Logging/Schema.php
CRM/Mailing/BAO/Query.php
CRM/Member/BAO/Query.php
CRM/Price/BAO/PriceFieldValue.php
CRM/Price/BAO/PriceSet.php
CRM/Report/Form/Activity.php
CRM/UF/Page/Field.php
CRM/UF/Page/Group.php
CRM/Upgrade/4.7.4.msg_template/civicrm_msg_template.tpl [new file with mode: 0644]
CRM/Upgrade/4.7.4.msg_template/message_templates/event_offline_receipt_html.tpl [new file with mode: 0644]
CRM/Upgrade/4.7.4.msg_template/message_templates/event_offline_receipt_text.tpl [new file with mode: 0644]
CRM/Upgrade/4.7.4.msg_template/message_templates/event_online_receipt_html.tpl [new file with mode: 0644]
CRM/Upgrade/4.7.4.msg_template/message_templates/event_online_receipt_text.tpl [new file with mode: 0644]
CRM/Upgrade/Incremental/php/FourSeven.php
CRM/Upgrade/Incremental/sql/4.7.4.mysql.tpl [new file with mode: 0644]
CRM/Utils/PDF/Label.php
CRM/Utils/Request.php
CRM/Utils/Rule.php
CRM/Utils/Sunlight.php [deleted file]
CRM/Utils/System/DrupalBase.php
CRM/Utils/System/Joomla.php
CRM/Utils/System/WordPress.php
api/v3/Contact.php
api/v3/utils.php
bin/cli.class.php
composer.json
composer.lock
sql/civicrm_generated.mysql
templates/CRM/Activity/Selector/Selector.tpl
templates/CRM/Campaign/Form/Petition.tpl
templates/CRM/Campaign/Form/Search/Campaign.tpl
templates/CRM/Campaign/Form/Survey/Main.tpl
templates/CRM/Contact/Form/Merge.tpl
templates/CRM/Contact/Form/Search/Builder.js
templates/CRM/Contact/Page/View/Sunlight.tpl [deleted file]
templates/CRM/Contribute/Form/Selector.tpl
templates/CRM/Contribute/Page/ContributionSoft.tpl
templates/CRM/Event/Form/Search/Common.tpl
templates/CRM/Group/Form/Search.tpl
tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php
tests/phpunit/api/v3/ActivityTest.php
tests/phpunit/api/v3/ContactTest.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/PaymentTest.php
tools/scripts/composer/tcpdf-cleanup.sh [new file with mode: 0755]
xml/schema/Contribute/Contribution.xml
xml/version.xml

index f5a5a0ac46b849a5e850e4071dd0d4b8f9379f03..2faca0e791e96d9d534abb2b789b56cf7d200640 100644 (file)
@@ -2173,11 +2173,13 @@ AND cl.modified_id  = c.id
             'title' => ts('Activity Type'),
             'name' => 'activity_type',
             'type' => CRM_Utils_Type::T_STRING,
+            'searchByLabel' => TRUE,
           ),
           'activity_status' => array(
             'title' => ts('Activity Status'),
             'name' => 'activity_status',
             'type' => CRM_Utils_Type::T_STRING,
+            'searchByLabel' => TRUE,
           ),
         );
         $fields = array_merge($Activityfields, $exportableFields);
@@ -2604,7 +2606,7 @@ INNER JOIN  civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n
         );
 
         if ($values['is_recurring_activity']) {
-          $contactActivities[$activityId]['is_recurring_activity'] = CRM_Core_BAO_RecurringEntity::getPositionAndCount($values['activity_id'], 'civicrm_activity');
+          $activity['is_recurring_activity'] = CRM_Core_BAO_RecurringEntity::getPositionAndCount($values['activity_id'], 'civicrm_activity');
         }
 
         array_push($contactActivities, $activity);
index 2f241f9a48f3611c7326d3a2be4d07aa63667fcc..20677e49770a7fd1186e3b3a594bf17251bfdd16 100644 (file)
@@ -415,6 +415,9 @@ class CRM_Activity_BAO_Query {
     );
 
     CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
+    $form->addElement('hidden', 'activity_date_range_error');
+    $form->addFormRule(array('CRM_Activity_BAO_Query', 'formRule'), $form);
+
     $followUpActivity = array(
       1 => ts('Yes'),
       2 => ts('No'),
@@ -555,4 +558,25 @@ class CRM_Activity_BAO_Query {
     return $properties;
   }
 
+  /**
+   * Custom form rules.
+   *
+   * @param array $fields
+   * @param array $files
+   * @param CRM_Core_Form $form
+   *
+   * @return bool|array
+   */
+  public static function formRule($fields, $files, $form) {
+    $errors = array();
+
+    if (empty($fields['activity_date_low']) || empty($fields['activity_date_high'])) {
+      return TRUE;
+    }
+
+    CRM_Utils_Rule::validDateRange($fields, 'activity_date', $errors, ts('Activity Date'));
+
+    return empty($errors) ? TRUE : $errors;
+  }
+
 }
index c14991c9f8f188facfd69d63f153a7607a93273c..d392c4337f319964304d51853711b7e777792147 100644 (file)
@@ -378,6 +378,11 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
    * @param bool $test
    */
   public function updatePaymentProcessor(&$values, $domainID, $test) {
+    if ($test) {
+      foreach (array('user_name', 'password', 'signature') as $field) {
+        $values[$field] = empty($values["test_{$field}"]) ? CRM_Utils_Array::value($field, $values) : $values["test_{$field}"];
+      }
+    }
     $params  = array_merge(array(
       'id' => $test ? $this->_testID : $this->_id,
       'domain_id' => $domainID,
index 6931a7917fb10d2b607b4f4693769ba6ed16dd37..44fbbe2f3158671729e40b4263be3b386d33c8b5 100644 (file)
@@ -66,8 +66,11 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
 
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
-      CRM_Custom_Form_CustomData::preProcess($this);
+      $this->set('type', 'Event');
+      $this->set('entityId', $this->_surveyId);
+      CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
       CRM_Custom_Form_CustomData::buildQuickForm($this);
+      CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
 
     $session = CRM_Core_Session::singleton();
@@ -318,6 +321,12 @@ WHERE  $whereClause
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
     $params['is_default'] = CRM_Utils_Array::value('is_default', $params, 0);
 
+    $customFields = CRM_Core_BAO_CustomField::getFields('Survey');
+    $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
+      $this->_surveyId,
+      'Survey'
+    );
+
     $surveyId = CRM_Campaign_BAO_Survey::create($params);
 
     // also update the ProfileModule tables
index 7ebc9887f0d1b188b1da8cdb89d10f22902ff21a..2f7f2894e4a8c89c483c8309404fb159b0817476 100644 (file)
@@ -78,6 +78,15 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form {
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
 
+    // when custom data is included in this page
+    if (!empty($_POST['hidden_custom'])) {
+      $this->set('type', 'Event');
+      $this->set('entityId', $this->_surveyId);
+      CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
+      CRM_Custom_Form_CustomData::buildQuickForm($this);
+      CRM_Custom_Form_CustomData::setDefaultValues($this);
+    }
+
     // CRM-11480, CRM-11682
     // Preload libraries required by the "Questions" tab
     CRM_UF_Page_ProfileEditor::registerProfileScripts();
index 63171a485db4489b11ad5b76dc6197653430fb5d..44b2557c752aac8ae4e11e3e0ff27166c6e98368 100644 (file)
@@ -883,7 +883,7 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
     // CRM-5081 - formatting the dates to omit seconds.
     // Note the 00 in the date format string is needed otherwise later on it thinks scheduled ones are overdue.
     $select = "
-           SELECT COUNT(ca.id) AS ismultiple,
+           SELECT SQL_CALC_FOUND_ROWS COUNT(ca.id) AS ismultiple,
                   ca.id AS id,
                   ca.activity_type_id AS type,
                   ca.activity_type_id AS activity_type_id,
@@ -1015,6 +1015,7 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
     $queryParams = array(1 => array($caseID, 'Integer'));
 
     $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
+    $caseCount = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()');
 
     $activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
     $activityStatuses = CRM_Core_PseudoConstant::activityStatus();
@@ -1074,10 +1075,8 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
     }
 
     $caseActivities = array();
-    $caseCount = 0;
 
     while ($dao->fetch()) {
-      $caseCount++;
       $caseActivity = array();
       $caseActivityId = $dao->id;
 
index 503d6f01215bcfe22d3e4842724825b6fa47a37f..f55b737d8e497adfa81ec7b00c20c8bb6a39bf0c 100644 (file)
@@ -688,6 +688,9 @@ case_relation_type.id = case_relationship.relationship_type_id )";
 
     CRM_Core_Form_Date::buildDateRange($form, 'case_from', 1, '_start_date_low', '_start_date_high', ts('From'), FALSE);
     CRM_Core_Form_Date::buildDateRange($form, 'case_to', 1, '_end_date_low', '_end_date_high', ts('From'), FALSE);
+    $form->addElement('hidden', 'case_from_start_date_range_error');
+    $form->addElement('hidden', 'case_to_end_date_range_error');
+    $form->addFormRule(array('CRM_Case_BAO_Query', 'formRule'), $form);
 
     $form->assign('validCiviCase', TRUE);
 
@@ -738,4 +741,26 @@ case_relation_type.id = case_relationship.relationship_type_id )";
   public static function searchAction(&$row, $id) {
   }
 
+  /**
+   * Custom form rules.
+   *
+   * @param array $fields
+   * @param array $files
+   * @param CRM_Core_Form $form
+   *
+   * @return bool|array
+   */
+  public static function formRule($fields, $files, $form) {
+    $errors = array();
+
+    if ((empty($fields['case_from_start_date_low']) || empty($fields['case_from_start_date_high'])) && (empty($fields['case_to_end_date_low']) || empty($fields['case_to_end_date_high']))) {
+      return TRUE;
+    }
+
+    CRM_Utils_Rule::validDateRange($fields, 'case_from_start_date', $errors, ts('Case Start Date'));
+    CRM_Utils_Rule::validDateRange($fields, 'case_to_end_date', $errors, ts('Case End Date'));
+
+    return empty($errors) ? TRUE : $errors;
+  }
+
 }
index 03feaa4f55031419ec145a769bc1be4d64e6937a..e58471ae02ea4ba2e1166dbe38097936db4e6aaa 100644 (file)
@@ -413,6 +413,10 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
     // format activity custom data
     if (!empty($params['hidden_custom'])) {
       if ($this->_activityId) {
+        // retrieve and include the custom data of old Activity
+        $oldActivity = civicrm_api3('Activity', 'getsingle', array('id' => $this->_activityId));
+        $params = array_merge($params, $oldActivity);
+
         // unset custom fields-id from params since we want custom
         // fields to be saved for new activity.
         foreach ($params as $key => $value) {
@@ -504,8 +508,8 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
       else {
         $newActParams['original_id'] = $activity->id;
       }
-      //is_current_revision will be set to 1 by default.
 
+      //is_current_revision will be set to 1 by default.
       // add attachments if any
       CRM_Core_BAO_File::formatAttachment($newActParams,
         $newActParams,
index c0d1f629294600f9cafe2dc5d25d13c3c1fcd780..afa89e2b6e51a63975ee65c091d46abfa2566fa6 100644 (file)
@@ -368,7 +368,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
       }
     }
     else {
-      $params['group_type'] = '';
+      $params['group_type'] = NULL;
     }
 
     $session = CRM_Core_Session::singleton();
@@ -752,7 +752,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
       $group['DT_RowId'] = 'row_' . $value['id'];
       if (!$params['parentsOnly']) {
         foreach ($value['class'] as $id => $class) {
-          if ($class = 'crm-group-parent') {
+          if ($class == 'crm-group-parent') {
             unset($value['class'][$id]);
           }
         }
index f1a347db0b11fbdb4f927b7a7392b7a65888818b..690a200e6992446bb05fb01d95465255261a04e7 100644 (file)
@@ -331,24 +331,27 @@ SET    cache_date = null,
 ";
       }
       else {
+
         $query = "
 DELETE     gc
 FROM       civicrm_group_contact_cache gc
 INNER JOIN civicrm_group g ON g.id = gc.group_id
-WHERE      TIMESTAMPDIFF(MINUTE, g.cache_date, $now) >= $smartGroupCacheTimeout
+WHERE      g.cache_date <= %1
 ";
         $update = "
 UPDATE civicrm_group g
 SET    cache_date = null,
        refresh_date = null
-WHERE  TIMESTAMPDIFF(MINUTE, cache_date, $now) >= $smartGroupCacheTimeout
+WHERE  g.cache_date <= %1
 ";
         $refresh = "
 UPDATE civicrm_group g
 SET    refresh_date = $refreshTime
-WHERE  TIMESTAMPDIFF(MINUTE, cache_date, $now) < $smartGroupCacheTimeout
+WHERE  g.cache_date > %1
 AND    refresh_date IS NULL
 ";
+        $cacheTime = date('Y-m-d H-i-s', strtotime("- $smartGroupCacheTimeout minutes"));
+        $params = array(1 => array($cacheTime, 'String'));
       }
     }
     elseif (is_array($groupID)) {
index 7db2bafb4763cd1adef80a9835b23d401e76f2eb..f0ff34aeb6f5d924f8f08fd6550f052c1ec5b258 100644 (file)
@@ -1507,6 +1507,8 @@ class CRM_Contact_BAO_Query {
       return $params;
     }
 
+    self::filterCountryFromValuesIfStateExists($formValues);
+
     foreach ($formValues as $id => $values) {
 
       if (self::isAlreadyProcessedForQueryFormat($values)) {
@@ -4456,6 +4458,29 @@ civicrm_relationship.is_permission_a_b = 0
     return in_array($operator, CRM_Core_DAO::acceptedSQLOperators());
   }
 
+  /**
+   * If the state and country are passed remove state.
+   *
+   * Country is implicit from the state, but including both results in
+   * a poor query as there is no combined index on state AND country.
+   *
+   * CRM-18125
+   *
+   * @param array $formValues
+   */
+  public static function filterCountryFromValuesIfStateExists(&$formValues) {
+    if (!empty($formValues['country']) && !empty($formValues['state_province'])) {
+      // The use of array map sanitises the data by ensuring we are dealing with integers.
+      $states = implode(', ', array_map('intval', $formValues['state_province']));
+      $countryList = CRM_Core_DAO::singleValueQuery(
+        "SELECT GROUP_CONCAT(country_id) FROM civicrm_state_province WHERE id IN ($states)"
+      );
+      if ($countryList == $formValues['country']) {
+        unset($formValues['country']);
+      }
+    }
+  }
+
   /**
    * Create and query the db for an contact search.
    *
@@ -5842,13 +5867,13 @@ AND   displayRelType.is_active = 1
       $pseudoOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
     }
     elseif ($fieldName == 'country_id') {
-      $pseduoOptions = CRM_Core_PseudoConstant::country();
+      $pseudoOptions = CRM_Core_PseudoConstant::country();
     }
     elseif ($fieldName == 'county_id') {
-      $pseduoOptions = CRM_Core_PseudoConstant::county();
+      $pseudoOptions = CRM_Core_PseudoConstant::county();
     }
     elseif ($fieldName == 'world_region') {
-      $pseduoOptions = CRM_Core_PseudoConstant::worldRegion();
+      $pseudoOptions = CRM_Core_PseudoConstant::worldRegion();
     }
     elseif ($daoName == 'CRM_Event_DAO_Event' && $fieldName == 'id') {
       $pseudoOptions = CRM_Event_BAO_Event::getEvents(0, $fieldValue, TRUE, TRUE, TRUE);
index ed3e4dbe8c272f19e24b6b5eec9b1d7238a76e55..03ba749b804688e66bc1e8a1eca8315db986f0a0 100644 (file)
@@ -166,7 +166,7 @@ class CRM_Contact_Form_Edit_CommunicationPreferences {
 
     // CRM-17778 -- set preferred_mail_format to default if unset
     if (empty($defaults['preferred_mail_format'])) {
-      $defaults['preferred_mail_format'] = array_search('Both', CRM_Core_SelectValues::pmf());
+      $defaults['preferred_mail_format'] = 'Both';
     }
 
     //set default from greeting types CRM-4575, CRM-9739
index 3027767cc5c1727619068b0b0d5a0938db5df1b3..270275ab0bcd9ba0242e90e0135420fedf437ad2 100644 (file)
@@ -321,20 +321,6 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
     $message = '<ul><li>' . ts('%1 has been updated.', array(1 => $name)) . '</li><li>' . ts('Contact ID %1 has been deleted.', array(1 => $this->_oid)) . '</li></ul>';
     CRM_Core_Session::setStatus($message, ts('Contacts Merged'), 'success');
 
-    //create activity for merge
-    //To do: this should be refactored into BAO layer at some point.
-    $messageActivity = ts('Contact ID %1 has been merged and deleted.', array(1 => $this->_oid));
-    $activityParams = array(
-      'subject' => $messageActivity,
-      'source_contact_id' => $session->get('userID'),
-      'target_contact_id' => $this->_cid,
-      'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Contact Merged'),
-      'status_id' => 'Completed',
-      'priority_id' => 'Normal',
-      'activity_date_time' => date('YmdHis'),
-    );
-    civicrm_api3('activity', 'create', $activityParams);
-
     $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_cid}");
     if (!empty($formValues['_qf_Merge_submit'])) {
       $listParamsURL = "reset=1&action=update&rgid={$this->_rgid}";
index 311e53d7076671960a8faf11fb15a6b8678334ae..6a0ee798a6e11697ebf0928a883e459d33092562 100644 (file)
@@ -150,7 +150,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
    *
    * @var array
    */
-  protected $entityReferenceFields = array('membership_type_id');
+  protected $entityReferenceFields = array('event_id', 'membership_type_id');
 
   /**
    * Name of the selector to use.
index aca7d35e79cb7fc626241b41b9c3ca5a474f87b7..7c059e41c8091cdab7ac3195f760b7c709ea876b 100644 (file)
@@ -381,11 +381,29 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search {
     if (!is_array($defaults)) {
       $defaults = array();
     }
-
+    $this->loadDefaultCountryBasedOnState($defaults);
     if ($this->_ssID && empty($_POST)) {
       $defaults = array_merge($defaults, CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID));
     }
     return $defaults;
   }
 
+  /**
+   * Set the default country for the form.
+   *
+   * For performance reasons country might be removed from the form CRM-18125
+   * but we need to include it in our defaults or the state will not be visible.
+   *
+   * @param array $defaults
+   */
+  public function loadDefaultCountryBasedOnState(&$defaults) {
+    if (!empty($defaults['state_province'])) {
+      $defaults['country'] = CRM_Core_DAO::singleValueQuery(
+        "SELECT country_id FROM civicrm_state_province
+         WHERE id = %1",
+        array(1 => array($defaults['state_province'][0], 'Integer'))
+      );
+    }
+  }
+
 }
index 5577b25610cb85b60e57342d9b1ccede76366ee1..9f4995cf767d69a9c287c5aa6f2a98491f34e1b6 100644 (file)
@@ -94,10 +94,20 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search {
     // Get fields of type date
     // FIXME: This is a hack until our fields contain this meta-data
     $dateFields = array();
+    $stringFields = array();
+    $searchByLabelFields = array();
     foreach ($fields as $name => $field) {
       if (strpos($name, '_date') || CRM_Utils_Array::value('data_type', $field) == 'Date') {
         $dateFields[] = $name;
       }
+      // it's necessary to know which of the fields are from string data type
+      if (isset($field['type']) && $field['type'] === CRM_Utils_Type::T_STRING) {
+        $stringFields[] = $name;
+      }
+      // it's necessary to know which of the fields are searchable by label
+      if (isset($field['searchByLabel']) && $field['searchByLabel']) {
+        $searchByLabelFields[] = $name;
+      }
     }
     // Add javascript
     CRM_Core_Resources::singleton()
@@ -108,6 +118,10 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search {
           'newBlock' => $this->get('newBlock'),
           'dateFields' => $dateFields,
           'fieldOptions' => self::fieldOptions(),
+          'stringFields' => $stringFields,
+          'searchByLabelFields' => $searchByLabelFields,
+          'generalOperators' => array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators(),
+          'stringOperators' => array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators(CRM_Utils_Type::T_STRING),
         ),
       ));
     //get the saved search mapping id
diff --git a/CRM/Contact/Page/View/Sunlight.php b/CRM/Contact/Page/View/Sunlight.php
deleted file mode 100644 (file)
index add1aa6..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- */
-class CRM_Contact_Page_View_Sunlight extends CRM_Contact_Page_View {
-
-  /**
-   * Called when action is browse.
-   */
-  public function browse() {
-    // get the primary city, state and zip for the contact
-    $ids = array($this->_contactId);
-    $locations = CRM_Contact_BAO_Contact_Location::getMapInfo($ids);
-
-    $rows = &CRM_Utils_Sunlight::getInfo($locations[0]['city'],
-      $locations[0]['state'],
-      $locations[0]['postal_code']
-    );
-    $this->assign('rowCount', count($rows));
-    $this->assign_by_ref('rows', $rows);
-  }
-
-  /**
-   * the main function that is called when the page loads,
-   * it decides the which action has to be taken for the page.
-   *
-   * @return null
-   */
-  public function run() {
-    $this->preProcess();
-
-    $this->browse();
-
-    return parent::run();
-  }
-
-}
index f62cbc7cbb10b1f1e93015d47f7453691fddd387..365ca8f1e2b507ec3770259317518e6ead492f2a 100644 (file)
@@ -3803,20 +3803,21 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
       }
       // add financial item entry
       $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
-      $getLine['entity_id'] = $contributionDAO->id;
-      $getLine['entity_table'] = 'civicrm_contribution';
-      $lineItemId = CRM_Price_BAO_LineItem::retrieve($getLine, CRM_Core_DAO::$_nullArray);
-      if (!empty($lineItemId->id)) {
-        $addFinancialEntry = array(
-          'transaction_date' => $financialTrxn->trxn_date,
-          'contact_id' => $contributionDAO->contact_id,
-          'amount' => $financialTrxn->total_amount,
-          'status_id' => array_search('Paid', $financialItemStatus),
-          'entity_id' => $lineItemId->id,
-          'entity_table' => 'civicrm_line_item',
-        );
-        $trxnIds['id'] = $financialTrxn->id;
-        CRM_Financial_BAO_FinancialItem::create($addFinancialEntry, NULL, $trxnIds);
+      $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contributionDAO->id);
+      if (!empty($lineItems)) {
+        foreach ($lineItems as $lineItemId => $lineItemValue) {
+          $paid = $lineItemValue['line_total'] * ($financialTrxn->total_amount / $contributionDAO->total_amount);
+          $addFinancialEntry = array(
+            'transaction_date' => $financialTrxn->trxn_date,
+            'contact_id' => $contributionDAO->contact_id,
+            'amount' => round($paid, 2),
+            'status_id' => array_search('Paid', $financialItemStatus),
+            'entity_id' => $lineItemId,
+            'entity_table' => 'civicrm_line_item',
+          );
+          $trxnIds['id'] = $financialTrxn->id;
+          CRM_Financial_BAO_FinancialItem::create($addFinancialEntry, NULL, $trxnIds);
+        }
       }
       if ($participantId) {
         // update participant status
@@ -4400,10 +4401,6 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
         $values['is_email_receipt'] = $recurContrib->is_email_receipt;
       }
 
-      if (!empty($values['is_email_receipt'])) {
-        $contributionParams['receipt_date'] = $changeDate;
-      }
-
       if (!empty($memberships)) {
         foreach ($memberships as $membershipTypeIdKey => $membership) {
           if ($membership) {
@@ -4620,6 +4617,10 @@ LIMIT 1;";
         $values['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $input, $userName);
       }
     }
+    // Contribution ID should really always be set. But ?
+    if (!$returnMessageText && (!isset($input['receipt_update']) || $input['receipt_update'])) {
+      civicrm_api3('Contribution', 'create', array('receipt_date' => 'now', 'id' => $contribution->id));
+    }
     return $contribution->composeMessageArray($input, $ids, $values, $recur, $returnMessageText);
   }
 
@@ -4785,10 +4786,10 @@ LIMIT 1;";
    */
   public static function addPayments($lineItems, $contributions) {
     // get financial trxn which is a payment
-    $ftSql = "SELECT ft.id
+    $ftSql = "SELECT ft.id, ft.total_amount
       FROM civicrm_financial_trxn ft
       INNER JOIN civicrm_entity_financial_trxn eft ON eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution'
-      WHERE eft.entity_id = %1 AND ft.is_payment = 1";
+      WHERE eft.entity_id = %1 AND ft.is_payment = 1 ORDER BY ft.id DESC LIMIT 1";
     $sql = "SELECT fi.id, li.price_field_value_id
       FROM civicrm_financial_item fi
       INNER JOIN civicrm_line_item li ON li.id = fi.entity_id
@@ -4798,7 +4799,11 @@ LIMIT 1;";
       if ($contribution->contribution_status_id != CRM_Core_OptionGroup::getValue('contribution_status', 'Partially paid', 'name')) {
         continue;
       }
-      $ftId = CRM_Core_DAO::singleValueQuery($ftSql, array(1 => array($contribution->id, 'Integer')));
+      $ftDao = CRM_Core_DAO::executeQuery($ftSql, array(1 => array($contribution->id, 'Integer')));
+      $ftDao->fetch();
+      $trxnAmount = $ftDao->total_amount;
+      $ftId = $ftDao->id;
+
       // get financial item
       $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($contribution->id, 'Integer')));
       while ($dao->fetch()) {
@@ -4810,7 +4815,7 @@ LIMIT 1;";
         'financial_trxn_id' => $ftId,
       );
       foreach ($lineItems as $key => $value) {
-        $paid = $value['line_total'] * ($contribution->net_amount / $contribution->total_amount);
+        $paid = $value['line_total'] * ($trxnAmount / $contribution->total_amount);
         // Record Entity Financial Trxn
         $params['amount'] = round($paid, 2);
         $params['entity_id'] = $ftIds[$value['price_field_value_id']];
index b139c9469b3bde2c0229a2da9f0d6a2b6a13270c..98b1a1d9f4e3c6bf6c698daac2ac4036c3b6fe1f 100644 (file)
@@ -760,7 +760,7 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
   public static function recurringContribution(&$form) {
     // Recurring contribution fields
     foreach (self::getRecurringFields() as $key => $label) {
-      if ($key == 'contribution_recur_payment_made' &&
+      if ($key == 'contribution_recur_payment_made' && !empty($form->_formValues) &&
         !CRM_Utils_System::isNull(CRM_Utils_Array::value($key, $form->_formValues))
       ) {
         $form->assign('contribution_recur_pane_open', TRUE);
@@ -768,7 +768,7 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
       }
       CRM_Core_Form_Date::buildDateRange($form, $key, 1, '_low', '_high');
       // If data has been entered for a recurring field, tell the tpl layer to open the pane
-      if (!empty($form->_formValues[$key . '_relative']) || !empty($form->_formValues[$key . '_low']) || !empty($form->_formValues[$key . '_high'])) {
+      if (!empty($form->_formValues) && !empty($form->_formValues[$key . '_relative']) || !empty($form->_formValues[$key . '_low']) || !empty($form->_formValues[$key . '_high'])) {
         $form->assign('contribution_recur_pane_open', TRUE);
         break;
       }
index aecf78541a7646e5352a2ed3aa400c863817465a..bd7354d7fa51365b68592b48d7b3bbbd479fe51a 100644 (file)
@@ -243,12 +243,15 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio
    * @return array
    */
   public static function getSoftContributionTotals($contact_id, $isTest = 0) {
-    $query = '
+
+    $whereClause = "AND cc.cancel_date IS NULL";
+
+    $query = "
     SELECT SUM(amount) as amount, AVG(total_amount) as average, cc.currency
     FROM civicrm_contribution_soft  ccs
       LEFT JOIN civicrm_contribution cc ON ccs.contribution_id = cc.id
-    WHERE cc.is_test = %2 AND ccs.contact_id = %1
-    GROUP BY currency';
+    WHERE cc.is_test = %2 AND ccs.contact_id = %1 {$whereClause}
+    GROUP BY currency";
 
     $params = array(
       1 => array($contact_id, 'Integer'),
@@ -258,7 +261,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio
     $cs = CRM_Core_DAO::executeQuery($query, $params);
 
     $count = 0;
-    $amount = $average = array();
+    $amount = $average = $cancelAmount = array();
 
     while ($cs->fetch()) {
       if ($cs->amount > 0) {
@@ -269,11 +272,23 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio
       }
     }
 
+    //to get cancel amount
+    $cancelAmountWhereClause = "AND cc.cancel_date IS NOT NULL";
+    $query = str_replace($whereClause, $cancelAmountWhereClause, $query);
+    $cancelAmountSQL  = CRM_Core_DAO::executeQuery($query, $params);
+    while ($cancelAmountSQL->fetch()) {
+      if ($cancelAmountSQL->amount > 0) {
+        $count++;
+        $cancelAmount[] = $cancelAmountSQL->amount;
+      }
+    }
+
     if ($count > 0) {
       return array(
         implode(',&nbsp;', $amount),
         implode(',&nbsp;', $average),
         implode(',&nbsp;', $currency),
+        implode(',&nbsp;', $cancelAmount),
       );
     }
     return array(0, 0);
index e86b91fabd40800571658d101a73399dd3cd7623..f26d00dc4e7e2dfa431ffc4e0d71e17562b28c5e 100644 (file)
@@ -864,7 +864,7 @@ class CRM_Contribute_BAO_Query {
    * kills a small kitten so add carefully.
    */
   public static function selectorReturnProperties() {
-    return array(
+    $properties = array(
       'contact_type' => 1,
       'contact_sub_type' => 1,
       'sort_name' => 1,
@@ -887,6 +887,11 @@ class CRM_Contribute_BAO_Query {
       'contribution_product_id' => 1,
       'product_name' => 1,
     );
+    if (self::isSoftCreditOptionEnabled()) {
+      $properties = array_merge($properties, self::softCreditReturnProperties());
+    }
+
+    return $properties;
   }
 
   /**
@@ -1014,6 +1019,10 @@ class CRM_Contribute_BAO_Query {
     $form->addElement('text', 'contribution_source', ts('Contribution Source'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'source'));
 
     CRM_Core_Form_Date::buildDateRange($form, 'contribution_date', 1, '_low', '_high', ts('From:'), FALSE);
+    // CRM-17602
+    // This hidden element added for displaying Date Range error correctly. Definitely a dirty hack, but... it works.
+    $form->addElement('hidden', 'contribution_date_range_error');
+    $form->addFormRule(array('CRM_Contribute_BAO_Query', 'formRule'), $form);
 
     $form->add('text', 'contribution_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
     $form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
@@ -1192,4 +1201,25 @@ class CRM_Contribute_BAO_Query {
     return TRUE;
   }
 
+  /**
+   * Custom form rules.
+   *
+   * @param array $fields
+   * @param array $files
+   * @param CRM_Core_Form $form
+   *
+   * @return bool|array
+   */
+  public static function formRule($fields, $files, $form) {
+    $errors = array();
+
+    if (empty($fields['contribution_date_high']) || empty($fields['contribution_date_low'])) {
+      return TRUE;
+    }
+
+    CRM_Utils_Rule::validDateRange($fields, 'contribution_date', $errors, ts('Date Received'));
+
+    return empty($errors) ? TRUE : $errors;
+  }
+
 }
index 2e02e3701f7764e7aa534098f616d77904d3da2c..0077c7912871144a3abd9ee175f5a283e2086f34 100644 (file)
@@ -382,7 +382,15 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       $this->processCreditCard($submittedValues);
     }
     else {
+      $defaults = array();
       $result = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $submittedValues, $this->_paymentType, $participantId);
+      // Fetch the contribution & do proportional line item assignment
+      $params = array('id' => $this->_contributionId);
+      $contribution = CRM_Contribute_BAO_Contribution::retrieve($params, $defaults, $params);
+      $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_contributionId);
+      if (!empty($lineItems)) {
+        CRM_Contribute_BAO_Contribution::addPayments($lineItems, array($contribution));
+      }
 
       // email sending
       if (!empty($result) && !empty($submittedValues['is_email_receipt'])) {
index 4e286e39979ec54966928ee1c67d292fd927d20c..2c90c8159d0e7ae928933f1bcb36e52affacbde0 100644 (file)
@@ -705,6 +705,11 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $name = CRM_Utils_Array::value($contributionStatus, $statusName);
       switch ($name) {
         case 'Completed':
+          // [CRM-17498] Removing unsupported status change options.
+          unset($status[CRM_Utils_Array::key('Pending', $statusName)]);
+          unset($status[CRM_Utils_Array::key('Failed', $statusName)]);
+          unset($status[CRM_Utils_Array::key('Partially paid', $statusName)]);
+          unset($status[CRM_Utils_Array::key('Pending refund', $statusName)]);
         case 'Cancelled':
         case 'Chargeback':
         case 'Refunded':
index 5c733a583dff8d0c306de19bb64a32429d35929f..8a6db269bb304c5fc02c98f261d7cf373119ac47 100644 (file)
@@ -1333,6 +1333,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     $isPending = $this->getIsPending();
 
     $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
+    $this->_values['membership_name'] = CRM_Utils_Array::value('name', $membershipType);
 
     $isPaidMembership = FALSE;
     if ($this->_amount >= 0.0 && isset($membershipParams['amount'])) {
@@ -1499,12 +1500,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         );
         $form->set('renewal_mode', $renewalMode);
         if (!empty($dates)) {
-          $form->assign('mem_start_date',
-            CRM_Utils_Date::customFormat($dates['start_date'], '%Y%m%d')
-          );
-          $form->assign('mem_end_date',
-            CRM_Utils_Date::customFormat($dates['end_date'], '%Y%m%d')
-          );
+          $form->assign('mem_start_date', CRM_Utils_Date::customFormat($dates['start_date'], '%Y%m%d'));
+          $form->assign('mem_end_date', CRM_Utils_Date::customFormat($dates['end_date'], '%Y%m%d'));
         }
 
         if (!empty($membershipContribution)) {
@@ -1562,7 +1559,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $form->_values['contribution_id'] = $membershipContributionID;
     }
 
-    if ($form->_paymentProcessor) {
+    if (empty($form->_params['is_pay_later']) && $form->_paymentProcessor) {
       // the is_monetary concept probably should be deprecated as it can be calculated from
       // the existence of 'amount' & seems fragile.
       if ($form->_values['is_monetary'] && $form->_amount > 0.0 && !$form->_params['is_pay_later']) {
@@ -1580,19 +1577,23 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       // Do not send an email if Recurring transaction is done via Direct Mode
       // Email will we sent when the IPN is received.
       foreach ($paymentResults as $result) {
-        $this->completeTransaction($result['result'], $result['contribution_id']);
+        //CRM-18211: Fix situation where second contribution doesn't exist because it is optional.
+        if ($result['contribution_id']) {
+          $this->completeTransaction($result['result'], $result['contribution_id']);
+        }
       }
       return;
     }
 
-    $emailValues = $form->_values;
+    $emailValues = array_merge($membershipParams, $form->_values);
+    $emailValues['membership_assign'] = 1;
     // Finally send an email receipt for pay-later scenario (although it might sometimes be caught above!)
     if ($totalAmount == 0) {
       // This feels like a bizarre hack as the variable name doesn't seem to be directly connected to it's use in the template.
       $emailValues['useForMember'] = 0;
-      $emailValues['membership_assign'] = 1;
       $emailValues['amount'] = 0;
     }
+
     CRM_Contribute_BAO_ContributionPage::sendMail($contactID,
       $emailValues,
       $isTest, FALSE,
index 7dd7574d28dd835d6225f36d0d26fc05cca37ba8..73cb547540a7c3a1d9f315ec14eda4a8705d7bcf 100644 (file)
@@ -1008,6 +1008,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
 
     $params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
 
+    $is_quick_config = 0;
     if (!empty($params['priceSetId'])) {
       $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
       if ($is_quick_config) {
@@ -1024,14 +1025,15 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
               case 'membership_amount':
                 $this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]);
                 $this->set('selectMembership', $params['selectMembership']);
-                if (CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) {
-                  $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
-                }
-                break;
 
               case 'contribution_amount':
                 $params['amount'] = $selectedPriceOptionID;
-                $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
+                if ($priceField->name == 'contribution_amount' ||
+                    ($priceField->name == 'membership_amount' &&
+                      CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0)
+                ) {
+                  $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
+                }
                 $this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]);
                 $this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]);
                 $this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID]);
@@ -1048,12 +1050,11 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     }
     // from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
     $params['amount'] = self::computeAmount($params, $this->_values);
-
     if (($this->_values['is_pay_later'] &&
         empty($this->_paymentProcessor) &&
         !array_key_exists('hidden_processor', $params)) ||
       (CRM_Utils_Array::value('payment_processor_id', $params) == 0)
-      && $params['amount'] != 0
+      && ($is_quick_config == 0 || $params['amount'] != 0)
     ) {
       $params['is_pay_later'] = 1;
     }
index 4e7e883cc3dd724dcddd7c5c11baa6fa490e6559..6efc73568e1ae334193e39150a7ee365c0a4684f 100644 (file)
@@ -57,6 +57,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
         $ufJoinDAO = new CRM_Core_DAO_UFJoin();
         $ufJoinDAO->module = $module;
         $ufJoinDAO->entity_id = $this->_id;
+        $ufJoinDAO->entity_table = 'civicrm_contribution_page';
         if ($ufJoinDAO->find(TRUE)) {
           $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, $module);
           if ($module == 'soft_credit') {
index 670bbcb812457ee8a1a7fefc49ec4bd21309c76d..78411d4d51e5b88cf08a9442befc82619d9bf533 100644 (file)
@@ -55,7 +55,7 @@ class CRM_Contribute_Form_SoftCredit {
 
       //check if any honree profile is enabled if yes then assign its profile type to $_honoreeProfileType
       // which will be used to constraint soft-credit contact type in formRule, CRM-13981
-      if ($profileId[0]) {
+      if (!empty($profileId[0]) && !empty($profileId[2])) {
         $form->_honoreeProfileType = CRM_Core_BAO_UFGroup::getContactType($profileId[0]);
       }
     }
index e06a79e877061d36358c0ddfaae8744bc95e8213..a3b941811f2d5eba7eb3d820c0a2a07b64dbe1a6 100644 (file)
@@ -180,7 +180,7 @@ AND    {$this->_componentClause}";
       $input['net_amount'] = $contribution->net_amount;
       $input['trxn_id'] = $contribution->trxn_id;
       $input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : NULL;
-      $input['receipt_date'] = $contribution->receipt_date;
+      $input['receipt_update'] = $params['receipt_update'];
 
       // CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date
       $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);
@@ -198,10 +198,6 @@ AND    {$this->_componentClause}";
 
       // reset template values before processing next transactions
       $template->clearTemplateVars();
-      if (!empty($params['receipt_update'])) {
-        $objects['contribution']->receipt_date = date('Y-m-d H-i-s');
-        $objects['contribution']->save();
-      }
     }
 
     if ($elements['createPdf']) {
index b284ed0118ac1efe2e8436849909767752f65770..e7ee1f2cfd3a32215bd09132e23f0a64e72023ce 100644 (file)
@@ -180,7 +180,8 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
 
       list($softCreditTotals['amount'],
         $softCreditTotals['avg'],
-        $softCreditTotals['currency']
+        $softCreditTotals['currency'],
+        $softCreditTotals['cancelAmount'] //to get cancel amount
         ) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest);
 
       $this->assign('softCredit', TRUE);
index fd1327706d374547e3c7f34c895c7ee34b5763b5..ef60698c8881fb4f113f5fa99777ba29f9875384 100644 (file)
@@ -311,7 +311,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
   public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
     if ($this->_includeSoftCredits) {
       // especial sort order when rows include soft credits
-      $sort = "civicrm_contribution.receive_date DESC, civicrm_contribution.id, civicrm_contribution_soft.id";
+      $sort = $sort->orderBy() . ", civicrm_contribution.id, civicrm_contribution_soft.id";
     }
     $result = $this->_query->searchQuery($offset, $rowCount, $sort,
       FALSE, FALSE,
index 5756980c206099527cc4d8baf66ba2511772d6c6..a562a1c1d4d619a4dec92cb2ac32fda1f6359806 100644 (file)
@@ -1619,14 +1619,27 @@ SELECT id
       $fName = $value['name'];
       $mimeType = $value['type'];
 
+      // If we are already passing the file id as a value then retrieve and set the file data
+      if (CRM_Utils_Rule::integer($value)) {
+        $fileDAO = new CRM_Core_DAO_File();
+        $fileDAO->id = $value;
+        $fileDAO->find(TRUE);
+        if ($fileDAO->N) {
+          $fileID = $value;
+          $fName = $fileDAO->uri;
+          $mimeType = $fileDAO->mime_type;
+        }
+      }
+
       $filename = pathinfo($fName, PATHINFO_BASENAME);
 
-      // rename this file to go into the secure directory
-      if (!rename($fName, $config->customFileUploadDir . $filename)) {
+      // rename this file to go into the secure directory only if
+      // user has uploaded new file not existing verfied on the basis of $fileID
+      if (!$fileID && !rename($fName, $config->customFileUploadDir . $filename)) {
         CRM_Core_Error::statusBounce(ts('Could not move custom file to custom upload directory'));
       }
 
-      if ($customValueId) {
+      if ($customValueId && !$fileID) {
         $query = "
 SELECT $columnName
   FROM $tableName
index e42bf80bfab52c9a769a5f50f2c78ba5416c05e4..c8df7cbdc738afb5735363efd24ddb962cc289af 100644 (file)
@@ -107,29 +107,30 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard {
   public static function getContactDashlets($flatFormat = FALSE, $contactID = NULL) {
     $dashlets = array();
 
-    if (!$contactID) {
-      $contactID = CRM_Core_Session::singleton()->get('userID');
-    }
-
     // Get contact dashboard dashlets.
     $hasDashlets = FALSE;
     $dao = new CRM_Contact_DAO_DashboardContact();
-    $dao->contact_id = $contactID;
+    $dao->contact_id = $contactID ? $contactID : CRM_Core_Session::singleton()->getLoggedInContactID();
     $dao->orderBy('column_no asc, weight asc');
     $dao->find();
+
+    // The available list will only include those which are valid for the domain.
+    $availableDashlets = self::getDashlets();
     while ($dao->fetch()) {
       // When a dashlet is removed, it stays in the table with status disabled,
       // so even if a user decides not to have any dashlets show, they will still
       // have records in the table to indicate that we are not newly initializing.
-      $hasDashlets = TRUE;
-      if (!$flatFormat) {
-        if ($dao->is_active) {
-          // append weight so that order is preserved.
-          $dashlets[$dao->column_no]["{$dao->weight}-{$dao->dashboard_id}"] = $dao->is_minimized;
+      if ((!empty($availableDashlets[$dao->dashboard_id]) && $availableDashlets[$dao->dashboard_id]['is_active'])) {
+        $hasDashlets = TRUE;
+        if (!$flatFormat) {
+          if ($dao->is_active) {
+            // append weight so that order is preserved.
+            $dashlets[$dao->column_no]["{$dao->weight}-{$dao->dashboard_id}"] = $dao->is_minimized;
+          }
+        }
+        else {
+          $dashlets[$dao->dashboard_id] = $dao->dashboard_id;
         }
-      }
-      else {
-        $dashlets[$dao->dashboard_id] = $dao->dashboard_id;
       }
     }
 
@@ -162,7 +163,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard {
         'domain_id' => CRM_Core_Config::domainID(),
         'option.limit' => 0,
       ));
-    $contactID = CRM_Core_Session::singleton()->get('userID');
+    $contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
     $allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']);
     $defaultDashlets = array();
     $defaults = array('blog' => 1, 'getting-started' => '0');
index ee6b7a9c99627a733d6d9145f633d2b228a05012..3f6e7a7114df6ade48eb2d3cdb042b4cb5696073 100644 (file)
@@ -405,6 +405,7 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate {
     $domain = CRM_Core_BAO_Domain::getDomain();
     $hookTokens = array();
     $mailing = new CRM_Mailing_BAO_Mailing();
+    $mailing->subject = $subject;
     $mailing->body_text = $text;
     $mailing->body_html = $html;
     $tokens = $mailing->getTokens();
@@ -417,6 +418,12 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate {
       $contactParams = array('contact_id' => $contactID);
       $returnProperties = array();
 
+      if (isset($tokens['subject']['contact'])) {
+        foreach ($tokens['subject']['contact'] as $name) {
+          $returnProperties[$name] = 1;
+        }
+      }
+
       if (isset($tokens['text']['contact'])) {
         foreach ($tokens['text']['contact'] as $name) {
           $returnProperties[$name] = 1;
index 92bd4cf9cd975d89e440468df73ed41638dfface..877db2524b599e8b3eb5efcd2f1c20bd613b050e 100644 (file)
@@ -141,6 +141,7 @@ class CRM_Core_BAO_UFJoin extends CRM_Core_DAO_UFJoin {
     $dao->entity_table = CRM_Utils_Array::value('entity_table', $params);
     $dao->entity_id = CRM_Utils_Array::value('entity_id', $params);
     $dao->weight = CRM_Utils_Array::value('weight', $params);
+    $dao->module = CRM_Utils_Array::value('module', $params);
     if ($dao->find(TRUE)) {
       return $dao->uf_group_id;
     }
index 189b6c8d59a626440de68f4d23b33d6c1fdba50d..c7a401353365b322cbe408d2db153f66cd417456 100644 (file)
@@ -112,6 +112,7 @@ class CRM_Core_DAO extends DB_DataObject {
       CRM_Core_DAO::executeQuery('SET SESSION sql_mode = STRICT_TRANS_TABLES');
     }
     CRM_Core_DAO::executeQuery('SET NAMES utf8');
+    CRM_Core_DAO::executeQuery('SET @uniqueID = %1', array(1 => array(CRM_Utils_Request::id(), 'String')));
   }
 
   /**
index e8c190d0d6e9f8e9083cff75d10d47f05f6c18ca..a2c0b4390ba5f9bf765dfd0b2186c087f9c7ec7c 100644 (file)
@@ -634,31 +634,33 @@ class CRM_Core_Error extends PEAR_ErrorStack {
    * @return Log
    */
   public static function createDebugLogger($comp = '') {
-    $config = CRM_Core_Config::singleton();
+    if (!isset(\Civi::$statics[__CLASS__]['logger_file' . $comp])) {
+      $config = CRM_Core_Config::singleton();
 
-    if ($comp) {
-      $comp = $comp . '.';
-    }
-
-    $fileName = "{$config->configAndLogDir}CiviCRM." . $comp . md5($config->dsn) . '.log';
-
-    // Roll log file monthly or if greater than 256M
-    // note that PHP file functions have a limit of 2G and hence
-    // the alternative was introduce
-    if (file_exists($fileName)) {
-      $fileTime = date("Ym", filemtime($fileName));
-      $fileSize = filesize($fileName);
-      if (($fileTime < date('Ym')) ||
-        ($fileSize > 256 * 1024 * 1024) ||
-        ($fileSize < 0)
-      ) {
-        rename($fileName,
-          $fileName . '.' . date('YmdHi')
-        );
+      if ($comp) {
+        $comp = $comp . '.';
       }
-    }
 
-    return Log::singleton('file', $fileName);
+      $fileName = "{$config->configAndLogDir}CiviCRM." . $comp . md5($config->dsn) . '.log';
+
+      // Roll log file monthly or if greater than 256M
+      // note that PHP file functions have a limit of 2G and hence
+      // the alternative was introduce
+      if (file_exists($fileName)) {
+        $fileTime = date("Ym", filemtime($fileName));
+        $fileSize = filesize($fileName);
+        if (($fileTime < date('Ym')) ||
+          ($fileSize > 256 * 1024 * 1024) ||
+          ($fileSize < 0)
+        ) {
+          rename($fileName,
+            $fileName . '.' . date('YmdHi')
+          );
+        }
+      }
+      \Civi::$statics[__CLASS__]['logger_file' . $comp] = $fileName;
+    }
+    return Log::singleton('file', \Civi::$statics[__CLASS__]['logger_file' . $comp]);
   }
 
   /**
index 6c1617fc74fc1b4b0fde58162f4cf5f4e5e7189c..c4d904927daa2cd93d810c7a1748497f00f2e1d4 100644 (file)
@@ -511,7 +511,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
         $params['frequency_interval'] . " " .
         $params['frequency_unit'];
       $args['amt'] = $params['amount'];
-      $args['totalbillingcycles'] = $params['installments'];
+      $args['totalbillingcycles'] = CRM_Utils_Array::value('installments', $params);
       $args['version'] = 56.0;
       $args['PROFILEREFERENCE'] = "" .
         "i=" . $params['invoiceID'] . "&m=" . $component .
@@ -562,7 +562,11 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
    * @throws \Civi\Payment\Exception\PaymentProcessorException
    */
   public function doQuery($params) {
-    if (empty($params['trxn_id'])) {
+    //CRM-18140 - trxn_id not returned for recurring paypal transaction
+    if (!empty($params['is_recur'])) {
+      return array();
+    }
+    elseif (empty($params['trxn_id'])) {
       throw new \Civi\Payment\Exception\PaymentProcessorException('transaction id not set');
     }
     $args = array(
index 463c6abeecff5a959ef467486653c2db81f3c7b7..f33d98ae196095650ee5dfd7b16c0645760704af 100644 (file)
@@ -66,7 +66,7 @@ class CRM_Core_Payment_ProcessorForm {
 
     $form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());
 
-    $form->assign('currency', $form->_values['currency']);
+    $form->assign('currency', CRM_Utils_Array::value('currency', $form->_values));
 
     // also set cancel subscription url
     if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) {
index 242fdf40748f897f2b3fa50486a076458fbfeb2b..300efaec8e979d5407d82d14e9d98bab17e5022c 100644 (file)
@@ -833,6 +833,14 @@ class CRM_Core_Permission {
         $prefix . ts('view my invoices'),
         ts('Allow users to view/ download their own invoices'),
       ),
+      'edit api keys' => array(
+        $prefix . ts('edit api keys'),
+        ts('Edit API keys'),
+      ),
+      'edit own api keys' => array(
+        $prefix . ts('edit own api keys'),
+        ts('Edit user\'s own API keys'),
+      ),
     );
 
     return $permissions;
index 16a6ef8933d91e728827171c7d3f9dfbcc3f8127..509a3ea29d55f8308f8ac27dc3cd64c3eb0781d4 100644 (file)
@@ -77,7 +77,7 @@ class CRM_Core_PseudoConstant {
    * States/provinces abbreviations
    * @var array
    */
-  private static $stateProvinceAbbreviation;
+  private static $stateProvinceAbbreviation = array();
 
   /**
    * Country.
@@ -738,22 +738,22 @@ class CRM_Core_PseudoConstant {
    *   array reference of all State/Province abbreviations.
    */
   public static function stateProvinceAbbreviation($id = FALSE, $limit = TRUE) {
-    if ($id > 1) {
-      $query = "
-SELECT abbreviation
+    if ($id && is_numeric($id)) {
+      if (!array_key_exists($id, (array) self::$stateProvinceAbbreviation)) {
+        $query = "SELECT abbreviation
 FROM   civicrm_state_province
 WHERE  id = %1";
-      $params = array(
-        1 => array(
-          $id,
-          'Integer',
-        ),
-      );
-      return CRM_Core_DAO::singleValueQuery($query, $params);
+        $params = array(
+          1 => array(
+            $id,
+            'Integer',
+          ),
+        );
+        self::$stateProvinceAbbreviation[$id] = CRM_Core_DAO::singleValueQuery($query, $params);
+      }
+      return self::$stateProvinceAbbreviation[$id];
     }
-
-    if (!self::$stateProvinceAbbreviation || !$id) {
-
+    else {
       $whereClause = FALSE;
 
       if ($limit) {
@@ -774,15 +774,6 @@ WHERE  id = %1";
       self::populate(self::$stateProvinceAbbreviation, 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', $whereClause);
     }
 
-    if ($id) {
-      if (array_key_exists($id, self::$stateProvinceAbbreviation)) {
-        return self::$stateProvinceAbbreviation[$id];
-      }
-      else {
-        $result = NULL;
-        return $result;
-      }
-    }
     return self::$stateProvinceAbbreviation;
   }
 
index b3f41b74fbf90ba8418a7b58370600f8f6844004..e835324de0a2efae63140e96294b0eefabc5a3af 100644 (file)
@@ -603,8 +603,9 @@ class CRM_Core_Resources {
         }
       }
 
+      global $tsLocale;
       // Dynamic localization script
-      $this->addScriptUrl(CRM_Utils_System::url('civicrm/ajax/l10n-js/' . $config->lcMessages, array('r' => $this->getCacheCode())), $jsWeight++, $region);
+      $this->addScriptUrl(CRM_Utils_System::url('civicrm/ajax/l10n-js/' . $tsLocale, array('r' => $this->getCacheCode())), $jsWeight++, $region);
 
       // Add global settings
       $settings = array(
@@ -752,12 +753,13 @@ class CRM_Core_Resources {
       $items[] = "js/crm.optionEdit.js";
     }
 
+    global $tsLocale;
     // Add localized jQuery UI files
-    if ($config->lcMessages && $config->lcMessages != 'en_US') {
+    if ($tsLocale && $tsLocale != 'en_US') {
       // Search for i18n file in order of specificity (try fr-CA, then fr)
-      list($lang) = explode('_', $config->lcMessages);
+      list($lang) = explode('_', $tsLocale);
       $path = "bower_components/jquery-ui/ui/i18n";
-      foreach (array(str_replace('_', '-', $config->lcMessages), $lang) as $language) {
+      foreach (array(str_replace('_', '-', $tsLocale), $lang) as $language) {
         $localizationFile = "$path/datepicker-{$language}.js";
         if ($this->getPath('civicrm', $localizationFile)) {
           $items[] = $localizationFile;
index c54b58ea881604efd8104f4e225d0270905b5d75..fd89fae817248ff2aab2e3465052e666c5fae338 100644 (file)
@@ -910,8 +910,8 @@ class CRM_Core_SelectValues {
    *
    * @return array
    */
-  public static function getSearchBuilderOperators() {
-    return array(
+  public static function getSearchBuilderOperators($fieldType = NULL) {
+    $builderOperators = array(
       '=' => '=',
       '!=' => '≠',
       '>' => '>',
@@ -928,6 +928,17 @@ class CRM_Core_SelectValues {
       'IS NULL' => ts('Is Null'),
       'IS NOT NULL' => ts('Not Null'),
     );
+    if ($fieldType) {
+      switch ($fieldType) {
+        case CRM_Utils_Type::T_STRING:
+          unset($builderOperators['>']);
+          unset($builderOperators['<']);
+          unset($builderOperators['>=']);
+          unset($builderOperators['<=']);
+          break;
+      }
+    }
+    return $builderOperators;
   }
 
   /**
index 7f1ac88b2a4110640171edbd880689b1a2b25bfc..cee3a1b9c2ee14bd6306214e1f09988e0ac9c0d4 100644 (file)
     <title>Smart Groups</title>
     <page_callback>CRM_Contact_Page_View_ContactSmartGroup</page_callback>
   </item>
-  <item>
-     <path>civicrm/contact/view/sunlight</path>
-     <title>Sunlight</title>
-     <page_callback>CRM_Contact_Page_View_Sunlight</page_callback>
-  </item>
   <item>
      <path>civicrm/contact/view/note</path>
      <path_arguments>cid=%%cid%%</path_arguments>
index 6fba6f79b9f14a3c06ae05083dd60a6fa1686475..0426c6cca654d19e97f2e729700f1f0b5fcaaf87 100644 (file)
@@ -979,11 +979,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       $$moniker = $result['values'][$cid];
     }
 
-    static $fields = array();
-    if (empty($fields)) {
-      $fields = CRM_Contact_DAO_Contact::fields();
-      CRM_Core_DAO::freeResult();
-    }
+    $fields = CRM_Contact_DAO_Contact::fields();
 
     // FIXME: there must be a better way
     foreach (array('main', 'other') as $moniker) {
@@ -1781,12 +1777,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       CRM_Core_BAO_CustomValueTable::setValues($viewOnlyCustomFields);
     }
 
-    // **** Delete other contact & update prev-next caching
-    $otherParams = array(
-      'contact_id' => $otherId,
-      'id' => $otherId,
-      'version' => 3,
-    );
     if (CRM_Core_Permission::check('merge duplicate contacts') &&
       CRM_Core_Permission::check('delete contacts')
     ) {
@@ -1796,15 +1786,13 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         CRM_Core_DAO::executeQuery($query);
       }
 
-      civicrm_api('contact', 'delete', $otherParams);
+      civicrm_api3('contact', 'delete', array('id' => $otherId));
       CRM_Core_BAO_PrevNextCache::deleteItem($otherId);
     }
     // FIXME: else part
-    /*         else { */
-
-    /*             CRM_Core_Session::setStatus( ts('Do not have sufficient permission to delete duplicate contact.') ); */
-
-    /*         } */
+    // else {
+    //  CRM_Core_Session::setStatus( ts('Do not have sufficient permission to delete duplicate contact.') );
+    // }
 
     // CRM-15681 merge sub_types
     if ($other_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['other_details'])) {
@@ -1845,6 +1833,16 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
     CRM_Utils_Hook::post('merge', 'Contact', $mainId, CRM_Core_DAO::$_nullObject);
 
+    // Create activity for merge.
+    $messageActivity = ts('Contact ID %1 has been merged and deleted.', array(1 => $otherId));
+    civicrm_api3('activity', 'create', array(
+      'subject' => $messageActivity,
+      'source_contact_id' => CRM_Core_Session::singleton()->getLoggedInContactID(),
+      'target_contact_id' => $mainId,
+      'activity_type_id' => 'Contact Merged',
+      'status_id' => 'Completed',
+    ));
+
     return TRUE;
   }
 
index 29dd6eab1b546197d05f3574049b1640c4db1e02..4905cf56e4c58fa8a636ce24b287a3e8b8ac780f 100644 (file)
@@ -283,12 +283,23 @@ class CRM_Event_BAO_Query {
               $exEventId = $val;
               $extractEventId = explode(" ", $val);
               $value = $extractEventId[2];
-              unset($query->_where[$grouping][$key]);
+              $where = $query->_where[$grouping][$key];
+            }
+            elseif (strstr($val, 'civicrm_event.id IN')) {
+              //extract the first event id if multiple events are selected
+              preg_match('/civicrm_event.id IN \(\"(\d+)/', $val, $matches);
+              $value = $matches[1];
+              $where = $query->_where[$grouping][$key];
             }
           }
-          $extractEventId = explode(" ", $exEventId);
-          $value = $extractEventId[2];
-          unset($query->_where[$grouping][$key]);
+          if ($exEventId) {
+            $extractEventId = explode(" ", $exEventId);
+            $value = $extractEventId[2];
+          }
+          elseif (!empty($matches[1])) {
+            $value = $matches[1];
+          }
+          $where = $query->_where[$grouping][$key];
         }
         $thisEventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($value, 'civicrm_event');
         if ($thisEventHasParent) {
@@ -302,7 +313,7 @@ class CRM_Event_BAO_Query {
             $value = "(" . implode(",", $allEventIds) . ")";
           }
         }
-        $query->_where[$grouping][] = "civicrm_event.id $op {$value}";
+        $query->_where[$grouping][] = "{$where} OR civicrm_event.id $op {$value}";
         $query->_qill[$grouping][] = ts('Include Repeating Events');
         $query->_tables['civicrm_event'] = $query->_whereTables['civicrm_event'] = 1;
         return;
@@ -328,12 +339,13 @@ class CRM_Event_BAO_Query {
         return;
 
       case 'participant_fee_id':
-        $feeLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $value, 'label');
-        $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel));
-        if ($value) {
-          $query->_where[$grouping][] = "civicrm_participant.fee_level LIKE '%$feeLabel%'";
-          $query->_qill[$grouping][] = ts("Fee level") . " contains $feeLabel";
+        foreach ($value as $k => &$val) {
+          $val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label');
+          $val = CRM_Core_DAO::escapeString(trim($val));
         }
+        $feeLabel = implode('|', $value);
+        $query->_where[$grouping][] = "civicrm_participant.fee_level REGEXP '{$feeLabel}'";
+        $query->_qill[$grouping][] = ts("Fee level") . " IN " . implode(', ', $value);
         $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
         return;
 
@@ -575,6 +587,7 @@ class CRM_Event_BAO_Query {
     $form->addEntityRef('event_id', ts('Event Name'), array(
         'entity' => 'event',
         'placeholder' => ts('- any -'),
+        'multiple' => 1,
         'select' => array('minimumInputLength' => 0),
       )
     );
@@ -587,12 +600,21 @@ class CRM_Event_BAO_Query {
         ),
       )
     );
-    $form->add('text', 'participant_fee_id', ts('Fee Level'), array('class' => 'big crm-ajax-select'));
+    $obj = new CRM_Report_Form_Event_ParticipantListing();
+    $form->add('select', 'participant_fee_id',
+       ts('Fee Level'),
+       $obj->getPriceLevels(),
+       FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -'))
+    );
 
     CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
 
     CRM_Core_Form_Date::buildDateRange($form, 'participant', 1, '_register_date_low', '_register_date_high', ts('From'), FALSE);
 
+    $form->addElement('hidden', 'event_date_range_error');
+    $form->addElement('hidden', 'participant_date_range_error');
+    $form->addFormRule(array('CRM_Event_BAO_Query', 'formRule'), $form);
+
     $form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', array(1 => '<em>%1</em>')));
 
     $form->addSelect('participant_status_id',
@@ -659,4 +681,37 @@ class CRM_Event_BAO_Query {
     }
   }
 
+  /**
+   * Check if the values in the date range are in correct chronological order.
+   *
+   * @todo Get this to work with CRM_Utils_Rule::validDateRange
+   *
+   * @param array $fields
+   * @param array $files
+   * @param CRM_Core_Form $form
+   *
+   * @return bool|array
+   */
+  public static function formRule($fields, $files, $form) {
+    $errors = array();
+
+    if ((empty($fields['event_start_date_low']) || empty($fields['event_end_date_high'])) && (empty($fields['participant_register_date_low']) || empty($fields['participant_register_date_high']))) {
+      return TRUE;
+    }
+    $lowDate = strtotime($fields['event_start_date_low']);
+    $highDate = strtotime($fields['event_end_date_high']);
+
+    if ($lowDate > $highDate) {
+      $errors['event_date_range_error'] = ts('Please check that your Event Date Range is in correct chronological order.');
+    }
+
+    $lowDate1 = strtotime($fields['participant_register_date_low']);
+    $highDate1 = strtotime($fields['participant_register_date_high']);
+
+    if ($lowDate1 > $highDate1) {
+      $errors['participant_date_range_error'] = ts('Please check that your Registration Date Range is in correct chronological order.');
+    }
+    return empty($errors) ? TRUE : $errors;
+  }
+
 }
index 6fbf40a32196b4ed3bd0101e24a659d847b63042..b1ba0ac0ad8dfcf6d91f5575de26486ce16cc6ed 100644 (file)
@@ -130,7 +130,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
       );
     }
 
-    $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
+    $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id'));
     $selector = new CRM_Event_Selector_Search($this->_queryParams,
       $this->_action,
       NULL,
@@ -215,9 +215,12 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
         // CRM-15379
         if (!empty($this->_formValues['participant_fee_id'])) {
           $participant_fee_id = $this->_formValues['participant_fee_id'];
-          $feeLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $participant_fee_id, 'label');
-          $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel));
-          $seatClause[] = "( participant.fee_level LIKE '%$feeLabel%' )";
+          foreach ($participant_fee_id as $k => &$val) {
+            $val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label');
+            $val = CRM_Core_DAO::escapeString(trim($val));
+          }
+          $feeLabel = implode('|', $participant_fee_id);
+          $seatClause[] = "( participant.fee_level REGEXP '{$feeLabel}' )";
         }
 
         $seatClause = implode(' AND ', $seatClause);
@@ -314,7 +317,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
 
     CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
 
-    $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
+    $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id'));
 
     $this->set('formValues', $this->_formValues);
     $this->set('queryParams', $this->_queryParams);
@@ -337,7 +340,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
       );
     }
 
-    $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
+    $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id'));
 
     $selector = new CRM_Event_Selector_Search($this->_queryParams,
       $this->_action,
index 6c607209812fdcf4338432e8e00d29146d4a5c40..c17e424ee969172c16dfd9d9bfd88610e0276b19 100644 (file)
@@ -98,6 +98,7 @@ class CRM_Export_BAO_Export {
    */
   public static function defaultReturnProperty($exportMode) {
     // hack to add default return property based on export mode
+    $property = NULL;
     if ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
       $property = 'contribution_id';
     }
@@ -119,9 +120,6 @@ class CRM_Export_BAO_Export {
     elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
       $property = 'activity_id';
     }
-    elseif ($exportMode == CRM_Export_Form_Select::CONTACT_EXPORT) {
-      $property = 'contact_id';
-    }
     return $property;
   }
 
@@ -434,7 +432,9 @@ class CRM_Export_BAO_Export {
           }
         }
       }
-      $returnProperties[self::defaultReturnProperty($exportMode)] = 1;
+      if (!empty(self::defaultReturnProperty($exportMode))) {
+        $returnProperties[self::defaultReturnProperty($exportMode)] = 1;
+      }
     }
     else {
       $primary = TRUE;
@@ -560,7 +560,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
     list($select, $from, $where, $having) = $query->query();
 
     if ($mergeSameHousehold == 1) {
-      if (!$returnProperties['id']) {
+      if (empty($returnProperties['id'])) {
         $returnProperties['id'] = 1;
       }
 
@@ -1388,7 +1388,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
             }
           }
           else {
-            $sqlColumns[$fieldName] = "$fieldName varchar(255)";
+            $sqlColumns[$fieldName] = "$fieldName text";
           }
         }
       }
index d3c36ac0a7853051b67d1242f951fc07fd20cdc2..e2c03c5c3d72ac859edaaf795a8d262369b64e45 100644 (file)
@@ -242,4 +242,13 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
     return 'csv';
   }
 
+  public function exportACCNT() {
+  }
+
+  public function exportCUST() {
+  }
+
+  public function exportTRANS() {
+  }
+
 }
index 7def4f7ab9723cb9ee12487ec24929ef1169cd23..ad97550ff89e15c265024229848d6c1164fe63ab 100644 (file)
@@ -384,6 +384,7 @@ WHERE  title = %1
       }
 
       $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
+      $params['group_type'] = CRM_Utils_Array::value('group_type', $params, array());
 
       $customFields = CRM_Core_BAO_CustomField::getFields('Group');
       $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
index ace4b5d081fee17bd671436844f21751208af8b3..9d2404d8a1770cbbe106bfba7b56c86610d39485 100644 (file)
@@ -64,7 +64,7 @@ class CRM_Group_Form_Search extends CRM_Core_Form {
       unset($groupTypes['Access Control']);
     }
 
-    $this->addCheckBox('group_type',
+    $this->addCheckBox('group_type_search',
       ts('Type'),
       $groupTypes,
       NULL, NULL, NULL, NULL, '&nbsp;&nbsp;&nbsp;'
index 52c82160b2abc9cd48a1f119abc589a7971a1e88..952496747664a14afe3765f981d18788ef66033e 100644 (file)
@@ -44,7 +44,13 @@ class CRM_Logging_Schema {
     'logging/contribute/summary',
   );
 
-  //CRM-13028 / NYSS-6933 - table => array (cols) - to be excluded from the update statement
+  /**
+   * Columns that should never be subject to logging.
+   *
+   * CRM-13028 / NYSS-6933 - table => array (cols) - to be excluded from the update statement
+   *
+   * @var array
+   */
   private $exceptions = array(
     'civicrm_job' => array('last_run'),
     'civicrm_group' => array('cache_date', 'refresh_date'),
@@ -656,9 +662,7 @@ COLS;
    * @param bool $force
    */
   public function triggerInfo(&$info, $tableName = NULL, $force = FALSE) {
-    // check if we have logging enabled
-    $config =& CRM_Core_Config::singleton();
-    if (!$config->logging) {
+    if (!CRM_Core_Config::singleton()->logging) {
       return;
     }
 
@@ -743,13 +747,11 @@ COLS;
    * Disable logging temporarily.
    *
    * This allow logging to be temporarily disabled for certain cases
-   * where we want to do a mass cleanup but dont want to bother with
-   * an audit trail
+   * where we want to do a mass cleanup but do not want to bother with
+   * an audit trail.
    */
   public static function disableLoggingForThisConnection() {
-    // do this only if logging is enabled
-    $config = CRM_Core_Config::singleton();
-    if ($config->logging) {
+    if (CRM_Core_Config::singleton()->logging) {
       CRM_Core_DAO::executeQuery('SET @civicrm_disable_logging = 1');
     }
   }
index 2cf2f04cd846e384a07b6aaf4d3008c523be57f6..56e1df0f62a2779b10012e8a6e66178f8ec5105b 100644 (file)
@@ -407,6 +407,8 @@ class CRM_Mailing_BAO_Query {
     }
 
     CRM_Core_Form_Date::buildDateRange($form, 'mailing_date', 1, '_low', '_high', ts('From'), FALSE);
+    $form->addElement('hidden', 'mailing_date_range_error');
+    $form->addFormRule(array('CRM_Mailing_BAO_Query', 'formRule'), $form);
 
     $mailingJobStatuses = array(
       '' => ts('- select -'),
@@ -494,4 +496,25 @@ class CRM_Mailing_BAO_Query {
     $query->_tables[$tableName] = $query->_whereTables[$tableName] = 1;
   }
 
+  /**
+   * Check if the values in the date range are in correct chronological order.
+   *
+   * @param array $fields
+   * @param array $files
+   * @param CRM_Core_Form $form
+   *
+   * @return bool|array
+   */
+  public static function formRule($fields, $files, $form) {
+    $errors = array();
+
+    if (empty($fields['mailing_date_high']) || empty($fields['mailing_date_low'])) {
+      return TRUE;
+    }
+
+    CRM_Utils_Rule::validDateRange($fields, 'mailing_date', $errors, ts('Mailing Date'));
+
+    return empty($errors) ? TRUE : $errors;
+  }
+
 }
index 970a14b485d5eb93e9ff5f1f58cef81c313e860a..985d731026209b6623216439c04be193b8d2cb66 100644 (file)
@@ -432,10 +432,15 @@ class CRM_Member_BAO_Query {
     $form->addElement('text', 'member_source', ts('Source'));
 
     CRM_Core_Form_Date::buildDateRange($form, 'member_join_date', 1, '_low', '_high', ts('From'), FALSE);
+    $form->addElement('hidden', 'member_join_date_range_error');
 
     CRM_Core_Form_Date::buildDateRange($form, 'member_start_date', 1, '_low', '_high', ts('From'), FALSE);
+    $form->addElement('hidden', 'member_start_date_range_error');
 
     CRM_Core_Form_Date::buildDateRange($form, 'member_end_date', 1, '_low', '_high', ts('From'), FALSE);
+    $form->addElement('hidden', 'member_end_date_range_error');
+
+    $form->addFormRule(array('CRM_Member_BAO_Query', 'formRule'), $form);
 
     $form->addYesNo('member_is_primary', ts('Primary Member?'), TRUE);
     $form->addYesNo('member_pay_later', ts('Pay Later?'), TRUE);
@@ -483,4 +488,27 @@ class CRM_Member_BAO_Query {
     }
   }
 
+  /**
+   * Custom form rules.
+   *
+   * @param array $fields
+   * @param array $files
+   * @param CRM_Core_Form $form
+   *
+   * @return bool|array
+   */
+  public static function formRule($fields, $files, $form) {
+    $errors = array();
+
+    if ((empty($fields['member_join_date_low']) || empty($fields['member_join_date_high'])) && (empty($fields['member_start_date_low']) || empty($fields['member_start_date_high'])) && (empty($fields['member_end_date_low']) || empty($fields['member_end_date_high']))) {
+      return TRUE;
+    }
+
+    CRM_Utils_Rule::validDateRange($fields, 'member_join_date', $errors, ts('Member Since'));
+    CRM_Utils_Rule::validDateRange($fields, 'member_start_date', $errors, ts('Start Date'));
+    CRM_Utils_Rule::validDateRange($fields, 'member_end_date', $errors, ts('End Date'));
+
+    return empty($errors) ? TRUE : $errors;
+  }
+
 }
index 85bcc5b15c70fb26e6dd016dd5a02685b217d4e6..fc0210d5cfacf5780dc8e994122629ce06da30ce 100644 (file)
@@ -310,21 +310,22 @@ WHERE cpse.id IS NOT NULL {$where}";
     $lineItem->label = $prevLabel;
     $lineItem->find();
     while ($lineItem->fetch()) {
-      $lineItem->label = $newLabel;
-      $lineItem->save();
+      $lineItemParams['id'] = $lineItem->id;
+      $lineItemParams['label'] = $newLabel;
+      CRM_Price_BAO_LineItem::create($lineItemParams);
+
       // update amount and fee level in civicrm_contribution and civicrm_participant
       $params = array(
         1 => array(CRM_Core_DAO::VALUE_SEPARATOR . $prevLabel . ' -', 'String'),
         2 => array(CRM_Core_DAO::VALUE_SEPARATOR . $newLabel . ' -', 'String'),
       );
+      // Update contribution
       if (!empty($lineItem->contribution_id)) {
         CRM_Core_DAO::executeQuery("UPDATE `civicrm_contribution` SET `amount_level` = REPLACE(amount_level, %1, %2) WHERE id = {$lineItem->contribution_id}", $params);
-        $participantIds = CRM_Event_BAO_Participant::getParticipantIds($lineItem->contribution_id);
-        foreach ($participantIds as $key => $id) {
-          if (!empty($id)) {
-            CRM_Core_DAO::executeQuery("UPDATE `civicrm_participant` SET `fee_level` = REPLACE(fee_level, %1, %2) WHERE id = {$id}", $params);
-          }
-        }
+      }
+      // Update participant
+      if ($lineItem->entity_table == 'civicrm_participant') {
+        CRM_Core_DAO::executeQuery("UPDATE `civicrm_participant` SET `fee_level` = REPLACE(fee_level, %1, %2) WHERE id = {$lineItem->entity_id}", $params);
       }
     }
   }
index b02055c3e750aee261fe41e7e02fad90f8ade195..35f4262f4668ab6ee48ea79132c9d96cc69172fd 100644 (file)
@@ -1444,6 +1444,12 @@ GROUP BY     mt.member_of_contact_id";
 
     $dao = CRM_Core_DAO::executeQuery($query, $params);
 
+    //CRM-18050: Check count of price set fields which has been set with auto-renew option.
+    //If price set field is already present with auto-renew option then, it will restrict for adding another price set field with auto-renew option.
+    if ($dao->N == 0) {
+      return 0;
+    }
+
     $autoRenewOption = 2;
     $priceFields = array();
     while ($dao->fetch()) {
index 84bc5ea730eeaf236f897703efb467c4a9b3e109..960b5516edf58f7910977d1c126a15b53a2ae3dc 100644 (file)
@@ -59,7 +59,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form {
 
     $components = CRM_Core_Component::getEnabledComponents();
     foreach ($components as $componentName => $componentInfo) {
-      if (CRM_Core_Permission::check("access $componentName")) {
+      $permission = sprintf("access %s", $componentName == 'CiviCase' ? "all cases and activities" : $componentName);
+      if (CRM_Core_Permission::check($permission)) {
         $accessAllowed[] = $componentInfo->componentID;
       }
     }
@@ -282,8 +283,6 @@ class CRM_Report_Form_Activity extends CRM_Report_Form {
     ) + $this->addressFields(TRUE);
 
     if ($caseEnabled && CRM_Core_Permission::check('access all cases and activities')) {
-      $this->activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
-      $this->_columns['civicrm_activity']['filters']['activity_type_id']['options'] = $this->activityTypes;
       $this->_columns['civicrm_activity']['filters']['include_case_activities'] = array(
         'name' => 'include_case_activities',
         'title' => ts('Include Case Activities'),
@@ -433,7 +432,7 @@ class CRM_Report_Form_Activity extends CRM_Report_Form {
           strstr($clause, 'civicrm_email_contact_target_email') ||
           strstr($clause, 'civicrm_phone_contact_target_phone')
         ) {
-          $this->_selectClauses[$key] = "GROUP_CONCAT($clause SEPARATOR '; ') as $clause";
+          $this->_selectClauses[$key] = "GROUP_CONCAT($clause SEPARATOR ';') as $clause";
         }
       }
     }
index c2cec5186e358b8e81fd62277c4f1fbbecc868af..7fb6b880eb03be003ca612ccf13304570a35349e 100644 (file)
@@ -125,8 +125,8 @@ class CRM_UF_Page_Field extends CRM_Core_Page {
     $isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved');
     $this->assign('isGroupReserved', $isGroupReserved);
 
-    $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
-    if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') {
+    $isMixedProfile = CRM_Core_BAO_UFField::checkProfileType($this->_gid);
+    if ($isMixedProfile) {
       $this->assign('skipCreate', TRUE);
     }
 
index 273dfab8fae523f578faad0c67565838944f0a16..aa60dd5e571cc0fd0fd05d74ad498936c8ac96b6 100644 (file)
@@ -351,10 +351,13 @@ class CRM_UF_Page_Group extends CRM_Core_Page {
       $groupTypes = self::extractGroupTypes($value['group_type']);
 
       // drop Create, Edit and View mode links if profile group_type is one of the following:
-      $groupComponents = array('Contribution', 'Membership', 'Activity', 'Participant', 'Case');
-      $componentFound = array_intersect($groupComponents, array_keys($groupTypes));
-      if (!empty($componentFound)) {
+      // Contribution, Membership, Activity, Participant, Case, Grant
+      $isMixedProfile = CRM_Core_BAO_UFField::checkProfileType($id);
+      if ($isMixedProfile) {
         $action -= CRM_Core_Action::ADD;
+        $action -= CRM_Core_Action::ADVANCED;
+        $action -= CRM_Core_Action::BASIC;
+        $action -= CRM_Core_Action::PROFILE;
       }
 
       $ufGroup[$id]['group_type'] = self::formatGroupTypes($groupTypes);
diff --git a/CRM/Upgrade/4.7.4.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.7.4.msg_template/civicrm_msg_template.tpl
new file mode 100644 (file)
index 0000000..f66b9c7
--- /dev/null
@@ -0,0 +1,16 @@
+{php}
+  $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.7.4.msg_template/message_templates';
+  $templates = array();
+  foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
+    $parts = explode('_', basename($filename, '.tpl'));
+    $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
+  }
+  $this->assign('templates', $templates);
+{/php}
+
+{foreach from=$templates item=tpl}
+  {fetch assign=content file=$tpl.filename}
+  SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
+  SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
+  UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
+{/foreach}
diff --git a/CRM/Upgrade/4.7.4.msg_template/message_templates/event_offline_receipt_html.tpl b/CRM/Upgrade/4.7.4.msg_template/message_templates/event_offline_receipt_html.tpl
new file mode 100644 (file)
index 0000000..f42bcc3
--- /dev/null
@@ -0,0 +1,527 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title></title>
+</head>
+<body>
+
+{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
+{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
+{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
+
+<center>
+ <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
+
+  <!-- BEGIN HEADER -->
+  <!-- You can add table row(s) here with logo or other header elements -->
+  <!-- END HEADER -->
+
+  <!-- BEGIN CONTENT -->
+
+  <tr>
+   <td>
+    <p>{contact.email_greeting}</p>
+
+    {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
+     <p>{$event.confirm_email_text|htmlize}</p>
+    {/if}
+
+    {if $isOnWaitlist}
+     <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
+     {if $isPrimary}
+       <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
+     {/if}
+    {elseif $isRequireApproval}
+     <p>{ts}Your registration has been submitted.{/ts}</p>
+     {if $isPrimary}
+      <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
+     {/if}
+    {elseif $is_pay_later}
+     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
+    {else}
+     <p>{ts}Please print this confirmation for your records.{/ts}</p>
+    {/if}
+
+   </td>
+  </tr>
+  <tr>
+   <td>
+    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
+     <tr>
+      <th {$headerStyle}>
+       {ts}Event Information and Location{/ts}
+      </th>
+     </tr>
+     <tr>
+      <td colspan="2" {$valueStyle}>
+       {$event.event_title}<br />
+       {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
+      </td>
+     </tr>
+
+     {if $event.participant_role neq 'Attendee' and $defaultRole}
+      <tr>
+       <td {$labelStyle}>
+        {ts}Participant Role{/ts}
+       </td>
+       <td {$valueStyle}>
+        {$event.participant_role}
+       </td>
+      </tr>
+     {/if}
+
+     {if $isShowLocation}
+      <tr>
+       <td colspan="2" {$valueStyle}>
+        {if $location.address.1.name}
+         {$location.address.1.name}<br />
+        {/if}
+        {if $location.address.1.street_address}
+         {$location.address.1.street_address}<br />
+        {/if}
+        {if $location.address.1.supplemental_address_1}
+         {$location.address.1.supplemental_address_1}<br />
+        {/if}
+        {if $location.address.1.supplemental_address_2}
+         {$location.address.1.supplemental_address_2}<br />
+        {/if}
+        {if $location.address.1.city}
+         {$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
+        {/if}
+       </td>
+      </tr>
+     {/if}
+
+     {if $location.phone.1.phone || $location.email.1.email}
+      <tr>
+       <td colspan="2" {$labelStyle}>
+        {ts}Event Contacts:{/ts}
+       </td>
+      </tr>
+      {foreach from=$location.phone item=phone}
+       {if $phone.phone}
+        <tr>
+         <td {$labelStyle}>
+          {if $phone.phone_type}
+           {$phone.phone_type_display}
+          {else}
+           {ts}Phone{/ts}
+          {/if}
+         </td>
+         <td {$valueStyle}>
+          {$phone.phone} {if $phone.phone_ext}&nbsp;{ts}ext.{/ts} {$phone.phone_ext}{/if}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+      {foreach from=$location.email item=eventEmail}
+       {if $eventEmail.email}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Email{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$eventEmail.email}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+     {/if}
+
+     {if $event.is_public}
+      <tr>
+       <td colspan="2" {$valueStyle}>
+        {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
+        <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
+       </td>
+      </tr>
+     {/if}
+
+     {if $email}
+      <tr>
+       <th {$headerStyle}>
+        {ts}Registered Email{/ts}
+       </th>
+      </tr>
+      <tr>
+       <td colspan="2" {$valueStyle}>
+        {$email}
+       </td>
+      </tr>
+     {/if}
+
+
+     {if $event.is_monetary}
+
+      <tr>
+       <th {$headerStyle}>
+        {$event.fee_label}
+       </th>
+      </tr>
+
+      {if $lineItem}
+       {foreach from=$lineItem item=value key=priceset}
+        {if $value neq 'skip'}
+         {if $isPrimary}
+          {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
+           <tr>
+            <td colspan="2" {$labelStyle}>
+             {ts 1=$priceset+1}Participant %1{/ts}
+            </td>
+           </tr>
+          {/if}
+         {/if}
+         <tr>
+          <td colspan="2" {$valueStyle}>
+           <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
+            <tr>
+             <th>{ts}Item{/ts}</th>
+             <th>{ts}Qty{/ts}</th>
+             <th>{ts}Each{/ts}</th>
+             {if $dataArray}
+              <th>{ts}SubTotal{/ts}</th>
+              <th>{ts}Tax Rate{/ts}</th>
+              <th>{ts}Tax Amount{/ts}</th>
+             {/if}
+             <th>{ts}Total{/ts}</th>
+       {if $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
+            </tr>
+            {foreach from=$value item=line}
+             <tr>
+              <td>
+        {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
+              </td>
+              <td>
+               {$line.qty}
+              </td>
+              <td>
+               {$line.unit_price|crmMoney}
+              </td>
+              {if $dataArray}
+               <td>
+                {$line.unit_price*$line.qty|crmMoney}
+               </td>
+               {if $line.tax_rate != "" || $line.tax_amount != ""}
+                <td>
+                 {$line.tax_rate|string_format:"%.2f"}%
+                </td>
+                <td>
+                 {$line.tax_amount|crmMoney}
+                </td>
+               {else}
+                <td></td>
+                <td></td>
+               {/if}
+              {/if}
+              <td>
+               {$line.line_total+$line.tax_amount|crmMoney}
+              </td>
+        {if  $pricesetFieldsCount }
+        <td>
+    {$line.participant_count}
+              </td>
+        {/if}
+             </tr>
+            {/foreach}
+           </table>
+          </td>
+         </tr>
+        {/if}
+       {/foreach}
+       {if $dataArray}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Amount Before Tax:{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$totalAmount-$totalTaxAmount|crmMoney}
+         </td>
+        </tr>
+        {foreach from=$dataArray item=value key=priceset}
+          <tr>
+           {if $priceset || $priceset == 0}
+            <td>&nbsp;{$taxTerm} {$priceset|string_format:"%.2f"}%</td>
+            <td>&nbsp;{$value|crmMoney:$currency}</td>
+           {else}
+            <td>&nbsp;{ts}No{/ts} {$taxTerm}</td>
+            <td>&nbsp;{$value|crmMoney:$currency}</td>
+           {/if}
+          </tr>
+        {/foreach}
+       {/if}
+      {/if}
+
+      {if $amount && !$lineItem}
+       {foreach from=$amount item=amnt key=level}
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          {$amnt.amount|crmMoney} {$amnt.label}
+         </td>
+        </tr>
+       {/foreach}
+      {/if}
+      {if $totalTaxAmount}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Total Tax Amount{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$totalTaxAmount|crmMoney:$currency}
+        </td>
+       </tr>
+      {/if}
+      {if $isPrimary}
+       <tr>
+        <td {$labelStyle}>
+        {if $balanceAmount}
+           {ts}Total Paid{/ts}
+        {else}
+           {ts}Total Amount{/ts}
+         {/if}
+        </td>
+        <td {$valueStyle}>
+         {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
+        </td>
+       </tr>
+      {if $balanceAmount}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Balance{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$balanceAmount|crmMoney}
+        </td>
+       </tr>
+      {/if}
+       {if $pricesetFieldsCount }
+     <tr>
+       <td {$labelStyle}>
+   {ts}Total Participants{/ts}</td>
+       <td {$valueStyle}>
+   {assign var="count" value= 0}
+         {foreach from=$lineItem item=pcount}
+         {assign var="lineItemCount" value=0}
+         {if $pcount neq 'skip'}
+           {foreach from=$pcount item=p_count}
+           {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
+           {/foreach}
+           {if $lineItemCount < 1 }
+           assign var="lineItemCount" value=1}
+           {/if}
+           {assign var="count" value=$count+$lineItemCount}
+         {/if}
+         {/foreach}
+   {$count}
+       </td>
+     </tr>
+     {/if}
+       {if $is_pay_later}
+        <tr>
+         <td colspan="2" {$labelStyle}>
+          {$pay_later_receipt}
+         </td>
+        </tr>
+       {/if}
+
+       {if $register_date}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Registration Date{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$register_date|crmDate}
+         </td>
+        </tr>
+       {/if}
+
+       {if $receive_date}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Transaction Date{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$receive_date|crmDate}
+         </td>
+        </tr>
+       {/if}
+
+       {if $financialTypeName}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Financial Type{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$financialTypeName}
+         </td>
+        </tr>
+       {/if}
+
+       {if $trxn_id}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Transaction #{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$trxn_id}
+         </td>
+        </tr>
+       {/if}
+
+       {if $paidBy}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Paid By{/ts}
+         </td>
+         <td {$valueStyle}>
+         {$paidBy}
+         </td>
+        </tr>
+       {/if}
+
+       {if $checkNumber}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Check Number{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$checkNumber}
+         </td>
+        </tr>
+       {/if}
+
+       {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
+        <tr>
+         <th {$headerStyle}>
+          {ts}Billing Name and Address{/ts}
+         </th>
+        </tr>
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          {$billingName}<br />
+          {$address|nl2br}
+         </td>
+        </tr>
+       {/if}
+
+       {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
+        <tr>
+         <th {$headerStyle}>
+          {ts}Credit Card Information{/ts}
+         </th>
+        </tr>
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          {$credit_card_type}<br />
+          {$credit_card_number}<br />
+          {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+         </td>
+        </tr>
+       {/if}
+
+      {/if}
+
+     {/if} {* End of conditional section for Paid events *}
+
+     {if $customPre}
+      <tr>
+       <th {$headerStyle}>
+        {$customPre_grouptitle}
+       </th>
+      </tr>
+      {foreach from=$customPre item=value key=customName}
+       {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+        <tr>
+         <td {$labelStyle}>
+          {$customName}
+         </td>
+         <td {$valueStyle}>
+          {$value}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+     {/if}
+
+     {if $customPost}
+      <tr>
+       <th {$headerStyle}>
+        {$customPost_grouptitle}
+       </th>
+      </tr>
+      {foreach from=$customPost item=value key=customName}
+       {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+        <tr>
+         <td {$labelStyle}>
+          {$customName}
+         </td>
+         <td {$valueStyle}>
+          {$value}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+     {/if}
+
+     {if $customProfile}
+      {foreach from=$customProfile item=value key=customName}
+       <tr>
+        <th {$headerStyle}>
+         {ts 1=$customName+1}Participant Information - Participant %1{/ts}
+        </th>
+       </tr>
+       {foreach from=$value item=val key=field}
+        {if $field eq 'additionalCustomPre' or $field eq 'additionalCustomPost'}
+         <tr>
+          <td colspan="2" {$labelStyle}>
+           {if $field eq 'additionalCustomPre'}
+            {$additionalCustomPre_grouptitle}
+           {else}
+            {$additionalCustomPost_grouptitle}
+           {/if}
+          </td>
+         </tr>
+         {foreach from=$val item=v key=f}
+          <tr>
+           <td {$labelStyle}>
+            {$f}
+           </td>
+           <td {$valueStyle}>
+            {$v}
+           </td>
+          </tr>
+         {/foreach}
+        {/if}
+       {/foreach}
+      {/foreach}
+     {/if}
+
+     {if $customGroup}
+      {foreach from=$customGroup item=value key=customName}
+       <tr>
+        <th {$headerStyle}>
+         {$customName}
+        </th>
+       </tr>
+       {foreach from=$value item=v key=n}
+        <tr>
+         <td {$labelStyle}>
+          {$n}
+         </td>
+         <td {$valueStyle}>
+          {$v}
+         </td>
+        </tr>
+       {/foreach}
+      {/foreach}
+     {/if}
+
+    </table>
+   </td>
+  </tr>
+
+ </table>
+</center>
+
+</body>
+</html>
diff --git a/CRM/Upgrade/4.7.4.msg_template/message_templates/event_offline_receipt_text.tpl b/CRM/Upgrade/4.7.4.msg_template/message_templates/event_offline_receipt_text.tpl
new file mode 100644 (file)
index 0000000..678fa7b
--- /dev/null
@@ -0,0 +1,304 @@
+{contact.email_greeting}
+{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
+{$event.confirm_email_text}
+{/if}
+
+{if $isOnWaitlist}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}You have been added to the WAIT LIST for this event.{/ts}
+
+{if $isPrimary}
+{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
+
+{/if}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{elseif $isRequireApproval}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Your registration has been submitted.{/ts}
+
+{if $isPrimary}
+{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
+
+{/if}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{elseif $is_pay_later}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$pay_later_receipt}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{else}
+
+{ts}Please print this confirmation for your records.{/ts}
+{/if}
+
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Event Information and Location{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$event.event_title}
+{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
+
+{if $event.participant_role neq 'Attendee' and $defaultRole}
+{ts}Participant Role{/ts}: {$event.participant_role}
+{/if}
+
+{if $isShowLocation}
+{if $location.address.1.name}
+
+{$location.address.1.name}
+{/if}
+{if $location.address.1.street_address}{$location.address.1.street_address}
+{/if}
+{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
+{/if}
+{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
+{/if}
+{if $location.address.1.city}{$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
+{/if}
+
+{/if}{*End of isShowLocation condition*}
+
+{if $location.phone.1.phone || $location.email.1.email}
+
+{ts}Event Contacts:{/ts}
+{foreach from=$location.phone item=phone}
+{if $phone.phone}
+
+{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if} {if $phone.phone_ext} {ts}ext.{/ts} {$phone.phone_ext}{/if}
+{/foreach}
+{foreach from=$location.email item=eventEmail}
+{if $eventEmail.email}
+
+{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
+{/if}
+
+{if $event.is_public}
+{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
+{ts}Download iCalendar File:{/ts} {$icalFeed}
+{/if}
+
+{if $email}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Registered Email{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$email}
+{/if}
+{if $event.is_monetary} {* This section for Paid events only.*}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$event.fee_label}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{if $lineItem}{foreach from=$lineItem item=value key=priceset}
+
+{if $value neq 'skip'}
+{if $isPrimary}
+{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
+{ts 1=$priceset+1}Participant %1{/ts}
+{/if}
+{/if}
+---------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{capture assign=ts_item}{ts}Item{/ts}{/capture}
+{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
+{capture assign=ts_each}{ts}Each{/ts}{/capture}
+{if $dataArray}
+{capture assign=ts_subtotal}{ts}Subtotal{/ts}{/capture}
+{capture assign=ts_taxRate}{ts}Tax Rate{/ts}{/capture}
+{capture assign=ts_taxAmount}{ts}Tax Amount{/ts}{/capture}
+{/if}
+{capture assign=ts_total}{ts}Total{/ts}{/capture}
+{capture assign=ts_participant_total}{if $pricesetFieldsCount }{ts}Total Participants{/ts}{/if}{/capture}
+{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if $dataArray} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate|string_format:"%10s"} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
+----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{foreach from=$value item=line}
+{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
+{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {if $dataArray} {$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate != "" || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if}  {/if}  {$line.line_total+$line.tax_amount|crmMoney|string_format:"%10s"} {$ts_participant_count|string_format:"%10s"}
+{/foreach}
+{/if}
+{/foreach}
+
+{if $dataArray}
+{ts}Amount before Tax{/ts}: {$totalAmount-$totalTaxAmount|crmMoney:$currency}
+
+{foreach from=$dataArray item=value key=priceset}
+{if $priceset || $priceset == 0}
+{$taxTerm} {$priceset|string_format:"%.2f"}%: {$value|crmMoney:$currency}
+{else}
+{ts}No{/ts} {$taxTerm}: {$value|crmMoney:$currency}
+{/if}
+{/foreach}
+{/if}
+{/if}
+
+{if $amount && !$lineItem}
+{foreach from=$amount item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
+{/foreach}
+{/if}
+
+{if $totalTaxAmount}
+{ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney:$currency}
+{/if}
+{if $isPrimary}
+
+{if $balanceAmount}{ts}Total Paid{/ts}{else}{ts}Total Amount{/ts}{/if}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
+
+{if $balanceAmount}
+{ts}Balance{/ts}: {$balanceAmount|crmMoney}
+{/if}
+
+{if $pricesetFieldsCount }
+      {assign var="count" value= 0}
+      {foreach from=$lineItem item=pcount}
+      {assign var="lineItemCount" value=0}
+      {if $pcount neq 'skip'}
+        {foreach from=$pcount item=p_count}
+        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
+        {/foreach}
+        {if $lineItemCount < 1 }
+        {assign var="lineItemCount" value=1}
+        {/if}
+      {assign var="count" value=$count+$lineItemCount}
+      {/if}
+      {/foreach}
+
+{ts}Total Participants{/ts}: {$count}
+{/if}
+
+{if $is_pay_later }
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$pay_later_receipt}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{/if}
+
+{if $register_date}
+{ts}Registration Date{/ts}: {$register_date|crmDate}
+{/if}
+{if $receive_date}
+{ts}Transaction Date{/ts}: {$receive_date|crmDate}
+{/if}
+{if $financialTypeName}
+{ts}Financial Type{/ts}: {$financialTypeName}
+{/if}
+{if $trxn_id}
+{ts}Transaction #{/ts}: {$trxn_id}
+{/if}
+{if $paidBy}
+{ts}Paid By{/ts}: {$paidBy}
+{/if}
+{if $checkNumber}
+{ts}Check Number{/ts}: {$checkNumber}
+{/if}
+{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Billing Name and Address{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$billingName}
+{$address}
+{/if}
+
+{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
+===========================================================
+{ts}Credit Card Information{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$credit_card_type}
+{$credit_card_number}
+{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+{/if}
+{/if}
+{/if} {* End of conditional section for Paid events *}
+
+{if $customPre}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$customPre_grouptitle}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$customPre item=value key=customName}
+{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+{$customName}: {$value}
+{/if}
+{/foreach}
+{/if}
+
+{if $customPost}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$customPost_grouptitle}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$customPost item=value key=customName}
+{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+{$customName}: {$value}
+{/if}
+{/foreach}
+{/if}
+{if $customProfile}
+
+{foreach from=$customProfile item=value key=customName}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts 1=$customName+1}Participant Information - Participant %1{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$value item=val key=field}
+{if $field eq 'additionalCustomPre' or $field eq 'additionalCustomPost' }
+{if $field eq 'additionalCustomPre' }
+----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{$additionalCustomPre_grouptitle}
+----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{else}
+----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{$additionalCustomPost_grouptitle}
+----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{/if}
+{foreach from=$val item=v key=f}
+{$f}: {$v}
+{/foreach}
+{/if}
+{/foreach}
+{/foreach}
+{/if}
+{if $customGroup}
+{foreach from=$customGroup item=value key=customName}
+=========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$customName}
+=========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$value item=v key=n}
+{$n}: {$v}
+{/foreach}
+{/foreach}
+{/if}
+
+
diff --git a/CRM/Upgrade/4.7.4.msg_template/message_templates/event_online_receipt_html.tpl b/CRM/Upgrade/4.7.4.msg_template/message_templates/event_online_receipt_html.tpl
new file mode 100644 (file)
index 0000000..90d93bb
--- /dev/null
@@ -0,0 +1,526 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title></title>
+</head>
+<body>
+
+{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
+{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
+{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
+{capture assign=tdfirstStyle}style="width: 180px; padding-bottom: 15px;"{/capture}
+{capture assign=tdStyle}style="width: 100px;"{/capture}
+{capture assign=participantTotal}style="margin: 0.5em 0 0.5em;padding: 0.5em;background-color: #999999;font-weight: bold;color: #FAFAFA;border-radius: 2px;"{/capture}
+
+
+<center>
+ <table width="700" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
+
+  <!-- BEGIN HEADER -->
+  <!-- You can add table row(s) here with logo or other header elements -->
+  <!-- END HEADER -->
+
+  <!-- BEGIN CONTENT -->
+
+  <tr>
+   <td>
+  <p>{contact.email_greeting},</p>
+
+    {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
+     <p>{$event.confirm_email_text|htmlize}</p>
+
+    {else}
+  <p>Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to <strong>{if $participant_status}{$participant_status}{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if}</strong>.</p>
+
+    {/if}
+
+    <p>
+    {if $isOnWaitlist}
+     <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
+     {if $isPrimary}
+       <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
+     {/if}
+    {elseif $isRequireApproval}
+     <p>{ts}Your registration has been submitted.{/ts}</p>
+     {if $isPrimary}
+      <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
+     {/if}
+    {elseif $is_pay_later && !$isAmountzero && !$isAdditionalParticipant}
+     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
+    {else}
+     <p>{ts}Please print this confirmation for your records.{/ts}</p>
+    {/if}
+
+   </td>
+  </tr>
+  <tr>
+   <td>
+    <table width="700" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
+     <tr>
+      <th {$headerStyle}>
+       {ts}Event Information and Location{/ts}
+      </th>
+     </tr>
+     <tr>
+      <td colspan="2" {$valueStyle}>
+       {$event.event_title}<br />
+       {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
+      </td>
+     </tr>
+
+
+     {if $conference_sessions}
+      <tr>
+       <td colspan="2" {$labelStyle}>
+  {ts}Your schedule:{/ts}
+       </td>
+      </tr>
+      <tr>
+       <td colspan="2" {$valueStyle}>
+  {assign var='group_by_day' value='NA'}
+  {foreach from=$conference_sessions item=session}
+   {if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
+    {assign var='group_by_day' value=$session.start_date}
+          <em>{$group_by_day|date_format:"%m/%d/%Y"}</em><br />
+   {/if}
+   {$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}<br />
+   {if $session.location}&nbsp;&nbsp;&nbsp;&nbsp;{$session.location}<br />{/if}
+  {/foreach}
+       </td>
+      </tr>
+     {/if}
+
+     {if $event.participant_role neq 'Attendee' and $defaultRole}
+      <tr>
+       <td {$labelStyle}>
+        {ts}Participant Role{/ts}
+       </td>
+       <td {$valueStyle}>
+        {$event.participant_role}
+       </td>
+      </tr>
+     {/if}
+
+     {if $isShowLocation}
+      <tr>
+       <td colspan="2" {$valueStyle}>
+        {if $location.address.1.name}
+         {$location.address.1.name}<br />
+        {/if}
+        {if $location.address.1.street_address}
+         {$location.address.1.street_address}<br />
+        {/if}
+        {if $location.address.1.supplemental_address_1}
+         {$location.address.1.supplemental_address_1}<br />
+        {/if}
+        {if $location.address.1.supplemental_address_2}
+         {$location.address.1.supplemental_address_2}<br />
+        {/if}
+        {if $location.address.1.city}
+         {$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
+        {/if}
+       </td>
+      </tr>
+     {/if}
+
+     {if $location.phone.1.phone || $location.email.1.email}
+      <tr>
+       <td colspan="2" {$labelStyle}>
+        {ts}Event Contacts:{/ts}
+       </td>
+      </tr>
+      {foreach from=$location.phone item=phone}
+       {if $phone.phone}
+        <tr>
+         <td {$labelStyle}>
+          {if $phone.phone_type}
+           {$phone.phone_type_display}
+          {else}
+           {ts}Phone{/ts}
+          {/if}
+         </td>
+         <td {$valueStyle}>
+          {$phone.phone} {if $phone.phone_ext}&nbsp;{ts}ext.{/ts} {$phone.phone_ext}{/if}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+      {foreach from=$location.email item=eventEmail}
+       {if $eventEmail.email}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Email{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$eventEmail.email}
+         </td>
+        </tr>
+       {/if}
+      {/foreach}
+     {/if}
+
+     {if $event.is_public}
+      <tr>
+       <td colspan="2" {$valueStyle}>
+        {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
+        <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
+       </td>
+      </tr>
+     {/if}
+
+    {if $event.is_share}
+        <tr>
+            <td colspan="2" {$valueStyle}>
+                {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=true fe=1 h=1}{/capture}
+                {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$eventUrl title=$event.title pageURL=$eventUrl}
+            </td>
+        </tr>
+    {/if}
+    {if $payer.name}
+     <tr>
+       <th {$headerStyle}>
+         {ts}You were registered by:{/ts}
+       </th>
+     </tr>
+     <tr>
+       <td colspan="2" {$valueStyle}>
+        {$payer.name}
+       </td>
+     </tr>
+    {/if}
+    {if $event.is_monetary}
+
+      <tr>
+       <th {$headerStyle}>
+        {$event.fee_label}
+       </th>
+      </tr>
+
+      {if $lineItem}
+       {foreach from=$lineItem item=value key=priceset}
+        {if $value neq 'skip'}
+         {if $isPrimary}
+          {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
+           <tr>
+            <td colspan="2" {$labelStyle}>
+             {ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
+            </td>
+           </tr>
+          {/if}
+         {/if}
+         <tr>
+          <td colspan="2" {$valueStyle}>
+           <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
+            <tr>
+             <th>{ts}Item{/ts}</th>
+             <th>{ts}Qty{/ts}</th>
+             <th>{ts}Each{/ts}</th>
+             {if $dataArray}
+              <th>{ts}SubTotal{/ts}</th>
+              <th>{ts}Tax Rate{/ts}</th>
+              <th>{ts}Tax Amount{/ts}</th>
+             {/if}
+             <th>{ts}Total{/ts}</th>
+       {if  $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
+            </tr>
+            {foreach from=$value item=line}
+             <tr>
+              <td {$tdfirstStyle}>
+              {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
+              </td>
+              <td {$tdStyle} align="middle">
+               {$line.qty}
+              </td>
+              <td {$tdStyle}>
+               {$line.unit_price|crmMoney:$currency}
+              </td>
+              {if $dataArray}
+               <td {$tdStyle}>
+                {$line.unit_price*$line.qty|crmMoney}
+               </td>
+               {if $line.tax_rate != "" || $line.tax_amount != ""}
+                <td {$tdStyle}>
+                 {$line.tax_rate|string_format:"%.2f"}%
+                </td>
+                <td {$tdStyle}>
+                 {$line.tax_amount|crmMoney}
+                </td>
+               {else}
+                <td></td>
+                <td></td>
+               {/if}
+              {/if}
+              <td {$tdStyle}>
+               {$line.line_total+$line.tax_amount|crmMoney:$currency}
+              </td>
+        {if $pricesetFieldsCount }<td {$tdStyle}>{$line.participant_count}</td> {/if}
+             </tr>
+            {/foreach}
+            {if $individual}
+              <tr {$participantTotal}>
+                <td colspan=3>{ts}Participant Total{/ts}</td>
+                <td  colspan=2>{$individual.$priceset.totalAmtWithTax-$individual.$priceset.totalTaxAmt|crmMoney}</td>
+                <td  colspan=1>{$individual.$priceset.totalTaxAmt|crmMoney}</td>
+                <td  colspan=2>{$individual.$priceset.totalAmtWithTax|crmMoney}</td>
+              </tr>
+            {/if}
+           </table>
+          </td>
+         </tr>
+        {/if}
+       {/foreach}
+       {if $dataArray}
+        <tr>
+         <td {$labelStyle}>
+          {ts} Amount Before Tax: {/ts}
+         </td>
+         <td {$valueStyle}>
+          {$totalAmount-$totalTaxAmount|crmMoney}
+         </td>
+        </tr>
+        {foreach from=$dataArray item=value key=priceset}
+         <tr>
+          {if $priceset || $priceset == 0}
+           <td>&nbsp;{$taxTerm} {$priceset|string_format:"%.2f"}%</td>
+           <td>&nbsp;{$value|crmMoney:$currency}</td>
+          {else}
+           <td>&nbsp;{ts}No{/ts} {$taxTerm}</td>
+           <td>&nbsp;{$value|crmMoney:$currency}</td>
+          {/if}
+         </tr>
+        {/foreach}
+       {/if}
+      {/if}
+
+      {if $amounts && !$lineItem}
+       {foreach from=$amounts item=amnt key=level}
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          {$amnt.amount|crmMoney:$currency} {$amnt.label}
+         </td>
+        </tr>
+       {/foreach}
+      {/if}
+
+    {if $totalTaxAmount}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Total Tax Amount{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$totalTaxAmount|crmMoney:$currency}
+        </td>
+       </tr>
+      {/if}
+      {if $isPrimary}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Total Amount{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$totalAmount|crmMoney:$currency} {if $hookDiscount.message}({$hookDiscount.message}){/if}
+        </td>
+       </tr>
+       {if $pricesetFieldsCount }
+     <tr>
+       <td {$labelStyle}>
+      {ts}Total Participants{/ts}</td>
+      <td {$valueStyle}>
+      {assign var="count" value= 0}
+      {foreach from=$lineItem item=pcount}
+      {assign var="lineItemCount" value=0}
+      {if $pcount neq 'skip'}
+        {foreach from=$pcount item=p_count}
+        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
+        {/foreach}
+      {if $lineItemCount < 1 }
+        {assign var="lineItemCount" value=1}
+      {/if}
+      {assign var="count" value=$count+$lineItemCount}
+      {/if}
+      {/foreach}
+     {$count}
+     </td> </tr>
+      {/if}
+
+       {if $register_date}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Registration Date{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$register_date|crmDate}
+         </td>
+        </tr>
+       {/if}
+
+       {if $receive_date}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Transaction Date{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$receive_date|crmDate}
+         </td>
+        </tr>
+       {/if}
+
+       {if $financialTypeName}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Financial Type{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$financialTypeName}
+         </td>
+        </tr>
+       {/if}
+
+       {if $trxn_id}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Transaction #{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$trxn_id}
+         </td>
+        </tr>
+       {/if}
+
+       {if $paidBy}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Paid By{/ts}
+         </td>
+         <td {$valueStyle}>
+         {$paidBy}
+         </td>
+        </tr>
+       {/if}
+
+       {if $checkNumber}
+        <tr>
+         <td {$labelStyle}>
+          {ts}Check Number{/ts}
+         </td>
+         <td {$valueStyle}>
+          {$checkNumber}
+         </td>
+        </tr>
+       {/if}
+
+       {if $contributeMode ne 'notify' and !$isAmountzero and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and !$isOnWaitlist and !$isRequireApproval}
+        <tr>
+         <th {$headerStyle}>
+          {ts}Billing Name and Address{/ts}
+         </th>
+        </tr>
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          {$billingName}<br />
+          {$address|nl2br}
+         </td>
+        </tr>
+       {/if}
+
+       {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
+        <tr>
+         <th {$headerStyle}>
+          {ts}Credit Card Information{/ts}
+         </th>
+        </tr>
+        <tr>
+         <td colspan="2" {$valueStyle}>
+          {$credit_card_type}<br />
+          {$credit_card_number}<br />
+          {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+         </td>
+        </tr>
+       {/if}
+
+      {/if}
+
+     {/if} {* End of conditional section for Paid events *}
+
+
+{if $customPre}
+{foreach from=$customPre item=customPr key=i}
+   <tr> <th {$headerStyle}>{$customPre_grouptitle.$i}</th></tr>
+   {foreach from=$customPr item=customValue key=customName}
+   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+     <tr>
+         <td {$labelStyle}>{$customName}</td>
+         <td {$valueStyle}>{$customValue}</td>
+     </tr>
+   {/if}
+   {/foreach}
+{/foreach}
+{/if}
+
+{if $customPost}
+{foreach from=$customPost item=customPos key=j}
+   <tr> <th {$headerStyle}>{$customPost_grouptitle.$j}</th></tr>
+   {foreach from=$customPos item=customValue key=customName}
+   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+     <tr>
+         <td {$labelStyle}>{$customName}</td>
+         <td {$valueStyle}>{$customValue}</td>
+     </tr>
+{/if}
+{/foreach}
+{/foreach}
+{/if}
+
+{if $customProfile}
+{foreach from=$customProfile.profile item=eachParticipant key=participantID}
+     <tr><th {$headerStyle}>{ts 1=$participantID+2}Participant %1{/ts} </th></tr>
+     {foreach from=$eachParticipant item=eachProfile key=pid}
+     <tr><th {$headerStyle}>{$customProfile.title.$pid}</th></tr>
+     {foreach from=$eachProfile item=val key=field}
+     <tr>{foreach from=$val item=v key=f}
+         <td {$labelStyle}>{$field}</td>
+         <td {$valueStyle}>{$v}</td>
+         {/foreach}
+     </tr>
+     {/foreach}
+{/foreach}
+{/foreach}
+{/if}
+
+    {if $customGroup}
+      {foreach from=$customGroup item=value key=customName}
+       <tr>
+        <th {$headerStyle}>
+         {$customName}
+        </th>
+       </tr>
+       {foreach from=$value item=v key=n}
+        <tr>
+         <td {$labelStyle}>
+          {$n}
+         </td>
+         <td {$valueStyle}>
+          {$v}
+         </td>
+        </tr>
+       {/foreach}
+      {/foreach}
+     {/if}
+    </table>
+    {if $event.allow_selfcancelxfer }
+     <tr>
+      <td colspan="2" {$valueStyle}>
+        {ts 1=$event.selfcancelxfer_time}You may transfer your registration to another participant or cancel your registration up to %1 hours before the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}<br />
+        {capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&pid=`$participant.id`&{contact.checksum}"  h=0 a=1 fe=1}{/capture}
+        <a href="{$selfService}">{ts}Click here to transfer or cancel your registration.{/ts}</a>
+      </td>
+     </tr>
+    {/if}
+   </td>
+  </tr>
+ </table>
+</center>
+
+</body>
+</html>
diff --git a/CRM/Upgrade/4.7.4.msg_template/message_templates/event_online_receipt_text.tpl b/CRM/Upgrade/4.7.4.msg_template/message_templates/event_online_receipt_text.tpl
new file mode 100644 (file)
index 0000000..e5a9c23
--- /dev/null
@@ -0,0 +1,311 @@
+{contact.email_greeting},
+
+{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
+{$event.confirm_email_text}
+
+{else}
+Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to {if $participant_status}{$participant_status}{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if}.
+
+{/if}
+
+{if $isOnWaitlist}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}You have been added to the WAIT LIST for this event.{/ts}
+
+{if $isPrimary}
+{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
+{/if}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{elseif $isRequireApproval}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Your registration has been submitted.{/ts}
+
+{if $isPrimary}
+{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
+
+{/if}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{elseif $is_pay_later && !$isAmountzero && !$isAdditionalParticipant}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$pay_later_receipt}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{else}
+
+{ts}Please print this confirmation for your records.{/ts}
+{/if}
+
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Event Information and Location{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$event.event_title}
+{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
+{if $conference_sessions}
+
+
+{ts}Your schedule:{/ts}
+{assign var='group_by_day' value='NA'}
+{foreach from=$conference_sessions item=session}
+{if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
+{assign var='group_by_day' value=$session.start_date}
+
+{$group_by_day|date_format:"%m/%d/%Y"}
+
+
+{/if}
+{$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}
+{if $session.location}    {$session.location}{/if}
+{/foreach}
+{/if}
+
+{if $event.participant_role neq 'Attendee' and $defaultRole}
+{ts}Participant Role{/ts}: {$event.participant_role}
+{/if}
+
+{if $isShowLocation}
+{if $location.address.1.name}
+
+{$location.address.1.name}
+{/if}
+{if $location.address.1.street_address}{$location.address.1.street_address}
+{/if}
+{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
+{/if}
+{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
+{/if}
+{if $location.address.1.city}{$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
+{/if}
+
+{/if}{*End of isShowLocation condition*}
+
+{if $location.phone.1.phone || $location.email.1.email}
+
+{ts}Event Contacts:{/ts}
+{foreach from=$location.phone item=phone}
+{if $phone.phone}
+
+{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if} {if $phone.phone_ext} {ts}ext.{/ts} {$phone.phone_ext}{/if}
+{/foreach}
+{foreach from=$location.email item=eventEmail}
+{if $eventEmail.email}
+
+{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
+{/if}
+
+{if $event.is_public}
+{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
+{ts}Download iCalendar File:{/ts} {$icalFeed}
+{/if}
+
+{if $payer.name}
+You were registered by: {$payer.name}
+{/if}
+{if $event.is_monetary} {* This section for Paid events only.*}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$event.fee_label}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{if $lineItem}{foreach from=$lineItem item=value key=priceset}
+
+{if $value neq 'skip'}
+{if $isPrimary}
+{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
+{ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
+
+{/if}
+{/if}
+-----------------------------------------------------------{if $pricesetFieldsCount }-----------------------------------------------------{/if}
+
+{capture assign=ts_item}{ts}Item{/ts}{/capture}
+{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
+{capture assign=ts_each}{ts}Each{/ts}{/capture}
+{if $dataArray}
+{capture assign=ts_subtotal}{ts}Subtotal{/ts}{/capture}
+{capture assign=ts_taxRate}{ts}Tax Rate{/ts}{/capture}
+{capture assign=ts_taxAmount}{ts}Tax Amount{/ts}{/capture}
+{/if}
+{capture assign=ts_total}{ts}Total{/ts}{/capture}
+{if $pricesetFieldsCount }{capture assign=ts_participant_total}{ts}Total Participants{/ts}{/capture}{/if}
+{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if $dataArray} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate|string_format:"%10s"} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
+-----------------------------------------------------------{if $pricesetFieldsCount }-----------------------------------------------------{/if}
+
+{foreach from=$value item=line}
+{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
+{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {if $dataArray} {$line.unit_price*$line.qty|crmMoney:$currency|string_format:"%10s"} {if $line.tax_rate != "" || $line.tax_amount != ""}  {$line.tax_rate|string_format:"%.2f"} %  {$line.tax_amount|crmMoney:$currency|string_format:"%10s"} {else}                  {/if}  {/if} {$line.line_total+$line.tax_amount|crmMoney:$currency|string_format:"%10s"}{$ts_participant_count|string_format:"%10s"}
+{/foreach}
+----------------------------------------------------------------------------------------------------------------
+{if $individual}{ts}Participant Total{/ts} {$individual.$priceset.totalAmtWithTax-$individual.$priceset.totalTaxAmt|crmMoney:$currency|string_format:"%29s"} {$individual.$priceset.totalTaxAmt|crmMoney:$currency|string_format:"%33s"} {$individual.$priceset.totalAmtWithTax|crmMoney:$currency|string_format:"%12s"}{/if}
+{/if}
+{""|string_format:"%120s"}
+{/foreach}
+{""|string_format:"%120s"}
+
+{if $dataArray}
+{ts}Amount before Tax{/ts}: {$totalAmount-$totalTaxAmount|crmMoney:$currency}
+
+{foreach from=$dataArray item=value key=priceset}
+{if $priceset || $priceset == 0}
+{$taxTerm} {$priceset|string_format:"%.2f"}%: {$value|crmMoney:$currency}
+{else}
+{ts}No{/ts} {$taxTerm}: {$value|crmMoney:$currency}
+{/if}
+{/foreach}
+{/if}
+{/if}
+
+{if $amounts && !$lineItem}
+{foreach from=$amounts item=amnt key=level}{$amnt.amount|crmMoney:$currency} {$amnt.label}
+{/foreach}
+{/if}
+
+{if $totalTaxAmount}
+{ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney:$currency}
+{/if}
+{if $isPrimary }
+
+{ts}Total Amount{/ts}: {$totalAmount|crmMoney:$currency} {if $hookDiscount.message}({$hookDiscount.message}){/if}
+
+{if $pricesetFieldsCount }
+      {assign var="count" value= 0}
+      {foreach from=$lineItem item=pcount}
+      {assign var="lineItemCount" value=0}
+      {if $pcount neq 'skip'}
+        {foreach from=$pcount item=p_count}
+        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
+        {/foreach}
+      {if $lineItemCount < 1 }
+        {assign var="lineItemCount" value=1}
+      {/if}
+      {assign var="count" value=$count+$lineItemCount}
+      {/if}
+      {/foreach}
+
+{ts}Total Participants{/ts}: {$count}
+{/if}
+
+{if $register_date}
+{ts}Registration Date{/ts}: {$register_date|crmDate}
+{/if}
+{if $receive_date}
+{ts}Transaction Date{/ts}: {$receive_date|crmDate}
+{/if}
+{if $financialTypeName}
+{ts}Financial Type{/ts}: {$financialTypeName}
+{/if}
+{if $trxn_id}
+{ts}Transaction #{/ts}: {$trxn_id}
+{/if}
+{if $paidBy}
+{ts}Paid By{/ts}: {$paidBy}
+{/if}
+{if $checkNumber}
+{ts}Check Number{/ts}: {$checkNumber}
+{/if}
+{if $contributeMode ne 'notify' and !$isAmountzero and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and !$isOnWaitlist and !$isRequireApproval}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Billing Name and Address{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$billingName}
+{$address}
+{/if}
+
+{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts}Credit Card Information{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$credit_card_type}
+{$credit_card_number}
+{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+{/if}
+{/if}
+{/if} {* End of conditional section for Paid events *}
+
+{if $customPre}
+{foreach from=$customPre item=customPr key=i}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$customPre_grouptitle.$i}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$customPr item=customValue key=customName}
+{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+ {$customName}: {$customValue}
+{/if}
+{/foreach}
+{/foreach}
+{/if}
+
+{if $customPost}
+{foreach from=$customPost item=customPos key=j}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$customPost_grouptitle.$j}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$customPos item=customValue key=customName}
+{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
+ {$customName}: {$customValue}
+{/if}
+{/foreach}
+{/foreach}
+{/if}
+{if $customProfile}
+
+{foreach from=$customProfile.profile item=eachParticipant key=participantID}
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{ts 1=$participantID+2}Participant Information - Participant %1{/ts}
+
+==========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$eachParticipant item=eachProfile key=pid}
+----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{$customProfile.title.$pid}
+----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
+
+{foreach from=$eachProfile item=val key=field}
+{foreach from=$val item=v key=f}
+{$field}: {$v}
+{/foreach}
+{/foreach}
+{/foreach}
+{/foreach}
+{/if}
+{if $customGroup}
+{foreach from=$customGroup item=value key=customName}
+=========================================================={if $pricesetFieldsCount }===================={/if}
+
+{$customName}
+=========================================================={if $pricesetFieldsCount }===================={/if}
+
+{foreach from=$value item=v key=n}
+{$n}: {$v}
+{/foreach}
+{/foreach}
+{/if}
+
+{if $event.allow_selfcancelxfer }
+{ts 1=$event.selfcancelxfer_time}You may transfer your registration to another participant or cancel your registration up to %1 hours before the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}
+   {capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&pid=`$participant.id`&{contact.checksum}"  h=0 a=1 fe=1}{/capture}
+{ts}Transfer or cancel your registration:{/ts} {$selfService}
+{/if}
index f80bb444cfd1c62927e9dcee249d62afc89e0f1c..ec6282f129ad35550547d1d6161714283ff24ae6 100644 (file)
@@ -165,6 +165,15 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
     $this->addTask('Add Index to civicrm_contribution.source', 'addIndexContributionSource');
   }
 
+  /**
+   * Upgrade function.
+   *
+   * @param string $rev
+   */
+  public function upgrade_4_7_3($rev) {
+    $this->addTask('Add Index to civicrm_contribution.total_amount', 'addIndexContributionAmount');
+  }
+
   /**
    * CRM-16354
    *
@@ -500,4 +509,21 @@ FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id";
     return TRUE;
   }
 
+  /**
+   * CRM-18124 Add index to civicrm_contribution.total_amount.
+   *
+   * Note that I made this a combined index with receive_date because the issue included
+   * both criteria and they seemed likely to be used in conjunction to me in other cases.
+   *
+   * @param \CRM_Queue_TaskContext $ctx
+   *
+   * @return bool
+   */
+  public function addIndexContributionAmount(CRM_Queue_TaskContext $ctx) {
+    CRM_Core_BAO_SchemaHandler::createIndexes(array(
+      'civicrm_contribution' => array(array('total_amount', 'receive_date')),
+    ));
+    return TRUE;
+  }
+
 }
diff --git a/CRM/Upgrade/Incremental/sql/4.7.4.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.4.mysql.tpl
new file mode 100644 (file)
index 0000000..4755bbe
--- /dev/null
@@ -0,0 +1,5 @@
+{* file to handle db changes in 4.7.4 during upgrade *}
+{include file='../CRM/Upgrade/4.7.4.msg_template/civicrm_msg_template.tpl'}
+
+-- CRM-18037 - update preferred mail format to set as default
+UPDATE `civicrm_contact` SET `preferred_mail_format` = 'Both' WHERE `preferred_mail_format` IS NULL;
index 78c4ae422c6ba8661e3bcba6e29243e38d5da277..86e2b3f451e0c223a9b921d66d0502583d751eeb 100644 (file)
@@ -33,8 +33,6 @@
  * @copyright CiviCRM LLC (c) 2004-2015
  */
 
-require_once 'tcpdf/tcpdf.php';
-
 /**
  * Class CRM_Utils_PDF_Label
  */
index fd0c8fe0e9bb38c86a4cf8e91a06a3a1bb3b7030..3d546bac7cecb69d46690aed294846b627c022af 100644 (file)
  */
 class CRM_Utils_Request {
 
+  /**
+   * Get a unique ID for the request.
+   *
+   * This unique ID is assigned to mysql when the connection is opened and is
+   * available in PHP.
+   *
+   * The intent is that it is available for logging purposes and for triggers.
+   *
+   * The resulting string is 17 characters long. This consists of 13 characters of uniqid
+   * and 4 more random characters.
+   *
+   * Uniqid is unique to the microsecond - to make it more unique we add 4 more characters
+   * but stop short of the full 23 character string that a prefix would generate.
+   *
+   * It is intended that this string will be saved to log tables so striking a balance between
+   * uniqueness and length is important. Note that I did check & lining up with byte values
+   * (e.g 16 characters) does not confer any benefits. Using a CHAR field rather than VARCHAR
+   * may improve speed, if indexed.
+   *
+   * @return string
+   */
+  public static function id() {
+    if (!isset(\Civi::$statics[__CLASS__]['id'])) {
+      \Civi::$statics[__CLASS__]['id'] = uniqid() . CRM_Utils_String::createRandom(CRM_Utils_String::ALPHANUMERIC, 4);
+    }
+    return \Civi::$statics[__CLASS__]['id'];
+  }
+
   /**
    * Retrieve a value from the request (GET/POST/REQUEST)
    *
index c3b483b9218ee0687ae2cc5088b639c7098170a4..cc7dff3e1ede1b0f01e409590d2c2519a0c24a39 100644 (file)
@@ -812,4 +812,25 @@ class CRM_Utils_Rule {
     return ($key) ? CRM_Core_Key::valid($key) : FALSE;
   }
 
+  /**
+   * Check if the values in the date range are in correct chronological order.
+   *
+   * @param array $fields
+   *  Fields of the form.
+   * @param $fieldName
+   *  Name of date range field.
+   * @param $errors
+   *  The error array.
+   * @param $title
+   *  Title of the date range to be displayed in the error message.
+   */
+  public static function validDateRange($fields, $fieldName, &$errors, $title) {
+    $lowDate = strtotime($fields[$fieldName . '_low']);
+    $highDate = strtotime($fields[$fieldName . '_high']);
+
+    if ($lowDate > $highDate) {
+      $errors[$fieldName . '_range_error'] = ts('%1: Please check that your date range is in correct chronological order.', array(1 => $title));
+    }
+  }
+
 }
diff --git a/CRM/Utils/Sunlight.php b/CRM/Utils/Sunlight.php
deleted file mode 100644 (file)
index bffa1ed..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- */
-class CRM_Utils_Sunlight {
-  static $_apiURL = 'http://api.sunlightlabs.com/';
-  static $_apiKey = NULL;
-
-  /**
-   * @param $uri
-   *
-   * @return SimpleXMLElement
-   * @throws Exception
-   */
-  public static function makeAPICall($uri) {
-    require_once 'HTTP/Request.php';
-    $params = array(
-      'method' => HTTP_REQUEST_METHOD_GET,
-      'allowRedirects' => FALSE,
-    );
-
-    $request = new HTTP_Request(self::$_apiURL . $uri, $params);
-    $result = $request->sendRequest();
-    if (PEAR::isError($result)) {
-      CRM_Core_Error::fatal($result->getMessage());
-    }
-    if ($request->getResponseCode() != 200) {
-      CRM_Core_Error::fatal(ts('Invalid response code received from Sunlight servers: %1',
-        array(1 => $request->getResponseCode())
-      ));
-    }
-    $string = $request->getResponseBody();
-    return simplexml_load_string($string);
-  }
-
-  /**
-   * @param $zipcode
-   *
-   * @return array
-   */
-  public static function getCityState($zipcode) {
-    $key = self::$_apiKey;
-    $uri = "places.getCityStateFromZip.php?zip={$zipcode}&apikey={$key}&output=xml";
-    $xml = self::makeAPICall($uri);
-
-    return array($xml->city, $xml->state);
-  }
-
-  /**
-   * @param int $peopleID
-   *
-   * @return array
-   */
-  public static function getDetailedInfo($peopleID) {
-    $key = self::$_apiKey;
-    $uri = "people.getPersonInfo.php?id={$peopleID}&apikey={$key}&output=xml";
-    $xml = self::makeAPICall($uri);
-
-    $result = array();
-    $fields = array(
-      'title' => 'title',
-      'firstname' => 'first_name',
-      'lastname' => 'last_name',
-      'gender' => 'gender',
-      'party' => 'party',
-      'congress_office' => 'address',
-      'phone' => 'phone',
-      'email' => 'email',
-      'congresspedia' => 'url',
-      'photo' => 'image_url',
-      'webform' => 'contact_url',
-    );
-
-    foreach ($fields as $old => $new) {
-      $result[$new] = (string ) $xml->$old;
-    }
-
-    $result['image_url'] = 'http://sunlightlabs.com/widgets/popuppoliticians/resources/images/' . $result['image_url'];
-
-    return $result;
-  }
-
-  /**
-   * @param $uri
-   *
-   * @return array
-   */
-  public static function getPeopleInfo($uri) {
-    $xml = self::makeAPICall($uri);
-
-    $result = array();
-    foreach ($xml->entity_id_list->entity_id as $key => $value) {
-      $result[] = self::getDetailedInfo($value);
-    }
-    return $result;
-  }
-
-  /**
-   * @param $city
-   * @param $state
-   *
-   * @return array|null
-   */
-  public static function getRepresentativeInfo($city, $state) {
-    if (!$city ||
-      !$state
-    ) {
-      return NULL;
-    }
-    $key = self::$_apiKey;
-    $city = urlencode($city);
-    $uri = "people.reps.getRepsFromCityState.php?city={$city}&state={$state}&apikey={$key}&output=xml";
-    return self::getPeopleInfo($uri);
-  }
-
-  /**
-   * @param $state
-   *
-   * @return array|null
-   */
-  public static function getSenatorInfo($state) {
-    if (!$state) {
-      return NULL;
-    }
-
-    $key = self::$_apiKey;
-    $uri = "people.sens.getSensFromState.php?state={$state}&apikey={$key}&output=xml";
-    return self::getPeopleInfo($uri);
-  }
-
-  /**
-   * @param $city
-   * @param $state
-   * @param null $zipcode
-   *
-   * @return array
-   */
-  public static function getInfo($city, $state, $zipcode = NULL) {
-    if ($zipcode) {
-      list($city, $state) = self::getCityState($zipcode);
-    }
-
-    $reps = self::getRepresentativeInfo($city, $state);
-    $sens = self::getSenatorInfo($state);
-
-    $result = array();
-    if (is_array($reps)) {
-      $result = array_merge($result, $reps);
-    }
-    if (is_array($sens)) {
-      $result = array_merge($result, $sens);
-    }
-
-    return $result;
-  }
-
-}
index 923994fbfadcb27d17f2fe703d3dc050bfbf4314..1d4e602393fb2db489ccb3dfb64435cd203e1bb5 100644 (file)
@@ -100,8 +100,12 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
     // compares $url (which is some unknown/untrusted value from a third-party dev) to the CMS's base url (which is independent of civi's url)
     // to see if the url is within our drupal dir, if it is we are able to treated it as an internal url
     if (strpos($url, $base_url) === 0) {
-      $internal = TRUE;
-      $url = trim(str_replace($base_url, '', $url), '/');
+      $file = trim(str_replace($base_url, '', $url), '/');
+      // CRM-18130: Custom CSS URL not working if aliased or rewritten
+      if (file_exists(DRUPAL_ROOT . $file)) {
+        $url = $file;
+        $internal = TRUE;
+      }
     }
     // Handle relative urls that are within the CiviCRM module directory
     elseif (strpos($url, $base) === 0) {
index b063d70adb2372deedc828a1892858db14c954c3..0176be5bbcccd5c3c5ed4a9c866aaf1a93ecbd59 100644 (file)
@@ -430,13 +430,30 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
   }
 
   /**
-   * FIXME: Do something
-   *
-   * @param \obj $user
+   * @param \string $username
+   * @param \string $password
    *
    * @return bool
    */
-  public function loadUser($user) {
+  public function loadUser($username, $password = NULL) {
+    $uid = JUserHelper::getUserId($username);
+    if (empty($uid)) {
+      return FALSE;
+    }
+    $contactID = CRM_Core_BAO_UFMatch::getContactId($uid);
+    if (!empty($password)) {
+      $instance = JFactory::getApplication('site');
+      $params = array(
+        'username' => $username,
+        'password' => $password,
+      );
+      //perform the login action
+      $instance->login($params);
+    }
+
+    $session = CRM_Core_Session::singleton();
+    $session->set('ufID', $uid);
+    $session->set('userID', $contactID);
     return TRUE;
   }
 
index 4f8c32b30583b98f1d1e6f4e43e2f40cc93641c7..355b5bc535843ba3418110557475fd52742a883e 100644 (file)
@@ -326,13 +326,24 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
   }
 
   /**
-   * FIXME: Do something
-   *
-   * @param \obj $user
+   * @param \string $user
    *
    * @return bool
    */
   public function loadUser($user) {
+    $userdata = get_user_by('login', $user);
+    if (!$userdata->data->ID) {
+      return FALSE;
+    }
+
+    $uid = $userdata->data->ID;
+    wp_set_current_user($uid);
+    $contactID = CRM_Core_BAO_UFMatch::getContactId($uid);
+
+    // lets store contact id and user id in session
+    $session = CRM_Core_Session::singleton();
+    $session->set('ufID', $uid);
+    $session->set('userID', $contactID);
     return TRUE;
   }
 
index 3dfe80f5a74322308adfed114f792b3ed120a5ce..1fb51a2a736b0438290ae229a7d60f702b3530f6 100644 (file)
@@ -61,6 +61,18 @@ function civicrm_api3_contact_create($params) {
     return $values;
   }
 
+  if (array_key_exists('api_key', $params) && !empty($params['check_permissions'])) {
+    if (CRM_Core_Permission::check('edit api keys') || CRM_Core_Permission::check('administer CiviCRM')) {
+      // OK
+    }
+    elseif ($contactID && CRM_Core_Permission::check('edit own api keys') && CRM_Core_Session::singleton()->get('userID') == $contactID) {
+      // OK
+    }
+    else {
+      throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify api key');
+    }
+  }
+
   if (!$contactID) {
     // If we get here, we're ready to create a new contact
     if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
@@ -1021,39 +1033,45 @@ function _civicrm_api3_contact_deprecation() {
  * @throws CiviCRM_API3_Exception
  */
 function civicrm_api3_contact_merge($params) {
-  $mode = CRM_Utils_Array::value('mode', $params, 'safe');
-  $autoFlip = CRM_Utils_Array::value('auto_flip', $params, TRUE);
-
-  $dupePairs = array(
-    array(
-      'srcID' => CRM_Utils_Array::value('main_id', $params),
-      'dstID' => CRM_Utils_Array::value('other_id', $params),
-    ),
-  );
-
-  if (($result = CRM_Dedupe_Merger::merge($dupePairs, array(), $mode, $autoFlip)) != FALSE) {
+  if (($result = CRM_Dedupe_Merger::merge(array(
+      array(
+        'srcID' => $params['to_remove_id'],
+        'dstID' => $params['to_keep_id'],
+      ),
+    ), array(), $params['mode'], $params['auto_flip'])) != FALSE) {
     return civicrm_api3_create_success($result, $params);
   }
   throw new CiviCRM_API3_Exception('Merge failed');
 }
 
 /**
- * Adjust metadata for contact_proximity api function.
+ * Adjust metadata for contact_merge api function.
  *
  * @param array $params
  */
 function _civicrm_api3_contact_merge_spec(&$params) {
-  $params['main_id'] = array(
+  $params['to_remove_id'] = array(
     'title' => 'ID of the contact to merge & remove',
     'description' => ts('Wow - these 2 params are the logical reverse of what I expect - but what to do?'),
     'api.required' => 1,
     'type' => CRM_Utils_Type::T_INT,
+    'api.aliases' => array('main_id'),
   );
-  $params['other_id'] = array(
+  $params['to_keep_id'] = array(
     'title' => 'ID of the contact to keep',
     'description' => ts('Wow - these 2 params are the logical reverse of what I expect - but what to do?'),
     'api.required' => 1,
     'type' => CRM_Utils_Type::T_INT,
+    'api.aliases' => array('other_id'),
+  );
+  $params['auto_flip'] = array(
+    'title' => 'Swap destination and source to retain lowest id?',
+    'api.default' => TRUE,
+  );
+  $params['mode'] = array(
+    // @todo need more detail on what this means.
+    'title' => 'Dedupe mode',
+    'api.default' => 'safe',
   );
 }
 
index 1d67d9120489a4a82753e6630724401db1e2f627..3cd75f7a66c8f870d7d9f000e4c29bcf52d1afd6 100644 (file)
@@ -131,9 +131,10 @@ function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = array()
 function civicrm_api3_create_error($msg, $data = array()) {
   $data['is_error'] = 1;
   $data['error_message'] = $msg;
+
   // we will show sql to privileged user only (not sure of a specific
   // security hole here but seems sensible - perhaps should apply to the trace as well?)
-  if (isset($data['sql']) && CRM_Core_Permission::check('Administer CiviCRM')) {
+  if (isset($data['sql']) && (CRM_Core_Permission::check('Administer CiviCRM') || CIVICRM_UF == 'UnitTests')) {
     // Isn't this redundant?
     $data['debug_information'] = $data['sql'];
   }
index a051135620f7c0e863bb042a5b174776d72ee010..dbcc5e9caf01268e28dc77b6e38b980b31863dbb 100644 (file)
@@ -269,7 +269,7 @@ class civicrm_cli {
         $this->_log(ts("Failed to login as %1. Wrong username or password.", array('1' => $this->_user)));
         return FALSE;
       }
-      if (!$cms->loadUser($this->_user)) {
+      if (($this->_config->userFramework == 'Joomla' && !$cms->loadUser($this->_user, $this->_password)) || !$cms->loadUser($this->_user)) {
         $this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
         return FALSE;
       }
index 0ab390e96a5d71351a511a13de54d142f136110a..e77c9b4b58af432f4c223656f7009427b759f044 100644 (file)
@@ -6,6 +6,7 @@
       "Civi\\": [".", "tests/phpunit/"]
     }
   },
+  "include-path": ["vendor/tecnickcom"],
   "require": {
     "dompdf/dompdf" : "0.6.*",
     "symfony/config": "~2.5.0",
@@ -15,6 +16,7 @@
     "symfony/process": "~2.5.0",
     "psr/log": "1.0.0",
     "symfony/finder": "~2.5.0",
+    "tecnickcom/tcpdf" : "6.2.*",
     "totten/ca-config": "~13.02",
     "civicrm/civicrm-cxn-rpc": "~0.15.12.04",
     "zetacomponents/base": "1.7.*",
   ],
   "scripts": {
     "post-install-cmd": [
-      "bash tools/scripts/composer/dompdf-cleanup.sh"
+      "bash tools/scripts/composer/dompdf-cleanup.sh",
+      "bash tools/scripts/composer/tcpdf-cleanup.sh"
     ],
     "post-update-cmd": [
-      "bash tools/scripts/composer/dompdf-cleanup.sh"
+      "bash tools/scripts/composer/dompdf-cleanup.sh",
+      "bash tools/scripts/composer/tcpdf-cleanup.sh"
     ]
   }
 }
index 8c125da339f8824d4211abc0b9e6018b3ba7a780..d7cd0835b369551f89cb76de995dc8f08cdcadc1 100644 (file)
@@ -4,7 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "77c841b4a3ad8ae6b4e740251e10526f",
+    "hash": "6d663f79b264d072ee699147bc572115",
+    "content-hash": "9d0da097291dbad481650b039869f719",
     "packages": [
         {
             "name": "civicrm/civicrm-cxn-rpc",
             "homepage": "http://symfony.com",
             "time": "2015-02-08 07:07:45"
         },
+        {
+            "name": "tecnickcom/tcpdf",
+            "version": "6.2.12",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/tecnickcom/TCPDF.git",
+                "reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/2f732eaa91b5665274689b1d40b285a7bacdc37f",
+                "reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "autoload": {
+                "classmap": [
+                    "fonts",
+                    "config",
+                    "include",
+                    "tcpdf.php",
+                    "tcpdf_parser.php",
+                    "tcpdf_import.php",
+                    "tcpdf_barcodes_1d.php",
+                    "tcpdf_barcodes_2d.php",
+                    "include/tcpdf_colors.php",
+                    "include/tcpdf_filters.php",
+                    "include/tcpdf_font_data.php",
+                    "include/tcpdf_fonts.php",
+                    "include/tcpdf_images.php",
+                    "include/tcpdf_static.php",
+                    "include/barcodes/datamatrix.php",
+                    "include/barcodes/pdf417.php",
+                    "include/barcodes/qrcode.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPLv3"
+            ],
+            "authors": [
+                {
+                    "name": "Nicola Asuni",
+                    "email": "info@tecnick.com",
+                    "homepage": "http://nicolaasuni.tecnick.com"
+                }
+            ],
+            "description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
+            "homepage": "http://www.tcpdf.org/",
+            "keywords": [
+                "PDFD32000-2008",
+                "TCPDF",
+                "barcodes",
+                "datamatrix",
+                "pdf",
+                "pdf417",
+                "qrcode"
+            ],
+            "time": "2015-09-12 10:08:34"
+        },
         {
             "name": "totten/ca-config",
             "version": "v13.02.0",
index b91293128e463492c9f285a636199238e754dce3..868e1db248ba5b5148661c400f6475714e5bf09f 100644 (file)
@@ -399,7 +399,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_domain` WRITE;
 /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.7.3',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.7.4',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
 /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
 UNLOCK TABLES;
 
index 7f569cf2107137517e5048d45712ce439156d0c7..a78c73333bb4a8ef92d21f0737c03cbe0a00a316 100644 (file)
@@ -39,7 +39,7 @@
       </div>
     </div><!-- /.crm-accordion-body -->
   </div><!-- /.crm-accordion-wrapper -->
-  <table class="contact-activity-selector-{$context} crm-ajax-table" data-order='[[5,"desc"]]'>
+  <table class="contact-activity-selector-{$context} crm-ajax-table" data-order='[[5,"asc"]]'>
     <thead>
     <tr>
       <th data-data="activity_type" class="crm-contact-activity-activity_type">{ts}Type{/ts}</th>
index 78501501505887dcabfe49bbf8365eb762e9def9..98f4860510adc2cf9794d5e4d0bedd0677dd1ad5 100644 (file)
         </td>
       </tr>
     </table>
+    <div id="customData"></div>
+    {*include custom data js file*}
+    {include file="CRM/common/customData.tpl"}
+    {literal}
+      <script type="text/javascript">
+        CRM.$(function($) {
+          {/literal}
+          CRM.buildCustomData( 'Survey' );
+          {literal}
+        });
+      </script>
+    {/literal}
   {/if}
   <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
index 082f1f509837377422cff7c927ce97b6a78fb21d..ee3000049c7b8e62def3f12890b14042fcb0c78c 100644 (file)
@@ -49,7 +49,7 @@
   <table class="campaigns">
     <thead>
     <tr class="columnheader">
-      <th class="hiddenElement">{ts}Campaign ID{/ts}</th>
+      <th>{ts}ID{/ts}</th>
       <th class="hiddenElement">{ts}Campaign Name{/ts}</th>
       <th>{ts}Title{/ts}</th>
       <th>{ts}Description{/ts}</th>
       "bLengthChange": false,
       "aaSorting": [],
       "aoColumns": [
-        {sClass: 'crm-campaign-id                   hiddenElement' },
+        {sClass: 'crm-campaign-id'                         },
         {sClass: 'crm-campaign-name                 hiddenElement' },
         {sClass: 'crmf-title'                              },
         {sClass: 'crmf-description'                        },
index 0856d1858da2a737d6cc7217574ff7c35076ad9d..ed581701c6df9dd2ade67348ae6ebdf2dff1487c 100644 (file)
        </td>
    </tr>
   </table>
+  <div id="customData"></div>
+  {*include custom data js file*}
+  {include file="CRM/common/customData.tpl"}
+  {literal}
+    <script type="text/javascript">
+      CRM.$(function($) {
+        {/literal}
+        CRM.buildCustomData( 'Survey' );
+        {literal}
+      });
+    </script>
+  {/literal}
 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
 
index d55abc3946164b48bd21ca0e2650fb4bfbee842c..4611605994a93bb43412668d47e305734aee95a0 100644 (file)
  +--------------------------------------------------------------------+
 *}
 <div class="crm-block crm-form-block crm-contact-merge-form-block">
-<div class="help">
-{ts}Click <strong>Merge</strong> to move data from the Duplicate Contact on the left into the Main Contact. In addition to the contact data (address, phone, email...), you may choose to move all or some of the related activity records (groups, contributions, memberships, etc.).{/ts} {help id="intro"}
-</div>
-
-<div class="message status">
-  <div class="icon inform-icon"></div>
-  <strong>{ts}WARNING: The duplicate contact record WILL BE DELETED after the merge is complete.{/ts}</strong>
-</div>
+  <div class="help">
+  {ts}Click <strong>Merge</strong> to move data from the Duplicate Contact on the left into the Main Contact. In addition to the contact data (address, phone, email...), you may choose to move all or some of the related activity records (groups, contributions, memberships, etc.).{/ts} {help id="intro"}
+  </div>
 
-{if $user}
   <div class="message status">
     <div class="icon inform-icon"></div>
-    <strong>{ts 1=$config->userFramework}WARNING: There are %1 user accounts associated with both the original and duplicate contacts. Ensure that the %1 user you want to retain is on the right - if necessary use the 'Flip between original and duplicate contacts.' option at top to swap the positions of the two records before doing the merge.
-The user record associated with the duplicate contact will not be deleted, but will be unlinked from the associated contact record (which will be deleted).
-You will need to manually delete that user (click on the link to open the %1 user account in new screen). You may need to give thought to how you handle any content or contents associated with that user.{/ts}</strong>
+    <strong>{ts}WARNING: The duplicate contact record WILL BE DELETED after the merge is complete.{/ts}</strong>
   </div>
-{/if}
 
-<div class="crm-submit-buttons">
-  {include file="CRM/common/formButtons.tpl" location="top"}
-</div>
+  {if $user}
+    <div class="message status">
+      <div class="icon inform-icon"></div>
+      <strong>{ts 1=$config->userFramework}WARNING: There are %1 user accounts associated with both the original and duplicate contacts. Ensure that the %1 user you want to retain is on the right - if necessary use the 'Flip between original and duplicate contacts.' option at top to swap the positions of the two records before doing the merge.
+  The user record associated with the duplicate contact will not be deleted, but will be unlinked from the associated contact record (which will be deleted).
+  You will need to manually delete that user (click on the link to open the %1 user account in new screen). You may need to give thought to how you handle any content or contents associated with that user.{/ts}</strong>
+    </div>
+  {/if}
+
+  <div class="crm-submit-buttons">
+    {include file="CRM/common/formButtons.tpl" location="top"}
+  </div>
 
-<div class="action-link">
-  {if $prev}<a href="{$prev}" class="crm-hover-button action-item"><i class="crm-i fa-chevron-left"></i> {ts}Previous{/ts}</a>{/if}
-  {if $next}<a href="{$next}" class="crm-hover-button action-item">{ts}Next{/ts} <i class="crm-i fa-chevron-right"></i></a>{/if}
-  <a href="{$flip}" class="action-item crm-hover-button">
-    <i class="crm-i fa-random"></i>
-    {ts}Flip between original and duplicate contacts.{/ts}
-  </a>
-</div>
+  <div class="action-link">
+    {if $prev}<a href="{$prev}" class="crm-hover-button action-item"><i class="crm-i fa-chevron-left"></i> {ts}Previous{/ts}</a>{/if}
+    {if $next}<a href="{$next}" class="crm-hover-button action-item">{ts}Next{/ts} <i class="crm-i fa-chevron-right"></i></a>{/if}
+    <a href="{$flip}" class="action-item crm-hover-button">
+      <i class="crm-i fa-random"></i>
+      {ts}Flip between original and duplicate contacts.{/ts}
+    </a>
+  </div>
 
-<div class="action-link">
-  <a href="#" class="action-item crm-hover-button crm-notDuplicate" title={ts}Mark this pair as not a duplicate.{/ts} onClick="processDupes( {$main_cid}, {$other_cid}, 'dupe-nondupe', 'merge-contact', '{if $rgid}{crmURL p="civicrm/contact/dedupefind" q="reset=1&action=update&rgid=$rgid"}{/if}' );return false;">
-    <i class="crm-i fa-times-circle"></i>
-    {ts}Mark this pair as not a duplicate.{/ts}
-  </a>
-</div>
+  <div class="action-link">
+    <a href="#" class="action-item crm-hover-button crm-notDuplicate" title={ts}Mark this pair as not a duplicate.{/ts} onClick="processDupes( {$main_cid}, {$other_cid}, 'dupe-nondupe', 'merge-contact', '{if $rgid}{crmURL p="civicrm/contact/dedupefind" q="reset=1&action=update&rgid=$rgid"}{/if}' );return false;">
+      <i class="crm-i fa-times-circle"></i>
+      {ts}Mark this pair as not a duplicate.{/ts}
+    </a>
+  </div>
 
-<div class="action-link">
-  <a href="javascript:void(0);" class="action-item crm-hover-button toggle_equal_rows">
-    <i class="crm-i fa-eye-slash"></i>
-    {ts}Show/hide rows with the same data on each contact record.{/ts}
-  </a>
-</div>
+  <div class="action-link">
+    <a href="javascript:void(0);" class="action-item crm-hover-button toggle_equal_rows">
+      <i class="crm-i fa-eye-slash"></i>
+      {ts}Show/hide rows with the same data on each contact record.{/ts}
+    </a>
+  </div>
 
-<table class="row-highlight">
-  <tr class="columnheader">
-    <th>&nbsp;</th>
-    <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name}</a> ({ts}duplicate{/ts})</th>
-    <th>{ts}Mark All{/ts}<br />=={$form.toggleSelect.html} ==&gt;</th>
-    <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name}</a></th>
-    <th width="300">Add/overwrite?</th>
-  </tr>
-
-  {crmAPI var='other_result' entity='Contact' action='get' return="modified_date" id=$other_cid}
-
-  {crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid}
-
-  <tr>
-    <td>Last modified</td>
-    <td>{$other_result.values.0.modified_date|crmDate} {if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} (Most recent) {/if}</td>
-    <td></td>
-    <td>{$main_result.values.0.modified_date|crmDate} {if $main_result.values.0.modified_date gt $other_result.values.0.modified_date} (Most recent) {/if}</td>
-    <td></td>
-  </tr>
-
-  {foreach from=$rows item=row key=field}
-
-    {if !isset($row.main) && !isset($row.other)}
-      <tr style="background-color: #fff !important; border-bottom:1px solid #ccc !important;" class="no-data">
-        <td>
-          <strong>{$row.title}</strong>
-        </td>
-    {else}
-      {if $row.main eq $row.other}
-         <tr class="merge-row-equal crm-row-ok {cycle values="odd-row,even-row"}">
-      {else}
-         <tr class="crm-row-error {cycle values="odd-row,even-row"}">
-      {/if}
-        <td>
-          {$row.title}
-        </td>
-      {/if}
+  <table class="row-highlight">
+    <tr class="columnheader">
+      <th>&nbsp;</th>
+      <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name}</a> ({ts}duplicate{/ts})</th>
+      <th>{ts}Mark All{/ts}<br />=={$form.toggleSelect.html} ==&gt;</th>
+      <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name}</a></th>
+      <th width="300">Add/overwrite?</th>
+    </tr>
 
-        {assign var=position  value=$field|strrpos:'_'}
-        {assign var=blockId   value=$field|substr:$position+1}
-        {assign var=blockName value=$field|substr:14:$position-14}
+    {crmAPI var='other_result' entity='Contact' action='get' return="modified_date" id=$other_cid}
 
-        <td>
-          {if $row.title|substr:0:7 == "Address"}<span style="white-space:pre">{else}<span>{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if}</span>
-        </td>
+    {crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid}
 
-        <td style='white-space: nowrap'>
-           {if $form.$field}=={$form.$field.html|crmAddClass:"select-row"}==&gt;{/if}
-        </td>
+    <tr>
+      <td>Last modified</td>
+      <td>{$other_result.values.0.modified_date|crmDate} {if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} (Most recent) {/if}</td>
+      <td></td>
+      <td>{$main_result.values.0.modified_date|crmDate} {if $main_result.values.0.modified_date gt $other_result.values.0.modified_date} (Most recent) {/if}</td>
+      <td></td>
+    </tr>
 
-        {* For location blocks *}
-        {if $row.title|substr:0:5 == "Email"   OR
-            $row.title|substr:0:7 == "Address" OR
-            $row.title|substr:0:2 == "IM"      OR
-            $row.title|substr:0:7 == "Website" OR
-            $row.title|substr:0:5 == "Phone"}
+    {foreach from=$rows item=row key=field}
 
+      {if !isset($row.main) && !isset($row.other)}
+        <tr style="background-color: #fff !important; border-bottom:1px solid #ccc !important;" class="no-data">
           <td>
-            {if $row.title|substr:0:7 == "Address"}<span id="main_{$blockName}_{$blockId}" style="white-space:pre">{else}<span id="main_{$blockName}_{$blockId}">{/if}{if !is_array($row.main)}{$row.main}{elseif $row.main.fileName}{$row.main.fileName}{else}{', '|implode:$row.main}{/if}</span>
+            <strong>{$row.title}</strong>
           </td>
-
+      {else}
+        {if $row.main eq $row.other}
+           <tr class="merge-row-equal crm-row-ok {cycle values="odd-row,even-row"}">
+        {else}
+           <tr class="crm-row-error {cycle values="odd-row,even-row"}">
+        {/if}
           <td>
-            {* Display location for fields with locations *}
-            {if $blockName eq 'email' || $blockName eq 'phone' || $blockName eq 'address' || $blockName eq 'im' }
-              {$form.location.$blockName.$blockId.locTypeId.html}&nbsp;
-            {/if}
-
-            {* Display other_type_id for websites, ims and phones *}
-            {if $blockName eq 'website' || $blockName eq 'im' || $blockName eq 'phone' }
-              {$form.location.$blockName.$blockId.typeTypeId.html}&nbsp;
-            {/if}
-
-            {* Display the overwrite/add/add new label *}
-            <span id="main_{$blockName}_{$blockId}_overwrite">
-              {if $row.main}
-                <span class="action_label">({ts}overwrite{/ts})</span>&nbsp;
-                 {if $blockName eq 'email' || $blockName eq 'phone' }
-                   {$form.location.$blockName.$blockId.operation.html}&nbsp;
-                 {/if}
-                 <br />
-              {else}
-                <span class="action_label">({ts}add{/ts})</span>&nbsp;
-              {/if}
-            </span>
+            {$row.title}
           </td>
+        {/if}
 
-        {* For non-location blocks *}
-        {else}
+          {assign var=position  value=$field|strrpos:'_'}
+          {assign var=blockId   value=$field|substr:$position+1}
+          {assign var=blockName value=$field|substr:14:$position-14}
 
           <td>
-            <span>
-              {if !is_array($row.main)}
-                {$row.main}
-              {elseif $row.main.fileName}
-                {$row.main.fileName}
-              {else}
-                {', '|implode:$row.main}
-              {/if}
-            </span>
+            {if $row.title|substr:0:7 == "Address"}<span style="white-space:pre">{else}<span>{/if}{if !is_array($row.other)}{$row.other}{elseif $row.other.fileName}{$row.other.fileName}{else}{', '|implode:$row.other}{/if}</span>
           </td>
 
-          <td>
-            {if isset($row.main) || isset($row.other)}
+          <td style='white-space: nowrap'>
+             {if $form.$field}=={$form.$field.html|crmAddClass:"select-row"}==&gt;{/if}
+          </td>
+
+          {* For location blocks *}
+          {if $row.title|substr:0:5 == "Email"   OR
+              $row.title|substr:0:7 == "Address" OR
+              $row.title|substr:0:2 == "IM"      OR
+              $row.title|substr:0:7 == "Website" OR
+              $row.title|substr:0:5 == "Phone"}
+
+            <td>
+              {if $row.title|substr:0:7 == "Address"}<span id="main_{$blockName}_{$blockId}" style="white-space:pre">{else}<span id="main_{$blockName}_{$blockId}">{/if}{if !is_array($row.main)}{$row.main}{elseif $row.main.fileName}{$row.main.fileName}{else}{', '|implode:$row.main}{/if}</span>
+            </td>
+
+            <td>
+              {* Display location for fields with locations *}
+              {if $blockName eq 'email' || $blockName eq 'phone' || $blockName eq 'address' || $blockName eq 'im' }
+                {$form.location.$blockName.$blockId.locTypeId.html}&nbsp;
+              {/if}
+
+              {* Display other_type_id for websites, ims and phones *}
+              {if $blockName eq 'website' || $blockName eq 'im' || $blockName eq 'phone' }
+                {$form.location.$blockName.$blockId.typeTypeId.html}&nbsp;
+              {/if}
+
+              {* Display the overwrite/add/add new label *}
+              <span id="main_{$blockName}_{$blockId}_overwrite">
+                {if $row.main}
+                  <span class="action_label">({ts}overwrite{/ts})</span>&nbsp;
+                   {if $blockName eq 'email' || $blockName eq 'phone' }
+                     {$form.location.$blockName.$blockId.operation.html}&nbsp;
+                   {/if}
+                   <br />
+                {else}
+                  <span class="action_label">({ts}add{/ts})</span>&nbsp;
+                {/if}
+              </span>
+            </td>
+
+          {* For non-location blocks *}
+          {else}
+
+            <td>
               <span>
-                {if $row.main == $row.other}
-                  <span class="action_label">({ts}match{/ts})</span><br />
-                {elseif $row.main}
-                  <span class="action_label">({ts}overwrite{/ts})</span><br />
-                 {else}
-                   <span class="action_label">({ts}add{/ts})</span>
+                {if !is_array($row.main)}
+                  {$row.main}
+                {elseif $row.main.fileName}
+                  {$row.main.fileName}
+                {else}
+                  {', '|implode:$row.main}
                 {/if}
               </span>
-            {/if}
-          </td>
+            </td>
+
+            <td>
+              {if isset($row.main) || isset($row.other)}
+                <span>
+                  {if $row.main == $row.other}
+                    <span class="action_label">({ts}match{/ts})</span><br />
+                  {elseif $row.main}
+                    <span class="action_label">({ts}overwrite{/ts})</span><br />
+                   {else}
+                     <span class="action_label">({ts}add{/ts})</span>
+                  {/if}
+                </span>
+              {/if}
+            </td>
 
-        {/if}
+          {/if}
 
-     </tr>
-  {/foreach}
+       </tr>
+    {/foreach}
 
-  {foreach from=$rel_tables item=params key=paramName}
-    {if $paramName eq 'move_rel_table_users'}
+    {foreach from=$rel_tables item=params key=paramName}
+      {if $paramName eq 'move_rel_table_users'}
+        <tr class="{cycle values="even-row,odd-row"}">
+        <td><strong>{ts}Move related...{/ts}</strong></td><td>{if $otherUfId}<a target="_blank" href="{$params.other_url}">{$otherUfName}</a></td><td style='white-space: nowrap'>=={$form.$paramName.html|crmAddClass:"select-row"}==&gt;{else}<td style='white-space: nowrap'></td>{/if}</td><td>{if $mainUfId}<a target="_blank" href="{$params.main_url}">{$mainUfName}</a>{/if}</td>
+        <td>({ts}migrate{/ts})</td>
+      </tr>
+      {else}
       <tr class="{cycle values="even-row,odd-row"}">
-      <td><strong>{ts}Move related...{/ts}</strong></td><td>{if $otherUfId}<a target="_blank" href="{$params.other_url}">{$otherUfName}</a></td><td style='white-space: nowrap'>=={$form.$paramName.html|crmAddClass:"select-row"}==&gt;{else}<td style='white-space: nowrap'></td>{/if}</td><td>{if $mainUfId}<a target="_blank" href="{$params.main_url}">{$mainUfName}</a>{/if}</td>
-      <td>({ts}migrate{/ts})</td>
-    </tr>
-    {else}
-    <tr class="{cycle values="even-row,odd-row"}">
-      <td><strong>{ts}Move related...{/ts}</strong></td><td><a href="{$params.other_url}">{$params.title}</a></td><td style='white-space: nowrap'>=={$form.$paramName.html|crmAddClass:"select-row"}==&gt;</td><td><a href="{$params.main_url}">{$params.title}</a>{if $form.operation.$paramName.add.html}&nbsp;{$form.operation.$paramName.add.html}{/if}</td>
-       <td>({ts}migrate{/ts})</td>
-    </tr>
-    {/if}
-  {/foreach}
-</table>
-<div class='form-item'>
-  <!--<p>{$form.moveBelongings.html} {$form.moveBelongings.label}</p>-->
-  <!--<p>{$form.deleteOther.html} {$form.deleteOther.label}</p>-->
-</div>
+        <td><strong>{ts}Move related...{/ts}</strong></td><td><a href="{$params.other_url}">{$params.title}</a></td><td style='white-space: nowrap'>=={$form.$paramName.html|crmAddClass:"select-row"}==&gt;</td><td><a href="{$params.main_url}">{$params.title}</a>{if $form.operation.$paramName.add.html}&nbsp;{$form.operation.$paramName.add.html}{/if}</td>
+         <td>({ts}migrate{/ts})</td>
+      </tr>
+      {/if}
+    {/foreach}
+  </table>
+  <div class='form-item'>
+    <!--<p>{$form.moveBelongings.html} {$form.moveBelongings.label}</p>-->
+    <!--<p>{$form.deleteOther.html} {$form.deleteOther.label}</p>-->
+  </div>
 
-<div class="crm-submit-buttons">
-  {include file="CRM/common/formButtons.tpl" location="bottom"}
+  <div class="crm-submit-buttons">
+    {include file="CRM/common/formButtons.tpl" location="bottom"}
+  </div>
 </div>
 
 {literal}
index 7a246032d6b9513c2bab788afb29bfa944c71a06..171ccf39668210d122ecdf14178a9c8deb858238 100644 (file)
   function handleUserInputField() {
     var row = $(this).closest('tr');
     var field = $('select[id^=mapper][id$="_1"]', row).val();
-    var op = $('select[id^=operator]', row).val();
+    var operator = $('select[id^=operator]', row);
+    var op = operator.val();
+    
+    var patt = /_1$/; // pattern to check if the change event came from field name
+    if (field !== null && patt.test(this.id)) {
+      if ($.inArray(field, CRM.searchBuilder.stringFields) >= 0) {
+        // string operators
+        buildOperator(operator, CRM.searchBuilder.stringOperators);
+      } else {
+        // general operators
+        buildOperator(operator, CRM.searchBuilder.generalOperators);
+      }
+    }
 
     // These Ops don't get any input field.
     var noFieldOps = ['', 'IS EMPTY', 'IS NOT EMPTY', 'IS NULL', 'IS NOT NULL'];
     }
   }
 
+  /**
+   * Add appropriate operator to selected field
+   * @param operator: jQuery object
+   * @param options: array
+   */
+  function buildOperator(operator, options) {
+    var selected = operator.val();
+    operator.html('');
+    $.each(options, function(value, label) {
+      operator.append('<option value="' + value + '">' + label + '</option>');
+    });
+    operator.val(selected);
+  }
+
   /**
    * Add select list if appropriate for this operation
    * @param row: jQuery object
       }
     }
     $.each(CRM.searchBuilder.fieldOptions[field], function(key, option) {
-      var selected = ($.inArray(''+option.key, options) > -1) ? 'selected="selected"' : '';
-      select.append('<option value="' + option.key + '"' + selected + '>' + option.value + '</option>');
+      var optionKey = option.key;
+      if ($.inArray(field, CRM.searchBuilder.searchByLabelFields) >= 0) {
+        optionKey = option.value;
+      }
+      var selected = ($.inArray(''+optionKey, options) > -1) ? 'selected="selected"' : '';
+      select.append('<option value="' + optionKey + '"' + selected + '>' + option.value + '</option>');
     });
     select.change();
   }
diff --git a/templates/CRM/Contact/Page/View/Sunlight.tpl b/templates/CRM/Contact/Page/View/Sunlight.tpl
deleted file mode 100644 (file)
index af04901..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
-*}
-<div id="electedOfficals" class="view-content">
-    <p></p>
-    <div class="bold">{ts}Elected Officials:{/ts} {$displayName}</div>
-    <div class="form-item">
-     {if $rowCount > 0 }
-       <table>
-       <tr class="columnheader">
-          <th>{ts}Image{/ts}</th>
-          <th>{ts}Name{/ts}</th>
-          <th>{ts}Party{/ts}</th>
-          <th>{ts}Address{/ts}</th>
-          <th>{ts}Phone{/ts}</th>
-          <th>{ts}Email{/ts}</th>
-       </tr>
-       {foreach from=$rows item=row}
-         <tr class="{cycle values="odd-row,even-row"}">
-            <td><a href="{$row.url}"><img src="{$row.image_url}"></a></td>
-            <td>{$row.title} {$row.first_name} {$row.last_name}</td>
-            <td>{$row.party}</td>
-            <td>{$row.address}</td>
-            <td>{$row.phone}</td>
-            <td>{$row.email}</td>
-         </tr>
-       {/foreach}
-       </table>
-     {else}
-     <div class="messages status no-popup">
-     <img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"> &nbsp;
-      {ts}No data available for this contact. Please check city/state/zipcode{/ts}
-     </div>
-     {/if}
-    </div>
- </p>
-</div>
index ceb19bb823fce170449fe448d92f35adafed5130..8b0322074d7bc0d960a46c757d436a109bf3eec2 100644 (file)
           <td>{$row.contact_type} &nbsp; <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
         {/if}
         <td class="crm-contribution-amount">
-          <a class="nowrap bold crm-expand-row" title="{ts}view payments{/ts}" href="{crmURL p='civicrm/payment' q="view=transaction&component=contribution&action=browse&cid=`$row.contact_id`&id=`$row.contribution_id`&selector=1"}">
-            &nbsp; {if !$row.contribution_soft_credit_amount}{$row.total_amount|crmMoney:$row.currency}{/if}
-          </a>
+          {if !$row.contribution_soft_credit_amount}
+             <a class="nowrap bold crm-expand-row" title="{ts}view payments{/ts}" href="{crmURL p='civicrm/payment' q="view=transaction&component=contribution&action=browse&cid=`$row.contact_id`&id=`$row.contribution_id`&selector=1"}">
+               &nbsp; {$row.total_amount|crmMoney:$row.currency}
+            </a>
+          {/if}
           {if $row.amount_level }<br/>({$row.amount_level}){/if}
           {if $row.contribution_recur_id}<br/>{ts}(Recurring Contribution){/ts}{/if}
         </td>
 
 {include file="CRM/common/pager.tpl" location="bottom"}
 {crmScript file='js/crm.expandRow.js'}
-
index 05af80f83d0eb1cf930764fa9e6e13d4213e5593..68c8363495b6ca46e683fc361be62157c64572e3 100644 (file)
 {if $context neq 'membership'}
     <table class="form-layout-compressed">
         <tr>
+          {if $softCreditTotals.amount}
             <th class="contriTotalLeft">{ts}Total Soft Credits{/ts} - {$softCreditTotals.amount|crmMoney:$softCreditTotals.currency}</th>
             <th class="right" width="10px"> &nbsp; </th>
             <th class="right contriTotalRight"> &nbsp; {ts}Avg Soft Credits{/ts} - {$softCreditTotals.avg|crmMoney:$softCreditTotals.currency}</th>
+          {/if}
+          {if $softCreditTotals.cancelAmount}
+            <th class="right contriTotalRight"> &nbsp; {ts}Total Cancelled Soft Credits{/ts} - {$softCreditTotals.cancelAmount|crmMoney:$softCreditTotals.currency}</th>
+          {/if}
         </tr>
     </table>
     <p></p>
index bab2fd45d647cf0ad83c0b4a4314776c16c6c46d..f714ee2a38665cc3ffd5a1e8f39190581689fa4f 100644 (file)
@@ -98,37 +98,19 @@ CRM.$(function($) {
       if (!$(this).data('select2')) {
         $(this).crmEntityRef();
       }
-      isRepeating = $(this).select2('data').extra.is_recur;
+      // allow repeat checkbox to be shown for first event selected
+      if (!$.isEmptyObject($(this).select2('data')[0])) {
+        isRepeating = $(this).select2('data')[0].extra.is_recur;
+      }
     }
     if (isRepeating) {
       $('.crm-event-form-block-event_include_repeating_events').show();
-      $('label[for=event_include_repeating_events]').html(recurringLabel.replace('%1', $(this).select2('data').label));
+      $('label[for=event_include_repeating_events]').html(recurringLabel.replace('%1', $(this).select2('data')[0].label));
     } else {
       $('.crm-event-form-block-event_include_repeating_events').hide().find('input').prop('checked', false);
     }
   }
   $('#event_id').each(toggleRecurrigCheckbox).change(toggleRecurrigCheckbox);
-
-  // FIXME: This could be much simpler as an entityRef field but the priceFieldValue api doesn't currently support the filters we need
-  $('#participant_fee_id').crmSelect2({
-    placeholder: {/literal}'{ts escape="js"}- any -{/ts}'{literal},
-    minimumInputLength: 1,
-    allowClear: true,
-    ajax: {
-      url: "{/literal}{$dataURLEventFee}{literal}",
-      data: function(term) {
-        return {term: term};
-      },
-      results: function(response) {
-        return {results: response};
-      }
-    },
-    initSelection: function(el, callback) {
-      CRM.api3('price_field_value', 'getsingle', {id: $(el).val()}).done(function(data) {
-        callback({id: data.id, text: data.label});
-      });
-    }
-  });
 });
 </script>
 {/literal}
index 9ed95d306c03a104ea7eb2151a6270cfba969993..6614b2bb94914d746ba0b1ae7f3dfcb4a386cf08 100644 (file)
@@ -43,8 +43,8 @@
       </span>
     </td>
     <td id="group_type-block">
-      {$form.group_type.label}<br />
-      {$form.group_type.html}<br />
+      {$form.group_type_search.label}<br />
+      {$form.group_type_search.html}<br />
       <span class="description font-italic">
           {ts}Filter search by group type(s).{/ts}
       </span>
         "url": {/literal}'{crmURL p="civicrm/ajax/grouplist" h=0 q="snippet=4"}'{literal},
         "data": function (d) {
 
-          var groupTypes = ($('.crm-group-search-form-block #group_type_1').prop('checked')) ? '1' : '';
+          var groupTypes = ($('.crm-group-search-form-block #group_type_search_1').prop('checked')) ? '1' : '';
           if (groupTypes) {
-            groupTypes = ($('.crm-group-search-form-block #group_type_2').prop('checked')) ? groupTypes + ',2' : groupTypes;
+            groupTypes = ($('.crm-group-search-form-block #group_type_search_2').prop('checked')) ? groupTypes + ',2' : groupTypes;
           } else {
-            groupTypes = ($('.crm-group-search-form-block #group_type_2').prop('checked')) ? '2' : '';
+            groupTypes = ($('.crm-group-search-form-block #group_type_search_2').prop('checked')) ? '2' : '';
           }
 
           var groupStatus = ($('.crm-group-search-form-block #group_status_1').prop('checked')) ? 1 : '';
                   appendHTML += '<td class="crm-group-name crmf-title crm-editable ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}' + val.title + '</td>';
                 }
                 else {
-                  appendHTML += '<td class="crm-group-name  crmf-title crm-editable ' + levelClass + '"><span class="crm-no-children"></span>' + val.title + '</td>';
+                  appendHTML += '<td class="' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span><span class="crm-group-name crmf-title crm-editable">{literal}' + val.title + '</span></td>';
                 }
                 appendHTML += '<td class="right">' + val.count + "</td>";
                 appendHTML += "<td>" + val.created_by + "</td>";
index 05ea8be0ed6c71f944b373ccb2666d704cbcb76c..3f3b07a48e26d6378c5b22e31b4a7b4de13a05db 100644 (file)
@@ -33,6 +33,7 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
 
   public function setUp() {
     parent::setUp();
+    $this->_orgContactID = $this->organizationCreate();
   }
 
   public function teardown() {
@@ -121,4 +122,218 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
     $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.');
   }
 
+  /**
+   * Set ACLs for Financial Types()
+   */
+  public function setACL() {
+    CRM_Core_BAO_Setting::setItem(array('acl_financial_type' => 1), NULL, 'contribution_invoice_settings');
+  }
+
+  /**
+   * Check method testgetAvailableFinancialTypes()
+   */
+  public function testgetAvailableFinancialTypes() {
+    $this->setACL();
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = array(
+      'view contributions of type Donation',
+      'view contributions of type Member Dues',
+    );
+    CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types);
+    $expectedResult = array(
+      1 => "Donation",
+      2 => "Member Dues",
+    );
+    $this->assertEquals($expectedResult, $types, 'Verify that only certain financial types can be retrieved');
+    CRM_Financial_BAO_FinancialType::$_availableFinancialTypes = NULL;
+    $config->userPermissionClass->permissions = array(
+      'view contributions of type Donation',
+    );
+    unset($expectedResult[2]);
+    CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types);
+    $this->assertEquals($expectedResult, $types, 'Verify that removing permission for a financial type restricts the available financial types');
+  }
+
+  /**
+   * Check method testgetAvailableMembershipTypes()
+   */
+  public function testgetAvailableMembershipTypes() {
+    // Create Membership types
+    $ids = array();
+    $params = array(
+      'name' => 'Type One',
+      'domain_id' => 1,
+      'minimum_fee' => 10,
+      'duration_unit' => 'year',
+      'member_of_contact_id' => $this->_orgContactID,
+      'period_type' => 'fixed',
+      'duration_interval' => 1,
+      'financial_type_id' => 1,
+      'visibility' => 'Public',
+      'is_active' => 1,
+    );
+
+    $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
+    // Add another
+    $params['name'] = 'Type Two';
+    $params['financial_type_id'] = 2;
+    $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
+
+    $this->setACL();
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = array(
+      'view contributions of type Donation',
+      'view contributions of type Member Dues',
+    );
+    CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($types);
+    $expectedResult = array(
+      1 => "Type One",
+      2 => "Type Two",
+    );
+    $this->assertEquals($expectedResult, $types, 'Verify that only certain membership types can be retrieved');
+    $config->userPermissionClass->permissions = array(
+      'view contributions of type Donation',
+    );
+    unset($expectedResult[2]);
+    CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($types);
+    $this->assertEquals($expectedResult, $types, 'Verify that removing permission for a financial type restricts the available membership types');
+  }
+
+  /**
+   * Check method testpermissionedFinancialTypes()
+   */
+  public function testpermissionedFinancialTypes() {
+    // First get all core permissions
+    $permissions = $checkPerms = CRM_Core_Permission::getCorePermissions();
+    $this->setACL();
+    CRM_Financial_BAO_FinancialType::permissionedFinancialTypes($permissions, TRUE);
+    $financialTypes = CRM_Contribute_PseudoConstant::financialType();
+    $prefix = ts('CiviCRM') . ': ';
+    $actions = array('add', 'view', 'edit', 'delete');
+    foreach ($financialTypes as $id => $type) {
+      foreach ($actions as $action) {
+        $checkPerms[$action . ' contributions of type ' . $type] = array(
+          $prefix . ts($action . ' contributions of type ') . $type,
+          ts(ucfirst($action) . ' contributions of type ') . $type,
+        );
+      }
+    }
+    $checkPerms['administer CiviCRM Financial Types'] = array(
+      $prefix . ts('administer CiviCRM Financial Types'),
+      ts('Administer access to Financial Types'),
+    );
+    $this->assertEquals($permissions, $checkPerms, 'Verify that permissions for each financial type have been added');
+  }
+
+  /**
+   * Check method testcheckPermissionedLineItems()
+   */
+  public function testcheckPermissionedLineItems() {
+    $contactId = Contact::createIndividual();
+    $paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 4);
+    $paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
+    $paramsSet['is_active'] = TRUE;
+    $paramsSet['financial_type_id'] = 1;
+    $paramsSet['extends'] = 1;
+
+    $priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
+    $priceSetId = $priceset->id;
+
+    //Checking for priceset added in the table.
+    $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title',
+      'id', $paramsSet['title'], 'Check DB for created priceset'
+    );
+    $paramsField = array(
+      'label' => 'Price Field',
+      'name' => CRM_Utils_String::titleToVar('Price Field'),
+      'html_type' => 'CheckBox',
+      'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'),
+      'option_value' => array('1' => 100, '2' => 200),
+      'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'),
+      'option_weight' => array('1' => 1, '2' => 2),
+      'option_amount' => array('1' => 100, '2' => 200),
+      'is_display_amounts' => 1,
+      'weight' => 1,
+      'options_per_line' => 1,
+      'is_active' => array('1' => 1, '2' => 1),
+      'price_set_id' => $priceset->id,
+      'is_enter_qty' => 1,
+      'financial_type_id' => 1,
+    );
+    $priceField = CRM_Price_BAO_PriceField::create($paramsField);
+    $priceFields = $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $priceField->id));
+    $contributionParams = array(
+      'total_amount' => 300,
+      'currency' => 'USD',
+      'contact_id' => $contactId,
+      'financial_type_id' => 1,
+      'contribution_status_id' => 1,
+    );
+
+    foreach ($priceFields['values'] as $key => $priceField) {
+      $lineItems[1][$key] = array(
+        'price_field_id' => $priceField['price_field_id'],
+        'price_field_value_id' => $priceField['id'],
+        'label' => $priceField['label'],
+        'field_title' => $priceField['label'],
+        'qty' => 1,
+        'unit_price' => $priceField['amount'],
+        'line_total' => $priceField['amount'],
+        'financial_type_id' => $priceField['financial_type_id'],
+      );
+    }
+    $contributionParams['line_item'] = $lineItems;
+    $contributions = CRM_Contribute_BAO_Contribution::create($contributionParams);
+    CRM_Financial_BAO_FinancialType::$_statusACLFt = array();
+    $this->setACL();
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = array(
+      'view contributions of type Member Dues',
+    );
+
+    try {
+      $error = CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributions->id, 'view');
+      $this->fail("Missed expected exception");
+    }
+    catch (Exception $e) {
+      $this->assertEquals("A fatal error was triggered: You do not have permission to access this page.", $e->getMessage());
+    }
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = array(
+      'view contributions of type Donation',
+    );
+    $perm = CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributions->id, 'view');
+    $this->assertEquals($perm, TRUE, 'Verify that lineitems now have permission.');
+  }
+
+  /**
+   * Check method testisACLFinancialTypeStatus()
+   */
+  public function testisACLFinancialTypeStatus() {
+    $isACL = CRM_Core_BAO_Setting::getItem(NULL, 'contribution_invoice_settings');
+    $this->assertEquals(array_search('acl_financial_type', $isACL), NULL);
+    $this->setACL();
+    $isACL = CRM_Core_BAO_Setting::getItem(NULL, 'contribution_invoice_settings');
+    $this->assertEquals($isACL, array('acl_financial_type' => 1));
+  }
+
+  /**
+   * Check method testisACLFinancialTypeStatus()
+   */
+  public function testbuildPermissionedClause() {
+    $this->setACL();
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = array(
+      'view contributions of type Donation',
+      'view contributions of type Member Dues',
+    );
+    CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
+    $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,2)');
+    $config->userPermissionClass->permissions[] = 'view contributions of type Event Fee';
+    $whereClause = NULL;
+    CRM_Financial_BAO_FinancialType::$_availableFinancialTypes = array();
+    CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
+    $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,4,2)');
+  }
+
 }
index c92568aeb02d973ef74e2d373c846947c44e706b..429a762274cce5986b4d1de3610166dc187b0e67 100644 (file)
@@ -379,8 +379,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    * database population.
    */
   public function createDomainContacts() {
-    $default_domain_contact = $this->organizationCreate();
-    $second_domain_contact = $this->organizationCreate();
+    $this->organizationCreate();
+    $this->organizationCreate(array('organization_name' => 'Second Domain'));
   }
 
   /**
index 2a7b1d56d0580573d5edc348a39cb30b25b8665d..1e8e46ec9aadc821a1c84a2a6e6edddf57c85aed 100644 (file)
@@ -1342,4 +1342,40 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase {
     $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));
   }
 
+  public function testOnBehalfSetDefaults() {
+    $this->webtestLogin();
+    $hash = substr(sha1(rand()), 0, 7);
+    $pageTitle = 'Donate Online ' . $hash;
+    $rand = 2 * rand(2, 50);
+
+    // go to the New Contribution Page page
+    $this->openCiviPage('admin/contribute', 'action=add&reset=1');
+
+    // fill in step 1 (Title and Settings)
+    $this->type('title', $pageTitle);
+
+    //to select financial type
+    $this->select('financial_type_id', "label=Donation");
+    $this->clickLink('_qf_Settings_next');
+
+    $this->click('link=Profiles');
+    $this->waitForElementPresent('_qf_Custom_next-bottom');
+    $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', "value=1");
+    $this->click('_qf_Custom_next-bottom');
+    $this->waitForElementPresent('_qf_Custom_next-bottom');
+
+    $this->click('link=Title');
+    $this->waitForElementPresent('_qf_Settings_next');
+    $this->click('is_organization');
+    $this->clickLink('_qf_Settings_next');
+    $this->waitForElementPresent('_qf_Settings_next');
+    $this->click('is_organization');
+    $this->clickLink('_qf_Settings_next');
+    $this->waitForElementPresent('_qf_Settings_next');
+    $this->click('is_organization');
+    $this->waitForElementPresent("xpath=//*[@id='select2-chosen-2']");
+    $sel = $this->getText("xpath=//*[@id='select2-chosen-2']");
+    $this->assertEquals($sel, 'On Behalf Of Organization');
+  }
+
 }
index cd942a1064e1e1b3d1843b2ef617a155e4b3e68a..27611c362dc9ad9cd8cd3bd5e48867581333182d 100644 (file)
@@ -312,18 +312,20 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
       'details' => 'a test activity',
       'status_id' => 1,
       'activity_type_id' => 29,
-      'priority_id' => 1,
     );
 
     $result = $this->callAPISuccess('activity', 'create', $params);
 
-    $result = $this->callAPISuccess('activity', 'get', array('id' => $result['id']));
-    $this->assertEquals($result['values'][$result['id']]['duration'], 120);
-    $this->assertEquals($result['values'][$result['id']]['subject'], 'Make-it-Happen Meeting');
-    $this->assertEquals($result['values'][$result['id']]['activity_date_time'], '2011-03-16 00:00:00');
-    $this->assertEquals($result['values'][$result['id']]['location'], 'Pennsylvania');
-    $this->assertEquals($result['values'][$result['id']]['details'], 'a test activity');
-    $this->assertEquals($result['values'][$result['id']]['status_id'], 1);
+    $result = $this->callAPISuccess('activity', 'getsingle', array('id' => $result['id']));
+    $this->assertEquals($result['duration'], 120);
+    $this->assertEquals($result['subject'], 'Make-it-Happen Meeting');
+    $this->assertEquals($result['activity_date_time'], '2011-03-16 00:00:00');
+    $this->assertEquals($result['location'], 'Pennsylvania');
+    $this->assertEquals($result['details'], 'a test activity');
+    $this->assertEquals($result['status_id'], 1);
+
+    $priorities = $this->callAPISuccess('activity', 'getoptions', array('field' => 'priority_id'));
+    $this->assertEquals($result['priority_id'], array_search('Normal', $priorities['values']));
   }
 
   /**
index 809bf568d5041a084bce65b84e814a314228bd2e..4e9599f02256de5ab2b2dccd186205b7749789dd 100644 (file)
@@ -69,9 +69,9 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    * @throws \Exception
    */
   public function tearDown() {
+    $this->callAPISuccess('Setting', 'create', array('includeOrderByClause' => TRUE));
     // truncate a few tables
     $tablesToTruncate = array(
-      'civicrm_contact',
       'civicrm_email',
       'civicrm_contribution',
       'civicrm_line_item',
@@ -80,9 +80,13 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'civicrm_uf_match',
       'civicrm_phone',
       'civicrm_address',
+      'civicrm_acl_contact_cache',
+      'civicrm_activity_contact',
+      'civicrm_activity',
     );
 
     $this->quickCleanup($tablesToTruncate, TRUE);
+    parent::tearDown();
   }
 
   /**
@@ -222,7 +226,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
 
     $contact = $this->callAPISuccess('contact', 'create', $params);
 
-    $this->assertEquals(1, $contact['id']);
+    $this->assertEquals(3, $contact['id']);
     $email = $this->callAPISuccess('email', 'get', array('contact_id' => $contact['id']));
     $this->assertEquals(1, $email['count']);
     $this->assertEquals('man3@yahoo.com', $email['values'][$email['id']]['email']);
@@ -242,8 +246,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'last_name' => 'xyz1',
     );
 
-    $contact = $this->callAPISuccess('contact', 'create', $params);
-    $this->assertEquals(1, $contact['id']);
+    $this->callAPISuccess('contact', 'create', $params);
   }
 
   /**
@@ -324,8 +327,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'household_name' => 'The abc Household',
       'contact_type' => 'Household',
     );
-    $contact = $this->callAPISuccess('contact', 'create', $params);
-    $this->assertEquals(1, $contact['id']);
+    $this->callAPISuccess('contact', 'create', $params);
   }
 
   /**
@@ -339,8 +341,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'organization_name' => 'The abc Organization',
       'contact_type' => 'Organization',
     );
-    $contact = $this->callAPISuccess('contact', 'create', $params);
-    $this->assertEquals(1, $contact['id']);
+    $this->callAPISuccess('contact', 'create', $params);
   }
 
   /**
@@ -621,6 +622,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'return.first_name' => 1,
       'sequential' => 1,
       'rowCount' => 1,
+      'contact_type' => 'Individual',
     ));
 
     $this->assertEquals('abc1', $result['values'][0]['first_name']);
@@ -670,24 +672,29 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $params['is_deleted'] = 1;
     $params['last_name'] = 'bcd';
     $contact2 = $this->callAPISuccess('contact', 'create', $params);
-    $countActive = $this->callAPISuccess('contact', 'getcount', array('showAll' => 'active'));
-    $countAll = $this->callAPISuccess('contact', 'getcount', array('showAll' => 'all'));
-    $countTrash = $this->callAPISuccess('contact', 'getcount', array('showAll' => 'trash'));
-    $countDefault = $this->callAPISuccess('contact', 'getcount', array());
+    $countActive = $this->callAPISuccess('contact', 'getcount', array(
+      'showAll' => 'active',
+      'contact_type' => 'Individual',
+    ));
+    $countAll = $this->callAPISuccess('contact', 'getcount', array('showAll' => 'all', 'contact_type' => 'Individual'));
+    $countTrash = $this->callAPISuccess('contact', 'getcount', array('showAll' => 'trash', 'contact_type' => 'Individual'));
+    $countDefault = $this->callAPISuccess('contact', 'getcount', array('contact_type' => 'Individual'));
     $countDeleted = $this->callAPISuccess('contact', 'getcount', array(
+      'contact_type' => 'Individual',
       'contact_is_deleted' => 1,
     ));
     $countNotDeleted = $this->callAPISuccess('contact', 'getcount', array(
       'contact_is_deleted' => 0,
+      'contact_type' => 'Individual',
     ));
     $this->callAPISuccess('contact', 'delete', array('id' => $contact1['id']));
     $this->callAPISuccess('contact', 'delete', array('id' => $contact2['id']));
-    $this->assertEquals(1, $countNotDeleted, 'contact_is_deleted => 0 is respected in line ' . __LINE__);
+    $this->assertEquals(1, $countNotDeleted, 'contact_is_deleted => 0 is respected');
     $this->assertEquals(1, $countActive);
     $this->assertEquals(1, $countTrash);
     $this->assertEquals(2, $countAll);
     $this->assertEquals(1, $countDeleted);
-    $this->assertEquals(1, $countDefault, 'Only active by default in line ' . __LINE__);
+    $this->assertEquals(1, $countDefault, 'Only active by default in line');
   }
 
   /**
@@ -702,15 +709,17 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     ));
     $result = $this->callAPISuccess($this->_entity, 'getvalue', array(
       'return' => 'first_name',
+      'contact_type' => 'Individual',
       'options' => array(
         'limit' => 1,
         'sort' => 'first_name',
       ),
     ));
-    $this->assertEquals('abc1', $result, 'in line' . __LINE__);
+    $this->assertEquals('abc1', $result);
 
     $result = $this->callAPISuccess($this->_entity, 'getvalue', array(
       'return' => 'first_name',
+      'contact_type' => 'Individual',
       'options' => array(
         'limit' => 1,
         'sort' => 'first_name DESC',
@@ -967,7 +976,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
 
     $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__, $description, $subFile);
 
-    $this->assertEquals(1, $result['id']);
     // checking child function result not covered in callAPIAndDocument
     $this->assertAPISuccess($result['values'][$result['id']]['api.website.create']);
     $this->assertEquals("http://chained.org", $result['values'][$result['id']]['api.website.create.2']['values'][0]['url']);
@@ -1014,7 +1022,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $subfile = "ChainTwoWebsitesSyntax2";
     $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
 
-    $this->assertEquals(1, $result['id']);
     // the callAndDocument doesn't check the chained call
     $this->assertEquals(0, $result['values'][$result['id']]['api.website.create'][0]['is_error']);
     $this->assertEquals("http://chained.org", $result['values'][$result['id']]['api.website.create'][1]['values'][0]['url']);
@@ -1107,7 +1114,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     );
 
     $contact = $this->callAPISuccess('contact', 'create', $params);
-    $this->assertEquals(1, $contact['id']);
 
     $this->callAPISuccess('contact', 'delete', $contact);
   }
@@ -1135,8 +1141,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     );
     $result = $this->callAPISuccess('contact', 'create', $params);
 
-    $this->assertEquals(1, $result['id']);
-
     $this->callAPISuccess('contact', 'delete', array('id' => $result['id']));
   }
 
@@ -1199,8 +1203,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
 
     $contact = $this->callAPISuccess('contact', 'create', $params);
 
-    $this->assertEquals(1, $contact['id']);
-
     $this->callAPISuccess('contact', 'delete', $contact);
   }
 
@@ -1537,16 +1539,12 @@ class api_v3_ContactTest extends CiviUnitTestCase {
 
     $contact = $this->callAPISuccess('contact', 'create', $params);
 
-    $this->assertEquals(1, $contact['id']);
-
     $params = array(
       'email' => 'man2@yahoo.com',
     );
     $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__);
-    $this->assertEquals(1, $result['values'][1]['contact_id']);
-    $this->assertEquals('man2@yahoo.com', $result['values'][1]['email']);
+    $this->assertEquals('man2@yahoo.com', $result['values'][$result['id']]['email']);
 
-    // delete the contact
     $this->callAPISuccess('contact', 'delete', $contact);
   }
 
@@ -1868,7 +1866,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $this->callAPISuccess('contact', 'delete', $result);
     $this->customGroupDelete($ids['custom_group_id']);
     $this->customGroupDelete($moreIDs['custom_group_id']);
-    $this->assertEquals(1, $result['id']);
     $this->assertEquals(0, $result['values'][$result['id']]['api.website.get']['is_error']);
     $this->assertEquals("http://civicrm.org", $result['values'][$result['id']]['api.website.get']['values'][0]['url']);
   }
@@ -1968,7 +1965,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'api.Membership.getCount' => array(),
     );
     $result = $this->callAPIAndDocument('Contact', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
-    $this->assertEquals(1, $result['id']);
     $this->assertEquals(2, $result['values'][$result['id']]['api.Contribution.getCount']);
     $this->assertEquals(0, $result['values'][$result['id']]['api.Note.get']['is_error']);
     $this->assertEquals("http://civicrm.org", $result['values'][$result['id']]['api.website.getValue']);
@@ -2054,7 +2050,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $this->customGroupDelete($ids['custom_group_id']);
     $this->customGroupDelete($moreIDs['custom_group_id']);
     $this->customGroupDelete($andMoreIDs['custom_group_id']);
-    $this->assertEquals(1, $result['id']);
     $this->assertEquals(0, $result['values'][$result['id']]['api.CustomValue.get']['is_error']);
     $this->assertEquals('http://civicrm.org', $result['values'][$result['id']]['api.website.getValue']);
   }
@@ -2314,7 +2309,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    */
   public function testGetQuickEmail() {
     $this->getQuickSearchSampleData();
-    $userID = $this->createLoggedInUser();
+    $loggedInContactID = $this->createLoggedInUser();
     $result = $this->callAPISuccess('contact', 'getquick', array(
       'name' => 'c',
     ));
@@ -2323,8 +2318,10 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'C Bobby, Bobby',
       'E Bobby, Bobby :: bob@bobby.com',
       'H Bobby, Bobby :: bob@h.com',
+      'Second Domain',
+      $this->callAPISuccessGetValue('Contact', array('id' => $loggedInContactID, 'return' => 'last_name')) . ', Logged In :: anthony_anderson@civicrm.org',
     );
-    $this->assertEquals(5, $result['count']);
+    $this->assertEquals(6, $result['count']);
     foreach ($expectedData as $index => $value) {
       $this->assertEquals($value, $result['values'][$index]['data']);
     }
@@ -2350,7 +2347,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    */
   public function testGetQuickEmailACL() {
     $this->getQuickSearchSampleData();
-    $userID = $this->createLoggedInUser();
+    $loggedInContactID = $this->createLoggedInUser();
     CRM_Core_Config::singleton()->userPermissionClass->permissions = array();
     $result = $this->callAPISuccess('contact', 'getquick', array(
       'name' => 'c',
@@ -2358,16 +2355,19 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $this->assertEquals(0, $result['count']);
 
     $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereNoBobH'));
-    CRM_Contact_BAO_Contact_Permission::cache($userID, CRM_Core_Permission::VIEW, TRUE);
+    CRM_Contact_BAO_Contact_Permission::cache($loggedInContactID, CRM_Core_Permission::VIEW, TRUE);
     $result = $this->callAPISuccess('contact', 'getquick', array(
       'name' => 'c',
     ));
-    // Without the acl it would be 5 like the previous email getquick test.
-    $this->assertEquals(4, $result['count']);
+
+    // Without the acl it would be 6 like the previous email getquick test.
+    $this->assertEquals(5, $result['count']);
     $expectedData = array(
       'Bob, Bob :: bob@bob.com',
       'C Bobby, Bobby',
       'E Bobby, Bobby :: bob@bobby.com',
+      'Second Domain',
+      $this->callAPISuccessGetValue('Contact', array('id' => $loggedInContactID, 'return' => 'last_name')) . ', Logged In :: anthony_anderson@civicrm.org',
     );
     foreach ($expectedData as $index => $value) {
       $this->assertEquals($value, $result['values'][$index]['data']);
@@ -2398,16 +2398,17 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    * Test that getquick returns contacts with an exact first name match first.
    */
   public function testGetQuickID() {
+    $max = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_contact");
     $this->getQuickSearchSampleData();
     $result = $this->callAPISuccess('contact', 'getquick', array(
-      'name' => 2,
+      'name' => $max + 2,
       'field_name' => 'id',
       'table_name' => 'cc',
     ));
     $this->assertEquals(1, $result['count']);
     $this->assertEquals('A Bobby, Bobby', $result['values'][0]['sort_name']);
     $result = $this->callAPISuccess('contact', 'getquick', array(
-      'name' => 2,
+      'name' => $max + 2,
       'field_name' => 'contact_id',
       'table_name' => 'cc',
     ));
@@ -2833,13 +2834,44 @@ class api_v3_ContactTest extends CiviUnitTestCase {
 
   /**
    * Test merging 2 contacts.
+   *
+   * Someone kindly bequethed us the legacy of mixed up use of main_id & other_id
+   * in the params for contact.merge api.
+   *
+   * This test protects that legacy.
    */
-  public function testMerge() {
+  public function testMergeBizzareOldParams() {
+    $this->createLoggedInUser();
     $otherContact = $this->callAPISuccess('contact', 'create', $this->_params);
     $mainContact = $this->callAPISuccess('contact', 'create', $this->_params);
-    $this->callAPISuccess('contact', 'merge', array('main_id' => $mainContact['id'], 'other_id' => $otherContact['id']));
+    $this->callAPISuccess('contact', 'merge', array(
+      'main_id' => $mainContact['id'],
+      'other_id' => $otherContact['id'],
+    ));
     $contacts = $this->callAPISuccess('contact', 'get', $this->_params);
     $this->assertEquals($otherContact['id'], $contacts['id']);
+  }
+
+  /**
+   * Test merging 2 contacts.
+   */
+  public function testMerge() {
+    $this->createLoggedInUser();
+    $otherContact = $this->callAPISuccess('contact', 'create', $this->_params);
+    $retainedContact = $this->callAPISuccess('contact', 'create', $this->_params);
+    $this->callAPISuccess('contact', 'merge', array(
+      'to_keep_id' => $retainedContact['id'],
+      'to_remove_id' => $otherContact['id'],
+      'auto_flip' => FALSE,
+    ));
+
+    $contacts = $this->callAPISuccess('contact', 'get', $this->_params);
+    $this->assertEquals($retainedContact['id'], $contacts['id']);
+    $activity = $this->callAPISuccess('Activity', 'getsingle', array(
+      'target_contact_id' => $retainedContact['id'],
+      'activity_type_id' => 'Contact Merged',
+    ));
+    $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($activity['activity_date_time'])));
 
   }
 
index a374f8f8eeed790b13e5c33677e73b8db7f8df45..d5d97da0c9a6c286e55f14d0dd4c7aed16ab61c2 100644 (file)
@@ -1578,8 +1578,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $this->callAPISuccess('contribution', 'completetransaction', array(
       'id' => $contribution['id'],
     ));
-    $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'sequential' => 1));
-    $this->assertEquals('Completed', $contribution['values'][0]['contribution_status']);
+    $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id']));
+    $this->assertEquals('Completed', $contribution['contribution_status']);
+    $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($contribution['receipt_date'])));
     $mut->checkMailLog(array(
       'Receipt - Contribution',
       'Please print this confirmation for your records.',
index e53a967b7dd048a828f177b613dde7fe47f1c74d..20dc98e5f6daefefb8f55effd3abc354294a94df 100644 (file)
@@ -407,6 +407,20 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
     array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'access CiviCRM', 'edit contributions');
     $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__, __FILE__, 'Update Payment', 'UpdatePayment');
 
+    // Check for proportional cancelled payment against lineitems.
+    $minParams = array(
+      'entity_table' => 'civicrm_financial_item',
+      'financial_trxn_id' => $payment['id'] - 1,
+    );
+
+    $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $minParams);
+    $amounts = array(-33.33, -16.67);
+
+    foreach ($eft['values'] as $value) {
+      $this->assertEquals($value['amount'], array_pop($amounts));
+    }
+
+    // Check for proportional updated payment against lineitems.
     $params = array(
       'entity_table' => 'civicrm_financial_item',
       'financial_trxn_id' => $payment['id'],
diff --git a/tools/scripts/composer/tcpdf-cleanup.sh b/tools/scripts/composer/tcpdf-cleanup.sh
new file mode 100755 (executable)
index 0000000..0ef06ca
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+## Cleanup the vendor tree. The main issue here is that civi Civi is
+## deployed as a module inside a CMS, so all its source-code gets published.
+## Some libraries distribute admin tools and sample files which should not
+## be published.
+##
+## This script should be idempotent -- if you rerun it several times, it
+## should always produce the same post-condition.
+
+##############################################################################
+## usage: safe_delete <relpath...>
+function safe_delete() {
+  for file in "$@" ; do
+    if [ -z "$file" ]; then
+      echo "Skip: empty file name"
+    elif [ -e "$file" ]; then
+      rm -rf "$file"
+    fi
+  done
+}
+
+##############################################################################
+## Remove example/CLI scripts. They're not needed and increase the attack-surface.
+safe_delete vendor/tecnickcom/tcpdf/examples
+safe_delete vendor/tecnickcom/tcpdf/tools
+
+## Remove all fonts not included before CRM-18098.
+safe_delete vendor/tecnickcom/tcpdf/fonts/a*
+safe_delete vendor/tecnickcom/tcpdf/fonts/ci*
+safe_delete vendor/tecnickcom/tcpdf/fonts/courierb*
+safe_delete vendor/tecnickcom/tcpdf/fonts/courieri*
+safe_delete vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33
+safe_delete vendor/tecnickcom/tcpdf/fonts/dejavusansb*
+safe_delete vendor/tecnickcom/tcpdf/fonts/dejavusansc*
+safe_delete vendor/tecnickcom/tcpdf/fonts/dejavusanse*
+safe_delete vendor/tecnickcom/tcpdf/fonts/dejavusansi*
+safe_delete vendor/tecnickcom/tcpdf/fonts/dejavusansm*
+safe_delete vendor/tecnickcom/tcpdf/fonts/dejavuserif*
+safe_delete vendor/tecnickcom/tcpdf/fonts/free*
+safe_delete vendor/tecnickcom/tcpdf/fonts/helveticab*
+safe_delete vendor/tecnickcom/tcpdf/fonts/helveticai*
+safe_delete vendor/tecnickcom/tcpdf/fonts/k*
+safe_delete vendor/tecnickcom/tcpdf/fonts/m*
+safe_delete vendor/tecnickcom/tcpdf/fonts/p*
+safe_delete vendor/tecnickcom/tcpdf/fonts/s*
+safe_delete vendor/tecnickcom/tcpdf/fonts/u*
+safe_delete vendor/tecnickcom/tcpdf/fonts/z*
index a8887503db68213f4cfb5181c7205f79ae486858..60e46f41e6165478264616065845ae17845e7792 100644 (file)
      <type>Text</type>
    </html>
   </field>
+  <index>
+    <name>index_total_amount_receive_date</name>
+    <fieldName>total_amount</fieldName>
+    <fieldName>receive_date</fieldName>
+    <add>4.7</add>
+  </index>
   <field>
     <name>fee_amount</name>
     <type>decimal</type>
index dd90fb5edae868608e91b559155e4a775367a0cf..2c7723c9014a35e043d71d42a7fff88387f9bbd1 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
 <version>
-  <version_no>4.7.3</version_no>
+  <version_no>4.7.4</version_no>
 </version>