summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-11-11 20:16:58 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-11-11 20:16:58 +0000
commitdd9058ada40b3afd47d3cbf800b78862bc44bdb6 (patch)
treec1f0481b8b2d8431b14f7d345804e96ee76a11b8 /modules
parent8223018a0be53d105d6ee901d80a633650238851 (diff)
Added some functionality to the user helper class (to check if the user is logged in) and changed the header to use the helper class
Diffstat (limited to 'modules')
-rw-r--r--modules/user/helpers/user.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php
index 10015b83..e522f016 100644
--- a/modules/user/helpers/user.php
+++ b/modules/user/helpers/user.php
@@ -25,4 +25,19 @@
*
*/
class user {
+ /**
+ * Function to determine if the user has logged in.
+ * @param $user(optional) Defaults to null, if specified will compare against the user in the
+ * session.
+ * @returns boolean true if logged in
+ */
+ public static function is_logged_in($user=null) {
+ $session_user = Session::instance()->get("user", null);
+ $logged_in = false;
+ if (!empty($session_user)) {
+ $logged_in = !empty($user) && $session_user === $user;
+ }
+
+ return $logged_in;
+ }
} \ No newline at end of file