1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* $Id: category.php v 1.0 8 May 2004 hsalazar Exp $ |
4
|
|
|
* Module: Lexikon - glossary module |
5
|
|
|
* Version: v 1.00 |
6
|
|
|
* Release Date: 8 May 2004 |
7
|
|
|
* Author: hsalazar |
8
|
|
|
* Licence: GNU |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
// -- General Stuff -- // |
12
|
|
|
include( "admin_header.php" ); |
13
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
14
|
|
|
xoops_cp_header(); |
15
|
|
|
xoops_load('XoopsUserUtility'); |
16
|
|
|
$indexAdmin = new ModuleAdmin(); |
17
|
|
|
echo $indexAdmin->addNavigation('category.php'); |
18
|
|
|
$indexAdmin->addItemButton(_AM_LEXIKON_CREATECAT, 'category.php?op=addcat', 'add'); |
19
|
|
|
echo $indexAdmin->renderButton('left'); |
20
|
|
|
$op = ''; |
21
|
|
|
|
22
|
|
|
/* -- Available operations -- */ |
23
|
|
|
|
24
|
|
|
function categoryDefault() { |
|
|
|
|
25
|
|
|
$op = 'default'; |
|
|
|
|
26
|
|
|
include_once XOOPS_ROOT_PATH . "/class/xoopslists.php"; |
27
|
|
|
include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
28
|
|
|
|
29
|
|
|
$startentry = isset( $_GET['startentry'] ) ? intval( $_GET['startentry'] ) : 0; |
|
|
|
|
30
|
|
|
$startcat = isset( $_GET['startcat'] ) ? intval( $_GET['startcat'] ) : 0; |
31
|
|
|
$startsub = isset( $_GET['startsub'] ) ? intval( $_GET['startsub'] ) : 0; |
|
|
|
|
32
|
|
|
$datesub = isset( $_GET['datesub'] ) ? intval( $_GET['datesub'] ) : 0; |
|
|
|
|
33
|
|
|
|
34
|
|
|
global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule, $entryID, $pathIcon16; |
|
|
|
|
35
|
|
|
|
36
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
37
|
|
|
// lx_adminMenu(1, _AM_LEXIKON_CATS); |
|
|
|
|
38
|
|
|
$result01 = $xoopsDB -> query( "SELECT COUNT(*) |
39
|
|
|
FROM " . $xoopsDB -> prefix( "lxcategories" ) . " " ); |
40
|
|
|
list( $totalcategories ) = $xoopsDB -> fetchRow( $result01 ); |
41
|
|
|
|
42
|
|
|
$result02 = $xoopsDB -> query( "SELECT COUNT(*) |
43
|
|
|
FROM " . $xoopsDB -> prefix( "lxentries" ) . " |
44
|
|
|
WHERE submit = 0" ); |
45
|
|
|
list( $totalpublished ) = $xoopsDB -> fetchRow( $result02 ); |
|
|
|
|
46
|
|
|
|
47
|
|
|
$result03 = $xoopsDB -> query( "SELECT COUNT(*) |
48
|
|
|
FROM " . $xoopsDB -> prefix( "lxentries" ) . " |
49
|
|
|
WHERE submit = '1' AND request = '0' " ); |
50
|
|
|
list( $totalsubmitted ) = $xoopsDB -> fetchRow( $result03 ); |
|
|
|
|
51
|
|
|
|
52
|
|
|
$result04 = $xoopsDB -> query( "SELECT COUNT(*) |
53
|
|
|
FROM " . $xoopsDB -> prefix( "lxentries" ) . " |
54
|
|
|
WHERE submit = '1' AND request = '1' " ); |
55
|
|
|
list( $totalrequested ) = $xoopsDB -> fetchRow( $result04 ); |
|
|
|
|
56
|
|
|
|
57
|
|
|
// echo "<table width='100%' class='outer' style=\"margin-top: 6px; clear:both;\" cellspacing='2' cellpadding='3' border='0' ><tr>"; |
58
|
|
|
// echo "<td class='odd'>" . _AM_LEXIKON_TOTALENTRIES . "</td><td align='center' class='even'>" . $totalpublished . "</td>"; |
59
|
|
|
// if ($xoopsModuleConfig['multicats'] == 1) { |
60
|
|
|
// echo "<td class='odd'>" . _AM_LEXIKON_TOTALCATS . "</td><td align='center' class='even'>" . $totalcategories . "</td>"; |
61
|
|
|
// } |
62
|
|
|
// echo "<td class='odd'>" . _AM_LEXIKON_TOTALSUBM . "</td><td align='center' class='even'>" . $totalsubmitted . "</td> |
63
|
|
|
// <td class='odd'>" . _AM_LEXIKON_TOTALREQ . "</td><td align='center' class='even'>" . $totalrequested . "</td> |
64
|
|
|
// </tr></table> |
65
|
|
|
// <br /><br />"; |
66
|
|
|
|
67
|
|
|
if ($xoopsModuleConfig['multicats'] == 1) { |
68
|
|
|
/** |
69
|
|
|
* Code to show existing categories |
70
|
|
|
**/ |
71
|
|
|
|
72
|
|
|
echo" <table class='outer' width='100%' border='0'> |
73
|
|
|
<tr> |
74
|
|
|
<td colspan='7' class='odd'> |
75
|
|
|
<strong>". _AM_LEXIKON_SHOWCATS . ' (' . $totalcategories . ')'. "</strong></td></TR>"; |
76
|
|
|
echo "<tr>"; |
77
|
|
|
// create existing columns table //doppio |
78
|
|
|
$resultC1 = $xoopsDB -> query( "SELECT COUNT(*) |
79
|
|
|
FROM " . $xoopsDB -> prefix( "lxcategories" ) . " " ); |
80
|
|
|
list( $numrows ) = $xoopsDB -> fetchRow( $resultC1 ); |
81
|
|
|
|
82
|
|
|
$sql = "SELECT * |
83
|
|
|
FROM " . $xoopsDB -> prefix( "lxcategories" ) . " |
84
|
|
|
ORDER BY weight"; |
85
|
|
|
$resultC2 = $xoopsDB -> query( $sql, $xoopsModuleConfig['perpage'], $startcat ); |
86
|
|
|
|
87
|
|
|
echo "<th width='40' align='center'><b>" . _AM_LEXIKON_ID . "</b></td> |
88
|
|
|
<th align='center'><b>" . _AM_LEXIKON_WEIGHT . "</b></td> |
89
|
|
|
<th width='30%' align='center'><b>" . _AM_LEXIKON_CATNAME . "</b></td> |
90
|
|
|
<th width='10' align='center'><b>" . _AM_LEXIKON_ENTRIES . "</b></td> |
91
|
|
|
<th width='*' align='center'><b>" . _AM_LEXIKON_DESCRIP . "</b></td> |
92
|
|
|
<th width='60' align='center'><b>" . _AM_LEXIKON_ACTION . "</b></td> |
93
|
|
|
</tr>"; |
94
|
|
|
|
95
|
|
|
$class = "odd"; |
96
|
|
|
if ( $numrows > 0 ) // That is, if there ARE columns in the system |
97
|
|
|
{ |
98
|
|
|
while ( list( $categoryID, $name, $description, $total, $weight ) = $xoopsDB -> fetchrow( $resultC2 ) ) |
99
|
|
|
//while ( list( $categoryID, $name, $description, $total, $weight, ) = $xoopsDB -> fetchrow( $resultC2 ) ) |
|
|
|
|
100
|
|
|
{ |
101
|
|
|
$name = $myts -> htmlSpecialChars( $name ); |
102
|
|
|
// $description = $myts -> htmlSpecialChars(xoops_substr( strip_tags( $description ),0,60)); |
|
|
|
|
103
|
|
|
$description = strip_tags(htmlspecialchars_decode($description)); |
104
|
|
|
$modify = "<a href='category.php?op=mod&categoryID=" . $categoryID . "'><img src=" . $pathIcon16."/edit.png width='16' height='16' ALT='"._AM_LEXIKON_EDITCAT."'></a>"; |
105
|
|
|
$delete = "<a href='category.php?op=del&categoryID=" . $categoryID . "'><img src=" . $pathIcon16."/delete.png width='16' height='16' ALT='"._AM_LEXIKON_DELETECAT."'></a>"; |
106
|
|
|
|
107
|
|
|
echo "<tr class='" . $class . "'>"; |
108
|
|
|
$class = ($class == "even") ? "odd" : "even"; |
109
|
|
|
|
110
|
|
|
echo " |
111
|
|
|
<td align='center'>" . $categoryID . "</td> |
112
|
|
|
<td width='10' align='center'>" . $weight . "</td> |
113
|
|
|
<td align='left'><a href='../category.php?categoryID=" . $categoryID . "'>" . $name . "</td> |
114
|
|
|
<td align='left'>" . $total . "</td> |
115
|
|
|
<td align='left'>" . $description . "</td> |
116
|
|
|
<td align='center'> $modify $delete </td> |
117
|
|
|
</tr></DIV>"; |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
else // that is, $numrows = 0, there's no columns yet |
121
|
|
|
{ |
122
|
|
|
echo "<tr>"; |
123
|
|
|
echo "<td class='odd' align='center' colspan= '7'>"._AM_LEXIKON_NOCATS."</td>"; |
124
|
|
|
echo "</tr></DIV>"; |
125
|
|
|
$categoryID = '0'; |
|
|
|
|
126
|
|
|
} |
127
|
|
|
echo "</table>\n"; |
128
|
|
|
$pagenav = new XoopsPageNav( $numrows, $xoopsModuleConfig['perpage'], $startcat, 'startcat' ); |
129
|
|
|
echo '<div style="text-align:right;">' . $pagenav -> renderNav(8) . '</div>'; |
130
|
|
|
echo "<br /><br />\n"; |
131
|
|
|
echo "</div>"; |
132
|
|
|
} else { |
133
|
|
|
redirect_header( "index.php", 1, sprintf( _AM_LEXIKON_SINGLECAT, '' ) ); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Code to edit categories |
139
|
|
|
**/ |
140
|
|
|
function categoryEdit( $categoryID = '' ) { |
141
|
|
|
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php"; |
142
|
|
|
include_once XOOPS_ROOT_PATH."/class/uploader.php"; |
143
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
144
|
|
|
|
145
|
|
|
$weight = 1; |
146
|
|
|
$name = ''; |
147
|
|
|
$description = ''; |
148
|
|
|
$logourl = ''; |
149
|
|
|
|
150
|
|
|
Global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
151
|
|
|
|
152
|
|
|
// If there is a parameter, and the id exists, retrieve data: we're editing a column |
153
|
|
|
if ( $categoryID ) { |
154
|
|
|
$result = $xoopsDB -> query( " |
155
|
|
|
SELECT categoryID, name, description, total, weight,logourl |
156
|
|
|
FROM " . $xoopsDB -> prefix( "lxcategories" ) . " |
157
|
|
|
WHERE categoryID = '$categoryID'" ); |
158
|
|
|
|
159
|
|
|
list( $categoryID, $name, $description, $total, $weight, $logourl ) = $xoopsDB -> fetchrow( $result ); |
|
|
|
|
160
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
161
|
|
|
$name = $myts->htmlSpecialChars($name); |
162
|
|
|
//permissions |
163
|
|
|
$member_handler = & xoops_gethandler('member'); |
164
|
|
|
$group_list = & $member_handler -> getGroupList(); |
165
|
|
|
$gperm_handler = & xoops_gethandler('groupperm'); |
166
|
|
|
|
167
|
|
|
$groups = $gperm_handler -> getGroupIds("lexikon_view", $categoryID, $xoopsModule -> getVar('mid')); |
168
|
|
|
$groups = $groups; |
|
|
|
|
169
|
|
|
if ( $xoopsDB -> getRowsNum( $result ) == 0 ) { |
170
|
|
|
redirect_header( "index.php", 1, _AM_LEXIKON_NOCATTOEDIT ); |
171
|
|
|
exit(); |
|
|
|
|
172
|
|
|
} |
173
|
|
|
if ( $xoopsDB -> getRowsNum( $result ) == 0 ) { |
174
|
|
|
redirect_header( "index.php", 1, _AM_LEXIKON_NOCATTOEDIT ); |
175
|
|
|
exit(); |
|
|
|
|
176
|
|
|
} |
177
|
|
|
//$myts =& MyTextSanitizer::getInstance(); |
|
|
|
|
178
|
|
|
// lx_adminMenu(1, _AM_LEXIKON_CATS); |
179
|
|
|
|
180
|
|
|
echo "<h3 style=\"color: #2F5376; margin-top: 6px; \">" . _AM_LEXIKON_CATSHEADER . "</h3>"; |
181
|
|
|
$sform = new XoopsThemeForm( _AM_LEXIKON_MODCAT . ": $name" , "op", xoops_getenv( 'PHP_SELF' ) ); |
182
|
|
|
} else { |
183
|
|
|
//$myts =& MyTextSanitizer::getInstance(); |
|
|
|
|
184
|
|
|
// lx_adminMenu(1, _AM_LEXIKON_CATS); |
185
|
|
|
$groups = true; |
186
|
|
|
echo "<h3 style=\"color: #2F5376; margin-top: 6px; \">" . _AM_LEXIKON_CATSHEADER . "</h3>"; |
187
|
|
|
$sform = new XoopsThemeForm( _AM_LEXIKON_NEWCAT, "op", xoops_getenv( 'PHP_SELF' ) ); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
$sform -> setExtra( 'enctype="multipart/form-data"' ); |
191
|
|
|
$sform -> addElement( new XoopsFormText( _AM_LEXIKON_CATNAME, 'name', 50, 80, $name ), true ); |
192
|
|
|
|
193
|
|
|
$editor = lx_getWysiwygForm( _AM_LEXIKON_CATDESCRIPT, 'description', $description, 7, 60 ); |
194
|
|
|
$sform -> addElement( $editor,true ); |
195
|
|
|
unset($editor); |
196
|
|
|
|
197
|
|
|
$sform -> addElement( new XoopsFormText( _AM_LEXIKON_CATPOSIT, 'weight', 4, 4, $weight ), true ); |
198
|
|
|
$sform -> addElement( new XoopsFormHidden( 'categoryID', $categoryID ) ); |
199
|
|
|
//CategoryImage |
200
|
|
|
if ($xoopsModuleConfig['useshots'] == 1) { |
201
|
|
|
//CategoryImage :: Common querys from Article module by phppp |
202
|
|
|
$image_option_tray = new XoopsFormElementTray("<b>"._AM_LEXIKON_CATIMGUPLOAD."</b>", "<br />"); |
203
|
|
|
$image_option_tray->addElement(new XoopsFormFile("", "userfile","")); |
204
|
|
|
$sform->addElement($image_option_tray); |
205
|
|
|
unset($image_tray); |
206
|
|
|
unset($image_option_tray); |
207
|
|
|
|
208
|
|
|
$path_catimg = "modules/".$xoopsModule->getVar('dirname')."/images/uploads"; |
209
|
|
|
$image_option_tray = new XoopsFormElementTray(_AM_LEXIKON_CATIMAGE."<br />"._AM_LEXIKON_CATIMG_DSC."<br />".$path_catimg, "<br />"); |
210
|
|
|
//$image_option_tray = new XoopsFormElementTray(_AM_LEXIKON_CATIMAGE.''); |
|
|
|
|
211
|
|
|
$image_array =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/".$path_catimg."/"); |
212
|
|
|
array_unshift($image_array, _NONE); |
213
|
|
|
|
214
|
|
|
$image_select = new XoopsFormSelect("", "logourl", $logourl); |
215
|
|
|
$image_select->addOptionArray($image_array); |
216
|
|
|
$image_select->setExtra("onchange=\"showImgSelected('img', 'logourl', '/".$path_catimg."/', '', '" . XOOPS_URL . "')\""); |
217
|
|
|
$image_tray = new XoopsFormElementTray("", " "); |
218
|
|
|
$image_tray->addElement($image_select); |
219
|
|
|
if (!empty($logourl) && file_exists(XOOPS_ROOT_PATH . "/" .$path_catimg."/" . $logourl)){ |
220
|
|
|
$image_tray->addElement(new XoopsFormLabel("", "<div style=\"padding: 4px;\"><img src=\"" . XOOPS_URL . "/" .$path_catimg."/" . $logourl . "\" name=\"img\" id=\"img\" alt=\"\" /></div>")); |
221
|
|
|
} else { |
222
|
|
|
$image_tray->addElement(new XoopsFormLabel("", "<div style=\"padding: 4px;\"><img src=\"" . XOOPS_URL . "/" .$path_catimg."/blank.gif\" name=\"img\" id=\"img\" alt=\"\" /></div>")); |
223
|
|
|
} |
224
|
|
|
$image_option_tray->addElement($image_tray); |
225
|
|
|
$sform->addElement($image_option_tray); |
226
|
|
|
} |
227
|
|
|
$sform -> addElement(new XoopsFormSelectGroup(_AM_LEXIKON_CAT_GROUPSVIEW, "groups", true, $groups, 5, true)); |
228
|
|
|
|
229
|
|
|
$button_tray = new XoopsFormElementTray( '', '' ); |
230
|
|
|
$hidden = new XoopsFormHidden( 'op', 'addcategory' ); |
231
|
|
|
$button_tray -> addElement( $hidden ); |
232
|
|
|
|
233
|
|
|
// No ID for column -- then it's new column, button says 'Create' |
234
|
|
View Code Duplication |
if ( !$categoryID ) { |
|
|
|
|
235
|
|
|
$butt_create = new XoopsFormButton( '', '', _AM_LEXIKON_CREATE, 'submit' ); |
236
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
237
|
|
|
$button_tray->addElement( $butt_create ); |
238
|
|
|
|
239
|
|
|
$butt_clear = new XoopsFormButton( '', '', _AM_LEXIKON_CLEAR, 'reset' ); |
240
|
|
|
$button_tray->addElement( $butt_clear ); |
241
|
|
|
|
242
|
|
|
$butt_cancel = new XoopsFormButton( '', '', _AM_LEXIKON_CANCEL, 'button' ); |
243
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
244
|
|
|
$button_tray->addElement( $butt_cancel ); |
245
|
|
|
} else // button says 'Update' |
246
|
|
|
{ |
247
|
|
|
$butt_create = new XoopsFormButton( '', '', _AM_LEXIKON_MODIFY, 'submit' ); |
248
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
249
|
|
|
$button_tray->addElement( $butt_create ); |
250
|
|
|
|
251
|
|
|
$butt_cancel = new XoopsFormButton( '', '', _AM_LEXIKON_CANCEL, 'button' ); |
252
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
253
|
|
|
$button_tray->addElement( $butt_cancel ); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
$sform -> addElement( $button_tray ); |
257
|
|
|
$sform -> display(); |
258
|
|
|
unset( $hidden ); |
259
|
|
|
// xoops_cp_footer(); |
|
|
|
|
260
|
|
|
// break; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Code to delete existing categories |
265
|
|
|
**/ |
266
|
|
|
function categoryDelete($categoryID = '') { |
|
|
|
|
267
|
|
|
//global $xoopsDB, $xoopsConfig; |
|
|
|
|
268
|
|
|
global $xoopsConfig, $xoopsDB, $xoopsModule; |
|
|
|
|
269
|
|
|
$idc = isset($_POST['categoryID']) ? intval($_POST['categoryID']) : intval($_GET['categoryID']); |
270
|
|
|
if ($idc == '') $idc = $_GET['categoryID']; |
271
|
|
|
if ($idc <= 0) { |
272
|
|
|
header('location: category.php'); |
273
|
|
|
die(); |
|
|
|
|
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
$ok = isset($_POST['ok']) ? intval($_POST['ok']) : 0; |
277
|
|
|
$result = $xoopsDB -> query( "SELECT categoryID, name FROM " . $xoopsDB -> prefix( "lxcategories" ) . " WHERE categoryID = $idc" ); |
278
|
|
|
list( $categoryID, $name ) = $xoopsDB -> fetchrow( $result ); |
279
|
|
|
// confirmed, so delete |
280
|
|
|
if ( $ok == 1 ) { |
281
|
|
|
//get all entries in the category |
282
|
|
|
$result3=$xoopsDB->query("SELECT entryID from ".$xoopsDB->prefix("lxentries")." where categoryID = $idc"); |
283
|
|
|
//now for each entry, delete the coments |
284
|
|
|
while ( list($entryID)=$xoopsDB->fetchRow($result3) ) { |
285
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $entryID); |
286
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'term', $entryID); |
287
|
|
|
} |
288
|
|
|
$xoopsDB->query("DELETE FROM ".$xoopsDB->prefix('lxcategories')." WHERE categoryID='$idc'"); |
289
|
|
|
$result2 = $xoopsDB -> query( "DELETE FROM " .$xoopsDB -> prefix("lxentries")." WHERE categoryID = $idc"); |
|
|
|
|
290
|
|
|
// remove permissions |
291
|
|
|
xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_view', $categoryID); |
292
|
|
|
xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_submit', $categoryID); |
293
|
|
|
xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_approve', $categoryID); |
294
|
|
|
xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_request', $categoryID); |
295
|
|
|
// delete notifications |
296
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'global', $categoryID); |
297
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $categoryID); |
298
|
|
|
|
299
|
|
|
redirect_header("category.php",1,sprintf( _AM_LEXIKON_CATISDELETED, $name ) ); |
300
|
|
|
exit(); |
|
|
|
|
301
|
|
|
} else { |
302
|
|
|
//xoops_cp_header(); |
303
|
|
|
xoops_confirm(array('op' => 'del', 'categoryID' => $categoryID, 'ok' => 1, 'name' => $name ), 'category.php', _AM_LEXIKON_DELETETHISCAT . "<br /><br>" . $name, _AM_LEXIKON_DELETE ); |
304
|
|
|
} |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
function categorySave ($categoryID = '') { |
|
|
|
|
308
|
|
|
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php"; |
309
|
|
|
include_once XOOPS_ROOT_PATH."/class/uploader.php"; |
310
|
|
|
Global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule, $xoopsDB, $myts, $categoryID; |
|
|
|
|
311
|
|
|
//print_r ($_POST); |
|
|
|
|
312
|
|
|
$categoryID = isset( $_POST['categoryID'] ) ? intval( $_POST['categoryID'] ) : intval( $_GET['categoryID'] ); |
313
|
|
|
$weight = isset($_POST['weight'] ) ? intval($_POST['weight']) : intval($_GET['weight']); |
314
|
|
|
$name = isset($_POST['name'] ) ? htmlSpecialChars($_POST['name']) : htmlSpecialChars($_GET['name']); |
|
|
|
|
315
|
|
|
$description = isset($_POST['description'] ) ? htmlSpecialChars($_POST['description']) : htmlSpecialChars($_GET['description']); |
316
|
|
|
//$description = $myts->xoopsCodeDecode($description, $allowimage = 0); |
|
|
|
|
317
|
|
|
$description = $myts -> xoopsCodeDecode($myts->censorString($description), $allowimage = 1); |
318
|
|
|
$name = $myts->addSlashes($_POST['name']); |
319
|
|
|
$logourl = $myts->addSlashes($_POST["logourl"]); |
|
|
|
|
320
|
|
|
$groups = isset($_POST['groups']) ? $_POST['groups'] : array(); |
321
|
|
|
// image upload |
322
|
|
|
$logourl = ""; |
323
|
|
|
$maxfilesize = 30000; |
324
|
|
|
$maxfilewidth = 128; |
325
|
|
|
$maxfileheight = 128; |
326
|
|
|
if (!empty($_FILES['userfile']['name'])) { |
327
|
|
|
$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); |
328
|
|
|
$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH ."/modules/".$xoopsModule->getVar('dirname')."/images/uploads/", $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); |
329
|
|
|
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
330
|
|
|
if (!$uploader->upload()) { |
331
|
|
|
echo $uploader->getErrors(); |
332
|
|
|
} else { |
333
|
|
|
echo '<h4>'._AM_LEXIKON_FILESUCCESS.'</h4>'; |
334
|
|
|
$logourl = $uploader->getSavedFileName(); |
335
|
|
|
} |
336
|
|
|
} else { |
337
|
|
|
echo $uploader->getErrors(); |
338
|
|
|
} |
339
|
|
|
} |
340
|
|
|
$logourl = empty($logourl)?(empty($_POST['logourl'])?"":$_POST['logourl']):$logourl; |
341
|
|
|
|
342
|
|
|
// Run the query and update the data |
343
|
|
|
if ( !$_POST['categoryID'] ) { |
344
|
|
|
if ( $xoopsDB -> query( "INSERT INTO " . $xoopsDB -> prefix( "lxcategories" ) . " (categoryID, name, description, weight, logourl) |
345
|
|
|
VALUES ('', '$name', '$description', '$weight', '$logourl')" ) ) { |
346
|
|
|
$newid = $xoopsDB->getInsertId(); |
347
|
|
|
// Increment author's posts count (only if it's a new definition) |
348
|
|
View Code Duplication |
if (is_object($xoopsUser) && empty($categoryID)) { |
|
|
|
|
349
|
|
|
$member_handler = &xoops_gethandler('member'); |
350
|
|
|
$submitter =& $member_handler -> getUser($uid); |
|
|
|
|
351
|
|
|
if (is_object($submitter) ) { |
352
|
|
|
$submitter -> setVar('posts',$submitter -> getVar('posts') + 1); |
353
|
|
|
$res=$member_handler -> insertUser($submitter, true); |
|
|
|
|
354
|
|
|
unset($submitter); |
355
|
|
|
} |
356
|
|
|
} |
357
|
|
|
//notification |
358
|
|
|
if(!empty($xoopsModuleConfig['notification_enabled']) ){ |
359
|
|
|
if ($newid == 0) { |
360
|
|
|
$newid = $xoopsDB -> getInsertId(); |
361
|
|
|
} |
362
|
|
|
global $xoopsModule; |
|
|
|
|
363
|
|
|
$notification_handler =& xoops_gethandler('notification'); |
364
|
|
|
$tags = array(); |
365
|
|
|
$tags['ITEM_NAME'] = $name; |
366
|
|
|
$tags['ITEM_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/category.php?categoryID=' . $newid; |
367
|
|
|
$notification_handler->triggerEvent( 'global', 0, 'new_category', $tags); |
368
|
|
|
} |
369
|
|
|
lx_save_Permissions($groups, $categoryID, "lexikon_view"); |
370
|
|
|
redirect_header( "category.php", 1, _AM_LEXIKON_CATCREATED ); |
371
|
|
|
exit(); |
|
|
|
|
372
|
|
|
} else { |
373
|
|
|
redirect_header( "index.php", 1, _AM_LEXIKON_NOTUPDATED ); |
374
|
|
|
exit(); |
|
|
|
|
375
|
|
|
} |
376
|
|
|
} else { |
377
|
|
|
if ( $xoopsDB -> queryF( " |
378
|
|
|
UPDATE " . $xoopsDB -> prefix( "lxcategories" ) . " |
379
|
|
|
SET name = '$name', description = '$description', weight = '$weight' , logourl = '$logourl' |
380
|
|
|
WHERE categoryID = '$categoryID'" ) ) { |
381
|
|
|
lx_save_Permissions($groups, $categoryID, "lexikon_view"); |
382
|
|
|
redirect_header( "category.php", 1, _AM_LEXIKON_CATMODIFIED ); |
383
|
|
|
exit(); |
|
|
|
|
384
|
|
|
} else { |
385
|
|
|
redirect_header( "index.php", 1, _AM_LEXIKON_NOTUPDATED ); |
386
|
|
|
exit(); |
|
|
|
|
387
|
|
|
} |
388
|
|
|
} |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* Available operations |
393
|
|
|
**/ |
394
|
|
|
|
395
|
|
|
$op = 'default'; |
396
|
|
View Code Duplication |
if (isset($_POST['op'])) { |
|
|
|
|
397
|
|
|
$op=$_POST['op']; |
398
|
|
|
} else { |
399
|
|
|
if (isset($_GET['op'])) { |
400
|
|
|
$op=$_GET['op']; |
401
|
|
|
} |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
switch ( $op ) { |
405
|
|
|
case "mod": |
406
|
|
|
$categoryID = isset( $_POST['categoryID'] ) ? intval( $_POST['categoryID'] ) : intval( $_GET['categoryID'] ); |
407
|
|
|
categoryEdit( $categoryID ); |
408
|
|
|
break; |
409
|
|
|
|
410
|
|
|
case "addcat": |
411
|
|
|
categoryEdit(); |
412
|
|
|
break; |
413
|
|
|
|
414
|
|
|
case "addcategory": |
415
|
|
|
categorySave(); |
416
|
|
|
break; |
417
|
|
|
|
418
|
|
|
case "del": |
419
|
|
|
categoryDelete(); |
420
|
|
|
break; |
421
|
|
|
|
422
|
|
|
case "default": |
423
|
|
|
default: |
424
|
|
|
categoryDefault(); |
425
|
|
|
break; |
426
|
|
|
} |
427
|
|
|
xoops_cp_footer(); |
428
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.