1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* Module: XoopsTube |
4
|
|
|
* |
5
|
|
|
* You may not change or alter any portion of this comment or credits |
6
|
|
|
* of supporting developers from this source code or any supporting source code |
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
8
|
|
|
* |
9
|
|
|
* PHP version 5 |
10
|
|
|
* |
11
|
|
|
* @category Module |
12
|
|
|
* @package Xoopstube |
13
|
|
|
* @author Fernando Santos (topet05), [email protected] |
14
|
|
|
* @copyright Mastop InfoDigital (c) 2003-2007 |
15
|
|
|
* @link http://www.mastop.com.br |
16
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
17
|
|
|
* @since 1.0.6 |
18
|
|
|
* @version $Id$ |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
include_once __DIR__ . '/admin_header.php'; |
22
|
|
|
if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid())) { |
23
|
|
|
exit(_AM_XOOPSTUBE_ERROR403); |
24
|
|
|
} |
25
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
26
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
27
|
|
|
$op = "list"; |
28
|
|
|
if (isset($_POST)) { |
29
|
|
|
foreach ($_POST as $k => $v) { |
30
|
|
|
$$k = $v; |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
if (isset($_GET['op'])) { |
35
|
|
|
if ($_GET['op'] == "edit" || $_GET['op'] == "delete" || $_GET['op'] == "delete_ok" || $_GET['op'] == "clone" |
36
|
|
|
|| $_GET['op'] == "edit" |
37
|
|
|
) { |
38
|
|
|
$op = $_GET['op']; |
39
|
|
|
$bid = isset($_GET['bid']) ? intval($_GET['bid']) : 0; |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* |
45
|
|
|
*/ |
46
|
|
|
function listBlocks() |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
global $xoopsUser, $xoopsConfig, $xoopsModule, $pathIcon16; |
|
|
|
|
49
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
50
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
51
|
|
View Code Duplication |
if (file_exists( |
|
|
|
|
52
|
|
|
XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php" |
53
|
|
|
) |
54
|
|
|
) { |
55
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin.php"); |
56
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php"); |
57
|
|
|
//include_once(XOOPS_ROOT_PATH."/modules/system/language/".$xoopsConfig['language']."/admin/groups.php"); |
|
|
|
|
58
|
|
|
} else { |
59
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin.php"); |
60
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/blocksadmin.php"); |
61
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/groups.php"); |
62
|
|
|
} |
63
|
|
|
$module_handler =& xoops_gethandler('module'); |
64
|
|
|
$member_handler =& xoops_gethandler('member'); |
65
|
|
|
$moduleperm_handler =& xoops_gethandler('groupperm'); |
66
|
|
|
$groups =& $member_handler->getGroups(); |
67
|
|
|
$criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
68
|
|
|
$criteria->add(new Criteria('isactive', 1)); |
69
|
|
|
$module_list =& $module_handler->getList($criteria); |
70
|
|
|
$module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; |
71
|
|
|
$module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; |
72
|
|
|
ksort($module_list); |
73
|
|
|
echo " |
74
|
|
|
<h4 style='text-align:left;'>" . _AM_XOOPSTUBE_BADMIN . "</h4>"; |
75
|
|
|
$module_handler =& xoops_gethandler('module'); |
76
|
|
|
echo "<form action='" . $_SERVER['PHP_SELF'] . "' name='blockadmin' method='post'> |
77
|
|
|
<table width='100%' class='outer' cellpadding='4' cellspacing='1'> |
78
|
|
|
<tr valign='middle'><th align='center'>" . _AM_XOOPSTUBE_TITLE . "</th><th align='center' nowrap='nowrap'>" . _AM_XOOPSTUBE_SIDE . "<br />" . _LEFT . "-" . _CENTER . "-" . _RIGHT |
79
|
|
|
. "</th><th align='center'>" . _AM_XOOPSTUBE_WEIGHT . "</th><th align='center'>" . _AM_XOOPSTUBE_VISIBLE . "</th><th align='center'>" . _AM_SYSTEM_BLOCKS_VISIBLEIN |
80
|
|
|
. "</th><th align='center'>" . _AM_SYSTEM_ADGS . "</th><th align='center'>" . _AM_SYSTEM_BLOCKS_BCACHETIME . "</th><th align='center'>" . _AM_XOOPSTUBE_ACTION . "</th></tr> |
81
|
|
|
"; |
82
|
|
|
$block_arr =& XoopsBlock::getByModule($xoopsModule->mid()); |
83
|
|
|
$block_count = count($block_arr); |
|
|
|
|
84
|
|
|
$class = 'even'; |
85
|
|
|
$cachetimes = array( |
86
|
|
|
'0' => _NOCACHE, |
87
|
|
|
'30' => sprintf(_SECONDS, 30), |
88
|
|
|
'60' => _MINUTE, |
89
|
|
|
'300' => sprintf(_MINUTES, 5), |
90
|
|
|
'1800' => sprintf(_MINUTES, 30), |
91
|
|
|
'3600' => _HOUR, |
92
|
|
|
'18000' => sprintf(_HOURS, 5), |
93
|
|
|
'86400' => _DAY, |
94
|
|
|
'259200' => sprintf(_DAYS, 3), |
95
|
|
|
'604800' => _WEEK, |
96
|
|
|
'2592000' => _MONTH |
97
|
|
|
); |
98
|
|
|
foreach ($block_arr as $i) { |
99
|
|
|
$groups_perms =& $moduleperm_handler->getGroupIds('block_read', $i->getVar("bid")); |
100
|
|
|
$sql |
101
|
|
|
= 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar("bid"); |
102
|
|
|
$result = $db->query($sql); |
103
|
|
|
$modules = array(); |
104
|
|
|
while ($row = $db->fetchArray($result)) { |
105
|
|
|
$modules[] = intval($row['module_id']); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$cachetime_options = ''; |
109
|
|
|
foreach ($cachetimes as $cachetime => $cachetime_name) { |
110
|
|
|
if ($i->getVar('bcachetime') == $cachetime) { |
111
|
|
|
$cachetime_options .= "<option value='$cachetime' selected='selected'>$cachetime_name</option>\n"; |
112
|
|
|
} else { |
113
|
|
|
$cachetime_options .= "<option value='$cachetime'>$cachetime_name</option>\n"; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
$sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = ""; |
118
|
|
|
if ($i->getVar("visible") == 1) { |
119
|
|
|
$sel1 = " checked='checked'"; |
120
|
|
|
} else { |
121
|
|
|
$sel0 = " checked='checked'"; |
122
|
|
|
} |
123
|
|
|
if ($i->getVar("side") == XOOPS_SIDEBLOCK_LEFT) { |
124
|
|
|
$ssel0 = " checked='checked'"; |
125
|
|
|
} elseif ($i->getVar("side") == XOOPS_SIDEBLOCK_RIGHT) { |
126
|
|
|
$ssel1 = " checked='checked'"; |
127
|
|
|
} elseif ($i->getVar("side") == XOOPS_CENTERBLOCK_LEFT) { |
128
|
|
|
$ssel2 = " checked='checked'"; |
129
|
|
|
} elseif ($i->getVar("side") == XOOPS_CENTERBLOCK_RIGHT) { |
130
|
|
|
$ssel4 = " checked='checked'"; |
131
|
|
|
} elseif ($i->getVar("side") == XOOPS_CENTERBLOCK_CENTER) { |
132
|
|
|
$ssel3 = " checked='checked'"; |
133
|
|
|
} elseif ($i->getVar("side") == XOOPS_CENTERBLOCK_BOTTOMLEFT) { |
134
|
|
|
$ssel5 = " checked='checked'"; |
135
|
|
|
} elseif ($i->getVar("side") == XOOPS_CENTERBLOCK_BOTTOMRIGHT) { |
136
|
|
|
$ssel6 = " checked='checked'"; |
137
|
|
|
} elseif ($i->getVar("side") == XOOPS_CENTERBLOCK_BOTTOM) { |
138
|
|
|
$ssel7 = " checked='checked'"; |
139
|
|
|
} |
140
|
|
|
if ($i->getVar("title") == "") { |
141
|
|
|
$title = " "; |
142
|
|
|
} else { |
143
|
|
|
$title = $i->getVar("title"); |
144
|
|
|
} |
145
|
|
|
$name = $i->getVar("name"); |
|
|
|
|
146
|
|
|
echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar("bid") . "]' value='" . $title . "'></td><td class='$class' align='center' nowrap='nowrap'> |
147
|
|
|
<div align='center' > |
148
|
|
|
<input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_CENTERBLOCK_LEFT . "'$ssel2 /> |
149
|
|
|
<input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_CENTERBLOCK_CENTER . "'$ssel3 /> |
150
|
|
|
<input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_CENTERBLOCK_RIGHT . "'$ssel4 /> |
151
|
|
|
</div> |
152
|
|
|
<div> |
153
|
|
|
<span style='float:right'><input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_SIDEBLOCK_RIGHT . "'$ssel1 /></span> |
154
|
|
|
<div align='left'><input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_SIDEBLOCK_LEFT . "'$ssel0 /></div> |
155
|
|
|
</div> |
156
|
|
|
<div align='center'> |
157
|
|
|
<input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_CENTERBLOCK_BOTTOMLEFT . "'$ssel5 /> |
158
|
|
|
<input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_CENTERBLOCK_BOTTOM . "'$ssel7 /> |
159
|
|
|
<input type='radio' name='side[" . $i->getVar("bid") . "]' value='" . XOOPS_CENTERBLOCK_BOTTOMRIGHT . "'$ssel6 /> |
160
|
|
|
</div> |
161
|
|
|
</td><td class='$class' align='center'><input type='text' name='weight[" . $i->getVar("bid") . "]' value='" . $i->getVar("weight") . "' size='5' maxlength='5' /></td><td class='$class' align='center' nowrap><input type='radio' name='visible[" |
162
|
|
|
. $i->getVar("bid") . "]' value='1'$sel1>" . _YES . " <input type='radio' name='visible[" . $i->getVar("bid") . "]' value='0'$sel0>" . _NO . "</td>"; |
163
|
|
|
|
164
|
|
|
echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar("bid") . "][]' id='bmodule[" . $i->getVar("bid") . "][]' multiple='multiple'>"; |
165
|
|
|
foreach ($module_list as $k => $v) { |
166
|
|
|
echo "<option value='$k'" . ((in_array($k, $modules)) ? " selected='selected'" : "") . ">$v</option>"; |
167
|
|
|
} |
168
|
|
|
echo "</select></td>"; |
169
|
|
|
|
170
|
|
|
echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar("bid") . "][]' id='groups[" . $i->getVar("bid") . "][]' multiple='multiple'>"; |
171
|
|
|
foreach ($groups as $grp) { |
172
|
|
|
echo "<option value='" . $grp->getVar('groupid') . "' " . ((in_array( |
173
|
|
|
$grp->getVar('groupid'), |
174
|
|
|
$groups_perms |
175
|
|
|
)) ? " selected='selected'" : "") . ">" . $grp->getVar('name') . "</option>"; |
176
|
|
|
} |
177
|
|
|
echo "</select></td>"; |
178
|
|
|
|
179
|
|
|
// Cache lifetime |
180
|
|
|
echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar("bid") . ']" size="1">' . $cachetime_options . '</select> |
181
|
|
|
</td>'; |
182
|
|
|
|
183
|
|
|
// Actions |
184
|
|
|
|
185
|
|
|
echo |
186
|
|
|
"<td class='$class' align='center'><a href='blocksadmin.php?op=edit&bid=" . $i->getVar("bid") . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "' /> |
187
|
|
|
</a> <a href='blocksadmin.php?op=clone&bid=" . $i->getVar("bid") . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "' /> |
188
|
|
|
</a>"; |
189
|
|
|
if ($i->getVar('block_type') != 'S' && $i->getVar('block_type') != 'M') { |
190
|
|
|
echo " <a href='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&op=delete&bid=" . $i->getVar("bid") . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" |
191
|
|
|
. _DELETE . "' title='" . _DELETE . "' /> |
192
|
|
|
</a>"; |
193
|
|
|
} |
194
|
|
|
echo " |
195
|
|
|
<input type='hidden' name='oldtitle[" . $i->getVar("bid") . "]' value='" . $i->getVar('title') . "' /> |
196
|
|
|
<input type='hidden' name='oldside[" . $i->getVar("bid") . "]' value='" . $i->getVar('side') . "' /> |
197
|
|
|
<input type='hidden' name='oldweight[" . $i->getVar("bid") . "]' value='" . $i->getVar('weight') . "' /> |
198
|
|
|
<input type='hidden' name='oldvisible[" . $i->getVar("bid") . "]' value='" . $i->getVar('visible') . "' /> |
199
|
|
|
<input type='hidden' name='oldgroups[" . $i->getVar("groups") . "]' value='" . $i->getVar('groups') . "' /> |
200
|
|
|
<input type='hidden' name='oldbcachetime[" . $i->getVar("bid") . "]' value='" . $i->getVar('bcachetime') . "' /> |
201
|
|
|
<input type='hidden' name='bid[" . $i->getVar("bid") . "]' value='" . $i->getVar("bid") . "' /> |
202
|
|
|
</td></tr> |
203
|
|
|
"; |
204
|
|
|
$class = ($class == 'even') ? 'odd' : 'even'; |
205
|
|
|
} |
206
|
|
|
echo "<tr><td class='foot' align='center' colspan='7'> |
207
|
|
|
<input type='hidden' name='op' value='order' /> |
208
|
|
|
" . $GLOBALS['xoopsSecurity']->getTokenHTML() . " |
209
|
|
|
<input type='submit' name='submit' value='" . _SUBMIT . "' /> |
210
|
|
|
</td></tr></table> |
211
|
|
|
</form> |
212
|
|
|
<br /><br />"; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @param $bid |
217
|
|
|
*/ |
218
|
|
|
function cloneBlock($bid) |
219
|
|
|
{ |
220
|
|
|
include_once __DIR__ . '/admin_header.php'; |
221
|
|
|
//include_once __DIR__ . '/admin_header.php'; |
|
|
|
|
222
|
|
|
xoops_cp_header(); |
223
|
|
|
|
224
|
|
|
global $xoopsConfig; |
|
|
|
|
225
|
|
|
|
226
|
|
|
//xoops_loadLanguage('admin', XTUBE_DIRNAME); |
|
|
|
|
227
|
|
|
//xoops_loadLanguage('modinfo', XTUBE_DIRNAME); |
228
|
|
|
//xoops_loadLanguage('main', XTUBE_DIRNAME); |
229
|
|
|
|
230
|
|
View Code Duplication |
if (file_exists( |
|
|
|
|
231
|
|
|
XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php" |
232
|
|
|
) |
233
|
|
|
) { |
234
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin.php"); |
235
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php"); |
236
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/groups.php"); |
237
|
|
|
} else { |
238
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin.php"); |
239
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/blocksadmin.php"); |
240
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/groups.php"); |
241
|
|
|
} |
242
|
|
|
// mpu_adm_menu(); |
243
|
|
|
$myblock = new XoopsBlock($bid); |
244
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
245
|
|
|
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . intval($bid); |
246
|
|
|
$result = $db->query($sql); |
247
|
|
|
$modules = array(); |
248
|
|
|
while ($row = $db->fetchArray($result)) { |
249
|
|
|
$modules[] = intval($row['module_id']); |
250
|
|
|
} |
251
|
|
|
$is_custom = ($myblock->getVar('block_type') == 'C' || $myblock->getVar('block_type') == 'E') ? true : false; |
252
|
|
|
$block = array( |
253
|
|
|
'title' => $myblock->getVar('title') . ' Clone', |
254
|
|
|
'form_title' => _AM_XOOPSTUBE_BLOCKS_CLONEBLOCK, |
255
|
|
|
'name' => $myblock->getVar('name'), |
256
|
|
|
'side' => $myblock->getVar('side'), |
257
|
|
|
'weight' => $myblock->getVar('weight'), |
258
|
|
|
'visible' => $myblock->getVar('visible'), |
259
|
|
|
'content' => $myblock->getVar('content', 'N'), |
260
|
|
|
'modules' => $modules, |
261
|
|
|
'is_custom' => $is_custom, |
262
|
|
|
'ctype' => $myblock->getVar('c_type'), |
263
|
|
|
'bcachetime' => $myblock->getVar('bcachetime'), |
264
|
|
|
'op' => 'clone_ok', |
265
|
|
|
'bid' => $myblock->getVar('bid'), |
266
|
|
|
'edit_form' => $myblock->getOptions(), |
267
|
|
|
'template' => $myblock->getVar('template'), |
268
|
|
|
'options' => $myblock->getVar('options') |
269
|
|
|
); |
270
|
|
|
echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br /><br />'; |
271
|
|
|
include __DIR__ . '/blockform.php'; |
272
|
|
|
$form->display(); |
|
|
|
|
273
|
|
|
// xoops_cp_footer(); |
274
|
|
|
include_once __DIR__ . '/admin_footer.php'; |
275
|
|
|
exit(); |
|
|
|
|
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @param $bid |
280
|
|
|
* @param $bside |
281
|
|
|
* @param $bweight |
282
|
|
|
* @param $bvisible |
283
|
|
|
* @param $bcachetime |
284
|
|
|
* @param $bmodule |
285
|
|
|
* @param $options |
286
|
|
|
*/ |
287
|
|
|
function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options) |
|
|
|
|
288
|
|
|
{ |
289
|
|
|
global $xoopsUser, $xoopsConfig; |
|
|
|
|
290
|
|
View Code Duplication |
if (file_exists( |
|
|
|
|
291
|
|
|
XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php" |
292
|
|
|
) |
293
|
|
|
) { |
294
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin.php"); |
295
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php"); |
296
|
|
|
//include_once(XOOPS_ROOT_PATH."/modules/system/language/".$xoopsConfig['language']."/admin/groups.php"); |
|
|
|
|
297
|
|
|
} else { |
298
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin.php"); |
299
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/blocksadmin.php"); |
300
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/groups.php"); |
301
|
|
|
} |
302
|
|
|
$block = new XoopsBlock($bid); |
303
|
|
|
$clone =& $block->xoopsClone(); |
304
|
|
|
if (empty($bmodule)) { |
305
|
|
|
xoops_cp_header(); |
306
|
|
|
xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); |
307
|
|
|
xoops_cp_footer(); |
308
|
|
|
exit(); |
|
|
|
|
309
|
|
|
} |
310
|
|
|
$clone->setVar('side', $bside); |
311
|
|
|
$clone->setVar('weight', $bweight); |
312
|
|
|
$clone->setVar('visible', $bvisible); |
313
|
|
|
//$clone->setVar('content', $_POST['bcontent']); |
|
|
|
|
314
|
|
|
$clone->setVar('title', $_POST['btitle']); |
315
|
|
|
$clone->setVar('bcachetime', $bcachetime); |
316
|
|
|
if (isset($options) && (count($options) > 0)) { |
317
|
|
|
$options = implode('|', $options); |
318
|
|
|
$clone->setVar('options', $options); |
319
|
|
|
} |
320
|
|
|
$clone->setVar('bid', 0); |
321
|
|
|
if ($block->getVar('block_type') == 'C' || $block->getVar('block_type') == 'E') { |
322
|
|
|
$clone->setVar('block_type', 'E'); |
323
|
|
|
} else { |
324
|
|
|
$clone->setVar('block_type', 'D'); |
325
|
|
|
} |
326
|
|
|
$newid = $clone->store(); |
327
|
|
|
if (!$newid) { |
328
|
|
|
xoops_cp_header(); |
329
|
|
|
$clone->getHtmlErrors(); |
330
|
|
|
xoops_cp_footer(); |
331
|
|
|
exit(); |
|
|
|
|
332
|
|
|
} |
333
|
|
|
if ($clone->getVar('template') != '') { |
334
|
|
|
$tplfile_handler =& xoops_gethandler('tplfile'); |
335
|
|
|
$btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
336
|
|
|
if (count($btemplate) > 0) { |
337
|
|
|
$tplclone =& $btemplate[0]->xoopsClone(); |
338
|
|
|
$tplclone->setVar('tpl_id', 0); |
339
|
|
|
$tplclone->setVar('tpl_refid', $newid); |
340
|
|
|
$tplfile_handler->insert($tplclone); |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
344
|
|
|
foreach ($bmodule as $bmid) { |
345
|
|
|
$sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; |
346
|
|
|
$db->query($sql); |
347
|
|
|
} |
348
|
|
|
$groups =& $xoopsUser->getGroups(); |
349
|
|
|
$count = count($groups); |
350
|
|
|
for ($i = 0; $i < $count; ++$i) { |
351
|
|
|
$sql |
352
|
|
|
= "INSERT INTO " . $db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (" . $groups[$i] . ", " . $newid . ", 1, 'block_read')"; |
353
|
|
|
$db->query($sql); |
354
|
|
|
} |
355
|
|
|
redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* @param $bid |
360
|
|
|
* @param $title |
361
|
|
|
* @param $weight |
362
|
|
|
* @param $visible |
363
|
|
|
* @param $side |
364
|
|
|
* @param $bcachetime |
365
|
|
|
*/ |
366
|
|
|
function xtubeSetOrder($bid, $title, $weight, $visible, $side, $bcachetime) |
367
|
|
|
{ |
368
|
|
|
$myblock = new XoopsBlock($bid); |
369
|
|
|
$myblock->setVar('title', $title); |
370
|
|
|
$myblock->setVar('weight', $weight); |
371
|
|
|
$myblock->setVar('visible', $visible); |
372
|
|
|
$myblock->setVar('side', $side); |
373
|
|
|
$myblock->setVar('bcachetime', $bcachetime); |
374
|
|
|
$myblock->store(); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* @param $bid |
379
|
|
|
*/ |
380
|
|
|
function xtubeEditBlock($bid) |
381
|
|
|
{ |
382
|
|
|
include_once __DIR__ . '/admin_header.php'; |
383
|
|
|
//include_once __DIR__ . '/admin_header.php'; |
|
|
|
|
384
|
|
|
xoops_cp_header(); |
385
|
|
|
|
386
|
|
|
global $xoopsConfig; |
|
|
|
|
387
|
|
|
|
388
|
|
|
//xoops_loadLanguage('admin', XTUBE_DIRNAME); |
|
|
|
|
389
|
|
|
//xoops_loadLanguage('modinfo', XTUBE_DIRNAME); |
390
|
|
|
//xoops_loadLanguage('main', XTUBE_DIRNAME); |
391
|
|
|
|
392
|
|
View Code Duplication |
if (file_exists( |
|
|
|
|
393
|
|
|
XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php" |
394
|
|
|
) |
395
|
|
|
) { |
396
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin.php"); |
397
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/blocksadmin.php"); |
398
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/" . $xoopsConfig['language'] . "/admin/groups.php"); |
399
|
|
|
} else { |
400
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin.php"); |
401
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/blocksadmin.php"); |
402
|
|
|
include_once(XOOPS_ROOT_PATH . "/modules/system/language/portuguesebr/admin/groups.php"); |
403
|
|
|
} |
404
|
|
|
// mpu_adm_menu(); |
405
|
|
|
$myblock = new XoopsBlock($bid); |
406
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
407
|
|
|
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . intval($bid); |
408
|
|
|
$result = $db->query($sql); |
409
|
|
|
$modules = array(); |
410
|
|
|
while ($row = $db->fetchArray($result)) { |
411
|
|
|
$modules[] = intval($row['module_id']); |
412
|
|
|
} |
413
|
|
|
$is_custom = ($myblock->getVar('block_type') == 'C' || $myblock->getVar('block_type') == 'E') ? true : false; |
414
|
|
|
$block = array( |
415
|
|
|
'title' => $myblock->getVar('title'), |
416
|
|
|
'form_title' => _AM_XOOPSTUBE_BLOCKS_EDITBLOCK, |
417
|
|
|
// 'name' => $myblock->getVar('name'), |
|
|
|
|
418
|
|
|
'side' => $myblock->getVar('side'), |
419
|
|
|
'weight' => $myblock->getVar('weight'), |
420
|
|
|
'visible' => $myblock->getVar('visible'), |
421
|
|
|
'content' => $myblock->getVar('content', 'N'), |
422
|
|
|
'modules' => $modules, |
423
|
|
|
'is_custom' => $is_custom, |
424
|
|
|
'ctype' => $myblock->getVar('c_type'), |
425
|
|
|
'bcachetime' => $myblock->getVar('bcachetime'), |
426
|
|
|
'op' => 'edit_ok', |
427
|
|
|
'bid' => $myblock->getVar('bid'), |
428
|
|
|
'edit_form' => $myblock->getOptions(), |
429
|
|
|
'template' => $myblock->getVar('template'), |
430
|
|
|
'options' => $myblock->getVar('options') |
431
|
|
|
); |
432
|
|
|
echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br /><br />'; |
433
|
|
|
include 'blockform.php'; |
434
|
|
|
$form->display(); |
|
|
|
|
435
|
|
|
// xoops_cp_footer(); |
436
|
|
|
include_once __DIR__ . '/admin_footer.php'; |
437
|
|
|
exit(); |
|
|
|
|
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* @param $bid |
442
|
|
|
* @param $btitle |
443
|
|
|
* @param $bside |
444
|
|
|
* @param $bweight |
445
|
|
|
* @param $bvisible |
446
|
|
|
* @param $bcachetime |
447
|
|
|
* @param $bmodule |
448
|
|
|
* @param $options |
449
|
|
|
* @param $groups |
450
|
|
|
*/ |
451
|
|
|
function xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups) |
|
|
|
|
452
|
|
|
{ |
453
|
|
|
$myblock = new XoopsBlock($bid); |
454
|
|
|
$myblock->setVar('title', $btitle); |
455
|
|
|
$myblock->setVar('weight', $bweight); |
456
|
|
|
$myblock->setVar('visible', $bvisible); |
457
|
|
|
$myblock->setVar('side', $bside); |
458
|
|
|
$myblock->setVar('bcachetime', $bcachetime); |
459
|
|
|
$myblock->store(); |
460
|
|
|
|
461
|
|
|
global $xoopsDB; |
|
|
|
|
462
|
|
|
|
463
|
|
|
if (!empty($bmodule) && count($bmodule) > 0) { |
464
|
|
|
$sql = sprintf("DELETE FROM %s WHERE block_id = %u", $xoopsDB->prefix('block_module_link'), $bid); |
465
|
|
|
$xoopsDB->query($sql); |
466
|
|
|
if (in_array(0, $bmodule)) { |
467
|
|
|
$sql = sprintf( |
468
|
|
|
"INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", |
469
|
|
|
$xoopsDB->prefix('block_module_link'), |
470
|
|
|
$bid, |
471
|
|
|
0 |
472
|
|
|
); |
473
|
|
|
$xoopsDB->query($sql); |
474
|
|
View Code Duplication |
} else { |
|
|
|
|
475
|
|
|
foreach ($bmodule as $bmid) { |
476
|
|
|
$sql = sprintf( |
477
|
|
|
"INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", |
478
|
|
|
$xoopsDB->prefix('block_module_link'), |
479
|
|
|
$bid, |
480
|
|
|
intval($bmid) |
481
|
|
|
); |
482
|
|
|
$xoopsDB->query($sql); |
483
|
|
|
} |
484
|
|
|
} |
485
|
|
|
} |
486
|
|
|
$sql = sprintf("DELETE FROM %s WHERE gperm_itemid = %u", $xoopsDB->prefix('group_permission'), $bid); |
487
|
|
|
$xoopsDB->query($sql); |
488
|
|
|
if (!empty($groups)) { |
489
|
|
View Code Duplication |
foreach ($groups as $grp) { |
|
|
|
|
490
|
|
|
$sql = sprintf( |
491
|
|
|
"INSERT INTO %s (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", |
492
|
|
|
$xoopsDB->prefix('group_permission'), |
493
|
|
|
$grp, |
494
|
|
|
$bid |
495
|
|
|
); |
496
|
|
|
$xoopsDB->query($sql); |
497
|
|
|
} |
498
|
|
|
} |
499
|
|
|
redirect_header($_SERVER['PHP_SELF'], 1, _AM_XOOPSTUBE_UPDATE_SUCCESS); |
500
|
|
|
exit(); |
|
|
|
|
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
if ($op == "list") { |
504
|
|
|
xoops_cp_header(); |
505
|
|
|
// mpu_adm_menu(); |
506
|
|
|
listBlocks(); |
507
|
|
|
include_once __DIR__ . '/admin_footer.php'; |
508
|
|
|
exit(); |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
if ($op == "order") { |
512
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
513
|
|
|
redirect_header($_SERVER['PHP_SELF'], 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); |
514
|
|
|
exit(); |
515
|
|
|
} |
516
|
|
|
foreach (array_keys($bid) as $i) { |
517
|
|
|
if ($oldtitle[$i] != $title[$i] || $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] |
518
|
|
|
|| $oldside[$i] != $side[$i] |
519
|
|
|
|| $oldbcachetime[$i] != $bcachetime[$i] |
520
|
|
|
) { |
521
|
|
|
xtubeSetOrder( |
522
|
|
|
$bid[$i], |
523
|
|
|
$title[$i], |
524
|
|
|
$weight[$i], |
525
|
|
|
$visible[$i], |
526
|
|
|
$side[$i], |
527
|
|
|
$bcachetime[$i], |
528
|
|
|
$bmodule[$i] |
|
|
|
|
529
|
|
|
); |
530
|
|
|
} |
531
|
|
|
if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) { |
532
|
|
|
$sql = sprintf("DELETE FROM %s WHERE block_id = %u", $xoopsDB->prefix('block_module_link'), $bid[$i]); |
533
|
|
|
$xoopsDB->query($sql); |
534
|
|
|
if (in_array(0, $bmodule[$i])) { |
535
|
|
|
$sql = sprintf( |
536
|
|
|
"INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", |
537
|
|
|
$xoopsDB->prefix('block_module_link'), |
538
|
|
|
$bid[$i], |
539
|
|
|
0 |
540
|
|
|
); |
541
|
|
|
$xoopsDB->query($sql); |
542
|
|
View Code Duplication |
} else { |
|
|
|
|
543
|
|
|
foreach ($bmodule[$i] as $bmid) { |
544
|
|
|
$sql = sprintf( |
545
|
|
|
"INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", |
546
|
|
|
$xoopsDB->prefix('block_module_link'), |
547
|
|
|
$bid[$i], |
548
|
|
|
intval($bmid) |
549
|
|
|
); |
550
|
|
|
$xoopsDB->query($sql); |
551
|
|
|
} |
552
|
|
|
} |
553
|
|
|
} |
554
|
|
|
$sql = sprintf("DELETE FROM %s WHERE gperm_itemid = %u", $xoopsDB->prefix('group_permission'), $bid[$i]); |
555
|
|
|
$xoopsDB->query($sql); |
556
|
|
|
if (!empty($groups[$i])) { |
557
|
|
View Code Duplication |
foreach ($groups[$i] as $grp) { |
|
|
|
|
558
|
|
|
$sql = sprintf( |
559
|
|
|
"INSERT INTO %s (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", |
560
|
|
|
$xoopsDB->prefix('group_permission'), |
561
|
|
|
$grp, |
562
|
|
|
$bid[$i] |
563
|
|
|
); |
564
|
|
|
$xoopsDB->query($sql); |
565
|
|
|
} |
566
|
|
|
} |
567
|
|
|
} |
568
|
|
|
redirect_header($_SERVER['PHP_SELF'], 1, _AM_XOOPSTUBE_UPDATE_SUCCESS); |
569
|
|
|
exit(); |
570
|
|
|
} |
571
|
|
|
if ($op == 'clone') { |
572
|
|
|
cloneBlock($bid); |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
if ($op == 'edit') { |
576
|
|
|
xtubeEditBlock($bid); |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
if ($op == 'edit_ok') { |
580
|
|
|
xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
581
|
|
|
|
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
if ($op == 'clone_ok') { |
585
|
|
|
isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options); |
586
|
|
|
} |
587
|
|
|
} else { |
588
|
|
|
echo _AM_XOOPSTUBE_ERROR403; |
589
|
|
|
} |
590
|
|
|
|
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.