public static function cloneLine($line_id, $ignore_clone_name = FALSE, $graph_id = NULL) { $line_to_clone = new Line($line_id); if (empty($graph_id)) { $graph_id = $line_to_clone->getGraphId(); } $line = new Line(); if ($ignore_clone_name) { $clone_alias = $line_to_clone->getAlias(); } else { $clone_alias = 'Clone of ' . $line_to_clone->getAlias(); // If it's too long, we truncate if (strlen($clone_alias) > 255) { $clone_alias = substr($clone_alias, 0, 255); } } $line->setAlias($clone_alias); $line->setTarget($line_to_clone->getTarget()); $line->setColor($line_to_clone->getColor()); $line->setGraphId($graph_id); $line->setWeight($line_to_clone->getWeight()); $line->store(); }
$line->delete(); fMessaging::create('success', Graph::makeUrl('edit', $graph), 'The line for ' . $graph->getName() . ' was successfully deleted'); fURL::redirect(Graph::makeUrl('edit', $graph)); } } catch (fNotFoundException $e) { 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_line.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'); //fURL::redirect($manage_url); } } 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';
<?php include 'inc/init.php'; fAuthorization::requireLoggedIn(); fRequest::overrideAction(); $action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete', 'view')); $line_id = fRequest::get('line_id', 'integer'); $graph_id = fRequest::get('graph_id', 'integer'); if ('delete' == $action) { $class_name = 'Line'; try { $obj = new Line($line_id); $graph = new Graph($obj->getGraphId()); $delete_text = 'Are you sure you want to delete the line : <strong>' . $obj->getAlias() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); fMessaging::create('success', Graph::makeUrl('edit', $graph), 'The line for ' . $graph->getName() . ' was successfully deleted'); fURL::redirect(Graph::makeUrl('edit', $graph)); } } catch (fNotFoundException $e) { 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);
} } } } else { $skip_next = false; } } } else { // In this case the user has used the drag and drop functionnality $array_of_weights = explode(",", $drag_order); $lines_in_graph = array(); foreach ($array_of_weights as $new_weight) { $expl = explode(":", $new_weight); $current_line = new Line($expl[0]); if (empty($graph_id)) { $graph_id = $current_line->getGraphId(); } else { // Check if all the lines are in the same graph if ($graph_id != $current_line->getGraphId()) { $error = true; break; } } $current_line->setWeight($expl[1]); $lines_in_graph[] = $current_line; } } if (!$error) { foreach ($lines_in_graph as $line_to_store) { $line_to_store->store(); }