From: eileen Date: Mon, 30 Apr 2018 02:47:08 +0000 (+1200) Subject: Fix Soft credit personal note ton limit to 255 characters (DB limit). X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ed71bbcafa9a93f2b335301d3c0516c5859ec9dc;p=civicrm-core.git Fix Soft credit personal note ton limit to 255 characters (DB limit). Note that some special characters can still cause it to spill over but that will affect other fields too & we should consider a bigger fix if we need to. Also fixed deprecation notices --- diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index e72a6843f1..17a0bd2f92 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1279,11 +1279,12 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $params = array('id' => $contributionSoft->pcp_id); CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo); $ownerNotifyID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id'); + $ownerNotifyOption = CRM_Core_PseudoConstant::getName('CRM_PCP_DAO_PCPBlock', 'owner_notify_id', $ownerNotifyID); - if ($ownerNotifyID != CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'no_notifications', 'name') && - (($ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name') && + if ($ownerNotifyOption != 'no_notifications' && + (($ownerNotifyOption == 'owner_chooses' && CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $contributionSoft->pcp_id, 'is_notify')) || - $ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'all_owners', 'name'))) { + $ownerNotifyOption == 'all_owners')) { $pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$contributionSoft->pcp_id}", TRUE, NULL, FALSE, TRUE diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index ba43dcceac..da9214d221 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -484,7 +484,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $this->addGroup($elements, 'pcp_is_anonymous', NULL, '   '); $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30)); - $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;')); + $this->addField('pcp_personal_note', array('entity' => 'ContributionSoft', 'context' => 'create', 'style' => 'height: 3em; width: 40em;')); } } if (empty($this->_values['fee']) && empty($this->_ccid)) { diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 13bc59e339..d6abdc7b3e 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1475,6 +1475,9 @@ class CRM_Core_Form extends HTML_QuickForm_Page { //Set default columns and rows for textarea. $props['rows'] = isset($props['rows']) ? $props['rows'] : 4; $props['cols'] = isset($props['cols']) ? $props['cols'] : 60; + if (!$props['maxlength'] && isset($fieldSpec['length'])) { + $props['maxlength'] = $fieldSpec['length']; + } return $this->add('textarea', $name, $label, $props, $required); case 'Select Date': diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index b771766617..215ac06c45 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -453,7 +453,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $page->_defaults['pcp_is_anonymous'] = 0; $page->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30)); - $page->add('textarea', "pcp_personal_note", ts('Personal Note'), array('style' => 'height: 3em; width: 40em;')); + $page->addField('pcp_personal_note', array('entity' => 'ContributionSoft', 'context' => 'create', 'style' => 'height: 3em; width: 40em;')); } else { $page->assign('is_honor_roll', FALSE); @@ -477,8 +477,6 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; return FALSE; } - $approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name'); - $pcpStatus = CRM_Core_OptionGroup::values("pcp_status"); $params = array('id' => $pcpId); @@ -507,12 +505,13 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; // define redirect url back to contrib page or event if needed $url = CRM_Utils_System::url($urlBase, "reset=1&id={$pcpBlock['entity_id']}", FALSE, NULL, FALSE, TRUE); + $currentPCPStatus = CRM_Core_PseudoConstant::getName('CRM_PCP_BAO_PCP', 'status_id', $pcpInfo['status_id']); if ($pcpBlock['target_entity_id'] != $entity['id']) { $statusMessage = ts('This page is not related to the Personal Campaign Page you have just visited. However you can still make a contribution here.'); CRM_Core_Error::statusBounce($statusMessage, $url); } - elseif ($pcpInfo['status_id'] != $approvedId) { + elseif ($currentPCPStatus !== 'Approved') { $statusMessage = ts('The Personal Campaign Page you have just visited is currently %1. However you can still support the campaign here.', array(1 => $pcpStatus[$pcpInfo['status_id']])); CRM_Core_Error::statusBounce($statusMessage, $url); } diff --git a/CRM/PCP/Form/Campaign.php b/CRM/PCP/Form/Campaign.php index 32c83eafc6..ffaa85a5db 100644 --- a/CRM/PCP/Form/Campaign.php +++ b/CRM/PCP/Form/Campaign.php @@ -140,7 +140,7 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { else { $owner_notification_option = CRM_PCP_BAO_PCP::getOwnerNotificationId($this->controller->get('component_page_id'), $this->_component ? $this->_component : 'contribute'); } - if ($owner_notification_option == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name')) { + if ($owner_notification_option == CRM_Core_PseudoConstant::getKey('CRM_PCP_BAO_PCPBlock', 'owner_notify_id', 'owner_chooses')) { $this->assign('owner_notification_option', TRUE); $this->addElement('checkbox', 'is_notify', ts('Notify me via email when someone donates to my page'), NULL); } diff --git a/CRM/PCP/Page/PCPInfo.php b/CRM/PCP/Page/PCPInfo.php index d3cea84eab..db32123a94 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -77,7 +77,7 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { $this->assign('pcp', $pcpInfo); $pcpStatus = CRM_Core_OptionGroup::values("pcp_status"); - $approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name'); + $approvedId = CRM_Core_PseudoConstant::getKey('CRM_PCP_BAO_PCP', 'status_id', 'Approved'); // check if PCP is created by anonymous user $anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this);