/** * Start the session and set the current User if a session is active * * Assumes that you have already performed all session-specific ini_set() and session_name() calls * */ public function __construct() { $this->config = $this->fuel('config'); @session_start(); unregisterGLOBALS(); $className = $this->className(); $user = null; if (empty($_SESSION[$className])) { $_SESSION[$className] = array(); } if ($userID = $this->get('_user_id')) { if ($this->isValidSession()) { $user = $this->fuel('users')->get($userID); } else { $this->logout(); } } if (!$user || !$user->id) { $user = $this->fuel('users')->getGuestUser(); } $this->fuel('users')->setCurrentUser($user); foreach (array('message', 'error') as $type) { if ($items = $this->get($type)) { foreach ($items as $text) { parent::$type($text); } } $this->remove($type); } $this->setTrackChanges(true); }
/** * Start the session and set the current User if a session is active * * Assumes that you have already performed all session-specific ini_set() and session_name() calls * */ public function __construct() { $this->config = $this->wire('config'); $this->init(); unregisterGLOBALS(); $className = $this->className(); $user = null; if (empty($_SESSION[$className])) { $_SESSION[$className] = array(); } if ($userID = $this->get('_user', 'id')) { if ($this->isValidSession($userID)) { $user = $this->wire('users')->get($userID); } else { $this->logout(); } } if (!$user || !$user->id) { $user = $this->wire('users')->getGuestUser(); } $this->wire('users')->setCurrentUser($user); foreach (array('message', 'error', 'warning') as $type) { $items = $this->get($type); if (is_array($items)) { foreach ($items as $item) { list($text, $flags) = $item; parent::$type($text, $flags); } } $this->remove($type); } $this->setTrackChanges(true); }