Merge pull request #15357 from civicrm/5.18
[civicrm-core.git] / CRM / Utils / System / DrupalBase.php
index e9061b5698ad7642ec5d7ffd02dcc48e1808bb8d..115efaebebbec9b58c00eb0b4aef02dc65fa102f 100644 (file)
@@ -40,10 +40,10 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
 
   /**
    * Does this CMS / UF support a CMS specific logging mechanism?
-   * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
    * @var bool
+   * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
    */
-  var $supports_UF_Logging = TRUE;
+  public $supports_UF_Logging = TRUE;
 
   /**
    */
@@ -266,10 +266,10 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
   public function getUserRecordUrl($contactID) {
     $uid = CRM_Core_BAO_UFMatch::getUFId($contactID);
     if (CRM_Core_Session::singleton()
-        ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([
-          'cms:administer users',
-          'cms:view user account',
-        ])
+      ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([
+        'cms:administer users',
+        'cms:view user account',
+      ])
     ) {
       return $this->url('user/' . $uid);
     };
@@ -663,4 +663,24 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
     return (!empty($language->language)) ? $language->language : $language;
   }
 
+  /**
+   * Is a front end page being accessed.
+   *
+   * Generally this would be a contribution form or other public page as opposed to a backoffice page (like contact edit).
+   *
+   * See https://github.com/civicrm/civicrm-drupal/pull/546/files
+   *
+   * @return bool
+   */
+  public function isFrontEndPage() {
+    $path = CRM_Utils_System::getUrlPath();
+
+    // Get the menu for above URL.
+    $item = CRM_Core_Menu::get($path);
+    if (!empty(CRM_Utils_Array::value('is_public', $item))) {
+      return TRUE;
+    }
+    return FALSE;
+  }
+
 }