public function sortChartInSession(array $charts, GraphOnTrackersV5_Chart $edited_chart, $wanted_position)
 {
     $this->moveElementInCollection($charts, $edited_chart, $wanted_position);
     $rank = 0;
     foreach ($charts as $chart) {
         $id = $chart->getId();
         $this->session->set("charts.{$id}.rank", $rank);
         $chart->setRank($rank);
         ++$rank;
     }
 }
 protected function instanciateChart($row, $renderer, $store_in_session = true)
 {
     $c = null;
     if ($chart_classname = $this->getChartClassname($row['chart_type'])) {
         if ($store_in_session) {
             $session = new Tracker_Report_Session($renderer->report->id);
             $session->changeSessionNamespace("renderers.{$renderer->id}");
             $session->set("charts.{$row['id']}.chart_type", $row['chart_type']);
         }
         $c = new $chart_classname($renderer, $row['id'], $row['rank'], $row['title'], $row['description'], $row['width'], $row['height']);
         if ($store_in_session) {
             $c->loadFromSession();
         } else {
             $c->loadFromDb();
         }
     }
     return $c;
 }
 /**
  * Add a new renderer in session
  * @param Report $report the id of the report
  * @param string $name
  * @param string $description
  * @param string $type
  */
 public function createInSession($report, $name, $description, $type)
 {
     $renderer_id = false;
     $type = $type ? $type : Tracker_Report_Renderer::TABLE;
     $types = $this->getTypes();
     if (isset($types[$type])) {
         $session = new Tracker_Report_Session($report->id);
         $session->changeSessionNamespace('renderers');
         $nb_renderers = count($report->getRenderers());
         $renderer_id = -$nb_renderers - 1;
         $session->set($renderer_id, array('id' => $renderer_id, 'name' => $name, 'description' => $description, 'rank' => $nb_renderers, 'renderer_type' => $type));
         if ($this->report_session) {
             $this->report_session->setHasChanged();
         }
         switch ($type) {
             case Tracker_Report_Renderer::TABLE:
                 $session->set("{$renderer_id}.chunksz", 15);
                 $session->set("{$renderer_id}.multisort", 0);
                 break;
             case Tracker_Report_Renderer::BOARD:
                 //Not yet implemented
                 break;
             default:
                 $this->getEventManager()->processEvent('tracker_report_create_renderer_in_session', array('renderer_id' => $renderer_id, 'type' => $type, 'report' => $report));
                 break;
         }
     }
     return $renderer_id;
 }