CMS
Version 3.9
forum_delete.inc
Go to the documentation of this file.
1
<?php
2
/**************************************************************
3
4
Copyright (c) 2010 Sonjara, Inc
5
6
Permission is hereby granted, free of charge, to any person
7
obtaining a copy of this software and associated documentation
8
files (the "Software"), to deal in the Software without
9
restriction, including without limitation the rights to use,
10
copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the
12
Software is furnished to do so, subject to the following
13
conditions:
14
15
The above copyright notice and this permission notice shall be
16
included in all copies or substantial portions of the Software.
17
18
Except as contained in this notice, the name(s) of the above
19
copyright holders shall not be used in advertising or otherwise
20
to promote the sale, use or other dealings in this Software
21
without prior written authorization.
22
23
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30
OTHER DEALINGS IN THE SOFTWARE.
31
32
*****************************************************************/
33
34
Fakoli::using
(
"forum"
);
35
Fakoli::assertRole
(
"admin,moderator"
);
36
37
$forum_id
= checkNumeric($_GET[
"forum_id"
]);
38
39
if
(!
$forum_id
)
40
redirect($_SERVER[
'HTTP_REFERER'
]);
41
42
$forum
=
new
Forum
(
$forum_id
);
43
44
/*
45
* We already know there are no messages b/c we were allowed to
46
* delete, but we need to delete all related records:
47
*
48
* ForumSiteXref
49
* ForumTopic
50
* ForumSubscription
51
*/
52
if
(
$forum
->allowDelete())
53
{
54
$xrefs
= query(
ForumSiteXref
,
"WHERE forum_id={$forum_id}"
);
55
if
(count(
$xrefs
) > 0)
56
{
57
foreach
(
$xrefs
as $xref)
58
$xref->delete();
59
}
60
61
$topics
= query(
ForumTopic
,
"WHERE forum_id={$forum_id}"
);
62
trace(
" ForumID: $forum_id"
);
63
if
(count(
$topics
) > 0)
64
{
65
foreach
(
$topics
as
$topic
)
66
{
67
$topic
->delete();
68
}
69
}
70
71
$subscriptions
= query(
ForumSubscription
,
"WHERE forum_id={$forum_id}"
);
72
if
(count(
$subscriptions
) > 0)
73
{
74
foreach
(
$subscriptions
as $subscription)
75
{
76
$subscription->delete();
77
}
78
}
79
80
$forum
->delete();
81
}
82
83
redirect(
"/restricted/forum_list"
);
84
85
?>
$subscriptions
$subscriptions
Definition:
blog_subscription_preferences.inc:53
Fakoli\using
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition:
core.inc:116
Fakoli\assertRole
static assertRole($role, $redirect="", $message="")
Assert that the user has one of the specified roles.
Definition:
core.inc:297
Forum
Definition:
forum.inc:42
ForumSiteXref
Definition:
forum.inc:141
ForumSubscription
Definition:
forum_subscription.inc:12
ForumTopic
Definition:
forum.inc:249
$forum_id
$forum_id
Definition:
forum_delete.inc:37
$forum
$forum
Definition:
forum_delete.inc:42
$topics
$topics
Definition:
group_form.inc:52
$xrefs
$xrefs
Definition:
survey_questions.inc:59
$topic
$topic
Definition:
topic_form.inc:42
code
cms.sonjara.com
cms
components
forum
handlers
forum_delete.inc
Generated on Tue Mar 23 2021 15:36:13 for CMS by
1.9.1