Invoker cleanup - Remove unused calling convention.
[civicrm-core.git] / CRM / Core / SelectValues.php
index 88739eccfbd4644a3c0afab3700d55f40bbbfc5d..089fd4163fa29336c53c296f3697cad0dfedd2a7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -97,8 +97,7 @@ class CRM_Core_SelectValues {
   static function &contactType() {
     static $contactType = NULL;
     if (!$contactType) {
-      $contactType = array('' => ts('- any contact type -'));
-      $contactType = $contactType + CRM_Contact_BAO_ContactType::basicTypePairs();
+      $contactType = CRM_Contact_BAO_ContactType::basicTypePairs();
     }
     return $contactType;
   }
@@ -126,6 +125,18 @@ class CRM_Core_SelectValues {
     return $unitList;
   }
 
+  /**
+   * membership type unit
+   * @static
+   */
+  static function membershipTypeUnitList( ) {
+    static $membershipTypeUnitList = NULL;
+    if (!$membershipTypeUnitList) {
+      $membershipTypeUnitList = self::unitList('duration');
+    }
+    return $membershipTypeUnitList;
+  }
+
   /**
    * various pre defined period types
    * @static
@@ -135,8 +146,8 @@ class CRM_Core_SelectValues {
     if (!$periodType) {
       $periodType = array(
         '' => ts('- select -'),
-        'rolling' => ts('rolling'),
-        'fixed' => ts('fixed'),
+        'rolling' => ts('Rolling'),
+        'fixed' => ts('Fixed'),
       );
     }
     return $periodType;
@@ -248,7 +259,6 @@ class CRM_Core_SelectValues {
         'Campaign' => ts('Campaigns'),
       );
       $contactTypes = self::contactType();
-      unset($contactTypes['']);
       $contactTypes       = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
       $extendObjs         = CRM_Core_OptionGroup::values('cg_extend_objects');
       $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs);
@@ -267,6 +277,7 @@ class CRM_Core_SelectValues {
       $customGroupStyle = array(
         'Tab' => ts('Tab'),
         'Inline' => ts('Inline'),
+        'Tab with table' => ts('Tab with table')
       );
     }
     return $customGroupStyle;
@@ -365,7 +376,7 @@ class CRM_Core_SelectValues {
         $date['emptyOptionValue'] = '';
       }
 
-      if (!CRM_Utils_Array::value('format', $date)) {
+      if (empty($date['format'])) {
         $date['format'] = 'M d';
       }
     }
@@ -396,6 +407,19 @@ class CRM_Core_SelectValues {
     return $_visibility;
   }
 
+  /**
+   * values for group form visibility options
+   *
+   * @static
+   */
+  static function groupVisibility() {
+    static $_groupVisibility = NULL;
+    if (!$_groupVisibility) {
+      $_groupVisibility = self::ufVisibility(true);
+    }
+    return $_groupVisibility;
+  }
+
   /**
    * different type of Mailing Components
    *
@@ -591,6 +615,7 @@ class CRM_Core_SelectValues {
         '{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;
@@ -661,17 +686,20 @@ class CRM_Core_SelectValues {
       $customFields        = CRM_Core_BAO_CustomField::getFields('Individual');
       $customFieldsAddress = CRM_Core_BAO_CustomField::getFields('Address');
       $customFields        = $customFields + $customFieldsAddress;
+      $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens());
 
-      foreach ($values as $key => $val) {
+      foreach ($values as $val) {
         if (in_array($val, $skipTokens)) {
           continue;
         }
         //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
         if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
-          $tokens["{contact.$val}"] = CRM_Utils_Array::value($customFieldId, $customFields) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
+          $tokens["{contact.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
         }
         else {
-          $tokens["{contact.$val}"] = $exportFields[$val]['title'];
+          // Support legacy token names
+          $tokenName = CRM_Utils_Array::value($val, $legacyTokenNames, $val);
+          $tokens["{contact.$tokenName}"] = $exportFields[$val]['title'];
         }
       }
 
@@ -725,7 +753,7 @@ class CRM_Core_SelectValues {
         }
         //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734
         if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) {
-          $tokens["{participant.$val}"] = CRM_Utils_Array::value($customFieldId, $customFields) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
+          $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : '';
         }
         else {
           $tokens["{participant.$val}"] = $exportFields[$val]['title'];
@@ -849,5 +877,214 @@ class CRM_Core_SelectValues {
     }
     return $numericOptions;
   }
+
+  /**
+   * barcode types
+   * @static
+   */
+  static function getBarcodeTypes() {
+    static $barcodeTypes = NULL;
+    if (!$barcodeTypes) {
+      $barcodeTypes = array(
+        'barcode' => ts('Linear (1D)'),
+        'qrcode' => ts('QR code'),
+      );
+    }
+    return $barcodeTypes;
+  }
+
+  /**
+   * dedupe rule types
+   */
+  static function getDedupeRuleTypes() {
+    static $dedupeRuleTypes = NULL;
+    if (!$dedupeRuleTypes) {
+      $dedupeRuleTypes = array(
+        'Unsupervised' => ts('Unsupervised'),
+        'Supervised' => ts('Supervised'),
+        'General' => ts('General'),
+      );
+    }
+    return $dedupeRuleTypes;
+  }
+
+  /**
+   * campaign group types
+   */
+  static function getCampaignGroupTypes() {
+    static $campaignGroupTypes = NULL;
+    if (!$campaignGroupTypes) {
+      $campaignGroupTypes = array(
+        'Include' => ts('Include'),
+        'Exclude' => ts('Exclude'),
+      );
+    }
+    return $campaignGroupTypes;
+  }
+
+  /**
+   * 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;
+  }
+
+  /**
+   * 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;
+  }
+
+  /**
+   * 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;
+  }
+
+  /**
+   * 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;
+  }
+
+  /**
+   * 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;
+  }
+
+  /**
+   * profile group types
+   *
+   * @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 );
+    }
+    return $profileGroupType;
+  }
+
+
+  /**
+   * word replacement match type
+   */
+  static function getWordReplacementMatchType() {
+    static $wordReplacementMatchType = NULL;
+    if (!$wordReplacementMatchType) {
+      $wordReplacementMatchType = 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;
+  }
+
+  /**
+   * 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'),
+      );
+    }
+
+    return $mailingJobStatus;
+  }
+
 }