Merge remote-tracking branch 'upstream/4.6' into 4.6-master-2015-08-31-12-20-39
authorKurund Jalmi <kurund@yahoo.com>
Mon, 31 Aug 2015 19:23:15 +0000 (12:23 -0700)
committerKurund Jalmi <kurund@yahoo.com>
Mon, 31 Aug 2015 19:23:15 +0000 (12:23 -0700)
Conflicts:
CRM/Activity/BAO/Query.php
CRM/Campaign/BAO/Query.php
CRM/Contribute/BAO/Query.php
CRM/Event/BAO/Query.php
CRM/Member/BAO/Query.php
CRM/Pledge/BAO/Query.php
CRM/Report/Form/Contribute/Summary.php
sql/civicrm_generated.mysql
xml/version.xml

18 files changed:
CRM/ACL/API.php
CRM/Contact/Form/Task/EmailCommon.php
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/ContributionPage/Widget.php
CRM/Core/BAO/ActionSchedule.php
CRM/Event/BAO/Participant.php
CRM/Event/Form/Registration.php
CRM/Pledge/Form/Pledge.php
CRM/Report/Form.php
CRM/Report/Form/Contribute/Summary.php
CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl [new file with mode: 0644]
CRM/Utils/System/Base.php
templates/CRM/Admin/Page/APIExplorer.js
templates/CRM/Contact/Form/Task/EmailCommon.js
templates/CRM/Contribute/Form/AdditionalInfo/Payment.tpl
templates/CRM/Contribute/Page/Widget.tpl
templates/CRM/Event/Page/DashBoard.tpl
tests/phpunit/api/v3/ACLPermissionTest.php

index 3674629ec4132275a2f98a411593bf7006a943be..569f9db53547823bf13a89485cf430e284192d6e 100644 (file)
@@ -118,21 +118,12 @@ class CRM_ACL_API {
       return $deleteClause;
     }
 
-    $user = CRM_Core_Session::getLoggedInContactID();
-    if ($contactID == NULL) {
-      $contactID = $user ? $user : 0;
-    }
-
-    // Check if contact has permissions on self
-    if ($user && $contactID == $user) {
-      if (CRM_Core_Permission::check('edit my contact') ||
-        ($type == self::VIEW && CRM_Core_Permission::check('view my contact'))
-      ) {
-        return ' ( 1 ) ';
-      }
+    if (!$contactID) {
+      $contactID = CRM_Core_Session::getLoggedInContactID();
     }
+    $contactID = (int) $contactID;
 
-    return implode(' AND ',
+    $where = implode(' AND ',
       array(
         CRM_ACL_BAO_ACL::whereClause($type,
           $tables,
@@ -142,6 +133,14 @@ class CRM_ACL_API {
         $deleteClause,
       )
     );
+
+    // Add permission on self
+    if ($contactID && (CRM_Core_Permission::check('edit my contact') ||
+      $type == self::VIEW && CRM_Core_Permission::check('view my contact'))
+    ) {
+      $where = "contact_a.id = $contactID OR ($where)";
+    }
+    return $where;
   }
 
   /**
index 421dd51c59964102ce29e719cdedcc83de8dfc8a..539a51e561e6cdca842dbafa7de97e9605d06d7d 100644 (file)
@@ -359,7 +359,7 @@ class CRM_Contact_Form_Task_EmailCommon {
     }
 
     $form->addFormRule(array('CRM_Contact_Form_Task_EmailCommon', 'formRule'), $form);
-    CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js');
+    CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js', 0, 'html-header');
   }
 
   /**
index 98316e268023094630b2f57b8ebbdfaee5890350..a66f2e1cd82e68dd5ef5a38ddd43bc262998435b 100644 (file)
@@ -421,7 +421,7 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
     //only valid processors get display to user
 
     if ($this->_mode) {
-      $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('supportsFutureRecurStartDate')));
+      $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('FutureRecurStartDate')));
       $this->_paymentProcessors = $this->getValidProcessors();
       if (!isset($this->_paymentProcessor['id'])) {
         // if the payment processor isn't set yet (as indicated by the presence of an id,) we'll grab the first one which should be the default
index 9ed2d26353445d3e2c7e43eaca7f3557e348382d..08a1b23ebcdf30bb452a3ec56a948fe0e2cdea0a 100644 (file)
@@ -93,7 +93,7 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co
         ts('Progress Bar Color'),
         'text',
         FALSE,
-        '#FFFFFF',
+        '#2786C2',
       ),
       'color_main_text' => array(
         ts('Additional Text Color'),
@@ -120,7 +120,7 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co
         '#96C0E7',
       ),
       'color_about_link' => array(
-        ts('Button Link Color'),
+        ts('Button Text Color'),
         'text',
         FALSE,
         '#556C82',
index 42644c759827f5dbdbf617a6298a9ac2ff435aa9..c9e33e341ddba2ad615572253d6e73a09c3e6b1f 100755 (executable)
@@ -1337,25 +1337,25 @@ GROUP BY c.id
         $repeatEvent = ($actionSchedule->end_action == 'before' ? 'DATE_SUB' : 'DATE_ADD') . "({$dateField}, INTERVAL {$actionSchedule->end_frequency_interval} {$actionSchedule->end_frequency_unit})";
 
         if ($actionSchedule->repetition_frequency_unit == 'day') {
-          $hrs = 24 * $actionSchedule->repetition_frequency_interval;
+          $interval = "{$actionSchedule->repetition_frequency_interval} DAY";
         }
         elseif ($actionSchedule->repetition_frequency_unit == 'week') {
-          $hrs = 24 * $actionSchedule->repetition_frequency_interval * 7;
+          $interval = "{$actionSchedule->repetition_frequency_interval} WEEK";
         }
         elseif ($actionSchedule->repetition_frequency_unit == 'month') {
-          $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 MONTH ), latest_log_time))";
+          $interval = "{$actionSchedule->repetition_frequency_interval} MONTH";
         }
         elseif ($actionSchedule->repetition_frequency_unit == 'year') {
-          $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 YEAR ), latest_log_time))";
+          $interval = "{$actionSchedule->repetition_frequency_interval} YEAR";
         }
         else {
-          $hrs = $actionSchedule->repetition_frequency_interval;
+          $interval = "{$actionSchedule->repetition_frequency_interval} HOUR";
         }
 
         // (now <= repeat_end_time )
         $repeatEventClause = "'{$now}' <= {$repeatEvent}";
         // diff(now && logged_date_time) >= repeat_interval
-        $havingClause = "HAVING TIMEDIFF({$now}, latest_log_time) >= TIME('{$hrs}:00:00')";
+        $havingClause = "HAVING TIMESTAMPDIFF(HOUR, latest_log_time, CAST({$now} AS datetime)) >= TIMESTAMPDIFF(HOUR, latest_log_time, DATE_ADD(latest_log_time, INTERVAL $interval))";
         $groupByClause = 'GROUP BY reminder.contact_id, reminder.entity_id, reminder.entity_table';
         $selectClause .= ', MAX(reminder.action_date_time) as latest_log_time';
         //CRM-15376 - do not send our reminders if original criteria no longer applies
index 318066384ce953bf9bb486f93468837dc654ebdd..941aeb6766773ce0de30e1c18999b8f9286720f6 100644 (file)
@@ -1961,13 +1961,18 @@ GROUP BY li.entity_table, li.entity_id, price_field_value_id
         WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId})";
       CRM_Core_DAO::executeQuery($updateLineItem);
     }
+    $amountLevel = array();
+    $totalParticipant = $participantCount = 0;
     if (!empty($updateLines)) {
       foreach ($updateLines as $valueId => $vals) {
+        $taxAmount = "NULL";
         if (isset($vals['tax_amount'])) {
           $taxAmount = $vals['tax_amount'];
         }
-        else {
-          $taxAmount = "NULL";
+        $amountLevel[] = $vals['label'] . ' - ' . (float) $vals['qty'];
+        if (isset($vals['participant_count'])) {
+          $participantCount = $vals['participant_count'];
+          $totalParticipant += $vals['participant_count'];
         }
         $updateLineItem = "
 UPDATE civicrm_line_item li
@@ -1975,6 +1980,7 @@ SET li.qty = {$vals['qty']},
     li.line_total = {$vals['line_total']},
     li.tax_amount = {$taxAmount},
     li.unit_price = {$vals['unit_price']},
+    li.participant_count = {$participantCount},
     li.label = %1
 WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantId}) AND
       (price_field_value_id = {$valueId})
@@ -2012,7 +2018,15 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
     else {
       $taxAmount = "NULL";
     }
-    $trxn = self::recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount);
+    $displayParticipantCount = '';
+    if ($totalParticipant > 0) {
+      $displayParticipantCount = ' Participant Count -' . $totalParticipant;
+    }
+    $updateAmountLevel = NULL;
+    if (!empty($amountLevel)) {
+      $updateAmountLevel = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $amountLevel) . $displayParticipantCount . CRM_Core_DAO::VALUE_SEPARATOR;
+    }
+    $trxn = self::recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount, $updateAmountLevel);
     $trxnId = array();
     if ($trxn) {
       $trxnId['id'] = $trxn->id;
@@ -2068,7 +2082,7 @@ WHERE (entity_table = 'civicrm_participant' AND entity_id = {$participantId} AND
    * @param $paidAmount
    * @param int $contributionId
    */
-  public static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount = NULL) {
+  public static function recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId, $taxAmount = NULL, $updateAmountLevel = NULL) {
     $pendingAmount = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
     $pendingAmount = CRM_Utils_Array::value('total_amount', $pendingAmount, 0);
     $balanceAmt = $updatedAmount - $paidAmount;
@@ -2105,6 +2119,9 @@ WHERE (entity_table = 'civicrm_participant' AND entity_id = {$participantId} AND
       $updatedContributionDAO->total_amount = $updatedContributionDAO->net_amount = $updatedAmount;
       $updatedContributionDAO->fee_amount = 0;
       $updatedContributionDAO->tax_amount = $taxAmount;
+      if (!empty($updateAmountLevel)) {
+        $updatedContributionDAO->amount_level = $updateAmountLevel;
+      }
       $updatedContributionDAO->save();
       // adjusted amount financial_trxn creation
       $updatedContribution = CRM_Contribute_BAO_Contribution::getValues(
index d440fa97e846fd89623b5497aa1a5673e9d6e508..8f57c31af9ff8cc9c6c6e2c9ba11718fbf412b0a 100644 (file)
@@ -1473,7 +1473,7 @@ WHERE  v.option_group_id = g.id
       $this->_values['event']
     ));
     $eventEndDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('event_end_date', $this->_values['event']));
-    if (($regEndDate && ($regEndDate < $now)) || (empty($regEndDate) && ($eventEndDate < $now))) {
+    if (($regEndDate && ($regEndDate < $now)) || (empty($regEndDate) && !empty($eventEndDate) && ($eventEndDate < $now))) {
       $endDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_end_date', $this->_values['event']));
       if (empty($regEndDate)) {
         $endDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('event_end_date', $this->_values['event']));
index 80827f2927a7242096d756547b41a55e28f45fd2..c9f1880397c98b216ff3a5a67ddc70d0ac56d787 100644 (file)
@@ -115,7 +115,7 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form {
       $params = array('id' => $this->_id);
       CRM_Pledge_BAO_Pledge::getValues($params, $this->_values);
 
-      $this->_isPending = (CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values))) ? FALSE : T;
+      $this->_isPending = (CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values))) ? FALSE : TRUE;
     }
 
     //get the pledge frequency units.
index 5614c0cc683cb787b952ac91bb2e0910d5ff64f0..e7d71e598c00994b09507770dd9e658efd96bb53 100644 (file)
@@ -941,7 +941,7 @@ class CRM_Report_Form extends CRM_Core_Form {
   /**
    * Setter for $_force.
    *
-   * @param $isForce
+   * @param bool $isForce
    */
   public function setForce($isForce) {
     $this->_force = $isForce;
@@ -1418,8 +1418,10 @@ class CRM_Report_Form extends CRM_Core_Form {
   }
 
   /**
-   * A form rule function to ensure that fields selected in group_by
-   * (if any) should only be the ones present in display/select fields criteria;
+   * A form rule function for custom data.
+   *
+   * The rule ensures that fields selected in group_by if any) should only be the ones
+   * present in display/select fields criteria;
    * note: works if and only if any custom field selected in group_by.
    *
    * @param array $fields
@@ -1819,7 +1821,7 @@ class CRM_Report_Form extends CRM_Core_Form {
    * Get SQL where clause for a date field.
    *
    * @param string $fieldName
-   * @param $relative
+   * @param string $relative
    * @param string $from
    * @param string $to
    * @param string $type
@@ -2005,9 +2007,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $value
-   * @param $customField
-   * @param $fieldValueMap
+   * Format custom values.
+   *
+   * @param mixed $value
+   * @param array $customField
+   * @param array $fieldValueMap
    *
    * @return float|string|void
    */
@@ -2125,7 +2129,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $rows
+   * Remove duplicate rows.
+   *
+   * @param array $rows
    */
   public function removeDuplicates(&$rows) {
     if (empty($this->_noRepeats)) {
@@ -2148,8 +2154,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $row
-   * @param $fields
+   * Fix subtotal display.
+   *
+   * @param array $row
+   * @param array $fields
    * @param bool $subtotal
    */
   public function fixSubTotalDisplay(&$row, $fields, $subtotal = TRUE) {
@@ -2169,7 +2177,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $rows
+   * Calculate grant total.
+   *
+   * @param array $rows
    *
    * @return bool
    */
@@ -2198,7 +2208,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $rows
+   * Format display output.
+   *
+   * @param array $rows
    * @param bool $pager
    */
   public function formatDisplay(&$rows, $pager = TRUE) {
@@ -2248,7 +2260,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $rows
+   * Build chart.
+   *
+   * @param array $rows
    */
   public function buildChart(&$rows) {
     // override this method for building charts.
@@ -2259,7 +2273,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   // towards generalizing the select() method below.
 
   /**
-   * Generate the SELECT clause and set class variable $_select
+   * Generate the SELECT clause and set class variable $_select.
    */
   public function select() {
     $select = $this->_selectAliases = array();
@@ -2282,9 +2296,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
           ) {
 
             // 1. In many cases we want select clause to be built in slightly different way
-            //    for a particular field of a particular type.
+            // for a particular field of a particular type.
             // 2. This method when used should receive params by reference and modify $this->_columnHeaders
-            //    as needed.
+            // as needed.
             $selectClause = $this->selectClause($tableName, 'fields', $fieldName, $field);
             if ($selectClause) {
               $select[] = $selectClause;
@@ -2356,9 +2370,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
             $this->_phoneField = TRUE;
           }
           // 1. In many cases we want select clause to be built in slightly different way
-          //    for a particular field of a particular type.
+          // for a particular field of a particular type.
           // 2. This method when used should receive params by reference and modify $this->_columnHeaders
-          //    as needed.
+          // as needed.
           $selectClause = $this->selectClause($tableName, 'group_bys', $fieldName, $field);
           if ($selectClause) {
             $select[] = $selectClause;
@@ -2422,10 +2436,12 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Build select clause for a single field.
+   *
    * @param string $tableName
-   * @param $tableKey
+   * @param string $tableKey
    * @param string $fieldName
-   * @param $field
+   * @param string $field
    *
    * @return bool
    */
@@ -2433,6 +2449,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     return FALSE;
   }
 
+  /**
+   * Build where clause.
+   */
   public function where() {
     $this->storeWhereHavingClauseArray();
 
@@ -2455,8 +2474,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * Store Where clauses into an array - breaking out this step makes
-   * over-riding more flexible as the clauses can be used in constructing a
+   * Store Where clauses into an array.
+   *
+   * Breaking out this step makes over-riding more flexible as the clauses can be used in constructing a
    * temp table that may not be part of the final where clause or added
    * in other functions
    */
@@ -2517,6 +2537,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
 
   }
 
+  /**
+   * Set output mode.
+   */
   public function processReportMode() {
     $buttonName = $this->controller->getButtonName();
 
@@ -2583,7 +2606,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * Post Processing function for Form (postProcessCommon should be used to set other variables from input as the api accesses that function)
+   * Post Processing function for Form.
+   *
+   * postProcessCommon should be used to set other variables from input as the api accesses that function.
    */
   public function beginPostProcess() {
     $this->setParams($this->controller->exportValues($this->_name));
@@ -2617,13 +2642,13 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * BeginPostProcess function run in both report mode and non-report mode (api)
+   * BeginPostProcess function run in both report mode and non-report mode (api).
    */
-  public function beginPostProcessCommon() {
-
-  }
+  public function beginPostProcessCommon() {}
 
   /**
+   * Build the report query.
+   *
    * @param bool $applyLimit
    *
    * @return string
@@ -2651,6 +2676,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     return $sql;
   }
 
+  /**
+   * Build group by clause.
+   */
   public function groupBy() {
     $groupBys = array();
     if (!empty($this->_params['group_bys']) &&
@@ -2673,6 +2701,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     }
   }
 
+  /**
+   * Build order by clause.
+   */
   public function orderBy() {
     $this->_orderBy = "";
     $this->_sections = array();
@@ -2684,6 +2715,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Extract order by fields and store as an array.
+   *
    * In some cases other functions want to know which fields are selected for ordering by
    * Separating this into a separate function allows it to be called separately from constructing
    * the order by clause
@@ -2741,6 +2774,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Determine unselected columns.
+   *
    * @return array
    */
   public function unselectedSectionColumns() {
@@ -2767,8 +2802,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $sql
-   * @param $rows
+   * Build output rows.
+   *
+   * @param string $sql
+   * @param array $rows
    */
   public function buildRows($sql, &$rows) {
     $dao = CRM_Core_DAO::executeQuery($sql);
@@ -2801,9 +2838,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Calculate section totals.
+   *
    * When "order by" fields are marked as sections, this assigns to the template
    * an array of total counts for each section. This data is used by the Smarty
-   * plugin {sectionTotal}
+   * plugin {sectionTotal}.
    */
   public function sectionTotals() {
 
@@ -2864,12 +2903,17 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     }
   }
 
+  /**
+   * Modify column headers.
+   */
   public function modifyColumnHeaders() {
     // use this method to modify $this->_columnHeaders
   }
 
   /**
-   * @param $rows
+   * Assign rows to the template.
+   *
+   * @param array $rows
    */
   public function doTemplateAssignment(&$rows) {
     $this->assign_by_ref('columnHeaders', $this->_columnHeaders);
@@ -2878,8 +2922,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * override this method to build your own statistics
-   * @param $rows
+   * Build report statistics.
+   *
+   * Override this method to build your own statistics.
+   *
+   * @param array $rows
    *
    * @return array
    */
@@ -2902,8 +2949,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $statistics
-   * @param $count
+   * Add count statistics.
+   *
+   * @param array $statistics
+   * @param int $count
    */
   public function countStat(&$statistics, $count) {
     $statistics['counts']['rowCount'] = array(
@@ -2920,7 +2969,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $statistics
+   * Add group by statistics.
+   *
+   * @param array $statistics
    */
   public function groupByStat(&$statistics) {
     if (!empty($this->_params['group_bys']) &&
@@ -2944,7 +2995,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $statistics
+   * Filter statistics.
+   *
+   * @param array $statistics
    */
   public function filterStat(&$statistics) {
     foreach ($this->_columns as $tableName => $table) {
@@ -3204,6 +3257,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
 
   /**
    * Compile the report content.
+   *
    * Although this function is super-short it is useful to keep separate so it can be over-ridden by report classes.
    *
    * @return string
@@ -3216,6 +3270,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
 
+  /**
+   * Post process function.
+   */
   public function postProcess() {
     // get ready with post process params
     $this->beginPostProcess();
@@ -3239,7 +3296,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Set limit.
+   *
    * @param int $rowCount
+   *
    * @return array
    */
   public function limit($rowCount = self::ROW_COUNT_LIMIT) {
@@ -3288,6 +3348,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Set pager.
+   *
    * @param int $rowCount
    */
   public function setPager($rowCount = self::ROW_COUNT_LIMIT) {
@@ -3316,9 +3378,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $field
-   * @param $value
-   * @param $op
+   * Build where clause for groups.
+   *
+   * @param string $field
+   * @param mixed $value
+   * @param string $op
    *
    * @return string
    */
@@ -3367,9 +3431,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * @param $field
-   * @param $value
-   * @param $op
+   * Build where clause for tags.
+   *
+   * @param string $field
+   * @param mixed $value
+   * @param string $op
    *
    * @return string
    */
@@ -3418,6 +3484,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
 
   /**
    * Generate Membership Type SQL Clause.
+   *
    * @param mixed $value
    * @param string $op
    *
@@ -3444,6 +3511,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Build acl clauses.
+   *
    * @param string $tableAlias
    */
   public function buildACLClause($tableAlias = 'contact_a') {
@@ -3451,6 +3520,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
+   * Add custom data to the columns.
+   *
    * @param bool $addFields
    * @param array $permCustomGroupIds
    */
@@ -3643,6 +3714,9 @@ ORDER BY cg.weight, cf.weight";
     }
   }
 
+  /**
+   * Build custom data from clause.
+   */
   public function customDataFrom() {
     if (empty($this->_customGroupExtends)) {
       return;
@@ -3681,7 +3755,9 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
   }
 
   /**
-   * @param $prop
+   * Check if the field is selected.
+   *
+   * @param string $prop
    *
    * @return bool
    */
@@ -3803,7 +3879,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
   }
 
   /**
-   * Does table name have columns in SELECT clause?
+   * Check if table name has columns in SELECT clause.
    *
    * @param string $tableName
    *   Name of table (index of $this->_columns array).
@@ -3816,7 +3892,8 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
 
   /**
    * Fetch array of DAO tables having columns included in SELECT or ORDER BY clause.
-   * (building the array if it's unset)
+   *
+   * If the array is unset it will be built.
    *
    * @return array
    *   selectedTables
@@ -3870,6 +3947,8 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
   }
 
   /**
+   * Add address fields.
+   *
    * @deprecated - use getAddressColumns which is a more accurate description
    * and also accepts an array of options rather than a long list
    *
@@ -4031,11 +4110,11 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
   /**
    * Do AlterDisplay processing on Address Fields.
    *
-   * @param $row
-   * @param $rows
-   * @param $rowNum
-   * @param $baseUrl
-   * @param $urltxt
+   * @param array $row
+   * @param array $rows
+   * @param int $rowNum
+   * @param string $baseUrl
+   * @param string $urltxt
    *
    * @return bool
    */
@@ -4206,6 +4285,8 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
   }
 
   /**
+   * Add contact to group.
+   *
    * @param int $groupID
    */
   public function add2group($groupID) {
@@ -4236,7 +4317,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
   }
 
   /**
-   * function used for showing charts on print screen.
+   * Show charts on print screen.
    */
   public static function uploadChartImage() {
     // upload strictly for '.png' images
index 84f7a3cfd46655b5f41022d42cbe4401746b2f0f..d64cd678d11c0edcd7f2d670c0d986123e0c51ad 100644 (file)
@@ -29,8 +29,6 @@
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
  */
 class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
   protected $_addressField = FALSE;
@@ -46,6 +44,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
   public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report');
 
   /**
+<<<<<<< HEAD
    * To what frequency group-by a date column
    *
    * @var array
@@ -59,6 +58,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
   );
 
   /**
+=======
+   * Class constructor.
+>>>>>>> upstream/4.6
    */
   public function __construct() {
 
@@ -283,19 +285,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
     parent::__construct();
   }
 
-  public function preProcess() {
-    parent::preProcess();
-  }
-
   /**
-   * @param bool $freeze
-   *
-   * @return array
+   * Set select clause.
    */
-  public function setDefaultValues($freeze = TRUE) {
-    return parent::setDefaultValues($freeze);
-  }
-
   public function select() {
     $select = array();
     $this->_columnHeaders = array();
@@ -406,16 +398,17 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
   }
 
   /**
-   * @param $fields
-   * @param $files
-   * @param $self
+   * Set form rules.
+   *
+   * @param array $fields
+   * @param array $files
+   * @param CRM_Report_Form_Contribute_Summary $self
    *
    * @return array
    */
   public static function formRule($fields, $files, $self) {
-    $errors = $grouping = array();
-    //check for searching combination of dispaly columns and
-    //grouping criteria
+    // Check for searching combination of display columns and
+    // grouping criteria
     $ignoreFields = array('total_amount', 'sort_name');
     $errors = $self->customDataFormRule($fields, $ignoreFields);
 
@@ -434,6 +427,11 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
     return $errors;
   }
 
+  /**
+   * Set from clause.
+   *
+   * @param string $entity
+   */
   public function from($entity = NULL) {
     $softCreditJoinType = "LEFT";
     if (!empty($this->_params['fields']['soft_amount']) &&
@@ -474,6 +472,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
     }
   }
 
+  /**
+   * Set group by clause.
+   */
   public function groupBy() {
     $this->_groupBy = "";
     $append = FALSE;
@@ -528,6 +529,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
     }
   }
 
+  /**
+   * Store having clauses as an array.
+   */
   public function storeWhereHavingClauseArray() {
     parent::storeWhereHavingClauseArray();
     if (empty($this->_params['fields']['soft_amount']) &&
@@ -542,7 +546,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
   }
 
   /**
-   * @param $rows
+   * Set statistics.
+   *
+   * @param array $rows
    *
    * @return array
    */
@@ -550,13 +556,13 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
     $statistics = parent::statistics($rows);
 
     $softCredit = CRM_Utils_Array::value('soft_amount', $this->_params['fields']);
-    $onlySoftCredit = $softCredit &&
-      !CRM_Utils_Array::value('total_amount', $this->_params['fields']);
-    $totalAmount = $average = $softTotalAmount = $softAverage = array();
+    $onlySoftCredit = $softCredit && !CRM_Utils_Array::value('total_amount', $this->_params['fields']);
     $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
 
     $this->from('contribution');
-    $contriQuery = "
+    $this->customDataFrom();
+
+    $contriQuery = "SELECT
 COUNT({$this->_aliases['civicrm_contribution']}.total_amount )        as civicrm_contribution_total_amount_count,
 SUM({$this->_aliases['civicrm_contribution']}.total_amount )          as civicrm_contribution_total_amount_sum,
 ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as civicrm_contribution_total_amount_avg,
@@ -653,11 +659,20 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
     return $statistics;
   }
 
+  /**
+   * Post process function.
+   */
   public function postProcess() {
     $this->buildACLClause($this->_aliases['civicrm_contact']);
     parent::postProcess();
   }
 
+  /**
+   * Build table rows for output.
+   *
+   * @param string $sql
+   * @param array $rows
+   */
   public function buildRows($sql, &$rows) {
     $dao = CRM_Core_DAO::executeQuery($sql);
     if (!is_array($rows)) {
@@ -666,7 +681,7 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
 
     // use this method to modify $this->_columnHeaders
     $this->modifyColumnHeaders();
-
+    $contriRows = array();
     $unselectedSectionColumns = $this->unselectedSectionColumns();
 
     //CRM-16338 if both soft-credit and contribution are enabled then process the contribution's
@@ -716,7 +731,9 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
   }
 
   /**
-   * @param $rows
+   * Build chart.
+   *
+   * @param array $rows
    */
   public function buildChart(&$rows) {
     $graphRows = array();
diff --git a/CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl
new file mode 100644 (file)
index 0000000..81ee9b7
--- /dev/null
@@ -0,0 +1 @@
+{* file to handle db changes in 4.6.9 during upgrade *}
index dec96a5dbc370fc491f804b64879a2628fa5aea2..b16ae7c7775eab0081bff970a3c1923b26d58e5e 100644 (file)
@@ -548,6 +548,10 @@ abstract class CRM_Utils_System_Base {
   public function getTimeZoneOffset() {
     $timezone = $this->getTimeZoneString();
     if ($timezone) {
+      if ($timezone == 'UTC') {
+        // CRM-17072 Let's short-circuit all the zero handling & return it here!
+        return '+00:00';
+      }
       $tzObj = new DateTimeZone($timezone);
       $dateTime = new DateTime("now", $tzObj);
       $tz = $tzObj->getOffset($dateTime);
index 1c8499dc466af7cc38a7bf651254ec3e96256c02..109d3d442e1686d8cb51232a78e08187e13a6b33 100644 (file)
           entity: entity,
           select: {
             multiple: multiSelect,
-            minimumInputLength: _.includes(OPEN_IMMEDIATELY, entity) ? 0 : 1
+            minimumInputLength: _.includes(OPEN_IMMEDIATELY, entity) ? 0 : 1,
+            // If user types a numeric id, allow it as a choice
+            createSearchChoice: function(input) {
+              var match = /[1-9][0-9]*/.exec(input);
+              if (match && match[0] === input) {
+                return {id: input, label: input};
+              }
+            }
           }
         });
       }
index 456a2216891c0d389471ef0667db859dedee852b..d74287631ab205bc306a7ab37ebf62a588da660c 100644 (file)
@@ -1,14 +1,14 @@
 CRM.$(function($) {
   //do not copy & paste this - find a way to generalise it
   'use strict';
-  // NOTE: Might be safer to say $('[name=_qf_Email_upload]')
-   $('.crm-form-submit').not('.cancel').on("click", function() {
-     $('.crm-form-submit').not('.cancel').attr({value: ts('Processing')});
+  // NOTE: Target only fullscreen forms (using #crm-container as context) because popups already have this feature
+   $('.crm-form-submit', '#crm-container').not('.cancel').on("click", function() {
+     $('.crm-form-submit', '#crm-container').not('.cancel').attr({value: ts('Processing')});
      // CRM-13449 : setting a 0 ms timeout is needed
      // for some browsers like chrome. Used for purpose of
      // submit the form and stop accidental multiple clicks
      setTimeout(function(){
-       $('.crm-form-submit').not('.cancel').prop({disabled: true});
+       $('.crm-form-submit', '#crm-container').not('.cancel').prop({disabled: true});
      }, 0);
    });
 });
index a1f4d4f99f43c0095cc8cf48bac810cd7016e206..a6810dd89aa5127b5fe0782d4ed240304e2473b5 100644 (file)
     }
 
     function buildRecurBlock( processorId ) {
-
       if ( !processorId ) processorId = cj( "#payment_processor_id" ).val( );
       var recurPaymentProIds = {/literal}'{$recurringPaymentProcessorIds}'{literal};
-      var funName = 'hide';
-      if ( recurPaymentProIds.indexOf( processorId ) != -1 ) funName = 'show';
+      var funName = ( cj.inArray(processorId, recurPaymentProIds.split(',')) > -1 ) ? 'show' : 'hide';
 
       var priceSet = cj("#price_set_id");
       if ( priceSet && priceSet.val( ) ) {
index ac4463254da1c7c9ebea2ab72ccaa573a09b6a55..1074e2e1a71f9f0f59f67742f33f8ee07c09e718 100644 (file)
         background-color: {/literal}{$form.color_main_bg.value}{literal};
     } /* title */
     .crm-contribute-widget .crm-amount-raised { color:#000; }
-    .crm-contribute-widget .crm-amount-bar  /* progress bar */
-        background-color:{/literal}{$form.color_bar.value}{literal};
-        border-color:#CECECE;
+    .crm-contribute-widget .crm-amount-fill {
+      background-color:{/literal}{$form.color_bar.value}{literal};
     }
-    .crm-contribute-widget .crm-amount-fill { background-color:#2786C2; }
     .crm-contribute-widget a.crm-contribute-button { /* button color */
         background-color:{/literal}{$form.color_button.value}{literal};
     }
index 4fa3a7c712c02a2333cf459d01f79c353c958826..969038b3c6235117217d30f462f046f8de724541 100644 (file)
                     {foreach from=$eventSummary.tab key=k item=v}
                       {assign var="fld" value=$v.field}
                       {if NOT $values.$fld}{assign var="status" value="disabled"}{else}{assign var="status" value="enabled"}{/if}
-                      <li><a title="{$v.title}" class="action-item crm-hover-button no-popup {$status}"
-                             href="{crmURL p="`$v.url`" q="reset=1&action=update&id=`$id`"}">{$v.title}</a></li>
+                      {* Schedule Reminders requires a different query string. *}
+                      {if $v.url EQ 'civicrm/event/manage/reminder'}
+                        <li><a title="{$v.title}" class="action-item crm-hover-button no-popup {$status}"
+                            href="{crmURL p="`$v.url`" q="reset=1&action=browse&setTab=1&id=`$id`"}">{$v.title}</a></li>
+                      {else}
+                        <li><a title="{$v.title}" class="action-item crm-hover-button no-popup {$status}"
+                            href="{crmURL p="`$v.url`" q="reset=1&action=update&id=`$id`"}">{$v.title}</a></li>
+                      {/if}
                     {/foreach}
                   </ul>
                 </span>
index a5b0a173019c1888319606a2a44264e4b00b40dd..f74de1077bd744a33c53dd5d7b1fa08ad14578a6 100644 (file)
@@ -82,6 +82,36 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
     $this->assertEquals(0, $result['count']);
   }
 
+  /**
+   * Function tests that an empty where hook returns exactly 1 result with "view my contact".
+   *
+   * CRM-16512 caused contacts with Edit my contact to be able to view all records.
+   */
+  public function testContactGetOneResultHookWithViewMyContact() {
+    $this->createLoggedInUser();
+    $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults'));
+    CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'view my contact');
+    $result = $this->callAPISuccess('contact', 'get', array(
+      'check_permissions' => 1,
+      'return' => 'display_name',
+    ));
+    $this->assertEquals(1, $result['count']);
+  }
+
+  /**
+   * Function tests that a user with "edit my contact" can edit themselves.
+   */
+  public function testContactEditHookWithEditMyContact() {
+    $this->markTestIncomplete('api acls only work with contact get so far');
+    $cid = $this->createLoggedInUser();
+    $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults'));
+    CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'edit my contact');
+    $this->callAPISuccess('contact', 'create', array(
+      'check_permissions' => 1,
+      'id' => $cid,
+    ));
+  }
+
   /**
    * Function tests all results are returned.
    */
@@ -122,7 +152,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
   }
 
   /**
-   * Confirm that without check permissions we still get 2 contacts returned
+   * Confirm that without check permissions we still get 2 contacts returned.
    */
   public function testContactGetHookLimitingHookDontCheck() {
     $result = $this->callAPISuccess('contact', 'get', array(
@@ -299,7 +329,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
   /**
    * @dataProvider entities
    * Function tests that an empty where hook returns no results
-   * @param $entity
+   * @param string $entity
    * @throws \PHPUnit_Framework_IncompleteTestError
    */
   public function testEntityGetNoResultsHook($entity) {