Fix bugs, improve perfs and use SimpleLogger instead of Monolog
This commit is contained in:
@@ -189,10 +189,6 @@ class Acl extends Base
|
||||
|
||||
public function isManagerActionAllowed($project_id)
|
||||
{
|
||||
if ($this->userSession->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $project_id > 0 && $this->projectPermission->isManager($project_id, $this->userSession->getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -199,6 +199,7 @@ class Action extends Base
|
||||
*/
|
||||
public function remove($action_id)
|
||||
{
|
||||
// $this->container['fileCache']->remove('proxy_action_getAll');
|
||||
return $this->db->table(self::TABLE)->eq('id', $action_id)->remove();
|
||||
}
|
||||
|
||||
@@ -242,6 +243,8 @@ class Action extends Base
|
||||
|
||||
$this->db->closeTransaction();
|
||||
|
||||
// $this->container['fileCache']->remove('proxy_action_getAll');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -252,7 +255,10 @@ class Action extends Base
|
||||
*/
|
||||
public function attachEvents()
|
||||
{
|
||||
foreach ($this->getAll() as $action) {
|
||||
//$actions = $this->container['fileCache']->proxy('action', 'getAll');
|
||||
$actions = $this->getAll();
|
||||
|
||||
foreach ($actions as $action) {
|
||||
|
||||
$listener = $this->load($action['action_name'], $action['project_id'], $action['event_name']);
|
||||
|
||||
@@ -315,6 +321,8 @@ class Action extends Base
|
||||
}
|
||||
}
|
||||
|
||||
// $this->container['fileCache']->remove('proxy_action_getAll');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,6 +253,23 @@ class Board extends Base
|
||||
return $swimlanes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total of tasks per column
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id
|
||||
* @return array
|
||||
*/
|
||||
public function getColumnStats($project_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(Task::TABLE)
|
||||
->eq('project_id', $project_id)
|
||||
->eq('is_active', 1)
|
||||
->groupBy('column_id')
|
||||
->listing('column_id', 'COUNT(*) AS total');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first column id for a given project
|
||||
*
|
||||
|
||||
@@ -114,7 +114,7 @@ class Notification extends Base
|
||||
}
|
||||
}
|
||||
catch (Swift_TransportException $e) {
|
||||
$this->container['logger']->addError($e->getMessage());
|
||||
$this->container['logger']->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,11 +191,12 @@ class Project extends Base
|
||||
public function getStats($project_id)
|
||||
{
|
||||
$stats = array();
|
||||
$columns = $this->board->getColumns($project_id);
|
||||
$stats['nb_active_tasks'] = 0;
|
||||
$columns = $this->board->getColumns($project_id);
|
||||
$column_stats = $this->board->getColumnStats($project_id);
|
||||
|
||||
foreach ($columns as &$column) {
|
||||
$column['nb_active_tasks'] = $this->taskFinder->countByColumnId($project_id, $column['id']);
|
||||
$column['nb_active_tasks'] = isset($column_stats[$column['id']]) ? $column_stats[$column['id']] : 0;
|
||||
$stats['nb_active_tasks'] += $column['nb_active_tasks'];
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,10 @@ class ProjectPaginator extends Base
|
||||
foreach ($projects as &$project) {
|
||||
|
||||
$project['columns'] = $this->board->getColumns($project['id']);
|
||||
$stats = $this->board->getColumnStats($project['id']);
|
||||
|
||||
foreach ($project['columns'] as &$column) {
|
||||
$column['nb_tasks'] = $this->taskFinder->countByColumnId($project['id'], $column['id']);
|
||||
$column['nb_tasks'] = isset($stats[$column['id']]) ? $stats[$column['id']] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -298,7 +298,11 @@ class ProjectPermission extends Base
|
||||
*/
|
||||
public function getAllowedProjects($user_id)
|
||||
{
|
||||
return $this->filterProjects($this->project->getListByStatus(Project::ACTIVE), $user_id, 'isUserAllowed');
|
||||
if ($this->user->isAdmin($user_id)) {
|
||||
return $this->project->getListByStatus(Project::ACTIVE);
|
||||
}
|
||||
|
||||
return $this->getMemberProjects($user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,7 +314,11 @@ class ProjectPermission extends Base
|
||||
*/
|
||||
public function getMemberProjects($user_id)
|
||||
{
|
||||
return $this->filterProjects($this->project->getListByStatus(Project::ACTIVE), $user_id, 'isMember');
|
||||
return $this->db
|
||||
->table(Project::TABLE)
|
||||
->eq('user_id', $user_id)
|
||||
->join(self::TABLE, 'project_id', 'id')
|
||||
->listing('projects.id', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -216,16 +216,15 @@ class TaskFinder extends Base
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @param integer $column_id Column id
|
||||
* @param array $status List of status id
|
||||
* @return integer
|
||||
*/
|
||||
public function countByColumnId($project_id, $column_id, array $status = array(Task::STATUS_OPEN))
|
||||
public function countByColumnId($project_id, $column_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(Task::TABLE)
|
||||
->eq('project_id', $project_id)
|
||||
->eq('column_id', $column_id)
|
||||
->in('is_active', $status)
|
||||
->in('is_active', 1)
|
||||
->count();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ class User extends Base
|
||||
*/
|
||||
public function isAdmin($user_id)
|
||||
{
|
||||
return $this->db
|
||||
return $this->userSession->isAdmin() || // Avoid SQL query if connected
|
||||
$this->db
|
||||
->table(User::TABLE)
|
||||
->eq('id', $user_id)
|
||||
->eq('is_admin', 1)
|
||||
|
||||
Reference in New Issue
Block a user