3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
8 | CiviCRM is free software; you can copy, modify, and distribute it |
9 | under the terms of the GNU Affero General Public License |
10 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | CiviCRM is distributed in the hope that it will be useful, but |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 | See the GNU Affero General Public License for more details. |
17 | You should have received a copy of the GNU Affero General Public |
18 | License and the CiviCRM Licensing Exception along |
19 | with this program; if not, contact CiviCRM LLC |
20 | at info[AT]civicrm[DOT]org. If you have questions about the |
21 | GNU Affero General Public License or the licensing of CiviCRM, |
22 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23 +--------------------------------------------------------------------+
27 * Field handler to provide acess control for the state field (which is a lookup)
29 * @ingroup civicrm_field_handlers
31 class civicrm_handler_field_state extends civicrm_handler_field_address {
34 function construct() {
36 if (!self::$_states || !self::$_states_full) {
37 if (!civicrm_initialize()) {
40 require_once 'CRM/Core/PseudoConstant.php';
41 self::$_states = CRM_Core_PseudoConstant::stateProvinceAbbreviation();
42 self::$_states_full = CRM_Core_PseudoConstant::stateProvince();
46 function render($values) {
47 $sid = $values->{$this->field_alias};
54 if ($this->options['prov_display'] == 1) {
55 return self::$_states[$values->{$this->field_alias}];
58 return self::$_states_full[$values->{$this->field_alias}];
62 function option_definition() {
63 $options = parent::option_definition();
64 $options['prov_display'] = array('default' => '');
68 function options_form(&$form, &$form_state) {
69 parent::options_form($form, $form_state);
70 $form['prov_display'] = array(
72 '#title' => 'Display complete name or abbreviation',
73 '#options' => array(1 => 'Display state/province abbreviations', 2 => 'Display full state/province name'),
74 '#description' => t('Display full or abbreviated province name'),
75 '#default_value' => $this->options['prov_display'],