User role support

User role support
This commit is contained in:
Danang Probo Sayekti 2014-02-08 00:17:28 +07:00
commit c7c23866bb
15 changed files with 235 additions and 79 deletions

View file

@ -1,5 +1,7 @@
<?php
$destination = $_GET['destination'];
if(isset($_GET['destination'])) {
$destination = $_GET['destination'];
}
$url = $p->file;
$dir = substr($url, 0, strrpos($url, '/'));
@ -8,11 +10,17 @@
$post = site_url() . $oldmd;
if($destination == 'post') {
$back = $post;
if(isset($destination)) {
if($destination == 'post') {
$back = $post;
}
else {
$back = site_url() . $destination;
}
}
else {
$back = site_url() . $destination;
$back = site_url();
}
?>

View file

@ -1,5 +1,7 @@
<?php
$destination = $_GET['destination'];
if(isset($_GET['destination'])) {
$destination = $_GET['destination'];
}
$url = $p->file;
$oldurl = explode('_', $url);
$oldtag = $oldurl[1];
@ -15,11 +17,17 @@
// The post URL
$post = site_url().date('Y/m', $postdate).'/'.$oldmd;
if($destination == 'post') {
$back = $post;
if(isset($destination)) {
if($destination == 'post') {
$back = $post;
}
else {
$back = site_url() . $destination;
}
}
else {
$back = site_url() . $destination;
$back = site_url();
}
?>

View file

@ -0,0 +1 @@
<h1>You don't have permission to access this page</h1>

View file

@ -17,7 +17,12 @@
$oldcontent = ltrim($arr[0]);
}
$destination = $_GET['destination'];
if(isset($_GET['destination'])) {
$destination = $_GET['destination'];
}
else {
$destination = 'admin';
}
$dir = substr($url, 0, strrpos($url, '/'));
$oldurl = str_replace($dir . '/','',$url);
$oldmd = str_replace('.md','',$oldurl);

View file

@ -25,7 +25,12 @@
$oldmd = str_replace('.md','',$oldurl[2]);
$destination = $_GET['destination'];
if(isset($_GET['destination'])) {
$destination = $_GET['destination'];
}
else {
$destination = 'admin';
}
$replaced = substr($oldurl[0], 0,strrpos($oldurl[0], '/')) . '/';
$dt = str_replace($replaced,'',$oldurl[0]);
$t = str_replace('-','',$dt);

View file

@ -23,21 +23,7 @@
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
</div>
<?php if(login()) {?>
<style> #outer-wrapper{ padding-top:30px;} @media all and (max-width: 550px) {#outer-wrapper{ padding-top:60px;}}</style>
<div id="toolbar">
<ul>
<li><a href="<?php echo site_url() ?>">Home</a></li>
<li><a href="<?php echo site_url() ?>admin">Admin</a></li>
<li><a href="<?php echo site_url() ?>admin/posts">Posts</a></li>
<li><a href="<?php echo site_url() ?>add/post">Add post</a></li>
<li><a href="<?php echo site_url() ?>add/page">Add page</a></li>
<li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li>
<li><a href="<?php echo site_url() ?>admin/import">Import</a></li>
<li><a href="<?php echo site_url() ?>logout">Logout</a></li>
</ul>
</div>
<?php } ?>
<?php if(login()) { toolbar();} ?>
<div id="outer-wrapper">
<div id="menu-wrapper">
<div class="container">

View file

@ -1,7 +1,7 @@
<h2 class="post-index">Your posts</h2>
<h2 class="post-index"><?php echo $heading?></h2>
<?php if(!empty($posts)) {?>
<table class="post-list">
<tr><th>Title</th><th>Published</th><th>Tag</th><th>Operations</th></tr>
<tr><th>Title</th><th>Published</th><th>Author</th><th>Tag</th><th>Operations</th></tr>
<?php $i = 0; $len = count($posts);?>
<?php foreach($posts as $p):?>
<?php
@ -19,6 +19,7 @@
<tr>
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
<td><?php echo date('d F Y', $p->date) ?></td>
<td><a target="_blank" href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></td>
<td><?php echo $p->tag ?></td>
<td><a href="<?php echo $p->url ?>/edit?destination=admin/posts">Edit</a> <a href="<?php echo $p->url ?>/delete?destination=admin/posts">Delete</a></td>
</tr>

View file

@ -0,0 +1,37 @@
<h2 class="post-index"><?php echo $heading?></h2>
<?php if(!empty($posts)) {?>
<table class="post-list">
<tr><th>Title</th><th>Published</th><th>Tag</th><th>Operations</th></tr>
<?php $i = 0; $len = count($posts);?>
<?php foreach($posts as $p):?>
<?php
if ($i == 0) {
$class = 'first';
}
elseif ($i == $len - 1) {
$class = 'last';
}
else {
$class = '';
}
$i++;
?>
<tr>
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
<td><?php echo date('d F Y', $p->date) ?></td>
<td><?php echo $p->tag ?></td>
<td><a href="<?php echo $p->url ?>/edit?destination=admin/mine">Edit</a> <a href="<?php echo $p->url ?>/delete?destination=admin/mine">Delete</a></td>
</tr>
<?php endforeach;?>
</table>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])):?>
<div class="pager">
<?php if (!empty($pagination['prev'])):?>
<span><a href="?page=<?php echo $page-1?>" class="pagination-arrow newer" rel="prev">Newer</a></span>
<?php endif;?>
<?php if (!empty($pagination['next'])):?>
<span><a href="?page=<?php echo $page+1?>" class="pagination-arrow older" rel="next">Older</a></span>
<?php endif;?>
</div>
<?php endif;?>
<?php } else { echo 'No posts found!'; }?>