Skip to content

Commit

Permalink
Merge pull request #1 from civicrm/master
Browse files Browse the repository at this point in the history
Update master from upstream
  • Loading branch information
martinh-pw committed Feb 1, 2019
2 parents 66a4d92 + 621f12d commit d92d9d6
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 82 deletions.
5 changes: 3 additions & 2 deletions CRM/Admin/Form/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@ public function setDefaultValues() {
$this->setDefaultsForMetadataDefinedFields();
return $this->_defaults;
}

/**
* Build the form object.
*/
public function buildQuickForm() {
$filter = array_pop($this->urlPath);
$filter = $this->getSettingPageFilter();
$settings = civicrm_api3('Setting', 'getfields', [])['values'];
foreach ($settings as $key => $setting) {
if (isset($setting['settings_pages'][$filter])) {
$this->_settings[$key] = $setting;
}
}
// @todo sort settings by weight.

$this->addFieldsDefinedInSettingsMetadata();

// @todo look at sharing the code below in the settings trait.
Expand Down
47 changes: 46 additions & 1 deletion CRM/Admin/Form/SettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
*/
trait CRM_Admin_Form_SettingTrait {

/**
* The setting page filter.
*
* @var string
*/
private $_filter;

/**
* @var array
*/
Expand Down Expand Up @@ -118,6 +125,44 @@ protected function getSettingMetadataItem($setting, $item) {
return CRM_Utils_Array::value($item, $this->getSettingsMetaData()[$setting]);
}

/**
* @return string
*/
protected function getSettingPageFilter() {
if (!isset($this->_filter)) {
// Get the last URL component without modifying the urlPath property.
$urlPath = array_values($this->urlPath);
$this->_filter = end($urlPath);
}
return $this->_filter;
}

/**
* Returns a re-keyed copy of the settings, ordered by weight.
*
* @return array
*/
protected function getSettingsOrderedByWeight() {
$settingMetaData = $this->getSettingsMetaData();
$filter = $this->getSettingPageFilter();

usort($settingMetaData, function ($a, $b) use ($filter) {
// Handle cases in which a comparison is impossible. Such will be considered ties.
if (
// A comparison can't be made unless both setting weights are declared.
!isset($a['settings_pages'][$filter]['weight'], $b['settings_pages'][$filter]['weight'])
// A pair of settings might actually have the same weight.
|| $a['settings_pages'][$filter]['weight'] === $b['settings_pages'][$filter]['weight']
) {
return 0;
}

return $a['settings_pages'][$filter]['weight'] > $b['settings_pages'][$filter]['weight'] ? 1 : -1;
});

return $settingMetaData;
}

/**
* Add fields in the metadata to the template.
*/
Expand Down Expand Up @@ -207,7 +252,7 @@ protected function addFieldsDefinedInSettingsMetadata() {
// setting_description should be deprecated - see Mail.tpl for metadata based tpl.
$this->assign('setting_descriptions', $descriptions);
$this->assign('settings_fields', $settingMetaData);
$this->assign('fields', $settingMetaData);
$this->assign('fields', $this->getSettingsOrderedByWeight());
}

/**
Expand Down
8 changes: 7 additions & 1 deletion CRM/Core/DAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/UFGroup.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:e5e629c4f6d56d238b4ac28e822cea8a)
* (GenCodeChecksum:0f78fb49440e1cf5d43fd3db5a43ee7e)
*/

/**
Expand Down Expand Up @@ -551,6 +551,9 @@ public static function &fields() {
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 1,
'html' => [
'type' => 'Text',
],
],
'submit_button_text' => [
'name' => 'submit_button_text',
Expand All @@ -564,6 +567,9 @@ public static function &fields() {
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 1,
'html' => [
'type' => 'Text',
],
],
'add_cancel_button' => [
'name' => 'add_cancel_button',
Expand Down
20 changes: 4 additions & 16 deletions CRM/Report/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ public function __construct() {
$campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
$caseEnabled = in_array("CiviCase", $config->enableComponents);
if ($campaignEnabled) {
$getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
$this->activeCampaigns = $getCampaigns['campaigns'];
asort($this->activeCampaigns);
$this->engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
}

Expand Down Expand Up @@ -345,18 +342,9 @@ public function __construct() {
'operator' => 'like',
'type' => CRM_Utils_Type::T_STRING,
);
if (!empty($this->activeCampaigns)) {
$this->_columns['civicrm_activity']['fields']['campaign_id'] = array(
'title' => ts('Campaign'),
'default' => 'false',
);
$this->_columns['civicrm_activity']['filters']['campaign_id'] = array(
'title' => ts('Campaign'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => $this->activeCampaigns,
);
}
// If we have campaigns enabled, add those elements to both the fields, filters.
$this->addCampaignFields('civicrm_activity');

if (!empty($this->engagementLevels)) {
$this->_columns['civicrm_activity']['fields']['engagement_level'] = array(
'title' => ts('Engagement Index'),
Expand Down Expand Up @@ -1033,7 +1021,7 @@ public function alterDisplay(&$rows) {

if (array_key_exists('civicrm_activity_campaign_id', $row)) {
if ($value = $row['civicrm_activity_campaign_id']) {
$rows[$rowNum]['civicrm_activity_campaign_id'] = $this->activeCampaigns[$value];
$rows[$rowNum]['civicrm_activity_campaign_id'] = $this->campaigns[$value];
$entryFound = TRUE;
}
}
Expand Down
24 changes: 3 additions & 21 deletions CRM/Report/Form/Member/ContributionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
* Class constructor.
*/
public function __construct() {
$config = CRM_Core_Config::singleton();
$campaignEnabled = in_array('CiviCampaign', $config->enableComponents);
if ($campaignEnabled) {
$getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
$this->activeCampaigns = $getCampaigns['campaigns'];
asort($this->activeCampaigns);
}
$this->_columns = array(
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
Expand Down Expand Up @@ -376,19 +369,8 @@ public function __construct() {
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;

if ($campaignEnabled && !empty($this->activeCampaigns)) {
$this->_columns['civicrm_contribution']['fields']['campaign_id'] = array(
'title' => ts('Campaign'),
'default' => 'false',
);
$this->_columns['civicrm_contribution']['filters']['campaign_id'] = array(
'title' => ts('Campaign'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => $this->activeCampaigns,
'type' => CRM_Utils_Type::T_INT,
);
$this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
}
// If we have campaigns enabled, add those elements to both the fields, filters and sorting
$this->addCampaignFields('civicrm_contribution', FALSE, TRUE);

$this->_currencyColumn = 'civicrm_contribution_currency';
parent::__construct();
Expand Down Expand Up @@ -780,7 +762,7 @@ public function alterDisplay(&$rows) {
// convert campaign_id to campaign title
if (array_key_exists('civicrm_contribution_campaign_id', $row)) {
if ($value = $row['civicrm_contribution_campaign_id']) {
$rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns[$value];
$rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->campaigns[$value];
$entryFound = TRUE;
}
}
Expand Down
27 changes: 3 additions & 24 deletions CRM/Report/Form/Member/Lapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form {
* Class constructor.
*/
public function __construct() {

// Check if CiviCampaign is a) enabled and b) has active campaigns
$config = CRM_Core_Config::singleton();
$campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
if ($campaignEnabled) {
$getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
$this->activeCampaigns = $getCampaigns['campaigns'];
asort($this->activeCampaigns);
}

// UI for selecting columns to appear in the report list
// array containing the columns, group_bys and filters build and provided to Form
$this->_columns = array(
Expand Down Expand Up @@ -177,19 +167,8 @@ public function __construct() {
),
);

// If we have a campaign, build out the relevant elements
if ($campaignEnabled && !empty($this->activeCampaigns)) {
$this->_columns['civicrm_membership']['fields']['campaign_id'] = array(
'title' => ts('Campaign'),
'default' => 'false',
);
$this->_columns['civicrm_membership']['filters']['campaign_id'] = array(
'title' => ts('Campaign'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => $this->activeCampaigns,
'type' => CRM_Utils_Type::T_INT,
);
}
// If we have campaigns enabled, add those elements to both the fields, filters.
$this->addCampaignFields('civicrm_membership');

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
Expand Down Expand Up @@ -392,7 +371,7 @@ public function alterDisplay(&$rows) {
// If using campaigns, convert campaign_id to campaign title
if (array_key_exists('civicrm_membership_campaign_id', $row)) {
if ($value = $row['civicrm_membership_campaign_id']) {
$rows[$rowNum]['civicrm_membership_campaign_id'] = $this->activeCampaigns[$value];
$rows[$rowNum]['civicrm_membership_campaign_id'] = $this->campaigns[$value];
}
$entryFound = TRUE;
}
Expand Down
8 changes: 6 additions & 2 deletions CRM/UF/Form/AdvanceSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group {
* @param CRM_Core_Form $form
*/
public static function buildAdvanceSetting(&$form) {
$entityFields = [
'cancel_button_text',
'submit_button_text',
];
$form->assign('advancedFieldsConverted', $entityFields);

// should mapping be enabled for this group
$form->addElement('checkbox', 'is_map', ts('Enable mapping for this profile?'));

Expand All @@ -53,8 +59,6 @@ public static function buildAdvanceSetting(&$form) {

$form->add('advcheckbox', 'add_cancel_button', ts('Include Cancel Button?'));
$form->addElement('text', 'cancel_URL', ts('Cancel Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_URL'));
$form->addElement('text', 'cancel_button_text', ts('Cancel Button Text'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_button_text'));
$form->addElement('text', 'submit_button_text', ts('Submit Button Text'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'submit_button_text'));

// add select for groups
$group = array('' => ts('- select -')) + $form->_group;
Expand Down
4 changes: 3 additions & 1 deletion CRM/UF/Form/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ protected function setEntityFields() {
'title' => ['name' => 'title'],
'frontend_title' => ['name' => 'frontend_title'],
'description' => ['name' => 'description', 'help' => ['id' => 'id-description', 'file' => 'CRM/UF/Form/Group.hlp']],
'uf_group_type' => ['name' => 'uf_group_type', 'not-auto-addable' => TRUE, 'help' => ['id' => 'id-used_for', 'file' => 'CRM/UF/Form/Group.hlp'], 'post_html_text' => ' ' . $this->getOtherModuleString()]
'uf_group_type' => ['name' => 'uf_group_type', 'not-auto-addable' => TRUE, 'help' => ['id' => 'id-used_for', 'file' => 'CRM/UF/Form/Group.hlp'], 'post_html_text' => ' ' . $this->getOtherModuleString()],
'cancel_button_text' => ['name' => 'cancel_button_text', 'help' => ['id' => 'id-cancel_button_text', 'file' => 'CRM/UF/Form/Group.hlp'], 'class' => 'cancel_button_section'],
'submit_button_text' => ['name' => 'submit_button_text', 'help' => ['id' => 'id-submit_button_text', 'file' => 'CRM/UF/Form/Group.hlp'], 'class' => ''],
];
}

Expand Down
2 changes: 1 addition & 1 deletion api/v3/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ function civicrm_api3_mailing_send_test($params) {
$query = CRM_Utils_SQL_Select::from('civicrm_email e')
->select(array('e.id', 'e.contact_id', 'e.email'))
->join('c', 'INNER JOIN civicrm_contact c ON e.contact_id = c.id')
->where('LOWER(e.email) IN (@emails)', array('@emails' => $testEmailParams['emails']))
->where('e.email IN (@emails)', array('@emails' => $testEmailParams['emails']))
->where('e.on_hold = 0')
->where('c.is_opt_out = 0')
->where('c.do_not_email = 0')
Expand Down
15 changes: 6 additions & 9 deletions templates/CRM/UF/Form/AdvanceSetting.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@
<td>{$form.cancel_URL.html} {help id='id-cancel_URL' file="CRM/UF/Form/Group.hlp"}</td>
</tr>

<tr class="cancel_button_section crm-uf-advancesetting-form-block-cancel_button_text">
<td class="label">{$form.cancel_button_text.label}</td>
<td>{$form.cancel_button_text.html} {help id='id-cancel_button_text' file="CRM/UF/Form/Group.hlp"}</td>
</tr>

<tr class="crm-uf-advancesetting-form-block-submit_button_text">
<td class="label">{$form.submit_button_text.label}</td>
<td>{$form.submit_button_text.html} {help id='id-submit_button_text' file="CRM/UF/Form/Group.hlp"}</td>
</tr>
{foreach from=$advancedFieldsConverted item=fieldName}
{assign var=fieldSpec value=$entityFields.$fieldName}
<tr class="crm-{$entityInClassFormat}-form-block-{$fieldName} {$fieldSpec.class}">
{include file="CRM/Core/Form/Field.tpl"}
</tr>
{/foreach}

<tr class="crm-uf-advancesetting-form-block-add_captcha">
<td class="label"></td>
Expand Down
10 changes: 6 additions & 4 deletions templates/CRM/UF/Form/Group.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
{else}
<table class="form-layout">
{foreach from=$entityFields item=fieldSpec}
{assign var=fieldName value=$fieldSpec.name}
<tr class="crm-{$entityInClassFormat}-form-block-{$fieldName}">
{include file="CRM/Core/Form/Field.tpl"}
</tr>
{if not in_array($fieldSpec.name, $advancedFieldsConverted)}
{assign var=fieldName value=$fieldSpec.name}
<tr class="crm-{$entityInClassFormat}-form-block-{$fieldName}">
{include file="CRM/Core/Form/Field.tpl"}
</tr>
{/if}
{/foreach}
<tr class="crm-uf_group-form-block-weight" >
<td class="label">{$form.weight.label}{if $config->userSystem->is_drupal EQ '1'} {help id='id-profile_weight' file="CRM/UF/Form/Group.hlp"}{/if}</td>
Expand Down
6 changes: 6 additions & 0 deletions xml/schema/Core/UFGroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@
<default>NULL</default>
<localizable>true</localizable>
<add>4.7</add>
<html>
<type>Text</type>
</html>
</field>
<field>
<name>submit_button_text</name>
Expand All @@ -291,6 +294,9 @@
<default>NULL</default>
<localizable>true</localizable>
<add>4.7</add>
<html>
<type>Text</type>
</html>
</field>
<field>
<name>add_cancel_button</name>
Expand Down

0 comments on commit d92d9d6

Please sign in to comment.