43 'selgrp' => XOOPS_GROUP_USERS,
46 foreach (
$sel as $key => $value) {
47 $_{$key} = isset($_COOKIE[$key]) ? intval($_COOKIE[$key]) : $value;
49 setcookie($key, ${$key});
53 if (
$type ==
'preview' )
$op =
'preview';
55 if ( isset(
$_GET[
'op']) ) {
56 if (
$_GET[
'op'] ==
"edit" ||
$_GET[
'op'] ==
"delete" ||
$_GET[
'op'] ==
"delete_ok" ||
$_GET[
'op'] ==
"clone") {
58 $bid = isset(
$_GET[
'bid']) ? intval(
$_GET[
'bid']) : 0;
70 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
72 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
73 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.ui.js');
74 $xoTheme->addScript(
'modules/system/js/admin.js');
75 $xoTheme->addScript(
'modules/system/js/blocks.js');
97 $filterform =
new XoopsThemeForm(
'',
'filterform',
'admin.php',
'get');
102 $sel_gen->setExtra(
"onchange='submit()'" );
105 foreach ($modules as $list) {
106 $sel_gen->addOption( $list->getVar(
'mid'), $list->getVar(
'name') );
108 $filterform->addElement( $sel_gen );
111 $sel_mod->setExtra(
"onchange='submit()'" );
112 ksort($display_list);
116 $display_list = $display_list_spec + $display_list;
117 foreach ($display_list as $k => $v) {
118 $sel_mod->addOption( $k, $v );
120 $filterform->addElement( $sel_mod );
124 $sel_grp->setExtra(
"onchange='submit()'" );
130 $sel_grp->addOption( $k, $v );
132 $filterform->addElement( $sel_grp );
135 $sel_vis->setExtra(
"onchange='submit()'" );
137 $sel_vis->addOption( 0,
_NO );
138 $sel_vis->addOption( 1,
_YES );
140 $filterform->addElement( $sel_vis );
145 $selvis = ( $selvis == -1 ) ? null : $selvis;
146 $selmod = ( $selmod == -2 ) ? null : $selmod;
147 $order_block = ( isset($selvis) ?
"" :
"b.visible DESC, " ) .
"b.side,b.weight,b.bid";
151 $blocks_arr = $block_handler->getNonGroupedBlocks($selmod, $toponlyblock =
false, $selvis, $order_block);
153 $blocks_arr = $block_handler->getAllByGroupModule($selgrp, $selmod, $toponlyblock =
false, $selvis, $order_block);
157 foreach (array_keys($blocks_arr) as $bid) {
158 if ($blocks_arr[$bid]->getVar(
"mid") != $selgen) {
159 unset($blocks_arr[$bid]);
165 foreach (array_keys($blocks_arr) as
$i) {
166 $arr[
$i] = $blocks_arr[
$i]->toArray();
167 $xoopsTpl->append_by_ref(
'blocks', $arr[$i] );
169 $block = $block_handler->create();
170 $blockform = $block->getForm();
171 $xoopsTpl->assign(
'blockform', $blockform->render() );
182 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
185 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
186 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.ui.js');
187 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.form.js');
188 $xoTheme->addScript(
'modules/system/js/admin.js');
189 $xoTheme->addScript(
'modules/system/js/blocks.js');
196 $block = $block_handler->create();
197 $blockform = $block->getForm();
198 $xoopsTpl->assign(
'blockform', $blockform->render() );
209 if ( $block_id > 0 ) {
210 $block = $block_handler->get( $block_id );
211 $block->setVar(
'visible', $visible);
212 if (!$block_handler->insert( $block )) {
224 if ( $block_id > 0 ) {
225 $block = $block_handler->get( $block_id );
226 $block->setVar(
'side', $side);
227 if (!$block_handler->insert( $block )) {
236 if ( isset(
$_POST[
'blk'] ) ) {
238 foreach (
$_POST[
'blk'] as $order) {
240 $block = $block_handler->get($order);
241 $block->setVar(
'weight', $i);
242 if (!$block_handler->insert($block)) {
253 if (!
$GLOBALS[
'xoopsSecurity']->check()) {
259 $block =& $block_handler->create();
262 $block->setVar(
'content',
$content);
264 echo
'<div id="xo-preview-dialog" title="'.$block->getVar(
'title',
's').
'">'.$block->getContent(
's', $block->getVar(
'c_type') ).
'</div>';
268 if (!
$GLOBALS[
'xoopsSecurity']->check()) {
276 if ( $block_id > 0) {
277 $block =& $block_handler->get( $block_id );
279 $block =& $block_handler->create();
282 $block->setVar(
'block_type', $block_type);
284 if (!$block->isCustom()) {
285 $block->setVars(
$_POST );
286 $type = $block->getVar(
'block_type');
287 $name = $block->getVar(
'name');
292 if ($options_count > 0) {
294 for ( $i = 0; $i < $options_count; $i++ ) {
300 $block->setVar(
'options',
$options);
304 $block->setVars(
$_POST );
305 switch ($block->getVar(
'c_type')) {
320 $block->setVar(
'name', $name);
321 $block->setVar(
'isactive', 1);
324 $block->setVar(
'content',
$content);
326 if (!$newid = $block_handler->insert( $block )) {
336 $blocklinkmodule_handler->deleteAll(
$criteria);
338 $modules =
$_POST[
'modules'];
339 foreach ($modules as
$mid) {
340 $blocklinkmodule = $blocklinkmodule_handler->create();
341 $blocklinkmodule->setVar(
'block_id', $newid );
342 $blocklinkmodule->setVar(
'module_id', $mid );
343 if(!$blocklinkmodule_handler->insert($blocklinkmodule)){
353 $groups_with_access =& $groupperm_handler->getGroupIds(
"block_read", $newid );
354 $removed_groups = array_diff($groups_with_access,
$groups);
355 if (count($removed_groups) > 0) {
356 foreach ($removed_groups as $groupid) {
361 $perm = $groupperm_handler->getObjects(
$criteria);
362 if (isset($perm[0]) && is_object($perm[0])) {
363 $groupperm_handler->delete($perm[0]);
367 $new_groups = array_diff(
$groups, $groups_with_access);
368 if (count($new_groups) > 0) {
369 foreach ($new_groups as $groupid) {
370 $groupperm_handler->addRight(
"block_read", $newid, $groupid);
381 if ( $block_id > 0 ) {
387 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
390 $xoTheme->addScript(
'browse.php?Frameworks/jquery/jquery.js');
391 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.ui.js');
392 $xoTheme->addScript(
'browse.php?Frameworks/jquery/plugins/jquery.form.js');
393 $xoTheme->addScript(
'modules/system/js/admin.js');
399 $block = $block_handler->get($block_id);
400 $blockform = $block->getForm();
401 $xoopsTpl->assign(
'blockform', $blockform->render() );
414 if ( $block_id > 0 ) {
415 $block = $block_handler->get($block_id);
416 if ( $block->getVar(
'block_type') ==
'S' ) {
419 } elseif ($block->getVar(
'block_type') ==
'M') {
424 if (1 >= $count = $block_handler->countSimilarBlocks($block->getVar(
'mid'), $block->getVar(
'func_num'), $block->getVar(
'show_func'))) {
441 if (!
$GLOBALS[
'xoopsSecurity']->check()) {
449 if ( $block_id > 0 ) {
450 $block = $block_handler->get( $block_id );
451 if ($block_handler->delete($block)) {
454 $blocklinkmodule = $blocklinkmodule_handler->getObjects(
new CriteriaCompo(
new Criteria(
'block_id', $block_id )));
455 foreach ($blocklinkmodule as $link) {
456 $blocklinkmodule_handler->delete($link,
true);
462 $groupperm = $groupperm_handler->getObjects(
$criteria);
463 foreach ($groupperm as $perm) {
464 $groupperm_handler->delete($perm,
true);
467 if ($block->getVar(
'template') !=
'') {
469 $btemplate = $tplfile_handler->find(
$GLOBALS[
'xoopsConfig'][
'template_set'],
'block', $block_id);
470 if (count($btemplate) > 0) {
471 $tplfile_handler->delete($btemplate[0]);
486 if ( $block_id > 0 ) {
492 $xoTheme->addStylesheet( XOOPS_URL .
'/modules/system/css/admin.css' );
498 $block = $block_handler->get($block_id);
499 $blockform = $block->getForm(
'clone');
500 $xoopsTpl->assign(
'blockform', $blockform->render() );