Fixed editing conditions
This commit is contained in:
parent
d555bde0d8
commit
3dae73fcf0
@ -96,9 +96,7 @@ class Posts
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$url = 'Data/pengumuman.html';
|
$url = 'Data/pengumuman.html';
|
||||||
|
$user = [];
|
||||||
$status = '';
|
|
||||||
$privilege = '';
|
|
||||||
|
|
||||||
if (Session::exists('userid')) {
|
if (Session::exists('userid')) {
|
||||||
$data = $this->model->showJoin();
|
$data = $this->model->showJoin();
|
||||||
@ -107,8 +105,8 @@ class Posts
|
|||||||
['pengumuman.status', '=', $args]
|
['pengumuman.status', '=', $args]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$privilege = Session::get('privilege');
|
$user = $_SESSION;
|
||||||
$status = 'loggedin';
|
unset($user['tokens']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data !== false) {
|
if ($data !== false) {
|
||||||
@ -126,8 +124,7 @@ class Posts
|
|||||||
|
|
||||||
View::render($url, [
|
View::render($url, [
|
||||||
'posts' => $datas,
|
'posts' => $datas,
|
||||||
'status' => $status,
|
'user' => $user,
|
||||||
'privilege' => $privilege,
|
|
||||||
'token' => Token::generate()
|
'token' => Token::generate()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class Post extends \Core\Model
|
|||||||
try {
|
try {
|
||||||
$db = static::connectDB();
|
$db = static::connectDB();
|
||||||
|
|
||||||
$sql = "SELECT pengumuman.id, kategori.background, kategori.foreground, pengumuman.valid_at, pengumuman.expired_at, pengumuman.content, pengumuman.status FROM pengumuman INNER JOIN kategori ON pengumuman.category=kategori.id";
|
$sql = "SELECT pengumuman.id, kategori.background, kategori.foreground, pengumuman.valid_at, pengumuman.expired_at, pengumuman.creator, pengumuman.editor, pengumuman.content, pengumuman.status FROM pengumuman INNER JOIN kategori ON pengumuman.category=kategori.id";
|
||||||
|
|
||||||
if ($conditions) {
|
if ($conditions) {
|
||||||
$sql .= " WHERE";
|
$sql .= " WHERE";
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<input type="checkbox" id="bmenug" class="show">
|
<input type="checkbox" id="bmenug" class="show">
|
||||||
<label for="bmenug" class="burger pseudo button"><i class="fa fa-bars" aria-hidden="true"></i></label>
|
<label for="bmenug" class="burger pseudo button"><i class="fa fa-bars" aria-hidden="true"></i></label>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
{% if privilege != "" %}
|
{% if user.privilege != "" %}
|
||||||
{% if privilege == 1 %}
|
{% if user.privilege == 1 %}
|
||||||
<a href="/posts/category" class="navy button" data-tooltip="Kategori"><i class="fa fa-list-ul" aria-hidden="true"></i> Kategori</a>
|
<a href="/posts/category" class="navy button" data-tooltip="Kategori"><i class="fa fa-list-ul" aria-hidden="true"></i> Kategori</a>
|
||||||
<a href="/register" class="navy button" data-tooltip="User Baru"><i class="fa fa-user-plus" aria-hidden="true"></i> User</a>
|
<a href="/register" class="navy button" data-tooltip="User Baru"><i class="fa fa-user-plus" aria-hidden="true"></i> User</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<main class="documentation">
|
<main class="documentation">
|
||||||
<div style="text-align:left;width:100%;">
|
<div style="text-align:left;width:100%;">
|
||||||
|
|
||||||
{% if privilege == "" %}
|
{% if user.privilege == "" %}
|
||||||
{% if not posts %}
|
{% if not posts %}
|
||||||
<div style="background:#fff;text-align:left;max-width:100vw;padding:10vh 0 0;">
|
<div style="background:#fff;text-align:left;max-width:100vw;padding:10vh 0 0;">
|
||||||
<h1 class="fitty pengumuman">Tidak ada pengumuman</h1>
|
<h1 class="fitty pengumuman">Tidak ada pengumuman</h1>
|
||||||
@ -63,18 +63,24 @@
|
|||||||
<form method="post" action="/">
|
<form method="post" action="/">
|
||||||
<footer class="flex full grow">
|
<footer class="flex full grow">
|
||||||
{% if post.status != 0 %}
|
{% if post.status != 0 %}
|
||||||
<div class="half-900">
|
{% if user.userid == post.creator %}
|
||||||
<a href="/posts/edit/{{ post.id }}" class="button full">
|
<div class="half-900">
|
||||||
<i class="fa fa-edit fa-fw"></i>
|
<a href="/posts/edit/{{ post.id }}" class="button full">
|
||||||
<span style="font-size:smaller;">Ubah</span>
|
<i class="fa fa-edit fa-fw"></i>
|
||||||
</a>
|
<span style="font-size:smaller;">Ubah</span>
|
||||||
</div>
|
</a>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="half-900">
|
||||||
|
<span class="button pseudo full" style="color:rgba(17,17,17,.3)">Tidak dapat diubah</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="half-900">
|
<div class="half-900">
|
||||||
<span class="button pseudo full" style="color:rgba(17,17,17,.3)">Nonaktif</span>
|
<span class="button pseudo full" style="color:rgba(17,17,17,.3)">Nonaktif</span>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if (post.status == 1 and editor_now.id == creator.id) %}
|
{% if (post.status == 1 and user.userid == post.creator) %}
|
||||||
<div class="half-900">
|
<div class="half-900">
|
||||||
<input type="hidden" name="id" value="{{ post.id }}">
|
<input type="hidden" name="id" value="{{ post.id }}">
|
||||||
<input type="hidden" name="status" value="0">
|
<input type="hidden" name="status" value="0">
|
||||||
@ -87,7 +93,7 @@
|
|||||||
<span style="font-size:smaller;">Matikan</span>
|
<span style="font-size:smaller;">Matikan</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% elseif (post.status == 2 and editor_now.id == creator.id) %}
|
{% elseif (post.status == 2 and user.userid == post.creator) %}
|
||||||
<div class="half-900">
|
<div class="half-900">
|
||||||
<input type="hidden" name="id" value="{{ post.id }}">
|
<input type="hidden" name="id" value="{{ post.id }}">
|
||||||
<input type="hidden" name="valid_at" value="##date##">
|
<input type="hidden" name="valid_at" value="##date##">
|
||||||
|
Loading…
Reference in New Issue
Block a user