Getion des commentaires dans un modèle spécial

This commit is contained in:
leosw
2026-01-18 15:51:59 +01:00
parent 9657093edd
commit a6c0e06d78
5 changed files with 487 additions and 305 deletions

View File

@@ -1,6 +1,7 @@
<?
require_once($config['models_folder']."d.blog.php");
require_once($config['models_folder']."d.comments.php");
require_once($config['models_folder']."d.users.php");
$head['css'] = "d.index.css;d.blog.css";
@@ -129,32 +130,32 @@ switch ($controller->splitted_url[1]) {
// Manage comment creation
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="new_comment") {
if (isset($_POST['submit']) && $user->rankIsHigher("registered")) {
$blogComment = new Kabano\BlogComment();
$blogComment->locale = $user->locale;
$blogComment->author = $user->id;
$blogComment->content = $blogArticle->content_id;
$blogComment->comment = $_POST['comment'];
$blogComment->insert();
$Comment = new Kabano\Comment();
$Comment->locale = $user->locale;
$Comment->author = $user->id;
$Comment->content = $blogArticle->content_id;
$Comment->comment = $_POST['comment'];
$Comment->insert();
}
}
// Manage comment deletion
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="delete_comment") {
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
$blogComment = new Kabano\BlogComment();
if($blogComment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->delete();
$Comment = new Kabano\Comment();
if($Comment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $Comment->author)
$Comment->delete();
}
}
// Manage comment restoration
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="restore_comment") {
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
$blogComment = new Kabano\BlogComment();
if($blogComment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->restore();
$Comment = new Kabano\Comment();
if($Comment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $Comment->author)
$Comment->restore();
}
}
@@ -162,7 +163,7 @@ switch ($controller->splitted_url[1]) {
// Manage comments
if ($blogArticle->is_commentable == "t") {
$blogArticles_comments = new Kabano\BlogComments();
$blogArticles_comments = new Kabano\Comments();
$blogArticles_comments->listComments($blogArticle->content_id, ($user->rankIsHigher("premium")));
$i = 0;

View File

@@ -61,104 +61,104 @@ switch ($controller->splitted_url[1]) {
$notfound = 1;
}
default:
// // If the page exists
// if ($blogArticle->checkPermalink($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->permalink);
// }
// else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "restore" && $user->rankIsHigher("moderator")) {
// $blogArticle->restore();
// header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->permalink);
// }
// 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'];
// $blogArticle->name = $_POST['name'];
// $blogArticle->is_commentable = isset($_POST['is_commentable'])?'t':'f';
// $blogArticle->author = $user->id;
// $blogArticle->update();
// header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->permalink);
// }
// else {
// $locales = new Kabano\Locales();
// $locales->getAll();
// If the page exists
if ($poi->checkPermalink($controller->splitted_url[1],$user->rankIsHigher("premium"))) {
// if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "delete" && $user->rankIsHigher("moderator")) {
// $poi->delete();
// header('Location: '.$config['rel_root_folder']."blog/".$poi->permalink);
// }
// else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "restore" && $user->rankIsHigher("moderator")) {
// $poi->restore();
// header('Location: '.$config['rel_root_folder']."blog/".$poi->permalink);
// }
// else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "edit" && $user->rankIsHigher("moderator")) {
// if(isset($_POST['submit'])) {
// $poi->content = $_POST['content'];
// $poi->locale = $_POST['locale'];
// $poi->name = $_POST['name'];
// $poi->is_commentable = $_POST['is_commentable'];
// $poi->author = $user->id;
// $poi->update();
// header('Location: '.$config['rel_root_folder']."blog/".$poi->permalink);
// }
// else {
// $locales = new Kabano\Locales();
// $locales->getAll();
// $head['title'] = $blogArticle->name;
// include ($config['views_folder']."d.blog.edit.html");
// }
// }
// else {
// // Manage history of an article
// if($user->rankIsHigher("premium")) {
// $blogHistory = new Kabano\BlogArticles();
// $blogHistory->getHistory($controller->splitted_url[1]);
// }
// 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]);
// $head['title'] = $poi->name;
// include ($config['views_folder']."d.blog.edit.html");
// }
// }
// else {
// Manage history of an article
if($user->rankIsHigher("premium")) {
$blogHistory = new Kabano\pois();
$blogHistory->getHistory($controller->splitted_url[1]);
}
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]))
$poi->checkPermalink($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->rankIsHigher("registered")) {
// $blogComment = new Kabano\BlogComment();
// $blogComment->locale = $user->locale;
// $blogComment->author = $user->id;
// $blogComment->content = $blogArticle->content_id;
// $blogComment->comment = $_POST['comment'];
// $blogComment->insert();
// }
// }
// Manage comment creation
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="new_comment") {
if (isset($_POST['submit']) && $user->rankIsHigher("registered")) {
$blogComment = new Kabano\BlogComment();
$blogComment->locale = $user->locale;
$blogComment->author = $user->id;
$blogComment->content = $poi->content_id;
$blogComment->comment = $_POST['comment'];
$blogComment->insert();
}
}
// // Manage comment deletion
// if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="delete_comment") {
// if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
// $blogComment = new Kabano\BlogComment();
// if($blogComment->checkId($controller->splitted_url[3]))
// if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
// $blogComment->delete();
// }
// }
// Manage comment deletion
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="delete_comment") {
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
$blogComment = new Kabano\BlogComment();
if($blogComment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->delete();
}
}
// // Manage comment restoration
// if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="restore_comment") {
// if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
// $blogComment = new Kabano\BlogComment();
// if($blogComment->checkId($controller->splitted_url[3]))
// if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
// $blogComment->restore();
// }
// }
// Manage comment restoration
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="restore_comment") {
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
$blogComment = new Kabano\BlogComment();
if($blogComment->checkId($controller->splitted_url[3]))
if ($user->rankIsHigher("moderator") || $user->id == $blogComment->author)
$blogComment->restore();
}
}
// $blogArticle->md2html();
$poi->md2html();
// // Manage comments
// if ($blogArticle->is_commentable == "t") {
// $blogArticles_comments = new Kabano\BlogComments();
// $blogArticles_comments->listComments($blogArticle->content_id, ($user->rankIsHigher("premium")));
// Manage comments
if ($poi->is_commentable == "t") {
$pois_comments = new Kabano\BlogComments();
$pois_comments->listComments($poi->content_id, ($user->rankIsHigher("premium")));
// $i = 0;
// foreach ($blogArticles_comments->objs as $comment) {
// $comment->md2html();
// $comment->author_obj = new Kabano\User();
// $comment->author_obj->checkId($comment->author);
// }
// }
$i = 0;
foreach ($pois_comments->objs as $comment) {
$comment->md2html();
$comment->author_obj = new Kabano\User();
$comment->author_obj->checkId($comment->author);
}
}
// $tempUser = new Kabano\User();
// $tempUser->checkId($blogArticle->author);
// $blogArticle->author_name = $tempUser->name;
// unset($tempUser);
$tempUser = new Kabano\User();
$tempUser->checkId($poi->author);
$poi->author_name = $tempUser->name;
unset($tempUser);
// $head['title'] = $blogArticle->name;
// include ($config['views_folder']."d.blog.view.html");
// }
// }
// else {
// $notfound = 1;
// }
// break;
$head['title'] = $poi->name;
include ($config['views_folder']."d.blog.view.html");
// }
}
else {
$notfound = 1;
}
break;
}
?>