Merge pull request #3293 from eileenmcnaughton/comments
[civicrm-core.git] / CRM / Utils / System / Joomla.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 * $Id$
33 *
34 */
35
36 /**
37 * Joomla specific stuff goes here
38 */
39 class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
40 /**
41 *
42 */
43 function __construct() {
44 $this->is_drupal = FALSE;
45 }
46
47 /**
48 * Function to create a user of Joomla.
49 *
50 * @param array $params associated array
51 * @param string $mail email id for cms user
52 *
53 * @return uid if user exists, false otherwise
54 *
55 * @access public
56 */
57 function createUser(&$params, $mail) {
58 $baseDir = JPATH_SITE;
59 require_once $baseDir . '/components/com_users/models/registration.php';
60
61 $userParams = JComponentHelper::getParams('com_users');
62 $model = new UsersModelRegistration();
63 $ufID = NULL;
64
65 // get the default usertype
66 $userType = $userParams->get('new_usertype');
67 if (!$userType) {
68 $userType = 2;
69 }
70
71 if (isset($params['name'])) {
72 $fullname = trim($params['name']);
73 }
74 elseif (isset($params['contactID'])) {
75 $fullname = trim(CRM_Contact_BAO_Contact::displayName($params['contactID']));
76 }
77 else {
78 $fullname = trim($params['cms_name']);
79 }
80
81 // Prepare the values for a new Joomla user.
82 $values = array();
83 $values['name'] = $fullname;
84 $values['username'] = trim($params['cms_name']);
85 $values['password1'] = $values['password2'] = $params['cms_pass'];
86 $values['email1'] = $values['email2'] = trim($params[$mail]);
87
88 $lang = JFactory::getLanguage();
89 $lang->load('com_users', $baseDir);
90
91 $register = $model->register($values);
92
93 $ufID = JUserHelper::getUserId($values['username']);
94 return $ufID;
95 }
96
97 /**
98 * Change user name in host CMS
99 *
100 * @param integer $ufID User ID in CMS
101 * @param string $ufName User name
102 */
103 function updateCMSName($ufID, $ufName) {
104 $ufID = CRM_Utils_Type::escape($ufID, 'Integer');
105 $ufName = CRM_Utils_Type::escape($ufName, 'String');
106
107 $values = array();
108 $user = &JUser::getInstance($ufID);
109
110 $values['email'] = $ufName;
111 $user->bind($values);
112
113 $user->save();
114 }
115
116 /**
117 * Check if username and email exists in the Joomla! db
118 *
119 * @params $params array array of name and mail values
120 * @params $errors array array of errors
121 * @params $emailName string field label for the 'email'
122 *
123 * @param $params
124 * @param $errors
125 * @param string $emailName
126 *
127 * @return void
128 */
129 function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
130 $config = CRM_Core_Config::singleton();
131
132 $dao = new CRM_Core_DAO();
133 $name = $dao->escape(CRM_Utils_Array::value('name', $params));
134 $email = $dao->escape(CRM_Utils_Array::value('mail', $params));
135 //don't allow the special characters and min. username length is two
136 //regex \\ to match a single backslash would become '/\\\\/'
137 $isNotValid = (bool) preg_match('/[\<|\>|\"|\'|\%|\;|\(|\)|\&|\\\\|\/]/im', $name);
138 if ($isNotValid || strlen($name) < 2) {
139 $errors['cms_name'] = ts('Your username contains invalid characters or is too short');
140 }
141
142
143 $JUserTable = &JTable::getInstance('User', 'JTable');
144
145 $db = $JUserTable->getDbo();
146 $query = $db->getQuery(TRUE);
147 $query->select('username, email');
148 $query->from($JUserTable->getTableName());
149 $query->where('(LOWER(username) = LOWER(\'' . $name . '\')) OR (LOWER(email) = LOWER(\'' . $email . '\'))');
150 $db->setQuery($query, 0, 10);
151 $users = $db->loadAssocList();
152
153 $row = array();;
154 if (count($users)) {
155 $row = $users[0];
156 }
157
158 if (!empty($row)) {
159 $dbName = CRM_Utils_Array::value('username', $row);
160 $dbEmail = CRM_Utils_Array::value('email', $row);
161 if (strtolower($dbName) == strtolower($name)) {
162 $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.',
163 array(1 => $name)
164 );
165 }
166 if (strtolower($dbEmail) == strtolower($email)) {
167 $resetUrl = str_replace('administrator/', '', $config->userFrameworkBaseURL) . 'index.php?option=com_users&view=reset';
168 $errors[$emailName] = ts('The email address %1 is already registered. <a href="%2">Have you forgotten your password?</a>',
169 array(1 => $email, 2 => $resetUrl)
170 );
171 }
172 }
173 }
174
175 /**
176 * sets the title of the page
177 *
178 * @param string $title title to set
179 * @param string $pageTitle
180 *
181 * @return void
182 * @access public
183 */
184 function setTitle($title, $pageTitle = NULL) {
185 if (!$pageTitle) {
186 $pageTitle = $title;
187 }
188
189 $template = CRM_Core_Smarty::singleton();
190 $template->assign('pageTitle', $pageTitle);
191
192 $document = JFactory::getDocument();
193 $document->setTitle($title);
194
195 return;
196 }
197
198 /**
199 * Append an additional breadcrumb tag to the existing breadcrumb
200 *
201 * @param $breadCrumbs
202 *
203 * @internal param string $title
204 * @internal param string $url
205 *
206 * @return void
207 * @access public
208 */
209 function appendBreadCrumb($breadCrumbs) {
210 $template = CRM_Core_Smarty::singleton();
211 $bc = $template->get_template_vars('breadcrumb');
212
213 if (is_array($breadCrumbs)) {
214 foreach ($breadCrumbs as $crumbs) {
215 if (stripos($crumbs['url'], 'id%%')) {
216 $args = array('cid', 'mid');
217 foreach ($args as $a) {
218 $val = CRM_Utils_Request::retrieve($a, 'Positive', CRM_Core_DAO::$_nullObject,
219 FALSE, NULL, $_GET
220 );
221 if ($val) {
222 $crumbs['url'] = str_ireplace("%%{$a}%%", $val, $crumbs['url']);
223 }
224 }
225 }
226 $bc[] = $crumbs;
227 }
228 }
229 $template->assign_by_ref('breadcrumb', $bc);
230 return;
231 }
232
233 /**
234 * Reset an additional breadcrumb tag to the existing breadcrumb
235 *
236 * @internal param string $bc the new breadcrumb to be appended
237 *
238 * @return void
239 * @access public
240 */
241 function resetBreadCrumb() {
242 return;
243 }
244
245 /**
246 * Append a string to the head of the html file
247 *
248 * @param null $string
249 *
250 * @internal param string $head the new string to be appended
251 *
252 * @return void
253 * @access public
254 */
255 static function addHTMLHead($string = NULL) {
256 if ($string) {
257 $document = JFactory::getDocument();
258 $document->addCustomTag($string);
259 }
260 }
261
262 /**
263 * Add a script file
264 *
265 * @param $url: string, absolute path to file
266 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
267 *
268 * Note: This function is not to be called directly
269 * @see CRM_Core_Region::render()
270 *
271 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
272 * @access public
273 */
274 public function addScriptUrl($url, $region) {
275 return FALSE;
276 }
277
278 /**
279 * Add an inline script
280 *
281 * @param $code: string, javascript code
282 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
283 *
284 * Note: This function is not to be called directly
285 * @see CRM_Core_Region::render()
286 *
287 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
288 * @access public
289 */
290 public function addScript($code, $region) {
291 return FALSE;
292 }
293
294 /**
295 * Add a css file
296 *
297 * @param $url: string, absolute path to file
298 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
299 *
300 * Note: This function is not to be called directly
301 * @see CRM_Core_Region::render()
302 *
303 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
304 * @access public
305 */
306 public function addStyleUrl($url, $region) {
307 if ($region == 'html-header') {
308 $document = JFactory::getDocument();
309 $document->addStyleSheet($url);
310 return TRUE;
311 }
312 return FALSE;
313 }
314
315 /**
316 * Add an inline style
317 *
318 * @param $code: string, css code
319 * @param $region string, location within the document: 'html-header', 'page-header', 'page-footer'
320 *
321 * Note: This function is not to be called directly
322 * @see CRM_Core_Region::render()
323 *
324 * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
325 * @access public
326 */
327 public function addStyle($code, $region) {
328 if ($region == 'html-header') {
329 $document = JFactory::getDocument();
330 $document->addStyleDeclaration($code);
331 return TRUE;
332 }
333 return FALSE;
334 }
335
336 /**
337 * Generate an internal CiviCRM URL
338 *
339 * @param $path string The path being linked to, such as "civicrm/add"
340 * @param $query string A query string to append to the link.
341 * @param $absolute boolean Whether to force the output to be an absolute link (beginning with http:).
342 * Useful for links that will be displayed outside the site, such as in an
343 * RSS feed.
344 * @param $fragment string A fragment identifier (named anchor) to append to the link.
345 * @param $htmlize boolean whether to convert to html eqivalant
346 * @param $frontend boolean a gross joomla hack
347 *
348 * @param bool $forceBackend
349 *
350 * @return string an HTML string containing a link to the given path.
351 * @access public
352 */
353 function url($path = NULL, $query = NULL, $absolute = TRUE,
354 $fragment = NULL, $htmlize = TRUE,
355 $frontend = FALSE, $forceBackend = FALSE
356 ) {
357 $config = CRM_Core_Config::singleton();
358 $separator = $htmlize ? '&amp;' : '&';
359 $Itemid = '';
360 $script = '';
361 $path = CRM_Utils_String::stripPathChars($path);
362
363 if ($config->userFrameworkFrontend) {
364 $script = 'index.php';
365 if (JRequest::getVar("Itemid")) {
366 $Itemid = "{$separator}Itemid=" . JRequest::getVar("Itemid");
367 }
368 }
369
370 if (isset($fragment)) {
371 $fragment = '#' . $fragment;
372 }
373
374 if (!isset($config->useFrameworkRelativeBase)) {
375 $base = parse_url($config->userFrameworkBaseURL);
376 $config->useFrameworkRelativeBase = $base['path'];
377 }
378 $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
379
380 if (!empty($query)) {
381 $url = "{$base}{$script}?option=com_civicrm{$separator}task={$path}{$Itemid}{$separator}{$query}{$fragment}";
382 }
383 else {
384 $url = "{$base}{$script}?option=com_civicrm{$separator}task={$path}{$Itemid}{$fragment}";
385 }
386
387 // gross hack for joomla, we are in the backend and want to send a frontend url
388 if ($frontend && $config->userFramework == 'Joomla') {
389 // handle both joomla v1.5 and v1.6, CRM-7939
390 $url = str_replace('/administrator/index2.php', '/index.php', $url);
391 $url = str_replace('/administrator/index.php', '/index.php', $url);
392
393 // CRM-8215
394 $url = str_replace('/administrator/', '/index.php', $url);
395 }
396 elseif ($forceBackend) {
397 if (defined('JVERSION')) {
398 $joomlaVersion = JVERSION;
399 } else {
400 $jversion = new JVersion;
401 $joomlaVersion = $jversion->getShortVersion();
402 }
403
404 if (version_compare($joomlaVersion, '1.6') >= 0) {
405 $url = str_replace('/index.php', '/administrator/index.php', $url);
406 }
407 }
408 return $url;
409 }
410
411 /**
412 * rewrite various system urls to https
413 *
414 * @return void
415 * access public
416 */
417 function mapConfigToSSL() {
418 // dont need to do anything, let CMS handle their own switch to SSL
419 return;
420 }
421
422 /**
423 * figure out the post url for the form
424 *
425 * @param $action the default action if one is pre-specified
426 *
427 * @return string the url to post the form
428 * @access public
429 */
430 function postURL($action) {
431 if (!empty($action)) {
432 return $action;
433 }
434
435 return $this->url(CRM_Utils_Array::value('task', $_GET),
436 NULL, TRUE, NULL, FALSE
437 );
438 }
439
440 /**
441 * Function to set the email address of the user
442 *
443 * @param object $user handle to the user object
444 *
445 * @return void
446 * @access public
447 */
448 function setEmail(&$user) {
449 global $database;
450 $query = "SELECT email FROM #__users WHERE id='$user->id'";
451 $database->setQuery($query);
452 $user->email = $database->loadResult();
453 }
454
455 /**
456 * Authenticate the user against the joomla db
457 *
458 * @param string $name the user name
459 * @param string $password the password for the above user name
460 * @param $loadCMSBootstrap boolean load cms bootstrap?
461 *
462 * @return mixed false if no auth
463 * array(
464 contactID, ufID, unique string ) if success
465 * @access public
466 */
467 function authenticate($name, $password, $loadCMSBootstrap = FALSE) {
468 require_once 'DB.php';
469
470 $config = CRM_Core_Config::singleton();
471 $user = NULL;
472
473 if ($loadCMSBootstrap) {
474 $bootStrapParams = array();
475 if ($name && $password) {
476 $bootStrapParams = array(
477 'name' => $name,
478 'pass' => $password,
479 );
480 }
481 CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, FALSE);
482 }
483
484 jimport('joomla.application.component.helper');
485 jimport('joomla.database.table');
486 jimport('joomla.user.helper');
487
488 $JUserTable = JTable::getInstance('User', 'JTable');
489
490 $db = $JUserTable->getDbo();
491 $query = $db->getQuery(TRUE);
492 $query->select('id, name, username, email, password');
493 $query->from($JUserTable->getTableName());
494 $query->where('(LOWER(username) = LOWER(\'' . $name . '\')) AND (block = 0)');
495 $db->setQuery($query, 0, 0);
496 $users = $db->loadObjectList();
497
498 $row = array();
499 if (count($users)) {
500 $row = $users[0];
501 }
502
503 $joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));
504 if ( !defined('JVERSION') ) {
505 require $joomlaBase . '/libraries/cms/version/version.php';
506 $jversion = new JVersion;
507 define('JVERSION', $jversion->getShortVersion());
508 }
509
510 if (!empty($row)) {
511 $dbPassword = $row->password;
512 $dbId = $row->id;
513 $dbEmail = $row->email;
514
515 if ( version_compare(JVERSION, '2.5.18', 'lt') ||
516 ( version_compare(JVERSION, '3.0', 'ge') && version_compare(JVERSION, '3.2.1', 'lt') )
517 ) {
518 // now check password
519 if (strpos($dbPassword, ':') === FALSE) {
520 if ($dbPassword != md5($password)) {
521 return FALSE;
522 }
523 }
524 else {
525 list($hash, $salt) = explode(':', $dbPassword);
526 $cryptpass = md5($password . $salt);
527 if ($hash != $cryptpass) {
528 return FALSE;
529 }
530 }
531 }
532 else {
533 if (!JUserHelper::verifyPassword($password, $dbPassword, $dbId)) return FALSE;
534
535 //include additional files required by Joomla 3.2.1+
536 if ( version_compare(JVERSION, '3.2.1', 'ge') ) {
537 require $joomlaBase . '/libraries/cms/application/helper.php';
538 require $joomlaBase . '/libraries/cms/application/cms.php';
539 require $joomlaBase . '/libraries/cms/application/administrator.php';
540 }
541 }
542
543 CRM_Core_BAO_UFMatch::synchronizeUFMatch($row, $dbId, $dbEmail, 'Joomla');
544 $contactID = CRM_Core_BAO_UFMatch::getContactId($dbId);
545 if (!$contactID) {
546 return FALSE;
547 }
548 return array($contactID, $dbId, mt_rand());
549 }
550
551 return FALSE;
552 }
553
554 /**
555 * Set a init session with user object
556 *
557 * @param array $data array with user specific data
558 *
559 * @access public
560 */
561 function setUserSession($data) {
562 list($userID, $ufID) = $data;
563 $user = new JUser( $ufID );
564 $session = JFactory::getSession();
565 $session->set('user', $user);
566
567 parent::setUserSession($data);
568 }
569
570 /**
571 * Set a message in the UF to display to a user
572 *
573 * @param string $message the message to set
574 *
575 * @access public
576 */
577 function setMessage($message) {
578 return;
579 }
580
581 /**
582 * @param $user
583 *
584 * @return bool
585 */
586 function loadUser($user) {
587 return TRUE;
588 }
589
590 function permissionDenied() {
591 CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
592 }
593
594 function logout() {
595 session_destroy();
596 header("Location:index.php");
597 }
598
599 /**
600 * Get the locale set in the hosting CMS
601 *
602 * @return string the used locale or null for none
603 */
604 function getUFLocale() {
605 if (defined('_JEXEC')) {
606 $conf = JFactory::getConfig();
607 $locale = $conf->get('language');
608 return str_replace('-', '_', $locale);
609 }
610 return NULL;
611 }
612
613 /**
614 * @return string
615 */
616 function getVersion() {
617 if (class_exists('JVersion')) {
618 $version = new JVersion;
619 return $version->getShortVersion();
620 }
621 else {
622 return 'Unknown';
623 }
624 }
625
626 /**
627 * load joomla bootstrap
628 *
629 * @param $params array with uid or name and password
630 * @param $loadUser boolean load cms user?
631 * @param bool|\throw $throwError throw error on failure?
632 * @param null $realPath
633 * @param bool $loadDefines
634 *
635 * @return bool
636 */
637 function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL, $loadDefines = TRUE) {
638 // Setup the base path related constant.
639 $joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));
640
641 // load BootStrap here if needed
642 // We are a valid Joomla entry point.
643 if ( ! defined( '_JEXEC' ) && $loadDefines ) {
644 define('_JEXEC', 1);
645 define('DS', DIRECTORY_SEPARATOR);
646 define('JPATH_BASE', $joomlaBase . '/administrator');
647 require $joomlaBase . '/administrator/includes/defines.php';
648 }
649
650 // Get the framework.
651 if (file_exists($joomlaBase . '/libraries/import.legacy.php')) {
652 require $joomlaBase . '/libraries/import.legacy.php';
653 }
654 require $joomlaBase . '/libraries/import.php';
655 require $joomlaBase . '/libraries/joomla/event/dispatcher.php';
656 require $joomlaBase . '/configuration.php';
657
658 // Files may be in different places depending on Joomla version
659 if ( !defined('JVERSION') ) {
660 require $joomlaBase . '/libraries/cms/version/version.php';
661 $jversion = new JVersion;
662 define('JVERSION', $jversion->getShortVersion());
663 }
664
665 if( version_compare(JVERSION, '3.0', 'lt') ) {
666 require $joomlaBase . '/libraries/joomla/environment/uri.php';
667 require $joomlaBase . '/libraries/joomla/application/component/helper.php';
668 }
669 else {
670 require $joomlaBase . '/libraries/cms.php';
671 require $joomlaBase . '/libraries/joomla/uri/uri.php';
672 }
673
674 jimport('joomla.application.cli');
675
676 // CRM-14281 Joomla wasn't available during bootstrap, so hook_civicrm_config never executes.
677 $config = CRM_Core_Config::singleton();
678 CRM_Utils_Hook::config($config);
679
680 return TRUE;
681 }
682
683 /**
684 * check is user logged in.
685 *
686 * @return boolean true/false.
687 */
688 public function isUserLoggedIn() {
689 $user = JFactory::getUser();
690 return ($user->guest) ? FALSE : TRUE;
691 }
692
693 /**
694 * Get currently logged in user uf id.
695 *
696 * @return int logged in user uf id.
697 */
698 public function getLoggedInUfID() {
699 $user = JFactory::getUser();
700 return ($user->guest) ? NULL : $user->id;
701 }
702
703 /**
704 * Get currently logged in user unique identifier - this tends to be the email address or user name.
705 *
706 * @return string $userID logged in user unique identifier
707 */
708 function getLoggedInUniqueIdentifier() {
709 $user = JFactory::getUser();
710 return $this->getUniqueIdentifierFromUserObject($user);
711 }
712 /**
713 * Get User ID from UserFramework system (Joomla)
714 * @param object $user object as described by the CMS
715 * @return mixed <NULL, number>
716 */
717 function getUserIDFromUserObject($user) {
718 return !empty($user->id) ? $user->id : NULL;
719 }
720
721 /**
722 * Get Unique Identifier from UserFramework system (CMS)
723 * @param object $user object as described by the User Framework
724 * @return mixed $uniqueIdentifer Unique identifier from the user Framework system
725 *
726 */
727 function getUniqueIdentifierFromUserObject($user) {
728 return ($user->guest) ? NULL : $user->email;
729 }
730
731 /**
732 * Get a list of all installed modules, including enabled and disabled ones
733 *
734 * @return array CRM_Core_Module
735 */
736 function getModules() {
737 $result = array();
738
739 $db = JFactory::getDbo();
740 $query = $db->getQuery(true);
741 $query->select('type, folder, element, enabled')
742 ->from('#__extensions')
743 ->where('type =' . $db->Quote('plugin'));
744 $plugins = $db->setQuery($query)->loadAssocList();
745 foreach ($plugins as $plugin) {
746 // question: is the folder really a critical part of the plugin's name?
747 $name = implode('.', array('joomla', $plugin['type'], $plugin['folder'], $plugin['element']));
748 $result[] = new CRM_Core_Module($name, $plugin['enabled'] ? TRUE : FALSE);
749 }
750
751 return $result;
752 }
753
754 /**
755 * Get user login URL for hosting CMS (method declared in each CMS system class)
756 *
757 * @param string $destination - if present, add destination to querystring (works for Drupal only)
758 *
759 * @return string - loginURL for the current CMS
760 * @static
761 */
762 public function getLoginURL($destination = '') {
763 $config = CRM_Core_Config::singleton();
764 $loginURL = $config->userFrameworkBaseURL;
765 $loginURL = str_replace('administrator/', '', $loginURL);
766 $loginURL .= 'index.php?option=com_users&view=login';
767 return $loginURL;
768 }
769
770 /**
771 * @param $form
772 */
773 public function getLoginDestination(&$form) {
774 return;
775 }
776
777 /**
778 * Return default Site Settings
779 *
780 * @param $dir
781 *
782 * @return array array
783 * - $url, (Joomla - non admin url)
784 * - $siteName,
785 * - $siteRoot
786 */
787 function getDefaultSiteSettings($dir){
788 $config = CRM_Core_Config::singleton();
789 $url = preg_replace(
790 '|/administrator|',
791 '',
792 $config->userFrameworkBaseURL
793 );
794 $siteRoot = preg_replace(
795 '|/media/civicrm/.*$|',
796 '',
797 $config->imageUploadDir
798 );
799 return array($url, NULL, $siteRoot);
800 }
801 }
802