standalone: when users extension not available create fake user IDs in session
authorRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Mon, 20 Feb 2023 13:46:04 +0000 (13:46 +0000)
committerTim Otten <totten@civicrm.org>
Fri, 23 Jun 2023 20:27:44 +0000 (13:27 -0700)
CRM/Utils/System/Standalone.php

index 29677f3a444650ec2de24010962a9a7d56a7c7fc..148f53d46e5864d9b811fbf2f3c2252030549dac 100644 (file)
@@ -28,6 +28,20 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base {
     $this->missingStandaloneExtension = !class_exists(\Civi\Standalone\Security::class);
   }
 
+  /**
+   * Start a new session.
+   */
+  public function sessionStart() {
+    parent::sessionStart();
+    if ($this->missingStandaloneExtension) {
+      // Provide a fake contact and user ID, otherwise we don't get a menu.
+      $session = CRM_Core_Session::singleton();
+      $session->set('userID', 1);
+      $session->set('ufID', 1);
+    }
+  }
+
+
   /**
    * @inheritdoc
    */