| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.4 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2013 | |
| 7 | +--------------------------------------------------------------------+ |
| 8 | | This file is a part of CiviCRM. | |
| 9 | | | |
| 10 | | CiviCRM is free software; you can copy, modify, and distribute it | |
| 11 | | under the terms of the GNU Affero General Public License | |
| 12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
| 13 | | | |
| 14 | | CiviCRM is distributed in the hope that it will be useful, but | |
| 15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 17 | | See the GNU Affero General Public License for more details. | |
| 18 | | | |
| 19 | | You should have received a copy of the GNU Affero General Public | |
| 20 | | License and the CiviCRM Licensing Exception along | |
| 21 | | with this program; if not, contact CiviCRM LLC | |
| 22 | | at info[AT]civicrm[DOT]org. If you have questions about the | |
| 23 | | GNU Affero General Public License or the licensing of CiviCRM, | |
| 24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | |
| 25 | +--------------------------------------------------------------------+ |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * @package CiviCRM_Hook |
| 31 | * @copyright CiviCRM LLC (c) 2004-2013 |
| 32 | * $Id: $ |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | abstract class CRM_Utils_Hook { |
| 37 | |
| 38 | // Allowed values for dashboard hook content placement |
| 39 | // Default - place content below activity list |
| 40 | CONST DASHBOARD_BELOW = 1; |
| 41 | // Place content above activity list |
| 42 | CONST DASHBOARD_ABOVE = 2; |
| 43 | // Don't display activity list at all |
| 44 | CONST DASHBOARD_REPLACE = 3; |
| 45 | |
| 46 | // by default - place content below existing content |
| 47 | CONST SUMMARY_BELOW = 1; |
| 48 | // pace hook content above |
| 49 | CONST SUMMARY_ABOVE = 2; |
| 50 | // create your own summarys |
| 51 | CONST SUMMARY_REPLACE = 3; |
| 52 | |
| 53 | static $_nullObject = NULL; |
| 54 | |
| 55 | /** |
| 56 | * We only need one instance of this object. So we use the singleton |
| 57 | * pattern and cache the instance in this variable |
| 58 | * |
| 59 | * @var object |
| 60 | * @static |
| 61 | */ |
| 62 | static private $_singleton = NULL; |
| 63 | |
| 64 | /** |
| 65 | * @var bool |
| 66 | */ |
| 67 | private $commonIncluded = FALSE; |
| 68 | |
| 69 | /** |
| 70 | * @var array(string) |
| 71 | */ |
| 72 | private $commonCiviModules = array(); |
| 73 | |
| 74 | /** |
| 75 | * Constructor and getter for the singleton instance |
| 76 | * |
| 77 | * @return instance of $config->userHookClass |
| 78 | */ |
| 79 | static function singleton($fresh = FALSE) { |
| 80 | if (self::$_singleton == NULL || $fresh) { |
| 81 | $config = CRM_Core_Config::singleton(); |
| 82 | $class = $config->userHookClass; |
| 83 | require_once (str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php'); |
| 84 | self::$_singleton = new $class(); |
| 85 | } |
| 86 | return self::$_singleton; |
| 87 | } |
| 88 | |
| 89 | abstract function invoke($numParams, |
| 90 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, |
| 91 | $fnSuffix |
| 92 | ); |
| 93 | |
| 94 | function commonInvoke($numParams, |
| 95 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, |
| 96 | $fnSuffix, $fnPrefix |
| 97 | ) { |
| 98 | |
| 99 | $this->commonBuildModuleList($fnPrefix); |
| 100 | |
| 101 | return $this->runHooks($this->commonCiviModules, $fnSuffix, |
| 102 | $numParams, $arg1, $arg2, $arg3, $arg4, $arg5 |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Build the list of modules to be processed for hooks. |
| 108 | */ |
| 109 | function commonBuildModuleList($fnPrefix) { |
| 110 | if (!$this->commonIncluded) { |
| 111 | // include external file |
| 112 | $this->commonIncluded = TRUE; |
| 113 | |
| 114 | $config = CRM_Core_Config::singleton(); |
| 115 | if (!empty($config->customPHPPathDir) && |
| 116 | file_exists("{$config->customPHPPathDir}/civicrmHooks.php") |
| 117 | ) { |
| 118 | @include_once ("civicrmHooks.php"); |
| 119 | } |
| 120 | |
| 121 | if (!empty($fnPrefix)) { |
| 122 | $this->commonCiviModules[$fnPrefix] = $fnPrefix; |
| 123 | } |
| 124 | |
| 125 | $this->requireCiviModules($this->commonCiviModules); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | function runHooks($civiModules, $fnSuffix, $numParams, |
| 130 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5 |
| 131 | ) { |
| 132 | // $civiModules is *not* passed by reference because runHooks |
| 133 | // must be reentrant. PHP is finicky about running |
| 134 | // multiple loops over the same variable. The circumstances |
| 135 | // to reproduce the issue are pretty intricate. |
| 136 | $result = $fResult = array(); |
| 137 | |
| 138 | if ($civiModules !== NULL) { |
| 139 | foreach ($civiModules as $module) { |
| 140 | $fnName = "{$module}_{$fnSuffix}"; |
| 141 | if (function_exists($fnName)) { |
| 142 | switch ($numParams) { |
| 143 | case 0: |
| 144 | $fResult = $fnName(); |
| 145 | break; |
| 146 | |
| 147 | case 1: |
| 148 | $fResult = $fnName($arg1); |
| 149 | break; |
| 150 | |
| 151 | case 2: |
| 152 | $fResult = $fnName($arg1, $arg2); |
| 153 | break; |
| 154 | |
| 155 | case 3: |
| 156 | $fResult = $fnName($arg1, $arg2, $arg3); |
| 157 | break; |
| 158 | |
| 159 | case 4: |
| 160 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4); |
| 161 | break; |
| 162 | |
| 163 | case 5: |
| 164 | $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5); |
| 165 | break; |
| 166 | |
| 167 | default: |
| 168 | CRM_Core_Error::fatal(ts('Invalid hook invocation')); |
| 169 | break; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | if (!empty($fResult) && |
| 174 | is_array($fResult)) { |
| 175 | $result = array_merge($result, $fResult); |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | return empty($result) ? TRUE : $result; |
| 181 | } |
| 182 | |
| 183 | function requireCiviModules(&$moduleList) { |
| 184 | $civiModules = CRM_Core_PseudoConstant::getModuleExtensions(); |
| 185 | foreach ($civiModules as $civiModule) { |
| 186 | if (!file_exists($civiModule['filePath'])) { |
| 187 | CRM_Core_Session::setStatus( |
| 188 | ts( 'Error loading module file (%1). Please restore the file or disable the module.', |
| 189 | array(1 => $civiModule['filePath']) ), |
| 190 | ts( 'Warning'), 'error'); |
| 191 | continue; |
| 192 | } |
| 193 | include_once $civiModule['filePath']; |
| 194 | $moduleList[$civiModule['prefix']] = $civiModule['prefix']; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * This hook is called before a db write on some core objects. |
| 200 | * This hook does not allow the abort of the operation |
| 201 | * |
| 202 | * @param string $op the type of operation being performed |
| 203 | * @param string $objectName the name of the object |
| 204 | * @param object $id the object id if available |
| 205 | * @param array $params the parameters used for object creation / editing |
| 206 | * |
| 207 | * @return null the return value is ignored |
| 208 | * @access public |
| 209 | */ |
| 210 | static function pre($op, $objectName, $id, &$params) { |
| 211 | return self::singleton()->invoke(4, $op, $objectName, $id, $params, $op, 'civicrm_pre'); |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * This hook is called after a db write on some core objects. |
| 216 | * |
| 217 | * @param string $op the type of operation being performed |
| 218 | * @param string $objectName the name of the object |
| 219 | * @param int $objectId the unique identifier for the object |
| 220 | * @param object $objectRef the reference to the object if available |
| 221 | * |
| 222 | * @return mixed based on op. pre-hooks return a boolean or |
| 223 | * an error message which aborts the operation |
| 224 | * @access public |
| 225 | */ |
| 226 | static function post($op, $objectName, $objectId, &$objectRef) { |
| 227 | return self::singleton()->invoke(4, $op, $objectName, $objectId, $objectRef, $op, 'civicrm_post'); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * This hook retrieves links from other modules and injects it into |
| 232 | * the view contact tabs |
| 233 | * |
| 234 | * @param string $op the type of operation being performed |
| 235 | * @param string $objectName the name of the object |
| 236 | * @param int $objectId the unique identifier for the object |
| 237 | * @params array $links (optional ) the links array (introduced in v3.2) |
| 238 | * |
| 239 | * @return array|null an array of arrays, each element is a tuple consisting of id, url, img, title, weight |
| 240 | * |
| 241 | * @access public |
| 242 | */ |
| 243 | static function links($op, $objectName, &$objectId, &$links, &$mask = NULL) { |
| 244 | return self::singleton()->invoke(5, $op, $objectName, $objectId, $links, $mask, 'civicrm_links'); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * This hook is invoked when building a CiviCRM form. This hook should also |
| 249 | * be used to set the default values of a form element |
| 250 | * |
| 251 | * @param string $formName the name of the form |
| 252 | * @param object $form reference to the form object |
| 253 | * |
| 254 | * @return null the return value is ignored |
| 255 | */ |
| 256 | static function buildForm($formName, &$form) { |
| 257 | return self::singleton()->invoke(2, $formName, $form, $formName, $formName, $formName, 'civicrm_buildForm'); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * This hook is invoked when a CiviCRM form is submitted. If the module has injected |
| 262 | * any form elements, this hook should save the values in the database |
| 263 | * |
| 264 | * @param string $formName the name of the form |
| 265 | * @param object $form reference to the form object |
| 266 | * |
| 267 | * @return null the return value is ignored |
| 268 | */ |
| 269 | static function postProcess($formName, &$form) { |
| 270 | return self::singleton()->invoke(2, $formName, $form, $formName, $formName, $formName, 'civicrm_postProcess'); |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * This hook is invoked during all CiviCRM form validation. An array of errors |
| 275 | * detected is returned. Else we assume validation succeeded. |
| 276 | * |
| 277 | * @param string $formName the name of the form |
| 278 | * @param array &$fields the POST parameters as filtered by QF |
| 279 | * @param array &$files the FILES parameters as sent in by POST |
| 280 | * @param array &$form the form object |
| 281 | * |
| 282 | * @return mixed formRule hooks return a boolean or |
| 283 | * an array of error messages which display a QF Error |
| 284 | * @access public |
| 285 | */ |
| 286 | static function validate($formName, &$fields, &$files, &$form) { |
| 287 | return self::singleton()->invoke(4, $formName, $fields, $files, $form, $formName, 'civicrm_validate'); |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * This hook is invoked during all CiviCRM form validation. An array of errors |
| 292 | * detected is returned. Else we assume validation succeeded. |
| 293 | * |
| 294 | * @param string $formName the name of the form |
| 295 | * @param array &$fields the POST parameters as filtered by QF |
| 296 | * @param array &$files the FILES parameters as sent in by POST |
| 297 | * @param array &$form the form object |
| 298 | * @param array &$errors the array of errors. |
| 299 | * |
| 300 | * @return mixed formRule hooks return a boolean or |
| 301 | * an array of error messages which display a QF Error |
| 302 | * @access public |
| 303 | */ |
| 304 | static function validateForm($formName, &$fields, &$files, &$form, &$errors) { |
| 305 | return self::singleton()->invoke(5, $formName, $fields, $files, $form, $errors, 'civicrm_validateForm'); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * This hook is called before a db write on a custom table |
| 310 | * |
| 311 | * @param string $op the type of operation being performed |
| 312 | * @param string $groupID the custom group ID |
| 313 | * @param object $entityID the entityID of the row in the custom table |
| 314 | * @param array $params the parameters that were sent into the calling function |
| 315 | * |
| 316 | * @return null the return value is ignored |
| 317 | * @access public |
| 318 | */ |
| 319 | static function custom($op, $groupID, $entityID, &$params) { |
| 320 | return self::singleton()->invoke(4, $op, $groupID, $entityID, $params, $op, 'civicrm_custom'); |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * This hook is called when composing the ACL where clause to restrict |
| 325 | * visibility of contacts to the logged in user |
| 326 | * |
| 327 | * @param int $type the type of permission needed |
| 328 | * @param array $tables (reference ) add the tables that are needed for the select clause |
| 329 | * @param array $whereTables (reference ) add the tables that are needed for the where clause |
| 330 | * @param int $contactID the contactID for whom the check is made |
| 331 | * @param string $where the currrent where clause |
| 332 | * |
| 333 | * @return null the return value is ignored |
| 334 | * @access public |
| 335 | */ |
| 336 | static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) { |
| 337 | return self::singleton()->invoke(5, $type, $tables, $whereTables, $contactID, $where, 'civicrm_aclWhereClause'); |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * This hook is called when composing the ACL where clause to restrict |
| 342 | * visibility of contacts to the logged in user |
| 343 | * |
| 344 | * @param int $type the type of permission needed |
| 345 | * @param int $contactID the contactID for whom the check is made |
| 346 | * @param string $tableName the tableName which is being permissioned |
| 347 | * @param array $allGroups the set of all the objects for the above table |
| 348 | * @param array $currentGroups the set of objects that are currently permissioned for this contact |
| 349 | * |
| 350 | * @return null the return value is ignored |
| 351 | * @access public |
| 352 | */ |
| 353 | static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) { |
| 354 | return self::singleton()->invoke(5, $type, $contactID, $tableName, $allGroups, $currentGroups, 'civicrm_aclGroup'); |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * This hook is called when building the menu table |
| 359 | * |
| 360 | * @param array $files The current set of files to process |
| 361 | * |
| 362 | * @return null the return value is ignored |
| 363 | * @access public |
| 364 | */ |
| 365 | static function xmlMenu(&$files) { |
| 366 | return self::singleton()->invoke(1, $files, |
| 367 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 368 | 'civicrm_xmlMenu' |
| 369 | ); |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * This hook is called for declaring managed entities via API |
| 374 | * |
| 375 | * @param array $entities List of pending entities |
| 376 | * |
| 377 | * @return null the return value is ignored |
| 378 | * @access public |
| 379 | */ |
| 380 | static function managed(&$entities) { |
| 381 | return self::singleton()->invoke(1, $entities, |
| 382 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 383 | 'civicrm_managed' |
| 384 | ); |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * This hook is called when rendering the dashboard (q=civicrm/dashboard) |
| 389 | * |
| 390 | * @param int $contactID - the contactID for whom the dashboard is being rendered |
| 391 | * @param int $contentPlacement - (output parameter) where should the hook content be displayed |
| 392 | * relative to the activity list |
| 393 | * |
| 394 | * @return string the html snippet to include in the dashboard |
| 395 | * @access public |
| 396 | */ |
| 397 | static function dashboard($contactID, &$contentPlacement = self::DASHBOARD_BELOW) { |
| 398 | $retval = self::singleton()->invoke(2, $contactID, $contentPlacement, |
| 399 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 400 | 'civicrm_dashboard' |
| 401 | ); |
| 402 | |
| 403 | /* |
| 404 | * Note we need this seemingly unnecessary code because in the event that the implementation |
| 405 | * of the hook declares the second parameter but doesn't set it, then it comes back unset even |
| 406 | * though we have a default value in this function's declaration above. |
| 407 | */ |
| 408 | if (!isset($contentPlacement)) { |
| 409 | $contentPlacement = self::DASHBOARD_BELOW; |
| 410 | } |
| 411 | |
| 412 | return $retval; |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * This hook is called before storing recently viewed items. |
| 417 | * |
| 418 | * @param array $recentArray - an array of recently viewed or processed items, for in place modification |
| 419 | * |
| 420 | * @return array |
| 421 | * @access public |
| 422 | */ |
| 423 | static function recent(&$recentArray) { |
| 424 | return self::singleton()->invoke(1, $recentArray, |
| 425 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 426 | 'civicrm_recent' |
| 427 | ); |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * This hook is called when building the amount structure for a Contribution or Event Page |
| 432 | * |
| 433 | * @param int $pageType - is this a contribution or event page |
| 434 | * @param object $form - reference to the form object |
| 435 | * @param array $amount - the amount structure to be displayed |
| 436 | * |
| 437 | * @return null |
| 438 | * @access public |
| 439 | */ |
| 440 | static function buildAmount($pageType, &$form, &$amount) { |
| 441 | return self::singleton()->invoke(3, $pageType, $form, $amount, self::$_nullObject, |
| 442 | self::$_nullObject, 'civicrm_buildAmount'); |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * This hook is called when building the state list for a particular country. |
| 447 | * |
| 448 | * @param array $countryID - the country id whose states are being selected. |
| 449 | * |
| 450 | * @return null |
| 451 | * @access public |
| 452 | */ |
| 453 | static function buildStateProvinceForCountry($countryID, &$states) { |
| 454 | return self::singleton()->invoke(2, $countryID, $states, |
| 455 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 456 | 'civicrm_buildStateProvinceForCountry' |
| 457 | ); |
| 458 | } |
| 459 | |
| 460 | /** |
| 461 | * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c |
| 462 | * |
| 463 | * @param array $tabs - the array of tabs that will be displayed |
| 464 | * @param int $contactID - the contactID for whom the dashboard is being rendered |
| 465 | * |
| 466 | * @return null |
| 467 | * @access public |
| 468 | */ |
| 469 | static function tabs(&$tabs, $contactID) { |
| 470 | return self::singleton()->invoke(2, $tabs, $contactID, |
| 471 | self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabs' |
| 472 | ); |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * This hook is called when rendering the tabs |
| 477 | * used for events and potentially contribution pages, etc |
| 478 | * @param string $tabset - name of the screen or visual element |
| 479 | * @param array $tabs - the array of tabs that will be displayed |
| 480 | * @param array $context - extra data about the screen or context in which the tab is used |
| 481 | * |
| 482 | * @return null |
| 483 | * @access public |
| 484 | */ |
| 485 | static function tabset($tabsetName, &$tabs, $context) { |
| 486 | return self::singleton()->invoke(3, $tabsetName, $tabs, |
| 487 | $context, self::$_nullObject, self::$_nullObject, 'civicrm_tabset' |
| 488 | ); |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * This hook is called when sending an email / printing labels |
| 493 | * |
| 494 | * @param array $tokens - the list of tokens that can be used for the contact |
| 495 | * |
| 496 | * @return null |
| 497 | * @access public |
| 498 | */ |
| 499 | static function tokens(&$tokens) { |
| 500 | return self::singleton()->invoke(1, $tokens, |
| 501 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tokens' |
| 502 | ); |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * This hook is called when sending an email / printing labels to get the values for all the |
| 507 | * tokens returned by the 'tokens' hook |
| 508 | * |
| 509 | * @param array $details - the array to store the token values indexed by contactIDs (unless it a single) |
| 510 | * @param array $contactIDs - an array of contactIDs |
| 511 | * @param int $jobID - the jobID if this is associated with a CiviMail mailing |
| 512 | * @param array $tokens - the list of tokens associated with the content |
| 513 | * @param string $className - the top level className from where the hook is invoked |
| 514 | * |
| 515 | * @return null |
| 516 | * @access public |
| 517 | */ |
| 518 | static function tokenValues(&$details, |
| 519 | $contactIDs, |
| 520 | $jobID = NULL, |
| 521 | $tokens = array(), |
| 522 | $className = NULL |
| 523 | ) { |
| 524 | return self::singleton()->invoke(5, $details, $contactIDs, $jobID, $tokens, $className, 'civicrm_tokenValues'); |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables |
| 529 | * in a template |
| 530 | * |
| 531 | * @param object $page - the page that will be rendered |
| 532 | * |
| 533 | * @return null |
| 534 | * @access public |
| 535 | */ |
| 536 | static function pageRun(&$page) { |
| 537 | return self::singleton()->invoke(1, $page, |
| 538 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 539 | 'civicrm_pageRun' |
| 540 | ); |
| 541 | } |
| 542 | |
| 543 | /** |
| 544 | * This hook is called after a copy of an object has been made. The current objects are |
| 545 | * Event, Contribution Page and UFGroup |
| 546 | * |
| 547 | * @param string $objectName - name of the object |
| 548 | * @param object $object - reference to the copy |
| 549 | * |
| 550 | * @return null |
| 551 | * @access public |
| 552 | */ |
| 553 | static function copy($objectName, &$object) { |
| 554 | return self::singleton()->invoke(2, $objectName, $object, |
| 555 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 556 | 'civicrm_copy' |
| 557 | ); |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * This hook is called when a contact unsubscribes from a mailing. It allows modules |
| 562 | * to override what the contacts are removed from. |
| 563 | * |
| 564 | * @param int $mailing_id - the id of the mailing to unsub from |
| 565 | * @param int $contact_id - the id of the contact who is unsubscribing |
| 566 | * @param array / int $groups - array of groups the contact will be removed from |
| 567 | **/ |
| 568 | static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) { |
| 569 | return self::singleton()->invoke(5, $op, $mailingId, $contactId, $groups, $baseGroups, 'civicrm_unsubscribeGroups'); |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox, |
| 574 | * adv multiselect) |
| 575 | * |
| 576 | * @param int $customFieldID - the custom field ID |
| 577 | * @param array $options - the current set of options for that custom field. |
| 578 | * You can add/remove existing options. |
| 579 | * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important |
| 580 | * to be careful to not overwrite the array. |
| 581 | * Only add/edit/remove the specific field options you intend to affect. |
| 582 | * @param boolean $detailedFormat - if true, |
| 583 | * the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format |
| 584 | */ |
| 585 | static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE) { |
| 586 | return self::singleton()->invoke(3, $customFieldID, $options, $detailedFormat, |
| 587 | self::$_nullObject, self::$_nullObject, |
| 588 | 'civicrm_customFieldOptions' |
| 589 | ); |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * |
| 594 | * This hook is called to display the list of actions allowed after doing a search. |
| 595 | * This allows the module developer to inject additional actions or to remove existing actions. |
| 596 | * |
| 597 | * @param string $objectType - the object type for this search |
| 598 | * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported. |
| 599 | * @param array $tasks - the current set of tasks for that custom field. |
| 600 | * You can add/remove existing tasks. |
| 601 | * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class |
| 602 | * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup'). |
| 603 | * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ). |
| 604 | * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be |
| 605 | * found in CRM/$objectType/Task.php. |
| 606 | */ |
| 607 | static function searchTasks($objectType, &$tasks) { |
| 608 | return self::singleton()->invoke(2, $objectType, $tasks, |
| 609 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 610 | 'civicrm_searchTasks' |
| 611 | ); |
| 612 | } |
| 613 | |
| 614 | static function eventDiscount(&$form, &$params) { |
| 615 | return self::singleton()->invoke(2, $form, $params, |
| 616 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 617 | 'civicrm_eventDiscount' |
| 618 | ); |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * This hook is called when composing a mailing. You can include / exclude other groups as needed. |
| 623 | * |
| 624 | * @param unknown_type $form - the form object for which groups / mailings being displayed |
| 625 | * @param array $groups - the list of groups being included / excluded |
| 626 | * @param array $mailings - the list of mailings being included / excluded |
| 627 | */ |
| 628 | static function mailingGroups(&$form, &$groups, &$mailings) { |
| 629 | return self::singleton()->invoke(3, $form, $groups, $mailings, |
| 630 | self::$_nullObject, self::$_nullObject, |
| 631 | 'civicrm_mailingGroups' |
| 632 | ); |
| 633 | } |
| 634 | |
| 635 | /** |
| 636 | * This hook is called when composing the array of membershipTypes and their cost during a membership registration |
| 637 | * (new or renewal). |
| 638 | * Note the hook is called on initial page load and also reloaded after submit (PRG pattern). |
| 639 | * You can use it to alter the membership types when first loaded, or after submission |
| 640 | * (for example if you want to gather data in the form and use it to alter the fees). |
| 641 | * |
| 642 | * @param unknown_type $form - the form object that is presenting the page |
| 643 | * @param array $membershipTypes - the array of membership types and their amount |
| 644 | */ |
| 645 | static function membershipTypeValues(&$form, &$membershipTypes) { |
| 646 | return self::singleton()->invoke(2, $form, $membershipTypes, |
| 647 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 648 | 'civicrm_membershipTypeValues' |
| 649 | ); |
| 650 | } |
| 651 | |
| 652 | /** |
| 653 | * This hook is called when rendering the contact summary |
| 654 | * |
| 655 | * @param int $contactID - the contactID for whom the summary is being rendered |
| 656 | * @param int $contentPlacement - (output parameter) where should the hook content be displayed relative to |
| 657 | * the existing content |
| 658 | * |
| 659 | * @return string the html snippet to include in the contact summary |
| 660 | * @access public |
| 661 | */ |
| 662 | static function summary($contactID, &$content, &$contentPlacement = self::SUMMARY_BELOW) { |
| 663 | return self::singleton()->invoke(3, $contactID, $content, $contentPlacement, |
| 664 | self::$_nullObject, self::$_nullObject, |
| 665 | 'civicrm_summary' |
| 666 | ); |
| 667 | } |
| 668 | |
| 669 | /** |
| 670 | * Use this hook to populate the list of contacts returned by Contact Reference custom fields. |
| 671 | * By default, Contact Reference fields will search on and return all CiviCRM contacts. |
| 672 | * If you want to limit the contacts returned to a specific group, or some other criteria |
| 673 | * - you can override that behavior by providing a SQL query that returns some subset of your contacts. |
| 674 | * The hook is called when the query is executed to get the list of contacts to display. |
| 675 | * |
| 676 | * @param unknown_type $query - - the query that will be executed (input and output parameter); |
| 677 | * It's important to realize that the ACL clause is built prior to this hook being fired, |
| 678 | * so your query will ignore any ACL rules that may be defined. |
| 679 | * Your query must return two columns: |
| 680 | * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data') |
| 681 | * the contact IDs |
| 682 | * @param string $name - the name string to execute the query against (this is the value being typed in by the user) |
| 683 | * @param string $context - the context in which this ajax call is being made (for example: 'customfield', 'caseview') |
| 684 | * @param int $id - the id of the object for which the call is being made. |
| 685 | * For custom fields, it will be the custom field id |
| 686 | */ |
| 687 | static function contactListQuery(&$query, $name, $context, $id) { |
| 688 | return self::singleton()->invoke(4, $query, $name, $context, $id, |
| 689 | self::$_nullObject, |
| 690 | 'civicrm_contactListQuery' |
| 691 | ); |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * Hook definition for altering payment parameters before talking to a payment processor back end. |
| 696 | * |
| 697 | * Definition will look like this: |
| 698 | * |
| 699 | * function hook_civicrm_alterPaymentProcessorParams($paymentObj, |
| 700 | * &$rawParams, &$cookedParams); |
| 701 | * |
| 702 | * @param string $paymentObj |
| 703 | * instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy') |
| 704 | * @param array &$rawParams |
| 705 | * array of params as passed to to the processor |
| 706 | * @params array &$cookedParams |
| 707 | * params after the processor code has translated them into its own key/value pairs |
| 708 | * |
| 709 | * @return void |
| 710 | */ |
| 711 | static function alterPaymentProcessorParams($paymentObj, |
| 712 | &$rawParams, |
| 713 | &$cookedParams |
| 714 | ) { |
| 715 | return self::singleton()->invoke(3, $paymentObj, $rawParams, $cookedParams, |
| 716 | self::$_nullObject, self::$_nullObject, |
| 717 | 'civicrm_alterPaymentProcessorParams' |
| 718 | ); |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * This hook is called when an email is about to be sent by CiviCRM. |
| 723 | * |
| 724 | * @param array $params - array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html, |
| 725 | * returnPath, replyTo, headers, attachments (array) |
| 726 | * @param string $context - the context in which the hook is being invoked, eg 'civimail' |
| 727 | */ |
| 728 | static function alterMailParams(&$params, $context = NULL) { |
| 729 | return self::singleton()->invoke(2, $params, $context, |
| 730 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 731 | 'civicrm_alterMailParams' |
| 732 | ); |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * This hook is called when rendering the Manage Case screen |
| 737 | * |
| 738 | * @param int $caseID - the case ID |
| 739 | * |
| 740 | * @return array of data to be displayed, where the key is a unique id to be used for styling (div id's) |
| 741 | * and the value is an array with keys 'label' and 'value' specifying label/value pairs |
| 742 | * @access public |
| 743 | */ |
| 744 | static function caseSummary($caseID) { |
| 745 | return self::singleton()->invoke(1, $caseID, |
| 746 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 747 | 'civicrm_caseSummary' |
| 748 | ); |
| 749 | } |
| 750 | |
| 751 | /** |
| 752 | * This hook is called when locating CiviCase types. |
| 753 | * |
| 754 | * @param array $caseTypes |
| 755 | * @return void |
| 756 | */ |
| 757 | static function caseTypes(&$caseTypes) { |
| 758 | return self::singleton()->invoke(1, $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes'); |
| 759 | } |
| 760 | |
| 761 | /** |
| 762 | * This hook is called soon after the CRM_Core_Config object has ben initialized. |
| 763 | * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically. |
| 764 | |
| 765 | * @param array $config - the config object |
| 766 | */ |
| 767 | static function config(&$config) { |
| 768 | return self::singleton()->invoke(1, $config, |
| 769 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 770 | 'civicrm_config' |
| 771 | ); |
| 772 | } |
| 773 | |
| 774 | static function enableDisable($recordBAO, $recordID, $isActive) { |
| 775 | return self::singleton()->invoke(3, $recordBAO, $recordID, $isActive, |
| 776 | self::$_nullObject, self::$_nullObject, |
| 777 | 'civicrm_enableDisable' |
| 778 | ); |
| 779 | } |
| 780 | |
| 781 | /** |
| 782 | * This hooks allows to change option values |
| 783 | * |
| 784 | * @param $options associated array of option values / id |
| 785 | * @param $name option group name |
| 786 | * |
| 787 | * @access public |
| 788 | */ |
| 789 | static function optionValues(&$options, $name) { |
| 790 | return self::singleton()->invoke(2, $options, $name, |
| 791 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 792 | 'civicrm_optionValues' |
| 793 | ); |
| 794 | } |
| 795 | |
| 796 | /** |
| 797 | * This hook allows modification of the navigation menu. |
| 798 | * |
| 799 | * @param $params associated array of navigation menu entry to Modify/Add |
| 800 | * @access public |
| 801 | */ |
| 802 | static function navigationMenu(&$params) { |
| 803 | return self::singleton()->invoke(1, $params, |
| 804 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 805 | 'civicrm_navigationMenu' |
| 806 | ); |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * This hook allows modification of the data used to perform merging of duplicates. |
| 811 | * |
| 812 | * @param string $type the type of data being passed (cidRefs|eidRefs|relTables|sqls) |
| 813 | * @param array $data the data, as described in $type |
| 814 | * @param int $mainId contact_id of the contact that survives the merge |
| 815 | * @param int $otherId contact_id of the contact that will be absorbed and deleted |
| 816 | * @param array $tables when $type is "sqls", an array of tables as it may have been handed to the calling function |
| 817 | * |
| 818 | * @access public |
| 819 | */ |
| 820 | static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) { |
| 821 | return self::singleton()->invoke(5, $type, $data, $mainId, $otherId, $tables, 'civicrm_merge'); |
| 822 | } |
| 823 | |
| 824 | /** |
| 825 | * This hook provides a way to override the default privacy behavior for notes. |
| 826 | * |
| 827 | * @param array $note (reference) Associative array of values for this note |
| 828 | * |
| 829 | * @access public |
| 830 | */ |
| 831 | static function notePrivacy(&$noteValues) { |
| 832 | return self::singleton()->invoke(1, $noteValues, |
| 833 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 834 | 'civicrm_notePrivacy' |
| 835 | ); |
| 836 | } |
| 837 | |
| 838 | /** |
| 839 | * This hook is called before record is exported as CSV |
| 840 | * |
| 841 | * @param string $exportTempTable - name of the temporary export table used during export |
| 842 | * @param array $headerRows - header rows for output |
| 843 | * @param array $sqlColumns - SQL columns |
| 844 | * @param int $exportMode - export mode ( contact, contribution, etc...) |
| 845 | * |
| 846 | * @return void |
| 847 | * @access public |
| 848 | */ |
| 849 | static function export(&$exportTempTable, &$headerRows, &$sqlColumns, &$exportMode) { |
| 850 | return self::singleton()->invoke(4, $exportTempTable, $headerRows, $sqlColumns, $exportMode, |
| 851 | self::$_nullObject, |
| 852 | 'civicrm_export' |
| 853 | ); |
| 854 | } |
| 855 | |
| 856 | /** |
| 857 | * This hook allows modification of the queries constructed from dupe rules. |
| 858 | * |
| 859 | * @param string $obj object of rulegroup class |
| 860 | * @param string $type type of queries e.g table / threshold |
| 861 | * @param array $query set of queries |
| 862 | * |
| 863 | * @access public |
| 864 | */ |
| 865 | static function dupeQuery($obj, $type, &$query) { |
| 866 | return self::singleton()->invoke(3, $obj, $type, $query, |
| 867 | self::$_nullObject, self::$_nullObject, |
| 868 | 'civicrm_dupeQuery' |
| 869 | ); |
| 870 | } |
| 871 | |
| 872 | /** |
| 873 | * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php |
| 874 | * |
| 875 | * @param string $type type of mail processed: 'activity' OR 'mailing' |
| 876 | * @param array &$params the params that were sent to the CiviCRM API function |
| 877 | * @param object $mail the mail object which is an ezcMail class |
| 878 | * @param array &$result the result returned by the api call |
| 879 | * @param string $action (optional ) the requested action to be performed if the types was 'mailing' |
| 880 | * |
| 881 | * @access public |
| 882 | */ |
| 883 | static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) { |
| 884 | return self::singleton()->invoke(5, $type, $params, $mail, $result, $action, 'civicrm_emailProcessor'); |
| 885 | } |
| 886 | |
| 887 | /** |
| 888 | * This hook is called after a row has been processed and the |
| 889 | * record (and associated records imported |
| 890 | * |
| 891 | * @param string $object - object being imported (for now Contact only, later Contribution, Activity, |
| 892 | * Participant and Member) |
| 893 | * @param string $usage - hook usage/location (for now process only, later mapping and others) |
| 894 | * @param string $objectRef - import record object |
| 895 | * @param array $params - array with various key values: currently |
| 896 | * contactID - contact id |
| 897 | * importID - row id in temp table |
| 898 | * importTempTable - name of tempTable |
| 899 | * fieldHeaders - field headers |
| 900 | * fields - import fields |
| 901 | * |
| 902 | * @return void |
| 903 | * @access public |
| 904 | */ |
| 905 | static function import($object, $usage, &$objectRef, &$params) { |
| 906 | return self::singleton()->invoke(4, $object, $usage, $objectRef, $params, |
| 907 | self::$_nullObject, |
| 908 | 'civicrm_import' |
| 909 | ); |
| 910 | } |
| 911 | |
| 912 | /** |
| 913 | * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission() |
| 914 | * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php). |
| 915 | * |
| 916 | * @param string $entity the API entity (like contact) |
| 917 | * @param string $action the API action (like get) |
| 918 | * @param array &$params the API parameters |
| 919 | * @param array &$permisisons the associative permissions array (probably to be altered by this hook) |
| 920 | */ |
| 921 | static function alterAPIPermissions($entity, $action, &$params, &$permissions) { |
| 922 | return self::singleton()->invoke(4, $entity, $action, $params, $permissions, |
| 923 | self::$_nullObject, |
| 924 | 'civicrm_alterAPIPermissions' |
| 925 | ); |
| 926 | } |
| 927 | |
| 928 | static function postSave(&$dao) { |
| 929 | $hookName = 'civicrm_postSave_' . $dao->getTableName(); |
| 930 | return self::singleton()->invoke(1, $dao, |
| 931 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 932 | $hookName |
| 933 | ); |
| 934 | } |
| 935 | |
| 936 | /** |
| 937 | * This hook allows user to customize context menu Actions on contact summary page. |
| 938 | * |
| 939 | * @param array $actions Array of all Actions in contextmenu. |
| 940 | * @param int $contactID ContactID for the summary page |
| 941 | */ |
| 942 | static function summaryActions(&$actions, $contactID = NULL) { |
| 943 | return self::singleton()->invoke(2, $actions, $contactID, |
| 944 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 945 | 'civicrm_summaryActions' |
| 946 | ); |
| 947 | } |
| 948 | |
| 949 | /** |
| 950 | * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go. |
| 951 | * This enables us hook implementors to modify both the headers and the rows |
| 952 | * |
| 953 | * The BIGGEST drawback with this hook is that you may need to modify the result template to include your |
| 954 | * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl |
| 955 | * |
| 956 | * However, if you use the same number of columns, you can overwrite the existing columns with the values that |
| 957 | * you want displayed. This is a hackish, but avoids template modification. |
| 958 | * |
| 959 | * @param string $objectName the component name that we are doing the search |
| 960 | * activity, campaign, case, contact, contribution, event, grant, membership, and pledge |
| 961 | * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order ) |
| 962 | * @param array &$rows the list of values, an associate array with fields that are displayed for that component |
| 963 | * @param array &$seletor the selector object. Allows you access to the context of the search |
| 964 | * |
| 965 | * @return void modify the header and values object to pass the data u need |
| 966 | */ |
| 967 | static function searchColumns($objectName, &$headers, &$rows, &$selector) { |
| 968 | return self::singleton()->invoke(4, $objectName, $headers, $rows, $selector, |
| 969 | self::$_nullObject, |
| 970 | 'civicrm_searchColumns' |
| 971 | ); |
| 972 | } |
| 973 | |
| 974 | /** |
| 975 | * This hook is called when uf groups are being built for a module. |
| 976 | * |
| 977 | * @param string $moduleName module name. |
| 978 | * @param array $ufGroups array of ufgroups for a module. |
| 979 | * |
| 980 | * @return null |
| 981 | * @access public |
| 982 | */ |
| 983 | static function buildUFGroupsForModule($moduleName, &$ufGroups) { |
| 984 | return self::singleton()->invoke(2, $moduleName, $ufGroups, |
| 985 | self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 986 | 'civicrm_buildUFGroupsForModule' |
| 987 | ); |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * This hook is called when we are determining the contactID for a specific |
| 992 | * email address |
| 993 | * |
| 994 | * @param string $email the email address |
| 995 | * @param int $contactID the contactID that matches this email address, IF it exists |
| 996 | * @param array $result (reference) has two fields |
| 997 | * contactID - the new (or same) contactID |
| 998 | * action - 3 possible values: |
| 999 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record |
| 1000 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID |
| 1001 | * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address |
| 1002 | * |
| 1003 | * @return null |
| 1004 | * @access public |
| 1005 | */ |
| 1006 | static function emailProcessorContact($email, $contactID, &$result) { |
| 1007 | return self::singleton()->invoke(3, $email, $contactID, $result, |
| 1008 | self::$_nullObject, self::$_nullObject, |
| 1009 | 'civicrm_emailProcessorContact' |
| 1010 | ); |
| 1011 | } |
| 1012 | |
| 1013 | /** |
| 1014 | * Hook definition for altering the generation of Mailing Labels |
| 1015 | * |
| 1016 | * @param array $args an array of the args in the order defined for the tcpdf multiCell api call |
| 1017 | * with the variable names below converted into string keys (ie $w become 'w' |
| 1018 | * as the first key for $args) |
| 1019 | * float $w Width of cells. If 0, they extend up to the right margin of the page. |
| 1020 | * float $h Cell minimum height. The cell extends automatically if needed. |
| 1021 | * string $txt String to print |
| 1022 | * mixed $border Indicates if borders must be drawn around the cell block. The value can |
| 1023 | * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or |
| 1024 | * a string containing some or all of the following characters (in any order): |
| 1025 | * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> |
| 1026 | * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string: |
| 1027 | * left align</li><li>C: center</li><li>R: right align</li><li>J: justification |
| 1028 | * (default value when $ishtml=false)</li></ul> |
| 1029 | * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0. |
| 1030 | * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0: |
| 1031 | * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul> |
| 1032 | * float $x x position in user units |
| 1033 | * float $y y position in user units |
| 1034 | * boolean $reseth if true reset the last cell height (default true). |
| 1035 | * int $stretch stretch carachter mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if |
| 1036 | * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if |
| 1037 | * necessary</li><li>4 = forced character spacing</li></ul> |
| 1038 | * boolean $ishtml set to true if $txt is HTML content (default = false). |
| 1039 | * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width. |
| 1040 | * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page, |
| 1041 | * or 0 for disable this feature. This feature works only when $ishtml=false. |
| 1042 | * |
| 1043 | */ |
| 1044 | static function alterMailingLabelParams(&$args) { |
| 1045 | return self::singleton()->invoke(1, $args, |
| 1046 | self::$_nullObject, self::$_nullObject, |
| 1047 | self::$_nullObject, self::$_nullObject, |
| 1048 | 'civicrm_alterMailingLabelParams' |
| 1049 | ); |
| 1050 | } |
| 1051 | |
| 1052 | /** |
| 1053 | * This hooks allows alteration of generated page content |
| 1054 | * |
| 1055 | * @param $content previously generated content |
| 1056 | * @param $context context of content - page or form |
| 1057 | * @param $tplName the file name of the tpl |
| 1058 | * @param $object a reference to the page or form object |
| 1059 | * |
| 1060 | * @access public |
| 1061 | */ |
| 1062 | static function alterContent(&$content, $context, $tplName, &$object) { |
| 1063 | return self::singleton()->invoke(4, $content, $context, $tplName, $object, |
| 1064 | self::$_nullObject, |
| 1065 | 'civicrm_alterContent' |
| 1066 | ); |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * This hooks allows alteration of the tpl file used to generate content. It differs from the |
| 1071 | * altercontent hook as the content has already been rendered through the tpl at that point |
| 1072 | * |
| 1073 | * @param $formName previously generated content |
| 1074 | * @param $form reference to the form object |
| 1075 | * @param $context context of content - page or form |
| 1076 | * @param $tplName reference the file name of the tpl |
| 1077 | * |
| 1078 | * @access public |
| 1079 | */ |
| 1080 | static function alterTemplateFile($formName, &$form, $context, &$tplName) { |
| 1081 | return self::singleton()->invoke(4, $formName, $form, $context, $tplName, |
| 1082 | self::$_nullObject, |
| 1083 | 'civicrm_alterTemplateFile' |
| 1084 | ); |
| 1085 | } |
| 1086 | /** |
| 1087 | * This hook collects the trigger definition from all components |
| 1088 | * |
| 1089 | * @param $triggerInfo reference to an array of trigger information |
| 1090 | * each element has 4 fields: |
| 1091 | * table - array of tableName |
| 1092 | * when - BEFORE or AFTER |
| 1093 | * event - array of eventName - INSERT OR UPDATE OR DELETE |
| 1094 | * sql - array of statements optionally terminated with a ; |
| 1095 | * a statement can use the tokes {tableName} and {eventName} |
| 1096 | * to do token replacement with the table / event. This allows |
| 1097 | * templatizing logging and other hooks |
| 1098 | * @param string $tableName (optional) the name of the table that we are interested in only |
| 1099 | */ |
| 1100 | static function triggerInfo(&$info, $tableName = NULL) { |
| 1101 | return self::singleton()->invoke(2, $info, $tableName, |
| 1102 | self::$_nullObject, self::$_nullObject, |
| 1103 | self::$_nullObject, |
| 1104 | 'civicrm_triggerInfo' |
| 1105 | ); |
| 1106 | } |
| 1107 | |
| 1108 | /** |
| 1109 | * This hook is called when a module-extension is installed. |
| 1110 | * Each module will receive hook_civicrm_install during its own installation (but not during the |
| 1111 | * installation of unrelated modules). |
| 1112 | */ |
| 1113 | static function install() { |
| 1114 | return self::singleton()->invoke(0, self::$_nullObject, |
| 1115 | self::$_nullObject, self::$_nullObject, |
| 1116 | self::$_nullObject, self::$_nullObject, |
| 1117 | 'civicrm_install' |
| 1118 | ); |
| 1119 | } |
| 1120 | |
| 1121 | /** |
| 1122 | * This hook is called when a module-extension is uninstalled. |
| 1123 | * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the |
| 1124 | * uninstallation of unrelated modules). |
| 1125 | */ |
| 1126 | static function uninstall() { |
| 1127 | return self::singleton()->invoke(0, self::$_nullObject, |
| 1128 | self::$_nullObject, self::$_nullObject, |
| 1129 | self::$_nullObject, self::$_nullObject, |
| 1130 | 'civicrm_uninstall' |
| 1131 | ); |
| 1132 | } |
| 1133 | |
| 1134 | /** |
| 1135 | * This hook is called when a module-extension is re-enabled. |
| 1136 | * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the |
| 1137 | * re-enablement of unrelated modules). |
| 1138 | */ |
| 1139 | static function enable() { |
| 1140 | return self::singleton()->invoke(0, self::$_nullObject, |
| 1141 | self::$_nullObject, self::$_nullObject, |
| 1142 | self::$_nullObject, self::$_nullObject, |
| 1143 | 'civicrm_enable' |
| 1144 | ); |
| 1145 | } |
| 1146 | |
| 1147 | /** |
| 1148 | * This hook is called when a module-extension is disabled. |
| 1149 | * Each module will receive hook_civicrm_disable during its own disablement (but not during the |
| 1150 | * disablement of unrelated modules). |
| 1151 | */ |
| 1152 | static function disable() { |
| 1153 | return self::singleton()->invoke(0, self::$_nullObject, |
| 1154 | self::$_nullObject, self::$_nullObject, |
| 1155 | self::$_nullObject, self::$_nullObject, |
| 1156 | 'civicrm_disable' |
| 1157 | ); |
| 1158 | } |
| 1159 | |
| 1160 | static function alterReportVar($varType, &$var, &$object) { |
| 1161 | return self::singleton()->invoke(3, $varType, $var, $object, |
| 1162 | self::$_nullObject, |
| 1163 | self::$_nullObject, |
| 1164 | 'civicrm_alterReportVar' |
| 1165 | ); |
| 1166 | } |
| 1167 | |
| 1168 | /** |
| 1169 | * This hook is called to drive database upgrades for extension-modules. |
| 1170 | * |
| 1171 | * @param string $op the type of operation being performed; 'check' or 'enqueue' |
| 1172 | * @param string $queue (for 'enqueue') the modifiable list of pending up upgrade tasks |
| 1173 | * |
| 1174 | * @return mixed based on op. 'check' returns a array(boolean) (TRUE if upgrades are pending) |
| 1175 | * 'enqueue' returns void |
| 1176 | * @access public |
| 1177 | */ |
| 1178 | static function upgrade($op, CRM_Queue_Queue $queue = NULL) { |
| 1179 | return self::singleton()->invoke(2, $op, $queue, |
| 1180 | self::$_nullObject, self::$_nullObject, |
| 1181 | self::$_nullObject, |
| 1182 | 'civicrm_upgrade' |
| 1183 | ); |
| 1184 | } |
| 1185 | |
| 1186 | /** |
| 1187 | * This hook is called when an email has been successfully sent by CiviCRM, but not on an error. |
| 1188 | * |
| 1189 | * @param array $params - the mailing parameters array fields include: groupName, from, toName, toEmail, |
| 1190 | * subject, cc, bcc, text, html, returnPath, replyTo, headers, attachments (array) |
| 1191 | */ |
| 1192 | static function postEmailSend(&$params) { |
| 1193 | return self::singleton()->invoke(1, $params, |
| 1194 | self::$_nullObject, self::$_nullObject, |
| 1195 | self::$_nullObject, self::$_nullObject, |
| 1196 | 'civicrm_postEmailSend' |
| 1197 | ); |
| 1198 | } |
| 1199 | |
| 1200 | /** |
| 1201 | * This hook is called when Settings specifications are loaded |
| 1202 | * |
| 1203 | * @param array $settingsFolders - list of paths from which to derive metadata |
| 1204 | */ |
| 1205 | static function alterSettingsFolders(&$settingsFolders) { |
| 1206 | return self::singleton()->invoke(1, $settingsFolders, |
| 1207 | self::$_nullObject, self::$_nullObject, |
| 1208 | self::$_nullObject, self::$_nullObject, |
| 1209 | 'civicrm_alterSettingsFolders' |
| 1210 | ); |
| 1211 | } |
| 1212 | |
| 1213 | /** |
| 1214 | * This hook is called when Settings have been loaded from the xml |
| 1215 | * It is an opportunity for hooks to alter the data |
| 1216 | * |
| 1217 | * @param array $settingsMetaData - Settings Metadata |
| 1218 | * @domainID integer $domainID |
| 1219 | */ |
| 1220 | static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) { |
| 1221 | return self::singleton()->invoke(3, $settingsMetaData, |
| 1222 | $domainID, $profile, |
| 1223 | self::$_nullObject, self::$_nullObject, |
| 1224 | 'civicrm_alterSettingsMetaData' |
| 1225 | ); |
| 1226 | } |
| 1227 | |
| 1228 | /** |
| 1229 | * This hook is called before running an api call. |
| 1230 | * |
| 1231 | * @param $wrappers array of implements API_Wrapper(see CRM/Utils/API/ReloadOption.php as an example) |
| 1232 | * |
| 1233 | * @return null the return value is ignored |
| 1234 | * @access public |
| 1235 | */ |
| 1236 | static function apiWrappers(&$wrappers, $apiRequest) { |
| 1237 | return self::singleton() |
| 1238 | ->invoke(2, $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1239 | 'civicrm_apiWrappers' |
| 1240 | ); |
| 1241 | } |
| 1242 | |
| 1243 | /** |
| 1244 | * This hook is called before running pending cron jobs. |
| 1245 | * |
| 1246 | * @param CRM_Core_JobManager $jobManager |
| 1247 | * |
| 1248 | * @return null the return value is ignored |
| 1249 | * @access public |
| 1250 | */ |
| 1251 | static function cron($jobManager) { |
| 1252 | return self::singleton()->invoke(1, |
| 1253 | $jobManager, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1254 | 'civicrm_cron' |
| 1255 | ); |
| 1256 | } |
| 1257 | |
| 1258 | /** |
| 1259 | * This hook is called when loading CMS permissions; use this hook to modify |
| 1260 | * the array of system permissions for CiviCRM. |
| 1261 | * |
| 1262 | * @param Array $permissions Array of permissions. See CRM_Core_Permission::getCorePermissions() |
| 1263 | * for the format of this array. |
| 1264 | * |
| 1265 | * @return null the return value is ignored |
| 1266 | * @access public |
| 1267 | */ |
| 1268 | static function permission(&$permissions) { |
| 1269 | return self::singleton()->invoke(1, $permissions, |
| 1270 | self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1271 | 'civicrm_permission' |
| 1272 | ); |
| 1273 | } |
| 1274 | |
| 1275 | |
| 1276 | /** |
| 1277 | * This hook is called for declaring managed entities via API |
| 1278 | * |
| 1279 | * @param array $entities List of entity types; each entity-type is an array with keys: |
| 1280 | * - name: string, a unique short name (e.g. "ReportInstance") |
| 1281 | * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance") |
| 1282 | * - table: string, a SQL table name (e.g. "civicrm_report_instance") |
| 1283 | * |
| 1284 | * @return null the return value is ignored |
| 1285 | * @access public |
| 1286 | */ |
| 1287 | static function entityTypes(&$entityTypes) { |
| 1288 | return self::singleton()->invoke(1, $entityTypes, self::$_nullObject, self::$_nullObject, |
| 1289 | self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes' |
| 1290 | ); |
| 1291 | } |
| 1292 | |
| 1293 | /** |
| 1294 | * This hook is called while preparing a profile form |
| 1295 | * |
| 1296 | * @param string $name |
| 1297 | * @return void |
| 1298 | */ |
| 1299 | static function buildProfile($name) { |
| 1300 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1301 | self::$_nullObject, 'civicrm_buildProfile'); |
| 1302 | } |
| 1303 | |
| 1304 | /** |
| 1305 | * This hook is called while validating a profile form submission |
| 1306 | * |
| 1307 | * @param string $name |
| 1308 | * @return void |
| 1309 | */ |
| 1310 | static function validateProfile($name) { |
| 1311 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1312 | self::$_nullObject, 'civicrm_validateProfile'); |
| 1313 | } |
| 1314 | |
| 1315 | /** |
| 1316 | * This hook is called processing a valid profile form submission |
| 1317 | * |
| 1318 | * @param string $name |
| 1319 | * @return void |
| 1320 | */ |
| 1321 | static function processProfile($name) { |
| 1322 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1323 | self::$_nullObject, 'civicrm_processProfile'); |
| 1324 | } |
| 1325 | |
| 1326 | /** |
| 1327 | * This hook is called while preparing a read-only profile screen |
| 1328 | * |
| 1329 | * @param string $name |
| 1330 | * @return void |
| 1331 | */ |
| 1332 | static function viewProfile($name) { |
| 1333 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1334 | self::$_nullObject, 'civicrm_viewProfile'); |
| 1335 | } |
| 1336 | |
| 1337 | /** |
| 1338 | * This hook is called while preparing a list of contacts (based on a profile) |
| 1339 | * |
| 1340 | * @param string $name |
| 1341 | * @return void |
| 1342 | */ |
| 1343 | static function searchProfile($name) { |
| 1344 | return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, |
| 1345 | self::$_nullObject, 'civicrm_searchProfile'); |
| 1346 | } |
| 1347 | |
| 1348 | /** |
| 1349 | * This hook is called before encoding data in barcode |
| 1350 | * |
| 1351 | * @param array $data associated array of values available for encoding |
| 1352 | * @param string $type type of barcode, classic barcode or QRcode |
| 1353 | * @param string $context where this hooks is invoked. |
| 1354 | * |
| 1355 | * @return void |
| 1356 | */ |
| 1357 | static function alterBarcode( &$data, $type = 'barcode', $context = 'name_badge' ) { |
| 1358 | return self::singleton()->invoke(3, $data, $type, $context, self::$_nullObject, |
| 1359 | self::$_nullObject, 'civicrm_alterBarcode'); |
| 1360 | } |
| 1361 | |
| 1362 | /** |
| 1363 | * Modify or replace the Mailer object used for outgoing mail. |
| 1364 | * |
| 1365 | * @param object $mailer |
| 1366 | * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory) |
| 1367 | * @param string $driver |
| 1368 | * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool") |
| 1369 | * @param array $params |
| 1370 | * The default mailer config options |
| 1371 | * @see Mail::factory |
| 1372 | */ |
| 1373 | static function alterMail(&$mailer, $driver, $params) { |
| 1374 | return self::singleton() |
| 1375 | ->invoke(3, $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer'); |
| 1376 | } |
| 1377 | |
| 1378 | /** |
| 1379 | * This hook is called while building the core search query, |
| 1380 | * so hook implementers can provide their own query objects which alters/extends core search. |
| 1381 | * |
| 1382 | * @param Array $queryObjects |
| 1383 | * @return void |
| 1384 | */ |
| 1385 | static function queryObjects(&$queryObjects, $type = 'Contact') { |
| 1386 | return self::singleton()->invoke(2, $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects'); |
| 1387 | } |
| 1388 | } |