The best way to learn how to use the WebCore is by example. See the documentation for more information.
The requested URL is always shown first; if a page uses one or more WebCore templates, those are shown afterwards.
Source for: https://www.earthli.com/news/delete_comment.php
Uses WebCore template(s):
00 <?php
01
02 /****************************************************************************
03
04 Copyright (c) 2002-2014 Marco Von Ballmoos
05
06 This file is part of earthli News.
07
08 earthli News is free software; you can redistribute it and/or modify
09 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 earthli News is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with earthli News; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 For more information about the earthli News, visit:
23
24 http://www.earthli.com/software/webcore/news
25
26 ****************************************************************************/
27
28 require_once ('news/start.php');
29 require_once ($App->page_template_for ('webcore/pages/delete_comment.php'));
30 ?>
31
Source for template: webcore/pages/delete_comment.php
00 <?php
01
02 /****************************************************************************
03
04 Copyright (c) 2002-2014 Marco Von Ballmoos
05
06 This file is part of earthli WebCore.
07
08 earthli WebCore is free software; you can redistribute it and/or modify
09 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 earthli WebCore is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with earthli WebCore; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 For more information about the earthli WebCore, visit:
23
24 http://www.earthli.com/software/webcore
25
26 ****************************************************************************/
27
28 $id = read_var ('id');
29 $folder_query = $App->login->folder_query ();
30 $folder = $folder_query->folder_for_comment_at_id ($id);
31
32 if (isset ($folder))
33 {
34 $entry_query = $folder->entry_query ();
35 $entry = $entry_query->object_for_comment_at_id ($id);
36
37 if (isset ($entry))
38 {
39 $com_query = $entry->comment_query ();
40 $comment = $com_query->object_at_id ($id);
41 }
42 }
43
44 if (isset ($comment) && $App->login->is_allowed (Privilege_set_comment, Privilege_delete, $comment))
45 {
46 $class_name = $App->final_class_name ('DELETE_OBJECT_IN_FOLDER_FORM', 'webcore/forms/delete_form.php', 'comment');
47 /** @var DELETE_OBJECT_IN_FOLDER_FORM $form */
48 $form = new $class_name ($folder, Privilege_set_comment);
49
50 $form->process_existing ($comment);
51 if ($form->committed ())
52 {
53 if ($App->login->is_allowed (Privilege_set_comment, Privilege_view_hidden, $folder) && ! $form->value_for ('purge'))
54 {
55 $App->return_to_referer ($comment->home_page ());
56 }
57 else
58 {
59 $Env->redirect_local ($entry->home_page ());
60 }
61 }
62
63 $Page->title->add_object ($folder);
64 $Page->title->add_object ($entry);
65 $Page->title->add_object ($comment);
66 $Page->title->subject = 'Delete Comment';
67
68 $Page->location->add_folder_link ($folder);
69 $Page->location->add_object_link ($entry);
70 $Page->location->add_object_link ($comment, '', '{icons}buttons/reply');
71 $Page->location->append ($Page->title->subject, '', '{icons}/buttons/delete');
72
73 $Page->start_display ();
74 ?>
75 <div class="main-box">
76 <div class="form-content">
77 <?php
78 $form->display ();
79 ?>
80 </div>
81 </div>
82 <?php
83 $Page->finish_display ();
84 }
85 else
86 {
87 $Page->raise_security_violation ('You are not allowed to delete this comment.', $folder);
88 }
89 ?>