You are here

crm_core_contact.context.inc in CRM Core 8.2

Same filename and directory in other branches
  1. 8 modules/crm_core_contact/legacy/crm_core_contact.context.inc

Integration with context module.

File

modules/crm_core_contact/legacy/crm_core_contact.context.inc
View source
<?php

/**
 * @file
 * Integration with context module.
 */

/**
 * Implements hook_context_plugins().
 */
function crm_core_contact_context_plugins() {
  $plugins = array();
  $plugins['crm_core_contact_context_condition_contact_type'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'crm_core_contact') . '/includes/context',
      'file' => 'crm_core_contact_context_condition_contact_type.inc',
      'class' => 'crm_core_contact_context_condition_contact_type',
      'parent' => 'context_condition',
    ),
  );
  return $plugins;
}

/**
 * Implements hook_context_registry().
 */
function crm_core_contact_context_registry() {
  return array(
    'conditions' => array(
      'crm_core_contact_context_condition_contact_type' => array(
        'title' => t('CRM Core Contact Type'),
        'plugin' => 'crm_core_contact_context_condition_contact_type',
      ),
    ),
  );
}

/**
 * Implements hook_context_page_condition().
 */
function crm_core_contact_context_page_condition() {
  if ($plugin = context_get_plugin('condition', 'crm_core_contact_context_condition_contact_type')) {
    $contact = menu_get_object('crm_core_contact', 2);
    $op = '';
    if ($contact) {
      switch (arg(3)) {
        case '':
          $op = 'view';
          break;
        case 'edit':
          $op = 'form';
          break;
      }
    }

    // Also execute context on contact add page.
    if (strpos($_GET['q'], 'crm-core/contact/add') !== FALSE) {
      $contact = entity_create('crm_core_contact', array(
        'type' => arg(3),
      ));
      $op = 'edit';
    }
    if ($op) {
      $plugin
        ->execute($contact, $op);
    }
  }
}

Functions

Namesort descending Description
crm_core_contact_context_page_condition Implements hook_context_page_condition().
crm_core_contact_context_plugins Implements hook_context_plugins().
crm_core_contact_context_registry Implements hook_context_registry().