Added edit validation

This commit is contained in:
Gregorio Chiko Putra 2017-09-06 11:19:44 +07:00
parent a34ce9d0eb
commit 01ce24fd39
2 changed files with 12 additions and 6 deletions

View File

@ -61,7 +61,6 @@ class Posts
$status = 'admin';
}
// $x = 0;
for ($i=0; $i < count($posts); $i++) {
$posts[$i]['content'] = preg_replace('/[\r]/', '', $posts[$i]['content']);
$posts[$i]['content'] = preg_replace('/[\n]/', "<br/>", $posts[$i]['content']);
@ -109,7 +108,7 @@ class Posts
$editor_now = Session::get('userid');
$date = new \DateTime();
$timestamp = $date->format("Y/m/d H:i:s");
$timestamp = $date->format("Y-m-d");
View::render(
'Data/edit_pengumuman.html',

View File

@ -40,7 +40,14 @@
<br>
<label for="expired_at">Berlaku sampai: </label>
<label>Berlaku dari: </label>
<span>
{{ post.valid_at }}
</span>
<br>
<label>Berlaku sampai: </label>
<span>
{{ post.expired_at }}
</span>
@ -49,7 +56,7 @@
<label>Diubah pada: </label>
<span>
{% if post.edited_at == "0000-00-00 00:00:00" %}
{% if post.edited_at is empty %}
Tidak pernah
{% else %}
{{ post.edited_at }}
@ -61,7 +68,7 @@
<label for="editor_name">Diubah oleh: </label>
<span>
{% if post.editor == "0" %}
{% if post.editor is empty %}
-
{% else %}
{{ editor.name }}
@ -92,7 +99,7 @@
<br>
<button type="submit"
{% if post.status == 0 %}
{% if (post.status == 0 and post.valid_at <= timestamp or editor_now != creator.id) %}
disabled
{% endif %}
>