| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 6 | | This work is published under the GNU AGPLv3 license with some | |
| 7 | | permitted exceptions and without any warranty. For full license | |
| 8 | | and copyright information, see https://civicrm.org/licensing | |
| 9 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * |
| 14 | * @package CiviCRM_Hook |
| 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 16 | */ |
| 17 | abstract class CRM_Utils_Hook { |
| 18 | |
| 19 | // Allowed values for dashboard hook content placement |
| 20 | // Default - place content below activity list |
| 21 | const DASHBOARD_BELOW = 1; |
| 22 | // Place content above activity list |
| 23 | const DASHBOARD_ABOVE = 2; |
| 24 | // Don't display activity list at all |
| 25 | const DASHBOARD_REPLACE = 3; |
| 26 | |
| 27 | // by default - place content below existing content |
| 28 | const SUMMARY_BELOW = 1; |
| 29 | // place hook content above |
| 30 | const SUMMARY_ABOVE = 2; |
| 31 | /** |
| 32 | *create your own summaries |
| 33 | */ |
| 34 | const SUMMARY_REPLACE = 3; |
| 35 | |
| 36 | /** |
| 37 | * Object to pass when an object is required to be passed by params. |
| 38 | * |
| 39 | * This is supposed to be a convenience but note that it is a bad |
| 40 | * pattern as it can get contaminated & result in hard-to-diagnose bugs. |
| 41 | * |
| 42 | * @var null |
| 43 | */ |
| 44 | public static $_nullObject = NULL; |
| 45 | |
| 46 | /** |
| 47 | * We only need one instance of this object. So we use the singleton |
| 48 | * pattern and cache the instance in this variable |
| 49 | * |
| 50 | * @var CRM_Utils_Hook |
| 51 | */ |
| 52 | static private $_singleton = NULL; |
| 53 | |
| 54 | /** |
| 55 | * @var bool |
| 56 | */ |
| 57 | private $commonIncluded = FALSE; |
| 58 | |
| 59 | /** |
| 60 | * @var array|string |
| 61 | */ |
| 62 | private $commonCiviModules = []; |
| 63 | |
| 64 | /** |
| 65 | * @var CRM_Utils_Cache_Interface |
| 66 | */ |
| 67 | protected $cache; |
| 68 | |
| 69 | /** |
| 70 | * Constructor and getter for the singleton instance. |
| 71 | * |
| 72 | * @param bool $fresh |
| 73 | * |
| 74 | * @return CRM_Utils_Hook |
| 75 | * An instance of $config->userHookClass |
| 76 | */ |
| 77 | public static function singleton($fresh = FALSE) { |
| 78 | if (self::$_singleton == NULL || $fresh) { |
| 79 | $config = CRM_Core_Config::singleton(); |
| 80 | $class = $config->userHookClass; |
| 81 | self::$_singleton = new $class(); |
| 82 | } |
| 83 | return self::$_singleton; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * CRM_Utils_Hook constructor. |
| 88 | * |
| 89 | * @throws \CRM_Core_Exception |
| 90 | */ |
| 91 | public function __construct() { |
| 92 | $this->cache = CRM_Utils_Cache::create([ |
| 93 | 'name' => 'hooks', |
| 94 | 'type' => ['ArrayCache'], |
| 95 | 'prefetch' => 1, |
| 96 | ]); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Invoke a hook through the UF/CMS hook system and the extension-hook |
| 101 | * system. |
| 102 | * |
| 103 | * @param int $numParams |
| 104 | * Number of parameters to pass to the hook. |
| 105 | * @param mixed $arg1 |
| 106 | * Parameter to be passed to the hook. |
| 107 | * @param mixed $arg2 |
| 108 | * Parameter to be passed to the hook. |
| 109 | * @param mixed $arg3 |
| 110 | * Parameter to be passed to the hook. |
| 111 | * @param mixed $arg4 |
| 112 | * Parameter to be passed to the hook. |
| 113 | * @param mixed $arg5 |
| 114 | * Parameter to be passed to the hook. |
| 115 | * @param mixed $arg6 |
| 116 | * Parameter to be passed to the hook. |
| 117 | * @param string $fnSuffix |
| 118 | * Function suffix, this is effectively the hook name. |
| 119 | * |
| 120 | * @return mixed |
| 121 | */ |
| 122 | abstract public function invokeViaUF( |
| 123 | $numParams, |
| 124 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, |
| 125 | $fnSuffix |
| 126 | ); |
| 127 | |
| 128 | /** |
| 129 | * Invoke a hook. |
| 130 | * |
| 131 | * This is a transitional adapter. It supports the legacy syntax |
| 132 | * but also accepts enough information to support Symfony Event |
| 133 | * dispatching. |
| 134 | * |
| 135 | * @param array $names |
| 136 | * (Recommended) Array of parameter names, in order. |
| 137 | * Using an array is recommended because it enables full |
| 138 | * event-broadcasting behaviors. |
| 139 | * (Legacy) Number of parameters to pass to the hook. |
| 140 | * This is provided for transitional purposes. |
| 141 | * @param mixed $arg1 |
| 142 | * @param mixed $arg2 |
| 143 | * @param mixed $arg3 |
| 144 | * @param mixed $arg4 |
| 145 | * @param mixed $arg5 |
| 146 | * @param mixed $arg6 |
| 147 | * @param mixed $fnSuffix |
| 148 | * @return mixed |
| 149 | */ |
| 150 | public function invoke( |
| 151 | $names, |
| 152 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, |
| 153 | $fnSuffix |
| 154 | ) { |
| 155 | if (!is_array($names)) { |
| 156 | // We were called with the old contract wherein $names is actually an int. |
| 157 | // Symfony dispatcher requires some kind of name. |
| 158 | Civi::log()->warning("hook_$fnSuffix should be updated to pass an array of parameter names to CRM_Utils_Hook::invoke().", ['civi.tag' => 'deprecated']); |
| 159 | $compatNames = ['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6']; |
| 160 | $names = array_slice($compatNames, 0, (int) $names); |
| 161 | } |
| 162 | |
| 163 | $event = \Civi\Core\Event\GenericHookEvent::createOrdered( |
| 164 | $names, |
| 165 | [&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6] |
| 166 | ); |
| 167 | \Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event); |
| 168 | return $event->getReturnValues(); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * @param array $numParams |
| 173 | * @param $arg1 |
| 174 | * @param $arg2 |
| 175 | * @param $arg3 |
| 176 | * @param $arg4 |
| 177 | * @param $arg5 |
| 178 | * @param $arg6 |
| 179 | * @param $fnSuffix |
| 180 | * @param $fnPrefix |
| 181 | * |
| 182 | * @return array|bool |
| 183 | */ |
| 184 | public function commonInvoke( |
| 185 | $numParams, |
| 186 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, |
| 187 | $fnSuffix, $fnPrefix |
| 188 | ) { |
| 189 | |
| 190 | $this->commonBuildModuleList($fnPrefix); |
| 191 | |
| 192 | return $this->runHooks($this->commonCiviModules, $fnSuffix, |
| 193 | $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6 |
| 194 | ); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Build the list of modules to be processed for hooks. |
| 199 | * |
| 200 | * @param string $fnPrefix |
| 201 | */ |
| 202 | public function commonBuildModuleList($fnPrefix) { |
| 203 | if (!$this->commonIncluded) { |
| 204 | // include external file |
| 205 | $this->commonIncluded = TRUE; |
| 206 | |
| 207 | $config = CRM_Core_Config::singleton(); |
| 208 | if (!empty($config->customPHPPathDir)) { |
| 209 | $civicrmHooksFile = CRM_Utils_File::addTrailingSlash($config->customPHPPathDir) . 'civicrmHooks.php'; |
| 210 | if (file_exists($civicrmHooksFile)) { |
| 211 | @include_once $civicrmHooksFile; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | if (!empty($fnPrefix)) { |
| 216 | $this->commonCiviModules[$fnPrefix] = $fnPrefix; |
| 217 | } |
| 218 | |
| 219 | $this->requireCiviModules($this->commonCiviModules); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Run hooks. |
| 225 | * |
| 226 | * @param array $civiModules |
| 227 | * @param string $fnSuffix |
| 228 | * @param int $numParams |
| 229 | * @param mixed $arg1 |
| 230 | * @param mixed $arg2 |
| 231 | * @param mixed $arg3 |
| 232 | * @param mixed $arg4 |
| 233 | * @param mixed $arg5 |
| 234 | * @param mixed $arg6 |
| 235 | * |
| 236 | * @return array|bool |
| 237 | * @throws \CRM_Core_Exception |
| 238 | */ |
| 239 | public function runHooks( |
| 240 | $civiModules, $fnSuffix, $numParams, |
| 241 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6 |
| 242 | ) { |
| 243 | // $civiModules is *not* passed by reference because runHooks |
| 244 | // must be reentrant. PHP is finicky about running |
| 245 | // multiple loops over the same variable. The circumstances |
| 246 | // to reproduce the issue are pretty intricate. |
| 247 | $result = []; |
| 248 | |
| 249 | $fnNames = $this->cache->get($fnSuffix); |
| 250 | if (!is_array($fnNames)) { |
| 251 | $fnNames = []; |
| 252 | if ($civiModules !== NULL) { |
| 253 | foreach ($civiModules as $module) { |
| 254 | $fnName = "{$module}_{$fnSuffix}"; |
| 255 | if (function_exists($fnName)) { |
| 256 | $fnNames[] = $fnName; |
| 257 | } |
| 258 | } |
| 259 | $this->cache->set($fnSuffix, $fnNames); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | foreach ($fnNames as $fnName) { |
| 264 | $fResult = []; |
| 265 | switch ($numParams) { |
| 266 | case 0: |
| 267 | $fResult = $fnName(); |
| 268 | break; |
| 269 | |
| 270 | case 1: |
| 271 | $fResult = $fnName($arg1); |
| 272 | break; |
| 273 | |
| 274 | case 2: |
| 275 | $fResult = $fnName($arg1, $arg2); |
| 276 | break; |
| 277 | |
| 278 | case 3: |
| 279 | $fResult = $fnName($arg1, $arg2, $arg3); |
| 280 | break; |
| 281 | |
| 282 | case 4: |
| 283 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4); |
| 284 | break; |
| 285 | |
| 286 | case 5: |
| 287 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5); |
| 288 | break; |
| 289 | |
| 290 | case 6: |
| 291 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6); |
| 292 | break; |
| 293 | |
| 294 | default: |
| 295 | throw new CRM_Core_Exception(ts('Invalid hook invocation')); |
| 296 | } |
| 297 | |
| 298 | if (!empty($fResult) && |
| 299 | is_array($fResult) |
| 300 | ) { |
| 301 | $result = array_merge($result, $fResult); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | return empty($result) ? TRUE : $result; |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * @param $moduleList |
| 310 | */ |
| 311 | public function requireCiviModules(&$moduleList) { |
| 312 | $civiModules = CRM_Core_PseudoConstant::getModuleExtensions(); |
| 313 | foreach ($civiModules as $civiModule) { |
| 314 | if (!file_exists($civiModule['filePath'])) { |
| 315 | CRM_Core_Session::setStatus( |
| 316 | ts('Error loading module file (%1). Please restore the file or disable the module.', |
| 317 | [1 => $civiModule['filePath']]), |
| 318 | ts('Warning'), 'error'); |
| 319 | continue; |
| 320 | } |
| 321 | include_once $civiModule['filePath']; |
| 322 | $moduleList[$civiModule['prefix']] = $civiModule['prefix']; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * This hook is called before a db write on some core objects. |
| 328 | * This hook does not allow the abort of the operation |
| 329 | * |
| 330 | * @param string $op |
| 331 | * The type of operation being performed. |
| 332 | * @param string $objectName |
| 333 | * The name of the object. |
| 334 | * @param int $id |
| 335 | * The object id if available. |
| 336 | * @param array $params |
| 337 | * The parameters used for object creation / editing. |
| 338 | * |
| 339 | * @return null |
| 340 | * the return value is ignored |
| 341 | */ |
| 342 | public static function pre($op, $objectName, $id, &$params) { |
| 343 | $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params); |
| 344 | \Civi::dispatcher()->dispatch('hook_civicrm_pre', $event); |
| 345 | return $event->getReturnValues(); |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * This hook is called after a db write on some core objects. |
| 350 | * |
| 351 | * @param string $op |
| 352 | * The type of operation being performed. |
| 353 | * @param string $objectName |
| 354 | * The name of the object. |
| 355 | * @param int $objectId |
| 356 | * The unique identifier for the object. |
| 357 | * @param object $objectRef |
| 358 | * The reference to the object if available. |
| 359 | * |
| 360 | * @return mixed |
| 361 | * based on op. pre-hooks return a boolean or |
| 362 | * an error message which aborts the operation |
| 363 | */ |
| 364 | public static function post($op, $objectName, $objectId, &$objectRef = NULL) { |
| 365 | $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef); |
| 366 | \Civi::dispatcher()->dispatch('hook_civicrm_post', $event); |
| 367 | return $event->getReturnValues(); |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * This hook is equivalent to post(), except that it is guaranteed to run |
| 372 | * outside of any SQL transaction. The objectRef is not modifiable. |
| 373 | * |
| 374 | * This hook is defined for two cases: |
| 375 | * |
| 376 | * 1. If the original action runs within a transaction, then the hook fires |
| 377 | * after the transaction commits. |
| 378 | * 2. If the original action runs outside a transaction, then the data was |
| 379 | * committed immediately, and we can run the hook immediately. |
| 380 | * |
| 381 | * @param string $op |
| 382 | * The type of operation being performed. |
| 383 | * @param string $objectName |
| 384 | * The name of the object. |
| 385 | * @param int $objectId |
| 386 | * The unique identifier for the object. |
| 387 | * @param object $objectRef |
| 388 | * The reference to the object if available. |
| 389 | * |
| 390 | * @return mixed |
| 391 | * based on op. pre-hooks return a boolean or |
| 392 | * an error message which aborts the operation |
| 393 | */ |
| 394 | public static function postCommit($op, $objectName, $objectId, $objectRef = NULL) { |
| 395 | $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef); |
| 396 | \Civi::dispatcher()->dispatch('hook_civicrm_postCommit', $event); |
| 397 | return $event->getReturnValues(); |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * This hook retrieves links from other modules and injects it into. |
| 402 | * the view contact tabs |
| 403 | * |
| 404 | * @param string $op |
| 405 | * The type of operation being performed. |
| 406 | * @param string $objectName |
| 407 | * The name of the object. |
| 408 | * @param int $objectId |
| 409 | * The unique identifier for the object. |
| 410 | * @param array $links |
| 411 | * (optional) the links array (introduced in v3.2). |
| 412 | * @param int $mask |
| 413 | * (optional) the bitmask to show/hide links. |
| 414 | * @param array $values |
| 415 | * (optional) the values to fill the links. |
| 416 | * |
| 417 | * @return null |
| 418 | * the return value is ignored |
| 419 | */ |
| 420 | public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) { |
| 421 | return self::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links'); |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Alter the contents of a resource bundle (ie a collection of JS/CSS/etc). |
| 426 | * |
| 427 | * TIP: $bundle->add*() and $bundle->filter() should be useful for |
| 428 | * adding/removing/updating items. |
| 429 | * |
| 430 | * @param CRM_Core_Resources_Bundle $bundle |
| 431 | * @return null |
| 432 | * @see CRM_Core_Resources_CollectionInterface::add() |
| 433 | * @see CRM_Core_Resources_CollectionInterface::filter() |
| 434 | */ |
| 435 | public static function alterBundle($bundle) { |
| 436 | return self::singleton() |
| 437 | ->invoke(['bundle'], $bundle, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterBundle'); |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * This hook is invoked during the CiviCRM form preProcess phase. |
| 442 | * |
| 443 | * @param string $formName |
| 444 | * The name of the form. |
| 445 | * @param CRM_Core_Form $form |
| 446 | * Reference to the form object. |
| 447 | * |
| 448 | * @return null |
| 449 | * the return value is ignored |
| 450 | */ |
| 451 | public static function preProcess($formName, &$form) { |
| 452 | return self::singleton() |
| 453 | ->invoke(['formName', 'form'], $formName, $form, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_preProcess'); |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * This hook is invoked when building a CiviCRM form. This hook should also |
| 458 | * be used to set the default values of a form element |
| 459 | * |
| 460 | * @param string $formName |
| 461 | * The name of the form. |
| 462 | * @param CRM_Core_Form $form |
| 463 | * Reference to the form object. |
| 464 | * |
| 465 | * @return null |
| 466 | * the return value is ignored |
| 467 | */ |
| 468 | public static function buildForm($formName, &$form) { |
| 469 | return self::singleton()->invoke(['formName', 'form'], $formName, $form, |
| 470 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 471 | 'civicrm_buildForm' |
| 472 | ); |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * This hook is invoked when a CiviCRM form is submitted. If the module has injected |
| 477 | * any form elements, this hook should save the values in the database |
| 478 | * |
| 479 | * @param string $formName |
| 480 | * The name of the form. |
| 481 | * @param CRM_Core_Form $form |
| 482 | * Reference to the form object. |
| 483 | * |
| 484 | * @return null |
| 485 | * the return value is ignored |
| 486 | */ |
| 487 | public static function postProcess($formName, &$form) { |
| 488 | return self::singleton()->invoke(['formName', 'form'], $formName, $form, |
| 489 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 490 | 'civicrm_postProcess' |
| 491 | ); |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * This hook is invoked during all CiviCRM form validation. An array of errors |
| 496 | * detected is returned. Else we assume validation succeeded. |
| 497 | * |
| 498 | * @param string $formName |
| 499 | * The name of the form. |
| 500 | * @param array &$fields the POST parameters as filtered by QF |
| 501 | * @param array &$files the FILES parameters as sent in by POST |
| 502 | * @param array &$form the form object |
| 503 | * @param array &$errors the array of errors. |
| 504 | * |
| 505 | * @return mixed |
| 506 | * formRule hooks return a boolean or |
| 507 | * an array of error messages which display a QF Error |
| 508 | */ |
| 509 | public static function validateForm($formName, &$fields, &$files, &$form, &$errors) { |
| 510 | return self::singleton() |
| 511 | ->invoke(['formName', 'fields', 'files', 'form', 'errors'], |
| 512 | $formName, $fields, $files, $form, $errors, self::$_nullObject, 'civicrm_validateForm'); |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * This hook is called after a db write on a custom table. |
| 517 | * |
| 518 | * @param string $op |
| 519 | * The type of operation being performed. |
| 520 | * @param string $groupID |
| 521 | * The custom group ID. |
| 522 | * @param object $entityID |
| 523 | * The entityID of the row in the custom table. |
| 524 | * @param array $params |
| 525 | * The parameters that were sent into the calling function. |
| 526 | * |
| 527 | * @return null |
| 528 | * the return value is ignored |
| 529 | */ |
| 530 | public static function custom($op, $groupID, $entityID, &$params) { |
| 531 | return self::singleton() |
| 532 | ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom'); |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * This hook is called before a db write on a custom table. |
| 537 | * |
| 538 | * @param string $op |
| 539 | * The type of operation being performed. |
| 540 | * @param string $groupID |
| 541 | * The custom group ID. |
| 542 | * @param object $entityID |
| 543 | * The entityID of the row in the custom table. |
| 544 | * @param array $params |
| 545 | * The parameters that were sent into the calling function. |
| 546 | * |
| 547 | * @return null |
| 548 | * the return value is ignored |
| 549 | */ |
| 550 | public static function customPre($op, $groupID, $entityID, &$params) { |
| 551 | return self::singleton() |
| 552 | ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_customPre'); |
| 553 | } |
| 554 | |
| 555 | /** |
| 556 | * This hook is called when composing the ACL where clause to restrict |
| 557 | * visibility of contacts to the logged in user |
| 558 | * |
| 559 | * @param int $type |
| 560 | * The type of permission needed. |
| 561 | * @param array $tables |
| 562 | * (reference ) add the tables that are needed for the select clause. |
| 563 | * @param array $whereTables |
| 564 | * (reference ) add the tables that are needed for the where clause. |
| 565 | * @param int $contactID |
| 566 | * The contactID for whom the check is made. |
| 567 | * @param string $where |
| 568 | * The currrent where clause. |
| 569 | * |
| 570 | * @return null |
| 571 | * the return value is ignored |
| 572 | */ |
| 573 | public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) { |
| 574 | return self::singleton() |
| 575 | ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self::$_nullObject, 'civicrm_aclWhereClause'); |
| 576 | } |
| 577 | |
| 578 | /** |
| 579 | * This hook is called when composing the ACL where clause to restrict |
| 580 | * visibility of contacts to the logged in user |
| 581 | * |
| 582 | * @param int $type |
| 583 | * The type of permission needed. |
| 584 | * @param int $contactID |
| 585 | * The contactID for whom the check is made. |
| 586 | * @param string $tableName |
| 587 | * The tableName which is being permissioned. |
| 588 | * @param array $allGroups |
| 589 | * The set of all the objects for the above table. |
| 590 | * @param array $currentGroups |
| 591 | * The set of objects that are currently permissioned for this contact. |
| 592 | * |
| 593 | * @return null |
| 594 | * the return value is ignored |
| 595 | */ |
| 596 | public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) { |
| 597 | return self::singleton() |
| 598 | ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self::$_nullObject, 'civicrm_aclGroup'); |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * @param string|CRM_Core_DAO $entity |
| 603 | * @param array $clauses |
| 604 | * @return mixed |
| 605 | */ |
| 606 | public static function selectWhereClause($entity, &$clauses) { |
| 607 | $entityName = is_object($entity) ? _civicrm_api_get_entity_name_from_dao($entity) : $entity; |
| 608 | return self::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses, |
| 609 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 610 | 'civicrm_selectWhereClause' |
| 611 | ); |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * This hook is called when building the menu table. |
| 616 | * |
| 617 | * @param array $files |
| 618 | * The current set of files to process. |
| 619 | * |
| 620 | * @return null |
| 621 | * the return value is ignored |
| 622 | */ |
| 623 | public static function xmlMenu(&$files) { |
| 624 | return self::singleton()->invoke(['files'], $files, |
| 625 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 626 | 'civicrm_xmlMenu' |
| 627 | ); |
| 628 | } |
| 629 | |
| 630 | /** |
| 631 | * (Experimental) This hook is called when build the menu table. |
| 632 | * |
| 633 | * @param array $items |
| 634 | * List of records to include in menu table. |
| 635 | * @return null |
| 636 | * the return value is ignored |
| 637 | */ |
| 638 | public static function alterMenu(&$items) { |
| 639 | return self::singleton()->invoke(['items'], $items, |
| 640 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 641 | 'civicrm_alterMenu' |
| 642 | ); |
| 643 | } |
| 644 | |
| 645 | /** |
| 646 | * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new |
| 647 | * theme, add it to the $themes array. Use these properties: |
| 648 | * |
| 649 | * - ext: string (required) |
| 650 | * The full name of the extension which defines the theme. |
| 651 | * Ex: "org.civicrm.themes.greenwich". |
| 652 | * - title: string (required) |
| 653 | * Visible title. |
| 654 | * - help: string (optional) |
| 655 | * Description of the theme's appearance. |
| 656 | * - url_callback: mixed (optional) |
| 657 | * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource. |
| 658 | * Returns either an array of URLs or PASSTHRU. |
| 659 | * Ex: \Civi\Core\Themes\Resolvers::simple (default) |
| 660 | * Ex: \Civi\Core\Themes\Resolvers::none |
| 661 | * - prefix: string (optional) |
| 662 | * A prefix within the extension folder to prepend to the file name. |
| 663 | * - search_order: array (optional) |
| 664 | * A list of themes to search. |
| 665 | * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK). |
| 666 | * - excludes: array (optional) |
| 667 | * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never |
| 668 | * be returned (they are excluded from display). |
| 669 | * |
| 670 | * @param array $themes |
| 671 | * List of themes, keyed by name. |
| 672 | * @return null |
| 673 | * the return value is ignored |
| 674 | */ |
| 675 | public static function themes(&$themes) { |
| 676 | return self::singleton()->invoke(['themes'], $themes, |
| 677 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 678 | 'civicrm_themes' |
| 679 | ); |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * The activeTheme hook determines which theme is active. |
| 684 | * |
| 685 | * @param string $theme |
| 686 | * The identifier for the theme. Alterable. |
| 687 | * Ex: 'greenwich'. |
| 688 | * @param array $context |
| 689 | * Information about the current page-request. Includes some mix of: |
| 690 | * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard'). |
| 691 | * - themes: an instance of the Civi\Core\Themes service. |
| 692 | * @return null |
| 693 | * the return value is ignored |
| 694 | */ |
| 695 | public static function activeTheme(&$theme, $context) { |
| 696 | return self::singleton()->invoke(['theme', 'context'], $theme, $context, |
| 697 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 698 | 'civicrm_activeTheme' |
| 699 | ); |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * This hook is called for declaring managed entities via API. |
| 704 | * |
| 705 | * @param array $entities |
| 706 | * List of pending entities. Each entity is an array with keys: |
| 707 | * + 'module': string; for module-extensions, this is the fully-qualifed name (e.g. "com.example.mymodule"); for CMS modules, the name is prefixed by the CMS (e.g. "drupal.mymodule") |
| 708 | * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace) |
| 709 | * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property) |
| 710 | * + 'params': array, the entity data as supported by the CiviCRM API |
| 711 | * + 'update' (v4.5+): string, a policy which describes when to update records |
| 712 | * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin) |
| 713 | * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities |
| 714 | * + 'cleanup' (v4.5+): string, a policy which describes whether to cleanup the record when it becomes orphaned (ie when $entities no longer references the record) |
| 715 | * - 'always' (default): always delete orphaned records |
| 716 | * - 'never': never delete orphaned records |
| 717 | * - 'unused': only delete orphaned records if there are no other references to it in the DB. (This is determined by calling the API's "getrefcount" action.) |
| 718 | * |
| 719 | * @return null |
| 720 | * the return value is ignored |
| 721 | */ |
| 722 | public static function managed(&$entities) { |
| 723 | return self::singleton()->invoke(['entities'], $entities, |
| 724 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 725 | 'civicrm_managed' |
| 726 | ); |
| 727 | } |
| 728 | |
| 729 | /** |
| 730 | * This hook is called when rendering the dashboard (q=civicrm/dashboard) |
| 731 | * |
| 732 | * @param int $contactID |
| 733 | * The contactID for whom the dashboard is being rendered. |
| 734 | * @param int $contentPlacement |
| 735 | * (output parameter) where should the hook content be displayed. |
| 736 | * relative to the activity list |
| 737 | * |
| 738 | * @return string |
| 739 | * the html snippet to include in the dashboard |
| 740 | */ |
| 741 | public static function dashboard($contactID, &$contentPlacement = self::DASHBOARD_BELOW) { |
| 742 | $retval = self::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement, |
| 743 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 744 | 'civicrm_dashboard' |
| 745 | ); |
| 746 | |
| 747 | /* |
| 748 | * Note we need this seemingly unnecessary code because in the event that the implementation |
| 749 | * of the hook declares the second parameter but doesn't set it, then it comes back unset even |
| 750 | * though we have a default value in this function's declaration above. |
| 751 | */ |
| 752 | if (!isset($contentPlacement)) { |
| 753 | $contentPlacement = self::DASHBOARD_BELOW; |
| 754 | } |
| 755 | |
| 756 | return $retval; |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * This hook is called before storing recently viewed items. |
| 761 | * |
| 762 | * @param array $recentArray |
| 763 | * An array of recently viewed or processed items, for in place modification. |
| 764 | * |
| 765 | * @return array |
| 766 | */ |
| 767 | public static function recent(&$recentArray) { |
| 768 | return self::singleton()->invoke(['recentArray'], $recentArray, |
| 769 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 770 | 'civicrm_recent' |
| 771 | ); |
| 772 | } |
| 773 | |
| 774 | /** |
| 775 | * Determine how many other records refer to a given record. |
| 776 | * |
| 777 | * @param CRM_Core_DAO $dao |
| 778 | * The item for which we want a reference count. |
| 779 | * @param array $refCounts |
| 780 | * Each item in the array is an Array with keys: |
| 781 | * - name: string, eg "sql:civicrm_email:contact_id" |
| 782 | * - type: string, eg "sql" |
| 783 | * - count: int, eg "5" if there are 5 email addresses that refer to $dao |
| 784 | * |
| 785 | * @return mixed |
| 786 | * Return is not really intended to be used. |
| 787 | */ |
| 788 | public static function referenceCounts($dao, &$refCounts) { |
| 789 | return self::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts, |
| 790 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 791 | 'civicrm_referenceCounts' |
| 792 | ); |
| 793 | } |
| 794 | |
| 795 | /** |
| 796 | * This hook is called when building the amount structure for a Contribution or Event Page. |
| 797 | * |
| 798 | * @param int $pageType |
| 799 | * Is this a contribution or event page. |
| 800 | * @param CRM_Core_Form $form |
| 801 | * Reference to the form object. |
| 802 | * @param array $amount |
| 803 | * The amount structure to be displayed. |
| 804 | * |
| 805 | * @return null |
| 806 | */ |
| 807 | public static function buildAmount($pageType, &$form, &$amount) { |
| 808 | return self::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self::$_nullObject, |
| 809 | self::$_nullObject, self::$_nullObject, 'civicrm_buildAmount'); |
| 810 | } |
| 811 | |
| 812 | /** |
| 813 | * This hook is called when building the state list for a particular country. |
| 814 | * |
| 815 | * @param array $countryID |
| 816 | * The country id whose states are being selected. |
| 817 | * @param $states |
| 818 | * |
| 819 | * @return null |
| 820 | */ |
| 821 | public static function buildStateProvinceForCountry($countryID, &$states) { |
| 822 | return self::singleton()->invoke(['countryID', 'states'], $countryID, $states, |
| 823 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 824 | 'civicrm_buildStateProvinceForCountry' |
| 825 | ); |
| 826 | } |
| 827 | |
| 828 | /** |
| 829 | * This hook is called when rendering the tabs used for events and potentially |
| 830 | * contribution pages, etc. |
| 831 | * |
| 832 | * @param string $tabsetName |
| 833 | * Name of the screen or visual element. |
| 834 | * @param array $tabs |
| 835 | * Tabs that will be displayed. |
| 836 | * @param array $context |
| 837 | * Extra data about the screen or context in which the tab is used. |
| 838 | * |
| 839 | * @return null |
| 840 | */ |
| 841 | public static function tabset($tabsetName, &$tabs, $context) { |
| 842 | return self::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs, |
| 843 | $context, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabset' |
| 844 | ); |
| 845 | } |
| 846 | |
| 847 | /** |
| 848 | * This hook is called when sending an email / printing labels |
| 849 | * |
| 850 | * @param array $tokens |
| 851 | * The list of tokens that can be used for the contact. |
| 852 | * |
| 853 | * @return null |
| 854 | */ |
| 855 | public static function tokens(&$tokens) { |
| 856 | return self::singleton()->invoke(['tokens'], $tokens, |
| 857 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tokens' |
| 858 | ); |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * This hook allows modification of the admin panels |
| 863 | * |
| 864 | * @param array $panels |
| 865 | * Associated array of admin panels |
| 866 | * |
| 867 | * @return mixed |
| 868 | */ |
| 869 | public static function alterAdminPanel(&$panels) { |
| 870 | return self::singleton()->invoke(['panels'], $panels, |
| 871 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 872 | 'civicrm_alterAdminPanel' |
| 873 | ); |
| 874 | } |
| 875 | |
| 876 | /** |
| 877 | * This hook is called when sending an email / printing labels to get the values for all the |
| 878 | * tokens returned by the 'tokens' hook |
| 879 | * |
| 880 | * @param array $details |
| 881 | * The array to store the token values indexed by contactIDs. |
| 882 | * @param array $contactIDs |
| 883 | * An array of contactIDs. |
| 884 | * @param int $jobID |
| 885 | * The jobID if this is associated with a CiviMail mailing. |
| 886 | * @param array $tokens |
| 887 | * The list of tokens associated with the content. |
| 888 | * @param string $className |
| 889 | * The top level className from where the hook is invoked. |
| 890 | * |
| 891 | * @return null |
| 892 | */ |
| 893 | public static function tokenValues( |
| 894 | &$details, |
| 895 | $contactIDs, |
| 896 | $jobID = NULL, |
| 897 | $tokens = [], |
| 898 | $className = NULL |
| 899 | ) { |
| 900 | return self::singleton() |
| 901 | ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues'); |
| 902 | } |
| 903 | |
| 904 | /** |
| 905 | * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables |
| 906 | * in a template |
| 907 | * |
| 908 | * @param object $page |
| 909 | * The page that will be rendered. |
| 910 | * |
| 911 | * @return null |
| 912 | */ |
| 913 | public static function pageRun(&$page) { |
| 914 | return self::singleton()->invoke(['page'], $page, |
| 915 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 916 | 'civicrm_pageRun' |
| 917 | ); |
| 918 | } |
| 919 | |
| 920 | /** |
| 921 | * This hook is called after a copy of an object has been made. The current objects are |
| 922 | * Event, Contribution Page and UFGroup |
| 923 | * |
| 924 | * @param string $objectName |
| 925 | * Name of the object. |
| 926 | * @param object $object |
| 927 | * Reference to the copy. |
| 928 | * |
| 929 | * @return null |
| 930 | */ |
| 931 | public static function copy($objectName, &$object) { |
| 932 | return self::singleton()->invoke(['objectName', 'object'], $objectName, $object, |
| 933 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 934 | 'civicrm_copy' |
| 935 | ); |
| 936 | } |
| 937 | |
| 938 | /** |
| 939 | * This hook is called when a contact unsubscribes from a mailing. It allows modules |
| 940 | * to override what the contacts are removed from. |
| 941 | * |
| 942 | * @param string $op |
| 943 | * Ignored for now |
| 944 | * @param int $mailingId |
| 945 | * The id of the mailing to unsub from |
| 946 | * @param int $contactId |
| 947 | * The id of the contact who is unsubscribing |
| 948 | * @param array|int $groups |
| 949 | * Groups the contact will be removed from. |
| 950 | * @param array|int $baseGroups |
| 951 | * Base groups (used in smart mailings) the contact will be removed from. |
| 952 | * |
| 953 | * |
| 954 | * @return mixed |
| 955 | */ |
| 956 | public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) { |
| 957 | return self::singleton() |
| 958 | ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self::$_nullObject, 'civicrm_unsubscribeGroups'); |
| 959 | } |
| 960 | |
| 961 | /** |
| 962 | * This hook is called when CiviCRM needs to edit/display a custom field with options |
| 963 | * |
| 964 | * @deprecated in favor of hook_civicrm_fieldOptions |
| 965 | * |
| 966 | * @param int $customFieldID |
| 967 | * The custom field ID. |
| 968 | * @param array $options |
| 969 | * The current set of options for that custom field. |
| 970 | * You can add/remove existing options. |
| 971 | * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important |
| 972 | * to be careful to not overwrite the array. |
| 973 | * Only add/edit/remove the specific field options you intend to affect. |
| 974 | * @param bool $detailedFormat |
| 975 | * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format |
| 976 | * @param array $selectAttributes |
| 977 | * Contain select attribute(s) if any. |
| 978 | * |
| 979 | * @return mixed |
| 980 | */ |
| 981 | public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) { |
| 982 | // Weird: $selectAttributes is inputted but not outputted. |
| 983 | return self::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat, |
| 984 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 985 | 'civicrm_customFieldOptions' |
| 986 | ); |
| 987 | } |
| 988 | |
| 989 | /** |
| 990 | * Hook for modifying field options |
| 991 | * |
| 992 | * @param string $entity |
| 993 | * @param string $field |
| 994 | * @param array $options |
| 995 | * @param array $params |
| 996 | * |
| 997 | * @return mixed |
| 998 | */ |
| 999 | public static function fieldOptions($entity, $field, &$options, $params) { |
| 1000 | return self::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params, |
| 1001 | self::$_nullObject, self::$_nullObject, |
| 1002 | 'civicrm_fieldOptions' |
| 1003 | ); |
| 1004 | } |
| 1005 | |
| 1006 | /** |
| 1007 | * |
| 1008 | * This hook is called to display the list of actions allowed after doing a search. |
| 1009 | * This allows the module developer to inject additional actions or to remove existing actions. |
| 1010 | * |
| 1011 | * @param string $objectType |
| 1012 | * The object type for this search. |
| 1013 | * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported. |
| 1014 | * @param array $tasks |
| 1015 | * The current set of tasks for that custom field. |
| 1016 | * You can add/remove existing tasks. |
| 1017 | * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class |
| 1018 | * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup'). |
| 1019 | * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ). |
| 1020 | * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be |
| 1021 | * found in CRM/$objectType/Task.php. |
| 1022 | * |
| 1023 | * @return mixed |
| 1024 | */ |
| 1025 | public static function searchTasks($objectType, &$tasks) { |
| 1026 | return self::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks, |
| 1027 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1028 | 'civicrm_searchTasks' |
| 1029 | ); |
| 1030 | } |
| 1031 | |
| 1032 | /** |
| 1033 | * @param mixed $form |
| 1034 | * @param array $params |
| 1035 | * |
| 1036 | * @return mixed |
| 1037 | */ |
| 1038 | public static function eventDiscount(&$form, &$params) { |
| 1039 | return self::singleton()->invoke(['form', 'params'], $form, $params, |
| 1040 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1041 | 'civicrm_eventDiscount' |
| 1042 | ); |
| 1043 | } |
| 1044 | |
| 1045 | /** |
| 1046 | * This hook is called when composing a mailing. You can include / exclude other groups as needed. |
| 1047 | * |
| 1048 | * @param mixed $form |
| 1049 | * The form object for which groups / mailings being displayed |
| 1050 | * @param array $groups |
| 1051 | * The list of groups being included / excluded |
| 1052 | * @param array $mailings |
| 1053 | * The list of mailings being included / excluded |
| 1054 | * |
| 1055 | * @return mixed |
| 1056 | */ |
| 1057 | public static function mailingGroups(&$form, &$groups, &$mailings) { |
| 1058 | return self::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings, |
| 1059 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1060 | 'civicrm_mailingGroups' |
| 1061 | ); |
| 1062 | } |
| 1063 | |
| 1064 | /** |
| 1065 | * (Experimental) Modify the list of template-types used for CiviMail composition. |
| 1066 | * |
| 1067 | * @param array $types |
| 1068 | * Sequentially indexed list of template types. Each type specifies: |
| 1069 | * - name: string |
| 1070 | * - editorUrl: string, Angular template URL |
| 1071 | * - weight: int, priority when picking a default value for new mailings |
| 1072 | * @return mixed |
| 1073 | */ |
| 1074 | public static function mailingTemplateTypes(&$types) { |
| 1075 | return self::singleton()->invoke(['types'], $types, self::$_nullObject, self::$_nullObject, |
| 1076 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1077 | 'civicrm_mailingTemplateTypes' |
| 1078 | ); |
| 1079 | } |
| 1080 | |
| 1081 | /** |
| 1082 | * This hook is called when composing the array of membershipTypes and their cost during a membership registration |
| 1083 | * (new or renewal). |
| 1084 | * Note the hook is called on initial page load and also reloaded after submit (PRG pattern). |
| 1085 | * You can use it to alter the membership types when first loaded, or after submission |
| 1086 | * (for example if you want to gather data in the form and use it to alter the fees). |
| 1087 | * |
| 1088 | * @param mixed $form |
| 1089 | * The form object that is presenting the page |
| 1090 | * @param array $membershipTypes |
| 1091 | * The array of membership types and their amount |
| 1092 | * |
| 1093 | * @return mixed |
| 1094 | */ |
| 1095 | public static function membershipTypeValues(&$form, &$membershipTypes) { |
| 1096 | return self::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes, |
| 1097 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1098 | 'civicrm_membershipTypeValues' |
| 1099 | ); |
| 1100 | } |
| 1101 | |
| 1102 | /** |
| 1103 | * This hook is called when rendering the contact summary. |
| 1104 | * |
| 1105 | * @param int $contactID |
| 1106 | * The contactID for whom the summary is being rendered |
| 1107 | * @param mixed $content |
| 1108 | * @param int $contentPlacement |
| 1109 | * Specifies where the hook content should be displayed relative to the |
| 1110 | * existing content |
| 1111 | * |
| 1112 | * @return string |
| 1113 | * The html snippet to include in the contact summary |
| 1114 | */ |
| 1115 | public static function summary($contactID, &$content, &$contentPlacement = self::SUMMARY_BELOW) { |
| 1116 | return self::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement, |
| 1117 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1118 | 'civicrm_summary' |
| 1119 | ); |
| 1120 | } |
| 1121 | |
| 1122 | /** |
| 1123 | * Use this hook to populate the list of contacts returned by Contact Reference custom fields. |
| 1124 | * By default, Contact Reference fields will search on and return all CiviCRM contacts. |
| 1125 | * If you want to limit the contacts returned to a specific group, or some other criteria |
| 1126 | * - you can override that behavior by providing a SQL query that returns some subset of your contacts. |
| 1127 | * The hook is called when the query is executed to get the list of contacts to display. |
| 1128 | * |
| 1129 | * @param mixed $query |
| 1130 | * - the query that will be executed (input and output parameter);. |
| 1131 | * It's important to realize that the ACL clause is built prior to this hook being fired, |
| 1132 | * so your query will ignore any ACL rules that may be defined. |
| 1133 | * Your query must return two columns: |
| 1134 | * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data') |
| 1135 | * the contact IDs |
| 1136 | * @param string $queryText |
| 1137 | * The name string to execute the query against (this is the value being typed in by the user). |
| 1138 | * @param string $context |
| 1139 | * The context in which this ajax call is being made (for example: 'customfield', 'caseview'). |
| 1140 | * @param int $id |
| 1141 | * The id of the object for which the call is being made. |
| 1142 | * For custom fields, it will be the custom field id |
| 1143 | * |
| 1144 | * @return mixed |
| 1145 | */ |
| 1146 | public static function contactListQuery(&$query, $queryText, $context, $id) { |
| 1147 | return self::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id, |
| 1148 | self::$_nullObject, self::$_nullObject, |
| 1149 | 'civicrm_contactListQuery' |
| 1150 | ); |
| 1151 | } |
| 1152 | |
| 1153 | /** |
| 1154 | * Hook definition for altering payment parameters before talking to a payment processor back end. |
| 1155 | * |
| 1156 | * Definition will look like this: |
| 1157 | * |
| 1158 | * function hook_civicrm_alterPaymentProcessorParams( |
| 1159 | * $paymentObj, |
| 1160 | * &$rawParams, |
| 1161 | * &$cookedParams |
| 1162 | * ); |
| 1163 | * |
| 1164 | * @param CRM_Core_Payment $paymentObj |
| 1165 | * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy') |
| 1166 | * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference. |
| 1167 | * @param array &$rawParams |
| 1168 | * array of params as passed to to the processor |
| 1169 | * @param array|\Civi\Payment\PropertyBag &$cookedParams |
| 1170 | * params after the processor code has translated them into its own key/value pairs |
| 1171 | * |
| 1172 | * @return mixed |
| 1173 | * This return is not really intended to be used. |
| 1174 | */ |
| 1175 | public static function alterPaymentProcessorParams( |
| 1176 | $paymentObj, |
| 1177 | &$rawParams, |
| 1178 | &$cookedParams |
| 1179 | ) { |
| 1180 | return self::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams, |
| 1181 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1182 | 'civicrm_alterPaymentProcessorParams' |
| 1183 | ); |
| 1184 | } |
| 1185 | |
| 1186 | /** |
| 1187 | * This hook is called when an email is about to be sent by CiviCRM. |
| 1188 | * |
| 1189 | * @param array $params |
| 1190 | * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html, |
| 1191 | * returnPath, replyTo, headers, attachments (array) |
| 1192 | * @param string $context |
| 1193 | * The context in which the hook is being invoked, eg 'civimail'. |
| 1194 | * |
| 1195 | * @return mixed |
| 1196 | */ |
| 1197 | public static function alterMailParams(&$params, $context = NULL) { |
| 1198 | return self::singleton()->invoke(['params', 'context'], $params, $context, |
| 1199 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1200 | 'civicrm_alterMailParams' |
| 1201 | ); |
| 1202 | } |
| 1203 | |
| 1204 | /** |
| 1205 | * This hook is called when membership status is being calculated. |
| 1206 | * |
| 1207 | * @param array $membershipStatus |
| 1208 | * Membership status details as determined - alter if required. |
| 1209 | * @param array $arguments |
| 1210 | * Arguments passed in to calculate date. |
| 1211 | * - 'start_date' |
| 1212 | * - 'end_date' |
| 1213 | * - 'status_date' |
| 1214 | * - 'join_date' |
| 1215 | * - 'exclude_is_admin' |
| 1216 | * - 'membership_type_id' |
| 1217 | * @param array $membership |
| 1218 | * Membership details from the calling function. |
| 1219 | * |
| 1220 | * @return mixed |
| 1221 | */ |
| 1222 | public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) { |
| 1223 | return self::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments, |
| 1224 | $membership, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1225 | 'civicrm_alterCalculatedMembershipStatus' |
| 1226 | ); |
| 1227 | } |
| 1228 | |
| 1229 | /** |
| 1230 | * This hook is called after getting the content of the mail and before tokenizing it. |
| 1231 | * |
| 1232 | * @param array $content |
| 1233 | * Array fields include: html, text, subject |
| 1234 | * |
| 1235 | * @return mixed |
| 1236 | */ |
| 1237 | public static function alterMailContent(&$content) { |
| 1238 | return self::singleton()->invoke(['content'], $content, |
| 1239 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1240 | 'civicrm_alterMailContent' |
| 1241 | ); |
| 1242 | } |
| 1243 | |
| 1244 | /** |
| 1245 | * This hook is called when rendering the Manage Case screen. |
| 1246 | * |
| 1247 | * @param int $caseID |
| 1248 | * The case ID. |
| 1249 | * |
| 1250 | * @return array |
| 1251 | * Array of data to be displayed, where the key is a unique id to be used for styling (div id's) |
| 1252 | * and the value is an array with keys 'label' and 'value' specifying label/value pairs |
| 1253 | */ |
| 1254 | public static function caseSummary($caseID) { |
| 1255 | return self::singleton()->invoke(['caseID'], $caseID, |
| 1256 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1257 | 'civicrm_caseSummary' |
| 1258 | ); |
| 1259 | } |
| 1260 | |
| 1261 | /** |
| 1262 | * This hook is called when locating CiviCase types. |
| 1263 | * |
| 1264 | * @param array $caseTypes |
| 1265 | * |
| 1266 | * @return mixed |
| 1267 | */ |
| 1268 | public static function caseTypes(&$caseTypes) { |
| 1269 | return self::singleton() |
| 1270 | ->invoke(['caseTypes'], $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes'); |
| 1271 | } |
| 1272 | |
| 1273 | /** |
| 1274 | * This hook is called when getting case email subject patterns. |
| 1275 | * |
| 1276 | * All emails related to cases have case hash/id in the subject, e.g: |
| 1277 | * [case #ab12efg] Magic moment |
| 1278 | * [case #1234] Magic is here |
| 1279 | * |
| 1280 | * Using this hook you can replace/enrich default list with some other |
| 1281 | * patterns, e.g. include case type categories (see CiviCase extension) like: |
| 1282 | * [(case|project|policy initiative) #hash] |
| 1283 | * [(case|project|policy initiative) #id] |
| 1284 | * |
| 1285 | * @param array $subjectPatterns |
| 1286 | * Cases related email subject regexp patterns. |
| 1287 | * |
| 1288 | * @return mixed |
| 1289 | */ |
| 1290 | public static function caseEmailSubjectPatterns(&$subjectPatterns) { |
| 1291 | return self::singleton() |
| 1292 | ->invoke(['caseEmailSubjectPatterns'], $subjectPatterns, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseEmailSubjectPatterns'); |
| 1293 | } |
| 1294 | |
| 1295 | /** |
| 1296 | * This hook is called soon after the CRM_Core_Config object has ben initialized. |
| 1297 | * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically. |
| 1298 | * |
| 1299 | * @param CRM_Core_Config|array $config |
| 1300 | * The config object |
| 1301 | * |
| 1302 | * @return mixed |
| 1303 | */ |
| 1304 | public static function config(&$config) { |
| 1305 | return self::singleton()->invoke(['config'], $config, |
| 1306 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1307 | 'civicrm_config' |
| 1308 | ); |
| 1309 | } |
| 1310 | |
| 1311 | /** |
| 1312 | * This hooks allows to change option values. |
| 1313 | * |
| 1314 | * @deprecated in favor of hook_civicrm_fieldOptions |
| 1315 | * |
| 1316 | * @param array $options |
| 1317 | * Associated array of option values / id |
| 1318 | * @param string $groupName |
| 1319 | * Option group name |
| 1320 | * |
| 1321 | * @return mixed |
| 1322 | */ |
| 1323 | public static function optionValues(&$options, $groupName) { |
| 1324 | return self::singleton()->invoke(['options', 'groupName'], $options, $groupName, |
| 1325 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1326 | 'civicrm_optionValues' |
| 1327 | ); |
| 1328 | } |
| 1329 | |
| 1330 | /** |
| 1331 | * This hook allows modification of the navigation menu. |
| 1332 | * |
| 1333 | * @param array $params |
| 1334 | * Associated array of navigation menu entry to Modify/Add |
| 1335 | * |
| 1336 | * @return mixed |
| 1337 | */ |
| 1338 | public static function navigationMenu(&$params) { |
| 1339 | return self::singleton()->invoke(['params'], $params, |
| 1340 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1341 | 'civicrm_navigationMenu' |
| 1342 | ); |
| 1343 | } |
| 1344 | |
| 1345 | /** |
| 1346 | * This hook allows modification of the data used to perform merging of duplicates. |
| 1347 | * |
| 1348 | * @param string $type |
| 1349 | * The type of data being passed (cidRefs|eidRefs|relTables|sqls). |
| 1350 | * @param array $data |
| 1351 | * The data, as described in $type. |
| 1352 | * @param int $mainId |
| 1353 | * Contact_id of the contact that survives the merge. |
| 1354 | * @param int $otherId |
| 1355 | * Contact_id of the contact that will be absorbed and deleted. |
| 1356 | * @param array $tables |
| 1357 | * When $type is "sqls", an array of tables as it may have been handed to the calling function. |
| 1358 | * |
| 1359 | * @return mixed |
| 1360 | */ |
| 1361 | public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) { |
| 1362 | return self::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self::$_nullObject, 'civicrm_merge'); |
| 1363 | } |
| 1364 | |
| 1365 | /** |
| 1366 | * This hook allows modification of the data calculated for merging locations. |
| 1367 | * |
| 1368 | * @param array $blocksDAO |
| 1369 | * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'. |
| 1370 | * @param int $mainId |
| 1371 | * Contact_id of the contact that survives the merge. |
| 1372 | * @param int $otherId |
| 1373 | * Contact_id of the contact that will be absorbed and deleted. |
| 1374 | * @param array $migrationInfo |
| 1375 | * Calculated migration info, informational only. |
| 1376 | * |
| 1377 | * @return mixed |
| 1378 | */ |
| 1379 | public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) { |
| 1380 | return self::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self::$_nullObject, self::$_nullObject, 'civicrm_alterLocationMergeData'); |
| 1381 | } |
| 1382 | |
| 1383 | /** |
| 1384 | * This hook provides a way to override the default privacy behavior for notes. |
| 1385 | * |
| 1386 | * @param array &$noteValues |
| 1387 | * Associative array of values for this note |
| 1388 | * |
| 1389 | * @return mixed |
| 1390 | */ |
| 1391 | public static function notePrivacy(&$noteValues) { |
| 1392 | return self::singleton()->invoke(['noteValues'], $noteValues, |
| 1393 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1394 | 'civicrm_notePrivacy' |
| 1395 | ); |
| 1396 | } |
| 1397 | |
| 1398 | /** |
| 1399 | * This hook is called before record is exported as CSV. |
| 1400 | * |
| 1401 | * @param string $exportTempTable |
| 1402 | * Name of the temporary export table used during export. |
| 1403 | * @param array $headerRows |
| 1404 | * Header rows for output. |
| 1405 | * @param array $sqlColumns |
| 1406 | * SQL columns. |
| 1407 | * @param int $exportMode |
| 1408 | * Export mode ( contact, contribution, etc...). |
| 1409 | * @param string $componentTable |
| 1410 | * Name of temporary table |
| 1411 | * @param array $ids |
| 1412 | * Array of object's ids |
| 1413 | * |
| 1414 | * @return mixed |
| 1415 | */ |
| 1416 | public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) { |
| 1417 | return self::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'], |
| 1418 | $exportTempTable, $headerRows, $sqlColumns, |
| 1419 | $exportMode, $componentTable, $ids, |
| 1420 | 'civicrm_export' |
| 1421 | ); |
| 1422 | } |
| 1423 | |
| 1424 | /** |
| 1425 | * This hook allows modification of the queries constructed from dupe rules. |
| 1426 | * |
| 1427 | * @param string $obj |
| 1428 | * Object of rulegroup class. |
| 1429 | * @param string $type |
| 1430 | * Type of queries e.g table / threshold. |
| 1431 | * @param array $query |
| 1432 | * Set of queries. |
| 1433 | * |
| 1434 | * @return mixed |
| 1435 | */ |
| 1436 | public static function dupeQuery($obj, $type, &$query) { |
| 1437 | return self::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query, |
| 1438 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1439 | 'civicrm_dupeQuery' |
| 1440 | ); |
| 1441 | } |
| 1442 | |
| 1443 | /** |
| 1444 | * Check for duplicate contacts |
| 1445 | * |
| 1446 | * @param array $dedupeParams |
| 1447 | * Array of params for finding duplicates: [ |
| 1448 | * '{parameters returned by CRM_Dedupe_Finder::formatParams} |
| 1449 | * 'check_permission' => TRUE/FALSE; |
| 1450 | * 'contact_type' => $contactType; |
| 1451 | * 'rule' = $rule; |
| 1452 | * 'rule_group_id' => $ruleGroupID; |
| 1453 | * 'excludedContactIDs' => $excludedContactIDs; |
| 1454 | * @param array $dedupeResults |
| 1455 | * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts] |
| 1456 | * @param array $contextParams |
| 1457 | * The context if relevant, eg. ['event_id' => X] |
| 1458 | * |
| 1459 | * @return mixed |
| 1460 | */ |
| 1461 | public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) { |
| 1462 | return self::singleton() |
| 1463 | ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_findDuplicates'); |
| 1464 | } |
| 1465 | |
| 1466 | /** |
| 1467 | * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php |
| 1468 | * |
| 1469 | * @param string $type |
| 1470 | * Type of mail processed: 'activity' OR 'mailing'. |
| 1471 | * @param array &$params the params that were sent to the CiviCRM API function |
| 1472 | * @param object $mail |
| 1473 | * The mail object which is an ezcMail class. |
| 1474 | * @param array &$result the result returned by the api call |
| 1475 | * @param string $action |
| 1476 | * (optional ) the requested action to be performed if the types was 'mailing'. |
| 1477 | * |
| 1478 | * @return mixed |
| 1479 | */ |
| 1480 | public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) { |
| 1481 | return self::singleton() |
| 1482 | ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self::$_nullObject, 'civicrm_emailProcessor'); |
| 1483 | } |
| 1484 | |
| 1485 | /** |
| 1486 | * This hook is called after a row has been processed and the |
| 1487 | * record (and associated records imported |
| 1488 | * |
| 1489 | * @param string $object |
| 1490 | * Object being imported (for now Contact only, later Contribution, Activity,. |
| 1491 | * Participant and Member) |
| 1492 | * @param string $usage |
| 1493 | * Hook usage/location (for now process only, later mapping and others). |
| 1494 | * @param string $objectRef |
| 1495 | * Import record object. |
| 1496 | * @param array $params |
| 1497 | * Array with various key values: currently. |
| 1498 | * contactID - contact id |
| 1499 | * importID - row id in temp table |
| 1500 | * importTempTable - name of tempTable |
| 1501 | * fieldHeaders - field headers |
| 1502 | * fields - import fields |
| 1503 | * |
| 1504 | * @return mixed |
| 1505 | */ |
| 1506 | public static function import($object, $usage, &$objectRef, &$params) { |
| 1507 | return self::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params, |
| 1508 | self::$_nullObject, self::$_nullObject, |
| 1509 | 'civicrm_import' |
| 1510 | ); |
| 1511 | } |
| 1512 | |
| 1513 | /** |
| 1514 | * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission() |
| 1515 | * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php). |
| 1516 | * |
| 1517 | * @param string $entity |
| 1518 | * The API entity (like contact). |
| 1519 | * @param string $action |
| 1520 | * The API action (like get). |
| 1521 | * @param array &$params the API parameters |
| 1522 | * @param array &$permissions the associative permissions array (probably to be altered by this hook) |
| 1523 | * |
| 1524 | * @return mixed |
| 1525 | */ |
| 1526 | public static function alterAPIPermissions($entity, $action, &$params, &$permissions) { |
| 1527 | return self::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions, |
| 1528 | self::$_nullObject, self::$_nullObject, |
| 1529 | 'civicrm_alterAPIPermissions' |
| 1530 | ); |
| 1531 | } |
| 1532 | |
| 1533 | /** |
| 1534 | * @param CRM_Core_DAO $dao |
| 1535 | * |
| 1536 | * @return mixed |
| 1537 | */ |
| 1538 | public static function postSave(&$dao) { |
| 1539 | $hookName = 'civicrm_postSave_' . $dao->getTableName(); |
| 1540 | return self::singleton()->invoke(['dao'], $dao, |
| 1541 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1542 | $hookName |
| 1543 | ); |
| 1544 | } |
| 1545 | |
| 1546 | /** |
| 1547 | * This hook allows user to customize context menu Actions on contact summary page. |
| 1548 | * |
| 1549 | * @param array $actions |
| 1550 | * Array of all Actions in contextmenu. |
| 1551 | * @param int $contactID |
| 1552 | * ContactID for the summary page. |
| 1553 | * |
| 1554 | * @return mixed |
| 1555 | */ |
| 1556 | public static function summaryActions(&$actions, $contactID = NULL) { |
| 1557 | return self::singleton()->invoke(['actions', 'contactID'], $actions, $contactID, |
| 1558 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1559 | 'civicrm_summaryActions' |
| 1560 | ); |
| 1561 | } |
| 1562 | |
| 1563 | /** |
| 1564 | * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go. |
| 1565 | * This enables us hook implementors to modify both the headers and the rows |
| 1566 | * |
| 1567 | * The BIGGEST drawback with this hook is that you may need to modify the result template to include your |
| 1568 | * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl |
| 1569 | * |
| 1570 | * However, if you use the same number of columns, you can overwrite the existing columns with the values that |
| 1571 | * you want displayed. This is a hackish, but avoids template modification. |
| 1572 | * |
| 1573 | * @param string $objectName |
| 1574 | * The component name that we are doing the search. |
| 1575 | * activity, campaign, case, contact, contribution, event, grant, membership, and pledge |
| 1576 | * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order ) |
| 1577 | * @param array &$rows the list of values, an associate array with fields that are displayed for that component |
| 1578 | * @param array $selector |
| 1579 | * the selector object. Allows you access to the context of the search |
| 1580 | * |
| 1581 | * @return mixed |
| 1582 | * modify the header and values object to pass the data you need |
| 1583 | */ |
| 1584 | public static function searchColumns($objectName, &$headers, &$rows, &$selector) { |
| 1585 | return self::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector, |
| 1586 | self::$_nullObject, self::$_nullObject, |
| 1587 | 'civicrm_searchColumns' |
| 1588 | ); |
| 1589 | } |
| 1590 | |
| 1591 | /** |
| 1592 | * This hook is called when uf groups are being built for a module. |
| 1593 | * |
| 1594 | * @param string $moduleName |
| 1595 | * Module name. |
| 1596 | * @param array $ufGroups |
| 1597 | * Array of ufgroups for a module. |
| 1598 | * |
| 1599 | * @return null |
| 1600 | */ |
| 1601 | public static function buildUFGroupsForModule($moduleName, &$ufGroups) { |
| 1602 | return self::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups, |
| 1603 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1604 | 'civicrm_buildUFGroupsForModule' |
| 1605 | ); |
| 1606 | } |
| 1607 | |
| 1608 | /** |
| 1609 | * This hook is called when we are determining the contactID for a specific |
| 1610 | * email address |
| 1611 | * |
| 1612 | * @param string $email |
| 1613 | * The email address. |
| 1614 | * @param int $contactID |
| 1615 | * The contactID that matches this email address, IF it exists. |
| 1616 | * @param array $result |
| 1617 | * (reference) has two fields. |
| 1618 | * contactID - the new (or same) contactID |
| 1619 | * action - 3 possible values: |
| 1620 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record |
| 1621 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID |
| 1622 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address |
| 1623 | * |
| 1624 | * @return null |
| 1625 | */ |
| 1626 | public static function emailProcessorContact($email, $contactID, &$result) { |
| 1627 | return self::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result, |
| 1628 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1629 | 'civicrm_emailProcessorContact' |
| 1630 | ); |
| 1631 | } |
| 1632 | |
| 1633 | /** |
| 1634 | * Hook definition for altering the generation of Mailing Labels. |
| 1635 | * |
| 1636 | * @param array $args |
| 1637 | * An array of the args in the order defined for the tcpdf multiCell api call. |
| 1638 | * with the variable names below converted into string keys (ie $w become 'w' |
| 1639 | * as the first key for $args) |
| 1640 | * float $w Width of cells. If 0, they extend up to the right margin of the page. |
| 1641 | * float $h Cell minimum height. The cell extends automatically if needed. |
| 1642 | * string $txt String to print |
| 1643 | * mixed $border Indicates if borders must be drawn around the cell block. The value can |
| 1644 | * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or |
| 1645 | * a string containing some or all of the following characters (in any order): |
| 1646 | * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> |
| 1647 | * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string: |
| 1648 | * left align</li><li>C: center</li><li>R: right align</li><li>J: justification |
| 1649 | * (default value when $ishtml=false)</li></ul> |
| 1650 | * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0. |
| 1651 | * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: |
| 1652 | * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul> |
| 1653 | * float $x x position in user units |
| 1654 | * float $y y position in user units |
| 1655 | * boolean $reseth if true reset the last cell height (default true). |
| 1656 | * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if |
| 1657 | * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if |
| 1658 | * necessary</li><li>4 = forced character spacing</li></ul> |
| 1659 | * boolean $ishtml set to true if $txt is HTML content (default = false). |
| 1660 | * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width. |
| 1661 | * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page, |
| 1662 | * or 0 for disable this feature. This feature works only when $ishtml=false. |
| 1663 | * |
| 1664 | * @return mixed |
| 1665 | */ |
| 1666 | public static function alterMailingLabelParams(&$args) { |
| 1667 | return self::singleton()->invoke(['args'], $args, |
| 1668 | self::$_nullObject, self::$_nullObject, |
| 1669 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1670 | 'civicrm_alterMailingLabelParams' |
| 1671 | ); |
| 1672 | } |
| 1673 | |
| 1674 | /** |
| 1675 | * This hooks allows alteration of generated page content. |
| 1676 | * |
| 1677 | * @param $content |
| 1678 | * Previously generated content. |
| 1679 | * @param $context |
| 1680 | * Context of content - page or form. |
| 1681 | * @param $tplName |
| 1682 | * The file name of the tpl. |
| 1683 | * @param $object |
| 1684 | * A reference to the page or form object. |
| 1685 | * |
| 1686 | * @return mixed |
| 1687 | */ |
| 1688 | public static function alterContent(&$content, $context, $tplName, &$object) { |
| 1689 | return self::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object, |
| 1690 | self::$_nullObject, self::$_nullObject, |
| 1691 | 'civicrm_alterContent' |
| 1692 | ); |
| 1693 | } |
| 1694 | |
| 1695 | /** |
| 1696 | * This hooks allows alteration of the tpl file used to generate content. It differs from the |
| 1697 | * altercontent hook as the content has already been rendered through the tpl at that point |
| 1698 | * |
| 1699 | * @param $formName |
| 1700 | * Previously generated content. |
| 1701 | * @param $form |
| 1702 | * Reference to the form object. |
| 1703 | * @param $context |
| 1704 | * Context of content - page or form. |
| 1705 | * @param $tplName |
| 1706 | * Reference the file name of the tpl. |
| 1707 | * |
| 1708 | * @return mixed |
| 1709 | */ |
| 1710 | public static function alterTemplateFile($formName, &$form, $context, &$tplName) { |
| 1711 | return self::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName, |
| 1712 | self::$_nullObject, self::$_nullObject, |
| 1713 | 'civicrm_alterTemplateFile' |
| 1714 | ); |
| 1715 | } |
| 1716 | |
| 1717 | /** |
| 1718 | * This hook collects the trigger definition from all components. |
| 1719 | * |
| 1720 | * @param $info |
| 1721 | * @param string $tableName |
| 1722 | * (optional) the name of the table that we are interested in only. |
| 1723 | * |
| 1724 | * @internal param \reference $triggerInfo to an array of trigger information |
| 1725 | * each element has 4 fields: |
| 1726 | * table - array of tableName |
| 1727 | * when - BEFORE or AFTER |
| 1728 | * event - array of eventName - INSERT OR UPDATE OR DELETE |
| 1729 | * sql - array of statements optionally terminated with a ; |
| 1730 | * a statement can use the tokes {tableName} and {eventName} |
| 1731 | * to do token replacement with the table / event. This allows |
| 1732 | * templatizing logging and other hooks |
| 1733 | * @return mixed |
| 1734 | */ |
| 1735 | public static function triggerInfo(&$info, $tableName = NULL) { |
| 1736 | return self::singleton()->invoke(['info', 'tableName'], $info, $tableName, |
| 1737 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1738 | self::$_nullObject, |
| 1739 | 'civicrm_triggerInfo' |
| 1740 | ); |
| 1741 | } |
| 1742 | |
| 1743 | /** |
| 1744 | * This hook allows changes to the spec of which tables to log. |
| 1745 | * |
| 1746 | * @param array $logTableSpec |
| 1747 | * |
| 1748 | * @return mixed |
| 1749 | */ |
| 1750 | public static function alterLogTables(&$logTableSpec) { |
| 1751 | return self::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject, |
| 1752 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1753 | self::$_nullObject, |
| 1754 | 'civicrm_alterLogTables' |
| 1755 | ); |
| 1756 | } |
| 1757 | |
| 1758 | /** |
| 1759 | * This hook is called when a module-extension is installed. |
| 1760 | * Each module will receive hook_civicrm_install during its own installation (but not during the |
| 1761 | * installation of unrelated modules). |
| 1762 | */ |
| 1763 | public static function install() { |
| 1764 | // Actually invoke via CRM_Extension_Manager_Module::callHook |
| 1765 | throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); |
| 1766 | } |
| 1767 | |
| 1768 | /** |
| 1769 | * This hook is called when a module-extension is uninstalled. |
| 1770 | * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the |
| 1771 | * uninstallation of unrelated modules). |
| 1772 | */ |
| 1773 | public static function uninstall() { |
| 1774 | // Actually invoke via CRM_Extension_Manager_Module::callHook |
| 1775 | throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); |
| 1776 | } |
| 1777 | |
| 1778 | /** |
| 1779 | * This hook is called when a module-extension is re-enabled. |
| 1780 | * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the |
| 1781 | * re-enablement of unrelated modules). |
| 1782 | */ |
| 1783 | public static function enable() { |
| 1784 | // Actually invoke via CRM_Extension_Manager_Module::callHook |
| 1785 | throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); |
| 1786 | } |
| 1787 | |
| 1788 | /** |
| 1789 | * This hook is called when a module-extension is disabled. |
| 1790 | * Each module will receive hook_civicrm_disable during its own disablement (but not during the |
| 1791 | * disablement of unrelated modules). |
| 1792 | */ |
| 1793 | public static function disable() { |
| 1794 | // Actually invoke via CRM_Extension_Manager_Module::callHook |
| 1795 | throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); |
| 1796 | } |
| 1797 | |
| 1798 | /** |
| 1799 | * Alter redirect. |
| 1800 | * |
| 1801 | * This hook is called when the browser is being re-directed and allows the url |
| 1802 | * to be altered. |
| 1803 | * |
| 1804 | * @param \Psr\Http\Message\UriInterface $url |
| 1805 | * @param array $context |
| 1806 | * Additional information about context |
| 1807 | * - output - if this is 'json' then it will return json. |
| 1808 | * |
| 1809 | * @return null |
| 1810 | * the return value is ignored |
| 1811 | */ |
| 1812 | public static function alterRedirect(&$url, &$context) { |
| 1813 | return self::singleton()->invoke(['url', 'context'], $url, |
| 1814 | $context, self::$_nullObject, |
| 1815 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1816 | 'civicrm_alterRedirect' |
| 1817 | ); |
| 1818 | } |
| 1819 | |
| 1820 | /** |
| 1821 | * @param $varType |
| 1822 | * @param $var |
| 1823 | * @param $object |
| 1824 | * |
| 1825 | * @return mixed |
| 1826 | */ |
| 1827 | public static function alterReportVar($varType, &$var, &$object) { |
| 1828 | return self::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object, |
| 1829 | self::$_nullObject, |
| 1830 | self::$_nullObject, self::$_nullObject, |
| 1831 | 'civicrm_alterReportVar' |
| 1832 | ); |
| 1833 | } |
| 1834 | |
| 1835 | /** |
| 1836 | * This hook is called to drive database upgrades for extension-modules. |
| 1837 | * |
| 1838 | * @param string $op |
| 1839 | * The type of operation being performed; 'check' or 'enqueue'. |
| 1840 | * @param CRM_Queue_Queue $queue |
| 1841 | * (for 'enqueue') the modifiable list of pending up upgrade tasks. |
| 1842 | * |
| 1843 | * @return bool|null |
| 1844 | * NULL, if $op is 'enqueue'. |
| 1845 | * TRUE, if $op is 'check' and upgrades are pending. |
| 1846 | * FALSE, if $op is 'check' and upgrades are not pending. |
| 1847 | */ |
| 1848 | public static function upgrade($op, CRM_Queue_Queue $queue = NULL) { |
| 1849 | return self::singleton()->invoke(['op', 'queue'], $op, $queue, |
| 1850 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1851 | self::$_nullObject, |
| 1852 | 'civicrm_upgrade' |
| 1853 | ); |
| 1854 | } |
| 1855 | |
| 1856 | /** |
| 1857 | * This hook is called when an email has been successfully sent by CiviCRM, but not on an error. |
| 1858 | * |
| 1859 | * @param array $params |
| 1860 | * The mailing parameters. Array fields include: groupName, from, toName, |
| 1861 | * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers, |
| 1862 | * attachments (array) |
| 1863 | * |
| 1864 | * @return mixed |
| 1865 | */ |
| 1866 | public static function postEmailSend(&$params) { |
| 1867 | return self::singleton()->invoke(['params'], $params, |
| 1868 | self::$_nullObject, self::$_nullObject, |
| 1869 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1870 | 'civicrm_postEmailSend' |
| 1871 | ); |
| 1872 | } |
| 1873 | |
| 1874 | /** |
| 1875 | * This hook is called when a CiviMail mailing has completed |
| 1876 | * |
| 1877 | * @param int $mailingId |
| 1878 | * Mailing ID |
| 1879 | * |
| 1880 | * @return mixed |
| 1881 | */ |
| 1882 | public static function postMailing($mailingId) { |
| 1883 | return self::singleton()->invoke(['mailingId'], $mailingId, |
| 1884 | self::$_nullObject, self::$_nullObject, |
| 1885 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1886 | 'civicrm_postMailing' |
| 1887 | ); |
| 1888 | } |
| 1889 | |
| 1890 | /** |
| 1891 | * This hook is called when Settings specifications are loaded. |
| 1892 | * |
| 1893 | * @param array $settingsFolders |
| 1894 | * List of paths from which to derive metadata |
| 1895 | * |
| 1896 | * @return mixed |
| 1897 | */ |
| 1898 | public static function alterSettingsFolders(&$settingsFolders) { |
| 1899 | return self::singleton()->invoke(['settingsFolders'], $settingsFolders, |
| 1900 | self::$_nullObject, self::$_nullObject, |
| 1901 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1902 | 'civicrm_alterSettingsFolders' |
| 1903 | ); |
| 1904 | } |
| 1905 | |
| 1906 | /** |
| 1907 | * This hook is called when Settings have been loaded from the xml |
| 1908 | * It is an opportunity for hooks to alter the data |
| 1909 | * |
| 1910 | * @param array $settingsMetaData |
| 1911 | * Settings Metadata. |
| 1912 | * @param int $domainID |
| 1913 | * @param mixed $profile |
| 1914 | * |
| 1915 | * @return mixed |
| 1916 | */ |
| 1917 | public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) { |
| 1918 | return self::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData, |
| 1919 | $domainID, $profile, |
| 1920 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1921 | 'civicrm_alterSettingsMetaData' |
| 1922 | ); |
| 1923 | } |
| 1924 | |
| 1925 | /** |
| 1926 | * This hook is called before running an api call. |
| 1927 | * |
| 1928 | * @param API_Wrapper[] $wrappers |
| 1929 | * (see CRM_Utils_API_ReloadOption as an example) |
| 1930 | * @param mixed $apiRequest |
| 1931 | * |
| 1932 | * @return null |
| 1933 | * The return value is ignored |
| 1934 | */ |
| 1935 | public static function apiWrappers(&$wrappers, $apiRequest) { |
| 1936 | return self::singleton() |
| 1937 | ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1938 | self::$_nullObject, 'civicrm_apiWrappers' |
| 1939 | ); |
| 1940 | } |
| 1941 | |
| 1942 | /** |
| 1943 | * This hook is called before running pending cron jobs. |
| 1944 | * |
| 1945 | * @param CRM_Core_JobManager $jobManager |
| 1946 | * |
| 1947 | * @return null |
| 1948 | * The return value is ignored. |
| 1949 | */ |
| 1950 | public static function cron($jobManager) { |
| 1951 | return self::singleton()->invoke(['jobManager'], |
| 1952 | $jobManager, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1953 | 'civicrm_cron' |
| 1954 | ); |
| 1955 | } |
| 1956 | |
| 1957 | /** |
| 1958 | * This hook is called when loading CMS permissions; use this hook to modify |
| 1959 | * the array of system permissions for CiviCRM. |
| 1960 | * |
| 1961 | * @param array $permissions |
| 1962 | * Array of permissions. See CRM_Core_Permission::getCorePermissions() for |
| 1963 | * the format of this array. |
| 1964 | * |
| 1965 | * @return null |
| 1966 | * The return value is ignored |
| 1967 | */ |
| 1968 | public static function permission(&$permissions) { |
| 1969 | return self::singleton()->invoke(['permissions'], $permissions, |
| 1970 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1971 | 'civicrm_permission' |
| 1972 | ); |
| 1973 | } |
| 1974 | |
| 1975 | /** |
| 1976 | * This hook is called when checking permissions; use this hook to dynamically |
| 1977 | * escalate user permissions in certain use cases (cf. CRM-19256). |
| 1978 | * |
| 1979 | * @param string $permission |
| 1980 | * The name of an atomic permission, ie. 'access deleted contacts' |
| 1981 | * @param bool $granted |
| 1982 | * Whether this permission is currently granted. The hook can change this value. |
| 1983 | * @param int $contactId |
| 1984 | * Contact whose permissions we are checking (if null, assume current user). |
| 1985 | * |
| 1986 | * @return null |
| 1987 | * The return value is ignored |
| 1988 | */ |
| 1989 | public static function permission_check($permission, &$granted, $contactId) { |
| 1990 | return self::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId, |
| 1991 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1992 | 'civicrm_permission_check' |
| 1993 | ); |
| 1994 | } |
| 1995 | |
| 1996 | /** |
| 1997 | * @param CRM_Core_Exception $exception |
| 1998 | * @param mixed $request |
| 1999 | * Reserved for future use. |
| 2000 | */ |
| 2001 | public static function unhandledException($exception, $request = NULL) { |
| 2002 | $event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject); |
| 2003 | \Civi::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event); |
| 2004 | } |
| 2005 | |
| 2006 | /** |
| 2007 | * This hook is called for declaring managed entities via API. |
| 2008 | * |
| 2009 | * Note: This is a pre-boot hook. It will dispatch via the extension/module |
| 2010 | * subsystem but *not* the Symfony EventDispatcher. |
| 2011 | * |
| 2012 | * @param array[] $entityTypes |
| 2013 | * List of entity types; each entity-type is an array with keys: |
| 2014 | * - name: string, a unique short name (e.g. "ReportInstance") |
| 2015 | * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance") |
| 2016 | * - table: string, a SQL table name (e.g. "civicrm_report_instance") |
| 2017 | * - fields_callback: array, list of callables which manipulates field list |
| 2018 | * - links_callback: array, list of callables which manipulates fk list |
| 2019 | * |
| 2020 | * @return null |
| 2021 | * The return value is ignored |
| 2022 | */ |
| 2023 | public static function entityTypes(&$entityTypes) { |
| 2024 | return self::singleton()->invoke(['entityTypes'], $entityTypes, self::$_nullObject, self::$_nullObject, |
| 2025 | self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes' |
| 2026 | ); |
| 2027 | } |
| 2028 | |
| 2029 | /** |
| 2030 | * Build a description of available hooks. |
| 2031 | * |
| 2032 | * @param \Civi\Core\CiviEventInspector $inspector |
| 2033 | */ |
| 2034 | public static function eventDefs($inspector) { |
| 2035 | $event = \Civi\Core\Event\GenericHookEvent::create([ |
| 2036 | 'inspector' => $inspector, |
| 2037 | ]); |
| 2038 | Civi::dispatcher()->dispatch('hook_civicrm_eventDefs', $event); |
| 2039 | } |
| 2040 | |
| 2041 | /** |
| 2042 | * This hook is called while preparing a profile form. |
| 2043 | * |
| 2044 | * @param string $profileName |
| 2045 | * @return mixed |
| 2046 | */ |
| 2047 | public static function buildProfile($profileName) { |
| 2048 | return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2049 | self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile'); |
| 2050 | } |
| 2051 | |
| 2052 | /** |
| 2053 | * This hook is called while validating a profile form submission. |
| 2054 | * |
| 2055 | * @param string $profileName |
| 2056 | * @return mixed |
| 2057 | */ |
| 2058 | public static function validateProfile($profileName) { |
| 2059 | return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2060 | self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile'); |
| 2061 | } |
| 2062 | |
| 2063 | /** |
| 2064 | * This hook is called processing a valid profile form submission. |
| 2065 | * |
| 2066 | * @param string $profileName |
| 2067 | * @return mixed |
| 2068 | */ |
| 2069 | public static function processProfile($profileName) { |
| 2070 | return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2071 | self::$_nullObject, self::$_nullObject, 'civicrm_processProfile'); |
| 2072 | } |
| 2073 | |
| 2074 | /** |
| 2075 | * This hook is called while preparing a read-only profile screen |
| 2076 | * |
| 2077 | * @param string $profileName |
| 2078 | * @return mixed |
| 2079 | */ |
| 2080 | public static function viewProfile($profileName) { |
| 2081 | return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2082 | self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile'); |
| 2083 | } |
| 2084 | |
| 2085 | /** |
| 2086 | * This hook is called while preparing a list of contacts (based on a profile) |
| 2087 | * |
| 2088 | * @param string $profileName |
| 2089 | * @return mixed |
| 2090 | */ |
| 2091 | public static function searchProfile($profileName) { |
| 2092 | return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2093 | self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile'); |
| 2094 | } |
| 2095 | |
| 2096 | /** |
| 2097 | * This hook is invoked when building a CiviCRM name badge. |
| 2098 | * |
| 2099 | * @param string $labelName |
| 2100 | * String referencing name of badge format. |
| 2101 | * @param object $label |
| 2102 | * Reference to the label object. |
| 2103 | * @param array $format |
| 2104 | * Array of format data. |
| 2105 | * @param array $participant |
| 2106 | * Array of participant values. |
| 2107 | * |
| 2108 | * @return null |
| 2109 | * the return value is ignored |
| 2110 | */ |
| 2111 | public static function alterBadge($labelName, &$label, &$format, &$participant) { |
| 2112 | return self::singleton() |
| 2113 | ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge'); |
| 2114 | } |
| 2115 | |
| 2116 | /** |
| 2117 | * This hook is called before encoding data in barcode. |
| 2118 | * |
| 2119 | * @param array $data |
| 2120 | * Associated array of values available for encoding. |
| 2121 | * @param string $type |
| 2122 | * Type of barcode, classic barcode or QRcode. |
| 2123 | * @param string $context |
| 2124 | * Where this hooks is invoked. |
| 2125 | * |
| 2126 | * @return mixed |
| 2127 | */ |
| 2128 | public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') { |
| 2129 | return self::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self::$_nullObject, |
| 2130 | self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode'); |
| 2131 | } |
| 2132 | |
| 2133 | /** |
| 2134 | * Modify or replace the Mailer object used for outgoing mail. |
| 2135 | * |
| 2136 | * @param object $mailer |
| 2137 | * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory) |
| 2138 | * @param string $driver |
| 2139 | * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool") |
| 2140 | * @param array $params |
| 2141 | * The default mailer config options |
| 2142 | * |
| 2143 | * @return mixed |
| 2144 | * @see Mail::factory |
| 2145 | */ |
| 2146 | public static function alterMailer(&$mailer, $driver, $params) { |
| 2147 | return self::singleton() |
| 2148 | ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer'); |
| 2149 | } |
| 2150 | |
| 2151 | /** |
| 2152 | * This hook is called while building the core search query, |
| 2153 | * so hook implementers can provide their own query objects which alters/extends core search. |
| 2154 | * |
| 2155 | * @param array $queryObjects |
| 2156 | * @param string $type |
| 2157 | * |
| 2158 | * @return mixed |
| 2159 | */ |
| 2160 | public static function queryObjects(&$queryObjects, $type = 'Contact') { |
| 2161 | return self::singleton() |
| 2162 | ->invoke(['queryObjects', 'type'], $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects'); |
| 2163 | } |
| 2164 | |
| 2165 | /** |
| 2166 | * This hook is called while viewing contact dashboard. |
| 2167 | * |
| 2168 | * @param array $availableDashlets |
| 2169 | * List of dashlets; each is formatted per api/v3/Dashboard |
| 2170 | * @param array $defaultDashlets |
| 2171 | * List of dashlets; each is formatted per api/v3/DashboardContact |
| 2172 | * |
| 2173 | * @return mixed |
| 2174 | */ |
| 2175 | public static function dashboard_defaults($availableDashlets, &$defaultDashlets) { |
| 2176 | return self::singleton() |
| 2177 | ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_dashboard_defaults'); |
| 2178 | } |
| 2179 | |
| 2180 | /** |
| 2181 | * This hook is called before a case merge (or a case reassign) |
| 2182 | * |
| 2183 | * @param int $mainContactId |
| 2184 | * @param int $mainCaseId |
| 2185 | * @param int $otherContactId |
| 2186 | * @param int $otherCaseId |
| 2187 | * @param bool $changeClient |
| 2188 | * |
| 2189 | * @return mixed |
| 2190 | */ |
| 2191 | public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) { |
| 2192 | return self::singleton() |
| 2193 | ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_pre_case_merge'); |
| 2194 | } |
| 2195 | |
| 2196 | /** |
| 2197 | * This hook is called after a case merge (or a case reassign) |
| 2198 | * |
| 2199 | * @param int $mainContactId |
| 2200 | * @param int $mainCaseId |
| 2201 | * @param int $otherContactId |
| 2202 | * @param int $otherCaseId |
| 2203 | * @param bool $changeClient |
| 2204 | * |
| 2205 | * @return mixed |
| 2206 | */ |
| 2207 | public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) { |
| 2208 | return self::singleton() |
| 2209 | ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_post_case_merge'); |
| 2210 | } |
| 2211 | |
| 2212 | /** |
| 2213 | * Issue CRM-14276 |
| 2214 | * Add a hook for altering the display name |
| 2215 | * |
| 2216 | * hook_civicrm_contact_get_displayname(&$display_name, $objContact) |
| 2217 | * |
| 2218 | * @param string $displayName |
| 2219 | * @param int $contactId |
| 2220 | * @param object $dao |
| 2221 | * The contact object. |
| 2222 | * |
| 2223 | * @return mixed |
| 2224 | */ |
| 2225 | public static function alterDisplayName(&$displayName, $contactId, $dao) { |
| 2226 | return self::singleton()->invoke(['displayName', 'contactId', 'dao'], |
| 2227 | $displayName, $contactId, $dao, self::$_nullObject, self::$_nullObject, |
| 2228 | self::$_nullObject, 'civicrm_contact_get_displayname' |
| 2229 | ); |
| 2230 | } |
| 2231 | |
| 2232 | /** |
| 2233 | * Modify the CRM_Core_Resources settings data. |
| 2234 | * |
| 2235 | * @param array $data |
| 2236 | * @see CRM_Core_Resources::addSetting |
| 2237 | */ |
| 2238 | public static function alterResourceSettings(&$data) { |
| 2239 | $event = \Civi\Core\Event\GenericHookEvent::create([ |
| 2240 | 'data' => &$data, |
| 2241 | ]); |
| 2242 | Civi::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event); |
| 2243 | } |
| 2244 | |
| 2245 | /** |
| 2246 | * EXPERIMENTAL: This hook allows one to register additional Angular modules |
| 2247 | * |
| 2248 | * @param array $angularModules |
| 2249 | * List of modules. Each module defines: |
| 2250 | * - ext: string, the CiviCRM extension which hosts the files. |
| 2251 | * - js: array, list of JS files or globs. |
| 2252 | * - css: array, list of CSS files or globs. |
| 2253 | * - partials: array, list of base-dirs containing HTML. |
| 2254 | * - partialsCallback: mixed, a callback function which generates a list of HTML |
| 2255 | * function(string $moduleName, array $moduleDefn) => array(string $file => string $html) |
| 2256 | * For future-proofing, use a serializable callback (e.g. string/array). |
| 2257 | * See also: Civi\Core\Resolver. |
| 2258 | * - requires: array, list of required Angular modules. |
| 2259 | * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+] |
| 2260 | * If omitted, default to "array('civicrm/a')" for backward compat. |
| 2261 | * For a utility that should only be loaded on-demand, use "array()". |
| 2262 | * For a utility that should be loaded in all pages use, "array('*')". |
| 2263 | * |
| 2264 | * ``` |
| 2265 | * function mymod_civicrm_angularModules(&$angularModules) { |
| 2266 | * $angularModules['myAngularModule'] = array( |
| 2267 | * 'ext' => 'org.example.mymod', |
| 2268 | * 'js' => array('js/myAngularModule.js'), |
| 2269 | * ); |
| 2270 | * $angularModules['myBigAngularModule'] = array( |
| 2271 | * 'ext' => 'org.example.mymod', |
| 2272 | * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'), |
| 2273 | * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'), |
| 2274 | * 'partials' => array('partials/myBigAngularModule'), |
| 2275 | * 'requires' => array('otherModuleA', 'otherModuleB'), |
| 2276 | * 'basePages' => array('civicrm/a'), |
| 2277 | * ); |
| 2278 | * } |
| 2279 | * ``` |
| 2280 | * |
| 2281 | * @return null |
| 2282 | * the return value is ignored |
| 2283 | */ |
| 2284 | public static function angularModules(&$angularModules) { |
| 2285 | return self::singleton()->invoke(['angularModules'], $angularModules, |
| 2286 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2287 | 'civicrm_angularModules' |
| 2288 | ); |
| 2289 | } |
| 2290 | |
| 2291 | /** |
| 2292 | * Alter the definition of some Angular HTML partials. |
| 2293 | * |
| 2294 | * @param \Civi\Angular\Manager $angular |
| 2295 | * |
| 2296 | * ``` |
| 2297 | * function example_civicrm_alterAngular($angular) { |
| 2298 | * $changeSet = \Civi\Angular\ChangeSet::create('mychanges') |
| 2299 | * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) { |
| 2300 | * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')'); |
| 2301 | * }) |
| 2302 | * ); |
| 2303 | * $angular->add($changeSet); |
| 2304 | * } |
| 2305 | * ``` |
| 2306 | */ |
| 2307 | public static function alterAngular($angular) { |
| 2308 | $event = \Civi\Core\Event\GenericHookEvent::create([ |
| 2309 | 'angular' => $angular, |
| 2310 | ]); |
| 2311 | Civi::dispatcher()->dispatch('hook_civicrm_alterAngular', $event); |
| 2312 | } |
| 2313 | |
| 2314 | /** |
| 2315 | * This hook is called when building a link to a semi-static asset. |
| 2316 | * |
| 2317 | * @param string $asset |
| 2318 | * The name of the asset. |
| 2319 | * Ex: 'angular.json' |
| 2320 | * @param array $params |
| 2321 | * List of optional arguments which influence the content. |
| 2322 | * @return null |
| 2323 | * the return value is ignored |
| 2324 | */ |
| 2325 | public static function getAssetUrl(&$asset, &$params) { |
| 2326 | return self::singleton()->invoke(['asset', 'params'], |
| 2327 | $asset, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2328 | 'civicrm_getAssetUrl' |
| 2329 | ); |
| 2330 | } |
| 2331 | |
| 2332 | /** |
| 2333 | * This hook is called whenever the system builds a new copy of |
| 2334 | * semi-static asset. |
| 2335 | * |
| 2336 | * @param string $asset |
| 2337 | * The name of the asset. |
| 2338 | * Ex: 'angular.json' |
| 2339 | * @param array $params |
| 2340 | * List of optional arguments which influence the content. |
| 2341 | * Note: Params are immutable because they are part of the cache-key. |
| 2342 | * @param string $mimeType |
| 2343 | * Initially, NULL. Modify to specify the mime-type. |
| 2344 | * @param string $content |
| 2345 | * Initially, NULL. Modify to specify the rendered content. |
| 2346 | * @return null |
| 2347 | * the return value is ignored |
| 2348 | */ |
| 2349 | public static function buildAsset($asset, $params, &$mimeType, &$content) { |
| 2350 | return self::singleton()->invoke(['asset', 'params', 'mimeType', 'content'], |
| 2351 | $asset, $params, $mimeType, $content, self::$_nullObject, self::$_nullObject, |
| 2352 | 'civicrm_buildAsset' |
| 2353 | ); |
| 2354 | } |
| 2355 | |
| 2356 | /** |
| 2357 | * This hook fires whenever a record in a case changes. |
| 2358 | * |
| 2359 | * @param \Civi\CCase\Analyzer $analyzer |
| 2360 | * A bundle of data about the case (such as the case and activity records). |
| 2361 | */ |
| 2362 | public static function caseChange(\Civi\CCase\Analyzer $analyzer) { |
| 2363 | $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer); |
| 2364 | \Civi::dispatcher()->dispatch('hook_civicrm_caseChange', $event); |
| 2365 | } |
| 2366 | |
| 2367 | /** |
| 2368 | * Generate a default CRUD URL for an entity. |
| 2369 | * |
| 2370 | * @param array $spec |
| 2371 | * With keys:. |
| 2372 | * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE |
| 2373 | * - entity_table: string |
| 2374 | * - entity_id: int |
| 2375 | * @param CRM_Core_DAO $bao |
| 2376 | * @param array $link |
| 2377 | * To define the link, add these keys to $link:. |
| 2378 | * - title: string |
| 2379 | * - path: string |
| 2380 | * - query: array |
| 2381 | * - url: string (used in lieu of "path"/"query") |
| 2382 | * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false |
| 2383 | * @return mixed |
| 2384 | */ |
| 2385 | public static function crudLink($spec, $bao, &$link) { |
| 2386 | return self::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link, |
| 2387 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2388 | 'civicrm_crudLink' |
| 2389 | ); |
| 2390 | } |
| 2391 | |
| 2392 | /** |
| 2393 | * Modify the CiviCRM container - add new services, parameters, extensions, etc. |
| 2394 | * |
| 2395 | * ``` |
| 2396 | * use Symfony\Component\Config\Resource\FileResource; |
| 2397 | * use Symfony\Component\DependencyInjection\Definition; |
| 2398 | * |
| 2399 | * function mymodule_civicrm_container($container) { |
| 2400 | * $container->addResource(new FileResource(__FILE__)); |
| 2401 | * $container->setDefinition('mysvc', new Definition('My\Class', array())); |
| 2402 | * } |
| 2403 | * ``` |
| 2404 | * |
| 2405 | * Tip: The container configuration will be compiled/cached. The default cache |
| 2406 | * behavior is aggressive. When you first implement the hook, be sure to |
| 2407 | * flush the cache. Additionally, you should relax caching during development. |
| 2408 | * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto'). |
| 2409 | * |
| 2410 | * Note: This is a preboot hook. It will dispatch via the extension/module |
| 2411 | * subsystem but *not* the Symfony EventDispatcher. |
| 2412 | * |
| 2413 | * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
| 2414 | * @see http://symfony.com/doc/current/components/dependency_injection/index.html |
| 2415 | */ |
| 2416 | public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder $container) { |
| 2417 | self::singleton()->invoke(['container'], $container, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_container'); |
| 2418 | } |
| 2419 | |
| 2420 | /** |
| 2421 | * @param array $fileSearches CRM_Core_FileSearchInterface |
| 2422 | * @return mixed |
| 2423 | */ |
| 2424 | public static function fileSearches(&$fileSearches) { |
| 2425 | return self::singleton()->invoke(['fileSearches'], $fileSearches, |
| 2426 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2427 | 'civicrm_fileSearches' |
| 2428 | ); |
| 2429 | } |
| 2430 | |
| 2431 | /** |
| 2432 | * Check system status. |
| 2433 | * |
| 2434 | * @param CRM_Utils_Check_Message[] $messages |
| 2435 | * A list of messages regarding system status |
| 2436 | * @param array $statusNames |
| 2437 | * If specified, only these checks are being requested and others should be skipped |
| 2438 | * @param bool $includeDisabled |
| 2439 | * Run checks that have been explicitly disabled (default false) |
| 2440 | * @return mixed |
| 2441 | */ |
| 2442 | public static function check(&$messages, $statusNames = [], $includeDisabled = FALSE) { |
| 2443 | return self::singleton()->invoke(['messages'], |
| 2444 | $messages, $statusNames, $includeDisabled, |
| 2445 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2446 | 'civicrm_check' |
| 2447 | ); |
| 2448 | } |
| 2449 | |
| 2450 | /** |
| 2451 | * This hook is called when a query string of the CSV Batch export is generated. |
| 2452 | * |
| 2453 | * @param string $query |
| 2454 | * |
| 2455 | * @return mixed |
| 2456 | */ |
| 2457 | public static function batchQuery(&$query) { |
| 2458 | return self::singleton()->invoke(['query'], $query, self::$_nullObject, |
| 2459 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2460 | 'civicrm_batchQuery' |
| 2461 | ); |
| 2462 | } |
| 2463 | |
| 2464 | /** |
| 2465 | * This hook is called to alter Deferred revenue item values just before they are |
| 2466 | * inserted in civicrm_financial_trxn table |
| 2467 | * |
| 2468 | * @param array $deferredRevenues |
| 2469 | * |
| 2470 | * @param array $contributionDetails |
| 2471 | * |
| 2472 | * @param bool $update |
| 2473 | * |
| 2474 | * @param string $context |
| 2475 | * |
| 2476 | * @return mixed |
| 2477 | */ |
| 2478 | public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) { |
| 2479 | return self::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context, |
| 2480 | self::$_nullObject, self::$_nullObject, 'civicrm_alterDeferredRevenueItems' |
| 2481 | ); |
| 2482 | } |
| 2483 | |
| 2484 | /** |
| 2485 | * This hook is called when the entries of the CSV Batch export are mapped. |
| 2486 | * |
| 2487 | * @param array $results |
| 2488 | * @param array $items |
| 2489 | * |
| 2490 | * @return mixed |
| 2491 | */ |
| 2492 | public static function batchItems(&$results, &$items) { |
| 2493 | return self::singleton()->invoke(['results', 'items'], $results, $items, |
| 2494 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2495 | 'civicrm_batchItems' |
| 2496 | ); |
| 2497 | } |
| 2498 | |
| 2499 | /** |
| 2500 | * This hook is called when core resources are being loaded |
| 2501 | * |
| 2502 | * @see CRM_Core_Resources::coreResourceList |
| 2503 | * |
| 2504 | * @param array $list |
| 2505 | * @param string $region |
| 2506 | */ |
| 2507 | public static function coreResourceList(&$list, $region) { |
| 2508 | self::singleton()->invoke(['list', 'region'], $list, $region, |
| 2509 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2510 | 'civicrm_coreResourceList' |
| 2511 | ); |
| 2512 | } |
| 2513 | |
| 2514 | /** |
| 2515 | * Allows the list of filters on the EntityRef widget to be altered. |
| 2516 | * |
| 2517 | * @see CRM_Core_Resources::entityRefFilters |
| 2518 | * |
| 2519 | * @param array $filters |
| 2520 | * @param array $links |
| 2521 | */ |
| 2522 | public static function entityRefFilters(&$filters, &$links = NULL) { |
| 2523 | self::singleton()->invoke(['filters', 'links'], $filters, $links, self::$_nullObject, |
| 2524 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2525 | 'civicrm_entityRefFilters' |
| 2526 | ); |
| 2527 | } |
| 2528 | |
| 2529 | /** |
| 2530 | * This hook is called for bypass a few civicrm urls from IDS check. |
| 2531 | * |
| 2532 | * @param array $skip list of civicrm urls |
| 2533 | * |
| 2534 | * @return mixed |
| 2535 | */ |
| 2536 | public static function idsException(&$skip) { |
| 2537 | return self::singleton()->invoke(['skip'], $skip, self::$_nullObject, |
| 2538 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2539 | 'civicrm_idsException' |
| 2540 | ); |
| 2541 | } |
| 2542 | |
| 2543 | /** |
| 2544 | * This hook is called when a geocoder's format method is called. |
| 2545 | * |
| 2546 | * @param string $geoProvider |
| 2547 | * @param array $values |
| 2548 | * @param SimpleXMLElement $xml |
| 2549 | * |
| 2550 | * @return mixed |
| 2551 | */ |
| 2552 | public static function geocoderFormat($geoProvider, &$values, $xml) { |
| 2553 | return self::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml, |
| 2554 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2555 | 'civicrm_geocoderFormat' |
| 2556 | ); |
| 2557 | } |
| 2558 | |
| 2559 | /** |
| 2560 | * This hook is called before an inbound SMS is processed. |
| 2561 | * |
| 2562 | * @param \CRM_SMS_Message $message |
| 2563 | * An SMS message received |
| 2564 | * @return mixed |
| 2565 | */ |
| 2566 | public static function inboundSMS(&$message) { |
| 2567 | return self::singleton()->invoke(['message'], $message, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_inboundSMS'); |
| 2568 | } |
| 2569 | |
| 2570 | /** |
| 2571 | * This hook is called to modify api params of EntityRef form field |
| 2572 | * |
| 2573 | * @param array $params |
| 2574 | * @param string $formName |
| 2575 | * @return mixed |
| 2576 | */ |
| 2577 | public static function alterEntityRefParams(&$params, $formName) { |
| 2578 | return self::singleton()->invoke(['params', 'formName'], $params, $formName, |
| 2579 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2580 | 'civicrm_alterEntityRefParams' |
| 2581 | ); |
| 2582 | } |
| 2583 | |
| 2584 | /** |
| 2585 | * This hook is called before a scheduled job is executed |
| 2586 | * |
| 2587 | * @param CRM_Core_DAO_Job $job |
| 2588 | * The job to be executed |
| 2589 | * @param array $params |
| 2590 | * The arguments to be given to the job |
| 2591 | */ |
| 2592 | public static function preJob($job, $params) { |
| 2593 | return self::singleton()->invoke(['job', 'params'], $job, $params, |
| 2594 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2595 | 'civicrm_preJob' |
| 2596 | ); |
| 2597 | } |
| 2598 | |
| 2599 | /** |
| 2600 | * This hook is called after a scheduled job is executed |
| 2601 | * |
| 2602 | * @param CRM_Core_DAO_Job $job |
| 2603 | * The job that was executed |
| 2604 | * @param array $params |
| 2605 | * The arguments given to the job |
| 2606 | * @param array $result |
| 2607 | * The result of the API call, or the thrown exception if any |
| 2608 | */ |
| 2609 | public static function postJob($job, $params, $result) { |
| 2610 | return self::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result, |
| 2611 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2612 | 'civicrm_postJob' |
| 2613 | ); |
| 2614 | } |
| 2615 | |
| 2616 | /** |
| 2617 | * This hook is called before and after constructing mail recipients. |
| 2618 | * Allows user to alter filter and/or search query to fetch mail recipients |
| 2619 | * |
| 2620 | * @param CRM_Mailing_DAO_Mailing $mailingObject |
| 2621 | * @param array $criteria |
| 2622 | * A list of SQL criteria; you can add/remove/replace/modify criteria. |
| 2623 | * Array(string $name => CRM_Utils_SQL_Select $criterion). |
| 2624 | * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")). |
| 2625 | * @param string $context |
| 2626 | * Ex: 'pre', 'post' |
| 2627 | * @return mixed |
| 2628 | */ |
| 2629 | public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) { |
| 2630 | return self::singleton()->invoke(['mailingObject', 'params', 'context'], |
| 2631 | $mailingObject, $criteria, $context, |
| 2632 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2633 | 'civicrm_alterMailingRecipients' |
| 2634 | ); |
| 2635 | } |
| 2636 | |
| 2637 | /** |
| 2638 | * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN |
| 2639 | * @param array $IPNData - Array of IPN Data |
| 2640 | * @return mixed |
| 2641 | */ |
| 2642 | public static function postIPNProcess(&$IPNData) { |
| 2643 | return self::singleton()->invoke(['IPNData'], |
| 2644 | $IPNData, self::$_nullObject, self::$_nullObject, |
| 2645 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2646 | 'civicrm_postIPNProcess' |
| 2647 | ); |
| 2648 | } |
| 2649 | |
| 2650 | /** |
| 2651 | * Allow extensions to modify the array of acceptable fields to be included on profiles |
| 2652 | * @param array $fields |
| 2653 | * format is [Entity => array of DAO fields] |
| 2654 | * @return mixed |
| 2655 | */ |
| 2656 | public static function alterUFFields(&$fields) { |
| 2657 | return self::singleton()->invoke(['fields'], |
| 2658 | $fields, self::$_nullObject, self::$_nullObject, |
| 2659 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 2660 | 'civicrm_alterUFFields' |
| 2661 | ); |
| 2662 | } |
| 2663 | |
| 2664 | /** |
| 2665 | * This hook is called to alter Custom field value before its displayed. |
| 2666 | * |
| 2667 | * @param string $displayValue |
| 2668 | * @param mixed $value |
| 2669 | * @param int $entityId |
| 2670 | * @param array $fieldInfo |
| 2671 | * |
| 2672 | * @return mixed |
| 2673 | */ |
| 2674 | public static function alterCustomFieldDisplayValue(&$displayValue, $value, $entityId, $fieldInfo) { |
| 2675 | return self::singleton()->invoke( |
| 2676 | ['displayValue', 'value', 'entityId', 'fieldInfo'], |
| 2677 | $displayValue, $value, $entityId, $fieldInfo, self::$_nullObject, |
| 2678 | self::$_nullObject, 'civicrm_alterCustomFieldDisplayValue' |
| 2679 | ); |
| 2680 | } |
| 2681 | |
| 2682 | } |