Skip to content
Snippets Groups Projects
nbrpanelconsentpack.php 4.81 KiB
Newer Older
ErikHommel's avatar
ErikHommel committed
<?php

require_once 'nbrpanelconsentpack.civix.php';
// phpcs:disable
use CRM_Nbrpanelconsentpack_ExtensionUtil as E;
// phpcs:enable

/**
 * Implements hook_civicrm_config().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
 */
function nbrpanelconsentpack_civicrm_config(&$config) {
  _nbrpanelconsentpack_civix_civicrm_config($config);
}

/**
 * Implements hook_civicrm_postProcess().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postProcess
 */
function nbrpanelconsentpack_civicrm_postProcess($formName, $form) {
  if ($form instanceof CRM_Case_Form_Activity) {
    // only if consent activity and create or edit
    if ($form->_action == CRM_Core_Action::ADD || $form->_action == CRM_Core_Action::UPDATE) {
      $activityTypeId = (int) $form->getVar('_activityTypeId');
      if (CRM_Nbrpanelconsentpack_Utils::isValidActivityType($activityTypeId)) {
        $contactId = (int) $form->getVar('_currentlyViewedContactId');
        $activityId = (int) $form->getVar('_activityId');
        CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/nbrpanelconsentpack/form/panelpacklink', 'reset=1&cid='
          . $contactId . '&aid=' . $activityId . '&action=' . $form->_action, TRUE));
      }
ErikHommel's avatar
ErikHommel committed
    }
  }
}
/**
 * Implements hook_civicrm_buildForm().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm
 */
function nbrpanelconsentpack_civicrm_buildForm($formName, &$form) {
  if ($form instanceof CRM_Case_Form_ActivityView) {
    $activityId = (int) CRM_Utils_Request::retrieveValue('aid', "Integer");
    $activityTypeId = CRM_Nbrpanelconsentpack_Utils::getActivityTypeId((int) $activityId);
    if (CRM_Nbrpanelconsentpack_Utils::isValidActivityType($activityTypeId)) {
      CRM_Nbrpanelconsentpack_BAO_ConsentPackLink::addPackLinksToView($form);
      CRM_Nbrpanelconsentpack_BAO_ConsentPanelLink::addPanelLinksToView($form);
      CRM_Core_Region::instance('page-body')->add(['template' => 'CRM/Nbrpanelconsentpack/ActivityViewLinks.tpl']);
    }
  if ($form instanceof CRM_Case_Form_Activity) {
    CRM_Nbrpanelconsentpack_BAO_ConsentPanelLink::addPanelPackLinksToConsent($form);
ErikHommel's avatar
ErikHommel committed
/**
 * Implements hook_civicrm_install().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
 */
function nbrpanelconsentpack_civicrm_install() {
  _nbrpanelconsentpack_civix_civicrm_install();
}

/**
 * Implements hook_civicrm_postInstall().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
 */
function nbrpanelconsentpack_civicrm_postInstall() {
  _nbrpanelconsentpack_civix_civicrm_postInstall();
}

/**
 * Implements hook_civicrm_uninstall().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
 */
function nbrpanelconsentpack_civicrm_uninstall() {
  _nbrpanelconsentpack_civix_civicrm_uninstall();
}

/**
 * Implements hook_civicrm_enable().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
 */
function nbrpanelconsentpack_civicrm_enable() {
  _nbrpanelconsentpack_civix_civicrm_enable();
}

/**
 * Implements hook_civicrm_disable().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
 */
function nbrpanelconsentpack_civicrm_disable() {
  _nbrpanelconsentpack_civix_civicrm_disable();
}

/**
 * Implements hook_civicrm_upgrade().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
 */
function nbrpanelconsentpack_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
  return _nbrpanelconsentpack_civix_civicrm_upgrade($op, $queue);
}

/**
 * Implements hook_civicrm_entityTypes().
 *
 * Declare entity types provided by this module.
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
 */
function nbrpanelconsentpack_civicrm_entityTypes(&$entityTypes) {
  _nbrpanelconsentpack_civix_civicrm_entityTypes($entityTypes);
}
function nbrpanelconsentpack_civicrm_xmlMenu(&$files) {
  foreach (glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
    $files[] = $file;
  }
}
ErikHommel's avatar
ErikHommel committed

// --- Functions below this ship commented out. Uncomment as required. ---

/**
 * Implements hook_civicrm_preProcess().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_preProcess
 */
//function nbrpanelconsentpack_civicrm_preProcess($formName, &$form) {
//
//}

/**
 * Implements hook_civicrm_navigationMenu().
 *
 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
 */
//function nbrpanelconsentpack_civicrm_navigationMenu(&$menu) {
//  _nbrpanelconsentpack_civix_insert_navigation_menu($menu, 'Mailings', [
//    'label' => E::ts('New subliminal message'),
//    'name' => 'mailing_subliminal_message',
//    'url' => 'civicrm/mailing/subliminal',
//    'permission' => 'access CiviMail',
//    'operator' => 'OR',
//    'separator' => 0,
//  ]);
//  _nbrpanelconsentpack_civix_navigationMenu($menu);
//}