Skip to content

Commit

Permalink
Merge pull request #11921 from civicrm/5.0
Browse files Browse the repository at this point in the history
5.0 merge to master
  • Loading branch information
eileenmcnaughton authored Apr 2, 2018
2 parents 09aaec1 + 0542d40 commit 3aa5f41
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 65 deletions.
1 change: 1 addition & 0 deletions CRM/Admin/Page/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public function preProcess() {
$this->assign('showCounted', TRUE);
}
$this->assign('isLocked', self::$_isLocked);
$this->assign('allowLoggedIn', Civi::settings()->get('allow_mail_from_logged_in_contact'));
$config = CRM_Core_Config::singleton();
if (self::$_gName == 'activity_type') {
$this->assign('showComponent', TRUE);
Expand Down
60 changes: 30 additions & 30 deletions CRM/Report/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ public function addGroupBys() {
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('group_bys', $table)) {
foreach ($table['group_bys'] as $fieldName => $field) {
if (!empty($field)) {
if (!empty($field) && empty($field['no_display'])) {
$options[$field['title']] = $fieldName;
if (!empty($field['frequency'])) {
$freqElements[$field['title']] = $fieldName;
Expand Down Expand Up @@ -5291,45 +5291,45 @@ protected function buildColumns($specs, $tableName, $daoName = NULL, $tableAlias
*/
protected function storeGroupByArray() {

if (CRM_Utils_Array::value('group_bys', $this->_params) &&
is_array($this->_params['group_bys']) &&
!empty($this->_params['group_bys'])
) {
foreach ($this->_columns as $tableName => $table) {
$table = $this->_columns[$tableName];
if (array_key_exists('group_bys', $table)) {
foreach ($table['group_bys'] as $fieldName => $fieldData) {
$field = $this->_columns[$tableName]['metadata'][$fieldName];
if (!empty($this->_params['group_bys'][$fieldName])) {
if (!empty($field['chart'])) {
$this->assign('chartSupported', TRUE);
}
if (!CRM_Utils_Array::value('group_bys', $this->_params)
|| !is_array($this->_params['group_bys'])) {
$this->_params['group_bys'] = [];
}

if (!empty($table['group_bys'][$fieldName]['frequency']) &&
!empty($this->_params['group_bys_freq'][$fieldName])
) {
foreach ($this->_columns as $tableName => $table) {
$table = $this->_columns[$tableName];
if (array_key_exists('group_bys', $table)) {
foreach ($table['group_bys'] as $fieldName => $fieldData) {
$field = $this->_columns[$tableName]['metadata'][$fieldName];
if (!empty($this->_params['group_bys'][$fieldName]) || !empty($fieldData['required'])) {
if (!empty($field['chart'])) {
$this->assign('chartSupported', TRUE);
}

switch ($this->_params['group_bys_freq'][$fieldName]) {
case 'FISCALYEAR':
$this->_groupByArray[$tableName . '_' . $fieldName . '_start'] = self::fiscalYearOffset($field['dbAlias']);
if (!empty($table['group_bys'][$fieldName]['frequency']) &&
!empty($this->_params['group_bys_freq'][$fieldName])
) {

case 'YEAR':
$this->_groupByArray[$tableName . '_' . $fieldName . '_start'] = " {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
switch ($this->_params['group_bys_freq'][$fieldName]) {
case 'FISCALYEAR':
$this->_groupByArray[$tableName . '_' . $fieldName . '_start'] = self::fiscalYearOffset($field['dbAlias']);

default:
$this->_groupByArray[$tableName . '_' . $fieldName . '_start'] = "EXTRACT(YEAR_{$this->_params['group_bys_freq'][$fieldName]} FROM {$field['dbAlias']})";
case 'YEAR':
$this->_groupByArray[$tableName . '_' . $fieldName . '_start'] = " {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";

default:
$this->_groupByArray[$tableName . '_' . $fieldName . '_start'] = "EXTRACT(YEAR_{$this->_params['group_bys_freq'][$fieldName]} FROM {$field['dbAlias']})";

}
}
else {
if (!in_array($field['dbAlias'], $this->_groupByArray)) {
$this->_groupByArray[$tableName . '_' . $fieldName] = $field['dbAlias'];
}
}
else {
if (!in_array($field['dbAlias'], $this->_groupByArray)) {
$this->_groupByArray[$tableName . '_' . $fieldName] = $field['dbAlias'];
}
}
}

}

}
}
}
Expand Down
20 changes: 9 additions & 11 deletions CRM/Report/Form/Contribute/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {

protected $_softFrom = NULL;

protected $noDisplayContributionOrSoftColumn = FALSE;

protected $_customGroupExtends = array(
'Contact',
'Individual',
Expand Down Expand Up @@ -338,10 +340,6 @@ public function select() {
$this->_columnHeaders = array();

parent::select();
//total_amount was affected by sum as it is considered as one of the stat field
//so it is been replaced with correct alias, CRM-13833
$this->_select = str_replace("sum({$this->_aliases['civicrm_contribution']}.total_amount)", "{$this->_aliases['civicrm_contribution']}.total_amount", $this->_select);
$this->_selectClauses = str_replace("sum({$this->_aliases['civicrm_contribution']}.total_amount)", "{$this->_aliases['civicrm_contribution']}.total_amount", $this->_selectClauses);
}

public function orderBy() {
Expand Down Expand Up @@ -723,7 +721,7 @@ public function alterDisplay(&$rows) {
}

// Contribution amount links to viewing contribution
if (($value = CRM_Utils_Array::value('civicrm_contribution_total_amount_sum', $row)) &&
if (($value = CRM_Utils_Array::value('civicrm_contribution_total_amount', $row)) &&
CRM_Core_Permission::check('access CiviContribute')
) {
$url = CRM_Utils_System::url("civicrm/contact/view/contribution",
Expand All @@ -732,8 +730,8 @@ public function alterDisplay(&$rows) {
"&action=view&context=contribution&selectedChild=contribute",
$this->_absoluteUrl
);
$rows[$rowNum]['civicrm_contribution_total_amount_sum_link'] = $url;
$rows[$rowNum]['civicrm_contribution_total_amount_sum_hover'] = ts("View Details of this Contribution.");
$rows[$rowNum]['civicrm_contribution_total_amount_link'] = $url;
$rows[$rowNum]['civicrm_contribution_total_amount_hover'] = ts("View Details of this Contribution.");
$entryFound = TRUE;
}

Expand All @@ -752,7 +750,7 @@ public function alterDisplay(&$rows) {
array_key_exists('civicrm_contribution_contribution_id', $row)
) {
$query = "
SELECT civicrm_contact_id, civicrm_contact_sort_name, civicrm_contribution_total_amount_sum, civicrm_contribution_currency
SELECT civicrm_contact_id, civicrm_contact_sort_name, civicrm_contribution_total_amount, civicrm_contribution_currency
FROM civireport_contribution_detail_temp2
WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}";
$this->addToDeveloperTab($query);
Expand All @@ -764,7 +762,7 @@ public function alterDisplay(&$rows) {
$dao->civicrm_contact_id);
$string = $string . ($string ? $separator : '') .
"<a href='{$url}'>{$dao->civicrm_contact_sort_name}</a> " .
CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->civicrm_contribution_currency);
CRM_Utils_Money::format($dao->civicrm_contribution_total_amount, $dao->civicrm_contribution_currency);
}
$rows[$rowNum]['civicrm_contribution_soft_credits'] = $string;
}
Expand Down Expand Up @@ -845,10 +843,10 @@ public function sectionTotals() {

$addtotals = '';

if (array_search("civicrm_contribution_total_amount_sum", $this->_selectAliases) !==
if (array_search("civicrm_contribution_total_amount", $this->_selectAliases) !==
FALSE
) {
$addtotals = ", sum(civicrm_contribution_total_amount_sum) as sumcontribs";
$addtotals = ", sum(civicrm_contribution_total_amount) as sumcontribs";
$showsumcontribs = TRUE;
}

Expand Down
21 changes: 3 additions & 18 deletions CRM/Report/Form/Contribute/TopDonor.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ public function __construct() {
),
),
'filters' => $this->getBasicContactFilters(),
'group_bys' => ['contact_contact_id' => ['name' => 'id', 'required' => 1, 'no_display' => 1]],
),
'civicrm_line_item' => array(
'dao' => 'CRM_Price_DAO_LineItem',
),
);
$this->_columns += $this->getAddressColumns();
$this->_columns += $this->getAddressColumns(['group_by' => FALSE]);
$this->_columns += array(
'civicrm_contribution' => array(
'dao' => 'CRM_Contribute_DAO_Contribution',
Expand Down Expand Up @@ -159,6 +160,7 @@ public function __construct() {
'default' => array(1),
),
),
'group_bys' => ['contribution_currency' => ['name' => 'currency', 'required' => 1, 'no_display' => 1]],
),
'civicrm_financial_trxn' => array(
'dao' => 'CRM_Financial_DAO_FinancialTrxn',
Expand Down Expand Up @@ -208,19 +210,6 @@ public function __construct() {
parent::__construct();
}

public function preProcess() {
parent::preProcess();
}

/**
* Select only contact ID when adding to group.
*
* @todo consider moving that to parent to support AddToGroup in general.
*/
public function select() {
parent::select();
}

/**
* @param $fields
* @param $files
Expand Down Expand Up @@ -316,10 +305,6 @@ public function where() {
}
}

public function groupBy() {
$this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, array("{$this->_aliases['civicrm_contact']}.id", "{$this->_aliases['civicrm_contribution']}.currency"));
}

/**
* Build output rows.
*
Expand Down
6 changes: 5 additions & 1 deletion templates/CRM/Admin/Page/Options.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
{elseif $gName eq 'participant_status'}
{ts}Define statuses for event participants here (e.g. Registered, Attended, Cancelled...). You can then assign statuses and search for participants by status.{/ts} {ts}"Counted?" controls whether a person with that status is counted as participant for the purpose of controlling the Maximum Number of Participants.{/ts}
{elseif $gName eq 'from_email_address'}
{ts}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, you can use this page to define one or more general Email Addresses that can be selected as an alternative. EXAMPLE: <em>"Client Services" &lt;clientservices@example.org&gt;</em>{/ts}
{if $allowLoggedIn}
{ts}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, you can use this page to define one or more general Email Addresses that can be selected as an alternative. EXAMPLE: <em>"Client Services" &lt;clientservices@example.org&gt;</em>{/ts}
{else}
{ts}You can use this page to define one or more general Email Addresses that can be selected as the From Address. EXAMPLE: <em>"Client Services" &lt;clientservices@example.org&gt;</em>{/ts}
{/if}
{elseif $isLocked}
{ts}This option group is reserved for system use. You cannot add or delete options in this list.{/ts}
{else}
Expand Down
14 changes: 11 additions & 3 deletions templates/CRM/Contact/Form/Task/Email.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@
{ts}From Address{/ts}
{/htxt}
{htxt id="id-from_email"}
<p>{ts}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, users with Administer CiviCRM permission can configure one or more general email addresses that can be selected as an alternative. EXAMPLE: "Client Services" &lt;clientservices@example.org&gt;{/ts}</p>
{if $params.logged_in_email_setting == "1"}
<p>{ts}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, users with Administer CiviCRM permission can configure one or more general email addresses that can be selected as an alternative. EXAMPLE: "Client Services" &lt;clientservices@example.org&gt;{/ts}</p>
{else}
<p>{ts}CiviCRM is currently configured to only use the defined From Email addresses. If you wish to be able to use the email address of the logged in user as the From Address you will need to set the setting "Allow mail from loged in contact" setting. Users with Administer CiviCRM can set this setting in the SMTP settings.{/ts}<p>
{if $params.isAdmin}
{capture assign="smtpUrl"}{crmURL p="civicrm/admin/setting/smtp" q="reset=1"}{/capture}
<p>{ts 1=$smtpUrl}Go to <a href='%1'>Settings - Outbound Mail</a> to enable the usage of the logged in contact's email address as the from email{/ts}</p>
{/if}
{/if}
{if $params.isAdmin}
{capture assign="fromConfig"}{crmURL p="civicrm/admin/options/from_email_address" q="reset=1"}{/capture}
<p>{ts 1=$fromConfig}Go to <a href='%1'>Administer CiviCRM &raquo; Communications &raquo; FROM Email Addresses</a> to add or edit general email addresses. Make sure these email addresses are valid email accounts with your email service provider.{/ts}</p>
{capture assign="fromConfig"}{crmURL p="civicrm/admin/options/from_email_address" q="reset=1"}{/capture}
<p>{ts 1=$fromConfig}Go to <a href='%1'>Administer CiviCRM &raquo; Communications &raquo; FROM Email Addresses</a> to add or edit general email addresses. Make sure these email addresses are valid email accounts with your email service provider.{/ts}</p>
{/if}
{/htxt}

Expand Down
3 changes: 2 additions & 1 deletion templates/CRM/Contact/Form/Task/Email.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
<p>{ts count=$suppressedEmails plural='Email will NOT be sent to %count contacts - (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).'}Email will NOT be sent to %count contact - (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).{/ts}</p>
</div>
{/if}
{crmSetting var="logged_in_email_setting" name="allow_mail_from_logged_in_contact"}
<table class="form-layout-compressed">
<tr id="selectEmailFrom" class="crm-contactEmail-form-block-fromEmailAddress crm-email-element">
<td class="label">{$form.from_email_address.label}</td>
<td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin}</td>
<td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin logged_in_email_setting=$logged_in_email_setting}</td>
</tr>
<tr class="crm-contactEmail-form-block-recipient">
<td class="label">{if $single eq false}{ts}Recipient(s){/ts}{else}{$form.to.label}{/if}</td>
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/api/v3/ReportTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public function testReportTemplateGetStatisticsAllReports($reportID) {
public static function getReportTemplates() {
$reportsToSkip = array(
'activity' => 'does not respect function signature on from clause',
'contribute/topDonor' => 'construction of query in postProcess makes inaccessible ',
'event/income' => 'I do no understand why but error is Call to undefined method CRM_Report_Form_Event_Income::from() in CRM/Report/Form.php on line 2120',
'logging/contact/summary' => '(likely to be test related) probably logging off Undefined index: Form/Contact/LoggingSummary.php(231): PHP',
'logging/contribute/summary' => '(likely to be test related) probably logging off DB Error: no such table',
Expand Down

0 comments on commit 3aa5f41

Please sign in to comment.