-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdelete_tag.php
81 lines (69 loc) · 2.31 KB
/
delete_tag.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
*
* @category modules
* @package news_img
* @author WBCE Community
* @copyright 2004-2009, Ryan Djurovich
* @copyright 2009-2010, Website Baker Org. e.V.
* @copyright 2019-, WBCE Community
* @link https://www.wbce.org/
* @license http://www.gnu.org/licenses/gpl.html
* @platform WBCE
*
*/
require_once __DIR__.'/functions.inc.php';
// Include WB admin wrapper script
$update_when_modified = false; // Tells script to update when this page was last updated
require(WB_PATH.'/modules/admin.php');
$tag_id = $admin->checkIDKEY('tag_id', 0, 'GET');
$section_id = (isset($_GET['section_id']) ? intval($_GET['section_id']) : null);
if (!$tag_id || !$section_id){
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']
.' (IDKEY) '.__FILE__.':'.__LINE__,
ADMIN_URL.'/pages/index.php');
$admin->print_footer();
exit();
}
$tag_id = intval($tag_id);
// get tag
$tag = mod_nwi_get_tag($tag_id);
// remove tag-to-posts-mappings
$database->query(sprintf(
"DELETE FROM `%smod_news_img_tags_posts` WHERE `tag_id`=$tag_id",
TABLE_PREFIX
));
$sections = explode(",",$tag['sections']);
// if it's a global tag...
// (in fact, if this is the case, there should be only one item in the $sections
// array)
if(in_array('0',$sections)) {
// remove all tag-to-section-mappings
$database->query(sprintf(
"DELETE FROM `%smod_news_img_tags_sections` WHERE `tag_id`=$tag_id",
TABLE_PREFIX
));
// remove tag
$database->query(sprintf(
"DELETE FROM `%smod_news_img_tags` WHERE `tag_id`=$tag_id",
TABLE_PREFIX
));
} else {
// remove the local tag
$database->query(sprintf(
"DELETE FROM `%smod_news_img_tags_sections` WHERE `section_id`=%d AND `tag_id`=%d",
TABLE_PREFIX, intval($section_id), $tag_id
));
$database->query(sprintf(
"DELETE FROM `%smod_news_img_tags` WHERE `tag_id`=$tag_id",
TABLE_PREFIX
));
}
// Check if there is a db error, otherwise say successful
if($database->is_error()) {
$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'&tab=s');
} else {
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'&tab=s');
}
// Print admin footer
$admin->print_footer();