Add a filter by user and due date + minor changes

This commit is contained in:
Frédéric Guillot
2014-04-26 20:04:39 -04:00
parent 3332949c8b
commit 6551609d1b
14 changed files with 158 additions and 57 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -22,6 +22,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
*