4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
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
{
40 * @param int $numParams
41 * Number of parameters to pass to the hook.
43 * Parameter to be passed to the hook.
45 * Parameter to be passed to the hook.
47 * Parameter to be passed to the hook.
49 * Parameter to be passed to the hook.
51 * Parameter to be passed to the hook.
53 * Parameter to be passed to the hook.
54 * @param string $fnSuffix
55 * Function suffix, this is effectively the hook name.
60 * @param int $numParams
67 * @param string $fnSuffix
73 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
76 // ensure that we are running in a joomla context
77 // we've not yet figured out how to bootstrap joomla, so we should
78 // not execute hooks if joomla is not loaded
79 if (defined('_JEXEC')) {
80 //Invoke the Joomla plugin system to observe to civicrm events.
81 jimport('joomla.plugin.helper');
82 jimport('cms.plugin.helper');
83 JPluginHelper
::importPlugin('civicrm');
85 // get app based on cli or web
86 if (PHP_SAPI
!= 'cli') {
87 $app = JFactory
::getApplication('administrator');
90 // condition on Joomla version
91 if (version_compare(JVERSION
, '3.0', 'lt')) {
92 $app = JCli
::getInstance();
95 $app = JApplicationCli
::getInstance();
99 $result = $app->triggerEvent($fnSuffix, array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6));
101 $moduleResult = $this->commonInvoke($numParams,
102 $arg1, $arg2, $arg3, $arg4, $arg5, $arg6,
103 $fnSuffix, 'joomla');
104 if (!empty($moduleResult) && is_array($moduleResult)) {
105 if (empty($result)) {
106 $result = $moduleResult;
109 if (is_array($moduleResult)) {
110 $result = array_merge($result, $moduleResult);
115 if (!empty($result)) {
116 // collapse result returned from hooks
118 $finalResult = array();
119 foreach ($result as $res) {
120 if (!is_array($res)) {
123 $finalResult = array_merge($finalResult, $res);
125 $result = $finalResult;