fURL::redirect(Dashboard::makeURL('edit', $dashboard)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } } include VIEW_PATH . '/add_edit_dashboard.php'; } elseif ('clone_into' == $action) { if (fRequest::isPost()) { $graph_to_clone = new Graph($graph_id); $dashboard = new Dashboard($dashboard_dest_id); try { fRequest::validateCSRFToken(fRequest::get('token')); Graph::cloneGraph($graph_id, $dashboard_dest_id); $url_redirect = Dashboard::makeURL('list'); fMessaging::create('affected', $url_redirect, $graph_to_clone->getName()); fMessaging::create('success', "/" . $url_redirect, 'The Graph "' . $graph_to_clone->getName() . '" was successfully cloned into the Dashboard "' . $dashboard->getName() . '"'); fURL::redirect($url_redirect); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } } include VIEW_PATH . '/list_dashboards.php'; } elseif ('reorder' == $action) { $drag_order = fRequest::get('drag_order'); $error = false; if (empty($drag_order)) { // In this case, the user clicks on the arrow $move = fRequest::getValid('move', array('previous', 'next')); $graph_to_move = new Graph($graph_id); $dashboard_id = $graph_to_move->getDashboardId(); $graphs_in_dashboard = Graph::findAll($dashboard_id);
$quick_sizes_desired = array("100 x 50" => array("width" => "100", "height" => "50"), "300 x 150" => array("width" => "300", "height" => "150"), "600 x 300" => array("width" => "600", "height" => "300"), "900 x 450" => array("width" => "900", "height" => "450")); $display_options_links = fRequest::get('display_options_links', 'integer'); if (empty($display_options_links) || $display_options_links > 3 || $display_options_links < 0) { // The only possibles values are 0 to 3 // 0 -> Nothing displayed // 1 -> Only options are displayed // 2 -> Only links are displayed // 3 -> Both are displayed $display_options_links = 0; } include VIEW_PATH . '/view_dashboard.php'; } elseif ('delete' == $action) { $class_name = 'Dashboard'; try { $obj = new Dashboard($dashboard_id); $delete_text = 'Are you sure you want to delete dashboard : <strong>' . $obj->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); $graphs = Graph::findAll($dashboard_id); // Do Dashboard Subelement Cleanup foreach ($graphs as $graph) { $lines = Line::findAll($graph->getGraphId()); foreach ($lines as $line) { $line->delete(); } $graph->delete(); } fMessaging::create('success', Dashboard::makeUrl('list'), 'The Dashboard ' . $obj->getName() . ' was successfully deleted'); fURL::redirect(Dashboard::makeUrl('list')); }
} catch (fNotFoundException $e) { fMessaging::create('error', Dashboard::makeUrl('list'), 'The Dashboard requested ' . fHTML::encode($dashboard_id) . 'could not be found'); fURL::redirect(Dashboard::makeUrl('list')); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_dashboard.php'; // --------------------------------- // } elseif ('add' == $action) { $dashboard = new Dashboard(); if (fRequest::isPost()) { try { $dashboard->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $dashboard->store(); fMessaging::create('affected', fURL::get(), $dashboard->getName()); fMessaging::create('success', fURL::get(), 'The Dashboard ' . $dashboard->getName() . ' was successfully created'); fURL::redirect(Dashboard::makeURL('edit', $dashboard)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } } include VIEW_PATH . '/add_edit_dashboard.php'; } elseif ('view' == $action) { $dashboard = new Dashboard($dashboard_id); $graphs = Graph::findAll($dashboard_id); include VIEW_PATH . '/view_dashboard.php'; } else { $dashboards = Dashboard::findAll(); include VIEW_PATH . '/list_dashboards.php'; }