X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FSelectValues.php;h=d9e63c5246e1f9b9fb958d38118a309f5598beaa;hb=03298d98322f2da05e2ab30cb0e2d5b90df47ab3;hp=089fd4163fa29336c53c296f3697cad0dfedd2a7;hpb=52e1573beda74267e5041a6eed4653829d07f0e3;p=civicrm-core.git diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 089fd4163f..d9e63c5246 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -1,9 +1,9 @@ ts('- select -'), - 'Phone' => ts('Phone'), - 'Mobile' => ts('Mobile'), - 'Fax' => ts('Fax'), - 'Pager' => ts('Pager'), - ); - } - return $phoneType; - } - /** * preferred mail format * @static */ - static function &pmf() { - static $pmf = NULL; - if (!$pmf) { - $pmf = array( - 'Both' => ts('Both'), - 'HTML' => ts('HTML'), - 'Text' => ts('Text'), - ); - } - return $pmf; + static function pmf() { + return array( + 'Both' => ts('Both'), + 'HTML' => ts('HTML'), + 'Text' => ts('Text'), + ); } /** * privacy options * @static */ - static function &privacy() { - static $privacy = NULL; - if (!$privacy) { - $privacy = array( - 'do_not_phone' => ts('Do not phone'), - 'do_not_email' => ts('Do not email'), - 'do_not_mail' => ts('Do not mail'), - 'do_not_sms' => ts('Do not sms'), - 'do_not_trade' => ts('Do not trade'), - 'is_opt_out' => ts('No bulk emails (User Opt Out)'), - ); - } - return $privacy; + static function privacy() { + return array( + 'do_not_phone' => ts('Do not phone'), + 'do_not_email' => ts('Do not email'), + 'do_not_mail' => ts('Do not mail'), + 'do_not_sms' => ts('Do not sms'), + 'do_not_trade' => ts('Do not trade'), + 'is_opt_out' => ts('No bulk emails (User Opt Out)'), + ); } /** * various pre defined contact super types * @static */ - static function &contactType() { + static function contactType() { static $contactType = NULL; if (!$contactType) { $contactType = CRM_Contact_BAO_ContactType::basicTypePairs(); @@ -106,21 +80,14 @@ class CRM_Core_SelectValues { * various pre defined unit list * @static */ - static function &unitList($unitType = NULL) { - static $unitList = NULL; - if (!$unitList) { - $unitList = array( - '' => ts('- select -'), - 'day' => ts('day'), - 'month' => ts('month'), - 'year' => ts('year'), - ); - if ($unitType == 'duration') { - $unitAdd = array( - 'lifetime' => ts('lifetime'), - ); - $unitList = array_merge($unitList, $unitAdd); - } + static function unitList($unitType = NULL) { + $unitList = array( + 'day' => ts('day'), + 'month' => ts('month'), + 'year' => ts('year'), + ); + if ($unitType == 'duration') { + $unitList['lifetime'] = ts('lifetime'); } return $unitList; } @@ -130,108 +97,67 @@ class CRM_Core_SelectValues { * @static */ static function membershipTypeUnitList( ) { - static $membershipTypeUnitList = NULL; - if (!$membershipTypeUnitList) { - $membershipTypeUnitList = self::unitList('duration'); - } - return $membershipTypeUnitList; + return self::unitList('duration'); } /** * various pre defined period types * @static */ - static function &periodType() { - static $periodType = NULL; - if (!$periodType) { - $periodType = array( - '' => ts('- select -'), - 'rolling' => ts('Rolling'), - 'fixed' => ts('Fixed'), - ); - } - return $periodType; + static function periodType() { + return array( + 'rolling' => ts('Rolling'), + 'fixed' => ts('Fixed'), + ); } /** * various pre defined member visibility options * @static */ - static function &memberVisibility() { - static $visible = NULL; - if (!$visible) { - $visible = array( - 'Public' => ts('Public'), - 'Admin' => ts('Admin'), - ); - } - return $visible; + static function memberVisibility() { + return array( + 'Public' => ts('Public'), + 'Admin' => ts('Admin'), + ); } /** * various pre defined event dates * @static */ - static function &eventDate() { - static $eventDate = NULL; - if (!$eventDate) { - $eventDate = array( - '' => ts('- select -'), - 'start_date' => ts('start date'), - 'end_date' => ts('end date'), - 'join_date' => ts('member since'), - ); - } - return $eventDate; - } - - /** - * Extended property (custom field) data types - * @static - */ - static function &customDataType() { - static $customDataType = NULL; - if (!$customDataType) { - $customDataType = array( - '' => ts('- select -'), - 'String' => ts('Text'), - 'Int' => ts('Integer'), - 'Float' => ts('Decimal Number'), - 'Money' => ts('Money'), - 'Text' => ts('Memo'), - 'Date' => ts('Date'), - 'File' => ts('File'), - 'Boolean' => ts('Yes/No'), - 'Link' => ts('Link'), - 'Auto-complete' => ts('Auto-complete'), - ); - } - return $customDataType; + static function eventDate() { + return array( + 'start_date' => ts('start date'), + 'end_date' => ts('end date'), + 'join_date' => ts('member since'), + ); } /** * Custom form field types * @static */ - static function &customHtmlType() { - static $customHtmlType = NULL; - if (!$customHtmlType) { - $customHtmlType = array( - '' => ts('- select -'), - 'Text' => ts('Single-line input field (text or numeric)'), - 'TextArea' => ts('Multi-line text box (textarea)'), - 'Select' => ts('Drop-down (select list)'), - 'Radio' => ts('Radio buttons'), - 'Checkbox' => ts('Checkbox(es)'), - 'Select Date' => ts('Date selector'), - 'File' => ts('File'), - 'Select State / Province' => ts('State / Province selector'), - 'Select Country' => ts('Country selector'), - 'RichTextEditor' => ts('Rich Text Editor'), - 'Auto-complete' => ts('Contact Reference'), - ); - } - return $customHtmlType; + static function customHtmlType() { + return array( + 'Text' => ts('Single-line input field (text or numeric)'), + 'TextArea' => ts('Multi-line text box (textarea)'), + 'Select' => ts('Drop-down (select list)'), + 'Radio' => ts('Radio buttons'), + 'CheckBox' => ts('Checkbox(es)'), + 'Select Date' => ts('Select Date'), + 'File' => ts('File'), + 'Select State/Province' => ts('Select State/Province'), + 'Multi-Select State/Province' => ts('Multi-Select State/Province'), + 'Select Country' => ts('Select Country'), + 'Multi-Select Country' => ts('Multi-Select Country'), + 'RichTextEditor' => ts('Rich Text Editor'), + 'Autocomplete-Select' => ts('Autocomplete-Select'), + 'Multi-Select' => ts('Multi-Select'), + 'AdvMulti-Select' => ts('AdvMulti-Select'), + 'Link' => ts('Link'), + 'ContactReference' => ts('Autocomplete Select'), + ); } /** @@ -239,30 +165,27 @@ class CRM_Core_SelectValues { * * @static */ - static function &customGroupExtends() { - static $customGroupExtends = NULL; - if (!$customGroupExtends) { - $customGroupExtends = array( - 'Activity' => ts('Activities'), - 'Relationship' => ts('Relationships'), - 'Contribution' => ts('Contributions'), - 'Group' => ts('Groups'), - 'Membership' => ts('Memberships'), - 'Event' => ts('Events'), - 'Participant' => ts('Participants'), - 'ParticipantRole' => ts('Participants (Role)'), - 'ParticipantEventName' => ts('Participants (Event Name)'), - 'ParticipantEventType' => ts('Participants (Event Type)'), - 'Pledge' => ts('Pledges'), - 'Grant' => ts('Grants'), - 'Address' => ts('Addresses'), - 'Campaign' => ts('Campaigns'), - ); - $contactTypes = self::contactType(); - $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); - $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects'); - $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs); - } + static function customGroupExtends() { + $customGroupExtends = array( + 'Activity' => ts('Activities'), + 'Relationship' => ts('Relationships'), + 'Contribution' => ts('Contributions'), + 'Group' => ts('Groups'), + 'Membership' => ts('Memberships'), + 'Event' => ts('Events'), + 'Participant' => ts('Participants'), + 'ParticipantRole' => ts('Participants (Role)'), + 'ParticipantEventName' => ts('Participants (Event Name)'), + 'ParticipantEventType' => ts('Participants (Event Type)'), + 'Pledge' => ts('Pledges'), + 'Grant' => ts('Grants'), + 'Address' => ts('Addresses'), + 'Campaign' => ts('Campaigns'), + ); + $contactTypes = self::contactType(); + $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); + $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects'); + $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs); return $customGroupExtends; } @@ -271,16 +194,12 @@ class CRM_Core_SelectValues { * * @static */ - static function &customGroupStyle() { - static $customGroupStyle = NULL; - if (!$customGroupStyle) { - $customGroupStyle = array( - 'Tab' => ts('Tab'), - 'Inline' => ts('Inline'), - 'Tab with table' => ts('Tab with table') - ); - } - return $customGroupStyle; + static function customGroupStyle() { + return array( + 'Tab' => ts('Tab'), + 'Inline' => ts('Inline'), + 'Tab with table' => ts('Tab with table'), + ); } /** @@ -288,20 +207,17 @@ class CRM_Core_SelectValues { * * @static */ - static function &ufGroupTypes() { - static $ufGroupType = NULL; - if (!$ufGroupType) { - $ufGroupType = array( - 'Profile' => ts('Standalone Form or Directory'), - 'Search Profile' => ts('Search Views'), + static function ufGroupTypes() { + $ufGroupType = array( + 'Profile' => ts('Standalone Form or Directory'), + 'Search Profile' => ts('Search Views'), + ); + + if (CRM_Core_Config::singleton()->userSystem->supports_form_extensions) { + $ufGroupType += array( + 'User Registration' => ts('Drupal User Registration'), + 'User Account' => ts('View/Edit Drupal User Account'), ); - $config = CRM_Core_Config::singleton(); - if ($config->userSystem->supports_form_extensions) { - $ufGroupType += array( - 'User Registration' => ts('Drupal User Registration'), - 'User Account' => ts('View/Edit Drupal User Account'), - ); - } } return $ufGroupType; } @@ -311,43 +227,38 @@ class CRM_Core_SelectValues { * * @static */ - static function &groupContactStatus() { - static $groupContactStatus = NULL; - if (!$groupContactStatus) { - $groupContactStatus = array( - 'Added' => ts('Added'), - 'Removed' => ts('Removed'), - 'Pending' => ts('Pending'), - ); - } - return $groupContactStatus; + static function groupContactStatus() { + return array( + 'Added' => ts('Added'), + 'Removed' => ts('Removed'), + 'Pending' => ts('Pending'), + ); } /** * list of Group Types * @static */ - static function &groupType() { - static $groupType = NULL; - if (!$groupType) { - $groupType = array( - 'query' => ts('Dynamic'), - 'static' => ts('Static'), - ); - } - return $groupType; + static function groupType() { + return array( + 'query' => ts('Dynamic'), + 'static' => ts('Static'), + ); } /** * compose the parameters for a date select object * - * @param $type the type of date - * @param $format date format ( QF format) + * @param string|NULL $type the type of date + * @param string|NULL $format date format ( QF format) + * + * @param null $minOffset + * @param null $maxOffset * * @return array the date array * @static */ - static function &date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) { + static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) { $date = array( 'addEmptyOption' => TRUE, @@ -381,7 +292,7 @@ class CRM_Core_SelectValues { } } - $year = date('Y'); + $year = date('Y'); $date['minYear'] = $year - $minOffset; $date['maxYear'] = $year + $maxOffset; return $date; @@ -392,19 +303,12 @@ class CRM_Core_SelectValues { * * @static */ - static function ufVisibility($isGroup = FALSE) { - static $_visibility = NULL; - if (!$_visibility) { - $_visibility = array( - 'User and User Admin Only' => ts('User and User Admin Only'), - 'Public Pages' => ts('Public Pages'), - 'Public Pages and Listings' => ts('Public Pages and Listings'), - ); - if ($isGroup) { - unset($_visibility['Public Pages and Listings']); - } - } - return $_visibility; + static function ufVisibility() { + return array( + 'User and User Admin Only' => ts('User and User Admin Only'), + 'Public Pages' => ts('Public Pages'), + 'Public Pages and Listings' => ts('Public Pages and Listings'), + ); } /** @@ -413,11 +317,10 @@ class CRM_Core_SelectValues { * @static */ static function groupVisibility() { - static $_groupVisibility = NULL; - if (!$_groupVisibility) { - $_groupVisibility = self::ufVisibility(true); - } - return $_groupVisibility; + return array( + 'User and User Admin Only' => ts('User and User Admin Only'), + 'Public Pages' => ts('Public Pages'), + ); } /** @@ -426,21 +329,16 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &mailingComponents() { - static $components = NULL; - - if (!$components) { - $components = array('Header' => ts('Header'), - 'Footer' => ts('Footer'), - 'Reply' => ts('Reply Auto-responder'), - 'OptOut' => ts('Opt-out Message'), - 'Subscribe' => ts('Subscription Confirmation Request'), - 'Welcome' => ts('Welcome Message'), - 'Unsubscribe' => ts('Unsubscribe Message'), - 'Resubscribe' => ts('Resubscribe Message'), - ); - } - return $components; + static function mailingComponents() { + return array('Header' => ts('Header'), + 'Footer' => ts('Footer'), + 'Reply' => ts('Reply Auto-responder'), + 'OptOut' => ts('Opt-out Message'), + 'Subscribe' => ts('Subscription Confirmation Request'), + 'Welcome' => ts('Welcome Message'), + 'Unsubscribe' => ts('Unsubscribe Message'), + 'Resubscribe' => ts('Resubscribe Message'), + ); } /** @@ -450,6 +348,7 @@ class CRM_Core_SelectValues { * @static */ function getHours() { + $hours = array(); for ($i = 0; $i <= 6; $i++) { $hours[$i] = $i; } @@ -463,6 +362,7 @@ class CRM_Core_SelectValues { * @static */ function getMinutes() { + $minutes = array(); for ($i = 0; $i < 60; $i = $i + 15) { $minutes[$i] = $i; } @@ -478,7 +378,7 @@ class CRM_Core_SelectValues { static function mapProvider() { static $map = NULL; if (!$map) { - return CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl"); + $map = CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl"); } return $map; } @@ -492,7 +392,7 @@ class CRM_Core_SelectValues { static function geoProvider() { static $geo = NULL; if (!$geo) { - return CRM_Utils_System::getPluginList('CRM/Utils/Geocode'); + $geo = CRM_Utils_System::getPluginList('CRM/Utils/Geocode'); } return $geo; } @@ -507,10 +407,7 @@ class CRM_Core_SelectValues { static function addressProvider() { static $addr = NULL; if (!$addr) { - return CRM_Utils_System::getPluginList('CRM/Utils/Address', - '.php', - array('BatchUpdate') - ); + $addr = CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate')); } return $addr; } @@ -521,29 +418,25 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &mailingTokens() { - static $tokens = NULL; - - if (!$tokens) { - $tokens = array('{action.unsubscribe}' => ts('Unsubscribe via email'), - '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'), - '{action.resubscribe}' => ts('Resubscribe via email'), - '{action.resubscribeUrl}' => ts('Resubscribe via web page'), - '{action.optOut}' => ts('Opt out via email'), - '{action.optOutUrl}' => ts('Opt out via web page'), - '{action.forward}' => ts('Forward this email (link)'), - '{action.reply}' => ts('Reply to this email (link)'), - '{action.subscribeUrl}' => ts('Subscribe via web page'), - '{domain.name}' => ts('Domain name'), - '{domain.address}' => ts('Domain (organization) address'), - '{domain.phone}' => ts('Domain (organization) phone'), - '{domain.email}' => ts('Domain (organization) email'), - '{mailing.name}' => ts('Mailing name'), - '{mailing.group}' => ts('Mailing group'), - '{mailing.viewUrl}' => ts('Mailing permalink'), - ); - } - return $tokens; + static function mailingTokens() { + return array( + '{action.unsubscribe}' => ts('Unsubscribe via email'), + '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'), + '{action.resubscribe}' => ts('Resubscribe via email'), + '{action.resubscribeUrl}' => ts('Resubscribe via web page'), + '{action.optOut}' => ts('Opt out via email'), + '{action.optOutUrl}' => ts('Opt out via web page'), + '{action.forward}' => ts('Forward this email (link)'), + '{action.reply}' => ts('Reply to this email (link)'), + '{action.subscribeUrl}' => ts('Subscribe via web page'), + '{domain.name}' => ts('Domain name'), + '{domain.address}' => ts('Domain (organization) address'), + '{domain.phone}' => ts('Domain (organization) phone'), + '{domain.email}' => ts('Domain (organization) email'), + '{mailing.name}' => ts('Mailing name'), + '{mailing.group}' => ts('Mailing group'), + '{mailing.viewUrl}' => ts('Mailing permalink'), + ); } /** @@ -552,18 +445,13 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &activityTokens() { - static $tokens = NULL; - - if (!$tokens) { - $tokens = array( - '{activity.activity_id}' => ts('Activity ID'), - '{activity.subject}' => ts('Activity Subject'), - '{activity.details}' => ts('Activity Details'), - '{activity.activity_date_time}' => ts('Activity Date Time'), - ); - } - return $tokens; + static function activityTokens() { + return array( + '{activity.activity_id}' => ts('Activity ID'), + '{activity.subject}' => ts('Activity Subject'), + '{activity.details}' => ts('Activity Details'), + '{activity.activity_date_time}' => ts('Activity Date Time'), + ); } /** @@ -572,21 +460,16 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &membershipTokens() { - static $tokens = NULL; - - if (!$tokens) { - $tokens = array( - '{membership.id}' => ts('Membership ID'), - '{membership.status}' => ts('Membership Status'), - '{membership.type}' => ts('Membership Type'), - '{membership.start_date}' => ts('Membership Start Date'), - '{membership.join_date}' => ts('Membership Join Date'), - '{membership.end_date}' => ts('Membership End Date'), - '{membership.fee}' => ts('Membership Fee'), - ); - } - return $tokens; + static function membershipTokens() { + return array( + '{membership.id}' => ts('Membership ID'), + '{membership.status}' => ts('Membership Status'), + '{membership.type}' => ts('Membership Type'), + '{membership.start_date}' => ts('Membership Start Date'), + '{membership.join_date}' => ts('Membership Join Date'), + '{membership.end_date}' => ts('Membership End Date'), + '{membership.fee}' => ts('Membership Fee'), + ); } /** @@ -595,30 +478,23 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &eventTokens() { - static $tokens = NULL; - - if (!$tokens) { - $tokens = array( - '{event.event_id}' => ts('Event ID'), - '{event.title}' => ts('Event Title'), - '{event.start_date}' => ts('Event Start Date'), - '{event.end_date}' => ts('Event End Date'), - '{event.event_type}' => ts('Event Type'), - '{event.summary}' => ts('Event Summary'), - '{event.description}' => ts('Event Description'), - '{event.contact_email}' => ts('Event Contact Email'), - '{event.contact_phone}' => ts('Event Contact Phone'), - '{event.location}' => ts('Event Location'), - '{event.description}' => ts('Event Description'), - '{event.location}' => ts('Event Location'), - '{event.fee_amount}' => ts('Event Fees'), - '{event.info_url}' => ts('Event Info URL'), - '{event.registration_url}' => ts('Event Registration URL'), - '{event.balance}' => ts('Event Balance') - ); - } - return $tokens; + static function eventTokens() { + return array( + '{event.event_id}' => ts('Event ID'), + '{event.title}' => ts('Event Title'), + '{event.start_date}' => ts('Event Start Date'), + '{event.end_date}' => ts('Event End Date'), + '{event.event_type}' => ts('Event Type'), + '{event.summary}' => ts('Event Summary'), + '{event.contact_email}' => ts('Event Contact Email'), + '{event.contact_phone}' => ts('Event Contact Phone'), + '{event.description}' => ts('Event Description'), + '{event.location}' => ts('Event Location'), + '{event.fee_amount}' => ts('Event Fees'), + '{event.info_url}' => ts('Event Info URL'), + '{event.registration_url}' => ts('Event Registration URL'), + '{event.balance}' => ts('Event Balance') + ); } /** @@ -627,37 +503,32 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &contributionTokens() { - static $tokens = NULL; - - if (!$tokens) { - $tokens = array( - '{contribution.contribution_id}' => ts('Contribution ID'), - '{contribution.total_amount}' => ts('Total Amount'), - '{contribution.fee_amount}' => ts('Fee Amount'), - '{contribution.net_amount}' => ts('Net Amount'), - '{contribution.non_deductible_amount}' => ts('Non Deductible Amount'), - '{contribution.receive_date}' => ts('Contribution Receive Date'), - '{contribution.payment_instrument}' => ts('Payment Instrument'), - '{contribution.trxn_id}' => ts('Transaction ID'), - '{contribution.invoice_id}' => ts('Invoice ID'), - '{contribution.currency}' => ts('Currency'), - '{contribution.cancel_date}' => ts('Contribution Cancel Date'), - '{contribution.cancel_reason}' => ts('Contribution Cancel Reason'), - '{contribution.receipt_date}' => ts('Receipt Date'), - '{contribution.thankyou_date}' => ts('Thank You Date'), - '{contribution.contribution_source}' => ts('Contribution Source'), - '{contribution.amount_level}' => ts('Amount Level'), - //'{contribution.contribution_recur_id}' => ts('Contribution Recurring ID'), - //'{contribution.honor_contact_id}' => ts('Honor Contact ID'), - '{contribution.contribution_status_id}' => ts('Contribution Status'), - //'{contribution.honor_type_id}' => ts('Honor Type ID'), - //'{contribution.address_id}' => ts('Address ID'), - '{contribution.check_number}' => ts('Check Number'), - '{contribution.campaign}' => ts('Contribution Campaign'), - ); - } - return $tokens; + static function contributionTokens() { + return array( + '{contribution.contribution_id}' => ts('Contribution ID'), + '{contribution.total_amount}' => ts('Total Amount'), + '{contribution.fee_amount}' => ts('Fee Amount'), + '{contribution.net_amount}' => ts('Net Amount'), + '{contribution.non_deductible_amount}' => ts('Non Deductible Amount'), + '{contribution.receive_date}' => ts('Contribution Receive Date'), + '{contribution.payment_instrument}' => ts('Payment Instrument'), + '{contribution.trxn_id}' => ts('Transaction ID'), + '{contribution.invoice_id}' => ts('Invoice ID'), + '{contribution.currency}' => ts('Currency'), + '{contribution.cancel_date}' => ts('Contribution Cancel Date'), + '{contribution.cancel_reason}' => ts('Contribution Cancel Reason'), + '{contribution.receipt_date}' => ts('Receipt Date'), + '{contribution.thankyou_date}' => ts('Thank You Date'), + '{contribution.contribution_source}' => ts('Contribution Source'), + '{contribution.amount_level}' => ts('Amount Level'), + //'{contribution.contribution_recur_id}' => ts('Contribution Recurring ID'), + //'{contribution.honor_contact_id}' => ts('Honor Contact ID'), + '{contribution.contribution_status_id}' => ts('Contribution Status'), + //'{contribution.honor_type_id}' => ts('Honor Type ID'), + //'{contribution.address_id}' => ts('Address ID'), + '{contribution.check_number}' => ts('Check Number'), + '{contribution.campaign}' => ts('Contribution Campaign'), + ); } /** @@ -666,7 +537,7 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &contactTokens() { + static function contactTokens() { static $tokens = NULL; if (!$tokens) { $additionalFields = array('checksum' => array('title' => ts('Checksum')), @@ -683,9 +554,9 @@ class CRM_Core_SelectValues { 'is_deceased', 'deceased_date', 'legal_identifier', 'contact_sub_type', 'user_unique_id', ); - $customFields = CRM_Core_BAO_CustomField::getFields('Individual'); + $customFields = CRM_Core_BAO_CustomField::getFields('Individual'); $customFieldsAddress = CRM_Core_BAO_CustomField::getFields('Address'); - $customFields = $customFields + $customFieldsAddress; + $customFields = $customFields + $customFieldsAddress; $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens()); foreach ($values as $val) { @@ -706,7 +577,7 @@ class CRM_Core_SelectValues { // might as well get all the hook tokens to $hookTokens = array(); CRM_Utils_Hook::tokens($hookTokens); - foreach ($hookTokens as $category => $tokenValues) { + foreach ($hookTokens as $tokenValues) { foreach ($tokenValues as $key => $value) { if (is_numeric($key)) { $key = $value; @@ -731,7 +602,7 @@ class CRM_Core_SelectValues { * @static * return array */ - static function &participantTokens() { + static function participantTokens() { static $tokens = NULL; if (!$tokens) { $exportFields = CRM_Event_BAO_Participant::exportableFields(); @@ -763,35 +634,6 @@ class CRM_Core_SelectValues { return $tokens; } - /** - * get qf mappig for all date parts. - * - */ - static function &qfDatePartsMapping() { - static $qfDatePartsMapping = NULL; - if (!$qfDatePartsMapping) { - $qfDatePartsMapping = array( - '%b' => 'M', - '%B' => 'F', - '%d' => 'd', - '%e' => 'j', - '%E' => 'j', - '%f' => 'S', - '%H' => 'H', - '%I' => 'h', - '%k' => 'G', - '%l' => 'g', - '%m' => 'm', - '%M' => 'i', - '%p' => 'a', - '%P' => 'A', - '%Y' => 'Y', - ); - } - - return $qfDatePartsMapping; - } - /** * CiviCRM supported date input formats */ @@ -859,10 +701,10 @@ class CRM_Core_SelectValues { * Time formats */ static function getTimeFormats() { - $timeFormats = array('1' => ts('12 Hours'), + return array( + '1' => ts('12 Hours'), '2' => ts('24 Hours'), ); - return $timeFormats; } /** @@ -872,6 +714,7 @@ class CRM_Core_SelectValues { * @static */ public static function getNumericOptions($start = 0, $end = 10) { + $numericOptions = array(); for ($i = $start; $i <= $end; $i++) { $numericOptions[$i] = $i; } @@ -883,137 +726,100 @@ class CRM_Core_SelectValues { * @static */ static function getBarcodeTypes() { - static $barcodeTypes = NULL; - if (!$barcodeTypes) { - $barcodeTypes = array( - 'barcode' => ts('Linear (1D)'), - 'qrcode' => ts('QR code'), - ); - } - return $barcodeTypes; + return array( + 'barcode' => ts('Linear (1D)'), + 'qrcode' => ts('QR code'), + ); } /** * dedupe rule types */ static function getDedupeRuleTypes() { - static $dedupeRuleTypes = NULL; - if (!$dedupeRuleTypes) { - $dedupeRuleTypes = array( - 'Unsupervised' => ts('Unsupervised'), - 'Supervised' => ts('Supervised'), - 'General' => ts('General'), - ); - } - return $dedupeRuleTypes; + return array( + 'Unsupervised' => ts('Unsupervised'), + 'Supervised' => ts('Supervised'), + 'General' => ts('General'), + ); } /** * campaign group types */ static function getCampaignGroupTypes() { - static $campaignGroupTypes = NULL; - if (!$campaignGroupTypes) { - $campaignGroupTypes = array( - 'Include' => ts('Include'), - 'Exclude' => ts('Exclude'), - ); - } - return $campaignGroupTypes; + return array( + 'Include' => ts('Include'), + 'Exclude' => ts('Exclude'), + ); } /** * subscription history method */ static function getSubscriptionHistoryMethods() { - static $subscriptionHistoryMethods = NULL; - if (!$subscriptionHistoryMethods) { - $subscriptionHistoryMethods = array( - 'Admin' => ts('Admin'), - 'Email' => ts('Email'), - 'Web' => ts('Web'), - 'API' => ts('API'), - ); - } - - return $subscriptionHistoryMethods; + return array( + 'Admin' => ts('Admin'), + 'Email' => ts('Email'), + 'Web' => ts('Web'), + 'API' => ts('API'), + ); } /** * premium units */ static function getPremiumUnits() { - static $premiumUnits = NULL; - if (!$premiumUnits) { - $premiumUnits = array( - 'day' => ts('Day'), - 'week' => ts('Week'), - 'month' => ts('Month'), - 'year' => ts('Year'), - ); - } - - return $premiumUnits; + return array( + 'day' => ts('Day'), + 'week' => ts('Week'), + 'month' => ts('Month'), + 'year' => ts('Year'), + ); } /** * extension types */ static function getExtensionTypes() { - static $extensionTypes = NULL; - if (!$extensionTypes) { - $extensionTypes = array( - 'payment' => ts('Payment'), - 'search' => ts('Search'), - 'report' => ts('Report'), - 'module' => ts('Module'), - 'sms' => ts('SMS'), - ); - } - - return $extensionTypes; + return array( + 'payment' => ts('Payment'), + 'search' => ts('Search'), + 'report' => ts('Report'), + 'module' => ts('Module'), + 'sms' => ts('SMS'), + ); } /** * job frequency */ static function getJobFrequency() { - static $jobFrequency = NULL; - if (!$jobFrequency) { - $jobFrequency = array( - 'Daily' => ts('Daily'), - 'Hourly' => ts('Hourly'), - 'Always' => ts('Every time cron job is run'), - ); - } - - return $jobFrequency; + return array( + 'Daily' => ts('Daily'), + 'Hourly' => ts('Hourly'), + 'Always' => ts('Every time cron job is run'), + ); } /** * Search builder operators */ static function getSearchBuilderOperators() { - static $searchBuilderOperators = NULL; - if (!$searchBuilderOperators) { - $searchBuilderOperators = array( - '=' => '=', - '!=' => '≠', - '>' => '>', - '<' => '<', - '>=' => '≥', - '<=' => '≤', - 'IN' => ts('In'), - 'LIKE' => ts('Like'), - 'RLIKE' => ts('Regex'), - 'IS EMPTY' => ts('Is Empty'), - 'IS NOT EMPTY' => ts('Not Empty'), - 'IS NULL' => ts('Is Null'), - 'IS NOT NULL' => ts('Not Null'), - ); - } - - return $searchBuilderOperators; + return array( + '=' => '=', + '!=' => '≠', + '>' => '>', + '<' => '<', + '>=' => '≥', + '<=' => '≤', + 'IN' => ts('In'), + 'LIKE' => ts('Like'), + 'RLIKE' => ts('Regex'), + 'IS EMPTY' => ts('Is Empty'), + 'IS NOT EMPTY' => ts('Not Empty'), + 'IS NULL' => ts('Is Null'), + 'IS NOT NULL' => ts('Not Null'), + ); } /** @@ -1022,18 +828,16 @@ class CRM_Core_SelectValues { * @static */ static function getProfileGroupType() { - static $profileGroupType = NULL; - if (!$profileGroupType) { - $profileGroupType = array( - 'Activity' => ts('Activities'), - 'Contribution' => ts('Contributions'), - 'Membership' => ts('Memberships'), - 'Participant' => ts('Participants'), - ); - $contactTypes = self::contactType(); - $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); - $profileGroupType = array_merge($contactTypes, $profileGroupType ); - } + $profileGroupType = array( + 'Activity' => ts('Activities'), + 'Contribution' => ts('Contributions'), + 'Membership' => ts('Memberships'), + 'Participant' => ts('Participants'), + ); + $contactTypes = self::contactType(); + $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); + $profileGroupType = array_merge($contactTypes, $profileGroupType ); + return $profileGroupType; } @@ -1042,49 +846,48 @@ class CRM_Core_SelectValues { * word replacement match type */ static function getWordReplacementMatchType() { - static $wordReplacementMatchType = NULL; - if (!$wordReplacementMatchType) { - $wordReplacementMatchType = array( + return array( 'exactMatch' => ts('Exact Match'), 'wildcardMatch' => ts('Wildcard Match'), ); - } - - return $jobFrequency; } /** * mailing group types */ static function getMailingGroupTypes() { - static $mailingGroupTypes = NULL; - if (!$mailingGroupTypes) { - $mailingGroupTypes = array( - 'Include' => ts('Include'), - 'Exclude' => ts('Exclude'), - 'Base' => ts('Base'), - ); - } - return $mailingGroupTypes; + return array( + 'Include' => ts('Include'), + 'Exclude' => ts('Exclude'), + 'Base' => ts('Base'), + ); } /** * Mailing Job Status */ - static function geMailingJobStatus() { - static $mailingJobStatus = NULL; - if (!$mailingJobStatus) { - $mailingJobStatus = array( - 'Scheduled' => ts('Scheduled'), - 'Running' => ts('Running'), - 'Complete' => ts('Complete'), - 'Paused' => ts('Paused'), - 'Canceled' => ts('Canceled'), - ); + static function getMailingJobStatus() { + return array( + 'Scheduled' => ts('Scheduled'), + 'Running' => ts('Running'), + 'Complete' => ts('Complete'), + 'Paused' => ts('Paused'), + 'Canceled' => ts('Canceled'), + ); + } + + /** + * Frequency unit for schedule reminders + */ + static function getScheduleReminderFrequencyUnits() { + //@todo update schema to refer to option group direct & remove this + static $scheduleReminderFrequencyUnits = NULL; + if (!$scheduleReminderFrequencyUnits) { + $scheduleReminderFrequencyUnits = array( + 'hour' => ts('hour')) + CRM_Core_OptionGroup::values('recur_frequency_units'); } - return $mailingJobStatus; + return $scheduleReminderFrequencyUnits; } - }