Newer
Older
<?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)) {
ErikHommel
committed
CRM_Nbrpanelconsentpack_BAO_ConsentPanelLink::savePanelLinks($form);
CRM_Nbrpanelconsentpack_BAO_ConsentPackLink::savePackLinks($form);
$form->ajaxResponse['updateTabs']['#tab_nbr_pack_id'] = 1;
/**
* 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);
function nbrpanelconsentpack_civicrm_validateForm(string $formName, array &$fields, array &$files, CRM_Core_Form &$form, array &$errors) {
if ($form instanceof CRM_Case_Form_Activity) {
CRM_Nbrpanelconsentpack_BAO_ConsentPackLink::validatePackIdFromForm($form, $fields, $errors);
}
}
/**
* Implements hook_civicrm_tabset().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tabset/
*/
function nbrpanelconsentpack_civicrm_tabset($tabsetName, &$tabs, $context) {
if ($tabsetName == 'civicrm/contact/view' && !empty($context['contact_id'])) {
if (CRM_Nbrpanelconsentpack_Utils::isVolunteer((int) $context['contact_id'])) {
$tabs[] = [
'id' => 'nbr_pack_id',
'url' => CRM_Utils_System::url('civicrm/nbrpanelconsentpack/page/packid', "reset=1&cid=" . $context['contact_id']),
'title' => E::ts('Pack IDs'),
'count' => CRM_Nbrpanelconsentpack_BAO_ConsentPackLink::countPackIds((int) $context['contact_id']),
'weight' => 30
];
}
}
}
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* 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;
}
}
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// --- 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);
//}