Commit 31df024e authored by Ad Schellevis's avatar Ad Schellevis

replace menusystem / integrate with new MVC framework

Next step in integrating our new MVC framework, the mainmenu in the left panel uses the same logic now for both legacy as new content.

- add feature, hide empty items
- configuration in /usr/local/opnsense/mvc/app/models/OPNsense/Base/Menu/Menu.xml
parent fa395656
......@@ -12,8 +12,6 @@
<UpdaterSettings VisibleName="Updater Settings" url="/system_firmware_settings.php"/>
</Firmware>
<GeneralSetup VisibleName="General Setup" url="/system_general.php"/>
<HighAvailSync VisibleName="High Availability" url="/system_hasync.php"/>
<Routing url="/system_gateways.php"/>
......@@ -101,7 +99,7 @@
<PPPoEServer VisibleName="PPPoE Server" url="/services_vpn_pppoe.php"/>
<SNMP VisibleName="SNMP" url="/services_snmp.php"/>
<UPnPNATPMP VisibleName="Universal P&amp;P / NAT-PMP" url="/pkg_edit.php?xml=miniupnpd.xml"/>
<WoL VisibleName="Wake on LAN" url="/pkg_edit.php?xml=miniupnpd.xml"/>
<WoL VisibleName="Wake on LAN" url="/services_wol.php"/>
</Services>
<VPN order="4" cssClass="glyphicon glyphicon-lock">
......@@ -126,8 +124,8 @@
<Status order="5" cssClass="glyphicon glyphicon-tasks">
<CaptivePortal VisibleName="Captive Portal" url="/status_captiveportal.php"/>
<CARP url="/status_captiveportal.php"/>
<DHCPLeases VisibleName="DHCP IPv4 Leases" url="/status_captiveportal.php"/>
<DHCPv6Leases VisibleName="DHCP IPv6 Leases" url="/status_captiveportal.php"/>
<DHCPLeases VisibleName="DHCP IPv4 Leases" url="/status_dhcp_leases.php"/>
<DHCPv6Leases VisibleName="DHCP IPv6 Leases" url="/status_dhcpv6_leases.php"/>
<FilterReload VisibleName="Filter Reload" url="/status_filter_reload.php"/>
<Gateways url="/status_gateways.php">
<GatewayGroups url="/status_gateway_groups.php"/>
......
......@@ -82,6 +82,14 @@ class ACL
$this->legacyUsers[$node->name->__toString()] = array() ;
$this->legacyUsers[$node->name->__toString()]["uid"] = $node->uid->__toString();
$this->legacyUsers[$node->name->__toString()]["groups"] = array();
$this->legacyUsers[$node->name->__toString()]["priv"] = array();
foreach ($node->priv as $priv) {
if (substr($priv, 0, 5) == "page-") {
if (array_key_exists($priv->__toString(), $legacyPageMap)) {
$this->legacyUsers[$node->name->__toString()]["priv"][] = $legacyPageMap[$priv->__toString()] ;
}
}
}
} elseif ($key == "group") {
$groupmap[$node->name->__toString()] = $node ;
}
......@@ -115,6 +123,16 @@ class ACL
public function isPageAccessible($username, $url)
{
if (array_key_exists($username, $this->legacyUsers)) {
// search user privs
foreach ($this->legacyUsers[$username]["priv"] as $privset) {
foreach ($privset as $urlmask) {
$match = str_replace(array(".", "*","?"), array("\.", ".*","\?"), $urlmask);
$result = preg_match("@^/{$match}$@", "{$url}");
if ($result) {
return true;
}
}
}
// search groups
foreach ($this->legacyUsers[$username]["groups"] as $itemkey => $group) {
if (array_key_exists($group, $this->legacyGroupPrivs)) {
......
......@@ -32,7 +32,7 @@ require_once("guiconfig.inc");
$host = trim($_REQUEST['host'], " \t\n\r\0\x0B[];\"'");
$host_esc = escapeshellarg($host);
if (is_array($config['aliases']['alias'])) {
if (isset($config['aliases']['alias']) && is_array($config['aliases']['alias'])) {
$a_aliases = &$config['aliases']['alias'];
} else {
$a_aliases = array();
......@@ -271,3 +271,4 @@ include("head.inc"); ?>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
This diff is collapsed.
......@@ -61,5 +61,9 @@
</div><!-- /modal -->
<?php endif; ?>
<!-- bootstrap script -->
<script type="text/javascript" src="/javascript/bootstrap.min.js"></script>
<!-- Fancy select with search options -->
<script type="text/javascript" src="/javascript/bootstrap-select.min.js"></script>
</body>
</html>
......@@ -43,13 +43,15 @@ $pagetitle = gentitle( $pgtitle );
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
<script>var theme = '<?=$g['theme'];?>'; </script>
<script src="/themes/<?=$g['theme'];?>/build/js/main.min.js" type="text/javascript"></script>
<!-- Fancy select with search options -->
<script src="/themes/<?=$g['theme'];?>/build/js/bootstrap-select.min.js" type="text/javascript"></script>
<!-- JQuery -->
<script type="text/javascript" src="/javascript/jquery-1.11.2.min.js"></script>
<!-- Ticker used for notices-->
<script type="text/javascript" src="/javascript/ticker.js"></script>
<script type="text/javascript" src="/javascript/ticker.js"></script>
<?php
/*
......@@ -76,21 +78,21 @@ $pagetitle = gentitle( $pgtitle );
<?php if (basename($_SERVER["SCRIPT_FILENAME"] != "index.php") && !$allowautocomplete): ?>
<script type="text/javascript">
//<![CDATA[
(function ($) {
$( document ).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
$("input").attr("autocomplete","off");
})(jQuery);
jQuery(function () {
jQuery('[data-toggle="tooltip"]').tooltip()
})
// hide empty menu items
$('#mainmenu > div > .collapse').each(function(){
if ($(this).children().length == 0) {
$("#mainmenu").find('[href="#'+$(this).attr('id')+'"]').remove();
}
});
});
//]]>
</script>
<? endif; ?>
<? endif; ?>
<?php if (!$closehead):?></head><? endif;?>
<?php
<?php if (!$closehead):?></head><? endif;?>
?>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -333,14 +333,6 @@ include("head.inc");
<body onload="<?= $jsevents["body"]["onload"] ?>">
<script type="text/javascript">
//<![CDATA[
jQuery(function() {
jQuery( "#expires" ).datepicker( { dateFormat: 'mm/dd/yy', changeYear: true, yearRange: "+0:+100" } );
});
//]]>
</script>
<?php include("fbegin.inc"); ?>
<script type="text/javascript">
......
$(document).ready(function(){
$('#btn-filter').click(function () {
var btn = $(this)
btn.button('loading')
/*
$.ajax(...).always(function () {
btn.button('reset')
});
*/
});
$(' #system,
#interfaces,
#firewall,
#services,
#vpn,
#status,
#diagnostics,
#help
').on('show.bs.collapse', function () {
// remove all actives
$("#mainmenu a.active-menu-title").removeClass('active-menu-title');
$("#mainmenu a + div.active-menu").removeClass('active-menu');
// remove all collaped
$("#mainmenu .collapse.in").not(this).collapse('hide');
$(this).prev('a').addClass('active-menu-title');
$(this).addClass('active-menu');
});
});
This diff is collapsed.
This diff is collapsed.
$(document).ready(function(){
$('#btn-filter').click(function () {
var btn = $(this)
btn.button('loading')
/*
$.ajax(...).always(function () {
btn.button('reset')
});
*/
});
$(' #system,
#interfaces,
#firewall,
#services,
#vpn,
#status,
#diagnostics,
#help
').on('show.bs.collapse', function () {
// remove all actives
$("#mainmenu a.active-menu-title").removeClass('active-menu-title');
$("#mainmenu a + div.active-menu").removeClass('active-menu');
// remove all collaped
$("#mainmenu .collapse.in").not(this).collapse('hide');
$(this).prev('a').addClass('active-menu-title');
$(this).addClass('active-menu');
});
});
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment