Example #1
0
            fRequest::validateCSRFToken(fRequest::get('token'));
            $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';
    try {
        $obj = new Graph($graph_id);
        $dashboard = new Dashboard($obj->getDashboardId());
        $delete_text = 'Are you sure you want to delete the graph : <strong>' . $obj->getName() . '</strong>?';
        if (fRequest::isPost()) {
            fRequest::validateCSRFToken(fRequest::get('token'));
            $obj->delete();
            $lines = Line::findAll($graph_id);
            foreach ($lines as $line) {
                $line->delete();
            }
            fMessaging::create('success', Dashboard::makeUrl('edit', $dashboard), 'The graph for ' . $dashboard->getName() . ' was successfully deleted');
            fURL::redirect(Dashboard::makeUrl('edit', $dashboard));
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', Dashboard::makeUrl('edit', $dashboard), 'The line requested could not be found');
        fURL::redirect(Dashboard::makeUrl('edit', $dashboard));
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
Example #2
0
            fMessaging::create('success', fURL::get(), 'The Graph ' . $graph_to_clone->getName() . ' was successfully cloned');
            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();
Example #3
0
 /**
  * Constructor for GraphTraversal.
  * @param Graph $graph Graph to be traversed.
  */
 public function __construct(&$graph)
 {
     parent::__construct($graph->getName(), $graph->isDirected());
 }
Example #4
0
        fMessaging::create('error', Graph::makeUrl('edit', $graph), 'The line requested could not be found');
        fURL::redirect(Graph::makeUrl('edit', $graph));
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    include VIEW_PATH . '/delete.php';
    // --------------------------------- //
} elseif ('edit' == $action) {
    try {
        $line = new Line($line_id);
        $graph = new Graph($line->getGraphId());
        if (fRequest::isPost()) {
            $line->populate();
            fRequest::validateCSRFToken(fRequest::get('token'));
            $line->store();
            fMessaging::create('affected', fURL::get(), $graph->getName());
            fMessaging::create('success', fURL::getWithQueryString(), 'The Line ' . $line->getAlias() . ' was successfully updated');
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', Graph::makeUrl('edit', $graph), 'The Line requested, ' . fHTML::encode($line_id) . ', could not be found');
        fURL::redirect(Graph::makeUrl('edit', $graph));
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    include VIEW_PATH . '/add_edit_line.php';
    // --------------------------------- //
} elseif ('add' == $action) {
    $line = new Line();
    $graph = new Graph($graph_id);
    if (fRequest::isPost()) {
        try {
 /**
  * Load a graph using its ID
  * @param $id integer
  * @return Graph if found, otherwise NULL
  */
 public function getGraph($id)
 {
     global $master_db_handle;
     foreach ($this->graphCache as $graphName => $graph) {
         if ($graph->getID() == $id) {
             return $graph;
         }
     }
     $statement = $master_db_handle->prepare('SELECT ID, Plugin, Type, Active, Readonly, Name, DisplayName, Scale, Halfwidth, Position FROM Graph WHERE ID = ?');
     $statement->execute(array($id));
     if ($row = $statement->fetch()) {
         $graph = new Graph($row['ID'], $this, $row['Type'], $row['Name'], $row['DisplayName'], $row['Active'], $row['Readonly'], $row['Position'], $row['Scale'], $row['Halfwidth'] == 1);
         $this->graphCache[$graph->getName()] = $graph;
         return $graph;
     }
     return null;
 }
Example #6
0
            fRequest::validateCSRFToken(fRequest::get('token'));
            $graph->store();
            fMessaging::create('affected', fURL::get(), $graph->getName());
            fMessaging::create('success', fURL::getWithQueryString(), 'The Graph ' . $graph->getName() . ' was successfully updated');
            //fURL::redirect($manage_url);
        }
    } 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();
            fRequest::validateCSRFToken(fRequest::get('token'));
            $graph->store();
            fMessaging::create('affected', $manage_url, $graph->getName());
            fMessaging::create('success', $manage_url, 'The Graph ' . $graph->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_graph.php';
}
Example #7
0
 public static function cloneGraph($graph_id, $dashboard_id = NULL)
 {
     $graph_to_clone = new Graph($graph_id);
     if (empty($dashboard_id)) {
         $dashboard_id = $graph_to_clone->getDashboardId();
     }
     $graph = new Graph();
     $clone_name = 'Clone of ' . $graph_to_clone->getName();
     // If it's too long, we truncate
     if (strlen($clone_name) > 255) {
         $clone_name = substr($clone_name, 0, 255);
     }
     $graph->setName($clone_name);
     $graph->setArea($graph_to_clone->getArea());
     $graph->setVtitle($graph_to_clone->getVtitle());
     $graph->setDescription($graph_to_clone->getDescription());
     $graph->setDashboardId($dashboard_id);
     $graph->setWeight($graph_to_clone->getWeight());
     $graph->setTimeValue($graph_to_clone->getTimeValue());
     $graph->setUnit($graph_to_clone->getUnit());
     $graph->setCustomOpts($graph_to_clone->getCustomOpts());
     $graph->setStartsAtMidnight($graph_to_clone->getStartsAtMidnight());
     $graph->store();
     // Clone of the lines
     $lines = Line::findAll($graph_id);
     foreach ($lines as $line_to_clone) {
         Line::cloneLine($line_to_clone->getLineId(), TRUE, $graph->getGraphId());
     }
 }