Skip to content
Snippets Groups Projects
Commit 503b596a authored by Imran Hussain's avatar Imran Hussain
Browse files

Security. Menu items that have a non null permission value in the menu table...

Security. Menu items that have a non null permission value in the menu table will now only be visiable to people with that permission, unlike before where it kinda half worked and everybody could see everything.
parent 9eea8b7a
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ function getPageID($name) { ...@@ -7,7 +7,7 @@ function getPageID($name) {
function translate($word) { function translate($word) {
global $language, $DB; global $language, $DB;
if ($language['code']!="en") { if ($language['code']!="en") {
$query=$DB->GetRow("select title, title".$language['db']." from menu where title='".$word."'"); $query=$DB->GetRow("select title, title".$language['db']." from menu where title='".$word."'");
if ($query['title'.$language['db']]!="") return $query['title'.$language['db']]; if ($query['title'.$language['db']]!="") return $query['title'.$language['db']];
...@@ -60,9 +60,25 @@ $res = $DB->GetAll($query); ...@@ -60,9 +60,25 @@ $res = $DB->GetAll($query);
$menu = parseMenu($res); $menu = parseMenu($res);
// this needs to choose the actual current one // this needs to choose the actual current one
$res = $DB->GetAll("select * from menu where parent=".getPageID($pagename)." order by menuorder"); // subpages/submenu items can have permissions attached to them as well!
if (count($res)>0) {
$submenu = parseMenu($res); $query2 = "select * from menu where parent=";
$query2 .= "'";
$query2 .= getPageID($pagename);
$query2 .= "'";
$query2 .= " and (permission is NULL";
if ($session->loggedin) $query2 .= " or permission='users'";
foreach ($session->groups as $group => $value) {
$query2 .= " or permission='$group'";
}
$query2 .= ") order by menuorder";
$res2 = $DB->GetAll($query2);
if (count($res2)>0) {
$submenu = parseMenu($res2);
$menu[translate($pagename)] = $submenu; $menu[translate($pagename)] = $submenu;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment