3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
30 * @package CiviCRM_Hook
31 * @copyright CiviCRM LLC (c) 2004-2017
33 class CRM_Utils_Hook_Joomla
extends CRM_Utils_Hook
{
37 * @param int $numParams
38 * Number of parameters to pass to the hook.
40 * Parameter to be passed to the hook.
42 * Parameter to be passed to the hook.
44 * Parameter to be passed to the hook.
46 * Parameter to be passed to the hook.
48 * Parameter to be passed to the hook.
50 * Parameter to be passed to the hook.
51 * @param string $fnSuffix
52 * Function suffix, this is effectively the hook name.
57 * @param int $numParams
64 * @param string $fnSuffix
68 public function invokeViaUF(
70 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
73 // ensure that we are running in a joomla context
74 // we've not yet figured out how to bootstrap joomla, so we should
75 // not execute hooks if joomla is not loaded
76 if (defined('_JEXEC')) {
77 //Invoke the Joomla plugin system to observe to civicrm events.
78 jimport('joomla.plugin.helper');
79 jimport('cms.plugin.helper');
80 JPluginHelper
::importPlugin('civicrm');
82 // get app based on cli or web
83 if (PHP_SAPI
!= 'cli') {
84 $app = JFactory
::getApplication('administrator');
87 // condition on Joomla version
88 if (version_compare(JVERSION
, '3.0', 'lt')) {
89 $app = JCli
::getInstance();
92 $app = JApplicationCli
::getInstance();
96 $result = $app->triggerEvent($fnSuffix, array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6));
98 $moduleResult = $this->commonInvoke($numParams,
99 $arg1, $arg2, $arg3, $arg4, $arg5, $arg6,
100 $fnSuffix, 'joomla');
101 if (!empty($moduleResult) && is_array($moduleResult)) {
102 if (empty($result)) {
103 $result = $moduleResult;
106 if (is_array($moduleResult)) {
107 $result = array_merge($result, $moduleResult);
112 if (!empty($result)) {
113 // collapse result returned from hooks
115 $finalResult = array();
116 foreach ($result as $res) {
117 if (!is_array($res)) {
120 $finalResult = array_merge($finalResult, $res);
122 $result = $finalResult;