OPNsense Forum

English Forums => Development and Code Review => Topic started by: ruslan-gennadievich on September 25, 2020, 04:43:52 pm

Title: How hide menu (root user)
Post by: ruslan-gennadievich on September 25, 2020, 04:43:52 pm
I need hide some menu item in root user.
Now i modified  src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuItem.php

__construct (..) {
        if (self::$hiddenMenus === null && is_file('/usr/local/opnsense/hiddenMenus.txt')){
            self::$hiddenMenus = explode ("\n",file_get_contents('/usr/local/opnsense/hiddenMenus.txt'));
        }
}

and in
public function getChildren()
...
        foreach ($this->children as $key => &$node) {
            if (in_array($node->getId(), self::$hiddenMenus)) continue; //ADD THIS !
        ...
}

It works, but this core hack.
Maybe i can do it with plugin? some hooks? Without modified core...
Thanks!