summaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/board.php8
-rw-r--r--models/project.php10
-rw-r--r--models/task.php10
-rw-r--r--models/user.php7
4 files changed, 26 insertions, 9 deletions
diff --git a/models/board.php b/models/board.php
index af1f4f7a..01c3e832 100644
--- a/models/board.php
+++ b/models/board.php
@@ -176,16 +176,14 @@ class Board extends Base
* @param integer $project_id Project id
* @return array
*/
- public function get($project_id)
+ public function get($project_id, array $filters = array())
{
$this->db->startTransaction();
$columns = $this->getColumns($project_id);
- $filters = array(
- array('column' => 'project_id', 'operator' => 'eq', 'value' => $project_id),
- array('column' => 'is_active', 'operator' => 'eq', 'value' => Task::STATUS_OPEN),
- );
+ $filters[] = array('column' => 'project_id', 'operator' => 'eq', 'value' => $project_id);
+ $filters[] = array('column' => 'is_active', 'operator' => 'eq', 'value' => Task::STATUS_OPEN);
$taskModel = new Task($this->db, $this->event);
$tasks = $taskModel->find($filters);
diff --git a/models/project.php b/models/project.php
index b2a54571..8b7a2293 100644
--- a/models/project.php
+++ b/models/project.php
@@ -18,7 +18,7 @@ class Project extends Base
const INACTIVE = 0;
// Get a list of people that can by assigned for tasks
- public function getUsersList($project_id, $prepend = true)
+ public function getUsersList($project_id, $prepend_unassigned = true, $prepend_everybody = false)
{
$allowed_users = $this->getAllowedUsers($project_id);
$userModel = new User($this->db, $this->event);
@@ -27,8 +27,12 @@ class Project extends Base
$allowed_users = $userModel->getList();
}
- if ($prepend) {
- return array(t('Unassigned')) + $allowed_users;
+ if ($prepend_unassigned) {
+ $allowed_users = array(t('Unassigned')) + $allowed_users;
+ }
+
+ if ($prepend_everybody) {
+ $allowed_users = array(User::EVERYBODY_ID => t('Everybody')) + $allowed_users;
}
return $allowed_users;
diff --git a/models/task.php b/models/task.php
index c54e0cbc..b61fb13f 100644
--- a/models/task.php
+++ b/models/task.php
@@ -127,9 +127,10 @@ class Task extends Base
*
* @access public
* @param array $filters Filters: [ ['column' => '...', 'operator' => '...', 'value' => '...'], ... ]
+ * @param array $sorting Sorting: [ 'column' => 'date_creation', 'direction' => 'asc']
* @return array
*/
- public function find(array $filters)
+ public function find(array $filters, array $sorting = array())
{
$table = $this->db
->table(self::TABLE)
@@ -155,6 +156,13 @@ class Task extends Base
$table->$filter['operator']($filter['column'], $filter['value']);
}
+ if (empty($sorting)) {
+ $table->orderBy('tasks.position', 'ASC');
+ }
+ else {
+ $table->orderBy($sorting['column'], $sorting['direction']);
+ }
+
return $table->findAll();
}
diff --git a/models/user.php b/models/user.php
index c5017ac6..7334373c 100644
--- a/models/user.php
+++ b/models/user.php
@@ -23,6 +23,13 @@ class User extends Base
const TABLE = 'users';
/**
+ * Id used for everbody (filtering)
+ *
+ * @var integer
+ */
+ const EVERYBODY_ID = -1;
+
+ /**
* Get a specific user by id
*
* @access public