+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* smart caching scheme on a per domain basis
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/
* @return array
*/
public static function boolean() {
- return array(
+ return [
1 => ts('Yes'),
0 => ts('No'),
- );
+ ];
}
/**
* @return array
*/
public static function pmf() {
- return array(
+ return [
'Both' => ts('Both'),
'HTML' => ts('HTML'),
'Text' => ts('Text'),
- );
+ ];
}
/**
* @return array
*/
public static function privacy() {
- return array(
+ return [
'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 array
*/
public static function unitList($unitType = NULL) {
- $unitList = array(
+ $unitList = [
'day' => ts('day'),
'month' => ts('month'),
'year' => ts('year'),
- );
+ ];
if ($unitType == 'duration') {
$unitList['lifetime'] = ts('lifetime');
}
* @return array
*/
public static function periodType() {
- return array(
+ return [
'rolling' => ts('Rolling'),
'fixed' => ts('Fixed'),
- );
+ ];
}
/**
* @return array
*/
public static function emailSelectMethods() {
- return array(
+ return [
'automatic' => ts("Automatic"),
'location-only' => ts("Only send to email addresses assigned to the specified location"),
'location-prefer' => ts("Prefer email addresses assigned to the specified location"),
'location-exclude' => ts("Exclude email addresses assigned to the specified location"),
- );
+ ];
}
/**
* @return array
*/
public static function memberVisibility() {
- return array(
+ return [
'Public' => ts('Public'),
'Admin' => ts('Admin'),
- );
+ ];
}
/**
* @return array
*/
public static function memberAutoRenew() {
- return array(
+ return [
ts('No auto-renew option'),
ts('Give option, but not required'),
ts('Auto-renew required'),
- );
+ ];
}
/**
* @return array
*/
public static function eventDate() {
- return array(
+ return [
'start_date' => ts('start date'),
'end_date' => ts('end date'),
'join_date' => ts('member since'),
- );
+ ];
}
/**
* @return array
*/
public static function customHtmlType() {
- return array(
+ return [
'Text' => ts('Single-line input field (text or numeric)'),
'TextArea' => ts('Multi-line text box (textarea)'),
'Select' => ts('Drop-down (select list)'),
'Multi-Select' => ts('Multi-Select'),
'Link' => ts('Link'),
'ContactReference' => ts('Autocomplete-Select'),
- );
+ ];
}
/**
*
*/
public static function customGroupExtends() {
- $customGroupExtends = array(
+ $customGroupExtends = [
'Activity' => ts('Activities'),
'Relationship' => ts('Relationships'),
'Contribution' => ts('Contributions'),
'Grant' => ts('Grants'),
'Address' => ts('Addresses'),
'Campaign' => ts('Campaigns'),
- );
+ ];
$contactTypes = self::contactType();
- $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
+ $contactTypes = !empty($contactTypes) ? ['Contact' => 'Contacts'] + $contactTypes : [];
$extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects');
$customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs);
return $customGroupExtends;
* @return array
*/
public static function customGroupStyle() {
- return array(
+ return [
'Tab' => ts('Tab'),
'Inline' => ts('Inline'),
'Tab with table' => ts('Tab with table'),
- );
+ ];
}
/**
* @return array
*/
public static function ufGroupTypes() {
- $ufGroupType = array(
+ $ufGroupType = [
'Profile' => ts('Standalone Form or Directory'),
'Search Profile' => ts('Search Views'),
- );
+ ];
if (CRM_Core_Config::singleton()->userSystem->supports_form_extensions) {
- $ufGroupType += array(
+ $ufGroupType += [
'User Registration' => ts('Drupal User Registration'),
'User Account' => ts('View/Edit Drupal User Account'),
- );
+ ];
}
return $ufGroupType;
}
* @return array
*/
public static function groupContactStatus() {
- return array(
+ return [
'Added' => ts('Added'),
'Removed' => ts('Removed'),
'Pending' => ts('Pending'),
- );
+ ];
}
/**
* @return array
*/
public static function groupType() {
- return array(
+ return [
'query' => ts('Dynamic'),
'static' => ts('Static'),
- );
+ ];
}
/**
* date format (QF format)
* @param null $minOffset
* @param null $maxOffset
- *
+ * @param string $context
* @return array
* the date array
*/
public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL, $context = 'display') {
// These options are deprecated. Definitely not used in datepicker. Possibly not even in jcalendar+addDateTime.
- $date = array(
+ $date = [
'addEmptyOption' => TRUE,
'emptyOptionText' => ts('- select -'),
'emptyOptionValue' => '',
- );
+ ];
if ($format) {
$date['format'] = $format;
* @return array
*/
public static function ufVisibility() {
- return array(
+ return [
'User and User Admin Only' => ts('User and User Admin Only'),
'Public Pages' => ts('Expose Publicly'),
'Public Pages and Listings' => ts('Expose Publicly and for Listings'),
- );
+ ];
}
/**
* @return array
*/
public static function groupVisibility() {
- return array(
+ return [
'User and User Admin Only' => ts('User and User Admin Only'),
'Public Pages' => ts('Public Pages'),
- );
+ ];
}
/**
* @return array
*/
public static function mailingComponents() {
- return array(
+ return [
'Header' => ts('Header'),
'Footer' => ts('Footer'),
'Reply' => ts('Reply Auto-responder'),
'Welcome' => ts('Welcome Message'),
'Unsubscribe' => ts('Unsubscribe Message'),
'Resubscribe' => ts('Resubscribe Message'),
- );
+ ];
}
/**
* @return array
*/
public function getHours() {
- $hours = array();
+ $hours = [];
for ($i = 0; $i <= 6; $i++) {
$hours[$i] = $i;
}
* @return array
*/
public function getMinutes() {
- $minutes = array();
+ $minutes = [];
for ($i = 0; $i < 60; $i = $i + 15) {
$minutes[$i] = $i;
}
public static function mapProvider() {
static $map = NULL;
if (!$map) {
- $map = array('' => '- select -') + CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl");
+ $map = ['' => '- select -'] + CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl");
}
return $map;
}
public static function geoProvider() {
static $geo = NULL;
if (!$geo) {
- $geo = array('' => '- select -') + CRM_Utils_System::getPluginList('CRM/Utils/Geocode');
+ $geo = ['' => '- select -'] + CRM_Utils_System::getPluginList('CRM/Utils/Geocode');
}
return $geo;
}
public static function addressProvider() {
static $addr = NULL;
if (!$addr) {
- $addr = CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate'));
+ $addr = array_merge(['' => '- select -'], CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', ['BatchUpdate']));
}
return $addr;
}
* @return array
*/
public static function mailingTokens() {
- return array(
+ return [
'{action.unsubscribe}' => ts('Unsubscribe via email'),
'{action.unsubscribeUrl}' => ts('Unsubscribe via web page'),
'{action.resubscribe}' => ts('Resubscribe via email'),
'{mailing.name}' => ts('Mailing name'),
'{mailing.group}' => ts('Mailing group'),
'{mailing.viewUrl}' => ts('Mailing permalink'),
- );
+ ];
}
/**
* @return array
*/
public static function activityTokens() {
- return array(
+ return [
'{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 array
*/
public static function membershipTokens() {
- return array(
+ return [
'{membership.id}' => ts('Membership ID'),
'{membership.status}' => ts('Membership Status'),
'{membership.type}' => ts('Membership Type'),
'{membership.join_date}' => ts('Membership Join Date'),
'{membership.end_date}' => ts('Membership End Date'),
'{membership.fee}' => ts('Membership Fee'),
- );
+ ];
}
/**
* @return array
*/
public static function eventTokens() {
- return array(
+ return [
'{event.event_id}' => ts('Event ID'),
'{event.title}' => ts('Event Title'),
'{event.start_date}' => ts('Event Start Date'),
'{event.info_url}' => ts('Event Info URL'),
'{event.registration_url}' => ts('Event Registration URL'),
'{event.balance}' => ts('Event Balance'),
- );
+ ];
}
/**
* @return array
*/
public static function contributionTokens() {
- return array_merge(array(
+ return array_merge([
'{contribution.contribution_id}' => ts('Contribution ID'),
'{contribution.total_amount}' => ts('Total Amount'),
'{contribution.fee_amount}' => ts('Fee Amount'),
//'{contribution.address_id}' => ts('Address ID'),
'{contribution.check_number}' => ts('Check Number'),
'{contribution.campaign}' => ts('Contribution Campaign'),
- ), CRM_Utils_Token::getCustomFieldTokens('contribution', TRUE));
+ ], CRM_Utils_Token::getCustomFieldTokens('contribution', TRUE));
}
/**
public static function contactTokens() {
static $tokens = NULL;
if (!$tokens) {
- $additionalFields = array(
- 'checksum' => array('title' => ts('Checksum')),
- 'contact_id' => array('title' => ts('Internal Contact ID')),
- );
+ $additionalFields = [
+ 'checksum' => ['title' => ts('Checksum')],
+ 'contact_id' => ['title' => ts('Internal Contact ID')],
+ ];
$exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields);
$values = array_merge(array_keys($exportFields));
unset($values[0]);
//FIXME:skipping some tokens for time being.
- $skipTokens = array(
+ $skipTokens = [
'is_bulkmail',
'group',
'tag',
'legal_identifier',
'contact_sub_type',
'user_unique_id',
- );
+ ];
- $customFields = CRM_Core_BAO_CustomField::getFields(array('Individual', 'Address'));
+ $customFields = CRM_Core_BAO_CustomField::getFields(['Individual', 'Address']);
$legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
foreach ($values as $val) {
}
// Get all the hook tokens too
- $hookTokens = array();
+ $hookTokens = [];
CRM_Utils_Hook::tokens($hookTokens);
foreach ($hookTokens as $tokenValues) {
foreach ($tokenValues as $key => $value) {
unset($values[0]);
// skipping some tokens for time being.
- $skipTokens = array(
+ $skipTokens = [
'event_id',
'participant_is_pay_later',
'participant_is_test',
'participant_campaign_id',
'participant_status',
'participant_discount_name',
- );
+ ];
$customFields = CRM_Core_BAO_CustomField::getFields('Participant');
* @return array
*/
public static function getDatePluginInputFormats() {
- $dateInputFormats = array(
+ $dateInputFormats = [
"mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'),
"dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'),
"yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'),
"yy-mm" => ts('yyyy-mm (2009-12)'),
'M yy' => ts('M yyyy (Dec 2009)'),
"yy" => ts('yyyy (2009)'),
- );
+ ];
/*
Year greater than 2000 get wrong result for following format
* @return array
*/
public static function getTimeFormats() {
- return array(
+ return [
'1' => ts('12 Hours'),
'2' => ts('24 Hours'),
- );
+ ];
}
/**
* @return array
*/
public static function getNumericOptions($start = 0, $end = 10) {
- $numericOptions = array();
+ $numericOptions = [];
for ($i = $start; $i <= $end; $i++) {
$numericOptions[$i] = $i;
}
* @return array
*/
public static function getBarcodeTypes() {
- return array(
+ return [
'barcode' => ts('Linear (1D)'),
'qrcode' => ts('QR code'),
- );
+ ];
}
/**
* @return array
*/
public static function getDedupeRuleTypes() {
- return array(
+ return [
'Unsupervised' => ts('Unsupervised'),
'Supervised' => ts('Supervised'),
'General' => ts('General'),
- );
+ ];
}
/**
* @return array
*/
public static function getCampaignGroupTypes() {
- return array(
+ return [
'Include' => ts('Include'),
'Exclude' => ts('Exclude'),
- );
+ ];
}
/**
* @return array
*/
public static function getSubscriptionHistoryMethods() {
- return array(
+ return [
'Admin' => ts('Admin'),
'Email' => ts('Email'),
'Web' => ts('Web'),
'API' => ts('API'),
- );
+ ];
}
/**
* @return array
*/
public static function getPremiumUnits() {
- return array(
+ return [
'day' => ts('Day'),
'week' => ts('Week'),
'month' => ts('Month'),
'year' => ts('Year'),
- );
+ ];
}
/**
* @return array
*/
public static function getExtensionTypes() {
- return array(
+ return [
'payment' => ts('Payment'),
'search' => ts('Search'),
'report' => ts('Report'),
'module' => ts('Module'),
'sms' => ts('SMS'),
- );
+ ];
}
/**
* @return array
*/
public static function getJobFrequency() {
- return array(
+ return [
// CRM-17669
'Yearly' => ts('Yearly'),
'Quarter' => ts('Quarterly'),
'Daily' => ts('Daily'),
'Hourly' => ts('Hourly'),
'Always' => ts('Every time cron job is run'),
- );
+ ];
}
/**
* @return array
*/
public static function getProfileGroupType() {
- $profileGroupType = array(
+ $profileGroupType = [
'Activity' => ts('Activities'),
'Contribution' => ts('Contributions'),
'Membership' => ts('Memberships'),
'Participant' => ts('Participants'),
- );
+ ];
$contactTypes = self::contactType();
- $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
+ $contactTypes = !empty($contactTypes) ? ['Contact' => 'Contacts'] + $contactTypes : [];
$profileGroupType = array_merge($contactTypes, $profileGroupType);
return $profileGroupType;
}
-
/**
* Word replacement match type.
*
* @return array
*/
public static function getWordReplacementMatchType() {
- return array(
+ return [
'exactMatch' => ts('Exact Match'),
'wildcardMatch' => ts('Wildcard Match'),
- );
+ ];
}
/**
* @return array
*/
public static function getMailingGroupTypes() {
- return array(
+ return [
'Include' => ts('Include'),
'Exclude' => ts('Exclude'),
'Base' => ts('Base'),
- );
+ ];
}
/**
* @return array
*/
public static function getMailingJobStatus() {
- return array(
+ return [
'Scheduled' => ts('Scheduled'),
'Running' => ts('Running'),
'Complete' => ts('Complete'),
'Paused' => ts('Paused'),
'Canceled' => ts('Canceled'),
- );
+ ];
}
/**
* @return array
*/
public static function billingMode() {
- return array(
+ return [
CRM_Core_Payment::BILLING_MODE_FORM => 'form',
CRM_Core_Payment::BILLING_MODE_BUTTON => 'button',
CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify',
- );
+ ];
}
/**
* @return array
*/
public static function contributeMode() {
- return array(
+ return [
CRM_Core_Payment::BILLING_MODE_FORM => 'direct',
CRM_Core_Payment::BILLING_MODE_BUTTON => 'directIPN',
CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify',
- );
+ ];
}
/**
// @todo this used to refer to the 'recur_frequency_unit' option_values which
// is for recurring payments and probably not good to re-use for recurring entities.
// If something other than a hard-coded list is desired, add a new option_group.
- return array(
- 'hour' => ts('hour', array('plural' => 'hours', 'count' => $count)),
- 'day' => ts('day', array('plural' => 'days', 'count' => $count)),
- 'week' => ts('week', array('plural' => 'weeks', 'count' => $count)),
- 'month' => ts('month', array('plural' => 'months', 'count' => $count)),
- 'year' => ts('year', array('plural' => 'years', 'count' => $count)),
- );
+ return [
+ 'hour' => ts('hour', ['plural' => 'hours', 'count' => $count]),
+ 'day' => ts('day', ['plural' => 'days', 'count' => $count]),
+ 'week' => ts('week', ['plural' => 'weeks', 'count' => $count]),
+ 'month' => ts('month', ['plural' => 'months', 'count' => $count]),
+ 'year' => ts('year', ['plural' => 'years', 'count' => $count]),
+ ];
}
/**
* @return array
*/
public static function getRelativeDateTerms() {
- return array(
+ return [
'previous' => ts('Previous'),
'previous_2' => ts('Previous 2'),
'previous_before' => ts('Prior to Previous'),
'starting' => ts('Upcoming'),
'less' => ts('To End of'),
'next' => ts('Next'),
- );
+ ];
}
/**
* @return array
*/
public static function getRelativeDateUnits() {
- return array(
+ return [
'year' => ts('Years'),
'fiscal_year' => ts('Fiscal Years'),
'quarter' => ts('Quarters'),
'month' => ts('Months'),
'week' => ts('Weeks'),
'day' => ts('Days'),
- );
+ ];
}
/**
* @return array
*/
public static function documentFormat() {
- return array(
+ return [
'pdf' => ts('Portable Document Format (.pdf)'),
'docx' => ts('MS Word (.docx)'),
'odt' => ts('Open Office (.odt)'),
'html' => ts('Webpage (.html)'),
- );
+ ];
}
/**
* @return array
*/
public static function documentApplicationType() {
- return array(
+ return [
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'odt' => 'application/vnd.oasis.opendocument.text',
- );
+ ];
}
/**
* @return array
*/
public static function activityTextOptions() {
- return array(
+ return [
2 => ts('Details Only'),
3 => ts('Subject Only'),
6 => ts('Both'),
- );
+ ];
}
/**
* @return array
*/
public static function getPermissionedRelationshipOptions() {
- return array(
+ return [
CRM_Contact_BAO_Relationship::NONE => ts('None'),
CRM_Contact_BAO_Relationship::VIEW => ts('View only'),
CRM_Contact_BAO_Relationship::EDIT => ts('View and update'),
- );
+ ];
}
/**
return $optionValues;
}
+ /**
+ * Dropdown options for quicksearch in the menu
+ *
+ * @return array
+ */
+ public static function quicksearchOptions() {
+ $includeEmail = civicrm_api3('setting', 'getvalue', ['name' => 'includeEmailInName', 'group' => 'Search Preferences']);
+ $options = [
+ 'sort_name' => $includeEmail ? ts('Name/Email') : ts('Name'),
+ 'contact_id' => ts('Contact ID'),
+ 'external_identifier' => ts('External ID'),
+ 'first_name' => ts('First Name'),
+ 'last_name' => ts('Last Name'),
+ 'email' => ts('Email'),
+ 'phone_numeric' => ts('Phone'),
+ 'street_address' => ts('Street Address'),
+ 'city' => ts('City'),
+ 'postal_code' => ts('Postal Code'),
+ 'job_title' => ts('Job Title'),
+ ];
+ $custom = civicrm_api3('CustomField', 'get', [
+ 'return' => ['name', 'label', 'custom_group_id.title'],
+ 'custom_group_id.extends' => ['IN' => ['Contact', 'Individual', 'Organization', 'Household']],
+ 'data_type' => ['NOT IN' => ['ContactReference', 'Date', 'File']],
+ 'custom_group_id.is_active' => 1,
+ 'is_active' => 1,
+ 'is_searchable' => 1,
+ 'options' => ['sort' => ['custom_group_id.weight', 'weight'], 'limit' => 0],
+ ]);
+ foreach ($custom['values'] as $field) {
+ $options['custom_' . $field['name']] = $field['custom_group_id.title'] . ': ' . $field['label'];
+ }
+ return $options;
+ }
+
}