4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
31 * @package CiviCRM_Hook
32 * @copyright CiviCRM LLC (c) 2004-2014
36 class CRM_Utils_Hook_Joomla
extends CRM_Utils_Hook
{
37 function invoke($numParams,
38 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
41 // ensure that we are running in a joomla context
42 // we've not yet figured out how to bootstrap joomla, so we should
43 // not execute hooks if joomla is not loaded
44 if (defined('_JEXEC')) {
45 //Invoke the Joomla plugin system to observe to civicrm events.
46 jimport('joomla.plugin.helper');
47 jimport('cms.plugin.helper');
48 JPluginHelper
::importPlugin('civicrm');
50 // get app based on cli or web
51 if (PHP_SAPI
!= 'cli') {
52 $app = JFactory
::getApplication('administrator');
55 // condition on Joomla version
56 if (version_compare(JVERSION
, '3.0', 'lt')) {
57 $app = JCli
::getInstance();
60 $app = JApplicationCli
::getInstance();
64 $result = $app->triggerEvent($fnSuffix, array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6));
66 $moduleResult = $this->commonInvoke($numParams,
67 $arg1, $arg2, $arg3, $arg4, $arg5, $arg6,
69 if (!empty($moduleResult) && is_array($moduleResult)) {
71 $result = $moduleResult;
74 if (is_array($moduleResult)) {
75 $result = array_merge($result, $moduleResult);
80 if (!empty($result)) {
81 // collapse result returned from hooks
83 $finalResult = array();
84 foreach ($result as $res) {
85 if (!is_array($res)) {
88 $finalResult = array_merge($finalResult, $res);
90 $result = $finalResult;