From: Coleman Watts Date: Sat, 4 May 2013 22:35:04 +0000 (-0700) Subject: Mailing pseudoconstant CRM-12464 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6ce01b0250e3ab825f700bb6a1f06afaf3080c57;p=civicrm-core.git Mailing pseudoconstant CRM-12464 ---------------------------------------- * CRM-12464: Search improvements in 4.4 http://issues.civicrm.org/jira/browse/CRM-12464 --- diff --git a/CRM/Mailing/Form/Approve.php b/CRM/Mailing/Form/Approve.php index 992b00335f..e6d1f46d25 100644 --- a/CRM/Mailing/Form/Approve.php +++ b/CRM/Mailing/Form/Approve.php @@ -112,7 +112,7 @@ class CRM_Mailing_Form_Approve extends CRM_Core_Form { $this->addElement('textarea', 'approval_note', ts('Approve/Reject Note')); - $mailApprovalStatus = CRM_Mailing_PseudoConstant::approvalStatus(); + $mailApprovalStatus = CRM_Core_OptionGroup::values('mail_approval_status'); // eliminate the none option $noneOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status', diff --git a/CRM/Mailing/PseudoConstant.php b/CRM/Mailing/PseudoConstant.php index 0a36721210..8b7a9742e2 100644 --- a/CRM/Mailing/PseudoConstant.php +++ b/CRM/Mailing/PseudoConstant.php @@ -39,13 +39,6 @@ */ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { - /** - * mailing approval status - * @var array - * @static - */ - private static $approvalStatus; - /** * mailing templates * @var array @@ -180,24 +173,6 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { return self::$completed; } - /** - * Get all mail approval status. - * - * The static array approvalStatus is returned - * - * @access public - * @static - * - * @return array - array reference of all mail approval statuses - * - */ - public static function &approvalStatus() { - if (!self::$approvalStatus) { - self::$approvalStatus = CRM_Core_OptionGroup::values('mail_approval_status'); - } - return self::$approvalStatus; - } - /** * Labels for advanced search against mailing summary. * @@ -231,7 +206,7 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { /** * Flush given pseudoconstant so it can be reread from db - * nex time it's requested. + * next time it's requested. * * @access public * @static @@ -239,7 +214,7 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { * @param boolean $name pseudoconstant to be flushed * */ - public static function flush($name) { + public static function flush($name = 'template') { if (isset(self::$$name)) { self::$$name = NULL; } diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index e404e2beba..b0ebe5fac0 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -378,13 +378,12 @@ class CRM_Utils_Array { /** * Function to check if give array is empty - * @param array $array array that needs to be check for empty condition + * @param array $array array to check for empty condition * * @return boolean true is array is empty else false * @static */ - static function crmIsEmptyArray($array = array( - )) { + static function crmIsEmptyArray($array = array()) { if (!is_array($array)) { return TRUE; } @@ -486,7 +485,8 @@ class CRM_Utils_Array { * Convenient way to unset a bunch of items from an array * * @param array $items (reference) - * @param string/int/array $itemN: other params to this function will be treated as keys (or arrays of keys) to unset + * @param string/int/array $itemN: other params to this function will be treated as keys + * (or arrays of keys) to unset */ static function remove(&$items) { foreach (func_get_args() as $n => $key) { diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index a63b5fd96f..246021e725 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -460,8 +460,7 @@ class CRM_Utils_Token { break; case 'approvalStatus': - $mailApprovalStatus = CRM_Mailing_PseudoConstant::approvalStatus(); - $value = $mailApprovalStatus[$mailing->approval_status_id]; + $value = CRM_Core_PseudoConstant::getValue('CRM_Mailing_DAO_Mailing', 'approval_status_id', $mailing->approval_status_id); break; case 'approvalNote': diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index 6df056dd58..aaf724554c 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -470,9 +470,11 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'fieldName' => 'status_id', 'sample' => 'New', ), + ), + 'CRM_Mailing_DAO_Mailing' => array( array( - 'fieldName' => 'membership_type_id', - 'sample' => 'Lifetime', + 'fieldName' => 'approval_status_id', + 'sample' => 'Approved', ), ), ); @@ -487,7 +489,7 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { // Ensure sample value is contained in the returned optionValues. $this->assertContains($field['sample'], $optionValues, $message); - // Exclude test + // Ensure exclude value is not contained in the optionValues if (!empty($field['exclude'])) { $this->assertNotContains($field['exclude'], $optionValues, $message); } diff --git a/xml/schema/Mailing/Mailing.xml b/xml/schema/Mailing/Mailing.xml index deed5418cb..53d4744e44 100644 --- a/xml/schema/Mailing/Mailing.xml +++ b/xml/schema/Mailing/Mailing.xml @@ -235,6 +235,9 @@ int unsigned Approval Status The status of this mailing. Values: none, approved, rejected + + mail_approval_status + 3.3 diff --git a/xml/schema/Member/Membership.xml b/xml/schema/Member/Membership.xml index 693b67765c..5afcafb1cd 100644 --- a/xml/schema/Member/Membership.xml +++ b/xml/schema/Member/Membership.xml @@ -54,7 +54,7 @@ civicrm_membership_type
id - label + name
1.5