You are here

function crm_core_contact_context_page_condition in CRM Core 7

Same name and namespace in other branches
  1. 8 modules/crm_core_contact/legacy/crm_core_contact.context.inc \crm_core_contact_context_page_condition()
  2. 8.2 modules/crm_core_contact/legacy/crm_core_contact.context.inc \crm_core_contact_context_page_condition()

Implements hook_context_page_condition().

File

modules/crm_core_contact/crm_core_contact.context.inc, line 41
Integration with context module.

Code

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);
    }
  }
}