Merge pull request #15144 from JKingsnorth/copying-events-contribution-pages
[civicrm-core.git] / CRM / Utils / System / DrupalBase.php
CommitLineData
9977c6f5 1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
9977c6f5 5 +--------------------------------------------------------------------+
6b83d5bd 6 | Copyright CiviCRM LLC (c) 2004-2019 |
9977c6f5 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 +--------------------------------------------------------------------+
d25dd0ee 26 */
9977c6f5 27
28/**
29 *
30 * @package CRM
6b83d5bd 31 * @copyright CiviCRM LLC (c) 2004-2019
9977c6f5 32 * $Id$
33 *
34 */
35
36/**
37 * Drupal specific stuff goes here
38 */
39abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
e0dd98a5
EM
40
41 /**
42 * Does this CMS / UF support a CMS specific logging mechanism?
e0dd98a5 43 * @var bool
6714d8d2 44 * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
e0dd98a5 45 */
6714d8d2 46 public $supports_UF_Logging = TRUE;
353ffa53 47
bb3a214a 48 /**
bb3a214a 49 */
00be9182 50 public function __construct() {
4caaa696
EM
51 /**
52 * deprecated property to check if this is a drupal install. The correct method is to have functions on the UF classes for all UF specific
53 * functions and leave the codebase oblivious to the type of CMS
54 * @deprecated
55 * @var bool
56 */
9977c6f5 57 $this->is_drupal = TRUE;
58 $this->supports_form_extensions = TRUE;
59 }
60
4ac7577d
TO
61 /**
62 * @inheritdoc
63 */
64 public function getDefaultFileStorage() {
65 $config = CRM_Core_Config::singleton();
66 $baseURL = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
67
3403e54b 68 $siteName = $this->parseDrupalSiteNameFromRequest('/files/civicrm');
4ac7577d
TO
69 if ($siteName) {
70 $filesURL = $baseURL . "sites/$siteName/files/civicrm/";
71 }
72 else {
73 $filesURL = $baseURL . "sites/default/files/civicrm/";
74 }
75
be2fb01f 76 return [
4ac7577d
TO
77 'url' => $filesURL,
78 'path' => CRM_Utils_File::baseFilePath(),
be2fb01f 79 ];
4ac7577d
TO
80 }
81
9977c6f5 82 /**
17f443df 83 * @inheritDoc
9977c6f5 84 */
9b873358 85 public function getDefaultSiteSettings($dir) {
9977c6f5 86 $config = CRM_Core_Config::singleton();
87 $siteName = $siteRoot = NULL;
be2fb01f 88 $matches = [];
9977c6f5 89 if (preg_match(
90 '|/sites/([\w\.\-\_]+)/|',
91 $config->templateCompileDir,
92 $matches
93 )) {
94 $siteName = $matches[1];
95 if ($siteName) {
96 $siteName = "/sites/$siteName/";
97 $siteNamePos = strpos($dir, $siteName);
98 if ($siteNamePos !== FALSE) {
99 $siteRoot = substr($dir, 0, $siteNamePos);
100 }
101 }
102 }
103 $url = $config->userFrameworkBaseURL;
be2fb01f 104 return [$url, $siteName, $siteRoot];
9977c6f5 105 }
42e1a97c
E
106
107 /**
fe482240 108 * Check if a resource url is within the drupal directory and format appropriately.
42e1a97c 109 *
3bdca100 110 * @param $url (reference)
42e1a97c 111 *
a6c01b45
CW
112 * @return bool
113 * TRUE for internal paths, FALSE for external. The drupal_add_js fn is able to add js more
16b10e64 114 * efficiently if it is known to be in the drupal site
42e1a97c 115 */
00be9182 116 public function formatResourceUrl(&$url) {
42e1a97c
E
117 $internal = FALSE;
118 $base = CRM_Core_Config::singleton()->resourceBase;
119 global $base_url;
dd85a1e6 120 // Strip query string
121 $q = strpos($url, '?');
122 $url_path = $q ? substr($url, 0, $q) : $url;
42e1a97c 123 // Handle absolute urls
abfa8a7d
EM
124 // compares $url (which is some unknown/untrusted value from a third-party dev) to the CMS's base url (which is independent of civi's url)
125 // to see if the url is within our drupal dir, if it is we are able to treated it as an internal url
dd85a1e6 126 if (strpos($url_path, $base_url) === 0) {
127 $file = trim(str_replace($base_url, '', $url_path), '/');
efe603b4 128 // CRM-18130: Custom CSS URL not working if aliased or rewritten
dd85a1e6 129 if (file_exists(DRUPAL_ROOT . '/' . $file)) {
efe603b4
NG
130 $url = $file;
131 $internal = TRUE;
132 }
42e1a97c 133 }
abfa8a7d 134 // Handle relative urls that are within the CiviCRM module directory
dd85a1e6 135 elseif (strpos($url_path, $base) === 0) {
42e1a97c 136 $internal = TRUE;
dd85a1e6 137 $url = $this->appendCoreDirectoryToResourceBase(dirname(drupal_get_path('module', 'civicrm')) . '/') . trim(substr($url_path, strlen($base)), '/');
42e1a97c
E
138 }
139 return $internal;
140 }
168be77d
E
141
142 /**
143 * In instance where civicrm folder has a drupal folder & a civicrm core folder @ the same level append the
144 * civicrm folder name to the url
145 * See CRM-13737 for discussion of how this allows implementers to alter the folder structure
146 * @todo - this only provides a limited amount of flexiblity - it still expects a 'civicrm' folder with a 'drupal' folder
147 * and is only flexible as to the name of the civicrm folder.
148 *
77855840
TO
149 * @param string $url
150 * Potential resource url based on standard folder assumptions.
a6c01b45
CW
151 * @return string
152 * with civicrm-core directory appended if not standard civi dir
168be77d 153 */
00be9182 154 public function appendCoreDirectoryToResourceBase($url) {
168be77d 155 global $civicrm_root;
2102546d 156 $lastDirectory = basename($civicrm_root);
22e263ad 157 if ($lastDirectory != 'civicrm') {
168be77d
E
158 return $url .= $lastDirectory . '/';
159 }
160 return $url;
161 }
72b140cf
E
162
163 /**
164 * Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)
165 *
17f443df 166 * @inheritDoc
72b140cf 167 */
3bdca100 168 public function url(
17f443df
CW
169 $path = NULL,
170 $query = NULL,
171 $absolute = FALSE,
172 $fragment = NULL,
17f443df
CW
173 $frontend = FALSE,
174 $forceBackend = FALSE
72b140cf
E
175 ) {
176 $config = CRM_Core_Config::singleton();
177 $script = 'index.php';
178
179 $path = CRM_Utils_String::stripPathChars($path);
180
181 if (isset($fragment)) {
182 $fragment = '#' . $fragment;
183 }
184
72b140cf
E
185 $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
186
c80e2dbf 187 $separator = '&';
72b140cf
E
188
189 if (!$config->cleanURL) {
190 if (isset($path)) {
191 if (isset($query)) {
192 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
193 }
194 else {
195 return $base . $script . '?q=' . $path . $fragment;
196 }
197 }
198 else {
199 if (isset($query)) {
200 return $base . $script . '?' . $query . $fragment;
201 }
202 else {
203 return $base . $fragment;
204 }
205 }
206 }
207 else {
208 if (isset($path)) {
209 if (isset($query)) {
210 return $base . $path . '?' . $query . $fragment;
211 }
212 else {
213 return $base . $path . $fragment;
214 }
215 }
216 else {
217 if (isset($query)) {
218 return $base . $script . '?' . $query . $fragment;
219 }
220 else {
221 return $base . $fragment;
222 }
223 }
224 }
225 }
32998c82
EM
226
227 /**
17f443df 228 * @inheritDoc
32998c82 229 */
00be9182 230 public function getUserIDFromUserObject($user) {
32998c82
EM
231 return !empty($user->uid) ? $user->uid : NULL;
232 }
2b617cb0
EM
233
234 /**
17f443df
CW
235 * @inheritDoc
236 */
237 public function setMessage($message) {
238 drupal_set_message($message);
239 }
240
241 /**
242 * @inheritDoc
2b617cb0 243 */
00be9182 244 public function getUniqueIdentifierFromUserObject($user) {
2b617cb0
EM
245 return empty($user->mail) ? NULL : $user->mail;
246 }
247
248 /**
17f443df 249 * @inheritDoc
2b617cb0 250 */
00be9182 251 public function getLoggedInUniqueIdentifier() {
2b617cb0
EM
252 global $user;
253 return $this->getUniqueIdentifierFromUserObject($user);
254 }
d0ffa3e4
EM
255
256 /**
17f443df 257 * @inheritDoc
d0ffa3e4 258 */
00be9182 259 public function permissionDenied() {
d0ffa3e4
EM
260 drupal_access_denied();
261 }
59f97da6
EM
262
263 /**
17f443df 264 * @inheritDoc
59f97da6 265 */
00be9182 266 public function getUserRecordUrl($contactID) {
59f97da6 267 $uid = CRM_Core_BAO_UFMatch::getUFId($contactID);
353ffa53 268 if (CRM_Core_Session::singleton()
6714d8d2
SL
269 ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([
270 'cms:administer users',
271 'cms:view user account',
272 ])
353ffa53 273 ) {
1dc24ed8 274 return $this->url('user/' . $uid);
59f97da6
EM
275 };
276 }
277
278 /**
17f443df 279 * @inheritDoc
59f97da6 280 */
00be9182 281 public function checkPermissionAddUser() {
17f443df 282 return CRM_Core_Permission::check('administer users');
59f97da6 283 }
e0dd98a5 284
e0dd98a5 285 /**
17f443df 286 * @inheritDoc
e0dd98a5 287 */
00be9182 288 public function logger($message) {
b36194a0 289 if (CRM_Core_Config::singleton()->userFrameworkLogging && function_exists('watchdog')) {
be2fb01f 290 watchdog('civicrm', '%message', ['%message' => $message], NULL, WATCHDOG_DEBUG);
e0dd98a5
EM
291 }
292 }
f091327b
CW
293
294 /**
17f443df 295 * @inheritDoc
f091327b 296 */
00be9182 297 public function clearResourceCache() {
f091327b
CW
298 _drupal_flush_css_js();
299 }
f9f361d0 300
7e9cadcf 301 /**
17f443df 302 * @inheritDoc
7e9cadcf 303 */
00be9182 304 public function flush() {
7e9cadcf
EM
305 drupal_flush_all_caches();
306 }
307
308 /**
66e42142 309 * @inheritDoc
7e9cadcf 310 */
00be9182 311 public function getModules() {
be2fb01f 312 $result = [];
7e9cadcf
EM
313 $q = db_query('SELECT name, status FROM {system} WHERE type = \'module\' AND schema_version <> -1');
314 foreach ($q as $row) {
315 $result[] = new CRM_Core_Module('drupal.' . $row->name, ($row->status == 1) ? TRUE : FALSE);
316 }
317 return $result;
318 }
319
320 /**
321 * Find any users/roles/security-principals with the given permission
322 * and replace it with one or more permissions.
323 *
5a4f6742
CW
324 * @param string $oldPerm
325 * @param array $newPerms
77855840 326 * Array, strings.
7e9cadcf
EM
327 *
328 * @return void
329 */
00be9182 330 public function replacePermission($oldPerm, $newPerms) {
7e9cadcf
EM
331 $roles = user_roles(FALSE, $oldPerm);
332 if (!empty($roles)) {
333 foreach (array_keys($roles) as $rid) {
be2fb01f 334 user_role_revoke_permissions($rid, [$oldPerm]);
7e9cadcf
EM
335 user_role_grant_permissions($rid, $newPerms);
336 }
337 }
338 }
353ffa53 339
7e9cadcf 340 /**
17f443df 341 * @inheritDoc
7e9cadcf 342 */
00be9182 343 public function languageNegotiationURL($url, $addLanguagePart = TRUE, $removeLanguagePart = FALSE) {
7e9cadcf
EM
344 if (empty($url)) {
345 return $url;
346 }
347
348 //CRM-7803 -from d7 onward.
349 $config = CRM_Core_Config::singleton();
350 if (function_exists('variable_get') &&
351 module_exists('locale') &&
352 function_exists('language_negotiation_get')
353 ) {
354 global $language;
355
356 //does user configuration allow language
357 //support from the URL (Path prefix or domain)
358 if (language_negotiation_get('language') == 'locale-url') {
359 $urlType = variable_get('locale_language_negotiation_url_part');
360
361 //url prefix
362 if ($urlType == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {
363 if (isset($language->prefix) && $language->prefix) {
364 if ($addLanguagePart) {
365 $url .= $language->prefix . '/';
366 }
367 if ($removeLanguagePart) {
368 $url = str_replace("/{$language->prefix}/", '/', $url);
369 }
370 }
371 }
372 //domain
373 if ($urlType == LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN) {
374 if (isset($language->domain) && $language->domain) {
375 if ($addLanguagePart) {
376 $url = (CRM_Utils_System::isSSL() ? 'https' : 'http') . '://' . $language->domain . base_path();
377 }
378 if ($removeLanguagePart && defined('CIVICRM_UF_BASEURL')) {
379 $url = str_replace('\\', '/', $url);
380 $parseUrl = parse_url($url);
381
382 //kinda hackish but not sure how to do it right
383 //hope http_build_url() will help at some point.
384 if (is_array($parseUrl) && !empty($parseUrl)) {
353ffa53
TO
385 $urlParts = explode('/', $url);
386 $hostKey = array_search($parseUrl['host'], $urlParts);
387 $ufUrlParts = parse_url(CIVICRM_UF_BASEURL);
7e9cadcf 388 $urlParts[$hostKey] = $ufUrlParts['host'];
353ffa53 389 $url = implode('/', $urlParts);
7e9cadcf
EM
390 }
391 }
392 }
393 }
394 }
395 }
396 return $url;
397 }
398
399 /**
17f443df 400 * @inheritDoc
7e9cadcf 401 */
00be9182 402 public function getVersion() {
7e9cadcf
EM
403 return defined('VERSION') ? VERSION : 'Unknown';
404 }
405
8caad0ce 406 /**
407 * @inheritDoc
408 */
409 public function isUserRegistrationPermitted() {
410 if (!variable_get('user_register', TRUE)) {
411 return FALSE;
412 }
413 return TRUE;
414 }
415
63df6889
HD
416 /**
417 * @inheritDoc
418 */
1a6630be 419 public function isPasswordUserGenerated() {
63df6889
HD
420 if (variable_get('user_email_verification', TRUE)) {
421 return FALSE;
422 }
423 return TRUE;
424 }
425
7e9cadcf 426 /**
17f443df 427 * @inheritDoc
7e9cadcf 428 */
00be9182 429 public function updateCategories() {
17f443df 430 // copied this from profile.module. Seems a bit inefficient, but i don't know a better way
7e9cadcf
EM
431 cache_clear_all();
432 menu_rebuild();
433 }
434
7e9cadcf 435 /**
17f443df 436 * @inheritDoc
7e9cadcf 437 */
00be9182 438 public function getUFLocale() {
7e9cadcf
EM
439 // return CiviCRM’s xx_YY locale that either matches Drupal’s Chinese locale
440 // (for CRM-6281), Drupal’s xx_YY or is retrieved based on Drupal’s xx
441 // sometimes for CLI based on order called, this might not be set and/or empty
ea9245cc 442 $language = $this->getCurrentLanguage();
7e9cadcf
EM
443
444 if (empty($language)) {
445 return NULL;
446 }
447
ea9245cc 448 if ($language == 'zh-hans') {
7e9cadcf
EM
449 return 'zh_CN';
450 }
451
ea9245cc 452 if ($language == 'zh-hant') {
7e9cadcf
EM
453 return 'zh_TW';
454 }
455
ea9245cc 456 if (preg_match('/^.._..$/', $language)) {
457 return $language;
7e9cadcf
EM
458 }
459
ea9245cc 460 return CRM_Core_I18n_PseudoConstant::longForShort(substr($language, 0, 2));
7e9cadcf 461 }
353ffa53 462
fd1f3a26
SV
463 /**
464 * @inheritDoc
465 */
466 public function setUFLocale($civicrm_language) {
467 global $language;
468
469 $langcode = substr($civicrm_language, 0, 2);
470 $languages = language_list();
471
472 if (isset($languages[$langcode])) {
473 $language = $languages[$langcode];
474
475 // Config must be re-initialized to reset the base URL
476 // otherwise links will have the wrong language prefix/domain.
477 $config = CRM_Core_Config::singleton();
478 $config->free();
479
480 return TRUE;
481 }
482
483 return FALSE;
484 }
485
7e9cadcf
EM
486 /**
487 * Perform any post login activities required by the UF -
488 * e.g. for drupal: records a watchdog message about the new session, saves the login timestamp,
489 * calls hook_user op 'login' and generates a new session.
490 *
3bdca100 491 * @param array $params
7e9cadcf
EM
492 *
493 * FIXME: Document values accepted/required by $params
7e9cadcf 494 */
be2fb01f 495 public function userLoginFinalize($params = []) {
7e9cadcf
EM
496 user_login_finalize($params);
497 }
498
499 /**
17f443df
CW
500 * @inheritDoc
501 */
502 public function getLoginDestination(&$form) {
503 $args = NULL;
504
505 $id = $form->get('id');
506 if ($id) {
507 $args .= "&id=$id";
508 }
509 else {
510 $gid = $form->get('gid');
511 if ($gid) {
512 $args .= "&gid=$gid";
513 }
514 else {
515 // Setup Personal Campaign Page link uses pageId
516 $pageId = $form->get('pageId');
517 if ($pageId) {
518 $component = $form->get('component');
519 $args .= "&pageId=$pageId&component=$component&action=add";
520 }
521 }
522 }
523
524 $destination = NULL;
525 if ($args) {
526 // append destination so user is returned to form they came from after login
527 $destination = CRM_Utils_System::currentPath() . '?reset=1' . $args;
528 }
529 return $destination;
530 }
531
532 /**
533 * Fixme: Why are we overriding the parent function? Seems inconsistent.
534 * This version supplies slightly different params to $this->url (not absolute and html encoded) but why?
ad37ac8e 535 *
536 * @param string $action
537 *
538 * @return string
7e9cadcf 539 */
00be9182 540 public function postURL($action) {
7e9cadcf
EM
541 if (!empty($action)) {
542 return $action;
543 }
544 return $this->url($_GET['q']);
545 }
96025800 546
2b0e7d03
EM
547 /**
548 * Get an array of user details for a contact, containing at minimum the user ID & name.
549 *
550 * @param int $contactID
551 *
552 * @return array
553 * CMS user details including
554 * - id
555 * - name (ie the system user name.
556 */
557 public function getUser($contactID) {
558 $userDetails = parent::getUser($contactID);
559 $user = $this->getUserObject($userDetails['id']);
560 $userDetails['name'] = $user->name;
561 $userDetails['email'] = $user->mail;
562 return $userDetails;
563 }
564
565 /**
566 * Load the user object.
567 *
568 * Note this function still works in drupal 6, 7 & 8 but is deprecated in Drupal 8.
569 *
570 * @param $userID
571 *
572 * @return object
573 */
574 public function getUserObject($userID) {
575 return user_load($userID);
576 }
577
3403e54b
TO
578 /**
579 * Parse the name of the drupal site.
580 *
581 * @param string $civicrm_root
582 *
583 * @return null|string
584 * @deprecated
585 */
586 public function parseDrupalSiteNameFromRoot($civicrm_root) {
587 $siteName = NULL;
588 if (strpos($civicrm_root,
589 DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'modules'
590 ) === FALSE
591 ) {
592 $startPos = strpos($civicrm_root,
593 DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR
594 );
595 $endPos = strpos($civicrm_root,
596 DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
597 );
598 if ($startPos && $endPos) {
599 // if component is in sites/SITENAME/modules
600 $siteName = substr($civicrm_root,
601 $startPos + 7,
602 $endPos - $startPos - 7
603 );
604 }
605 }
606 return $siteName;
607 }
608
bc854509 609 /**
4ac7577d
TO
610 * Determine if Drupal multi-site applies to the current request -- and,
611 * specifically, determine the name of the multisite folder.
bc854509 612 *
4ac7577d
TO
613 * @param string $flagFile
614 * Check if $flagFile exists inside the site dir.
bc854509 615 * @return null|string
4ac7577d
TO
616 * string, e.g. `bar.example.com` if using multisite.
617 * NULL if using the default site.
bc854509 618 */
3403e54b 619 private function parseDrupalSiteNameFromRequest($flagFile = '') {
4ac7577d
TO
620 $phpSelf = array_key_exists('PHP_SELF', $_SERVER) ? $_SERVER['PHP_SELF'] : '';
621 $httpHost = array_key_exists('HTTP_HOST', $_SERVER) ? $_SERVER['HTTP_HOST'] : '';
622 if (empty($httpHost)) {
623 $httpHost = parse_url(CIVICRM_UF_BASEURL, PHP_URL_HOST);
624 if (parse_url(CIVICRM_UF_BASEURL, PHP_URL_PORT)) {
625 $httpHost .= ':' . parse_url(CIVICRM_UF_BASEURL, PHP_URL_PORT);
626 }
627 }
628
629 $confdir = $this->cmsRootPath() . '/sites';
630
631 if (file_exists($confdir . "/sites.php")) {
632 include $confdir . "/sites.php";
633 }
634 else {
be2fb01f 635 $sites = [];
4ac7577d
TO
636 }
637
638 $uri = explode('/', $phpSelf);
639 $server = explode('.', implode('.', array_reverse(explode(':', rtrim($httpHost, '.')))));
640 for ($i = count($uri) - 1; $i > 0; $i--) {
641 for ($j = count($server); $j > 0; $j--) {
642 $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
643 if (file_exists("$confdir/$dir" . $flagFile)) {
644 \Civi::$statics[__CLASS__]['drupalSiteName'] = $dir;
645 return \Civi::$statics[__CLASS__]['drupalSiteName'];
646 }
647 // check for alias
648 if (isset($sites[$dir]) && file_exists("$confdir/{$sites[$dir]}" . $flagFile)) {
649 \Civi::$statics[__CLASS__]['drupalSiteName'] = $sites[$dir];
650 return \Civi::$statics[__CLASS__]['drupalSiteName'];
651 }
f6f958e4
TO
652 }
653 }
f6f958e4 654 }
1a6630be 655
ea9245cc 656 /**
657 * Function to return current language of Drupal
658 *
659 * @return string
660 */
661 public function getCurrentLanguage() {
662 global $language;
663 return (!empty($language->language)) ? $language->language : $language;
664 }
665
68e3bc34 666 /**
667 * Is a front end page being accessed.
668 *
669 * Generally this would be a contribution form or other public page as opposed to a backoffice page (like contact edit).
670 *
671 * See https://github.com/civicrm/civicrm-drupal/pull/546/files
672 *
673 * @return bool
674 */
675 public function isFrontEndPage() {
9d350db4 676 $path = CRM_Utils_System::getUrlPath();
68e3bc34 677
678 // Get the menu for above URL.
679 $item = CRM_Core_Menu::get($path);
680 if (!empty(CRM_Utils_Array::value('is_public', $item))) {
681 return TRUE;
682 }
683 return FALSE;
684 }
685
43d84987 686}