Commit 2f6c641a authored by eileen's avatar eileen

Finish fixing contribute preferences & preferences form to isolate hacks into one form

parent f87c35c7
......@@ -92,6 +92,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
$settings = Civi::settings();
// @todo replace this by defining all in settings.
foreach ($this->_varNames as $groupName => $settingNames) {
CRM_Core_Error::deprecatedFunctionWarning('deprecated use of preferences form. This will be removed from core soon');
foreach ($settingNames as $settingName => $options) {
$this->_config->$settingName = $settings->get($settingName);
}
......@@ -107,6 +108,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
$this->setDefaultsForMetadataDefinedFields();
foreach ($this->_varNames as $groupName => $settings) {
CRM_Core_Error::deprecatedFunctionWarning('deprecated use of preferences form. This will be removed from core soon');
foreach ($settings as $settingName => $settingDetails) {
$this->_defaults[$settingName] = isset($this->_config->$settingName) ? $this->_config->$settingName : CRM_Utils_Array::value('default', $settingDetails, NULL);
}
......@@ -123,6 +125,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
public function cbsDefaultValues(&$defaults) {
foreach ($this->_varNames as $groupName => $groupValues) {
CRM_Core_Error::deprecatedFunctionWarning('deprecated use of preferences form. This will be removed from core soon');
foreach ($groupValues as $settingName => $fieldValue) {
if ($fieldValue['html_type'] == 'checkboxes') {
if (isset($this->_config->$settingName) &&
......@@ -150,6 +153,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
parent::buildQuickForm();
if (!empty($this->_varNames)) {
CRM_Core_Error::deprecatedFunctionWarning('deprecated use of preferences form. This will be removed from core soon');
foreach ($this->_varNames as $groupName => $groupValues) {
$formName = CRM_Utils_String::titleToVar($groupName);
$this->assign('formName', $formName);
......
This diff is collapsed.
......@@ -39,6 +39,7 @@ return array(
'group' => 'contribute',
'name' => 'cvv_backoffice_required',
'type' => 'Boolean',
'html_type' => 'radio',
'quick_form_type' => 'YesNo',
'default' => '1',
'add' => '4.1',
......@@ -49,6 +50,8 @@ return array(
'help_text' => 'If set it back-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change',
),
'contribution_invoice_settings' => array(
// @todo our standard is to have a setting per item not to hide settings in an array with
// no useful metadata. Undo this setting.
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'contribution_invoice_settings',
......
......@@ -25,25 +25,27 @@
*}
<div class="crm-block crm-form-block crm-{$formName}-block">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<table class = "form-layout">
{foreach from=$htmlFields item=desc key=htmlField}
{include file="CRM/Form/basicFormFields.tpl"}
<table class="form-layout" id="invoicing_blocks">
{foreach from=$htmlFields item=fieldSpec key=htmlField}
{if $form.$htmlField}
{assign var=n value=$htmlField|cat:'_description'}
<tr class="crm-preferences-form-block-{$htmlField}">
{if $form.$htmlField.html_type EQ 'checkbox'|| $form.$htmlField.html_type EQ 'checkboxes'}
{if $fieldSpec.html_type EQ 'checkbox'|| $fieldSpec.html_type EQ 'checkboxes'}
<td class="label"></td>
<td>
{$form.$htmlField.html} {$form.$htmlField.label}
{if $desc}
<br /><span class="description">{$desc}</span>
<br /><span class="description">{$fieldSpec.description}</span>
{/if}
</td>
{else}
<td class="label">{$form.$htmlField.label}&nbsp;{if $htmlField eq 'acl_financial_type'}{help id="$htmlField"}{/if}</td>
<td>
{$form.$htmlField.html}
{if $desc}
<br /><span class="description">{$desc}</span>
{if $fieldSpec.description}
<br /><span class="description">{$fieldSpec.description}</span>
{/if}
</td>
{/if}
......@@ -51,14 +53,13 @@
{/if}
{/foreach}
</table>
{include file="CRM/Form/basicFormFields.tpl"}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
{literal}
<script type="text/javascript">
cj(document).ready(function() {
if (document.getElementById("invoicing").checked) {
if (document.getElementById("invoicing_invoicing").checked) {
cj("#invoicing_blocks").show();
}
else {
......@@ -67,7 +68,7 @@
});
cj(function () {
cj("input[type=checkbox]").click(function() {
if (cj("#invoicing").is(":checked")) {
if (cj("#invoicing_invoicing").is(":checked")) {
cj("#invoicing_blocks").show();
}
else {
......
......@@ -23,9 +23,8 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{* @todo the invoicing_blocks id is used by contribution preferences - get that out of the shared code & back to where it belongs *}
{* @todo with a small amount of tinkering most of this can be replaced by re-using the foreach loop in CRM_Core_EntityForm.tpl *}
<table class="form-layout" id="invoicing_blocks">
<table class="form-layout">
{foreach from=$fields item=field key=fieldName}
{assign var=n value=$fieldName}
{if $form.$n}
......
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| 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 |
+--------------------------------------------------------------------+
*/
/**
* Trait ACL_Permission_Trait.
*
* Trait for working with ACLs in tests
*/
trait CRMTraits_ACL_PermissionTrait {
protected $allowedContactId = 0;
protected $allowedContacts = [];
/**
* All results returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereHookAllResults($type, &$tables, &$whereTables, &$contactID, &$where) {
$where = " (1) ";
}
/**
* All but first results returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereOnlySecond($type, &$tables, &$whereTables, &$contactID, &$where) {
$where = " contact_a.id > 1";
}
/**
* Only specified contact returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereOnlyOne($type, &$tables, &$whereTables, &$contactID, &$where) {
$where = " contact_a.id = " . $this->allowedContactId;
}
}
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| 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 |
+--------------------------------------------------------------------+
*/
/**
* Trait ACL_Permission_Trait.
*
* Trait for working with ACLs in tests
*/
trait CRMTraits_ACL_PermissionTrait {
protected $allowedContactId = 0;
protected $allowedContacts = [];
/**
* All results returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereHookAllResults($type, &$tables, &$whereTables, &$contactID, &$where) {
$where = " (1) ";
}
/**
* All but first results returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereOnlySecond($type, &$tables, &$whereTables, &$contactID, &$where) {
$where = " contact_a.id > 1";
}
/**
* Only specified contact returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereOnlyOne($type, &$tables, &$whereTables, &$contactID, &$where) {
$where = " contact_a.id = " . $this->allowedContactId;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment