<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Core_PseudoConstant {
/**
- * static cache for pseudoconstant arrays
+ * Static cache for pseudoconstant arrays
* @var array
* @static
*/
private static $cache;
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* activity type
* @var array
private static $activityType;
/**
- * states, provinces
+ * States, provinces
* @var array
* @static
*/
private static $stateProvince;
/**
- * counties
+ * Counties
* @var array
* @static
*/
private static $county;
/**
- * states/provinces abbreviations
+ * States/provinces abbreviations
* @var array
* @static
*/
private static $stateProvinceAbbreviation;
/**
- * country
+ * Country
* @var array
* @static
*/
private static $country;
/**
- * countryIsoCode
+ * CountryIsoCode
* @var array
* @static
*/
private static $countryIsoCode;
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* group
* @var array
private static $group;
/**
- * groupIterator
+ * GroupIterator
* @var mixed
* @static
*/
private static $groupIterator;
/**
- * relationshipType
+ * RelationshipType
* @var array
* @static
*/
private static $relationshipType;
/**
- * civicrm groups that are not smart groups
+ * Civicrm groups that are not smart groups
* @var array
* @static
*/
private static $staticGroup;
/**
- * currency codes
+ * Currency codes
* @var array
* @static
*/
private static $currencyCode;
/**
- * payment processor
+ * Payment processor
* @var array
* @static
*/
private static $paymentProcessor;
/**
- * payment processor types
+ * Payment processor types
* @var array
* @static
*/
private static $worldRegions;
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* activity status
* @var array
*/
private static $accountOptionValues;
+ /**
+ * Tax Rates
+ * @var array
+ * @static
+ */
+ private static $taxRates;
+
/**
* Low-level option getter, rarely accessed directly.
* NOTE: Rather than calling this function directly use CRM_*_BAO_*::buildOptions()
* NULL if the given key has no corresponding option
* String if label is found
*/
- static function getLabel($baoName, $fieldName, $key) {
+ public static function getLabel($baoName, $fieldName, $key) {
$values = $baoName::buildOptions($fieldName, 'get');
if ($values === FALSE) {
return FALSE;
* NULL if the given key has no corresponding option
* String if label is found
*/
- static function getName($baoName, $fieldName, $key) {
+ public static function getName($baoName, $fieldName, $key) {
$values = $baoName::buildOptions($fieldName, 'validate');
if ($values === FALSE) {
return FALSE;
* NULL if the given key has no corresponding option
* String|Number if key is found
*/
- static function getKey($baoName, $fieldName, $value) {
+ public static function getKey($baoName, $fieldName, $value) {
$values = $baoName::buildOptions($fieldName, 'validate');
if ($values === FALSE) {
return FALSE;
* @param $fieldSpec
* @return string|null
*/
- static function getOptionEditUrl($fieldSpec) {
+ public static function getOptionEditUrl($fieldSpec) {
// If it's an option group, that's easy
if (!empty($fieldSpec['pseudoconstant']['optionGroupName'])) {
return 'civicrm/admin/options/' . $fieldSpec['pseudoconstant']['optionGroupName'];
/**
* DEPRECATED generic populate method
- * All pseudoconstant functions that use this method are also deprecated.
+ * 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>.
* @param null $force
*
* @return void
- * @access public
* @static
*/
public static function populate(
* Flush given pseudoconstant so it can be reread from db
* nex time it's requested.
*
- * @access public
* @static
*
* @param bool|string $name pseudoconstant to be flushed
}
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* Get all Activty types.
*
* The static array activityType is returned
*
- * @internal param bool $all - get All Activity types - default is to get only active ones.
- *
- * @access public
* @static
*
* @return array - array reference of all activity types.
*
* Note: any database errors will be trapped by the DAO.
*
- * @access public
* @static
*
* @param bool|int $id - Optional id to return
*
* Same as above, except gets the abbreviations instead of the names.
*
- * @access public
* @static
*
* @param bool|int $id - Optional id to return
*
* Note: any database errors will be trapped by the DAO.
*
- * @access public
* @static
*
* @param bool|int $id - Optional id to return
*
* Note: any database errors will be trapped by the DAO.
*
- * @access public
* @static
*
* @param bool $id
}
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* Get all groups from database
*
* Note: any database errors will be trapped by the DAO.
*
* @param string $groupType type of group(Access/Mailing)
- * @param bool|\boolen $excludeHidden exclude hidden groups.
+ * @param bool $excludeHidden exclude hidden groups.
*
- * @access public
* @static
*
* @return array - array reference of all groups.
* called for the first time
*
*
- * @access public
* @static
*
* @param bool $styledLabels
}
/**
- * 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
* Note: any database errors will be trapped by the DAO.
*
* @param string $groupType type of group(Access/Mailing)
- * @param bool|\boolen $excludeHidden exclude hidden groups.
+ * @param bool $excludeHidden exclude hidden groups.
*
- * @access public
* @static
*
* @return array - array reference of all groups.
return CRM_Core_Permission::group($groupType, $excludeHidden);
}
+ /**
+ * Fetch groups in a nested format suitable for use in select form element
+ * @param bool $checkPermissions
+ * @param string|null $groupType
+ * @param bool $excludeHidden
+ * @return array
+ */
+ public static function nestedGroup($checkPermissions = TRUE, $groupType = NULL, $excludeHidden = TRUE) {
+ $groups = $checkPermissions ? self::group($groupType, $excludeHidden) : self::allGroup($groupType, $excludeHidden);
+ return CRM_Contact_BAO_Group::getGroupsHierarchy($groups, NULL, ' ', TRUE);
+ }
+
/**
* Get all permissioned groups from database
*
*
* Note: any database errors will be trapped by the DAO.
*
- * @access public
* @static
*
* @param bool $onlyPublic
* @param string $valueColumnName db column name/label.
* @param boolean $reset reset relationship types if true
*
- * @access public
* @static
*
* @return array - array reference of all relationship types.
}
/**
- * get all the ISO 4217 currency codes
+ * Get all the ISO 4217 currency codes
*
* so far, we use this for validation only, so there's no point of putting this into the database
*
- * @access public
*
* @return array - array reference of all currency codes
* @static
*
* Note: any database errors will be trapped by the DAO.
*
- * @access public
* @static
*
* @param bool|int $id - Optional id to return
}
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
* Get all active payment processors
*
* The static array paymentProcessor is returned
*
- * @access public
* @static
*
* @param boolean $all - get payment processors - default is to get only active ones.
}
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* The static array paymentProcessorType is returned
*
- * @access public
* @static
*
* @param boolean $all - get payment processors - default is to get only active ones.
*
- * @param null $id
+ * @param int $id
* @param string $return
*
* @return array - array of all payment processor types
/**
* Get all the World Regions from Database
*
- * @access public
*
* @param bool $id
*
}
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* Get all Activity Statuses.
*
* The static array activityStatus is returned
*
- * @access public
* @static
*
* @param string $column
}
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
+ * @deprecated Please use the buildOptions() method in the appropriate BAO object.
*
* Get all Visibility levels.
*
* The static array visibility is returned
*
- * @access public
* @static
*
* @param string $column
}
/**
- * @param $countryID
+ * @param int $countryID
* @param string $field
*
* @return array
}
/**
- * @param $stateID
+ * @param int $stateID
*
* @return array
*/
*
* @return int the country id that the state belongs to
* @static
- * @public
*/
- static function countryIDForStateID($stateID) {
+ public static function countryIDForStateID($stateID) {
if (empty($stateID)) {
return CRM_Core_DAO::$_nullObject;
}
*
* The static array of greeting is returned
*
- * @access public
* @static
*
* @param $filter - get All Email Greetings - default is to get only active ones.
/**
* Construct array of default greeting values for contact type
*
- * @access public
* @static
*
* @return array - array reference of default greetings.
* FIXME: This is called by civix but not by any core code. We
* should provide an API call which civix can use instead.
*
- * @access public
* @static
*
* @return array - array($fullyQualifiedName => $label) list of extensions
*
* 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.
*
- * @param null $id
+ * @param int $id
* @param null $condition
*
* @return array - array reference of all Option Group Name
* Fetch the list of active extensions of type 'module'
*
* @param $fresh bool whether to forcibly reload extensions list from canonical store
- * @access public
* @static
*
* @return array - array(array('prefix' => $, 'file' => $))
public static function getModuleExtensions($fresh = FALSE) {
return CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles($fresh);
}
-}
+
+ /**
+ * Get all tax rates
+ *
+ * The static array tax rates is returned
+ *
+ * @static
+ *
+ * @return array - array list of tax rates with the financial type
+ */
+ public static function getTaxRates() {
+ if (!self::$taxRates) {
+ self::$taxRates = array();
+ $sql = "
+ SELECT fa.tax_rate, efa.entity_id
+ FROM civicrm_entity_financial_account efa
+ INNER JOIN civicrm_financial_account fa ON fa.id = efa.financial_account_id
+ INNER JOIN civicrm_option_value cov ON cov.value = efa.account_relationship
+ INNER JOIN civicrm_option_group cog ON cog.id = cov.option_group_id
+ WHERE efa.entity_table = 'civicrm_financial_type'
+ AND cov.name = 'Sales Tax Account is'
+ AND cog.name = 'account_relationship'
+ AND fa.is_active = 1";
+ $dao = CRM_Core_DAO::executeQuery($sql);
+ while ($dao->fetch()) {
+ self::$taxRates[$dao->entity_id] = $dao->tax_rate;
+ }
+ }
+
+ return self::$taxRates;
+ }
+}