First API implementation
This commit is contained in:
@@ -99,7 +99,7 @@ class Board extends Base
|
||||
|
||||
foreach (array('title', 'task_limit') as $field) {
|
||||
foreach ($values[$field] as $column_id => $field_value) {
|
||||
$this->db->table(self::TABLE)->eq('id', $column_id)->update(array($field => $field_value));
|
||||
$this->updateColumn($column_id, array($field => $field_value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,19 @@ class Board extends Base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a column
|
||||
*
|
||||
* @access public
|
||||
* @param integer $column_id Column id
|
||||
* @param array $values Form values
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateColumn($column_id, array $values)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('id', $column_id)->update($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a column down, increment the column position value
|
||||
*
|
||||
|
||||
@@ -61,6 +61,21 @@ class Category extends Base
|
||||
return $prepend + $listing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all categories for a given project
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @return array
|
||||
*/
|
||||
public function getAll($project_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)
|
||||
->eq('project_id', $project_id)
|
||||
->asc('name')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a category
|
||||
*
|
||||
|
||||
@@ -197,6 +197,18 @@ class Project extends Base
|
||||
return $this->db->table(self::TABLE)->eq('id', $project_id)->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a project by the name
|
||||
*
|
||||
* @access public
|
||||
* @param string $project_name Project name
|
||||
* @return array
|
||||
*/
|
||||
public function getByName($project_name)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('name', $project_name)->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch project data by using the token
|
||||
*
|
||||
@@ -505,7 +517,8 @@ class Project extends Base
|
||||
new Validators\Integer('id', t('This value must be an integer')),
|
||||
new Validators\Required('name', t('The project name is required')),
|
||||
new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50),
|
||||
new Validators\Unique('name', t('This project must be unique'), $this->db->getConnection(), self::TABLE)
|
||||
new Validators\Unique('name', t('This project must be unique'), $this->db->getConnection(), self::TABLE),
|
||||
new Validators\Integer('is_active', t('This value must be an integer'))
|
||||
));
|
||||
|
||||
return array(
|
||||
|
||||
@@ -108,6 +108,23 @@ class Task extends Base
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count all tasks for a given project and status
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @param array $status List of status id
|
||||
* @return array
|
||||
*/
|
||||
public function getAll($project_id, array $status = array(self::STATUS_OPEN, self::STATUS_CLOSED))
|
||||
{
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
->eq('project_id', $project_id)
|
||||
->in('is_active', $status)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count all tasks for a given project and status
|
||||
*
|
||||
|
||||
@@ -135,7 +135,7 @@ class User extends Base
|
||||
|
||||
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
|
||||
|
||||
if ($_SESSION['user']['id'] == $values['id']) {
|
||||
if (session_id() !== '' && $_SESSION['user']['id'] == $values['id']) {
|
||||
$this->updateSession();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user