-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtag.php
140 lines (124 loc) · 4.29 KB
/
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* Tag page
*
* @copyright http://smartfactory.ca The SmartFactory
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
* @since 1.0
* @author marcan aka Marc-André Lanciault <marcan@smartfactory.ca>
* @package imtagging
*
*/
/**
* Edit a Tag
*
* @param object $tagObj ImtaggingTag object to be edited
*/
function edittag($tagObj) {
global $imtagging_tag_handler, $icmsTpl;
if (!$tagObj->isNew()) {
if (!$tagObj->userCanEditAndDelete()) {
redirect_header($tagObj->getItemLink(true), 3, _NOPERM);
}
$tagObj->hideFieldFromForm(array(
'tag_published_date',
'tag_uid',
'meta_keywords',
'meta_description',
'short_url'));
$sform = $tagObj->getSecureForm(_MD_IMTAGGING_TAG_EDIT, 'addtag');
$sform->assign($icmsTpl, 'imtagging_tagform');
$icmsTpl->assign('imtagging_category_path', $tagObj->getVar('tag_title') . ' > ' . _EDIT);
} else {
if (!$imtagging_tag_handler->userCanSubmit()) {
redirect_header(IMTAGGING_URL, 3, _NOPERM);
}
$tagObj->setVar('tag_uid', icms::$user->uid());
$tagObj->setVar('tag_published_date', time());
$tagObj->hideFieldFromForm(array(
'tag_published_date',
'tag_uid',
'meta_keywords',
'meta_description',
'short_url'));
$sform = $tagObj->getSecureForm(_MD_IMTAGGING_TAG_SUBMIT, 'addtag');
$sform->assign($icmsTpl, 'imtagging_tagform');
$icmsTpl->assign('imtagging_category_path', _SUBMIT);
}
}
include_once 'header.php';
$xoopsOption['template_main'] = 'imtagging_tag.html';
include_once ICMS_ROOT_PATH . '/header.php';
$imtagging_tag_handler = icms_getModulehandler('tag');
/**
* Use a naming convention that indicates the source of the content of the variable
*/
$clean_op = '';
if (isset($_GET['op'])) $clean_op = $_GET['op'];
if (isset($_POST['op'])) $clean_op = $_POST['op'];
/**
* Again, use a naming convention that indicates the source of the content of the variable
*/
$clean_tag_id = isset($_GET['tag_id']) ? (int) ($_GET['tag_id']) : 0;
$tagObj = $imtagging_tag_handler->get($clean_tag_id);
/**
* Create a whitelist of valid values, be sure to use appropriate types for each value
* Be sure to include a value for no parameter, if you have a default condition
*/
$valid_op = array(
'mod',
'addtag',
'del',
'');
/**
* Only proceed if the supplied operation is a valid operation
*/
if (in_array($clean_op, $valid_op, TRUE)) {
switch ($clean_op) {
case "mod":
if ($clean_tag_id > 0 && $tagObj->isNew()) {
redirect_header(icms_getPreviousPage('index.php'), 3, _NOPERM);
}
edittag($tagObj);
break;
case "addtag":
if (!icms::$security->check()) {
redirect_header(icms_getPreviousPage('index.php'), 3, _MD_IMTAGGING_SECURITY_CHECK_FAILED . implode('<br />', icms::$security->getErrors()));
}
$controller = new icms_ipf_Controller($imtagging_tag_handler);
$controller->storeFromDefaultForm(_MD_IMTAGGING_TAG_CREATED, _MD_IMTAGGING_TAG_MODIFIED);
break;
case "del":
if (!$tagObj->userCanEditAndDelete()) {
redirect_header($tagObj->getItemLink(true), 3, _NOPERM);
}
if (isset($_POST['confirm'])) {
if (!icms::$security->check()) {
redirect_header($impresscms->urls['previouspage'], 3, _MD_IMTAGGING_SECURITY_CHECK_FAILED . implode('<br />', icms::$security->getErrors()));
}
}
$controller = new icms_ipf_Controller($imtagging_tag_handler);
$controller->handleObjectDeletionFromUserSide();
$icmsTpl->assign('imtagging_category_path', $tagObj->getVar('tag_title') . ' > ' . _DELETE);
break;
default:
if ($tagObj && !$tagObj->isNew() && $tagObj->accessGranted()) {
$icmsTpl->assign('imtagging_tag', $tagObj->toArray());
$icmsTpl->assign('imtagging_category_path', $tagObj->getVar('tag_title'));
} else {
redirect_header(IMTAGGING_URL, 3, _NOPERM);
}
if ($icmsModuleConfig['com_rule'] && $tagObj->getVar('tag_cancomment')) {
$icmsTpl->assign('imtagging_tag_comment', true);
include_once ICMS_ROOT_PATH . '/include/comment_view.php';
}
break;
}
/**
* Generating meta information for this page
*/
$icms_metagen = new icms_ipf_Metagen($tagObj->getVar('tag_title'), $tagObj->getVar('meta_keywords', 'n'), $tagObj->getVar('meta_description', 'n'));
$icms_metagen->createMetaTags();
}
$icmsTpl->assign('imtagging_module_home', icms_getModuleName(true, true));
include_once 'footer.php';