require_once "PEAR.php";
+
+/**
+ * Class CRM_Core_Session
+ */
class CRM_Core_Session {
/**
* This constructor is invoked whenever any module requests an instance of
* the session and one is not available.
*
- * @return void
+ * @return \CRM_Core_Session
*/
function __construct() {
$this->_session = null;
}
$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();
*
* @access public
*
+ * @param int $all
+ *
* @return void
*/
function reset($all = 1) {
}
}
+ /**
+ * @param $names
+ */
static function registerAndRetrieveSessionObjects($names) {
if (!is_array($names)) {
$names = array($names);
CRM_Core_BAO_Cache::restoreSessionFromCache($names);
}
+ /**
+ * @param bool $reset
+ */
static function storeSessionObjects($reset = TRUE) {
if (empty(self::$_managedNames)) {
return;
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');
+ }
+
+ /**
+ * @return bool
+ */
function isEmpty() {
// check if session is empty, if so we dont cache
// stuff that we can get away with