|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
// $Id: main.php,v 1.12 2004/01/06 09:36:20 okazu Exp $ |
|
3
|
|
|
// ------------------------------------------------------------------------ // |
|
4
|
|
|
// XOOPS - PHP Content Management System // |
|
5
|
|
|
// Copyright (c) 2000 XOOPS.org // |
|
6
|
|
|
// <http://www.xoops.org/> // |
|
7
|
|
|
// ------------------------------------------------------------------------ // |
|
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
11
|
|
|
// (at your option) any later version. // |
|
12
|
|
|
// // |
|
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
14
|
|
|
// of supporting developers from this source code or any supporting // |
|
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
16
|
|
|
// original comment or credit authors. // |
|
17
|
|
|
// // |
|
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
21
|
|
|
// GNU General Public License for more details. // |
|
22
|
|
|
// // |
|
23
|
|
|
// You should have received a copy of the GNU General Public License // |
|
24
|
|
|
// along with this program; if not, write to the Free Software // |
|
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
26
|
|
|
// ------------------------------------------------------------------------ // |
|
27
|
|
|
// Author: Kazumi Ono (AKA onokazu) // |
|
28
|
|
|
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
|
29
|
|
|
// Project: The XOOPS Project // |
|
30
|
|
|
// ------------------------------------------------------------------------- // |
|
31
|
|
|
|
|
32
|
|
View Code Duplication |
if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { |
|
|
|
|
|
|
33
|
|
|
exit('Access Denied'); |
|
34
|
|
|
} |
|
35
|
|
|
include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php'; |
|
36
|
|
|
include XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blocksadmin.php'; |
|
37
|
|
|
|
|
38
|
|
|
$op = 'list'; |
|
39
|
|
|
|
|
40
|
|
|
if ( !empty($_POST['op']) ) { $op = $_POST['op']; } |
|
41
|
|
|
if ( !empty($_POST['bid']) ) { $bid = intval($_POST['bid']); } |
|
42
|
|
|
|
|
43
|
|
|
if ( isset($_GET['op']) ) { |
|
44
|
|
|
if ($_GET['op'] == 'edit' || $_GET['op'] == 'delete' || $_GET['op'] == 'delete_ok' || $_GET['op'] == 'clone' /* || $_GET['op'] == 'previewpopup'*/) { |
|
|
|
|
|
|
45
|
|
|
$op = $_GET['op']; |
|
46
|
|
|
$bid = isset($_GET['bid']) ? intval($_GET['bid']) : 0; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if (isset($_POST['previewblock'])) { |
|
51
|
|
|
//if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
|
|
|
|
|
52
|
|
|
// exit('Invalid Referer'); |
|
|
|
|
|
|
53
|
|
|
//} |
|
54
|
|
|
if ( ! $xoopsGTicket->check() ) { |
|
55
|
|
|
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if( empty( $bid ) ) die( 'Invalid bid.' ) ; |
|
59
|
|
|
|
|
60
|
|
|
if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } |
|
61
|
|
|
if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } |
|
62
|
|
|
if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } |
|
63
|
|
|
if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } |
|
64
|
|
|
if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
|
65
|
|
|
if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
|
66
|
|
|
if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
|
67
|
|
|
if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } |
|
68
|
|
|
|
|
69
|
|
|
xoops_cp_header(); |
|
70
|
|
|
include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
71
|
|
|
$xoopsTpl = new XoopsTpl(); |
|
72
|
|
|
$xoopsTpl->xoops_setCaching(0); |
|
73
|
|
|
$block['bid'] = $bid; |
|
74
|
|
|
|
|
75
|
|
|
if ($op == 'clone_ok') { |
|
76
|
|
|
$block['form_title'] = _AM_CLONEBLOCK; |
|
77
|
|
|
$block['submit_button'] = _CLONE; |
|
78
|
|
|
$myblock = new XoopsBlock(); |
|
79
|
|
|
$myblock->setVar('block_type', 'C'); |
|
80
|
|
|
} else { |
|
81
|
|
|
$op = 'update' ; |
|
82
|
|
|
$block['form_title'] = _AM_EDITBLOCK; |
|
83
|
|
|
$block['submit_button'] = _SUBMIT; |
|
84
|
|
|
$myblock = new XoopsBlock($bid); |
|
85
|
|
|
$block['name'] = $myblock->getVar('name'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$wfmyts = MyTextSanitizer::getInstance(); |
|
89
|
|
|
$myblock->setVar('title', $wfmyts->stripSlashesGPC($btitle)); |
|
90
|
|
|
$myblock->setVar('content', $wfmyts->stripSlashesGPC($bcontent)); |
|
91
|
|
|
// $dummyhtml = '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" /><meta http-equiv="content-language" content="'._LANGCODE.'" /><title>'.$xoopsConfig['sitename'].'</title><link rel="stylesheet" type="text/css" media="all" href="'.getcss($xoopsConfig['theme_set']).'" /></head><body><table><tr><th>'.$myblock->getVar('title').'</th></tr><tr><td>'.$myblock->getContent('S', $bctype).'</td></tr></table></body></html>'; |
|
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
/* $dummyfile = '_dummyfile_'.time().'.html'; |
|
|
|
|
|
|
94
|
|
|
$fp = fopen(XOOPS_CACHE_PATH.'/'.$dummyfile, 'w'); |
|
95
|
|
|
fwrite($fp, $dummyhtml); |
|
96
|
|
|
fclose($fp);*/ |
|
97
|
|
|
$block['edit_form'] = false; |
|
98
|
|
|
$block['template'] = ''; |
|
99
|
|
|
$block['op'] = $op; |
|
100
|
|
|
$block['side'] = $bside; |
|
101
|
|
|
$block['weight'] = $bweight; |
|
102
|
|
|
$block['visible'] = $bvisible; |
|
103
|
|
|
$block['title'] = $myblock->getVar('title', 'E'); |
|
104
|
|
|
$block['content'] = $myblock->getVar('content', 'E'); |
|
105
|
|
|
$block['modules'] =& $bmodule; |
|
106
|
|
|
$block['ctype'] = isset($bctype) ? $bctype : $myblock->getVar('c_type'); |
|
107
|
|
|
$block['is_custom'] = true; |
|
108
|
|
|
$block['cachetime'] = intval($bcachetime); |
|
109
|
|
|
echo '<a href="myblocksadmin.php">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '.$block['form_title'].'<br /><br />'; |
|
110
|
|
|
include dirname(__FILE__).'/../admin/myblockform.php'; //GIJ |
|
111
|
|
|
//echo '<a href="admin.php?fct=blocksadmin">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '.$block['form_title'].'<br /><br />'; |
|
|
|
|
|
|
112
|
|
|
//include XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blockform.php'; |
|
|
|
|
|
|
113
|
|
|
$form->addElement( $xoopsGTicket->getTicketXoopsForm( __LINE__ ) );//GIJ |
|
114
|
|
|
$form->display(); |
|
115
|
|
|
|
|
116
|
|
|
$original_level = error_reporting( E_ALL ) ; |
|
117
|
|
|
echo " |
|
118
|
|
|
<table width='100%' class='outer' cellspacing='1'> |
|
119
|
|
|
<tr> |
|
120
|
|
|
<th>".$myblock->getVar('title')."</th> |
|
121
|
|
|
</tr> |
|
122
|
|
|
<tr> |
|
123
|
|
|
<td class='odd'>".$myblock->getContent('S', $bctype)."</td> |
|
124
|
|
|
</tr> |
|
125
|
|
|
</table>\n" ; |
|
126
|
|
|
error_reporting( $original_level ) ; |
|
127
|
|
|
|
|
128
|
|
|
xoops_cp_footer(); |
|
129
|
|
|
/* echo '<script type="text/javascript"> |
|
|
|
|
|
|
130
|
|
|
preview_window = openWithSelfMain("'.XOOPS_URL.'/modules/system/admin.php?fct=blocksadmin&op=previewpopup&file='.$dummyfile.'", "popup", 250, 200); |
|
131
|
|
|
</script>';*/ |
|
132
|
|
|
|
|
133
|
|
|
exit(); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/* if ($op == 'previewpopup') { |
|
|
|
|
|
|
137
|
|
|
if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
138
|
|
|
exit('Invalid Referer'); |
|
139
|
|
|
} |
|
140
|
|
|
$file = str_replace('..', '', XOOPS_CACHE_PATH.'/'.trim($_GET['file'])); |
|
141
|
|
|
if (file_exists($file)) { |
|
142
|
|
|
include $file; |
|
143
|
|
|
@unlink($file); |
|
144
|
|
|
} |
|
145
|
|
|
exit(); |
|
146
|
|
|
} */ |
|
147
|
|
|
|
|
148
|
|
|
/* if ($op == "list") { |
|
|
|
|
|
|
149
|
|
|
xoops_cp_header(); |
|
150
|
|
|
list_blocks(); |
|
151
|
|
|
xoops_cp_footer(); |
|
152
|
|
|
exit(); |
|
153
|
|
|
} */ |
|
154
|
|
|
|
|
155
|
|
|
if ($op == 'order') { |
|
156
|
|
|
//if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
|
|
|
|
|
157
|
|
|
// exit('Invalid Referer'); |
|
|
|
|
|
|
158
|
|
|
//} |
|
159
|
|
|
if ( ! $xoopsGTicket->check() ) { |
|
160
|
|
|
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|
161
|
|
|
} |
|
162
|
|
|
if ( !empty($_POST['side']) ) { $side = $_POST['side']; } |
|
163
|
|
|
// if ( !empty($_POST['weight']) ) { $weight = $_POST['weight']; } |
|
|
|
|
|
|
164
|
|
|
if ( !empty($_POST['visible']) ) { $visible = $_POST['visible']; } |
|
165
|
|
|
// if ( !empty($_POST['oldside']) ) { $oldside = $_POST['oldside']; } |
|
|
|
|
|
|
166
|
|
|
// if ( !empty($_POST['oldweight']) ) { $oldweight = $_POST['oldweight']; } |
|
167
|
|
|
// if ( !empty($_POST['oldvisible']) ) { $oldvisible = $_POST['oldvisible']; } |
|
168
|
|
|
if ( !empty($_POST['bid']) ) { $bid = $_POST['bid']; } else { $bid = array(); } |
|
169
|
|
|
// GIJ start |
|
170
|
|
|
foreach (array_keys($bid) as $i) { |
|
171
|
|
|
if ($side[$i] < 0) { |
|
172
|
|
|
$visible[$i] = 0 ; |
|
173
|
|
|
$side[$i] = -1 ; |
|
174
|
|
|
} else { |
|
175
|
|
|
$visible[$i] = 1 ; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
$bmodule = (isset($_POST['bmodule'][$i]) && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : array(-1) ; |
|
179
|
|
|
|
|
180
|
|
|
myblocksadmin_update_block($i, $side[$i], $_POST['weight'][$i], $visible[$i], $_POST['title'][$i], null , null , $_POST['bcachetime'][$i], $bmodule, array()); |
|
181
|
|
|
|
|
182
|
|
|
// if ( $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] || $oldside[$i] != $side[$i] ) |
|
|
|
|
|
|
183
|
|
|
// order_block($bid[$i], $weight[$i], $visible[$i], $side[$i]); |
|
184
|
|
|
} |
|
185
|
|
|
$query4redirect = '?dirname=' . urlencode( strip_tags( substr( $_POST['query4redirect'] , 9 ) ) ) ; |
|
186
|
|
|
redirect_header("myblocksadmin.php$query4redirect",1,_AM_DBUPDATED); |
|
187
|
|
|
// GIJ end |
|
188
|
|
|
exit(); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/* if ($op == 'save') { |
|
|
|
|
|
|
192
|
|
|
if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
193
|
|
|
exit('Invalid Referer'); |
|
194
|
|
|
} |
|
195
|
|
|
if ( ! $xoopsGTicket->check() ) { |
|
196
|
|
|
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|
197
|
|
|
} |
|
198
|
|
|
if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } |
|
199
|
|
|
if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } |
|
200
|
|
|
if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } |
|
201
|
|
|
if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } |
|
202
|
|
|
if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
|
203
|
|
|
if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
|
204
|
|
|
if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
|
205
|
|
|
if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } |
|
206
|
|
|
save_block($bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bmodule, $bcachetime); |
|
207
|
|
|
exit(); |
|
208
|
|
|
} */ |
|
209
|
|
|
|
|
210
|
|
|
if ($op == 'update') { |
|
211
|
|
|
//if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
|
|
|
|
|
212
|
|
|
// exit('Invalid Referer'); |
|
|
|
|
|
|
213
|
|
|
//} |
|
214
|
|
|
if ( ! $xoopsGTicket->check() ) { |
|
215
|
|
|
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|
216
|
|
|
} |
|
217
|
|
|
/* if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } |
|
|
|
|
|
|
218
|
|
|
if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } |
|
219
|
|
|
if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } |
|
220
|
|
|
if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
|
221
|
|
|
if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
|
222
|
|
|
if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
|
223
|
|
|
if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } |
|
224
|
|
|
if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } |
|
225
|
|
|
if ( !empty($_POST['options']) ) { $options = $_POST['options']; } else { $options = array(); } |
|
226
|
|
|
update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options);*/ |
|
227
|
|
|
|
|
228
|
|
|
$bcachetime = isset($_POST['bcachetime']) ? intval($_POST['bcachetime']) : 0; |
|
229
|
|
|
$options = isset($_POST['options']) ? $_POST['options'] : array(); |
|
230
|
|
|
$bcontent = isset($_POST['bcontent']) ? $_POST['bcontent'] : ''; |
|
231
|
|
|
$bctype = isset($_POST['bctype']) ? $_POST['bctype'] : ''; |
|
232
|
|
|
$bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : array(-1) ; // GIJ + |
|
233
|
|
|
$msg = myblocksadmin_update_block($_POST['bid'], $_POST['bside'], $_POST['bweight'], $_POST['bvisible'], $_POST['btitle'], $bcontent, $bctype, $bcachetime, $bmodule, $options); // GIJ ! |
|
234
|
|
|
redirect_header('myblocksadmin.php',1,$msg); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
if ($op == 'delete_ok') { |
|
238
|
|
|
//if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
|
|
|
|
|
239
|
|
|
// exit('Invalid Referer'); |
|
|
|
|
|
|
240
|
|
|
//} |
|
241
|
|
|
if ( ! $xoopsGTicket->check() ) { |
|
242
|
|
|
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|
243
|
|
|
} |
|
244
|
|
|
// delete_block_ok($bid); GIJ imported from blocksadmin.php |
|
245
|
|
|
$myblock = new XoopsBlock($bid); |
|
246
|
|
|
if ( $myblock->getVar('block_type') != 'D' && $myblock->getVar('block_type') != 'C' ) { |
|
247
|
|
|
redirect_header('myblocksadmin.php',4,'Invalid block'); |
|
248
|
|
|
exit(); |
|
249
|
|
|
} |
|
250
|
|
|
$myblock->delete(); |
|
251
|
|
|
if ($myblock->getVar('template') != '' && ! defined('XOOPS_ORETEKI') ) { |
|
252
|
|
|
$tplfile_handler =& xoops_gethandler('tplfile'); |
|
253
|
|
|
$btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
|
254
|
|
|
if (count($btemplate) > 0) { |
|
255
|
|
|
$tplman->delete($btemplate[0]); |
|
256
|
|
|
} |
|
257
|
|
|
} |
|
258
|
|
|
redirect_header('myblocksadmin.php',1,_AM_DBUPDATED); |
|
259
|
|
|
exit(); |
|
260
|
|
|
// end of delete_block_ok() GIJ |
|
261
|
|
|
exit(); |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
if ($op == 'delete') { |
|
265
|
|
|
xoops_cp_header(); |
|
266
|
|
|
// delete_block($bid); GIJ imported from blocksadmin.php |
|
267
|
|
|
$myblock = new XoopsBlock($bid); |
|
268
|
|
|
if ( $myblock->getVar('block_type') == 'S' ) { |
|
269
|
|
|
$message = _AM_SYSTEMCANT; |
|
270
|
|
|
redirect_header('admin.php?fct=blocksadmin',4,$message); |
|
271
|
|
|
exit(); |
|
272
|
|
|
} elseif ($myblock->getVar('block_type') == 'M') { |
|
273
|
|
|
$message = _AM_MODULECANT; |
|
274
|
|
|
redirect_header('admin.php?fct=blocksadmin',4,$message); |
|
275
|
|
|
exit(); |
|
276
|
|
|
} else { |
|
277
|
|
|
xoops_confirm(array('fct' => 'blocksadmin', 'op' => 'delete_ok', 'bid' => $myblock->getVar('bid')) + $xoopsGTicket->getTicketArray( __LINE__ ) , 'admin.php', sprintf(_AM_RUSUREDEL,$myblock->getVar('title'))); |
|
278
|
|
|
} |
|
279
|
|
|
// end of delete_block() GIJ |
|
280
|
|
|
xoops_cp_footer(); |
|
281
|
|
|
exit(); |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
View Code Duplication |
if ($op == 'edit') { |
|
|
|
|
|
|
285
|
|
|
|
|
286
|
|
|
xoops_cp_header(); |
|
287
|
|
|
// edit_block($bid); GIJ imported from blocksadmin.php |
|
288
|
|
|
$myblock = new XoopsBlock($bid); |
|
289
|
|
|
|
|
290
|
|
|
$db =& XoopsDatabaseFactory :: getdatabaseconnection(); |
|
291
|
|
|
$sql = 'SELECT module_id FROM '.$db->prefix('block_module_link').' WHERE block_id='.intval($bid); |
|
292
|
|
|
$result = $db->query($sql); |
|
293
|
|
|
$modules = array(); |
|
294
|
|
|
while ($row = $db->fetchArray($result)) { |
|
295
|
|
|
$modules[] = intval($row['module_id']); |
|
296
|
|
|
} |
|
297
|
|
|
$is_custom = ($myblock->getVar('block_type') == 'C' || $myblock->getVar('block_type') == 'E') ? true : false; |
|
298
|
|
|
$block = array('form_title' => _AM_EDITBLOCK, 'name' => $myblock->getVar('name'), 'side' => $myblock->getVar('side'), 'weight' => $myblock->getVar('weight'), 'visible' => $myblock->getVar('visible'), 'title' => $myblock->getVar('title', 'E'), 'content' => $myblock->getVar('content', 'E'), 'modules' => $modules, 'is_custom' => $is_custom, 'ctype' => $myblock->getVar('c_type'), 'cachetime' => $myblock->getVar('bcachetime'), 'op' => 'update', 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'), 'submit_button' => _SUBMIT); |
|
299
|
|
|
|
|
300
|
|
|
echo '<a href="myblocksadmin.php">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '._AM_EDITBLOCK.'<br /><br />'; |
|
301
|
|
|
include dirname(__FILE__).'/../admin/myblockform.php'; //GIJ |
|
302
|
|
|
$form->addElement( $xoopsGTicket->getTicketXoopsForm( __LINE__ ) );//GIJ |
|
303
|
|
|
$form->display(); |
|
304
|
|
|
// end of edit_block() GIJ |
|
305
|
|
|
xoops_cp_footer(); |
|
306
|
|
|
exit(); |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
View Code Duplication |
if ($op == 'clone') { |
|
|
|
|
|
|
310
|
|
|
xoops_cp_header(); |
|
311
|
|
|
$myblock = new XoopsBlock($bid); |
|
312
|
|
|
|
|
313
|
|
|
$db =& XoopsDatabaseFactory :: getdatabaseconnection(); |
|
314
|
|
|
$sql = 'SELECT module_id FROM '.$db->prefix('block_module_link').' WHERE block_id='.intval($bid); |
|
315
|
|
|
$result = $db->query($sql); |
|
316
|
|
|
$modules = array(); |
|
317
|
|
|
while ($row = $db->fetchArray($result)) { |
|
318
|
|
|
$modules[] = intval($row['module_id']); |
|
319
|
|
|
} |
|
320
|
|
|
$is_custom = ($myblock->getVar('block_type') == 'C' || $myblock->getVar('block_type') == 'E') ? true : false; |
|
321
|
|
|
$block = array('form_title' => _AM_CLONEBLOCK, 'name' => $myblock->getVar('name'), 'side' => $myblock->getVar('side'), 'weight' => $myblock->getVar('weight'), 'visible' => $myblock->getVar('visible'), 'content' => $myblock->getVar('content', 'N'), 'title' => $myblock->getVar('title','E'), 'modules' => $modules, 'is_custom' => $is_custom, 'ctype' => $myblock->getVar('c_type'), 'cachetime' => $myblock->getVar('bcachetime'), 'op' => 'clone_ok', 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'), 'submit_button' => _CLONE); |
|
322
|
|
|
echo '<a href="myblocksadmin.php">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '._AM_CLONEBLOCK.'<br /><br />'; |
|
323
|
|
|
include dirname(__FILE__).'/../admin/myblockform.php'; |
|
324
|
|
|
$form->addElement( $xoopsGTicket->getTicketXoopsForm( __LINE__ ) );//GIJ |
|
325
|
|
|
$form->display(); |
|
326
|
|
|
xoops_cp_footer(); |
|
327
|
|
|
exit(); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
if ($op == 'clone_ok') { |
|
331
|
|
|
// Ticket Check |
|
332
|
|
|
if ( ! $xoopsGTicket->check() ) { |
|
333
|
|
|
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
$block = new XoopsBlock($bid); |
|
337
|
|
|
|
|
338
|
|
|
// block type check |
|
339
|
|
|
$block_type = $block->getVar('block_type') ; |
|
340
|
|
|
if ($block_type != 'C' && $block_type != 'M' && $block_type != 'D') { |
|
341
|
|
|
redirect_header('myblocksadmin.php',4,'Invalid block'); |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
if( empty( $_POST['options'] ) ) $options = array() ; |
|
345
|
|
|
else if( is_array( $_POST['options'] ) ) $options = $_POST['options'] ; |
|
346
|
|
|
else $options = explode( '|' , $_POST['options'] ) ; |
|
347
|
|
|
|
|
348
|
|
|
// for backward compatibility |
|
349
|
|
|
// $cblock =& $block->clone(); or $cblock =& $block->xoopsClone(); |
|
|
|
|
|
|
350
|
|
|
$cblock = new XoopsBlock() ; |
|
351
|
|
|
foreach ($block->vars as $k => $v) { |
|
352
|
|
|
$cblock->assignVar( $k , $v['value'] ) ; |
|
353
|
|
|
} |
|
354
|
|
|
$cblock->setNew(); |
|
355
|
|
|
|
|
356
|
|
|
$cblock->setVar('side', $_POST['bside']); |
|
357
|
|
|
$cblock->setVar('weight', $_POST['bweight']); |
|
358
|
|
|
$cblock->setVar('visible', $_POST['bvisible']); |
|
359
|
|
|
$cblock->setVar('title', $_POST['btitle']); |
|
360
|
|
|
//$cblock->setVar('content', $bcontent); |
|
|
|
|
|
|
361
|
|
|
//$cblock->setVar('title', $btitle); |
|
|
|
|
|
|
362
|
|
|
$cblock->setVar('bcachetime', $_POST['bcachetime']); |
|
363
|
|
View Code Duplication |
if ( isset($options) && (count($options) > 0) ) { |
|
|
|
|
|
|
364
|
|
|
$options = implode('|', $options); |
|
365
|
|
|
$cblock->setVar('options', $options); |
|
366
|
|
|
} |
|
367
|
|
|
$cblock->setVar('bid', 0); |
|
368
|
|
|
$cblock->setVar('block_type', $block_type == 'C' ? 'C' : 'D' ); |
|
369
|
|
|
$cblock->setVar('func_num', 255); |
|
370
|
|
|
$newid = $cblock->store(); |
|
371
|
|
|
if (!$newid) { |
|
372
|
|
|
xoops_cp_header(); |
|
373
|
|
|
$cblock->getHtmlErrors(); |
|
374
|
|
|
xoops_cp_footer(); |
|
375
|
|
|
exit(); |
|
376
|
|
|
} |
|
377
|
|
|
/* if ($cblock->getVar('template') != '') { |
|
|
|
|
|
|
378
|
|
|
$tplfile_handler =& xoops_gethandler('tplfile'); |
|
379
|
|
|
$btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
|
380
|
|
|
if (count($btemplate) > 0) { |
|
381
|
|
|
$tplclone =& $btemplate[0]->clone(); |
|
382
|
|
|
$tplclone->setVar('tpl_id', 0); |
|
383
|
|
|
$tplclone->setVar('tpl_refid', $newid); |
|
384
|
|
|
$tplman->insert($tplclone); |
|
385
|
|
|
} |
|
386
|
|
|
} */ |
|
387
|
|
|
$db =& XoopsDatabaseFactory :: getdatabaseconnection(); |
|
388
|
|
|
$bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : array(-1) ; // GIJ + |
|
389
|
|
|
foreach ($bmodule as $bmid) { |
|
390
|
|
|
$sql = 'INSERT INTO '.$db->prefix('block_module_link').' (block_id, module_id) VALUES ('.$newid.', '.$bmid.')'; |
|
391
|
|
|
$db->query($sql); |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
/* global $xoopsUser; |
|
|
|
|
|
|
395
|
|
|
$groups =& $xoopsUser->getGroups(); |
|
396
|
|
|
$count = count($groups); |
|
397
|
|
|
for ($i = 0; $i < $count; ++$i) { |
|
398
|
|
|
$sql = "INSERT INTO ".$db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (".$groups[$i].", ".$newid.", 1, 'block_read')"; |
|
399
|
|
|
$db->query($sql); |
|
400
|
|
|
} |
|
401
|
|
|
*/ |
|
402
|
|
|
|
|
403
|
|
|
$sql = "SELECT gperm_groupid FROM ".$db->prefix('group_permission')." WHERE gperm_name='block_read' AND gperm_modid='1' AND gperm_itemid='$bid'" ; |
|
404
|
|
|
$result = $db->query($sql); |
|
405
|
|
|
while ( list( $gid ) = $db->fetchRow( $result ) ) { |
|
406
|
|
|
$sql = "INSERT INTO ".$db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ($gid, $newid, 1, 'block_read')"; |
|
407
|
|
|
$db->query($sql); |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
redirect_header('myblocksadmin.php',1,_AM_DBUPDATED); |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
// import from modules/system/admin/blocksadmin/blocksadmin.php |
|
414
|
|
|
function myblocksadmin_update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options=array()) |
|
|
|
|
|
|
415
|
|
|
{ |
|
416
|
|
|
global $xoopsConfig; |
|
|
|
|
|
|
417
|
|
|
/* if (empty($bmodule)) { |
|
|
|
|
|
|
418
|
|
|
xoops_cp_header(); |
|
419
|
|
|
xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); |
|
420
|
|
|
xoops_cp_footer(); |
|
421
|
|
|
exit(); |
|
422
|
|
|
} */ |
|
423
|
|
|
$myblock = new XoopsBlock($bid); |
|
424
|
|
|
// $myblock->setVar('side', $bside); GIJ - |
|
|
|
|
|
|
425
|
|
|
if( $bside >= 0 ) $myblock->setVar('side', $bside); // GIJ + |
|
426
|
|
|
$myblock->setVar('weight', $bweight); |
|
427
|
|
|
$myblock->setVar('visible', $bvisible); |
|
428
|
|
|
$myblock->setVar('title', $btitle); |
|
429
|
|
|
if( isset( $bcontent ) ) $myblock->setVar('content', $bcontent); |
|
430
|
|
|
if( isset( $bctype ) ) $myblock->setVar('c_type', $bctype); |
|
431
|
|
|
$myblock->setVar('bcachetime', $bcachetime); |
|
432
|
|
View Code Duplication |
if ( isset($options) && (count($options) > 0) ) { |
|
|
|
|
|
|
433
|
|
|
$options = implode('|', $options); |
|
434
|
|
|
$myblock->setVar('options', $options); |
|
435
|
|
|
} |
|
436
|
|
|
if ( $myblock->getVar('block_type') == 'C') { |
|
437
|
|
|
switch ( $myblock->getVar('c_type') ) { |
|
438
|
|
|
case 'H': |
|
439
|
|
|
$name = _AM_CUSTOMHTML; |
|
440
|
|
|
break; |
|
441
|
|
|
case 'P': |
|
442
|
|
|
$name = _AM_CUSTOMPHP; |
|
443
|
|
|
break; |
|
444
|
|
|
case 'S': |
|
445
|
|
|
$name = _AM_CUSTOMSMILE; |
|
446
|
|
|
break; |
|
447
|
|
|
default: |
|
448
|
|
|
$name = _AM_CUSTOMNOSMILE; |
|
449
|
|
|
break; |
|
450
|
|
|
} |
|
451
|
|
|
$myblock->setVar('name', $name); |
|
452
|
|
|
} |
|
453
|
|
|
$msg = _AM_DBUPDATED; |
|
454
|
|
|
if ($myblock->store() != false) { |
|
455
|
|
|
$db =& XoopsDatabaseFactory :: getdatabaseconnection(); |
|
456
|
|
|
$sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid); |
|
457
|
|
|
$db->query($sql); |
|
458
|
|
|
foreach ($bmodule as $bmid) { |
|
459
|
|
|
$sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid)); |
|
460
|
|
|
$db->query($sql); |
|
461
|
|
|
} |
|
462
|
|
|
include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
463
|
|
|
$xoopsTpl = new XoopsTpl(); |
|
464
|
|
|
$xoopsTpl->xoops_setCaching(2); |
|
465
|
|
|
if ($myblock->getVar('template') != '') { |
|
466
|
|
|
if ($xoopsTpl->is_cached('db:'.$myblock->getVar('template'))) { |
|
467
|
|
|
if (!$xoopsTpl->clear_cache('db:'.$myblock->getVar('template'))) { |
|
468
|
|
|
$msg = 'Unable to clear cache for block ID'.$bid; |
|
469
|
|
|
} |
|
470
|
|
|
} |
|
471
|
|
|
} else { |
|
472
|
|
|
if ($xoopsTpl->is_cached('db:system_dummy.html', 'block'.$bid)) { |
|
473
|
|
|
if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block'.$bid)) { |
|
474
|
|
|
$msg = 'Unable to clear cache for block ID'.$bid; |
|
475
|
|
|
} |
|
476
|
|
|
} |
|
477
|
|
|
} |
|
478
|
|
|
} else { |
|
479
|
|
|
$msg = 'Failed update of block. ID:'.$bid; |
|
480
|
|
|
} |
|
481
|
|
|
// redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg); |
|
|
|
|
|
|
482
|
|
|
// exit(); GIJ - |
|
|
|
|
|
|
483
|
|
|
return $msg ; // GIJ + |
|
484
|
|
|
} |
|
485
|
|
|
|
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.