| | <?php |
| |
|
| | namespace Kanboard\Model; |
| |
|
| | use Kanboard\Core\Base; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | class ColumnModel extends Base |
| | { |
| | |
| | |
| | |
| | |
| | |
| | const TABLE = 'columns'; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getById($column_id) |
| | { |
| | return $this->db->table(self::TABLE)->eq('id', $column_id)->findOne(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getProjectId($column_id) |
| | { |
| | return $this->db->table(self::TABLE)->eq('id', $column_id)->findOneColumn('project_id'); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getFirstColumnId($project_id) |
| | { |
| | return $this->db->table(self::TABLE)->eq('project_id', $project_id)->asc('position')->findOneColumn('id'); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getLastColumnId($project_id) |
| | { |
| | return $this->db->table(self::TABLE)->eq('project_id', $project_id)->desc('position')->findOneColumn('id'); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getLastColumnPosition($project_id) |
| | { |
| | return (int) $this->db |
| | ->table(self::TABLE) |
| | ->eq('project_id', $project_id) |
| | ->desc('position') |
| | ->findOneColumn('position'); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getColumnIdByTitle($project_id, $title) |
| | { |
| | return (int) $this->db->table(self::TABLE)->eq('project_id', $project_id)->eq('title', $title)->findOneColumn('id'); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getColumnTitleById($column_id) |
| | { |
| | return $this->db->table(self::TABLE)->eq('id', $column_id)->findOneColumn('title'); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getAll($project_id) |
| | { |
| | return $this->db->table(self::TABLE)->eq('project_id', $project_id)->asc('position')->findAll(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getAllWithTaskCount($project_id) |
| | { |
| | return $this->db->table(self::TABLE) |
| | ->columns('id', 'title', 'position', 'task_limit', 'description', 'hide_in_dashboard', 'project_id') |
| | ->subquery("SELECT COUNT(*) FROM ".TaskModel::TABLE." WHERE column_id=".self::TABLE.".id AND is_active='1'", 'nb_open_tasks') |
| | ->subquery("SELECT COUNT(*) FROM ".TaskModel::TABLE." WHERE column_id=".self::TABLE.".id AND is_active='0'", 'nb_closed_tasks') |
| | ->eq('project_id', $project_id) |
| | ->asc('position') |
| | ->findAll(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getAllWithPerSwimlaneTaskCount($project_id, $swimlane_id) |
| | { |
| | return $this->db->table(self::TABLE) |
| | ->columns('id', 'title', 'position', 'task_limit', 'description', 'hide_in_dashboard', 'project_id', $swimlane_id.' AS swimlane_id') |
| | ->subquery("SELECT COUNT(*) FROM ".TaskModel::TABLE." WHERE column_id=".self::TABLE.".id AND swimlane_id=".$swimlane_id." AND is_active='1'", 'nb_open_tasks') |
| | ->subquery("SELECT COUNT(*) FROM ".TaskModel::TABLE." WHERE column_id=".self::TABLE.".id AND swimlane_id=".$swimlane_id." AND is_active='0'", 'nb_closed_tasks') |
| | ->eq('project_id', $project_id) |
| | ->asc('position') |
| | ->findAll(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getList($project_id, $prepend = false) |
| | { |
| | $listing = $this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->asc('position')->getAll('id', 'title'); |
| | return $prepend ? array(-1 => t('All columns')) + $listing : $listing; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function create($project_id, $title, $task_limit = 0, $description = '', $hide_in_dashboard = 0) |
| | { |
| | $values = array( |
| | 'project_id' => $project_id, |
| | 'title' => $title, |
| | 'task_limit' => intval($task_limit), |
| | 'position' => $this->getLastColumnPosition($project_id) + 1, |
| | 'hide_in_dashboard' => $hide_in_dashboard, |
| | 'description' => $description, |
| | ); |
| |
|
| | return $this->db->table(self::TABLE)->persist($values); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function update($column_id, $title, $task_limit = 0, $description = '', $hide_in_dashboard = 0) |
| | { |
| | return $this->db->table(self::TABLE)->eq('id', $column_id)->update(array( |
| | 'title' => $title, |
| | 'task_limit' => intval($task_limit), |
| | 'hide_in_dashboard' => $hide_in_dashboard, |
| | 'description' => $description, |
| | )); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function remove($column_id) |
| | { |
| | return $this->db->table(self::TABLE)->eq('id', $column_id)->remove(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function changePosition($project_id, $column_id, $position) |
| | { |
| | if ($position < 1 || $position > $this->db->table(self::TABLE)->eq('project_id', $project_id)->count()) { |
| | return false; |
| | } |
| |
|
| | $column_ids = $this->db->table(self::TABLE)->eq('project_id', $project_id)->neq('id', $column_id)->asc('position')->findAllByColumn('id'); |
| | $offset = 1; |
| | $results = array(); |
| |
|
| | foreach ($column_ids as $current_column_id) { |
| | if ($offset == $position) { |
| | $offset++; |
| | } |
| |
|
| | $results[] = $this->db->table(self::TABLE)->eq('id', $current_column_id)->update(array('position' => $offset)); |
| | $offset++; |
| | } |
| |
|
| | $results[] = $this->db->table(self::TABLE)->eq('id', $column_id)->update(array('position' => $position)); |
| |
|
| | return !in_array(false, $results, true); |
| | } |
| | } |
| |
|