CRM-15103 fix - Priceset for memberships on contribution-page not working
[civicrm-core.git] / CRM / Core / Session.php
index 4ca54bb0557ae9e97df6585d6ab0bd3ef1398e26..b31782dfad49bfaf0957880ce7d1978018a1dfe0 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -88,7 +88,7 @@ class CRM_Core_Session {
   /**
    * singleton function used to manage this object
    *
-   * @return object
+   * @return CRM_Core_Session
    * @static
    */
   static function &singleton() {
@@ -119,7 +119,11 @@ class CRM_Core_Session {
         }
         $config =& CRM_Core_Config::singleton();
         if ($config->userSystem->is_drupal && function_exists('drupal_session_start')) {
-          drupal_session_start();
+          // https://issues.civicrm.org/jira/browse/CRM-14356
+          if (! (isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == true)) {
+            drupal_session_start();
+          }
+          $_SESSION = array();
         }
         else {
           session_start();
@@ -496,7 +500,7 @@ class CRM_Core_Session {
     if (!isset(self::$_singleton->_session[self::$_singleton->_key]['status'])) {
       self::$_singleton->_session[self::$_singleton->_key]['status'] = array();
     }
-    if ($text) {
+    if ($text || $title) {
       if ($options['unique']) {
         foreach (self::$_singleton->_session[self::$_singleton->_key]['status'] as $msg) {
           if ($msg['text'] == $text && $msg['title'] == $title) {
@@ -541,6 +545,18 @@ class CRM_Core_Session {
     self::$_managedNames = NULL;
   }
 
+  /**
+   * Retrieve contact id of the logged in user
+   * @return integer | NULL contact ID of logged in user
+   */
+  static function getLoggedInContactID() {
+    $session = CRM_Core_Session::singleton();
+    if (!is_numeric($session->get('userID'))) {
+      return NULL;
+    }
+    return $session->get('userID');
+  }
+
   function isEmpty() {
     // check if session is empty, if so we dont cache
     // stuff that we can get away with