You are here

class crm_core_contact_context_condition_contact_type in CRM Core 7

Same name and namespace in other branches
  1. 8 modules/crm_core_contact/legacy/context/crm_core_contact_context_condition_contact_type.inc \crm_core_contact_context_condition_contact_type
  2. 8.2 modules/crm_core_contact/legacy/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

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/crm_core_contact.context.inc
Implements hook_context_page_condition().
crm_core_contact_context_plugins in modules/crm_core_contact/crm_core_contact.context.inc
Implements hook_context_plugins().
crm_core_contact_context_registry in modules/crm_core_contact/crm_core_contact.context.inc
Implements hook_context_registry().

File

modules/crm_core_contact/includes/context/crm_core_contact_context_condition_contact_type.inc, line 26
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 (crm_core_contact_types() 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);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
context_condition::$description property
context_condition::$plugin property
context_condition::$title property
context_condition::$values property
context_condition::condition_form function Condition form. 3
context_condition::condition_form_submit function Condition form submit handler. 2
context_condition::condition_met function Marks a context as having met this particular condition.
context_condition::condition_used function Check whether this condition is used by any contexts. Can be used to prevent expensive condition checks from being triggered when no contexts use this condition.
context_condition::editor_form function Context editor form for conditions. 2
context_condition::editor_form_submit function Context editor form submit handler.
context_condition::fetch_from_context function Retrieve options from the context provided.
context_condition::get_contexts function Retrieve all contexts with the condition value provided. 2
context_condition::options_form_submit function Options form submit handler.
context_condition::settings_form function Settings form. Provide variable settings for your condition.
context_condition::__clone function Clone our references when we're being cloned.
context_condition::__construct function Constructor. Do not override.
crm_core_contact_context_condition_contact_type::condition_values function Condition values. Overrides context_condition::condition_values
crm_core_contact_context_condition_contact_type::execute function
crm_core_contact_context_condition_contact_type::options_form function Options form. Provide additional options for your condition. Overrides context_condition::options_form