From 7a29f0825f4ee15706c802143f189cfeee87672d Mon Sep 17 00:00:00 2001
From: leosw
Date: Mon, 5 Nov 2018 22:05:42 +0100
Subject: [PATCH] fix blog view page
---
controllers/d.blog.php | 16 +++-----------
models/d.blog.php | 10 ++++-----
views/d.blog.view.html | 49 +++++++++++++++++++++---------------------
3 files changed, 33 insertions(+), 42 deletions(-)
diff --git a/controllers/d.blog.php b/controllers/d.blog.php
index 3d88ae5..ab9b07c 100755
--- a/controllers/d.blog.php
+++ b/controllers/d.blog.php
@@ -120,14 +120,6 @@ switch ($controller->splitted_url[1]) {
if($user->rankIsHigher("premium")) {
$blogArticles_history = new Kabano\BlogArticles();
$blogArticles_history->getHistory($controller->splitted_url[1]);
-
- $i = 0;
- foreach ($blogArticles_history->ids as $row) {
- $blogArticles_history_list[$i] = new Kabano\BlogArticle();
- $blogArticles_history_list[$i]->id = $row;
- $blogArticles_history_list[$i]->populate();
- $i++;
- }
}
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]))
$blogArticle->checkPermalink($controller->splitted_url[1],$user->rankIsHigher("premium"),$controller->splitted_url[2]);
@@ -166,11 +158,10 @@ switch ($controller->splitted_url[1]) {
}
}
- $blogArticle->populate();
$blogArticle->md2html();
// Manage comments
- if ($blogArticle->comments == "t") {
+ if ($blogArticle->is_commentable == "t") {
$blogArticles_comments = new Kabano\BlogComments();
$blogArticles_comments->listComments($blogArticle->id, ($user->rankIsHigher("premium")));
@@ -189,12 +180,11 @@ switch ($controller->splitted_url[1]) {
$tempUser = new Kabano\User();
- $tempUser->id = $blogArticle->author;
- $tempUser->populate();
+ $tempUser->checkId($blogArticle->author);
$blogArticle->author_name = $tempUser->name;
unset($tempUser);
- $head['title'] = $blogArticle->title;
+ $head['title'] = $blogArticle->name;
include ($config['views_folder']."d.blog.view.html");
}
}
diff --git a/models/d.blog.php b/models/d.blog.php
index ce22e5d..d72eb4f 100755
--- a/models/d.blog.php
+++ b/models/d.blog.php
@@ -271,13 +271,13 @@ class BlogArticles
/*****
** Return the list of archived version of a blog article
*****/
-/* public function getHistory($url) {
+ public function getHistory($url) {
global $config;
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
or die ("Could not connect to server\n");
- $query = "SELECT id FROM blog_articles WHERE url=$1 ORDER BY lastedit DESC";
+ $query = "SELECT * FROM contents WHERE permalink=$1 AND type='blog' ORDER BY update_date DESC";
pg_prepare($con, "prepare1", $query)
or die ("Cannot prepare statement\n");
@@ -290,12 +290,12 @@ class BlogArticles
for($i = 0; $i < $this->number; $i++) {
$row = pg_fetch_assoc($result, $i);
- $this->ids[$i] = $row['id'];
+ $this->objs[$i] = new BlogArticle;
+ $this->objs[$i]->populate($row);
}
- }*/
+ }
}
-
/**********************************************************
***********************************************************
**
diff --git a/views/d.blog.view.html b/views/d.blog.view.html
index 1cdd312..4ae330e 100755
--- a/views/d.blog.view.html
+++ b/views/d.blog.view.html
@@ -7,9 +7,9 @@
include('blocks/d.nav.html'); ?>
- archive=="t"?'class="archive"':''?>>
- =$blogArticle->title?>.
- if($user->role >= 600) { ?>
+ is_archive=="t"||$blogArticle->is_public=="f"?'class="archive"':''?>>
+ =$blogArticle->name?>.
+ if($user->rankIsHigher("premium")) { ?>
if(isset($blogArticles_history_list)) { ?>
}
- if ($user->role >= 800 && isset($blogArticles_history_list)) { ?>
+ if ($user->rankIsHigher("moderator") && isset($blogArticles_history_list)) { ?>
—
}
- if ($user->role >= 800) { ?>
- Éditer l'article
- if ($blogArticle->archive == 'f') { ?>
- —
- Effacer l'article
+ if ($user->rankIsHigher("moderator")) { ?>
+ Éditer l'article —
+ if ($blogArticle->is_public == 't') { ?>
+ Effacer l'article
+ } else { ?>
+ Restaurer l'article
} ?>
} ?>
@@ -38,21 +39,21 @@
Article écrit par
- if ($user->role > 0) { ?>
+ if ($user->rankIsHigher("blocked")) { ?>
=$blogArticle->author_name?>
}
else { ?>
=$blogArticle->author_name?>
} ?>
- le echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($blogArticle->lastedit)) ?> UTC
+ le echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($blogArticle->creation_date)) ?> UTC
- if ($blogArticle->comments == "t" && $blogArticle->archive == "f") { ?>
+ if ($blogArticle->is_commentable == "t" && $blogArticle->is_archive == "f" && $blogArticle->is_public == "t") { ?>