fURL::redirect(Dashboard::makeUrl('edit', $dashboard)); } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The Graph requested, ' . fHTML::encode($graph_id) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_graph.php'; // --------------------------------- // } elseif ('add' == $action) { $graph = new Graph(); $dashboard = new Dashboard($dashboard_id); if (fRequest::isPost()) { try { $graph->populate(); $graph->setStartsAtMidnight(isset($_POST['starts_at_midnight']) ? $_POST['starts_at_midnight'] : false); fRequest::validateCSRFToken(fRequest::get('token')); $graphs_in_dashboard = Graph::findAll($dashboard_id); $graph->setWeight($graphs_in_dashboard->count(TRUE)); $graph->store(); fMessaging::create('affected', $manage_url, $graph->getName()); fMessaging::create('success', $manage_url, 'The Graph ' . $graph->getName() . ' was successfully created'); fURL::redirect(Graph::makeUrl('edit', $graph)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } } include VIEW_PATH . '/add_edit_graph.php'; } elseif ('delete' == $action) { $class_name = 'Graph';