Exemple #1
0
 /**
  * The project board whiteboard page
  *
  * @Route(url="/boards/:board_id/whiteboard")
  *
  * @param framework\Request $request
  */
 public function runWhiteboard(framework\Request $request)
 {
     $this->forward403unless($this->_checkProjectPageAccess('project_planning'));
     $this->board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
     $this->forward403unless($this->board instanceof entities\AgileBoard);
     try {
         if ($request->isPost()) {
             $columns = $request['columns'];
             $saved_columns = array();
             $cc = 1;
             if (is_array($columns)) {
                 foreach ($columns as $details) {
                     if ($details['column_id']) {
                         $column = entities\BoardColumn::getB2DBTable()->selectById($details['column_id']);
                     } else {
                         $column = new entities\BoardColumn();
                         $column->setBoard($this->board);
                     }
                     if (!$column instanceof entities\BoardColumn) {
                         throw new \Exception($this->getI18n()->__('There was an error trying to save column %column', array('%column' => $details['column_id'])));
                     }
                     $column->setName($details['name']);
                     $column->setSortOrder($details['sort_order']);
                     if (array_key_exists('min_workitems', $details)) {
                         $column->setMinWorkitems($details['min_workitems']);
                     }
                     if (array_key_exists('max_workitems', $details)) {
                         $column->setMaxWorkitems($details['max_workitems']);
                     }
                     $column->setStatusIds(explode(',', $details['status_ids']));
                     $column->save();
                     $saved_columns[$column->getID()] = $column->getID();
                     $cc++;
                 }
             }
             foreach ($this->board->getColumns() as $column) {
                 if (!array_key_exists($column->getID(), $saved_columns)) {
                     $column->delete();
                 }
             }
             return $this->renderJSON(array('forward' => $this->getRouting()->generate('agile_whiteboard', array('project_key' => $this->board->getProject()->getKey(), 'board_id' => $this->board->getID()))));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
     $this->selected_milestone = $this->board->getDefaultSelectedMilestone();
 }