Skip to content

Commit

Permalink
add exception for zoomed/custom timespaned favourite graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
xmacan committed Dec 4, 2020
1 parent 3a6f9c0 commit 9e79dfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion include/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
WHERE user_id= ? AND fav_graph_id= ? AND fav_graph_timespan= ?',
array($_SESSION['sess_user_id'],get_request_var('graph_id'),$_SESSION['sess_current_timespan']));
} else { // add to fav
if ($_SESSION['sess_current_timespan'] == 0) {
raise_message('custom_error',__('Cannot add zoomed or custom timespaned graph, changing timespan to Last half hour'));
$span = 1;
}
else {
$span = $_SESSION['sess_current_timespan'];
}

$prio = db_fetch_cell_prepared('SELECT max(priority)+1
FROM plugin_intropage_panel_data
WHERE user_id = ?',
Expand All @@ -84,7 +92,7 @@
db_execute_prepared('REPLACE INTO plugin_intropage_panel_data
(user_id, panel_id, fav_graph_id, fav_graph_timespan, priority)
VALUES (?, "favourite_graph", ?, ?, ?)',
array($_SESSION['sess_user_id'],get_request_var('graph_id'),$_SESSION['sess_current_timespan'], $prio));
array($_SESSION['sess_user_id'],get_request_var('graph_id'), $span, $prio));

$id = db_fetch_insert_id();
db_execute_prepared('INSERT INTO plugin_intropage_panel_dashboard
Expand Down
8 changes: 6 additions & 2 deletions include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,13 @@ function intropage_graph_button($data) {
WHERE user_id= ?', array($_SESSION['sess_user_id'])) == 'on') {
$local_graph_id = $data[1]['local_graph_id'];

if (db_fetch_cell_prepared('SELECT COUNT(*) FROM plugin_intropage_panel_data

if ($_SESSION['sess_current_timespan'] == 0) { // zoom or custom timespan
$fav = '<i class="fa fa-eye-slash" title="' . __esc('Cannot add to Dashboard. Custom timespan.', 'intropage') . '"></i>';
}
else if (db_fetch_cell_prepared('SELECT COUNT(*) FROM plugin_intropage_panel_data
WHERE user_id= ? AND fav_graph_id= ? AND fav_graph_timespan= ?',
array($_SESSION['sess_user_id'],$local_graph_id,$_SESSION['sess_current_timespan'] )) > 0) { // already fav
array($_SESSION['sess_user_id'],$local_graph_id,$_SESSION['sess_current_timespan'])) > 0) { // already fav
$fav = '<i class="fa fa-eye-slash" title="' . __esc('Remove from Dashboard', 'intropage') . '"></i>';
} else { // add to fav
$fav = '<i class="fa fa-eye" title="' . __esc('Add to Dashboard', 'intropage') . '"></i>';
Expand Down

0 comments on commit 9e79dfa

Please sign in to comment.