Created
April 12, 2011 17:00
-
-
Save bangpound/915918 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
*/ | |
class tsccivicrm_handler_field_primary_phone extends views_handler_field { | |
function option_definition() { | |
$options = parent::option_definition(); | |
$options['phone_type'] = array('default' => '1'); | |
return $options; | |
} | |
/** | |
* Provide link to the page being visited. | |
*/ | |
function options_form(&$form, &$form_state) { | |
parent::options_form($form, $form_state); | |
civicrm_initialize(); | |
require_once 'api/v2/Constant.php'; | |
// List phone types. | |
$form['phone_type'] = array( | |
'#title' => t('Phone type'), | |
'#type' => 'select', | |
'#options' => civicrm_constant_get('phoneType'), | |
'#default_value' => $this->options['phone_type'], | |
); | |
} | |
function query() { | |
$this->ensure_my_table(); | |
$join = new views_join(); | |
$join->construct('civicrm_phone', $this->table_alias, 'id', 'contact_id'); | |
$join->extra = array(); | |
$join->extra[] = array('field' => 'phone_type_id', 'operator' => '=', 'value' => $this->options['phone_type']); | |
$this->phone_table = $this->query->add_table('contact_phone', $this->relationship, $join); | |
// Add the field. | |
$this->field_alias = $this->query->add_field($this->phone_table, 'phone'); | |
$this->add_additional_fields(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment