. */ namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsDb; /** @global Tree $WT_TREE */ global $WT_TREE; require 'includes/session.php'; $controller = new PageController; // Only one of $user_id and $gedcom_id should be set $user_id = Filter::get('user_id', WT_REGEX_INTEGER, Filter::post('user_id', WT_REGEX_INTEGER)); $gedcom_id = Filter::get('gedcom_id', WT_REGEX_INTEGER, Filter::post('gedcom_id', WT_REGEX_INTEGER)); if ($user_id) { $gedcom_id = null; if ($user_id < 0) { $controller->setPageTitle(I18N::translate('Set the default blocks for new users')); $can_reset = false; } else { $controller->setPageTitle(I18N::translate('Change the “My page” blocks')); $can_reset = true; } } else { if ($gedcom_id < 0) { $controller->setPageTitle(I18N::translate('Set the default blocks for new family trees')); $can_reset = false; } else { $controller->setPageTitle(I18N::translate('Change the “Home page” blocks')); $can_reset = true; } } // Only an admin can edit the "default" page // Only managers can edit the "home page" // Only a user or an admin can edit a user’s "my page" if ( $gedcom_id < 0 && !Auth::isAdmin() || $gedcom_id > 0 && !Auth::isManager(Tree::findById($gedcom_id)) || $user_id && Auth::id() != $user_id && !Auth::isAdmin() ) { header('Location: index.php'); return; } $action = Filter::get('action'); if ($can_reset && Filter::post('default') === '1') { if ($user_id) { $defaults = FunctionsDb::getUserBlocks(-1); } else { $defaults = FunctionsDb::getTreeBlocks(-1); } $main = $defaults['main']; $right = $defaults['side']; } else { if (isset($_REQUEST['main'])) { $main = $_REQUEST['main']; } else { $main = []; } if (isset($_REQUEST['side'])) { $side = $_REQUEST['side']; } else { $side = []; } } $all_blocks = []; foreach (Module::getActiveBlocks($WT_TREE) as $name => $block) { if ($user_id && $block->isUserBlock() || $gedcom_id && $block->isGedcomBlock()) { $all_blocks[$name] = $block; } } if ($user_id) { $blocks = FunctionsDb::getUserBlocks($user_id); } else { $blocks = FunctionsDb::getTreeBlocks($gedcom_id); } if ($action === 'update') { foreach (['main', 'side'] as $location) { if ($location === 'main') { $new_blocks = $main; } else { $new_blocks = $side; } foreach ($new_blocks as $order => $block_name) { if (is_numeric($block_name)) { // existing block Database::prepare("UPDATE `##block` SET block_order=? WHERE block_id=?")->execute([$order, $block_name]); // existing block moved location Database::prepare("UPDATE `##block` SET location=? WHERE block_id=?")->execute([$location, $block_name]); } else { // new block if ($user_id) { Database::prepare("INSERT INTO `##block` (user_id, location, block_order, module_name) VALUES (?, ?, ?, ?)")->execute([$user_id, $location, $order, $block_name]); } else { Database::prepare("INSERT INTO `##block` (gedcom_id, location, block_order, module_name) VALUES (?, ?, ?, ?)")->execute([$gedcom_id, $location, $order, $block_name]); } } } // deleted blocks foreach ($blocks[$location] as $block_id => $block_name) { if (!in_array($block_id, $main) && !in_array($block_id, $side)) { Database::prepare("DELETE FROM `##block_setting` WHERE block_id=?")->execute([$block_id]); Database::prepare("DELETE FROM `##block` WHERE block_id=?")->execute([$block_id]); } } } if ($user_id < 0 || $gedcom_id < 0 ) { header('Location: admin.php'); } elseif ($user_id > 0) { header('Location: index.php?ctype=user&ged=' . $WT_TREE->getNameUrl()); } else { header('Location: index.php?ctype=gedcom&ged=' . $WT_TREE->getNameUrl()); } return; } $controller->pageHeader(); ?>

getPageTitle() ?>

'btn btn-link', 'href' => '#', 'onclick' => 'return move_up_block("main_select");']) ?>
'btn btn-link', 'href' => '#', 'onclick' => 'return move_left_right_block("main_select", "side_select");']) ?>
'btn btn-link', 'href' => '#', 'onclick' => 'return move_left_right_block("main_select", "available_select");']) ?>
'btn btn-link', 'href' => '#', 'onclick' => 'return move_down_block("main_select");']) ?>
'btn btn-link', 'href' => '#', 'onclick' => 'return move_left_right_block("available_select", "main_select");']) ?> 'btn btn-link', 'href' => '#', 'onclick' => 'return move_left_right_block("available_select", "side_select");']) ?> 'btn btn-link', 'href' => '#', 'onclick' => 'return move_up_block("side_select");']) ?>
'btn btn-link', 'href' => '#', 'onclick' => 'return move_left_right_block("side_select", "main_select");']) ?>
'btn btn-link', 'href' => '#', 'onclick' => 'return move_left_right_block("side_select", "available_select");']) ?>
'btn btn-link', 'href' => '#', 'onclick' => 'return move_down_block("side_select");']) ?>
 
0): ?>