Support custom fields CRM-12464
[civicrm-core.git] / CRM / Core / PseudoConstant.php
index 224bcf887049ab1ba52b473f061a141fc2321438..06055036670f86751afd901a858fca1fd4a9be3b 100644 (file)
@@ -57,68 +57,14 @@ class CRM_Core_PseudoConstant {
   private static $cache;
 
   /**
-   * location type
-   * @var array
-   * @static
-   */
-  private static $locationType;
-
-  /**
-   * location vCard name
-   * @var array
-   * @static
-   */
-  private static $locationVcardName;
-
-  /**
-   * location display name
-   * @var array
-   * @static
-   */
-  private static $locationDisplayName;
-
-  /**
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+   *
    * activity type
    * @var array
    * @static
    */
   private static $activityType;
 
-  /**
-   * payment processor billing modes
-   * @var array
-   * @static
-   */
-  private static $billingMode;
-
-  /**
-   * component
-   * @var array
-   * @static
-   */
-  private static $component;
-
-  /**
-   * im protocols
-   * @var array
-   * @static
-   */
-  private static $imProvider;
-
-  /**
-   * website protocols
-   * @var array
-   * @static
-   */
-  private static $websiteType;
-
-  /**
-   * im protocols
-   * @var array
-   * @static
-   */
-  private static $fromEmailAddress;
-
   /**
    * states, provinces
    * @var array
@@ -155,13 +101,8 @@ class CRM_Core_PseudoConstant {
   private static $countryIsoCode;
 
   /**
-   * tag
-   * @var array
-   * @static
-   */
-  private static $tag;
-
-  /**
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+   *
    * group
    * @var array
    * @static
@@ -189,20 +130,6 @@ class CRM_Core_PseudoConstant {
    */
   private static $staticGroup;
 
-  /**
-   * user framework groups
-   * @var array
-   * @static
-   */
-  private static $ufGroup;
-
-  /**
-   * custom groups
-   * @var array
-   * @static
-   */
-  private static $customGroup;
-
   /**
    * currency codes
    * @var array
@@ -210,20 +137,6 @@ class CRM_Core_PseudoConstant {
    */
   private static $currencyCode;
 
-  /**
-   * currency Symbols
-   * @var array
-   * @static
-   */
-  private static $currencySymbols;
-
-  /**
-   * preferred communication methods
-   * @var array
-   * @static
-   */
-  private static $pcm;
-
   /**
    * payment processor
    * @var array
@@ -246,40 +159,14 @@ class CRM_Core_PseudoConstant {
   private static $worldRegions;
 
   /**
-   * honorType
-   * @var array
-   * @static
-   */
-  private static $honorType;
-
-  /**
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+   *
    * activity status
    * @var array
    * @static
    */
   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
@@ -287,13 +174,6 @@ class CRM_Core_PseudoConstant {
    */
   private static $visibility;
 
-  /**
-   * Mail Protocols
-   * @var array
-   * @static
-   */
-  private static $mailProtocol;
-
   /**
    * Greetings
    * @var array
@@ -316,63 +196,9 @@ class CRM_Core_PseudoConstant {
   private static $extensions;
 
   /**
-   * activity contacts
-   * @var array
-   * @static
-   */
-  private static $activityContacts;
-
-  /**
-   * event contacts
-   * @var array
-   * @static
-   */
-  private static $eventContacts;
-
-  /**
-   * auto renew options
-   * @var array
-   * @static
-   */
-  private static $autoRenew;
-
-  /**
-   * batch mode options
-   * @var array
-   * @static
-   */
-  private static $batchModes;
-
-  /**
-   * batch type options
-   * @var array
-   * @static
-   */
-  private static $batchTypes;
-
-  /**
-   * batch status options
-   * @var array
-   * @static
-   */
-  private static $batchStatues;
-
-  /**
-   * contact Type
-   * @var array
-   * @static
-   */
-  private static $contactType;
-
-  /**
-   * Financial Account Type
-   * @var array
-   * @static
-   */
-  private static $accountOptionValues;
-
-  /**
-   * Get options for a given field.
+   * Low-level option getter, rarely accessed directly.
+   * NOTE: Rather than calling this function directly use CRM_*_BAO_*::buildOptions()
+   *
    * @param String $daoName
    * @param String $fieldName
    * @param Array $params
@@ -381,8 +207,10 @@ class CRM_Core_PseudoConstant {
    *                            if true, the results are reversed
    * - grouping   boolean if true, return the value in 'grouping' column (currently unsupported for tables other than option_value)
    * - localize   boolean if true, localize the results before returning
-   * - condition  string  add another condition to the sql query
-   * - labelColumnName string the column to use for 'label'
+   * - condition  string|array add condition(s) to the sql query
+   * - keyColumn  string the column to use for 'id'
+   * - labelColumn string the column to use for 'label'
+   * - orderColumn string the column to use for sorting, defaults to 'weight' column if one exists, else defaults to labelColumn
    * - onlyActive boolean return only the action option values
    * - fresh      boolean ignore cache entries and go back to DB
    *
@@ -391,35 +219,53 @@ class CRM_Core_PseudoConstant {
    * @static
    */
   public static function get($daoName, $fieldName, $params = array()) {
-    // Merge defaults
-    $params += array(
-      'flip' => FALSE,
-      'grouping' => FALSE,
-      'localize' => FALSE,
-      'condition' => NULL,
-      'labelColumnName' => NULL,
-      'onlyActive' => TRUE,
-      'fresh' => FALSE,
-    );
-    $flip = $params['flip'];
+    $flip = !empty($params['flip']);
 
+    // Custom fields are not in the schema
+    if (strpos($fieldName, 'custom') === 0) {
+      $dao = new CRM_Core_DAO_CustomField;
+      $dao->id = (int) substr($fieldName, 7);
+      $dao->find(TRUE);
+      $customField = (array) $dao;
+      $dao->free();
+      $output = array();
+      CRM_Core_BAO_CustomField::buildOption($customField, $output);
+      return $flip ? array_flip($output) : $output;
+    }
+
+    // Core field: load schema
     $dao = new $daoName;
     $fields = $dao->fields();
-    if (empty($fields[$fieldName])) {
+    $fieldKeys = $dao->fieldKeys();
+    $fieldKey = $fieldKeys[$fieldName];
+    $dao->free();
+    if (empty($fields[$fieldKey])) {
       return FALSE;
     }
-    $fieldSpec = $fields[$fieldName];
+    $fieldSpec = $fields[$fieldKey];
 
     // If the field is an enum, explode the enum definition and return the array.
-    if (array_key_exists('enumValues', $fieldSpec)) {
+    if (isset($fieldSpec['enumValues'])) {
       // use of a space after the comma is inconsistent in xml
       $enumStr = str_replace(', ', ',', $fieldSpec['enumValues']);
-      $values = explode(',', $enumStr);
-      return $flip ? array_flip($values) : $values;
+      $output = explode(',', $enumStr);
+      return $flip ? array_flip($output) : $output;
     }
 
     elseif (!empty($fieldSpec['pseudoconstant'])) {
       $pseudoconstant = $fieldSpec['pseudoconstant'];
+      // Merge params with defaults
+      $params += array(
+        'grouping' => FALSE,
+        'localize' => FALSE,
+        'condition' => CRM_Utils_Array::value('condition', $pseudoconstant),
+        'keyColumn' => CRM_Utils_Array::value('keyColumn', $pseudoconstant),
+        'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant),
+        'onlyActive' => TRUE,
+        'fresh' => FALSE,
+      );
+
+      // Fetch option group from option_value table
       if(!empty($pseudoconstant['optionGroupName'])) {
         // Call our generic fn for retrieving from the option_value table
         return CRM_Core_OptionGroup::values(
@@ -428,64 +274,98 @@ class CRM_Core_PseudoConstant {
           $params['grouping'],
           $params['localize'],
           $params['condition'],
-          $params['labelColumnName'] ? $params['labelColumnName'] : 'label',
+          $params['labelColumn'] ? $params['labelColumn'] : 'label',
           $params['onlyActive'],
-          $params['fresh']
+          $params['fresh'],
+          $params['keyColumn'] ? $params['keyColumn'] : 'value'
         );
       }
+
+      // Fetch options from other tables
       if (!empty($pseudoconstant['table'])) {
         // Normalize params so the serialized cache string will be consistent.
         CRM_Utils_Array::remove($params, 'flip', 'fresh');
         ksort($params);
-        $cacheKey = "{$daoName}{$fieldName}" . serialize($params);
+        $cacheKey = $daoName . $fieldName . serialize($params);
 
-        // Return cached options
+        // Retrieve cached options
         if (isset(self::$cache[$cacheKey]) && empty($params['fresh'])) {
-          return self::$cache[$cacheKey];
-        }
-
-        $select = "SELECT %1 AS id, %2 AS label";
-        $from = "FROM %3";
-        $wheres = array();
-        $order = "ORDER BY %2";
-        // Condition param can be passed as an sql string
-        if (!empty($params['condition'])) {
-          $wheres[] = $params['condition'];
+          $output = self::$cache[$cacheKey];
         }
-        // Support for onlyActive param if option table contains is_active field
-        if (!empty($params['onlyActive'])) {
+        else {
           $daoName = CRM_Core_AllCoreTables::getClassForTable($pseudoconstant['table']);
+          if (!class_exists($daoName)) {
+            return FALSE;
+          }
+          // Get list of fields for the option table
           $dao = new $daoName;
-          if (in_array('is_active', $dao->fields())) {
+          $availableFields = array_keys($dao->fieldKeys());
+          if (in_array('is_active', $availableFields)) {
             $wheres[] = 'is_active = 1';
           }
           $dao->free();
-        }
-        // Support labelColumnName param
-        $labelColumnName = $params['labelColumnName'] ? $params['labelColumnName'] : $pseudoconstant['labelColumn'];
-        $queryParams = array(
-           1 => array($pseudoconstant['keyColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
-           2 => array($labelColumnName, 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
-           3 => array($pseudoconstant['table'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
-        );
 
-        self::$cache[$cacheKey] = array();
-        $query = "$select $from";
-        if ($wheres) {
-          $query .= " WHERE " . implode($wheres, ' AND ');
-        }
-        $query .= ' ' . $order;
-        $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
-        while ($dao->fetch()) {
-          self::$cache[$cacheKey][$dao->id] = $dao->label;
-        }
-        $dao->free();
-        if (!empty($params['localize'])) {
-          $i18n = CRM_Core_I18n::singleton();
-          $i18n->localizeArray(self::$cache[$cacheKey]);
-        }
+          $select = "SELECT %1 AS id, %2 AS label";
+          $from = "FROM %3";
+          $wheres = array();
+          $order = "ORDER BY %2";
+          // Condition param can be passed as an sql clause string or an array of clauses
+          if (!empty($params['condition'])) {
+            $wheres[] = implode(' AND ', (array) $params['condition']);
+          }
+          // onlyActive param will automatically filter on common flags
+          if (!empty($params['onlyActive'])) {
+            foreach (array('is_active' => 1, 'is_deleted' => 0, 'is_test' => 0) as $flag => $val) {
+              if (in_array($flag, $availableFields)) {
+                $wheres[] = "$flag = $val";
+              }
+            }
+          }
+          // Filter domain specific options
+          if (in_array('domain_id', $availableFields)) {
+            $wheres[] = 'domain_id = ' . CRM_Core_Config::domainID();
+          }
+          $queryParams = array(
+             1 => array($params['keyColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
+             2 => array($params['labelColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
+             3 => array($pseudoconstant['table'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES),
+          );
+          // Add orderColumn param
+          if (!empty($params['orderColumn'])) {
+            $queryParams[4] = array($params['orderColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES);
+            $order = "ORDER BY %4";
+          }
+          // Support no sorting if $params[orderColumn] is FALSE
+          elseif (isset($params['orderColumn']) && $params['orderColumn'] === FALSE) {
+            $order = '';
+          }
+          // Default to 'weight' if that column exists
+          elseif (in_array('weight', $availableFields)) {
+            $order = "ORDER BY weight";
+          }
 
-        return $flip ? array_flip(self::$cache[$cacheKey]) : self::$cache[$cacheKey];
+          $output = array();
+          $query = "$select $from";
+          if ($wheres) {
+            $query .= " WHERE " . implode($wheres, ' AND ');
+          }
+          $query .= ' ' . $order;
+          $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
+          while ($dao->fetch()) {
+            $output[$dao->id] = $dao->label;
+          }
+          $dao->free();
+          if (!empty($params['localize'])) {
+            $i18n = CRM_Core_I18n::singleton();
+            $i18n->localizeArray($output);
+            // Maintain sort by label
+            if ($order == "ORDER BY %2") {
+              CRM_Utils_Array::asort($output);
+            }
+          }
+          self::$cache[$cacheKey] = $output;
+        }
+        return $flip ? array_flip($output) : $output;
       }
     }
     // If we're still here, it's an error. Return FALSE.
@@ -493,8 +373,38 @@ class CRM_Core_PseudoConstant {
   }
 
   /**
-   * populate the object from the database. generic populate
-   * method
+   * Fetch the label (or other value) for a field given its key
+   *
+   * @param String $daoName
+   * @param String $fieldName
+   * @param String|Int $key
+   * @param Array $params will be passed into self::get
+   *
+   * @return string
+   */
+   function getValue($daoName, $fieldName, $key, $params = array()) {
+     $values = self::get($daoName, $fieldName, $params);
+     return CRM_Utils_Array::value($key, $values);
+   }
+
+  /**
+   * Fetch the key for a field option given its label/name
+   *
+   * @param String $daoName
+   * @param String $fieldName
+   * @param String|Int $value
+   * @param Array $params will be passed into self::get
+   *
+   * @return string
+   */
+   function getKey($daoName, $fieldName, $value, $params = array()) {
+     $values = self::get($daoName, $fieldName, $params);
+     return CRM_Utils_Array::key($value, $values);
+   }
+
+  /**
+   * DEPRECATED generic populate method
+   * All pseudoconstant functions that use this method are also deprecated.
    *
    * The static array $var is populated from the db
    * using the <b>$name DAO</b>.
@@ -575,66 +485,8 @@ class CRM_Core_PseudoConstant {
   }
 
   /**
-   * Get all location types.
-   *
-   * The static array locationType is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param boolean $all - get All location types - default is to get only active ones.
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    *
-   * @return array - array reference of all location types.
-   *
-   */
-  public static function &locationType($all = FALSE) {
-    if (!self::$locationType) {
-      self::populate(self::$locationType, 'CRM_Core_DAO_LocationType', $all);
-    }
-    return self::$locationType;
-  }
-
-  /**
-   * Get all location vCard names.
-   *
-   * The static array locationVcardName is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param boolean $all - get All location vCard names - default is to get only active ones.
-   *
-   * @return array - array reference of all location vCard names.
-   *
-   */
-  public static function &locationVcardName($all = FALSE) {
-    if (!self::$locationVcardName) {
-      self::populate(self::$locationVcardName, 'CRM_Core_DAO_LocationType', $all, 'vcard_name');
-    }
-    return self::$locationVcardName;
-  }
-
-  /**
-   * Get all location Display names.
-   *
-   * The static array locationDisplayName is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param boolean $all - get All location display names - default is to get only active ones.
-   *
-   * @return array - array reference of all location display names.
-   *
-   */
-  public static function &locationDisplayName($all = FALSE) {
-    if (!self::$locationDisplayName) {
-      self::populate(self::$locationDisplayName, 'CRM_Core_DAO_LocationType', $all, 'display_name');
-    }
-    return self::$locationDisplayName;
-  }
-
-  /**
    * Get all Activty types.
    *
    * The static array activityType is returned
@@ -706,128 +558,7 @@ class CRM_Core_PseudoConstant {
     }
     return self::$activityType[$index];
   }
-
-  /**
-   * Get all payment-processor billing modes
-   *
-   * @access public
-   * @static
-   *
-   * @return array ($id => $name)
-   */
-  public static function billingMode() {
-    if (!self::$billingMode) {
-      self::$billingMode = array(
-        CRM_Core_Payment::BILLING_MODE_FORM => 'form',
-        CRM_Core_Payment::BILLING_MODE_BUTTON => 'button',
-        CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify',
-      );
-    }
-    return self::$billingMode;
-  }
-
-  /**
-   * Get all component names
-   *
-   * @access public
-   * @static
-   *
-   * @return array - array reference of all location display names.
-   *
-   */
-  public static function &component() {
-    if (!self::$component) {
-      self::populate(self::$component, 'CRM_Core_DAO_Component', TRUE, 'name');
-    }
-    return self::$component;
-  }
-
-  /**
-   * Get all the IM Providers from database.
-   *
-   * The static array imProvider is returned, and if it's
-   * called the first time, the <b>IM DAO</b> is used
-   * to get all the IM Providers.
-   *
-   * Note: any database errors will be trapped by the DAO.
-   *
-   * @access public
-   * @static
-   *
-   * @return array - array reference of all IM providers.
-   *
-   */
-  public static function &IMProvider($localize = FALSE) {
-    if (!self::$imProvider) {
-      self::$imProvider = CRM_Core_OptionGroup::values('instant_messenger_service', FALSE, FALSE, $localize);
-    }
-    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 <b>Website DAO</b> 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.
    *
@@ -1057,28 +788,8 @@ WHERE  id = %1";
   }
 
   /**
-   * Get all the categories from database.
-   *
-   * The static array tag is returned, and if it's
-   * called the first time, the <b>Tag DAO</b> is used
-   * to get all the categories.
-   *
-   * Note: any database errors will be trapped by the DAO.
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    *
-   * @access public
-   * @static
-   *
-   * @return array - array reference of all categories.
-   *
-   */
-  public static function &tag() {
-    if (!self::$tag) {
-      self::populate(self::$tag, 'CRM_Core_DAO_Tag', TRUE);
-    }
-    return self::$tag;
-  }
-
-  /**
    * Get all groups from database
    *
    * The static array group is returned, and if it's
@@ -1138,6 +849,8 @@ WHERE  id = %1";
   }
 
   /**
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+   *
    * Get all permissioned groups from database
    *
    * The static array group is returned, and if it's
@@ -1195,36 +908,6 @@ WHERE  id = %1";
     return self::$staticGroup;
   }
 
-  /**
-   * Get all the custom groups
-   *
-   * @access public
-   *
-   * @return array - array reference of all groups.
-   * @static
-   */
-  public static function &customGroup($reset = FALSE) {
-    if (!self::$customGroup || $reset) {
-      self::populate(self::$customGroup, 'CRM_Core_DAO_CustomGroup', FALSE, 'title', 'is_active', NULL, 'title');
-    }
-    return self::$customGroup;
-  }
-
-  /**
-   * Get all the user framework groups
-   *
-   * @access public
-   *
-   * @return array - array reference of all groups.
-   * @static
-   */
-  public static function &ufGroup() {
-    if (!self::$ufGroup) {
-      self::populate(self::$ufGroup, 'CRM_Core_DAO_UFGroup', FALSE, 'title', 'is_active', NULL, 'title');
-    }
-    return self::$ufGroup;
-  }
-
   /**
    * Get all Relationship Types  from database.
    *
@@ -1271,23 +954,6 @@ WHERE  id = %1";
     return self::$relationshipType[$valueColumnName];
   }
 
-  /**
-   * Get all the Currency Symbols from Database
-   *
-   * @access public
-   *
-   * @return array - array reference of all Currency Symbols
-   * @static
-   */
-  public static function &currencySymbols($name = 'symbol', $key = 'id') {
-    $cacheKey = "{$name}_{$key}";
-    if (!isset(self::$currencySymbols[$cacheKey])) {
-      self::populate(self::$currencySymbols[$cacheKey], 'CRM_Financial_DAO_Currency', TRUE, $name, NULL, NULL, 'name', $key);
-    }
-
-    return self::$currencySymbols[$cacheKey];
-  }
-
   /**
    * get all the ISO 4217 currency codes
    *
@@ -1609,29 +1275,7 @@ WHERE  id = %1";
   }
 
   /**
-   * Get all the Preferred Communication Methods from database.
-   *
-   * @access public
-   * @static
-   *
-   * @return array self::pcm - array reference of all preferred communication methods.
-   *
-   */
-  public static function &pcm($localize = FALSE) {
-    if (!self::$pcm) {
-      self::$pcm = CRM_Core_OptionGroup::values('preferred_communication_method', FALSE, FALSE, $localize);
-    }
-    return self::$pcm;
-  }
-
-  /**
-   * Alias of pcm
-   */
-  public static function preferredCommunicationMethod($localize = FALSE) {
-    return self::pcm($localize);
-  }
-
-  /**
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    * Get all active payment processors
    *
    * The static array paymentProcessor is returned
@@ -1666,7 +1310,7 @@ WHERE  id = %1";
   }
 
   /**
-   * Get all active payment processors
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    *
    * The static array paymentProcessorType is returned
    *
@@ -1715,26 +1359,8 @@ WHERE  id = %1";
   }
 
   /**
-   * Get all Honor Type.
-   *
-   * The static array honorType is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param boolean $all - get All Honor Type.
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    *
-   * @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.
    *
    * The static array activityStatus is returned
@@ -1758,41 +1384,8 @@ WHERE  id = %1";
   }
 
   /**
-   * 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
+   * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
    *
-   * @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.
    *
    * The static array visibility is returned
@@ -1815,20 +1408,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;
 
@@ -2020,13 +1599,9 @@ WHERE  id = %1
   public static function &greetingDefaults() {
     if (!self::$greetingDefaults) {
       $defaultGreetings = array();
-      $contactTypes = array(
-        'Individual' => 1,
-        'Household' => 2,
-        'Organization' => 3,
-      );
+      $contactTypes = self::get('CRM_Contact_DAO_Contact', 'contact_type', array('keyColumn' => 'id', 'labelColumn' => 'name'));
 
-      foreach ($contactTypes as $contactType => $filter) {
+      foreach ($contactTypes as $filter => $contactType) {
         $filterCondition = " AND (v.filter = 0 OR v.filter = $filter) AND v.is_default = 1 ";
 
         foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
@@ -2041,26 +1616,6 @@ WHERE  id = %1
     return self::$greetingDefaults;
   }
 
-  /**
-   * Get all the Languages from database.
-   *
-   * @access public
-   * @static
-   *
-   * @return array self::languages - array reference of all languages
-   *
-   */
-  public static function &languages() {
-    return CRM_Core_I18n_PseudoConstant::languages();
-  }
-
-  /**
-   * Alias of above
-   */
-  public static function &preferredLanguage() {
-    return CRM_Core_I18n_PseudoConstant::languages();
-  }
-
   /**
    * Get all extensions
    *
@@ -2103,158 +1658,5 @@ WHERE  id = %1
   public static function getModuleExtensions($fresh = FALSE) {
     return CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles($fresh);
   }
-
-  /**
-   * Get all Activity Contacts
-   *
-   * The static array activityContacts is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param string $column db column name/label.
-   *
-   * @return array - array reference of all  activity Contacts
-   *
-   */
-  public static function &activityContacts($column = 'label') {
-    if (!self::$activityContacts) {
-      self::$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, $column);
-    }
-    return self::$activityContacts;
-  }
-
-  /**
-   * Get all Event Contacts
-   *
-   * The static array eventContacts is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param string $column db column name/label.
-   *
-   * @return array - array reference of all  event Contacts
-   *
-   */
-  public static function &eventContacts($column = 'label') {
-    if (!self::$eventContacts) {
-      self::$eventContacts = CRM_Core_OptionGroup::values('event_contacts', FALSE, FALSE, FALSE, NULL, $column);
-    }
-    return self::$eventContacts;
-  }
-
-  /**
-   * Get all options values
-   *
-   * The static array option values is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param boolean $optionGroupName - get All  Option Group values- default is to get only active ones.
-   *
-   * @return array - array reference of all Option Group Name
-   *
-   */
-  public static function accountOptionValues($optionGroupName, $id = null, $condition = null) {
-    $cacheKey = $optionGroupName . '_' . $condition;
-    if (empty(self::$accountOptionValues[$cacheKey])) {
-      self::$accountOptionValues[$cacheKey] = CRM_Core_OptionGroup::values($optionGroupName, false, false, false, $condition);
-    }
-    if ($id) {
-      return CRM_Utils_Array::value($id, self::$accountOptionValues[$cacheKey]);
-    }
-
-    return self::$accountOptionValues[$cacheKey];
-  }
-
-  /**
-   * Get all batch modes
-   *
-   * The static array batchModes
-   *
-   * @access public
-   * @static
-   *
-   * @return array - array reference of all batch modes
-   */
-  public static function &getBatchMode($columnName = 'label') {
-    if (!self::$batchModes) {
-      self::$batchModes = CRM_Core_OptionGroup::values('batch_mode', false, false, false, null, $columnName);
-    }
-
-    return self::$batchModes;
-  }
-
-  /**
-   * Get all batch types
-   *
-   * The static array batchTypes
-   *
-   * @access public
-   * @static
-   *
-   * @return array - array reference of all batch types
-   */
-  public static function &getBatchType() {
-    if (!self::$batchTypes) {
-      self::$batchTypes = CRM_Core_OptionGroup::values('batch_type');
-    }
-
-    return self::$batchTypes;
-  }
-
-  /**
-   * Get all batch statuses
-   *
-   * The static array batchStatues
-   *
-   * @access public
-   * @static
-   *
-   * @return array - array reference of all batch statuses
-   */
-  public static function &getBatchStatus() {
-    if (!self::$batchStatues) {
-      self::$batchStatues = CRM_Core_OptionGroup::values('batch_status');
-    }
-
-    return self::$batchStatues;
-  }
-
-  /*
-  * The static array contactType is returned
-  *
-  * @access public
-  * @static
-  * @param string $column db column name/label.
-  *
-  * @return array - array reference of all Types
-  *
-     */
-
-  public static function &contactType($column = 'label') {
-    if (!self::$contactType) {
-      self::$contactType = CRM_Contact_BAO_ContactType::basicTypePairs(TRUE);
-    }
-    return self::$contactType;
-  }
-
-  /**
-   * Get all the auto renew options
-   *
-   * @access public
-   * @static
-   *
-   * @return array self::autoRenew - array reference of all autoRenew
-   *
-   */
-  public static function &autoRenew() {
-      if (!self::$autoRenew) {
-          self::$autoRenew = CRM_Core_OptionGroup::values('auto_renew_options', FALSE, FALSE);
-      }
-      return self::$autoRenew;
-  }
 }