Commit a346bd13 authored by Ryan Wade's avatar Ryan Wade

Added dynamic login/logout/admin links to the header and footer

Displays user name when logged in.
Only shows admin link when user has adequate permissions
parent c0d1e431
......@@ -22,8 +22,8 @@
$SQL = new SQL();
$Auth = new Authentication($SQL->Get_TABLE(1));
if($AuthRequired&&(!$Auth->isAuthenticated()))
header("location: ".AuthReturn);
if($AuthRequired&&!(($Auth->isAuthenticated())&&($Auth->hasPermissions(AUTH_LEVEL_WRITER))))
header("location: ".$AuthReturn);
//Get Basic Site Info
if($title==null)
$site_title = $SQL->GET_SITE_TITLE();
......@@ -61,14 +61,14 @@
//Initialize page component objects
$css = new CSS();
$header = new Header($site_title, $site_logo);
$header = new Header($site_title, $site_logo, $Auth, $linking);
$nav = new NAV($SQL->GET_TABLE($Table), $linking, $page_id);
$title = new Title($page_id, $page_title, $page_desc, $page_img);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE($Table), $linking, $page_id, $page_title);
$body = new Body($page_src);
$sitemap = new Sitemap($SQL->GET_TABLE($Table), $linking);
$login = new Login($SQL->GET_TABLE(1), $Auth, "./".$linking);
$footer = new footer($linking);
$footer = new footer($Auth, $linking);
//render HTML output
?>
......
......@@ -2,9 +2,11 @@
//create footer
class Footer
{
private $Auth = null;
private $link = null;
function Footer($link)
function Footer($Auth, $link)
{
$this->Auth = $Auth;
$this->link = $link;
}
//render footer
......@@ -14,7 +16,28 @@
<footer id="footer">
<div class="footerText left">
<ul>
<li><a class="footerLink" href="<?php echo $this->link;?>?id=-2">Login</a></li>
<li>
<?php
if($this->Auth->isAuthenticated())
{
echo $this->Auth->getUser();
?>
<ul>
<?php if($this->Auth->hasPermissions(AUTH_LEVEL_WRITER)) { ?>
<li><a class="footerLink" href="admin.php">Admin</a></li>
<?php } ?>
<li><a class="footerLink" href="<?php echo ($this->link."?id=-3") ?>">Log Out</a></li>
</ul>
<?php
}
else
{
?>
<a class="footerLink" href="<?php echo ($this->link."?id=-2") ?>">Log In</a>
<?php
}
?>
</li>
<li><a class="footerLink" href="<?php echo $this->link;?>?id=-1">Site Map</a></li>
</ul>
</div>
......
......@@ -24,6 +24,81 @@
position:relative;
float:left;
}
#headerUser
{
float: right;
width: 200px;
text-align: center;
border: none;
//margin-top: 25px;
font: 20px Georgia, serif;
color: black;
font-style: underline;
position: relative;
z-index:2;
}
/**Top Level #headerUser**/
#headerUser ul ul {
display: none;
}
#headerUser ul li:hover > ul {
display: block;
}
#headerUser ul {
width: 100%;
margin: 0px;
padding: 0px 0px;
list-style: none;
position: relative;
display: inline-table;
}
#headerUser ul:after {
content: "";
clear: both;
display: block;
}
#headerUser ul li {
width: 100%;
border: none;
float: left;
border-left:2px solid black;
border-right:2px solid black;
}
#headerUser ul li a:hover {
background-color: rgba(240, 240, 240, 1);
border-radius: 0px 0px 0px 10px;
-webkit-border-radius: 0px 0px 0px 10px;
}
#headerUser ul li a {
display: block;
padding: 5px 20px;
text-decoration: none;
}
/**Submenu**/
#headerUser ul ul {
background:white;
/*background:rgba(86, 170, 204, 0.75);*/
border-radius: 0px 0px 0px 10px;
-webkit-border-radius: 0px 0px 0px 10px;
border: solid 1px black;
padding: 0px;
position: absolute;
top: 100%;
}
#headerUser ul ul li {
border: none;
float: none;
position: relative;
}
#headerUser ul ul li:hover {
}
#headerUser ul ul li a {
border-top: solid 1px black;
}
#headerUser ul ul li a:hover {
}
/*Images*/
img.headerImg
{
......
......@@ -4,10 +4,14 @@
{
private $title = "";
private $logo = "";
public function Header($title, $logo)
private $Auth = "";
private $link = "";
public function Header($title, $logo, $Auth, $link)
{
$this->title = $title;
$this->logo = $logo;
$this->Auth = $Auth;
$this->link = $link;
}
public function render()
{
......@@ -15,6 +19,32 @@
<div id="header" class="center">
<img id="headerLogo" src="<?php echo $this->logo;?>"/>
<div id="headerTitle"><?php echo $this->title;?></div>
<div id="headerUser">
<ul>
<li>
<?php
if($this->Auth->isAuthenticated())
{
echo $this->Auth->getUser();
?>
<ul>
<?php if($this->Auth->hasPermissions(AUTH_LEVEL_WRITER)) { ?>
<li><a href="admin.php">Admin</a></li>
<?php } ?>
<li><a href="<?php echo ($this->link."?id=-3") ?>">Log Out</a></li>
</ul>
<?php
}
else
{
?>
<a href="<?php echo ($this->link."?id=-2") ?>">Log In</a>
<?php
}
?>
</li>
</ul>
</div>
</div>
<?php
}
......
......@@ -22,8 +22,8 @@
$SQL = new SQL();
$Auth = new Authentication($SQL->Get_TABLE(1));
if($AuthRequired&&(!$Auth->isAuthenticated()))
header("location: ".AuthReturn);
if($AuthRequired&&!(($Auth->isAuthenticated())&&($Auth->hasPermissions(AUTH_LEVEL_WRITER))))
header("location: ".$AuthReturn);
//Get Basic Site Info
if($title==null)
$site_title = $SQL->GET_SITE_TITLE();
......@@ -61,14 +61,14 @@
//Initialize page component objects
$css = new CSS();
$header = new Header($site_title, $site_logo);
$header = new Header($site_title, $site_logo, $Auth, $linking);
$nav = new NAV($SQL->GET_TABLE($Table), $linking, $page_id);
$title = new Title($page_id, $page_title, $page_desc, $page_img);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE($Table), $linking, $page_id, $page_title);
$body = new Body($page_src);
$sitemap = new Sitemap($SQL->GET_TABLE($Table), $linking);
$login = new Login($SQL->GET_TABLE(1), $Auth, "./".$linking);
$footer = new footer($linking);
$footer = new footer($Auth, $linking);
//render HTML output
?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment