From cbf48754cda127e5dfe2d4faeeb28e3c15296a5e Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Tue, 30 Apr 2013 22:45:18 -0700 Subject: [PATCH] Refactored out of CRM_Core_PseudoConstant: websiteType(), fromEmailAddress(), honorType(), priority(), wysiwygEditor(), mappingType(), mailProtocol(). CRM-12464 ---------------------------------------- * CRM-12464: Search improvements in 4.4 http://issues.civicrm.org/jira/browse/CRM-12464 ---------------------------------------- * CRM-12464: http://issues.civicrm.org/jira/browse/CRM-12464 * CRM-12464:: http://issues.civicrm.org/jira/browse/CRM-12464: --- CRM/Activity/BAO/Activity.php | 2 +- CRM/Activity/Form/Activity.php | 4 +- CRM/Admin/Form/MailSettings.php | 2 +- CRM/Admin/Form/Mapping.php | 2 +- CRM/Admin/Form/Preferences/Display.php | 2 +- CRM/Admin/Page/MailSettings.php | 2 +- CRM/Case/BAO/Case.php | 2 +- CRM/Contact/BAO/Query.php | 4 +- CRM/Contact/Form/Edit/Website.php | 2 +- CRM/Contact/Form/Task/EmailCommon.php | 2 +- CRM/Contact/Import/Form/MapField.php | 4 +- CRM/Contact/Import/ImportJob.php | 2 +- CRM/Contact/Page/Inline/Website.php | 2 +- CRM/Contact/Selector.php | 2 +- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Contribute/Form/AdditionalInfo.php | 4 +- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Contribute/Form/Contribution/Confirm.php | 4 +- CRM/Contribute/Form/Contribution/Main.php | 2 +- CRM/Contribute/Form/Contribution/ThankYou.php | 2 +- CRM/Contribute/Form/ContributionView.php | 2 +- CRM/Core/BAO/UFGroup.php | 6 +- CRM/Core/Form.php | 2 +- CRM/Core/Page/Basic.php | 2 +- CRM/Core/PseudoConstant.php | 184 +----------------- CRM/Logging/Differ.php | 4 +- CRM/Mailing/Form/Upload.php | 6 +- CRM/Mailing/MailStore.php | 2 +- CRM/Member/Form/Membership.php | 2 +- CRM/Member/Form/MembershipRenewal.php | 2 +- CRM/Pledge/BAO/Pledge.php | 2 +- CRM/Pledge/Form/Pledge.php | 2 +- CRM/Pledge/Form/PledgeView.php | 2 +- CRM/Profile/Selector/Listings.php | 2 +- CRM/Report/Form/ActivitySummary.php | 2 +- api/v3/Contact.php | 2 +- tests/phpunit/CRM/Core/PseudoConstantTest.php | 61 ++++++ xml/schema/Activity/Activity.xml | 1 - xml/schema/Contribute/Contribution.xml | 3 + xml/schema/Core/MailSettings.xml | 3 + xml/schema/Core/Mapping.xml | 3 + xml/schema/Core/MappingField.xml | 3 + xml/schema/Core/Website.xml | 1 - xml/schema/Pledge/Pledge.xml | 3 + 44 files changed, 122 insertions(+), 230 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index dd54cfc8bb..5c0c0a15c3 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -309,7 +309,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { // if not set and not 0 !CRM_Utils_Array::value('id', $params) ) { - $priority = CRM_Core_PseudoConstant::priority(); + $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); $params['priority_id'] = array_search('Normal', $priority); } diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index f921a08c80..05f805d8f8 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -168,7 +168,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { 'type' => 'select', 'label' => ts('Priority'), 'attributes' => - CRM_Core_PseudoConstant::priority(), + CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), 'required' => TRUE ), 'source_contact_id' => array( @@ -597,7 +597,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { ); } if (!CRM_Utils_Array::value('priority_id', $defaults)) { - $priority = CRM_Core_PseudoConstant::priority(); + $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); $defaults['priority_id'] = array_search('Normal', $priority); } if (!CRM_Utils_Array::value('status_id', $defaults)) { diff --git a/CRM/Admin/Form/MailSettings.php b/CRM/Admin/Form/MailSettings.php index 3973a96c0d..992a209df4 100644 --- a/CRM/Admin/Form/MailSettings.php +++ b/CRM/Admin/Form/MailSettings.php @@ -70,7 +70,7 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { $this->add('select', 'protocol', ts('Protocol'), - array('' => ts('- select -')) + CRM_Core_PseudoConstant::mailProtocol(), + array('' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'), TRUE ); diff --git a/CRM/Admin/Form/Mapping.php b/CRM/Admin/Form/Mapping.php index 9fe11f20e5..63ea130bcc 100644 --- a/CRM/Admin/Form/Mapping.php +++ b/CRM/Admin/Form/Mapping.php @@ -70,7 +70,7 @@ class CRM_Admin_Form_Mapping extends CRM_Admin_Form { CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'description') ); - $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant::mappingTypes()); + $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id')); if ($this->_action == CRM_Core_Action::UPDATE) { $mappingType->freeze(); diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index bc0962cf54..d92dbc41b9 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -147,7 +147,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { * @access public */ public function buildQuickForm() { - $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_PseudoConstant::wysiwygEditor(); + $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_OptionGroup::values('wysiwyg_editor'); $config = CRM_Core_Config::singleton(); $extra = array(); diff --git a/CRM/Admin/Page/MailSettings.php b/CRM/Admin/Page/MailSettings.php index 2a9c0e674c..ed38e1bb8b 100644 --- a/CRM/Admin/Page/MailSettings.php +++ b/CRM/Admin/Page/MailSettings.php @@ -94,7 +94,7 @@ class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic { $allMailSettings = array(); $mailSetting = new CRM_Core_DAO_MailSettings(); - $allProtocols = CRM_Core_PseudoConstant::mailProtocol(); + $allProtocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); //multi-domain support for mail settings. CRM-5244 $mailSetting->domain_id = CRM_Core_Config::domainID(); diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index c72877bc1a..9bdad9ac62 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1104,7 +1104,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type $activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); - $activityPriority = CRM_Core_PseudoConstant::priority(); + $activityPriority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); $url = CRM_Utils_System::url("civicrm/case/activity", "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index b6a222050f..b3bf07c144 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3077,8 +3077,8 @@ WHERE id IN ( $groupIDs ) */ function phone_option_group($values) { list($name, $op, $value, $grouping, $wildcard) = $values; - $option = $name == 'phone_phone_type_id' ? 'phoneType' : 'locationType'; - $options = CRM_Core_PseudoConstant::$option(); + $option = ($name == 'phone_phone_type_id' ? 'phone_type_id' : 'location_type_id'); + $options = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', $option); $optionName = $options[$value]; $this->_qill[$grouping][] = ts('Phone') . ' ' . ($name == 'phone_phone_type_id' ? ts('type') : ('location')) . " $op $optionName"; $this->_where[$grouping][] = self::buildClause('civicrm_phone.' . substr($name, 6), $op, $value, 'Integer'); diff --git a/CRM/Contact/Form/Edit/Website.php b/CRM/Contact/Form/Edit/Website.php index a2c4de4d81..22bc9618a9 100644 --- a/CRM/Contact/Form/Edit/Website.php +++ b/CRM/Contact/Form/Edit/Website.php @@ -59,7 +59,7 @@ class CRM_Contact_Form_Edit_Website { $form->applyFilter('__ALL__', 'trim'); //Website type select - $form->addElement('select', "website[$blockId][website_type_id]", '', CRM_Core_PseudoConstant::websiteType()); + $form->addElement('select', "website[$blockId][website_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id')); //Website box $form->addElement('text', "website[$blockId][url]", ts('Website'), diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index 2694d6a8dd..06337bbc6e 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -105,7 +105,7 @@ class CRM_Contact_Form_Task_EmailCommon { // now add domain from addresses $domainEmails = array(); - $domainFrom = CRM_Core_PseudoConstant::fromEmailAddress(); + $domainFrom = CRM_Core_OptionGroup::values('from_email_address'); foreach (array_keys($domainFrom) as $k) { $domainEmail = $domainFrom[$k]; $domainEmails[$domainEmail] = htmlspecialchars($domainEmail); diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index aecbe5aeb8..31591528d9 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -355,7 +355,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Core_Form { $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $imProviders = CRM_Core_PseudoConstant::IMProvider(); - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); foreach ($this->_location_types as $key => $value) { $sel3['phone'][$key] = &$phoneTypes; @@ -763,7 +763,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Core_Form { $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $imProviders = CRM_Core_PseudoConstant::IMProvider(); - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); //these mapper params need to set key as array and val as null. diff --git a/CRM/Contact/Import/ImportJob.php b/CRM/Contact/Import/ImportJob.php index a09a2fdb9d..2007de91d1 100644 --- a/CRM/Contact/Import/ImportJob.php +++ b/CRM/Contact/Import/ImportJob.php @@ -146,7 +146,7 @@ class CRM_Contact_Import_ImportJob { $mapperFields = array(); $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $imProviders = CRM_Core_PseudoConstant::IMProvider(); - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); //initialize mapper perperty value. diff --git a/CRM/Contact/Page/Inline/Website.php b/CRM/Contact/Page/Inline/Website.php index 4a48c3b618..ab4a2a29ad 100644 --- a/CRM/Contact/Page/Inline/Website.php +++ b/CRM/Contact/Page/Inline/Website.php @@ -52,7 +52,7 @@ class CRM_Contact_Page_Inline_Website extends CRM_Core_Page { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $params = array('contact_id' => $contactId); $websites = CRM_Core_BAO_Website::getValues($params, CRM_Core_DAO::$_nullArray); diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 78c891e1e5..734f31ce7c 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -665,7 +665,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $propertyArray = explode('-', $property); $websiteFld = $websiteKey . '-' . array_pop($propertyArray); if (!empty($result->$websiteFld)) { - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $websiteType = $websiteTypes[$result->{"$websiteKey-website_type_id"}]; $websiteValue = $result->$websiteFld; $websiteUrl = "{$websiteValue} ({$websiteType})"; diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 0103ce58d6..6f866190e4 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2255,7 +2255,7 @@ WHERE contribution_id = %1 "; $honorIds['contribution'] = $this->id; $idParams = array('id' => $honorID, 'contact_id' => $honorID); CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $honorIds); - $honorType = CRM_Core_PseudoConstant::honor(); + $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $template->assign('honor_block_is_active', 1); if (CRM_Utils_Array::value('prefix_id', $honorDefault)) { diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index af123b1e1c..b01b243286 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -164,7 +164,7 @@ class CRM_Contribute_Form_AdditionalInfo { static function buildHonoree(&$form) { //Honoree section $form->add('hidden', 'hidden_Honoree', 1); - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $extraOption = array('onclick' => "return enableHonorType();"); foreach ($honor as $key => $var) { $honorTypes[$key] = $form->createElement('radio', NULL, NULL, $var, $key, $extraOption); @@ -363,7 +363,7 @@ class CRM_Contribute_Form_AdditionalInfo { // retrieve individual prefix value for honoree if (CRM_Utils_Array::value('hidden_Honoree', $params)) { $individualPrefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $params['honor_prefix'] = CRM_Utils_Array::value(CRM_Utils_Array::value('honor_prefix_id', $params ), diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 195539a29e..38152e65f3 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -380,7 +380,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP if (isset($defaults['honor_contact_id'])) { $honorDefault = $ids = array(); $this->_honorID = $defaults['honor_contact_id']; - $honorType = CRM_Core_PseudoConstant::honor(); + $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $idParams = array( 'id' => $defaults['honor_contact_id'], 'contact_id' => $defaults['honor_contact_id'], diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 19e83fc356..dd751378f1 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -388,7 +388,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values)); $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $this->assign('honor_type', CRM_Utils_Array::value($params['honor_type_id'], $honor)); $this->assign('honor_prefix', CRM_Utils_Array::value($params['honor_prefix_id'], $prefix)); $this->assign('honor_first_name', $params['honor_first_name']); @@ -1573,7 +1573,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values)); $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $honorType = CRM_Core_PseudoConstant::honor(); + $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $this->assign('honor_type', CRM_Utils_Array::value(CRM_Utils_Array::value('honor_type_id', $params), $honorType)); $this->assign('honor_prefix', CRM_Utils_Array::value(CRM_Utils_Array::value('honor_prefix_id', $params), $prefix)); $this->assign('honor_first_name', CRM_Utils_Array::value('honor_first_name', $params)); diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 83a293fe19..35d53b77f7 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -599,7 +599,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $extraOption = array('onclick' => "enableHonorType();"); // radio button for Honor Type $honorOptions = array(); - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); foreach ($honor as $key => $var) { $honorTypes[$key] = $this->createElement('radio', NULL, NULL, $var, $key, $extraOption); } diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index 392d065f7a..ae70d52a4c 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -129,7 +129,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values)); $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $this->assign('honor_type', $honor[$params["honor_type_id"]]); $this->assign('honor_prefix', ($params["honor_prefix_id"]) ? $prefix[$params["honor_prefix_id"]] : ' '); $this->assign('honor_first_name', $params["honor_first_name"]); diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index be1fe301b6..f1fb3d2340 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -78,7 +78,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid=$values[honor_contact_id]"); $values['honor_display'] = "" . $dao->display_name . ""; } - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id'); $values['honor_type'] = CRM_Utils_Array::value(CRM_Utils_Array::value('honor_type_id', $values), $honor); } diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index acbeff7fc6..2c03cd1b37 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -915,7 +915,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $imProviders = CRM_Core_PseudoConstant::IMProvider(); - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $multipleFields = array('url'); $nullIndex = $nullValueIndex = ' '; @@ -1974,10 +1974,10 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) if (substr($name, -1) == ']') { $websiteTypeName = substr($name, 0, -1) . '-website_type_id]'; } - $form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::websiteType()); + $form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id')); } else { - $form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::websiteType()); + $form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id')); } } // Note should be rendered as textarea diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 649c3464a2..a8b81dbc86 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -870,7 +870,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 'editor_id' ); $editor = strtolower(CRM_Utils_Array::value($editorID, - CRM_Core_PseudoConstant::wysiwygEditor() + CRM_Core_OptionGroup::values('wysiwyg_editor') )); if (!$editor || $forceTextarea) { $editor = 'textarea'; diff --git a/CRM/Core/Page/Basic.php b/CRM/Core/Page/Basic.php index 3c7a441f8c..c55c368829 100644 --- a/CRM/Core/Page/Basic.php +++ b/CRM/Core/Page/Basic.php @@ -263,7 +263,7 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { $this->action($object, $action, $values[$object->id], $links, $permission); if (isset($object->mapping_type_id)) { - $mappintTypes = CRM_Core_PseudoConstant::mappingTypes(); + $mappintTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id'); $values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id]; } } diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 0ae97ec3ec..f4a8e4bf25 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -98,20 +98,6 @@ class CRM_Core_PseudoConstant { */ private static $imProvider; - /** - * website protocols - * @var array - * @static - */ - private static $websiteType; - - /** - * im protocols - * @var array - * @static - */ - private static $fromEmailAddress; - /** * states, provinces * @var array @@ -238,13 +224,6 @@ class CRM_Core_PseudoConstant { */ private static $worldRegions; - /** - * honorType - * @var array - * @static - */ - private static $honorType; - /** * activity status * @var array @@ -252,27 +231,6 @@ class CRM_Core_PseudoConstant { */ private static $activityStatus; - /** - * priority - * @var array - * @static - */ - private static $priority; - - /** - * wysiwyg Editor - * @var array - * @static - */ - private static $wysiwygEditor; - - /** - * Mapping Types - * @var array - * @static - */ - private static $mappingType; - /** * Visibility * @var array @@ -280,13 +238,6 @@ class CRM_Core_PseudoConstant { */ private static $visibility; - /** - * Mail Protocols - * @var array - * @static - */ - private static $mailProtocol; - /** * Greetings * @var array @@ -736,71 +687,7 @@ class CRM_Core_PseudoConstant { } return self::$imProvider; } - - /** - * Get all the website types from database. - * - * The static array websiteType is returned, and if it's - * called the first time, the Website DAO is used - * to get all the Website Types. - * - * Note: any database errors will be trapped by the DAO. - * - * @access public - * @static - * - * @return array - array reference of all Website types. - * - */ - public static function &websiteType() { - if (!self::$websiteType) { - self::$websiteType = CRM_Core_OptionGroup::values('website_type'); - } - return self::$websiteType; - } - - /** - * Get the all From Email Address from database. - * - * The static array $fromEmailAddress is returned, and if it's - * called the first time, DAO is used - * to get all the From Email Address - * - * Note: any database errors will be trapped by the DAO. - * - * @access public - * @static - * - * @return array - array reference of all From Email Address. - */ - public static function &fromEmailAddress() { - if (!self::$fromEmailAddress) { - self::$fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address'); - } - return self::$fromEmailAddress; - } - - /** - * Get the all Mail Protocols from database. - * - * The static array mailProtocol is returned, and if it's - * called the first time, the DAO is used - * to get all the Mail Protocol. - * - * Note: any database errors will be trapped by the DAO. - * - * @access public - * @static - * - * @return array - array reference of all Mail Protocols. - */ - public static function &mailProtocol() { - if (!self::$mailProtocol) { - self::$mailProtocol = CRM_Core_OptionGroup::values('mail_protocol'); - } - return self::$mailProtocol; - } - + /** * Get all the State/Province from database. * @@ -1687,26 +1574,6 @@ WHERE id = %1"; return self::$worldRegions; } - /** - * Get all Honor Type. - * - * The static array honorType is returned - * - * @access public - * @static - * - * @param boolean $all - get All Honor Type. - * - * @return array - array reference of all Honor Types. - * - */ - public static function &honor() { - if (!self::$honorType) { - self::$honorType = CRM_Core_OptionGroup::values('honor_type'); - } - return self::$honorType; - } - /** * Get all Activity Statuses. * @@ -1730,41 +1597,6 @@ WHERE id = %1"; return self::$activityStatus[$column]; } - /** - * Get all Priorities - * - * The static array Priority is returned - * - * @access public - * @static - * - * @return array - array reference of all Priority - */ - public static function &priority() { - if (!self::$priority) { - self::$priority = CRM_Core_OptionGroup::values('priority'); - } - - return self::$priority; - } - - /** - * Get all WYSIWYG Editors. - * - * The static array wysiwygEditor is returned - * - * @access public - * @static - * - * @return array - array reference of all wysiwygEditors - */ - public static function &wysiwygEditor() { - if (!self::$wysiwygEditor) { - self::$wysiwygEditor = CRM_Core_OptionGroup::values('wysiwyg_editor'); - } - return self::$wysiwygEditor; - } - /** * Get all Visibility levels. * @@ -1788,20 +1620,6 @@ WHERE id = %1"; return self::$visibility[$column]; } - /** - * Get all mapping types - * - * @return array - array reference of all mapping types - * @access public - * @static - */ - public static function &mappingTypes() { - if (!self::$mappingType) { - self::$mappingType = CRM_Core_OptionGroup::values('mapping_type'); - } - return self::$mappingType; - } - public static function &stateProvinceForCountry($countryID, $field = 'name') { static $_cache = NULL; diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 61b8dbef14..a9ba451f9d 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -244,10 +244,10 @@ WHERE log_conn_id = %1 AND 'provider_id' => CRM_Core_PseudoConstant::IMProvider(), 'state_province_id' => CRM_Core_PseudoConstant::stateProvince(), 'suffix_id' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), - 'website_type_id' => CRM_Core_PseudoConstant::websiteType(), + 'website_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), 'activity_type_id' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), 'case_type_id' => CRM_Case_PseudoConstant::caseType('label', FALSE), - 'priority_id' => CRM_Core_PseudoConstant::priority(), + 'priority_id' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), ); // for columns that appear in more than 1 table diff --git a/CRM/Mailing/Form/Upload.php b/CRM/Mailing/Form/Upload.php index 1fd093c26c..98f0258445 100644 --- a/CRM/Mailing/Form/Upload.php +++ b/CRM/Mailing/Form/Upload.php @@ -214,7 +214,7 @@ class CRM_Mailing_Form_Upload extends CRM_Core_Form { "CRM_Mailing_Controller_Send_{$this->controller->_key}" ); - $fromEmailAddress = CRM_Core_PseudoConstant::fromEmailAddress('from_email_address'); + $fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address'); if (empty($fromEmailAddress)) { //redirect user to enter from email address. $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'group=from_email_address&action=add&reset=1'); @@ -430,7 +430,7 @@ class CRM_Mailing_Form_Upload extends CRM_Core_Form { //handle mailing from name & address. $fromEmailAddress = CRM_Utils_Array::value($formValues['from_email_address'], - CRM_Core_PseudoConstant::fromEmailAddress('from_email_address') + CRM_Core_OptionGroup::values('from_email_address') ); //get the from email address @@ -441,7 +441,7 @@ class CRM_Mailing_Form_Upload extends CRM_Core_Form { //Add Reply-To to headers if (CRM_Utils_Array::value('reply_to_address', $formValues)) { - $replyToEmail = CRM_Core_PseudoConstant::fromEmailAddress('from_email_address'); + $replyToEmail = CRM_Core_OptionGroup::values('from_email_address'); $params['replyto_email'] = CRM_Utils_Array::value($formValues['reply_to_address'], $replyToEmail); } diff --git a/CRM/Mailing/MailStore.php b/CRM/Mailing/MailStore.php index bc8ce2e59c..ee9e8dd5fa 100644 --- a/CRM/Mailing/MailStore.php +++ b/CRM/Mailing/MailStore.php @@ -51,7 +51,7 @@ class CRM_Mailing_MailStore { throw new Exception("Could not find entry named $name in civicrm_mail_settings"); } - $protocols = CRM_Core_PseudoConstant::mailProtocol(); + $protocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); switch ($protocols[$dao->protocol]) { case 'IMAP': diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index da4e4ad680..d790bece25 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -766,7 +766,7 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; // causes a conflict in standalone mode so skip in standalone for now $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?')); $this->add( 'select', 'honor_type_id', ts('Membership payment is : '), - array( '' => ts( '-') ) + CRM_Core_PseudoConstant::honor() ); + array( '' => ts( '-') ) + CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id') ); CRM_Contact_Form_NewContact::buildQuickForm($this,1, null, false,'contribution_'); } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 0733b03dee..f1649a091d 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -500,7 +500,7 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; // causes a conflict in standalone mode so skip in standalone for now $this->addElement('checkbox', 'contribution_contact', ts('Record Payment from a Different Contact?')); $this->add( 'select', 'honor_type_id', ts('Membership payment is : '), - array( '' => ts( '-') ) + CRM_Core_PseudoConstant::honor() ); + array( '' => ts( '-') ) + CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id') ); require_once 'CRM/Contact/Form/NewContact.php'; CRM_Contact_Form_NewContact::buildQuickForm($this,1, null, false,'contribution_'); } diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index 5650664420..5f88e13255 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -548,7 +548,7 @@ GROUP BY currency ) { $honor_block_is_active = TRUE; $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id'); $form->assign('honor_type', $honor[$params['honor_type_id']]); $form->assign('honor_prefix', $prefix[$params['honor_prefix_id']]); $form->assign('honor_first_name', $params['honor_first_name']); diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index fa154f95eb..6cb55a661e 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -257,7 +257,7 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $honorDefault = array(); $idParams = array('contact_id' => $this->_honorID); CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault); - $honorType = CRM_Core_PseudoConstant::honor(); + $honorType = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id'); $defaults['honor_prefix_id'] = $honorDefault['prefix_id']; $defaults['honor_first_name'] = CRM_Utils_Array::value('first_name', $honorDefault); $defaults['honor_last_name'] = CRM_Utils_Array::value('last_name', $honorDefault); diff --git a/CRM/Pledge/Form/PledgeView.php b/CRM/Pledge/Form/PledgeView.php index 617a89e981..715725227b 100644 --- a/CRM/Pledge/Form/PledgeView.php +++ b/CRM/Pledge/Form/PledgeView.php @@ -64,7 +64,7 @@ class CRM_Pledge_Form_PledgeView extends CRM_Core_Form { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid=$values[honor_contact_id]"); $values["honor_display"] = "" . $dao->display_name . ""; } - $honor = CRM_Core_PseudoConstant::honor(); + $honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id'); $values['honor_type'] = $honor[$values['honor_type_id']]; } diff --git a/CRM/Profile/Selector/Listings.php b/CRM/Profile/Selector/Listings.php index 43cded7c3c..1b469d2cec 100644 --- a/CRM/Profile/Selector/Listings.php +++ b/CRM/Profile/Selector/Listings.php @@ -569,7 +569,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile(); $imProviders = CRM_Core_PseudoConstant::IMProvider(); - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $languages = CRM_Core_PseudoConstant::languages(); while ($result->fetch()) { if (isset($result->country)) { diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index e176003aac..c7dadeb5ec 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -149,7 +149,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { 'priority_id' => array('title' => ts('Priority'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::priority(), + 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), ), ), 'group_bys' => diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 48fd7301de..44e3e1b1ae 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -78,7 +78,7 @@ function civicrm_api3_contact_create($params) { } if (!empty($params['home_url'])) { - $websiteTypes = CRM_Core_PseudoConstant::websiteType(); + $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); $params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url'], ), diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index 0389fee30c..feb295d87a 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -50,6 +50,55 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { // - sample: Any one value which is expected in the list of option values. // - max: integer (default = 10) maximum number of option values expected. $fields = array( + 'CRM_Project_DAO_Task' => array( + array( + 'fieldName' => 'priority_id', + 'sample' => 'Urgent', + ), + ), + 'CRM_Activity_DAO_Activity' => array( + array( + 'fieldName' => 'priority_id', + 'sample' => 'Urgent', + ), + ), + 'CRM_Core_DAO_MailSettings' => array( + array( + 'fieldName' => 'protocol', + 'sample' => 'Localdir', + ), + ), + 'CRM_Core_DAO_Mapping' => array( + array( + 'fieldName' => 'mapping_type_id', + 'sample' => 'Search Builder', + 'max' => 15, + ), + ), + 'CRM_Pledge_DAO_Pledge' => array( + array( + 'fieldName' => 'honor_type_id', + 'sample' => 'In Honor of', + ), + ), + 'CRM_Contribute_DAO_Contribution' => array( + array( + 'fieldName' => 'honor_type_id', + 'sample' => 'In Honor of', + ), + ), + 'CRM_Core_DAO_Website' => array( + array( + 'fieldName' => 'website_type_id', + 'sample' => 'Facebook', + ), + ), + 'CRM_Core_DAO_MappingField' => array( + array( + 'fieldName' => 'website_type_id', + 'sample' => 'Facebook', + ), + ), 'CRM_Contact_DAO_Contact' => array( array( 'fieldName' => 'prefix_id', @@ -86,6 +135,18 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'sample' => 'Home', ), ), + 'CRM_Core_DAO_Website' => array( + array( + 'fieldName' => 'website_type_id', + 'sample' => 'Facebook', + ), + ), + 'CRM_Core_DAO_MappingField' => array( + array( + 'fieldName' => 'website_type_id', + 'sample' => 'Facebook', + ), + ), ); foreach ($fields as $daoName => $daoFields) { diff --git a/xml/schema/Activity/Activity.xml b/xml/schema/Activity/Activity.xml index f18c4d324e..7f80e1f923 100644 --- a/xml/schema/Activity/Activity.xml +++ b/xml/schema/Activity/Activity.xml @@ -235,7 +235,6 @@ ID of the priority given to this activity. Foreign key to civicrm_option_value. 2.0 - priority priority diff --git a/xml/schema/Contribute/Contribution.xml b/xml/schema/Contribute/Contribution.xml index 61623ab630..60bd84cade 100644 --- a/xml/schema/Contribute/Contribution.xml +++ b/xml/schema/Contribute/Contribution.xml @@ -334,6 +334,9 @@ Implicit FK to civicrm_option_value. 2.0 SET NULL + + honor_type + index_contribution_status diff --git a/xml/schema/Core/MailSettings.xml b/xml/schema/Core/MailSettings.xml index 39d5726f41..49530292b2 100644 --- a/xml/schema/Core/MailSettings.xml +++ b/xml/schema/Core/MailSettings.xml @@ -62,6 +62,9 @@ 255 name of the protocol to use for polling (like IMAP, POP3 or Maildir) 2.2 + + mail_protocol + server diff --git a/xml/schema/Core/Mapping.xml b/xml/schema/Core/Mapping.xml index 33578409c9..ee570c0fa7 100644 --- a/xml/schema/Core/Mapping.xml +++ b/xml/schema/Core/Mapping.xml @@ -45,6 +45,9 @@ int unsigned Mapping Type 2.1 + + mapping_type + UI_name diff --git a/xml/schema/Core/MappingField.xml b/xml/schema/Core/MappingField.xml index fd6125ba01..c2b67f2dc5 100644 --- a/xml/schema/Core/MappingField.xml +++ b/xml/schema/Core/MappingField.xml @@ -89,6 +89,9 @@ int unsigned Which type of website does this site belong 3.2 + + website_type + relationship_type_id diff --git a/xml/schema/Core/Website.xml b/xml/schema/Core/Website.xml index 6c9a64277e..0305638e4c 100644 --- a/xml/schema/Core/Website.xml +++ b/xml/schema/Core/Website.xml @@ -49,7 +49,6 @@ Which Website type does this website belong to. 3.2 - websiteType website_type diff --git a/xml/schema/Pledge/Pledge.xml b/xml/schema/Pledge/Pledge.xml index b520d8fe5f..4c95b343dd 100644 --- a/xml/schema/Pledge/Pledge.xml +++ b/xml/schema/Pledge/Pledge.xml @@ -213,6 +213,9 @@ Implicit FK to civicrm_option_value. 2.1 SET NULL + + honor_type + max_reminders -- 2.25.1