First work on article list

このコミットが含まれているのは:
Léo Serre 2018-11-04 08:35:56 +01:00
コミット a3d964e9c5
3個のファイルの変更22行の追加19行の削除

ファイルの表示

@ -31,13 +31,13 @@ switch ($controller->splitted_url[1]) {
case "list":
$blogArticles = new Kabano\BlogArticles();
$blogArticles->number(($user->role >= 600));
$blogArticles->number(($user->rankIsHigher("premium")));
// In case the wanted page is too big
if($articles_per_pages * $page >= $blogArticles->number)
$page = 0;
$blogArticles->listArticles($page*$articles_per_pages,$articles_per_pages,($user->role >= 600));
$blogArticles->listArticles($page*$articles_per_pages,$articles_per_pages,($user->rankIsHigher("premium")));
$i = 0;
$blogArticles_list = array();
@ -64,7 +64,7 @@ switch ($controller->splitted_url[1]) {
}
break;
case "new":
if($user->role >= 800) {
if($user->rankIsHigher("moderator")) {
if(isset($_POST['submit'])) {
$blogArticle->content = $_POST['content'];
$blogArticle->locale = $_POST['locale'];
@ -91,12 +91,12 @@ switch ($controller->splitted_url[1]) {
}
default:
// If the page exists
if ($blogArticle->checkUrl($controller->splitted_url[1],$user->role >= 600)) {
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "delete" && $user->role >= 800) {
if ($blogArticle->checkUrl($controller->splitted_url[1],$user->rankIsHigher("premium"))) {
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "delete" && $user->rankIsHigher("moderator")) {
$blogArticle->delete();
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->url);
}
else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "edit" && $user->role >= 800) {
else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "edit" && $user->rankIsHigher("moderator")) {
if(isset($_POST['submit'])) {
$blogArticle->content = $_POST['content'];
$blogArticle->locale = $_POST['locale'];
@ -114,7 +114,7 @@ switch ($controller->splitted_url[1]) {
}
else {
// Manage history of an article
if($user->role >= 600) {
if($user->rankIsHigher("premium")) {
$blogArticles_history = new Kabano\BlogArticles();
$blogArticles_history->getHistory($controller->splitted_url[1]);
@ -127,11 +127,11 @@ switch ($controller->splitted_url[1]) {
}
}
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]))
$blogArticle->checkUrl($controller->splitted_url[1],$user->role>=600,$controller->splitted_url[2]);
$blogArticle->checkUrl($controller->splitted_url[1],$user->rankIsHigher("premium"),$controller->splitted_url[2]);
// Manage comment creation
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="new_comment") {
if (isset($_POST['submit']) && $user->role > 0) {
if (isset($_POST['submit']) && $user->rankIsHigher("registered")) {
$blogComment = new Kabano\BlogComment();
$blogComment->locale = $user->locale;
$blogComment->author = $user->id;
@ -147,7 +147,7 @@ switch ($controller->splitted_url[1]) {
$blogComment = new Kabano\BlogComment();
$blogComment->id = $controller->splitted_url[3];
$blogComment->populate();
if ($user->role >= 800 || $user->id == $blogComment->author)
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->delete();
}
}
@ -158,7 +158,7 @@ switch ($controller->splitted_url[1]) {
$blogComment = new Kabano\BlogComment();
$blogComment->id = $controller->splitted_url[3];
$blogComment->populate();
if ($user->role >= 800 || $user->id == $blogComment->author)
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->undelete();
}
}
@ -169,7 +169,7 @@ switch ($controller->splitted_url[1]) {
// Manage comments
if ($blogArticle->comments == "t") {
$blogArticles_comments = new Kabano\BlogComments();
$blogArticles_comments->listComments($blogArticle->id, ($user->role>400));
$blogArticles_comments->listComments($blogArticle->id, ($user->rankIsHigher("premium")));
$i = 0;
foreach ($blogArticles_comments->ids as $row) {

ファイルの表示

@ -218,7 +218,7 @@ class BlogArticle
class BlogArticles
{
public $ids = array();
public $objs = array();
public $number = NULL;
/*****
@ -232,10 +232,10 @@ class BlogArticles
if ($archive == 1) {
// You just want one per url and the criteria is ORDER BY archives = true, time DES=C
$query = "SELECT id FROM (SELECT a.id, a.lastedit , ROW_NUMBER() OVER (PARTITION BY a.url ORDER BY CASE WHEN a.archive IS TRUE THEN 1 ELSE 0 END, a.lastedit DESC) AS r FROM blog_articles AS a) AS b WHERE r = 1 ORDER BY lastedit DESC";
$query = "SELECT * FROM (SELECT a.id, a.update_date , ROW_NUMBER() OVER (PARTITION BY a.permalink ORDER BY CASE WHEN a.is_archive IS TRUE THEN 1 ELSE 0 END, a.update_date DESC) AS r FROM contents WHERE type='blog' AS a) AS b WHERE r = 1 ORDER BY update_date DESC";
}
else {
$query = "SELECT id FROM blog_articles WHERE archive IS NOT TRUE ORDER BY lastedit DESC";
$query = "SELECT * FROM contents WHERE is_archive IS NOT TRUE AND is_public IS TRUE AND type='blog' ORDER BY update_date DESC";
}
$query .= " LIMIT $1 OFFSET $2";
@ -248,9 +248,11 @@ class BlogArticles
for($i = 0; $i < pg_num_rows($result); $i++) {
$row = pg_fetch_assoc($result, $i);
$this->ids[$i] = $row['id'];
$this->objs[$i] = new BlogArticle;
$this->objs[$i]->populate($row);
}
}
/*****
** Return the number of articles
*****/
@ -262,10 +264,10 @@ class BlogArticles
if ($archive == 1) {
// You just want one per url and the criteria is ORDER BY archives = true, time DES=C
$query = "SELECT id FROM (SELECT a.id, a.lastedit , ROW_NUMBER() OVER (PARTITION BY a.url ORDER BY CASE WHEN a.archive IS TRUE THEN 1 ELSE 0 END, a.lastedit DESC) AS r FROM blog_articles AS a) AS b WHERE r = 1 ORDER BY lastedit DESC";
$query = "SELECT * FROM (SELECT a.id, a.update_date , ROW_NUMBER() OVER (PARTITION BY a.permalink ORDER BY CASE WHEN a.is_archive IS TRUE THEN 1 ELSE 0 END, a.update_date DESC) AS r FROM contents WHERE type='blog' AS a) AS b WHERE r = 1 ORDER BY update_date DESC";
}
else {
$query = "SELECT id FROM blog_articles WHERE archive IS NOT TRUE ORDER BY lastedit DESC";
$query = "SELECT * FROM contents WHERE is_archive IS NOT TRUE AND is_public IS TRUE AND type='blog' ORDER BY update_date DESC";
}
pg_prepare($con, "prepare1", $query)
@ -277,6 +279,7 @@ class BlogArticles
$this->number = pg_num_rows($result);
}
/*****
** Return the list of archived version of a blog article
*****/

ファイルの表示

@ -40,7 +40,7 @@
<li class="on-bar has-sub"><a class="on-bar" href="#"><i class="icon fas fa-question"></i></a>
<ul>
<li><a href="<?=$config['rel_root_folder']?>wiki/help">Aide</a></li>
<!--<li><a href="<?=$config['rel_root_folder']?>blog">Blog</a></li>-->
<li><a href="<?=$config['rel_root_folder']?>blog">Blog</a></li>
<li><a href="<?=$config['rel_root_folder']?>contact">Contact</a></li>
<li><a href="<?=$config['rel_root_folder']?>wiki/api">API Développeurs</a></li>
<li><a href="<?=$config['rel_root_folder']?>wiki/about">À propos</a></li>