1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Module: lexikon |
5
|
|
|
* Version: v 1.00 |
6
|
|
|
* Release Date: 18 Dec 2011 |
7
|
|
|
* Author: Yerres |
8
|
|
|
* Licence: GNU |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
View Code Duplication |
if (is_object($xoopsUser)) { |
|
|
|
|
12
|
|
|
$xoopsModule = XoopsModule::getByDirname('lexikon'); |
13
|
|
|
if (!$xoopsUser->isAdmin($xoopsModule->mid())) { |
14
|
|
|
redirect_header(XOOPS_URL . '/', 1, _NOPERM); |
15
|
|
|
} |
16
|
|
|
} else { |
17
|
|
|
redirect_header(XOOPS_URL . '/', 1, _NOPERM); |
18
|
|
|
} |
19
|
|
|
/** |
20
|
|
|
* Function used to display an horizontal menu inside the admin panel |
21
|
|
|
* Enable webmasters to navigate thru the module's features. |
22
|
|
|
* Each time you select an option in the admin panel of the news module, this option is highlighted in this menu |
23
|
|
|
* @package lexikon |
24
|
|
|
* @orig author: hsalazar, The smartfactory |
25
|
|
|
* @copyright (c) XOOPS Project (http://xoops.org) |
26
|
|
|
* @param int $currentoption |
27
|
|
|
* @param string $breadcrumb |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
function lx_adminMenu($currentoption = 0, $breadcrumb = '') |
31
|
|
|
{ |
32
|
|
|
include_once XOOPS_ROOT_PATH . '/class/template.php'; |
33
|
|
|
|
34
|
|
|
global $xoopsDB, $xoopsModule, $xoopsConfig; |
|
|
|
|
35
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
|
|
|
36
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/lexikon/language/' . $xoopsConfig['language'] . '/modinfo.php'; |
37
|
|
|
} else { |
38
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/lexikon/language/english/modinfo.php'; |
39
|
|
|
} |
40
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
|
|
|
41
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/lexikon/language/' . $xoopsConfig['language'] . '/admin.php'; |
42
|
|
|
} else { |
43
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/lexikon/language/english/admin.php'; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
include __DIR__ . '/menu.php'; |
47
|
|
|
|
48
|
|
|
$tpl = new XoopsTpl(); |
49
|
|
|
$tpl->assign(array( |
50
|
|
|
'headermenu' => $headermenu, |
|
|
|
|
51
|
|
|
'adminmenu' => $adminmenu, |
|
|
|
|
52
|
|
|
'current' => $currentoption, |
53
|
|
|
'breadcrumb' => $breadcrumb, |
54
|
|
|
'headermenucount' => count($headermenu) |
55
|
|
|
)); |
56
|
|
|
$tpl->display('db:lx_adminmenu.tpl'); |
57
|
|
|
echo "<br>\n"; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Verify that a field exists inside a mysql table |
62
|
|
|
* |
63
|
|
|
* @package Lexikon |
64
|
|
|
* @author Instant Zero (http://xoops.instant-zero.com) |
65
|
|
|
* @copyright (c) Instant Zero |
66
|
|
|
* @param $fieldname |
67
|
|
|
* @param $table |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
function lx_FieldExists($fieldname, $table) |
71
|
|
|
{ |
72
|
|
|
global $xoopsDB; |
|
|
|
|
73
|
|
|
$result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); |
74
|
|
|
|
75
|
|
|
return ($xoopsDB->getRowsNum($result) > 0); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Add a field to a mysql table |
80
|
|
|
* |
81
|
|
|
* @package Lexikon |
82
|
|
|
* @author Instant Zero (http://xoops.instant-zero.com) |
83
|
|
|
* @copyright (c) Instant Zero |
84
|
|
|
* @param $field |
85
|
|
|
* @param $table |
86
|
|
|
* @return |
87
|
|
|
*/ |
88
|
|
|
|
89
|
|
|
function lx_AddField($field, $table) |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
global $xoopsDB; |
|
|
|
|
92
|
|
|
//naja ! |
93
|
|
|
$result = $xoopsDB->queryF('ALTER TABLE ' . $table . ' ADD ' . $field . ''); |
94
|
|
|
|
95
|
|
|
return $result; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Change a field to a mysql table |
100
|
|
|
* desuet |
101
|
|
|
* @package Lexikon |
102
|
|
|
* @author Instant Zero (http://xoops.instant-zero.com) |
103
|
|
|
* @copyright (c) Instant Zero |
104
|
|
|
* @param $field |
105
|
|
|
* @param $table |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
|
|
|
109
|
|
|
function lx_alterTable($field, $table) |
110
|
|
|
{ |
111
|
|
|
global $xoopsDB; |
|
|
|
|
112
|
|
|
$sql = 'SHOW COLUMNS FROM ' . $table . " LIKE '" . $field . "'"; |
113
|
|
|
$result = $xoopsDB->queryF($sql); |
114
|
|
|
//if ($result) { |
|
|
|
|
115
|
|
|
if ($xoopsDB->getRowsNum($result) == 0) { |
116
|
|
|
$sql = 'ALTER TABLE ' . $xoopsDB->prefix($table) . ' ADD `' . $field . '`'; |
117
|
|
|
|
118
|
|
|
return $xoopsDB->query($sql); |
119
|
|
|
// } |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
return true; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/* |
126
|
|
|
* Sub-Menu for Importscripts |
127
|
|
|
* @package lexikon |
128
|
|
|
* @copyright (c) XOOPS Project (http://xoops.org) |
129
|
|
|
*/ |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param int $currentoption |
133
|
|
|
* @param string $breadcrumb |
134
|
|
|
*/ |
135
|
|
|
function lx_importMenu($currentoption = 0, $breadcrumb = '') |
|
|
|
|
136
|
|
|
{ |
137
|
|
|
global $cf; |
|
|
|
|
138
|
|
|
echo "<style type=\"text/css\"> |
139
|
|
|
br {clear: left;} |
140
|
|
|
img {border:0;} |
141
|
|
|
#menu {width:400px; position:relative; height:80px; margin:1em auto auto 2em;} |
142
|
|
|
#menu a:visited, #menu a {text-decoration:none; color:#d00; font-weight:bold;} |
143
|
|
|
#menu a:visited img, #menu a img{filter: alpha(opacity=40); |
144
|
|
|
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=40); |
145
|
|
|
-moz-opacity: 0.40; opacity:0.4; |
146
|
|
|
} |
147
|
|
|
#menu a:hover {background-color:trans; color:#06a;} |
148
|
|
|
#menu a span {display:none;} |
149
|
|
|
#menu a:hover span {display:block; position:absolute; top:50px; left:0; font-size:12px; height:18px; padding:4px; font-weight:normal; color:#a40;} |
150
|
|
|
|
151
|
|
|
#menu a:hover img { filter: alpha(opacity=100); |
152
|
|
|
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100); |
153
|
|
|
-moz-opacity: 1.00; opacity:1; |
154
|
|
|
} |
155
|
|
|
</style>"; |
156
|
|
|
echo " <TABLE BORDER=0 CELLPADDING=1 CELLSPACING=2 width='98%'> |
157
|
|
|
<tr><td width='200' VALIGN='top'> |
158
|
|
|
<h3>Import Menu</h3><span style='font-size:1'>"; |
159
|
|
|
if ($cf < 5) { |
160
|
|
|
echo '' . _AM_LEXIKON_OTHERMODS . ''; |
161
|
|
|
} else { |
162
|
|
|
echo '' . _AM_LEXIKON_NOOTHERMODS . ''; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
echo "</FONT></td><td VALIGN='top'> |
166
|
|
|
<div id=\"menu\">"; |
167
|
|
|
// show only modules located on the system |
168
|
|
|
/** @var XoopsModuleHandler $moduleHandler */ |
169
|
|
|
$moduleHandler = xoops_getHandler('module'); |
170
|
|
|
$wordbookModule = $moduleHandler->getByDirname('wordbook'); |
171
|
|
|
$got_options = false; |
|
|
|
|
172
|
|
|
$cf = 0; |
173
|
|
|
if (is_object($wordbookModule)) { |
174
|
|
|
$wb_imgurl = XOOPS_URL . '/modules/wordbook/images'; |
175
|
|
|
++$cf; |
176
|
|
|
echo "<a href=\"importwordbook.php\"> |
177
|
|
|
<img src=\"" . $wb_imgurl . "/wb_slogo.png\" alt=\"wb_slogo.png\" title=\"Wordbook\" height=\"39\" width=\"69\"><span>Import Wordbook</span></a>"; |
178
|
|
|
} //else { echo "". 'wordbook' ."";} |
|
|
|
|
179
|
|
|
$dictionaryModule = $moduleHandler->getByDirname('dictionary'); |
180
|
|
|
$got_options = false; |
|
|
|
|
181
|
|
|
if (is_object($dictionaryModule)) { |
182
|
|
|
$dic_imgurl = XOOPS_URL . '/modules/dictionary/images'; |
183
|
|
|
++$cf; |
184
|
|
|
echo "<a href=\"importdictionary.php\"> |
185
|
|
|
<img src=\"" . $dic_imgurl . "/dictionary_logo.png\" alt=\"Dictionary\" title=\"Dictionary\" height=\"39\" width=\"69\"><span>Import Dictionary</span></a>"; |
186
|
|
|
} //else { echo "<B>·</B>". 'dictionary' ."";} |
|
|
|
|
187
|
|
|
$glossaireModule = $moduleHandler->getByDirname('glossaire'); |
188
|
|
|
$got_options = false; |
|
|
|
|
189
|
|
|
if (is_object($glossaireModule)) { |
190
|
|
|
$glo_imgurl = XOOPS_URL . '/modules/glossaire.'; |
191
|
|
|
++$cf; |
192
|
|
|
echo "<a href=\"importglossaire.php\"> |
193
|
|
|
<img src=\"" . $glo_imgurl . "/glossaire_logo.jpg\" alt=\"Glossaire\" title=\"Glossaire\" height=\"31\" width=\"88\"><span>Import Glossaire</span></a>"; |
194
|
|
|
} //else { echo "<B>·</B>". 'glossaire' ."";} |
|
|
|
|
195
|
|
|
$wiwimodModule = $moduleHandler->getByDirname('wiwimod'); |
196
|
|
|
$got_options = false; |
|
|
|
|
197
|
|
|
if (is_object($wiwimodModule)) { |
198
|
|
|
$wiwi_imgurl = XOOPS_URL . '/modules/wiwimod/images'; |
199
|
|
|
++$cf; |
200
|
|
|
echo "<a href=\"importwiwimod.php\"><img src=\"" . $wiwi_imgurl . "/wiwilogo.gif\" alt=\"Wiwimod\" title=\"Wiwimod\" height=\"39\" width=\"69\"><span>Import Wiwimod</span></a>"; |
201
|
|
|
} //else { echo "<B>·</B>". 'wiwimod' ."";} |
|
|
|
|
202
|
|
|
$xwordsModule = $moduleHandler->getByDirname('xwords'); |
203
|
|
|
$got_options = false; |
|
|
|
|
204
|
|
|
if (is_object($xwordsModule)) { |
205
|
|
|
$xwd_imgurl = XOOPS_URL . '/modules/xwords/images'; |
206
|
|
|
++$cf; |
207
|
|
|
echo "<a href=\"importxwords.php\"><img src=\"" . $xwd_imgurl . "/xwords_slogo.png\" alt=\"Xwords\" title=\"Xwords\" height=\"39\" width=\"69\"><span>Import Xwords</span></a>"; |
208
|
|
|
}// else { echo "<B>·</B>". 'xwords' ."";} |
|
|
|
|
209
|
|
|
echo '</div></td><tr></TABLE>'; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* collapsable bar for items lists |
214
|
|
|
* @package lexikon |
215
|
|
|
* @copyright (c) XOOPS Project (http://xoops.org) |
216
|
|
|
* @param string $tablename |
217
|
|
|
* @param string $iconname |
218
|
|
|
*/ |
219
|
|
|
|
220
|
|
|
function lx_collapsableBar($tablename = '', $iconname = '') |
221
|
|
|
{ |
222
|
|
|
?> |
223
|
|
|
<script type="text/javascript"><!-- |
224
|
|
|
function goto_URL(object) { |
225
|
|
|
window.location.href = object.options[object.selectedIndex].value; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
function toggle(id) { |
229
|
|
|
if (document.getElementById) { |
230
|
|
|
obj = document.getElementById(id); |
231
|
|
|
} |
232
|
|
|
if (document.all) { |
233
|
|
|
obj = document.all[id]; |
234
|
|
|
} |
235
|
|
|
if (document.layers) { |
236
|
|
|
obj = document.layers[id]; |
237
|
|
|
} |
238
|
|
|
if (obj) { |
239
|
|
|
if (obj.style.display == "none") { |
240
|
|
|
obj.style.display = ""; |
241
|
|
|
} else { |
242
|
|
|
obj.style.display = "none"; |
243
|
|
|
} |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
return false; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
var iconClose = new Image(); |
250
|
|
|
iconClose.src = '../assets/images/close12.gif'; |
251
|
|
|
var iconOpen = new Image(); |
252
|
|
|
iconOpen.src = '../assets/images/open12.gif'; |
253
|
|
|
|
254
|
|
|
function toggleIcon(iconName) { |
255
|
|
|
if (document.images[iconName].src == window.iconOpen.src) { |
256
|
|
|
document.images[iconName].src = window.iconClose.src; |
257
|
|
|
} |
258
|
|
|
elseif(document.images[iconName].src == window.iconClose.src) |
259
|
|
|
{ |
260
|
|
|
document.images[iconName].src = window.iconOpen.src; |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
//--> |
265
|
|
|
</script> |
266
|
|
|
<?php |
267
|
|
|
// HTML Error Fixed by 5Vision |
268
|
|
|
echo "<div style=\"color: #2F5376; margin: 6px 0 0 0; \"><a href=\"#\" onClick=\"toggle('" . $tablename . "'); toggleIcon('" . $iconname . "');\">"; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Returns statistics about the Glossary |
273
|
|
|
* adapted from news module 1.0 |
274
|
|
|
* @param $limit |
275
|
|
|
* @return array |
276
|
|
|
*/ |
277
|
|
|
function lx_GetStatistics($limit) |
278
|
|
|
{ |
279
|
|
|
$ret = array(); |
280
|
|
|
$db = XoopsDatabaseFactory::getDatabaseConnection(); |
281
|
|
|
$tbls = $db->prefix('lxentries'); |
282
|
|
|
$tblt = $db->prefix('lxcategories'); |
283
|
|
|
|
284
|
|
|
$db = XoopsDatabaseFactory::getDatabaseConnection(); |
285
|
|
|
// Number of Definitions per Category, including offline and submitted terms |
286
|
|
|
$ret2 = array(); |
287
|
|
|
$sql = "SELECT count(s.entryID) as cpt, s.categoryID, t.name FROM $tbls s, $tblt t WHERE s.categoryID=t.categoryID GROUP BY s.categoryID ORDER BY t.name"; |
288
|
|
|
$result = $db->query($sql); |
289
|
|
|
while ($myrow = $db->fetchArray($result)) { |
290
|
|
|
$ret2[$myrow['categoryID']] = $myrow; |
291
|
|
|
} |
292
|
|
|
$ret['termspercategory'] = $ret2; |
293
|
|
|
unset($ret2); |
294
|
|
|
|
295
|
|
|
// Total reads per category |
296
|
|
|
$ret2 = array(); |
297
|
|
|
$sql = "SELECT Sum(counter) as cpt, categoryID FROM $tbls GROUP BY categoryID ORDER BY categoryID"; |
298
|
|
|
$result = $db->query($sql); |
299
|
|
|
while ($myrow = $db->fetchArray($result)) { |
300
|
|
|
$ret2[$myrow['categoryID']] = $myrow['cpt']; |
301
|
|
|
} |
302
|
|
|
$ret['readspercategory'] = $ret2; |
303
|
|
|
|
304
|
|
|
// unused terms per category i.e. offline or submitted |
305
|
|
|
$ret2 = array(); |
306
|
|
|
$sql = "SELECT Count(entryID) as cpt, categoryID FROM $tbls WHERE offline > 0 OR submit > 0 GROUP BY categoryID ORDER BY categoryID"; |
307
|
|
|
$result = $db->query($sql); |
308
|
|
|
while ($myrow = $db->fetchArray($result)) { |
309
|
|
|
$ret2[$myrow['categoryID']] = $myrow['cpt']; |
310
|
|
|
} |
311
|
|
|
$ret['offlinepercategory'] = $ret2; |
312
|
|
|
unset($ret2); |
313
|
|
|
|
314
|
|
|
// Number of unique authors per category |
315
|
|
|
$ret2 = array(); |
316
|
|
|
$sql = "SELECT Count(Distinct(uid)) as cpt, categoryID FROM $tbls GROUP BY categoryID ORDER BY categoryID"; |
317
|
|
|
$result = $db->query($sql); |
318
|
|
|
while ($myrow = $db->fetchArray($result)) { |
319
|
|
|
$ret2[$myrow['categoryID']] = $myrow['cpt']; |
320
|
|
|
} |
321
|
|
|
$ret['authorspercategory'] = $ret2; |
322
|
|
|
unset($ret2); |
323
|
|
|
|
324
|
|
|
// Most read terms |
325
|
|
|
$ret2 = array(); |
326
|
|
|
$sql = "SELECT s.entryID, s.uid, s.term, s.counter, s.categoryID, t.name FROM $tbls s, $tblt t WHERE s.categoryID=t.categoryID ORDER BY s.counter DESC"; |
327
|
|
|
$result = $db->query($sql, (int)$limit); |
328
|
|
|
while ($myrow = $db->fetchArray($result)) { |
329
|
|
|
$ret2[$myrow['entryID']] = $myrow; |
330
|
|
|
} |
331
|
|
|
$ret['mostreadterms'] = $ret2; |
332
|
|
|
unset($ret2); |
333
|
|
|
|
334
|
|
|
// Less read terms |
335
|
|
|
$ret2 = array(); |
336
|
|
|
$sql = "SELECT s.entryID, s.uid, s.term, s.counter, s.categoryID, t.name FROM $tbls s, $tblt t WHERE s.categoryID=t.categoryID ORDER BY s.counter"; |
337
|
|
|
$result = $db->query($sql, (int)$limit); |
338
|
|
|
while ($myrow = $db->fetchArray($result)) { |
339
|
|
|
$ret2[$myrow['entryID']] = $myrow; |
340
|
|
|
} |
341
|
|
|
$ret['lessreadterms'] = $ret2; |
342
|
|
|
unset($ret2); |
343
|
|
|
|
344
|
|
|
// Most read authors |
345
|
|
|
$ret2 = array(); |
346
|
|
|
$sql = "SELECT Sum(counter) as cpt, uid FROM $tbls GROUP BY uid ORDER BY cpt DESC"; |
347
|
|
|
$result = $db->query($sql, (int)$limit); |
348
|
|
|
while ($myrow = $db->fetchArray($result)) { |
349
|
|
|
$ret2[$myrow['uid']] = $myrow['cpt']; |
350
|
|
|
} |
351
|
|
|
$ret['mostreadauthors'] = $ret2; |
352
|
|
|
unset($ret2); |
353
|
|
|
|
354
|
|
|
// Biggest contributors |
355
|
|
|
$ret2 = array(); |
356
|
|
|
$sql = "SELECT Count(*) as cpt, uid FROM $tbls GROUP BY uid ORDER BY cpt DESC"; |
357
|
|
|
$result = $db->query($sql, (int)$limit); |
358
|
|
|
while ($myrow = $db->fetchArray($result)) { |
359
|
|
|
$ret2[$myrow['uid']] = $myrow['cpt']; |
360
|
|
|
} |
361
|
|
|
$ret['biggestcontributors'] = $ret2; |
362
|
|
|
unset($ret2); |
363
|
|
|
|
364
|
|
|
return $ret; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
//-- build a table header |
368
|
|
|
function lx_buildTable() |
369
|
|
|
{ |
370
|
|
|
global $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
371
|
|
|
echo "<div style='color: #2F5376; margin: 6px 0 0 0; '>"; |
372
|
|
|
echo "<table width='100%' cellspacing='2' cellpadding='3' border='0' class='outer'>"; |
373
|
|
|
//echo "<tr><td colspan='7' class='odd'>"; |
374
|
|
|
//echo "<strong>". _AM_LEXIKON_INVENTORY . "</strong></td></tr>"; |
|
|
|
|
375
|
|
|
echo '<tr >'; |
376
|
|
|
echo "<th width='40px' align='center'><b>" . _AM_LEXIKON_ENTRYID . '</b></td>'; |
377
|
|
|
echo "<th width='100px' align='center'><b>" . _AM_LEXIKON_ENTRYCATNAME . '</b></td>'; |
378
|
|
|
echo "<th align='center'><b>" . _AM_LEXIKON_TERM . '</b></td>'; |
379
|
|
|
echo "<th width='90px' align='center'><b>" . _AM_LEXIKON_AUTHOR . '</b></td>'; |
380
|
|
|
echo "<th width='90px' align='center'><b>" . _AM_LEXIKON_ENTRYCREATED . '</b></td>'; |
381
|
|
|
echo "<th width='40px' align='center'><b>" . _AM_LEXIKON_STATUS . '</b></td>'; |
382
|
|
|
echo "<th width='60px' align='center'><b>" . _AM_LEXIKON_ACTION . '</b></td>'; |
383
|
|
|
echo '</tr>'; |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* save_permissions() |
388
|
|
|
* adapted from WF-Downloads |
389
|
|
|
* @param $groups |
390
|
|
|
* @param $id |
391
|
|
|
* @param $perm_name |
392
|
|
|
* @return bool |
393
|
|
|
*/ |
394
|
|
|
|
395
|
|
|
function lx_save_Permissions($groups, $id, $perm_name) |
396
|
|
|
{ |
397
|
|
|
$result = true; |
398
|
|
|
$hModule = xoops_getHandler('module'); |
399
|
|
|
$lxModule = $hModule->getByDirname('lexikon'); |
400
|
|
|
|
401
|
|
|
$module_id = $lxModule->getVar('mid'); |
402
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
403
|
|
|
|
404
|
|
|
/* |
405
|
|
|
* First, if the permissions are already there, delete them |
406
|
|
|
*/ |
407
|
|
|
$gpermHandler->deleteByModule($module_id, $perm_name, $id); |
408
|
|
|
/* |
409
|
|
|
* Save the new permissions |
410
|
|
|
*/ |
411
|
|
|
if (is_array($groups)) { |
412
|
|
|
foreach ($groups as $group_id) { |
413
|
|
|
$gpermHandler->addRight($perm_name, $id, $group_id, $module_id); |
414
|
|
|
} |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
return $result; |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
//-- Initial Selector |
421
|
|
|
/** |
422
|
|
|
* @param $init |
423
|
|
|
*/ |
424
|
|
|
function lx_getinit($init) |
425
|
|
|
{ |
426
|
|
|
global $init; |
|
|
|
|
427
|
|
|
echo "<select name='init'>"; |
428
|
|
|
echo "<option value='#'> # </option>"; |
429
|
|
|
for ($a = 65; $a < (65 + 26); ++$a) { |
430
|
|
|
if (chr($a) == $init) { |
431
|
|
|
$opt_selected = 'selected'; |
432
|
|
|
} else { |
433
|
|
|
$opt_selected = ''; |
434
|
|
|
} |
435
|
|
|
echo "<option value='" . chr($a) . "' $opt_selected> " . chr($a) . ' </option>'; |
436
|
|
|
} |
437
|
|
|
echo '</select></div>'; |
438
|
|
|
} |
439
|
|
|
|
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.