예제 #1
0
 public static function getModuleMenus()
 {
     $menus = array();
     foreach (WT_Module::getActiveMenus() as $module) {
         $menu = $module->getMenu();
         if ($menu) {
             $menus[] = $menu;
         }
     }
     return $menus;
 }
예제 #2
0
require 'includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Module administration'))->pageHeader()->addInlineJavascript('
    jQuery("#menus_table").sortable({items: ".sortme", forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});

    //-- update the order numbers after drag-n-drop sorting is complete
    jQuery("#menus_table").bind("sortupdate", function(event, ui) {
			jQuery("#"+jQuery(this).attr("id")+" input").each(
				function (index, value) {
					value.value = index+1;
				}
			);
		});
	');
$modules = WT_Module::getActiveMenus(WT_GED_ID, WT_PRIV_HIDE);
$action = WT_Filter::post('action');
if ($action == 'update_mods' && WT_Filter::checkCsrf()) {
    foreach ($modules as $module_name => $module) {
        foreach (WT_Tree::getAll() as $tree) {
            $access_level = WT_Filter::post("menuaccess-{$module_name}-{$tree->tree_id}", WT_REGEX_INTEGER, $module->defaultAccessLevel());
            WT_DB::prepare("REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'menu', ?)")->execute(array($module_name, $tree->tree_id, $access_level));
        }
        $order = WT_Filter::post('menuorder-' . $module_name);
        WT_DB::prepare("UPDATE `##module` SET menu_order=? WHERE module_name=?")->execute(array($order, $module_name));
        $module->order = $order;
        // Make the new order take effect immediately
    }
    uasort($modules, function ($x, $y) {
        return $x->order - $y->order;
    });