Permalink
Browse files

Added the fIdentity class for Identity Management

  • Loading branch information...
1 parent ecacbf5 commit fdc0364c66c90127c8d96e3f72e973f34bfc147a @ihumanable committed Feb 19, 2011
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * The fIdentity class allows for easy User management by creating a
+ * persistent, clean, identity system
+ *
+ * @see fAuthorization
+ * @see fSession
+ *
+ * @copyright Copyright (c) 2011 Matt Nowack
+ * @author Matt Nowack [mdn] <ihumanable@gmail.com>
+ * @license http://ihumanable.com/rigby/license
+ *
+ * @package Rigby
+ * @link http://ihumanable.com/rigby/
+ *
+ * @version 1.0.0b
+ */
+class fIdentity {
+
+ /**
+ * Sets a type of identity, this allows multiple Authorizable entities to coexist
+ * within an application. Modeled after the fAuthorization::setUserToken() function.
+ * @see fAuthorization::setUserToken()
+ * @see fSession::regenerateID()
+ * @param string $type The type identifier
+ * @param mixed $token An identification token
+ * @param optional boolean $persistent Flag for long term persistence of identity information, defaults to true
+ * @return nothing
+ */
+ function set($type, $token, $persistent = true) {
+ fSession::set(__CLASS__ . '::' . $type . '::token', $token);
+ fSession::regenerateID();
+ if($persistent) {
+ fSession::enablePersistence();
+ }
+ }
+
+ /**
+ * Gets a token for a given type of identity.
+ * @see fIdentity::set()
+ * @param string $type The type identifier
+ * @return mixed The stored token, if no token is available returns null
+ */
+ function get($type) {
+ return fSession::get(__CLASS__ . '::' . $type . '::token', null);
+ }
+
+ /**
+ * Destroys identity information for a given type
+ * @see fIdentity::set()
+ * @param string $type The type identifier
+ * @return nothing
+ */
+ function destroy($type) {
+ fSession::delete(__CLASS__ . '::' . $type . '::token');
+ }
+}
@@ -29,6 +29,7 @@
fRigby::registerClass('fAJAX');
fRigby::registerClass('fApplication');
fRigby::registerClass('fErrors');
+fRigby::registerClass('fIdentity');
fRigby::registerClass('fResponse');
fRigby::registerClass('fRigby');
fRigby::registerClass('fRouter');
View
@@ -1 +1,23 @@
+fRouter.url = function() {
+ var result = fRouter.base;
+ for(var i = 0; i < arguments.length; ++i) {
+ result += arguments[i] + '/';
+ }
+ return result;
+}
+fRouter.push = function() {
+ var result = fRouter.self;
+ for(var i = 0; i < arguments.length; ++i) {
+ result += arguments[i] + '/';
+ }
+ return result;
+}
+
+fRouter.pop = function(count) {
+ var parse = fRouter.self.split('/');
+ for(var i = 0; i <= count; ++i) {
+ parse.pop()
+ }
+ return parse.join('/') + '/';
+}
@@ -4,10 +4,12 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title><?php echo $this->prepare('title') ?></title>
<?php $this->place('css') ?>
- <!--[if lt IE 8]<link rel="stylesheet" href="<?php echo CSS_URL ?>/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
+ <!--[if lt IE 8]<link rel="stylesheet" href="<?php echo fRouter::getRoute('css', 'blueprint/ie.css') ?>" type="text/css" media="screen, projection"><![endif]-->
<script type="text/javascript">
- var BASE_URL = '<?php echo BASE_URL; ?>';
- var SELF_URL = '<?php echo SELF_URL; ?>';
+ var fRouter = {
+ base: '<?php echo fRouter::base() ?>',
+ self: '<?php echo fRouter::self() ?>'
+ }
</script>
<?php $this->place('js') ?>
</head>

0 comments on commit fdc0364

Please sign in to comment.