1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2019 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16namespace Fisharebest\Webtrees; 17 18use Fisharebest\Webtrees\Controller\PageController; 19use Fisharebest\Webtrees\Functions\FunctionsEdit; 20use Fisharebest\Webtrees\Module\ModuleConfigInterface; 21 22define('WT_SCRIPT_NAME', 'admin_module_charts.php'); 23require 'includes/session.php'; 24 25$controller = new PageController; 26$controller 27 ->restrictAccess(Auth::isAdmin()) 28 ->setPageTitle(I18N::translate('Charts')); 29 30$action = Filter::post('action'); 31$modules = Module::getAllModulesByComponent('chart'); 32 33if ($action === 'update_mods' && Filter::checkCsrf()) { 34 foreach ($modules as $module) { 35 foreach (Tree::getAll() as $tree) { 36 $access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel()); 37 Database::prepare( 38 "REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'chart', ?)" 39 )->execute(array($module->getName(), $tree->getTreeId(), $access_level)); 40 } 41 } 42 43 header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); 44 45 return; 46} 47 48$controller 49 ->pageHeader(); 50 51?> 52<ol class="breadcrumb small"> 53 <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> 54 <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> 55 <li class="active"><?php echo $controller->getPageTitle(); ?></li> 56</ol> 57 58<h1><?php echo $controller->getPageTitle(); ?></h1> 59 60<form method="post"> 61 <input type="hidden" name="action" value="update_mods"> 62 <?php echo Filter::getCsrf(); ?> 63 <table class="table table-bordered"> 64 <thead> 65 <tr> 66 <th class="col-xs-2"><?php echo I18N::translate('Chart'); ?></th> 67 <th class="col-xs-5"><?php echo I18N::translate('Description'); ?></th> 68 <th class="col-xs-5"><?php echo I18N::translate('Access level'); ?></th> 69 </tr> 70 </thead> 71 <tbody> 72 <?php foreach ($modules as $module_name => $module): ?> 73 <tr> 74 <td class="col-xs-2"> 75 <?php if ($module instanceof ModuleConfigInterface): ?> 76 <a href="<?php echo $module->getConfigLink(); ?>"><?php echo $module->getTitle(); ?> <i class="fa fa-cogs"></i></a> 77 <?php else: ?> 78 <?php echo $module->getTitle(); ?> 79 <?php endif; ?> 80 </td> 81 <td class="col-xs-5"><?php echo $module->getDescription(); ?></td> 82 <td class="col-xs-5"> 83 <table class="table"> 84 <tbody> 85 <?php foreach (Tree::getAll() as $tree): ?> 86 <tr> 87 <td> 88 <?php echo $tree->getTitleHtml(); ?> 89 </td> 90 <td> 91 <?php echo FunctionsEdit::editFieldAccessLevel('access-' . $module->getName() . '-' . $tree->getTreeId(), $module->getAccessLevel($tree, 'chart')); ?> 92 </td> 93 </tr> 94 <?php endforeach; ?> 95 </tbody> 96 </table> 97 </td> 98 </tr> 99 <?php endforeach; ?> 100 </tbody> 101 </table> 102 <button class="btn btn-primary" type="submit"> 103 <i class="fa fa-check"></i> 104 <?php echo I18N::translate('save'); ?> 105 </button> 106</form> 107