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 for phone field
29 * @ingroup civicrm_field_handlers
31 class civicrm_handler_field_phone extends civicrm_handler_field_location {
33 function construct() {
35 if (!self::$_phoneType) {
36 if (!civicrm_initialize()) {
39 self::$_phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
43 function option_definition() {
44 $options = parent::option_definition();
45 $options['phone_type'] = array('default' => 0);
49 function options_form(&$form, &$form_state) {
50 parent::options_form($form, $form_state);
51 $phoneOptions = array(0 => 'Any');
52 foreach (self::$_phoneType as $id => $type) {
53 $phoneOptions[$id] = $type;
55 $form['phone_type'] = array(
57 '#title' => 'Phone type for this field',
58 '#options' => $phoneOptions,
59 '#description' => t('Phone type to be displayed for this field'),
60 '#default_value' => $this->options['phone_type'],
61 '#fieldset' => 'location_choices',
65 function ensure_my_table() {
66 if (!isset($this->table_alias)) {
67 if (!method_exists($this->query, 'ensure_table')) {
71 if (isset($this->options['phone_type']) && $this->options['phone_type']) {
72 $join = $this->get_join();
73 $extra = parent::location_extras();
75 'value' => $this->options['phone_type'],
77 'field' => 'phone_type_id',
80 $join->extra = $extra;
81 $join->extra_type = self::$_locationOps[$this->options['location_op']];
82 $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join);
85 $join = $this->get_join();
86 $join->extra = parent::location_extras();
87 $join->extra_type = self::$_locationOps[$this->options['location_op']];
88 $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join);
91 return $this->table_alias;