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

View File

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