38 $op =
$system->cleanVars($_REQUEST,
'op',
'list',
'string');
47 $selmod = $selgen = $selgrp = $selvis = null;
51 'selgrp' => FixedGroups::USERS,
54 foreach (
$sel as $key => $value) {
55 $_{$key} = isset($_COOKIE[$key]) ? intval($_COOKIE[$key]) : $value;
56 ${$key} =
$system->cleanVars($method, $key, $_{$key},
'int');
57 setcookie($key, ${$key});
61 if (
$type ==
'preview') {
65 if (isset($_GET[
'op'])) {
66 if ($_GET[
'op'] ==
"edit" || $_GET[
'op'] ==
"delete" || $_GET[
'op'] ==
"delete_ok" || $_GET[
'op'] ==
"clone") {
68 $bid = isset($_GET[
'bid']) ? intval($_GET[
'bid']) : 0;
76 $xoops->header(
'admin:system/system_blocks.tpl');
78 $xoops->theme()->addStylesheet(
'modules/system/css/admin.css');
80 $xoops->theme()->addScript(
'modules/system/js/admin.js');
81 $xoops->theme()->addScript(
'modules/system/js/blocks.js');
87 $system->adminVersion(
'blocksadmin',
'adminpath')
113 $block_handler =
$xoops->getHandlerBlock();
117 $filterform->addElement(
new Xoops\Form\Hidden(
'fct',
'blocksadmin'));
118 $filterform->addElement(
new Xoops\Form\Hidden(
'op',
'list'));
119 $filterform->addElement(
new Xoops\Form\Hidden(
'filter', 1));
121 $sel_gen->setExtra(
"onchange='submit()'");
126 $sel_gen->addOption($list->getVar(
'mid'), $list->getVar(
'name'));
128 $filterform->addElement($sel_gen);
131 $sel_mod->setExtra(
"onchange='submit()'");
132 ksort($display_list);
136 $display_list = $display_list_spec + $display_list;
137 foreach ($display_list as $k => $v) {
138 $sel_mod->addOption($k, $v);
140 $filterform->addElement($sel_mod);
144 $sel_grp->setExtra(
"onchange='submit()'");
150 $sel_grp->addOption($k, $v);
152 $filterform->addElement($sel_grp);
155 $sel_vis->setExtra(
"onchange='submit()'");
160 $filterform->addElement($sel_vis);
162 $filterform->assign(
$xoops->tpl());
165 $selvis = ($selvis == -1) ? null : $selvis;
167 $order_block = (isset($selvis) ?
"" :
"b.visible DESC, ") .
"b.side,b.weight,b.bid";
171 $blocks_arr = $block_handler->getNonGroupedBlocks(
$selmod, $toponlyblock =
false, $selvis, $order_block);
173 $selgrp = ($selgrp == -1) ? null : $selgrp;
174 $blocks_arr = $block_handler->
175 getAllByGroupModule($selgrp,
$selmod, $toponlyblock =
false, $selvis, $order_block);
179 foreach (array_keys($blocks_arr) as $bid) {
180 if ($blocks_arr[$bid]->getVar(
"mid") != $selgen) {
181 unset($blocks_arr[$bid]);
187 foreach (array_keys($blocks_arr) as
$i) {
188 $arr[
$i] = $blocks_arr[
$i]->getValues();
189 $xoops->tpl()->appendByRef(
'blocks', $arr[$i]);
197 $xoops->header(
'admin:system/system_blocks.tpl');
199 $xoops->theme()->addStylesheet(
'modules/system/css/admin.css');
201 $xoops->theme()->addScript(
'media/jquery/plugins/jquery.form.js');
202 $xoops->theme()->addScript(
'modules/system/js/admin.js');
203 $xoops->theme()->addScript(
'modules/system/js/blocks.js');
209 $system->adminVersion(
'blocksadmin',
'adminpath')
214 $block_handler =
$xoops->getHandlerBlock();
215 $block = $block_handler->create();
225 $block_handler =
$xoops->getHandlerBlock();
227 $block_id =
$system->cleanVars($_POST,
'bid', 0,
'int');
230 $block = $block_handler->get($block_id);
231 $block->setVar(
'visible',
$visible);
232 if (!$block_handler->insertBlock($block)) {
240 $block_handler =
$xoops->getHandlerBlock();
242 $block_id =
$system->cleanVars($_POST,
'bid', 0,
'int');
243 $side =
$system->cleanVars($_POST,
'side', 0,
'int');
245 $block = $block_handler->get($block_id);
246 $block->setVar(
'side', $side);
247 if (!$block_handler->insertBlock($block)) {
255 $block_handler =
$xoops->getHandlerBlock();
256 if (isset($_POST[
'blk'])) {
258 foreach ($_POST[
'blk'] as $order) {
260 $block = $block_handler->get($order);
261 $block->setVar(
'weight', $i);
262 if (!$block_handler->insertBlock($block)) {
273 if (!
$xoops->security()->check()) {
274 $xoops->redirect(
'admin.php?fct=blocksadmin', 3, implode(
'<br />',
$xoops->security()->getErrors()));
278 $block_handler =
$xoops->getHandlerBlock();
280 $block = $block_handler->create();
281 $block->setVars($_POST);
282 $content = isset($_POST[
'content_block']) ? $_POST[
'content_block'] :
'';
283 $block->setVar(
'content',
$content);
285 echo
'<div id="xo-preview-dialog" title="' . $block->getVar(
'title',
's')
286 .
'">' . $block->getContent(
's', $block->getVar(
'c_type')) .
'</div>';
290 if (!
$xoops->security()->check()) {
291 $xoops->redirect(
'admin.php?fct=blocksadmin', 3, implode(
'<br />',
$xoops->security()->getErrors()));
295 $block_handler =
$xoops->getHandlerBlock();
297 $block_id =
$system->cleanVars($_POST,
'bid', 0,
'int');
299 $block = $block_handler->get($block_id);
301 $block = $block_handler->create();
303 $block_type =
$system->cleanVars($_POST,
'block_type',
'',
'string');
304 $block->setVar(
'block_type', $block_type);
306 if (!$block->isCustom()) {
307 $block->setVars($_POST);
308 $type = $block->getVar(
'block_type');
309 $name = $block->getVar(
'name');
314 if ($options_count > 0) {
316 for ($i = 0; $i < $options_count; ++
$i) {
322 $block->setVar(
'options',
$options);
326 $block->setVars($_POST);
327 switch ($block->getVar(
'c_type')) {
342 $block->setVar(
'name',
$name);
343 $block->setVar(
'isactive', 1);
345 $content = isset($_POST[
'content_block']) ? $_POST[
'content_block'] :
'';
346 $block->setVar(
'content',
$content);
348 if (!$newid = $block_handler->insertBlock($block)) {
350 echo
$xoops->alert(
'error', $block->getHtmlErrors());
355 $blockmodulelink_handler =
$xoops->getHandlerBlockmodulelink();
358 $blockmodulelink_handler->deleteAll(
$criteria);
362 $blockmodulelink = $blockmodulelink_handler->create();
363 $blockmodulelink->setVar(
'block_id', $newid);
364 $blockmodulelink->setVar(
'module_id', $mid);
365 if (!$blockmodulelink_handler->insert($blockmodulelink)) {
367 echo
$xoops->alert(
'error', $blockmodulelink->getHtmlErrors());
373 $groupperm_handler =
$xoops->getHandlerGroupperm();
375 $groups_with_access = $groupperm_handler->getGroupIds(
"block_read", $newid);
376 $removed_groups = array_diff($groups_with_access,
$groups);
377 if (count($removed_groups) > 0) {
378 foreach ($removed_groups as $groupid) {
383 $perm = $groupperm_handler->getObjects(
$criteria);
384 if (isset($perm[0]) && is_object($perm[0])) {
385 $groupperm_handler->delete($perm[0]);
389 $new_groups = array_diff(
$groups, $groups_with_access);
390 if (count($new_groups) > 0) {
391 foreach ($new_groups as $groupid) {
392 $groupperm_handler->addRight(
"block_read", $newid, $groupid);
400 $block_handler =
$xoops->getHandlerBlock();
402 $block_id =
$system->cleanVars($_REQUEST,
'bid', 0,
'int');
405 $xoops->header(
'admin:system/system_blocks.tpl');
407 $xoops->theme()->addStylesheet(
'modules/system/css/admin.css');
408 $xoops->theme()->addScript(
'media/jquery/plugins/jquery.form.js');
409 $xoops->theme()->addScript(
'modules/system/js/admin.js');
415 $system->adminVersion(
'blocksadmin',
'adminpath')
419 $block = $block_handler->get($block_id);
433 $xoops->header(
'admin:system/system_blocks.tpl');
435 $xoops->theme()->addStylesheet(
'modules/system/css/admin.css');
441 $system->adminVersion(
'blocksadmin',
'adminpath')
446 $block_handler =
$xoops->getHandlerBlock();
448 $block_id =
$system->cleanVars($_REQUEST,
'bid', 0,
'int');
450 $block = $block_handler->get($block_id);
451 if ($block->getVar(
'block_type') ==
'S') {
454 } elseif ($block->getVar(
'block_type') ==
'M') {
459 if (1 >=
$count = $block_handler->countSimilarBlocks(
460 $block->getVar(
'mid'),
461 $block->getVar(
'func_num'),
462 $block->getVar(
'show_func')
469 $xoops->header(
'admin:system/system_header.tpl');
471 echo
$xoops->confirm(array(
473 'fct' =>
'blocksadmin',
474 'bid' => $block->getVar(
'bid')
482 if (!
$xoops->security()->check()) {
483 $xoops->redirect(
'admin.php?fct=blocksadmin', 3, implode(
'<br />',
$xoops->security()->getErrors()));
487 $block_handler =
$xoops->getHandlerBlock();
489 $block_id =
$system->cleanVars($_POST,
'bid', 0,
'int');
491 $block = $block_handler->get($block_id);
492 if ($block_handler->deleteBlock($block)) {
494 $blockmodulelink_handler =
$xoops->getHandlerBlockmodulelink();
497 foreach ($blockmodulelink as
$link) {
498 $blockmodulelink_handler->delete($link,
true);
501 $groupperm_handler =
$xoops->getHandlerGroupperm();
504 $groupperm = $groupperm_handler->getObjects(
$criteria);
506 foreach ($groupperm as $perm) {
507 $groupperm_handler->delete($perm,
true);
510 if ($block->getVar(
'template') !=
'') {
511 $tplfile_handler =
$xoops->getHandlerTplfile();
512 $btemplate = $tplfile_handler->find(
$xoops->getConfig(
'template_set'),
'block', $block_id);
513 if (count($btemplate) > 0) {
514 $tplfile_handler->deleteTpl($btemplate[0]);
526 $block_handler =
$xoops->getHandlerBlock();
528 $block_id =
$system->cleanVars($_REQUEST,
'bid', 0,
'int');
531 $xoops->header(
'admin:system/system_blocks.tpl');
533 $xoops->theme()->addStylesheet(
'modules/system/css/admin.css');
543 $block = $block_handler->get($block_id);
546 $form->getForm(
'clone');
if(empty($settings['ROOT_PATH'])) elseif(empty($settings['DB_PARAMETERS'])) $error
const BLOCKS_ADMINISTRATION
static getInstance($fct= '')
if(in_array($op, array('install', 'update', 'uninstall'))) $myts
system_adminVersion($version, $value= '')
const E_THIS_BLOCK_CANNOT_BE_DELETED
const E_SYSTEM_BLOCKS_CANNOT_BE_DELETED
const CUSTOM_BLOCK_AUTO_FORMAT_SMILIES
foreach($sel as $key=> $value) $type
const CUSTOM_BLOCK_AUTO_FORMAT
const E_NO_ACCESS_PERMISSION
const QF_ARE_YOU_SURE_TO_DELETE_THIS_BLOCK
const E_DATABASE_NOT_UPDATED