Permalink
Browse files

some better account stuff

  • Loading branch information...
1 parent 149cd41 commit dcf7d2724df3483c265da683a4391e7ac34afb86 @fligtar committed Nov 15, 2009
View
@@ -1,6 +1,10 @@
<IfModule mod_rewrite.c>
RewriteEngine On
+ # Account functions redirect
+ # Example: /login -> account.php?action=login
+ RewriteRule ^(login|logout|account)$ account.php?action=$1 [L]
+
# Milestone redirect
# Example: /products/1/milestones/2 -> milestone.php?product=1&milestone=2&extra=
RewriteRule ^products\/([^\/]+)\/milestones\/([^\/]+)(.*)$ milestone.php?product=$1&milestone=$2&extra=$3 [L]
View
@@ -0,0 +1,37 @@
+<?php
+define('PAGE', 'account');
+
+require 'includes/init.inc.php';
+require 'includes/template.inc.php';
+
+list($Product) =
+load_models('Product');
+
+$template = new Template($Config->get('theme'));
+
+$template->render('head', array(
+ 'title' => $Config->get('site_name').' moxie',
+ 'css' => $template->cssString('global')
+ ));
+
+$template->render('header', array(
+ 'site_name' => $Config->get('site_name'),
+ ));
+
+if ($_GET['action'] == 'login') {
+ exit;
+ $template->render('login', array());
+}
+elseif ($_GET['action'] == 'logout') {
+ $_SESSION = array();
+ session_destroy();
+
+ $template->render('loggedout', array());
+}
+elseif ($_GET['action'] == 'register') {
+ $template->render('register', array());
+}
+
+$template->render('footer', array());
+
+?>
@@ -24,5 +24,7 @@
list($Config) = load_models('Config');
+session_start();
+
?>
@@ -66,6 +66,14 @@ public function getBaseURL() {
return $url;
}
+ public function getCurrentURL() {
+ $url = $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
+
+ $url .= $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
+
+ return $url;
+ }
+
public function cssString() {
$files = func_get_args();
$string = '';
@@ -89,11 +89,47 @@ a:hover {
#account-box {
float: right;
+ text-align: right;
}
#login-form {
+ background: #EEEEEE;
+ position: relative;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ z-index: 10;
+ color: #218FB1;
+ padding: 10px;
+ font-size: 1.1em;
+ -moz-box-shadow: 2px 2px 15px #333;
+ text-align: left;
+ top: 0.5em;
+ right: 5em;
display: none;
}
+#login-form dt,
+#login-form dd {
+ margin-bottom: 0.3em;
+}
+#login-form input {
+ font-size: 1.1em;
+ font-weight: bold;
+}
+#login-form .actions {
+ text-align: right;
+}
+#login-form .actions a {
+ float: left;
+ color: #666666;
+}
+#login-form .actions input {
+ background-color: #218FB1;
+ border: none;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ color: #FFFFFF;
+ font-weight: normal;
+}
#account-links {
display: inline-block;
@@ -106,6 +142,9 @@ a:hover {
#account-links li a {
color: #EEEEEE;
}
+#account-links li.separator {
+ padding: 0;
+}
#account-links li strong {
color: #FFFFFF;
}
@@ -209,7 +248,6 @@ a:hover {
#content {
padding: 20px;
- clear: both;
}
/* Elements used on multiple pages */
@@ -624,6 +662,21 @@ div.deliverable.level-0 {
margin: 0.3em 0 0.5em;
}
+
+/* Account Management */
+.body-account .logged-out {
+ text-align: center;
+ margin: 5em 0;
+}
+.body-account .logged-out h3 {
+ font-size: 2em;
+}
+.body-account .logged-out h4 {
+ font-size: 1.3em;
+ font-weight: normal;
+ margin: 1em 0;
+}
+
/* Footer */
#global-footer {
text-align: center;
@@ -11,7 +11,7 @@
</div>
<?php
-echo $this->jsString('jquery/jquery.min', 'jquery/jquery-ui.min');
+echo $this->jsString('jquery/jquery.min', 'jquery/jquery-ui.min', 'global');
// Custom JS in the page
if (!empty($vars['js'])) {
@@ -25,10 +25,6 @@
echo $vars['jsFiles'];
}
-echo '<script type="text/javascript">';
-hook('output_js');
-echo '</script>';
-
/*global $starttime;
$endtime = microtime();
$endarray = explode(" ", $endtime);
@@ -1,4 +1,4 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
@@ -7,9 +7,6 @@
<base href="<?php echo $this->getBaseURL(); ?>/" />
<?php if (!empty($vars['css'])) echo $vars['css']; ?>
<?php echo $this->cssString('smoothness/jquery-ui'); ?>
- <style type="text/css">
- <?php hook('output_css'); ?>
- </style>
</head>
-<body>
+<body class="body-<?php echo PAGE; ?>">
@@ -4,36 +4,57 @@
</div>
<div id="account-box">
+ <ul id="account-links">
+ <?php if (!empty($_SESSION['id'])): ?>
+ <li>hello, <a href="<?php echo $this->getBaseURL(); ?>/account"><strong>Justin Scott</strong></a></li>
+ <li class="separator">/</li>
+ <li><a href="<?php echo $this->getBaseURL(); ?>/logout">log out</a></li>
+ <?php else: ?>
+ <li><a href="<?php echo $this->getBaseURL(); ?>/login" onclick="global.showLoginForm(); return false;">log in</a></li>
+ <li class="separator">/</li>
+ <li><a href="<?php echo $this->getBaseURL(); ?>/register">register</a></li>
+ <?php endif; ?>
+ </ul>
+
<div id="login-form">
- <form method="post" action="">
- <label>E-mail</label>
- <input type="text" name="email" />
- <label>Password</label>
- <input type="password" name="password" />
- <input type="submit" value="Log in" />
+ <form method="post" action="<?php echo $this->getBaseURL(); ?>/login">
+ <input type="hidden" name="redirect" value="<?php echo htmlentities($this->getCurrentURL()); ?>" />
+ <dl>
+ <dt><label for="login_email">e-mail address</label></dt>
+ <dd><input type="text" name="email" id="login_email" /></dd>
+ <dt><label for="login_password">password</label></dt>
+ <dd><input type="password" name="password" id="login_password" /></dd>
+ </dl>
+
+ <div class="actions">
+ <a href="#" onclick="global.hideLoginForm(); return false;">never mind</a>
+ <?php
+ // random login button. this is important
+ $login_choices = array(
+ 'this is it!',
+ 'yes, please!',
+ 'whatever',
+ 'here we go!'
+ );
+ $this->getCurrentURL();
+ ?>
+ <input type="submit" value="<?php echo $login_choices[array_rand($login_choices)]; ?>" />
+ </div>
</form>
</div>
-
- <ul id="account-links">
- <!--<li><a href="#">Log in</a></li>
- <li><a href="#">Sign up</a></li>-->
- <li>hello, <a href="#"><strong>Justin Scott</strong></a> / <a href="#">log out</a></li>
- </ul>
</div>
</div>
<div class="page">
<div id="header">
- <?php if (PAGE != 'index'): ?>
+ <?php if (!empty($vars['product_name'])): ?>
<ul id="toolbar">
<li><a href="<?php echo $vars['product_base_url'].'/roadmap'; ?>">roadmap</a></li>
<li><a href="<?php echo $vars['product_base_url'].'/milestones'; ?>">milestones</a></li>
<li><a href="<?php echo $vars['product_base_url'].'/projects'; ?>">projects</a></li>
</ul>
- <?php endif; ?>
-
- <?php if (!empty($vars['product_name'])): ?>
+
<div id="title">
<a href="<?php echo $vars['product_base_url']; ?>">
<img id="logo" src="<?php echo $this->image('logo.png') ?>" alt="<?php echo $vars['product_name']; ?> logo" />
@@ -64,7 +85,7 @@
?>
</div>
</div>
- </div>
<?php endif; ?>
+ </div>
<div id="content">
@@ -0,0 +1,10 @@
+var global = {
+ showLoginForm: function() {
+ $('#login-form').show();
+ $('#login_email').focus();
+ },
+
+ hideLoginForm: function() {
+ $('#login-form').hide();
+ }
+};
@@ -0,0 +1,6 @@
+<div class="logged-out">
+ <h3>You're logged out!</h3>
+ <h4>Phew, that was a close one. What now?</h4>
+ <p><a href="<?php echo $this->getBaseURL(); ?>">Go to the homepage</a> / <a href="<?php echo $this->getBaseURL(); ?>/login" onclick="global.showLoginForm(); return false;">log back in!</p>
+</div>
+
@@ -34,6 +34,9 @@
echo '.</p>';
}
?>
+
+ <h3>project lead</h3>
+ <p></p>
<div class="edit-box">
<h3>edit project</h3>

0 comments on commit dcf7d27

Please sign in to comment.