class crm_core_contact_context_condition_contact_type in CRM Core 8.2
Same name and namespace in other branches
- 8 modules/crm_core_contact/legacy/context/crm_core_contact_context_condition_contact_type.inc \crm_core_contact_context_condition_contact_type
- 7 modules/crm_core_contact/includes/context/crm_core_contact_context_condition_contact_type.inc \crm_core_contact_context_condition_contact_type
Expose node views/node forms of specific node types as a context condition.
Hierarchy
- class \crm_core_contact_context_condition_contact_type extends \context_condition
Expanded class hierarchy of crm_core_contact_context_condition_contact_type
3 string references to 'crm_core_contact_context_condition_contact_type'
- crm_core_contact_context_page_condition in modules/
crm_core_contact/ legacy/ crm_core_contact.context.inc - Implements hook_context_page_condition().
- crm_core_contact_context_plugins in modules/
crm_core_contact/ legacy/ crm_core_contact.context.inc - Implements hook_context_plugins().
- crm_core_contact_context_registry in modules/
crm_core_contact/ legacy/ crm_core_contact.context.inc - Implements hook_context_registry().
File
- modules/
crm_core_contact/ legacy/ context/ crm_core_contact_context_condition_contact_type.inc, line 28 - Class for determining if the user is in the right contact context.
View source
class crm_core_contact_context_condition_contact_type extends context_condition {
function condition_values() {
$values = array();
foreach (ContactType::loadMultiple() as $type) {
$values[$type->type] = check_plain($type->name);
}
return $values;
}
function options_form($context) {
$defaults = $this
->fetch_from_context($context, 'options');
return array(
'contact_form' => array(
'#title' => t('Set on contact form'),
'#type' => 'select',
'#options' => array(
CONTEXT_CRM_CONTACT_VIEW => t('No'),
CONTEXT_CRM_CONTACT_NODE_FORM => t('Yes'),
CONTEXT_CRM_CONTACT_NODE_FORM_ONLY => t('Only on contact form'),
),
'#description' => t('Set this context on contact forms'),
'#default_value' => isset($defaults['contact_form']) ? $defaults['contact_form'] : TRUE,
),
);
}
function execute($contact, $op) {
foreach ($this
->get_contexts($contact->type) as $context) {
$options = $this
->fetch_from_context($context, 'options');
if ($op === 'form') {
$options = $this
->fetch_from_context($context, 'options');
if (!empty($options['contact_form']) && in_array($options['contact_form'], array(
CONTEXT_CRM_CONTACT_NODE_FORM,
CONTEXT_CRM_CONTACT_NODE_FORM_ONLY,
))) {
$this
->condition_met($context, $contact->type);
}
}
elseif (empty($options['contact_form']) || $options['contact_form'] != CONTEXT_CRM_CONTACT_NODE_FORM_ONLY) {
$this
->condition_met($context, $contact->type);
}
}
}
}