From ff095770a7e537426648c7ac6bbbd0119d7dbb2b Mon Sep 17 00:00:00 2001 From: chaveiro Date: Thu, 7 Oct 2021 10:20:39 +0100 Subject: [PATCH 1/3] Fix security, menu and support large screens - Fix security, only allow if user is reader or writer - Fix menu integration, only show if user is logeed - Allow large screens expand --- graph.css | 2 +- graph.js | 26 ++++++++++++++------------ graph_controller.php | 4 ++-- graph_menu.php | 15 ++++++++------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/graph.css b/graph.css index 045cfa4..572a88f 100644 --- a/graph.css +++ b/graph.css @@ -1,4 +1,4 @@ -.content-container { max-width:1150px; } +/* .content-container { max-width:1150px; } make usable on large devices*/ /* ------------------------------------------ */ /* REMOVE ONCE GROUP VIEW SIDEBAR REMOVED */ diff --git a/graph.js b/graph.js index a3facd8..06d231d 100644 --- a/graph.js +++ b/graph.js @@ -227,18 +227,20 @@ function graph_init_editor() // --------------------------------------------------------------- // Writting direct to the menu system here // --------------------------------------------------------------- - // 1. Populate custom l3 menu from sidebar html placed in hidden element - $(".menu-l3").html($("#sidebar_html").html()); - // 2. Clear original hidden element - $("#sidebar_html").html(""); - // 3. Populate with feed list selector - $("#feeds").html(out); - // 4. Show l3 menu - if (menu.width>=576) menu.show_l3(); - // 5. Enable l3 menu so that collapsing and re-expanding works if (menu.obj.setup!=undefined) { - menu.obj.setup.l2.graph.l3 = [] - menu.active_l3 = true; + if (menu.obj.setup.l2.graph != undefined) { + // 1. Populate custom l3 menu from sidebar html placed in hidden element + $(".menu-l3").html($("#sidebar_html").html()); + // 2. Clear original hidden element + $("#sidebar_html").html(""); + // 3. Populate with feed list selector + $("#feeds").html(out); + // 4. Show l3 menu + if (menu.width>=576) menu.show_l3(); + // 5. Enable l3 menu so that collapsing and re-expanding works + menu.obj.setup.l2.graph.l3 = [] + menu.active_l3 = true; + } } load_saved_graphs_menu(); // --------------------------------------------------------------- @@ -1841,7 +1843,7 @@ function printdate(timestamp) if (secs<10) secs = "0"+secs; var datestr = ""; - // date.getHours()+":"+minutes+" "+day+" "+month; + // date.getHours()+":"+minutes+" "+day+" "+month; datestr += day+"/"+month; if (thisyear!=year) datestr += "/"+year; datestr += " " + date.getHours()+":"+minutes+":"+secs; diff --git a/graph_controller.php b/graph_controller.php index 8291f69..787e87f 100644 --- a/graph_controller.php +++ b/graph_controller.php @@ -17,7 +17,7 @@ function graph_controller() require_once "Modules/graph/graph_model.php"; $graph = new Graph($mysqli, $group); - $result = ""; + $result = false; if ($route->action=="embed") { global $embed; $embed = true; @@ -70,7 +70,7 @@ function graph_controller() else if ($group && $route->action=="groupgraph") { $result = view("Modules/graph/group_view.php", array("session" => $session["write"], 'group_support' => 1)); } - else { + else if ($session['read']){ $result = view("Modules/graph/view.php", array("session" => $session["write"])); } diff --git a/graph_menu.php b/graph_menu.php index fd9ecbb..ef45dac 100644 --- a/graph_menu.php +++ b/graph_menu.php @@ -1,12 +1,13 @@ _("Graphs"), - "href"=>"graph", - "order"=>3, - "icon"=>"show_chart" -); - + $menu["setup"]["l2"]['graph'] = array( + "name"=>_("Graphs"), + "href"=>"graph", + "order"=>3, + "icon"=>"show_chart" + ); +} // Full level3 sidebar is added via javascript in graph.js From ac8386be829d63508777cf21cd1fd0bf2af65cb3 Mon Sep 17 00:00:00 2001 From: chaveiro Date: Thu, 7 Oct 2021 10:25:51 +0100 Subject: [PATCH 2/3] Update graph_menu.php --- graph_menu.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/graph_menu.php b/graph_menu.php index ef45dac..3a02e70 100644 --- a/graph_menu.php +++ b/graph_menu.php @@ -2,12 +2,11 @@ global $session; if ($session["read"]) { // Initial graph menu item placement - $menu["setup"]["l2"]['graph'] = array( - "name"=>_("Graphs"), - "href"=>"graph", - "order"=>3, - "icon"=>"show_chart" - ); + $menu["setup"]["l2"]['graph'] = array( + "name"=>_("Graphs"), + "href"=>"graph", + "order"=>3, + "icon"=>"show_chart" + ); } // Full level3 sidebar is added via javascript in graph.js - From c9a8da34904411a5bdb7b87038f7cf3cf69a67df Mon Sep 17 00:00:00 2001 From: chaveiro Date: Wed, 13 Oct 2021 21:20:50 +0100 Subject: [PATCH 3/3] Fix menu system integration when logged out --- graph.js | 6 +++--- graph_controller.php | 2 +- graph_menu.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/graph.js b/graph.js index 06d231d..f58fe10 100644 --- a/graph.js +++ b/graph.js @@ -235,11 +235,11 @@ function graph_init_editor() $("#sidebar_html").html(""); // 3. Populate with feed list selector $("#feeds").html(out); - // 4. Show l3 menu - if (menu.width>=576) menu.show_l3(); - // 5. Enable l3 menu so that collapsing and re-expanding works + // 4. Enable l3 menu menu.obj.setup.l2.graph.l3 = [] menu.active_l3 = true; + // 5. Show l3 menu now (next line or just the if may not be neede as menu class will use auto hide feature when needed) + if (menu.width>=576) menu.show_l3(); } } load_saved_graphs_menu(); diff --git a/graph_controller.php b/graph_controller.php index 787e87f..881547a 100644 --- a/graph_controller.php +++ b/graph_controller.php @@ -70,7 +70,7 @@ function graph_controller() else if ($group && $route->action=="groupgraph") { $result = view("Modules/graph/group_view.php", array("session" => $session["write"], 'group_support' => 1)); } - else if ($session['read']){ + else if ($session['read'] || isset($_GET['userid'])){ // allow emoncms.org/graph?userid=1 to work $result = view("Modules/graph/view.php", array("session" => $session["write"])); } diff --git a/graph_menu.php b/graph_menu.php index 3a02e70..463dc17 100644 --- a/graph_menu.php +++ b/graph_menu.php @@ -1,6 +1,6 @@ _("Graphs"),