1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kanboard_ynh.git synced 2024-09-03 19:36:17 +02:00

Update sources to v1.0.20

This commit is contained in:
mbugeia 2015-10-26 14:48:27 +01:00
parent 777f30b769
commit 0826b10798
340 changed files with 3500 additions and 5868 deletions

View file

@ -1,3 +1,30 @@
Version 1.0.20
--------------
Breaking changes:
- Add namespace Kanboard (update your plugins)
- Move Mailgun, Sendgrid, Postmark, Slack, Hipchat and Jabber to plugins
- ReverseProxy authentication check for each request that the username match the user session
New features:
* Add CSV import for users and tasks
* Add Task, User and Project metadata for plugin creators
Improvements:
* Allow to change comments sorting
* Add the possibility to append or not custom filters
* Make mail transports pluggable
* Do not show scroll-bars when a column is collapsed on Windows systems
* Regenerate thumbnails if missing
Bug fixes:
* People should not see any tasks during a search when they are not associated to a project
* Avoid to disable the default swimlane during renaming when there is no other activated swimlane
Version 1.0.19 Version 1.0.19
-------------- --------------

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Event\GenericEvent; use Kanboard\Event\GenericEvent;
use Pimple\Container; use Pimple\Container;
/** /**
@ -11,7 +11,7 @@ use Pimple\Container;
* @package action * @package action
* @author Frederic Guillot * @author Frederic Guillot
*/ */
abstract class Base extends \Core\Base abstract class Base extends \Kanboard\Core\Base
{ {
/** /**
* Flag for called listener * Flag for called listener

View file

@ -1,10 +1,10 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Integration\BitbucketWebhook; use Kanboard\Integration\BitbucketWebhook;
use Integration\GithubWebhook; use Kanboard\Integration\GithubWebhook;
use Integration\GitlabWebhook; use Kanboard\Integration\GitlabWebhook;
/** /**
* Create automatically a comment from a webhook * Create automatically a comment from a webhook

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Set a category automatically according to the color * Set a category automatically according to the color

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Integration\GithubWebhook; use Kanboard\Integration\GithubWebhook;
/** /**
* Set a category automatically according to a label * Set a category automatically according to a label

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Assign a color to a specific category * Assign a color to a specific category

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Assign a color to a task * Assign a color to a task

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\TaskLink; use Kanboard\Model\TaskLink;
/** /**
* Assign a color to a specific task link * Assign a color to a specific task link

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Assign a color to a specific user * Assign a color to a specific user

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Assign a task to the logged user * Assign a task to the logged user

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Assign a task to a specific user * Assign a task to a specific user

View file

@ -1,9 +1,9 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Integration\GithubWebhook; use Kanboard\Integration\GithubWebhook;
use Integration\BitbucketWebhook; use Kanboard\Integration\BitbucketWebhook;
/** /**
* Assign a task to someone * Assign a task to someone

View file

@ -1,11 +1,11 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Integration\GitlabWebhook; use Kanboard\Integration\GitlabWebhook;
use Integration\GithubWebhook; use Kanboard\Integration\GithubWebhook;
use Integration\BitbucketWebhook; use Kanboard\Integration\BitbucketWebhook;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Close automatically a task * Close automatically a task

View file

@ -1,10 +1,10 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Integration\GithubWebhook; use Kanboard\Integration\GithubWebhook;
use Integration\GitlabWebhook; use Kanboard\Integration\GitlabWebhook;
use Integration\BitbucketWebhook; use Kanboard\Integration\BitbucketWebhook;
/** /**
* Create automatically a task from a webhook * Create automatically a task from a webhook

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Duplicate a task to another project * Duplicate a task to another project

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Email a task to someone * Email a task to someone
@ -67,7 +67,6 @@ class TaskEmail extends Base
$user = $this->user->getById($this->getParam('user_id')); $user = $this->user->getById($this->getParam('user_id'));
if (! empty($user['email'])) { if (! empty($user['email'])) {
$task = $this->taskFinder->getDetails($data['task_id']); $task = $this->taskFinder->getDetails($data['task_id']);
$this->emailClient->send( $this->emailClient->send(

View file

@ -1,9 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\GithubWebhook; use Kanboard\Model\Task;
use Model\Task;
/** /**
* Add a log of the triggering event to the task description. * Add a log of the triggering event to the task description.

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Move a task to another project * Move a task to another project

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Move a task to another column when an assignee is set * Move a task to another column when an assignee is set

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Move a task to another column when the category is changed * Move a task to another column when the category is changed

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Move a task to another column when an assignee is cleared * Move a task to another column when an assignee is cleared

View file

@ -1,9 +1,9 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Integration\GithubWebhook; use Kanboard\Integration\GithubWebhook;
use Integration\BitbucketWebhook; use Kanboard\Integration\BitbucketWebhook;
/** /**
* Open automatically a task * Open automatically a task

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Action; namespace Kanboard\Action;
use Model\Task; use Kanboard\Model\Task;
/** /**
* Set the start date of task * Set the start date of task

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Action API controller * Action API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Action extends \Core\Base class Action extends \Kanboard\Core\Base
{ {
public function getAvailableActions() public function getAvailableActions()
{ {
@ -35,10 +35,9 @@ class Action extends \Core\Base
$actions = $this->action->getAllByProject($project_id); $actions = $this->action->getAllByProject($project_id);
foreach ($actions as $index => $action) { foreach ($actions as $index => $action) {
$params = array(); $params = array();
foreach($action['params'] as $param) { foreach ($action['params'] as $param) {
$params[$param['name']] = $param['value']; $params[$param['name']] = $param['value'];
} }
@ -57,7 +56,7 @@ class Action extends \Core\Base
'params' => $params, 'params' => $params,
); );
list($valid,) = $this->action->validateCreation($values); list($valid, ) = $this->action->validateCreation($values);
if (! $valid) { if (! $valid) {
return false; return false;
@ -80,14 +79,14 @@ class Action extends \Core\Base
$required_params = $action->getActionRequiredParameters(); $required_params = $action->getActionRequiredParameters();
// Check missing parameters // Check missing parameters
foreach($required_params as $param => $value) { foreach ($required_params as $param => $value) {
if (! isset($params[$param])) { if (! isset($params[$param])) {
return false; return false;
} }
} }
// Check extra parameters // Check extra parameters
foreach($params as $param => $value) { foreach ($params as $param => $value) {
if (! isset($required_params[$param])) { if (! isset($required_params[$param])) {
return false; return false;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* App API controller * App API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class App extends \Core\Base class App extends \Kanboard\Core\Base
{ {
public function getTimezone() public function getTimezone()
{ {

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
use JsonRPC\AuthenticationFailure; use JsonRPC\AuthenticationFailure;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
@ -29,11 +29,9 @@ class Auth extends Base
if ($username !== 'jsonrpc' && ! $this->authentication->hasCaptcha($username) && $this->authentication->authenticate($username, $password)) { if ($username !== 'jsonrpc' && ! $this->authentication->hasCaptcha($username) && $this->authentication->authenticate($username, $password)) {
$this->checkProcedurePermission(true, $method); $this->checkProcedurePermission(true, $method);
$this->userSession->refresh($this->user->getByUsername($username)); $this->userSession->refresh($this->user->getByUsername($username));
} } elseif ($username === 'jsonrpc' && $password === $this->config->get('api_token')) {
else if ($username === 'jsonrpc' && $password === $this->config->get('api_token')) {
$this->checkProcedurePermission(false, $method); $this->checkProcedurePermission(false, $method);
} } else {
else {
throw new AuthenticationFailure('Wrong credentials'); throw new AuthenticationFailure('Wrong credentials');
} }
} }

View file

@ -1,8 +1,7 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
use JsonRPC\AuthenticationFailure;
use JsonRPC\AccessDeniedException; use JsonRPC\AccessDeniedException;
/** /**
@ -11,7 +10,7 @@ use JsonRPC\AccessDeniedException;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
abstract class Base extends \Core\Base abstract class Base extends \Kanboard\Core\Base
{ {
private $user_allowed_procedures = array( private $user_allowed_procedures = array(
'getMe', 'getMe',
@ -50,8 +49,7 @@ abstract class Base extends \Core\Base
if ($is_user && ! $is_both_procedure && ! $is_user_procedure) { if ($is_user && ! $is_both_procedure && ! $is_user_procedure) {
throw new AccessDeniedException('Permission denied'); throw new AccessDeniedException('Permission denied');
} } elseif (! $is_user && ! $is_both_procedure && $is_user_procedure) {
else if (! $is_user && ! $is_both_procedure && $is_user_procedure) {
throw new AccessDeniedException('Permission denied'); throw new AccessDeniedException('Permission denied');
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Board API controller * Board API controller

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Category API controller * Category API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Category extends \Core\Base class Category extends \Kanboard\Core\Base
{ {
public function getCategory($category_id) public function getCategory($category_id)
{ {
@ -32,7 +32,7 @@ class Category extends \Core\Base
'name' => $name, 'name' => $name,
); );
list($valid,) = $this->category->validateCreation($values); list($valid, ) = $this->category->validateCreation($values);
return $valid ? $this->category->create($values) : false; return $valid ? $this->category->create($values) : false;
} }
@ -43,7 +43,7 @@ class Category extends \Core\Base
'name' => $name, 'name' => $name,
); );
list($valid,) = $this->category->validateModification($values); list($valid, ) = $this->category->validateModification($values);
return $valid && $this->category->update($values); return $valid && $this->category->update($values);
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Comment API controller * Comment API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Comment extends \Core\Base class Comment extends \Kanboard\Core\Base
{ {
public function getComment($comment_id) public function getComment($comment_id)
{ {
@ -33,7 +33,7 @@ class Comment extends \Core\Base
'comment' => $content, 'comment' => $content,
); );
list($valid,) = $this->comment->validateCreation($values); list($valid, ) = $this->comment->validateCreation($values);
return $valid ? $this->comment->create($values) : false; return $valid ? $this->comment->create($values) : false;
} }
@ -45,7 +45,7 @@ class Comment extends \Core\Base
'comment' => $content, 'comment' => $content,
); );
list($valid,) = $this->comment->validateModification($values); list($valid, ) = $this->comment->validateModification($values);
return $valid && $this->comment->update($values); return $valid && $this->comment->update($values);
} }
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
use Core\ObjectStorage\ObjectStorageException; use Kanboard\Core\ObjectStorage\ObjectStorageException;
/** /**
* File API controller * File API controller
@ -10,7 +10,7 @@ use Core\ObjectStorage\ObjectStorageException;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class File extends \Core\Base class File extends \Kanboard\Core\Base
{ {
public function getFile($file_id) public function getFile($file_id)
{ {
@ -25,14 +25,12 @@ class File extends \Core\Base
public function downloadFile($file_id) public function downloadFile($file_id)
{ {
try { try {
$file = $this->file->getById($file_id); $file = $this->file->getById($file_id);
if (! empty($file)) { if (! empty($file)) {
return base64_encode($this->objectStorage->get($file['path'])); return base64_encode($this->objectStorage->get($file['path']));
} }
} } catch (ObjectStorageException $e) {
catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Link API controller * Link API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Link extends \Core\Base class Link extends \Kanboard\Core\Base
{ {
/** /**
* Get a link by id * Get a link by id
@ -72,7 +72,7 @@ class Link extends \Core\Base
'opposite_label' => $opposite_label, 'opposite_label' => $opposite_label,
); );
list($valid,) = $this->link->validateCreation($values); list($valid, ) = $this->link->validateCreation($values);
return $valid ? $this->link->create($label, $opposite_label) : false; return $valid ? $this->link->create($label, $opposite_label) : false;
} }
@ -93,7 +93,7 @@ class Link extends \Core\Base
'label' => $label, 'label' => $label,
); );
list($valid,) = $this->link->validateModification($values); list($valid, ) = $this->link->validateModification($values);
return $valid && $this->link->update($values); return $valid && $this->link->update($values);
} }

View file

@ -1,9 +1,8 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
use Model\Subtask as SubtaskModel; use Kanboard\Model\Subtask as SubtaskModel;
use Model\Task as TaskModel;
/** /**
* Me API controller * Me API controller
@ -45,7 +44,7 @@ class Me extends Base
'is_private' => 1, 'is_private' => 1,
); );
list($valid,) = $this->project->validateCreation($values); list($valid, ) = $this->project->validateCreation($values);
return $valid ? $this->project->create($values, $this->userSession->getId(), true) : false; return $valid ? $this->project->create($values, $this->userSession->getId(), true) : false;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Project API controller * Project API controller
@ -69,7 +69,7 @@ class Project extends Base
'description' => $description 'description' => $description
); );
list($valid,) = $this->project->validateCreation($values); list($valid, ) = $this->project->validateCreation($values);
return $valid ? $this->project->create($values) : false; return $valid ? $this->project->create($values) : false;
} }
@ -81,7 +81,7 @@ class Project extends Base
'description' => $description 'description' => $description
); );
list($valid,) = $this->project->validateModification($values); list($valid, ) = $this->project->validateModification($values);
return $valid && $this->project->update($values); return $valid && $this->project->update($values);
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* ProjectPermission API controller * ProjectPermission API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class ProjectPermission extends \Core\Base class ProjectPermission extends \Kanboard\Core\Base
{ {
public function getMembers($project_id) public function getMembers($project_id)
{ {

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Subtask API controller * Subtask API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Subtask extends \Core\Base class Subtask extends \Kanboard\Core\Base
{ {
public function getSubtask($subtask_id) public function getSubtask($subtask_id)
{ {
@ -36,7 +36,7 @@ class Subtask extends \Core\Base
'status' => $status, 'status' => $status,
); );
list($valid,) = $this->subtask->validateCreation($values); list($valid, ) = $this->subtask->validateCreation($values);
return $valid ? $this->subtask->create($values) : false; return $valid ? $this->subtask->create($values) : false;
} }
@ -58,7 +58,7 @@ class Subtask extends \Core\Base
} }
} }
list($valid,) = $this->subtask->validateApiModification($values); list($valid, ) = $this->subtask->validateApiModification($values);
return $valid && $this->subtask->update($values); return $valid && $this->subtask->update($values);
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* Swimlane API controller * Swimlane API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Swimlane extends \Core\Base class Swimlane extends \Kanboard\Core\Base
{ {
public function getActiveSwimlanes($project_id) public function getActiveSwimlanes($project_id)
{ {

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
use Model\Task as TaskModel; use Kanboard\Model\Task as TaskModel;
/** /**
* Task API controller * Task API controller
@ -91,7 +91,7 @@ class Task extends Base
'reference' => $reference, 'reference' => $reference,
); );
list($valid,) = $this->taskValidator->validateCreation($values); list($valid, ) = $this->taskValidator->validateCreation($values);
return $valid ? $this->taskCreation->create($values) : false; return $valid ? $this->taskCreation->create($values) : false;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
/** /**
* TaskLink API controller * TaskLink API controller
@ -8,7 +8,7 @@ namespace Api;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class TaskLink extends \Core\Base class TaskLink extends \Kanboard\Core\Base
{ {
/** /**
* Get a task link * Get a task link

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Api; namespace Kanboard\Api;
use Auth\Ldap; use Kanboard\Auth\Ldap;
/** /**
* User API controller * User API controller
@ -10,7 +10,7 @@ use Auth\Ldap;
* @package api * @package api
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class User extends \Core\Base class User extends \Kanboard\Core\Base
{ {
public function getUser($user_id) public function getUser($user_id)
{ {
@ -39,7 +39,7 @@ class User extends \Core\Base
'is_project_admin' => $is_project_admin, 'is_project_admin' => $is_project_admin,
); );
list($valid,) = $this->user->validateCreation($values); list($valid, ) = $this->user->validateCreation($values);
return $valid ? $this->user->create($values) : false; return $valid ? $this->user->create($values) : false;
} }
@ -81,7 +81,7 @@ class User extends \Core\Base
} }
} }
list($valid,) = $this->user->validateApiModification($values); list($valid, ) = $this->user->validateApiModification($values);
return $valid && $this->user->update($values); return $valid && $this->user->update($values);
} }
} }

View file

@ -1,34 +0,0 @@
<?php
namespace Auth;
use Pimple\Container;
/**
* Base auth class
*
* @package auth
* @author Frederic Guillot
*/
abstract class Base extends \Core\Base
{
/**
* Database instance
*
* @access protected
* @var \PicoDb\Database
*/
protected $db;
/**
* Constructor
*
* @access public
* @param \Pimple\Container $container
*/
public function __construct(Container $container)
{
$this->container = $container;
$this->db = $this->container['db'];
}
}

View file

@ -1,9 +1,10 @@
<?php <?php
namespace Auth; namespace Kanboard\Auth;
use Model\User; use Kanboard\Core\Base;
use Event\AuthEvent; use Kanboard\Model\User;
use Kanboard\Event\AuthEvent;
/** /**
* Database authentication * Database authentication

View file

@ -1,8 +1,9 @@
<?php <?php
namespace Auth; namespace Kanboard\Auth;
use Event\AuthEvent; use Kanboard\Core\Base;
use Kanboard\Event\AuthEvent;
/** /**
* Github backend * Github backend
@ -22,7 +23,7 @@ class Github extends Base
* OAuth2 instance * OAuth2 instance
* *
* @access private * @access private
* @var \Core\OAuth2 * @var \Kanboard\Core\OAuth2
*/ */
private $service; private $service;
@ -85,7 +86,7 @@ class Github extends Base
* Get OAuth2 configured service * Get OAuth2 configured service
* *
* @access public * @access public
* @return \Core\OAuth2 * @return Kanboard\Core\OAuth2
*/ */
public function getService() public function getService()
{ {

View file

@ -1,8 +1,9 @@
<?php <?php
namespace Auth; namespace Kanboard\Auth;
use Event\AuthEvent; use Kanboard\Core\Base;
use Kanboard\Event\AuthEvent;
/** /**
* Gitlab backend * Gitlab backend
@ -22,7 +23,7 @@ class Gitlab extends Base
* OAuth2 instance * OAuth2 instance
* *
* @access private * @access private
* @var \Core\OAuth2 * @var \Kanboard\Core\OAuth2
*/ */
private $service; private $service;
@ -85,7 +86,7 @@ class Gitlab extends Base
* Get OAuth2 configured service * Get OAuth2 configured service
* *
* @access public * @access public
* @return \Core\OAuth2 * @return Kanboard\Core\OAuth2
*/ */
public function getService() public function getService()
{ {

View file

@ -1,8 +1,9 @@
<?php <?php
namespace Auth; namespace Kanboard\Auth;
use Event\AuthEvent; use Kanboard\Core\Base;
use Kanboard\Event\AuthEvent;
/** /**
* Google backend * Google backend
@ -23,7 +24,7 @@ class Google extends Base
* OAuth2 instance * OAuth2 instance
* *
* @access private * @access private
* @var \Core\OAuth2 * @var \Kanboard\Core\OAuth2
*/ */
private $service; private $service;
@ -86,7 +87,7 @@ class Google extends Base
* Get OAuth2 configured service * Get OAuth2 configured service
* *
* @access public * @access public
* @return \Core\OAuth2 * @return KanboardCore\OAuth2
*/ */
public function getService() public function getService()
{ {

View file

@ -1,8 +1,9 @@
<?php <?php
namespace Auth; namespace Kanboard\Auth;
use Event\AuthEvent; use Kanboard\Core\Base;
use Kanboard\Event\AuthEvent;
/** /**
* LDAP model * LDAP model
@ -217,7 +218,6 @@ class Ldap extends Base
$result = $this->findUser($username, $password); $result = $this->findUser($username, $password);
if (is_array($result)) { if (is_array($result)) {
$user = $this->user->getByUsername($username); $user = $this->user->getByUsername($username);
if (! empty($user)) { if (! empty($user)) {
@ -226,14 +226,12 @@ class Ldap extends Base
if ($user['is_ldap_user'] == 0) { if ($user['is_ldap_user'] == 0) {
return false; return false;
} }
} } else {
else {
// We create automatically a new user // We create automatically a new user
if ($this->isLdapAccountCreationEnabled() && $this->user->create($result) !== false) { if ($this->isLdapAccountCreationEnabled() && $this->user->create($result) !== false) {
$user = $this->user->getByUsername($username); $user = $this->user->getByUsername($username);
} } else {
else {
return false; return false;
} }
} }
@ -319,12 +317,10 @@ class Ldap extends Base
if ($this->getLdapBindType() === 'user') { if ($this->getLdapBindType() === 'user') {
$ldap_username = sprintf($this->getLdapUsername(), $username); $ldap_username = sprintf($this->getLdapUsername(), $username);
$ldap_password = $password; $ldap_password = $password;
} } elseif ($this->getLdapBindType() === 'proxy') {
else if ($this->getLdapBindType() === 'proxy') {
$ldap_username = $this->getLdapUsername(); $ldap_username = $this->getLdapUsername();
$ldap_password = $this->getLdapPassword(); $ldap_password = $this->getLdapPassword();
} } else {
else {
$ldap_username = null; $ldap_username = null;
$ldap_password = null; $ldap_password = null;
} }
@ -486,11 +482,9 @@ class Ldap extends Base
{ {
if (! empty($username) && ! empty($email)) { if (! empty($username) && ! empty($email)) {
return '(&('.$this->getLdapUserPattern($username).')('.$this->getLdapAccountEmail().'='.$email.'))'; return '(&('.$this->getLdapUserPattern($username).')('.$this->getLdapAccountEmail().'='.$email.'))';
} } elseif (! empty($username)) {
else if (! empty($username)) {
return $this->getLdapUserPattern($username); return $this->getLdapUserPattern($username);
} } elseif (! empty($email)) {
else if (! empty($email)) {
return '('.$this->getLdapAccountEmail().'='.$email.')'; return '('.$this->getLdapAccountEmail().'='.$email.')';
} }

View file

@ -1,10 +1,11 @@
<?php <?php
namespace Auth; namespace Kanboard\Auth;
use Core\Request; use Kanboard\Core\Base;
use Event\AuthEvent; use Kanboard\Core\Request;
use Core\Security; use Kanboard\Event\AuthEvent;
use Kanboard\Core\Security;
/** /**
* RememberMe model * RememberMe model
@ -88,7 +89,6 @@ class RememberMe extends Base
$credentials = $this->readCookie(); $credentials = $this->readCookie();
if ($credentials !== false) { if ($credentials !== false) {
$record = $this->find($credentials['token'], $credentials['sequence']); $record = $this->find($credentials['token'], $credentials['sequence']);
if ($record) { if ($record) {
@ -144,7 +144,6 @@ class RememberMe extends Base
$credentials = $this->readCookie(); $credentials = $this->readCookie();
if ($credentials !== false) { if ($credentials !== false) {
$this->deleteCookie(); $this->deleteCookie();
$this->db $this->db

View file

@ -1,8 +1,9 @@
<?php <?php
namespace Auth; namespace Kanboard\Auth;
use Event\AuthEvent; use Kanboard\Core\Base;
use Kanboard\Event\AuthEvent;
/** /**
* ReverseProxy backend * ReverseProxy backend
@ -19,6 +20,17 @@ class ReverseProxy extends Base
*/ */
const AUTH_NAME = 'ReverseProxy'; const AUTH_NAME = 'ReverseProxy';
/**
* Get username from the reverse proxy
*
* @access public
* @return string
*/
public function getUsername()
{
return isset($_SERVER[REVERSE_PROXY_USER_HEADER]) ? $_SERVER[REVERSE_PROXY_USER_HEADER] : '';
}
/** /**
* Authenticate the user with the HTTP header * Authenticate the user with the HTTP header
* *

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use Pimple\Container; use Pimple\Container;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
@ -11,17 +11,18 @@ use Symfony\Component\Console\Command\Command;
* @package console * @package console
* @author Frederic Guillot * @author Frederic Guillot
* *
* @property \Model\Notification $notification * @property \Kanboard\Model\Notification $notification
* @property \Model\Project $project * @property \Kanboard\Model\Project $project
* @property \Model\ProjectPermission $projectPermission * @property \Kanboard\Model\ProjectPermission $projectPermission
* @property \Model\ProjectAnalytic $projectAnalytic * @property \Kanboard\Model\ProjectAnalytic $projectAnalytic
* @property \Model\ProjectDailyColumnStats $projectDailyColumnStats * @property \Kanboard\Model\ProjectDailyColumnStats $projectDailyColumnStats
* @property \Model\ProjectDailyStats $projectDailyStats * @property \Kanboard\Model\ProjectDailyStats $projectDailyStats
* @property \Model\SubtaskExport $subtaskExport * @property \Kanboard\Model\SubtaskExport $subtaskExport
* @property \Model\Task $task * @property \Kanboard\Model\OverdueNotification $overdueNotification
* @property \Model\TaskExport $taskExport * @property \Kanboard\Model\Task $task
* @property \Model\TaskFinder $taskFinder * @property \Kanboard\Model\TaskExport $taskExport
* @property \Model\Transition $transition * @property \Kanboard\Model\TaskFinder $taskFinder
* @property \Kanboard\Model\Transition $transition
*/ */
abstract class Base extends Command abstract class Base extends Command
{ {

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
@ -25,7 +25,6 @@ class LocaleComparator extends Base
$it->rewind(); $it->rewind();
while ($it->valid()) { while ($it->valid()) {
if (! $it->isDot() && substr($it->key(), -4) === '.php') { if (! $it->isDot() && substr($it->key(), -4) === '.php') {
$strings = array_merge($strings, $this->search($it->key())); $strings = array_merge($strings, $this->search($it->key()));
} }
@ -72,7 +71,7 @@ class LocaleComparator extends Base
$strings = array_merge($strings, $matches[1]); $strings = array_merge($strings, $matches[1]);
} }
array_walk($strings, function(&$value) { array_walk($strings, function (&$value) {
$value = trim($value, "'"); $value = trim($value, "'");
$value = str_replace("\'", "'", $value); $value = str_replace("\'", "'", $value);
}); });

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use DirectoryIterator; use DirectoryIterator;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -23,9 +23,7 @@ class LocaleSync extends Base
$reference = include $reference_file; $reference = include $reference_file;
foreach (new DirectoryIterator('app/Locale') as $fileInfo) { foreach (new DirectoryIterator('app/Locale') as $fileInfo) {
if (! $fileInfo->isDot() && $fileInfo->isDir() && $fileInfo->getFilename() !== self::REF_LOCALE) { if (! $fileInfo->isDot() && $fileInfo->isDir() && $fileInfo->getFilename() !== self::REF_LOCALE) {
$filename = 'app/Locale/'.$fileInfo->getFilename().'/translations.php'; $filename = 'app/Locale/'.$fileInfo->getFilename().'/translations.php';
echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL; echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL;
@ -42,11 +40,9 @@ class LocaleSync extends Base
$output .= 'return array('.PHP_EOL; $output .= 'return array('.PHP_EOL;
foreach ($reference as $key => $value) { foreach ($reference as $key => $value) {
if (! empty($outdated[$key])) { if (! empty($outdated[$key])) {
$output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $outdated[$key])."',\n"; $output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $outdated[$key])."',\n";
} } else {
else {
$output .= " // '".str_replace("'", "\'", $key)."' => '',\n"; $output .= " // '".str_replace("'", "\'", $key)."' => '',\n";
} }
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use Core\Tool; use Kanboard\Core\Csv;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -28,7 +28,7 @@ class ProjectDailyColumnStatsExport extends Base
); );
if (is_array($data)) { if (is_array($data)) {
Tool::csv($data); Csv::output($data);
} }
} }
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use Model\Project; use Kanboard\Model\Project;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use Core\Tool; use Kanboard\Core\Csv;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -28,7 +28,7 @@ class SubtaskExport extends Base
); );
if (is_array($data)) { if (is_array($data)) {
Tool::csv($data); Csv::output($data);
} }
} }
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use Core\Tool; use Kanboard\Core\Csv;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -28,7 +28,7 @@ class TaskExport extends Base
); );
if (is_array($data)) { if (is_array($data)) {
Tool::csv($data); Csv::output($data);
} }
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Console; namespace Kanboard\Console;
use Core\Tool; use Kanboard\Core\Csv;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -28,7 +28,7 @@ class TransitionExport extends Base
); );
if (is_array($data)) { if (is_array($data)) {
Tool::csv($data); Csv::output($data);
} }
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Automatic actions management * Automatic actions management
@ -115,14 +115,12 @@ class Action extends Base
*/ */
private function doCreation(array $project, array $values) private function doCreation(array $project, array $values)
{ {
list($valid,) = $this->action->validateCreation($values); list($valid, ) = $this->action->validateCreation($values);
if ($valid) { if ($valid) {
if ($this->action->create($values) !== false) { if ($this->action->create($values) !== false) {
$this->session->flash(t('Your automatic action have been created successfully.')); $this->session->flash(t('Your automatic action have been created successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to create your automatic action.')); $this->session->flashError(t('Unable to create your automatic action.'));
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Activity stream * Activity stream

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Project Analytic controller * Project Analytic controller

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\Subtask as SubtaskModel; use Kanboard\Model\Subtask as SubtaskModel;
/** /**
* Application controller * Application controller
@ -198,7 +198,7 @@ class App extends Base
$this->response->html($this->layout('app/notifications', array( $this->response->html($this->layout('app/notifications', array(
'title' => t('My notifications'), 'title' => t('My notifications'),
'notifications' => $this->webNotification->getAll($user['id']), 'notifications' => $this->userUnreadNotification->getAll($user['id']),
'user' => $user, 'user' => $user,
))); )));
} }
@ -227,17 +227,21 @@ class App extends Base
public function autocomplete() public function autocomplete()
{ {
$search = $this->request->getStringParam('term'); $search = $this->request->getStringParam('term');
$projects = $this->projectPermission->getActiveMemberProjectIds($this->userSession->getId());
if (empty($projects)) {
$this->response->json(array());
}
$filter = $this->taskFilterAutoCompleteFormatter $filter = $this->taskFilterAutoCompleteFormatter
->create() ->create()
->filterByProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId())) ->filterByProjects($projects)
->excludeTasks(array($this->request->getIntegerParam('exclude_task_id'))); ->excludeTasks(array($this->request->getIntegerParam('exclude_task_id')));
// Search by task id or by title // Search by task id or by title
if (ctype_digit($search)) { if (ctype_digit($search)) {
$filter->filterById($search); $filter->filterById($search);
} } else {
else {
$filter->filterByTitle($search); $filter->filterByTitle($search);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Gregwar\Captcha\CaptchaBuilder; use Gregwar\Captcha\CaptchaBuilder;
@ -43,7 +43,6 @@ class Auth extends Base
list($valid, $errors) = $this->authentication->validateForm($values); list($valid, $errors) = $this->authentication->validateForm($values);
if ($valid) { if ($valid) {
if (! empty($this->session['login_redirect']) && ! filter_var($this->session['login_redirect'], FILTER_VALIDATE_URL)) { if (! empty($this->session['login_redirect']) && ! filter_var($this->session['login_redirect'], FILTER_VALIDATE_URL)) {
$redirect = $this->session['login_redirect']; $redirect = $this->session['login_redirect'];
unset($this->session['login_redirect']); unset($this->session['login_redirect']);

View file

@ -1,14 +1,11 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Pimple\Container; use Pimple\Container;
use Core\Security; use Kanboard\Core\Security;
use Core\Request; use Kanboard\Core\Request;
use Core\Response; use Kanboard\Core\Response;
use Core\Template;
use Core\Session;
use Model\LastLogin;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
/** /**
@ -17,13 +14,13 @@ use Symfony\Component\EventDispatcher\Event;
* @package controller * @package controller
* @author Frederic Guillot * @author Frederic Guillot
*/ */
abstract class Base extends \Core\Base abstract class Base extends \Kanboard\Core\Base
{ {
/** /**
* Request instance * Request instance
* *
* @accesss protected * @accesss protected
* @var \Core\Request * @var \Kanboard\Core\Request
*/ */
protected $request; protected $request;
@ -31,7 +28,7 @@ abstract class Base extends \Core\Base
* Response instance * Response instance
* *
* @accesss protected * @accesss protected
* @var \Core\Response * @var \Kanboard\Core\Response
*/ */
protected $response; protected $response;
@ -60,7 +57,6 @@ abstract class Base extends \Core\Base
public function __destruct() public function __destruct()
{ {
if (DEBUG) { if (DEBUG) {
foreach ($this->container['db']->getLogMessages() as $message) { foreach ($this->container['db']->getLogMessages() as $message) {
$this->container['logger']->debug($message); $this->container['logger']->debug($message);
} }
@ -123,7 +119,6 @@ abstract class Base extends \Core\Base
public function handleAuthentication() public function handleAuthentication()
{ {
if (! $this->authentication->isAuthenticated()) { if (! $this->authentication->isAuthenticated()) {
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
$this->response->text('Not Authorized', 401); $this->response->text('Not Authorized', 401);
} }
@ -143,7 +138,6 @@ abstract class Base extends \Core\Base
$ignore = ($controller === 'twofactor' && in_array($action, array('code', 'check'))) || ($controller === 'auth' && $action === 'logout'); $ignore = ($controller === 'twofactor' && in_array($action, array('code', 'check'))) || ($controller === 'auth' && $action === 'logout');
if ($ignore === false && $this->userSession->has2FA() && ! $this->userSession->check2FA()) { if ($ignore === false && $this->userSession->has2FA() && ! $this->userSession->check2FA()) {
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
$this->response->text('Not Authorized', 401); $this->response->text('Not Authorized', 401);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Board controller * Board controller
@ -195,7 +195,7 @@ class Board extends Base
$task = $this->getTask(); $task = $this->getTask();
$this->response->html($this->template->render('board/tooltip_comments', array( $this->response->html($this->template->render('board/tooltip_comments', array(
'comments' => $this->comment->getAll($task['id']) 'comments' => $this->comment->getAll($task['id'], $this->userSession->getCommentSorting())
))); )));
} }
@ -239,12 +239,11 @@ class Board extends Base
{ {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid,) = $this->taskValidator->validateAssigneeModification($values); list($valid, ) = $this->taskValidator->validateAssigneeModification($values);
if ($valid && $this->taskModification->update($values)) { if ($valid && $this->taskModification->update($values)) {
$this->session->flash(t('Task updated successfully.')); $this->session->flash(t('Task updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your task.')); $this->session->flashError(t('Unable to update your task.'));
} }
@ -277,12 +276,11 @@ class Board extends Base
{ {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid,) = $this->taskValidator->validateCategoryModification($values); list($valid, ) = $this->taskValidator->validateCategoryModification($values);
if ($valid && $this->taskModification->update($values)) { if ($valid && $this->taskModification->update($values)) {
$this->session->flash(t('Task updated successfully.')); $this->session->flash(t('Task updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your task.')); $this->session->flashError(t('Unable to update your task.'));
} }
@ -365,8 +363,7 @@ class Board extends Base
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
$this->response->html($this->renderBoard($project_id)); $this->response->html($this->renderBoard($project_id));
} } else {
else {
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id))); $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id)));
} }
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\Task as TaskModel; use Kanboard\Model\Task as TaskModel;
/** /**
* Project Calendar controller * Project Calendar controller
@ -44,8 +44,7 @@ class Calendar extends Base
// Tasks // Tasks
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') { if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
$events = $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format(); $events = $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format();
} } else {
else {
$events = $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format(); $events = $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format();
} }
@ -79,8 +78,7 @@ class Calendar extends Base
// Tasks // Tasks
if ($this->config->get('calendar_user_tasks', 'date_started') === 'date_creation') { if ($this->config->get('calendar_user_tasks', 'date_started') === 'date_creation') {
$events = array_merge($events, $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format()); $events = array_merge($events, $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format());
} } else {
else {
$events = array_merge($events, $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format()); $events = array_merge($events, $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format());
} }
@ -106,7 +104,6 @@ class Calendar extends Base
public function save() public function save()
{ {
if ($this->request->isAjax() && $this->request->isPost()) { if ($this->request->isAjax() && $this->request->isPost()) {
$values = $this->request->getJson(); $values = $this->request->getJson();
$this->taskModification->update(array( $this->taskModification->update(array(

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Category management * Category management
@ -60,12 +60,10 @@ class Category extends Base
list($valid, $errors) = $this->category->validateCreation($values); list($valid, $errors) = $this->category->validateCreation($values);
if ($valid) { if ($valid) {
if ($this->category->create($values)) { if ($this->category->create($values)) {
$this->session->flash(t('Your category have been created successfully.')); $this->session->flash(t('Your category have been created successfully.'));
$this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to create your category.')); $this->session->flashError(t('Unable to create your category.'));
} }
} }
@ -104,12 +102,10 @@ class Category extends Base
list($valid, $errors) = $this->category->validateModification($values); list($valid, $errors) = $this->category->validateModification($values);
if ($valid) { if ($valid) {
if ($this->category->update($values)) { if ($this->category->update($values)) {
$this->session->flash(t('Your category have been updated successfully.')); $this->session->flash(t('Your category have been updated successfully.'));
$this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to update your category.')); $this->session->flashError(t('Unable to update your category.'));
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Column controller * Column controller
@ -54,12 +54,10 @@ class Column extends Base
list($valid, $errors) = $this->board->validateCreation($data); list($valid, $errors) = $this->board->validateCreation($data);
if ($valid) { if ($valid) {
if ($this->board->addColumn($project['id'], $data['title'], $data['task_limit'], $data['description'])) { if ($this->board->addColumn($project['id'], $data['title'], $data['task_limit'], $data['description'])) {
$this->session->flash(t('Board updated successfully.')); $this->session->flash(t('Board updated successfully.'));
$this->response->redirect($this->helper->url->to('column', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('column', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to update this board.')); $this->session->flashError(t('Unable to update this board.'));
} }
} }
@ -99,12 +97,10 @@ class Column extends Base
list($valid, $errors) = $this->board->validateModification($values); list($valid, $errors) = $this->board->validateModification($values);
if ($valid) { if ($valid) {
if ($this->board->updateColumn($values['id'], $values['title'], $values['task_limit'], $values['description'])) { if ($this->board->updateColumn($values['id'], $values['title'], $values['task_limit'], $values['description'])) {
$this->session->flash(t('Board updated successfully.')); $this->session->flash(t('Board updated successfully.'));
$this->response->redirect($this->helper->url->to('column', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('column', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to update this board.')); $this->session->flashError(t('Unable to update this board.'));
} }
} }
@ -160,8 +156,7 @@ class Column extends Base
if (! empty($column) && $this->board->removeColumn($column['id'])) { if (! empty($column) && $this->board->removeColumn($column['id'])) {
$this->session->flash(t('Column removed successfully.')); $this->session->flash(t('Column removed successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to remove this column.')); $this->session->flashError(t('Unable to remove this column.'));
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Comment controller * Comment controller
@ -81,11 +81,9 @@ class Comment extends Base
list($valid, $errors) = $this->comment->validateCreation($values); list($valid, $errors) = $this->comment->validateCreation($values);
if ($valid) { if ($valid) {
if ($this->comment->create($values)) { if ($this->comment->create($values)) {
$this->session->flash(t('Comment added successfully.')); $this->session->flash(t('Comment added successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to create your comment.')); $this->session->flashError(t('Unable to create your comment.'));
} }
@ -132,11 +130,9 @@ class Comment extends Base
list($valid, $errors) = $this->comment->validateModification($values); list($valid, $errors) = $this->comment->validateModification($values);
if ($valid) { if ($valid) {
if ($this->comment->update($values)) { if ($this->comment->update($values)) {
$this->session->flash(t('Comment updated successfully.')); $this->session->flash(t('Comment updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your comment.')); $this->session->flashError(t('Unable to update your comment.'));
} }
@ -176,11 +172,25 @@ class Comment extends Base
if ($this->comment->remove($comment['id'])) { if ($this->comment->remove($comment['id'])) {
$this->session->flash(t('Comment removed successfully.')); $this->session->flash(t('Comment removed successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to remove this comment.')); $this->session->flashError(t('Unable to remove this comment.'));
} }
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments')); $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
} }
/**
* Toggle comment sorting
*
* @access public
*/
public function toggleSorting()
{
$task = $this->getTask();
$order = $this->userSession->getCommentSorting() === 'ASC' ? 'DESC' : 'ASC';
$this->userSession->setCommentSorting($order);
$this->response->redirect($this->helper->url->href('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'comments'));
}
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Config controller * Config controller
@ -37,7 +37,6 @@ class Config extends Base
private function common($redirect) private function common($redirect)
{ {
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
switch ($redirect) { switch ($redirect) {
@ -45,7 +44,7 @@ class Config extends Base
$values += array('subtask_restriction' => 0, 'subtask_time_tracking' => 0, 'cfd_include_closed_tasks' => 0); $values += array('subtask_restriction' => 0, 'subtask_time_tracking' => 0, 'cfd_include_closed_tasks' => 0);
break; break;
case 'integrations': case 'integrations':
$values += array('integration_slack_webhook' => 0, 'integration_hipchat' => 0, 'integration_gravatar' => 0, 'integration_jabber' => 0); $values += array('integration_gravatar' => 0);
break; break;
case 'calendar': case 'calendar':
$values += array('calendar_user_subtasks_time_tracking' => 0); $values += array('calendar_user_subtasks_time_tracking' => 0);
@ -55,8 +54,7 @@ class Config extends Base
if ($this->config->save($values)) { if ($this->config->save($values)) {
$this->config->reload(); $this->config->reload();
$this->session->flash(t('Settings saved successfully.')); $this->session->flash(t('Settings saved successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to save your settings.')); $this->session->flashError(t('Unable to save your settings.'));
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Currency controller * Currency controller
@ -54,12 +54,10 @@ class Currency extends Base
list($valid, $errors) = $this->currency->validate($values); list($valid, $errors) = $this->currency->validate($values);
if ($valid) { if ($valid) {
if ($this->currency->create($values['currency'], $values['rate'])) { if ($this->currency->create($values['currency'], $values['rate'])) {
$this->session->flash(t('The currency rate have been added successfully.')); $this->session->flash(t('The currency rate have been added successfully.'));
$this->response->redirect($this->helper->url->to('currency', 'index')); $this->response->redirect($this->helper->url->to('currency', 'index'));
} } else {
else {
$this->session->flashError(t('Unable to add this currency rate.')); $this->session->flashError(t('Unable to add this currency rate.'));
} }
} }
@ -79,8 +77,7 @@ class Currency extends Base
if ($this->config->save($values)) { if ($this->config->save($values)) {
$this->config->reload(); $this->config->reload();
$this->session->flash(t('Settings saved successfully.')); $this->session->flash(t('Settings saved successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to save your settings.')); $this->session->flashError(t('Unable to save your settings.'));
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Custom Filter management * Custom Filter management
@ -46,8 +46,7 @@ class Customfilter extends Base
if ($this->customFilter->create($values)) { if ($this->customFilter->create($values)) {
$this->session->flash(t('Your custom filter have been created successfully.')); $this->session->flash(t('Your custom filter have been created successfully.'));
$this->response->redirect($this->helper->url->to('customfilter', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('customfilter', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to create your custom filter.')); $this->session->flashError(t('Unable to create your custom filter.'));
} }
} }
@ -116,14 +115,17 @@ class Customfilter extends Base
$values += array('is_shared' => 0); $values += array('is_shared' => 0);
} }
if (! isset($values['append'])) {
$values += array('append' => 0);
}
list($valid, $errors) = $this->customFilter->validateModification($values); list($valid, $errors) = $this->customFilter->validateModification($values);
if ($valid) { if ($valid) {
if ($this->customFilter->update($values)) { if ($this->customFilter->update($values)) {
$this->session->flash(t('Your custom filter have been updated successfully.')); $this->session->flash(t('Your custom filter have been updated successfully.'));
$this->response->redirect($this->helper->url->to('customfilter', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('customfilter', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to update custom filter.')); $this->session->flashError(t('Unable to update custom filter.'));
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Parsedown; use Parsedown;
@ -16,7 +16,7 @@ class Doc extends Base
{ {
$url = $this->helper->url; $url = $this->helper->url;
$data = file_get_contents($filename); $data = file_get_contents($filename);
list($title,) = explode("\n", $data, 2); list($title, ) = explode("\n", $data, 2);
$replaceUrl = function (array $matches) use ($url) { $replaceUrl = function (array $matches) use ($url) {
return '('.$url->to('doc', 'show', array('file' => str_replace('.markdown', '', $matches[1]))).')'; return '('.$url->to('doc', 'show', array('file' => str_replace('.markdown', '', $matches[1]))).')';

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Export controller * Export controller

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Atom/RSS Feed controller * Atom/RSS Feed controller

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Core\ObjectStorage\ObjectStorageException; use Kanboard\Core\ObjectStorage\ObjectStorageException;
/** /**
* File controller * File controller
@ -22,7 +22,6 @@ class File extends Base
$task = $this->getTask(); $task = $this->getTask();
if ($this->request->isPost() && $this->file->uploadScreenshot($task['project_id'], $task['id'], $this->request->getValue('screenshot')) !== false) { if ($this->request->isPost() && $this->file->uploadScreenshot($task['project_id'], $task['id'], $this->request->getValue('screenshot')) !== false) {
$this->session->flash(t('Screenshot uploaded successfully.')); $this->session->flash(t('Screenshot uploaded successfully.'));
if ($this->request->getStringParam('redirect') === 'board') { if ($this->request->getStringParam('redirect') === 'board') {
@ -77,7 +76,6 @@ class File extends Base
public function download() public function download()
{ {
try { try {
$task = $this->getTask(); $task = $this->getTask();
$file = $this->file->getById($this->request->getIntegerParam('file_id')); $file = $this->file->getById($this->request->getIntegerParam('file_id'));
@ -87,8 +85,7 @@ class File extends Base
$this->response->forceDownload($file['name']); $this->response->forceDownload($file['name']);
$this->objectStorage->output($file['path']); $this->objectStorage->output($file['path']);
} } catch (ObjectStorageException $e) {
catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());
} }
} }
@ -112,50 +109,48 @@ class File extends Base
} }
/** /**
* Return the file content (work only for images) * Display image
* *
* @access public * @access public
*/ */
public function image() public function image()
{ {
try { try {
$task = $this->getTask(); $task = $this->getTask();
$file = $this->file->getById($this->request->getIntegerParam('file_id')); $file = $this->file->getById($this->request->getIntegerParam('file_id'));
if ($file['task_id'] != $task['id']) { if ($file['task_id'] == $task['id']) {
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
}
$this->response->contentType($this->file->getImageMimeType($file['name'])); $this->response->contentType($this->file->getImageMimeType($file['name']));
$this->objectStorage->output($file['path']); $this->objectStorage->output($file['path']);
} }
catch (ObjectStorageException $e) { } catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());
} }
} }
/** /**
* Return image thumbnails * Display image thumbnails
* *
* @access public * @access public
*/ */
public function thumbnail() public function thumbnail()
{ {
try { $this->response->contentType('image/jpeg');
try {
$task = $this->getTask(); $task = $this->getTask();
$file = $this->file->getById($this->request->getIntegerParam('file_id')); $file = $this->file->getById($this->request->getIntegerParam('file_id'));
if ($file['task_id'] != $task['id']) { if ($file['task_id'] == $task['id']) {
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
}
$this->response->contentType('image/jpeg');
$this->objectStorage->output($this->file->getThumbnailPath($file['path'])); $this->objectStorage->output($this->file->getThumbnailPath($file['path']));
} }
catch (ObjectStorageException $e) { } catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());
// Try to generate thumbnail on the fly for images uploaded before Kanboard < 1.0.19
$data = $this->objectStorage->get($file['path']);
$this->file->generateThumbnailFromData($file['path'], $data);
$this->objectStorage->output($this->file->getThumbnailPath($file['path']));
} }
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\Task as TaskModel; use Kanboard\Model\Task as TaskModel;
/** /**
* Gantt controller * Gantt controller
@ -19,8 +19,7 @@ class Gantt extends Base
{ {
if ($this->userSession->isAdmin()) { if ($this->userSession->isAdmin()) {
$project_ids = $this->project->getAllIds(); $project_ids = $this->project->getAllIds();
} } else {
else {
$project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId()); $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId());
} }
@ -62,8 +61,7 @@ class Gantt extends Base
if ($sorting === 'date') { if ($sorting === 'date') {
$filter->getQuery()->asc(TaskModel::TABLE.'.date_started')->asc(TaskModel::TABLE.'.date_creation'); $filter->getQuery()->asc(TaskModel::TABLE.'.date_started')->asc(TaskModel::TABLE.'.date_creation');
} } else {
else {
$filter->getQuery()->asc('column_position')->asc(TaskModel::TABLE.'.position'); $filter->getQuery()->asc('column_position')->asc(TaskModel::TABLE.'.position');
} }
@ -134,14 +132,12 @@ class Gantt extends Base
list($valid, $errors) = $this->taskValidator->validateCreation($values); list($valid, $errors) = $this->taskValidator->validateCreation($values);
if ($valid) { if ($valid) {
$task_id = $this->taskCreation->create($values); $task_id = $this->taskCreation->create($values);
if ($task_id !== false) { if ($task_id !== false) {
$this->session->flash(t('Task created successfully.')); $this->session->flash(t('Task created successfully.'));
$this->response->redirect($this->helper->url->to('gantt', 'project', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('gantt', 'project', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to create your task.')); $this->session->flashError(t('Unable to create your task.'));
} }
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\TaskFilter; use Kanboard\Model\TaskFilter;
use Eluceo\iCal\Component\Calendar as iCalendar; use Eluceo\iCal\Component\Calendar as iCalendar;
/** /**
@ -89,8 +89,7 @@ class Ical extends Base
->setColumns('date_creation', 'date_completed') ->setColumns('date_creation', 'date_completed')
->setCalendar($calendar) ->setCalendar($calendar)
->addDateTimeEvents(); ->addDateTimeEvents();
} } else {
else {
$filter $filter
->copy() ->copy()
->filterByStartDateRange($start, $end) ->filterByStartDateRange($start, $end)

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Link controller * Link controller
@ -70,12 +70,10 @@ class Link extends Base
list($valid, $errors) = $this->link->validateCreation($values); list($valid, $errors) = $this->link->validateCreation($values);
if ($valid) { if ($valid) {
if ($this->link->create($values['label'], $values['opposite_label']) !== false) { if ($this->link->create($values['label'], $values['opposite_label']) !== false) {
$this->session->flash(t('Link added successfully.')); $this->session->flash(t('Link added successfully.'));
$this->response->redirect($this->helper->url->to('link', 'index')); $this->response->redirect($this->helper->url->to('link', 'index'));
} } else {
else {
$this->session->flashError(t('Unable to create your link.')); $this->session->flashError(t('Unable to create your link.'));
} }
} }
@ -116,8 +114,7 @@ class Link extends Base
if ($this->link->update($values)) { if ($this->link->update($values)) {
$this->session->flash(t('Link updated successfully.')); $this->session->flash(t('Link updated successfully.'));
$this->response->redirect($this->helper->url->to('link', 'index')); $this->response->redirect($this->helper->url->to('link', 'index'));
} } else {
else {
$this->session->flashError(t('Unable to update your link.')); $this->session->flashError(t('Unable to update your link.'));
} }
} }
@ -152,8 +149,7 @@ class Link extends Base
if ($this->link->remove($link['id'])) { if ($this->link->remove($link['id'])) {
$this->session->flash(t('Link removed successfully.')); $this->session->flash(t('Link removed successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to remove this link.')); $this->session->flashError(t('Unable to remove this link.'));
} }

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\Task as TaskModel; use Kanboard\Model\Task as TaskModel;
/** /**
* List view controller * List view controller

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* OAuth controller * OAuth controller
@ -52,8 +52,7 @@ class Oauth extends Base
if ($this->authentication->backend($backend)->unlink($this->userSession->getId())) { if ($this->authentication->backend($backend)->unlink($this->userSession->getId())) {
$this->session->flash(t('Your external account is not linked anymore to your profile.')); $this->session->flash(t('Your external account is not linked anymore to your profile.'));
} } else {
else {
$this->session->flashError(t('Unable to unlink your external account.')); $this->session->flashError(t('Unable to unlink your external account.'));
} }
@ -71,8 +70,7 @@ class Oauth extends Base
if (! empty($code)) { if (! empty($code)) {
$this->step2($backend, $code); $this->step2($backend, $code);
} } else {
else {
$this->response->redirect($this->authentication->backend($backend)->getService()->getAuthorizationUrl()); $this->response->redirect($this->authentication->backend($backend)->getService()->getAuthorizationUrl());
} }
} }
@ -102,8 +100,7 @@ class Oauth extends Base
{ {
if (empty($profile)) { if (empty($profile)) {
$this->session->flashError(t('External authentication failed')); $this->session->flashError(t('External authentication failed'));
} } else {
else {
$this->session->flash(t('Your external account is linked to your profile successfully.')); $this->session->flash(t('Your external account is linked to your profile successfully.'));
$this->authentication->backend($backend)->updateUser($this->userSession->getId(), $profile); $this->authentication->backend($backend)->updateUser($this->userSession->getId(), $profile);
} }
@ -120,8 +117,7 @@ class Oauth extends Base
{ {
if (! empty($profile) && $this->authentication->backend($backend)->authenticate($profile['id'])) { if (! empty($profile) && $this->authentication->backend($backend)->authenticate($profile['id'])) {
$this->response->redirect($this->helper->url->to('app', 'index')); $this->response->redirect($this->helper->url->to('app', 'index'));
} } else {
else {
$this->response->html($this->template->layout('auth/index', array( $this->response->html($this->template->layout('auth/index', array(
'errors' => array('login' => t('External authentication failed')), 'errors' => array('login' => t('External authentication failed')),
'values' => array(), 'values' => array(),

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Project controller (Settings + creation/edition) * Project controller (Settings + creation/edition)
@ -19,8 +19,7 @@ class Project extends Base
{ {
if ($this->userSession->isAdmin()) { if ($this->userSession->isAdmin()) {
$project_ids = $this->project->getAllIds(); $project_ids = $this->project->getAllIds();
} } else {
else {
$project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId()); $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId());
} }
@ -68,13 +67,11 @@ class Project extends Base
$switch = $this->request->getStringParam('switch'); $switch = $this->request->getStringParam('switch');
if ($switch === 'enable' || $switch === 'disable') { if ($switch === 'enable' || $switch === 'disable') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->project->{$switch.'PublicAccess'}($project['id'])) { if ($this->project->{$switch.'PublicAccess'}($project['id'])) {
$this->session->flash(t('Project updated successfully.')); $this->session->flash(t('Project updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update this project.')); $this->session->flashError(t('Unable to update this project.'));
} }
@ -92,28 +89,49 @@ class Project extends Base
* *
* @access public * @access public
*/ */
public function integration() public function integrations()
{ {
$project = $this->getProject(); $project = $this->getProject();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$params = $this->request->getValues(); $this->projectMetadata->save($project['id'], $this->request->getValues());
$params += array('hipchat' => 0, 'slack' => 0, 'jabber' => 0); $this->session->flash(t('Project updated successfully.'));
$this->projectIntegration->saveParameters($project['id'], $params); $this->response->redirect($this->helper->url->to('project', 'integrations', array('project_id' => $project['id'])));
} }
$values = $this->projectIntegration->getParameters($project['id']);
$values += array('hipchat_api_url' => 'https://api.hipchat.com');
$this->response->html($this->projectLayout('project/integrations', array( $this->response->html($this->projectLayout('project/integrations', array(
'project' => $project, 'project' => $project,
'title' => t('Integrations'), 'title' => t('Integrations'),
'webhook_token' => $this->config->get('webhook_token'), 'webhook_token' => $this->config->get('webhook_token'),
'values' => $values, 'values' => $this->projectMetadata->getAll($project['id']),
'errors' => array(), 'errors' => array(),
))); )));
} }
/**
* Display project notifications
*
* @access public
*/
public function notifications()
{
$project = $this->getProject();
if ($this->request->isPost()) {
$values = $this->request->getValues();
$this->projectNotification->saveSettings($project['id'], $values);
$this->session->flash(t('Project updated successfully.'));
$this->response->redirect($this->helper->url->to('project', 'notifications', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/notifications', array(
'notifications' => $this->projectNotification->readSettings($project['id']),
'types' => $this->projectNotificationType->getTypes(),
'project' => $project,
'title' => t('Notifications'),
)));
}
/** /**
* Display a form to edit a project * Display a form to edit a project
* *
@ -145,8 +163,7 @@ class Project extends Base
if (! $this->helper->user->isProjectAdministrationAllowed($project['id'])) { if (! $this->helper->user->isProjectAdministrationAllowed($project['id'])) {
unset($values['is_private']); unset($values['is_private']);
} }
} } elseif ($project['is_private'] == 1 && ! isset($values['is_private'])) {
else if ($project['is_private'] == 1 && ! isset($values['is_private'])) {
if ($this->helper->user->isProjectAdministrationAllowed($project['id'])) { if ($this->helper->user->isProjectAdministrationAllowed($project['id'])) {
$values += array('is_private' => 0); $values += array('is_private' => 0);
} }
@ -155,12 +172,10 @@ class Project extends Base
list($valid, $errors) = $this->project->validateModification($values); list($valid, $errors) = $this->project->validateModification($values);
if ($valid) { if ($valid) {
if ($this->project->update($values)) { if ($this->project->update($values)) {
$this->session->flash(t('Project updated successfully.')); $this->session->flash(t('Project updated successfully.'));
$this->response->redirect($this->helper->url->to('project', 'edit', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('project', 'edit', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to update this project.')); $this->session->flashError(t('Unable to update this project.'));
} }
} }
@ -193,14 +208,12 @@ class Project extends Base
{ {
$project = $this->getProject(); $project = $this->getProject();
$values = $this->request->getValues() + array('is_everybody_allowed' => 0); $values = $this->request->getValues() + array('is_everybody_allowed' => 0);
list($valid,) = $this->projectPermission->validateProjectModification($values); list($valid, ) = $this->projectPermission->validateProjectModification($values);
if ($valid) { if ($valid) {
if ($this->project->update($values)) { if ($this->project->update($values)) {
$this->session->flash(t('Project updated successfully.')); $this->session->flash(t('Project updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update this project.')); $this->session->flashError(t('Unable to update this project.'));
} }
} }
@ -216,14 +229,12 @@ class Project extends Base
public function allow() public function allow()
{ {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid,) = $this->projectPermission->validateUserModification($values); list($valid, ) = $this->projectPermission->validateUserModification($values);
if ($valid) { if ($valid) {
if ($this->projectPermission->addMember($values['project_id'], $values['user_id'])) { if ($this->projectPermission->addMember($values['project_id'], $values['user_id'])) {
$this->session->flash(t('Project updated successfully.')); $this->session->flash(t('Project updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update this project.')); $this->session->flashError(t('Unable to update this project.'));
} }
} }
@ -246,14 +257,12 @@ class Project extends Base
'is_owner' => $this->request->getIntegerParam('is_owner'), 'is_owner' => $this->request->getIntegerParam('is_owner'),
); );
list($valid,) = $this->projectPermission->validateUserModification($values); list($valid, ) = $this->projectPermission->validateUserModification($values);
if ($valid) { if ($valid) {
if ($this->projectPermission->changeRole($values['project_id'], $values['user_id'], $values['is_owner'])) { if ($this->projectPermission->changeRole($values['project_id'], $values['user_id'], $values['is_owner'])) {
$this->session->flash(t('Project updated successfully.')); $this->session->flash(t('Project updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update this project.')); $this->session->flashError(t('Unable to update this project.'));
} }
} }
@ -275,14 +284,12 @@ class Project extends Base
'user_id' => $this->request->getIntegerParam('user_id'), 'user_id' => $this->request->getIntegerParam('user_id'),
); );
list($valid,) = $this->projectPermission->validateUserModification($values); list($valid, ) = $this->projectPermission->validateUserModification($values);
if ($valid) { if ($valid) {
if ($this->projectPermission->revokeMember($values['project_id'], $values['user_id'])) { if ($this->projectPermission->revokeMember($values['project_id'], $values['user_id'])) {
$this->session->flash(t('Project updated successfully.')); $this->session->flash(t('Project updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update this project.')); $this->session->flashError(t('Unable to update this project.'));
} }
} }
@ -300,7 +307,6 @@ class Project extends Base
$project = $this->getProject(); $project = $this->getProject();
if ($this->request->getStringParam('remove') === 'yes') { if ($this->request->getStringParam('remove') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->project->remove($project['id'])) { if ($this->project->remove($project['id'])) {
@ -356,7 +362,6 @@ class Project extends Base
$project = $this->getProject(); $project = $this->getProject();
if ($this->request->getStringParam('disable') === 'yes') { if ($this->request->getStringParam('disable') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->project->disable($project['id'])) { if ($this->project->disable($project['id'])) {
@ -384,7 +389,6 @@ class Project extends Base
$project = $this->getProject(); $project = $this->getProject();
if ($this->request->getStringParam('enable') === 'yes') { if ($this->request->getStringParam('enable') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->project->enable($project['id'])) { if ($this->project->enable($project['id'])) {
@ -431,7 +435,6 @@ class Project extends Base
list($valid, $errors) = $this->project->validateCreation($values); list($valid, $errors) = $this->project->validateCreation($values);
if ($valid) { if ($valid) {
$project_id = $this->project->create($values, $this->userSession->getId(), true); $project_id = $this->project->create($values, $this->userSession->getId(), true);
if ($project_id > 0) { if ($project_id > 0) {

View file

@ -1,9 +1,9 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\User as UserModel; use Kanboard\Model\User as UserModel;
use Model\Task as TaskModel; use Kanboard\Model\Task as TaskModel;
/** /**
* Project User overview * Project User overview
@ -36,8 +36,7 @@ class Projectuser extends Base
if ($this->userSession->isAdmin()) { if ($this->userSession->isAdmin()) {
$project_ids = $this->project->getAllIds(); $project_ids = $this->project->getAllIds();
} } else {
else {
$project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId()); $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId());
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Search controller * Search controller
@ -22,8 +22,7 @@ class Search extends Base
->setOrder('tasks.id') ->setOrder('tasks.id')
->setDirection('DESC'); ->setDirection('DESC');
if ($search !== '') { if ($search !== '' && ! empty($projects)) {
$query = $this $query = $this
->taskFilter ->taskFilter
->search($search) ->search($search)

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\Subtask as SubtaskModel; use Kanboard\Model\Subtask as SubtaskModel;
/** /**
* Subtask controller * Subtask controller
@ -66,11 +66,9 @@ class Subtask extends Base
list($valid, $errors) = $this->subtask->validateCreation($values); list($valid, $errors) = $this->subtask->validateCreation($values);
if ($valid) { if ($valid) {
if ($this->subtask->create($values)) { if ($this->subtask->create($values)) {
$this->session->flash(t('Sub-task added successfully.')); $this->session->flash(t('Sub-task added successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to create your sub-task.')); $this->session->flashError(t('Unable to create your sub-task.'));
} }
@ -118,11 +116,9 @@ class Subtask extends Base
list($valid, $errors) = $this->subtask->validateModification($values); list($valid, $errors) = $this->subtask->validateModification($values);
if ($valid) { if ($valid) {
if ($this->subtask->update($values)) { if ($this->subtask->update($values)) {
$this->session->flash(t('Sub-task updated successfully.')); $this->session->flash(t('Sub-task updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your sub-task.')); $this->session->flashError(t('Unable to update your sub-task.'));
} }
@ -161,8 +157,7 @@ class Subtask extends Base
if ($this->subtask->remove($subtask['id'])) { if ($this->subtask->remove($subtask['id'])) {
$this->session->flash(t('Sub-task removed successfully.')); $this->session->flash(t('Sub-task removed successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to remove this sub-task.')); $this->session->flashError(t('Unable to remove this sub-task.'));
} }
@ -183,7 +178,6 @@ class Subtask extends Base
$this->subtask->toggleStatus($subtask['id']); $this->subtask->toggleStatus($subtask['id']);
if ($redirect === 'board') { if ($redirect === 'board') {
$this->session['has_subtask_inprogress'] = $this->subtask->hasSubtaskInProgress($this->userSession->getId()); $this->session['has_subtask_inprogress'] = $this->subtask->hasSubtaskInProgress($this->userSession->getId());
$this->response->html($this->template->render('board/tooltip_subtasks', array( $this->response->html($this->template->render('board/tooltip_subtasks', array(

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\Swimlane as SwimlaneModel; use Kanboard\Model\Swimlane as SwimlaneModel;
/** /**
* Swimlanes * Swimlanes
@ -63,12 +63,10 @@ class Swimlane extends Base
list($valid, $errors) = $this->swimlane->validateCreation($values); list($valid, $errors) = $this->swimlane->validateCreation($values);
if ($valid) { if ($valid) {
if ($this->swimlane->create($values)) { if ($this->swimlane->create($values)) {
$this->session->flash(t('Your swimlane have been created successfully.')); $this->session->flash(t('Your swimlane have been created successfully.'));
$this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to create your swimlane.')); $this->session->flashError(t('Unable to create your swimlane.'));
} }
} }
@ -86,15 +84,13 @@ class Swimlane extends Base
$project = $this->getProject(); $project = $this->getProject();
$values = $this->request->getValues() + array('show_default_swimlane' => 0); $values = $this->request->getValues() + array('show_default_swimlane' => 0);
list($valid,) = $this->swimlane->validateDefaultModification($values); list($valid, ) = $this->swimlane->validateDefaultModification($values);
if ($valid) { if ($valid) {
if ($this->swimlane->updateDefault($values)) { if ($this->swimlane->updateDefault($values)) {
$this->session->flash(t('The default swimlane have been updated successfully.')); $this->session->flash(t('The default swimlane have been updated successfully.'));
$this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to update this swimlane.')); $this->session->flashError(t('Unable to update this swimlane.'));
} }
} }
@ -136,8 +132,7 @@ class Swimlane extends Base
if ($this->swimlane->update($values)) { if ($this->swimlane->update($values)) {
$this->session->flash(t('Swimlane updated successfully.')); $this->session->flash(t('Swimlane updated successfully.'));
$this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
} } else {
else {
$this->session->flashError(t('Unable to update this swimlane.')); $this->session->flashError(t('Unable to update this swimlane.'));
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Task controller * Task controller
@ -68,7 +68,7 @@ class Task extends Base
'project' => $this->project->getById($task['project_id']), 'project' => $this->project->getById($task['project_id']),
'files' => $this->file->getAllDocuments($task['id']), 'files' => $this->file->getAllDocuments($task['id']),
'images' => $this->file->getAllImages($task['id']), 'images' => $this->file->getAllImages($task['id']),
'comments' => $this->comment->getAll($task['id']), 'comments' => $this->comment->getAll($task['id'], $this->userSession->getCommentSorting()),
'subtasks' => $subtasks, 'subtasks' => $subtasks,
'links' => $this->taskLink->getAllGroupedByLabel($task['id']), 'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
'task' => $task, 'task' => $task,
@ -156,7 +156,6 @@ class Task extends Base
} }
if ($this->request->getStringParam('confirmation') === 'yes') { if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->task->remove($task['id'])) { if ($this->task->remove($task['id'])) {

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Task Creation controller * Task Creation controller
@ -22,7 +22,6 @@ class Taskcreation extends Base
$swimlanes_list = $this->swimlane->getList($project['id'], false, true); $swimlanes_list = $this->swimlane->getList($project['id'], false, true);
if (empty($values)) { if (empty($values)) {
$values = array( $values = array(
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)), 'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)),
'column_id' => $this->request->getIntegerParam('column_id'), 'column_id' => $this->request->getIntegerParam('column_id'),
@ -62,8 +61,7 @@ class Taskcreation extends Base
if ($valid && $this->taskCreation->create($values)) { if ($valid && $this->taskCreation->create($values)) {
$this->session->flash(t('Task created successfully.')); $this->session->flash(t('Task created successfully.'));
$this->afterSave($project, $values); $this->afterSave($project, $values);
} } else {
else {
$this->session->flashError(t('Unable to create your task.')); $this->session->flashError(t('Unable to create your task.'));
} }
@ -79,8 +77,7 @@ class Taskcreation extends Base
if (! $this->request->isAjax()) { if (! $this->request->isAjax()) {
$this->response->redirect($this->helper->url->to('taskcreation', 'create', $values)); $this->response->redirect($this->helper->url->to('taskcreation', 'create', $values));
} }
} } else {
else {
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id']))); $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id'])));
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Task Duplication controller * Task Duplication controller
@ -20,7 +20,6 @@ class Taskduplication extends Base
$task = $this->getTask(); $task = $this->getTask();
if ($this->request->getStringParam('confirmation') === 'yes') { if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
$task_id = $this->taskDuplication->duplicate($task['id']); $task_id = $this->taskDuplication->duplicate($task['id']);
@ -48,9 +47,8 @@ class Taskduplication extends Base
$task = $this->getTask(); $task = $this->getTask();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid,) = $this->taskValidator->validateProjectModification($values); list($valid, ) = $this->taskValidator->validateProjectModification($values);
if ($valid && $this->taskDuplication->moveToProject($task['id'], if ($valid && $this->taskDuplication->moveToProject($task['id'],
$values['project_id'], $values['project_id'],
@ -58,7 +56,6 @@ class Taskduplication extends Base
$values['column_id'], $values['column_id'],
$values['category_id'], $values['category_id'],
$values['owner_id'])) { $values['owner_id'])) {
$this->session->flash(t('Task updated successfully.')); $this->session->flash(t('Task updated successfully.'));
$this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $values['project_id'], 'task_id' => $task['id']))); $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $values['project_id'], 'task_id' => $task['id'])));
} }
@ -79,9 +76,8 @@ class Taskduplication extends Base
$task = $this->getTask(); $task = $this->getTask();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid,) = $this->taskValidator->validateProjectModification($values); list($valid, ) = $this->taskValidator->validateProjectModification($values);
if ($valid) { if ($valid) {
$task_id = $this->taskDuplication->duplicateToProject( $task_id = $this->taskDuplication->duplicateToProject(
@ -125,8 +121,7 @@ class Taskduplication extends Base
$values = $this->taskDuplication->checkDestinationProjectValues($task); $values = $this->taskDuplication->checkDestinationProjectValues($task);
$values['project_id'] = $dst_project_id; $values['project_id'] = $dst_project_id;
} } else {
else {
$swimlanes_list = array(); $swimlanes_list = array();
$columns_list = array(); $columns_list = array();
$categories_list = array(); $categories_list = array();

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* TaskLink controller * TaskLink controller
@ -72,7 +72,6 @@ class Tasklink extends Base
list($valid, $errors) = $this->taskLink->validateCreation($values); list($valid, $errors) = $this->taskLink->validateCreation($values);
if ($valid) { if ($valid) {
if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) { if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
$this->session->flash(t('Link added successfully.')); $this->session->flash(t('Link added successfully.'));
@ -129,7 +128,6 @@ class Tasklink extends Base
list($valid, $errors) = $this->taskLink->validateModification($values); list($valid, $errors) = $this->taskLink->validateModification($values);
if ($valid) { if ($valid) {
if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) { if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
$this->session->flash(t('Link updated successfully.')); $this->session->flash(t('Link updated successfully.'));
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links'); $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
@ -169,8 +167,7 @@ class Tasklink extends Base
if ($this->taskLink->remove($this->request->getIntegerParam('link_id'))) { if ($this->taskLink->remove($this->request->getIntegerParam('link_id'))) {
$this->session->flash(t('Link removed successfully.')); $this->session->flash(t('Link removed successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to remove this link.')); $this->session->flashError(t('Unable to remove this link.'));
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Task Modification controller * Task Modification controller
@ -32,12 +32,11 @@ class Taskmodification extends Base
$task = $this->getTask(); $task = $this->getTask();
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid,) = $this->taskValidator->validateTimeModification($values); list($valid, ) = $this->taskValidator->validateTimeModification($values);
if ($valid && $this->taskModification->update($values)) { if ($valid && $this->taskModification->update($values)) {
$this->session->flash(t('Task updated successfully.')); $this->session->flash(t('Task updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your task.')); $this->session->flashError(t('Unable to update your task.'));
} }
@ -55,29 +54,24 @@ class Taskmodification extends Base
$ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax'); $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values); list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values);
if ($valid) { if ($valid) {
if ($this->taskModification->update($values)) { if ($this->taskModification->update($values)) {
$this->session->flash(t('Task updated successfully.')); $this->session->flash(t('Task updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your task.')); $this->session->flashError(t('Unable to update your task.'));
} }
if ($ajax) { if ($ajax) {
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
} } else {
else {
$this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
} }
} }
} } else {
else {
$values = $task; $values = $task;
$errors = array(); $errors = array();
} }
@ -91,8 +85,7 @@ class Taskmodification extends Base
if ($ajax) { if ($ajax) {
$this->response->html($this->template->render('task_modification/edit_description', $params)); $this->response->html($this->template->render('task_modification/edit_description', $params));
} } else {
else {
$this->response->html($this->taskLayout('task_modification/edit_description', $params)); $this->response->html($this->taskLayout('task_modification/edit_description', $params));
} }
} }
@ -127,8 +120,7 @@ class Taskmodification extends Base
if ($ajax) { if ($ajax) {
$html = $this->template->render('task_modification/edit_task', $params); $html = $this->template->render('task_modification/edit_task', $params);
} } else {
else {
$html = $this->taskLayout('task_modification/edit_task', $params); $html = $this->taskLayout('task_modification/edit_task', $params);
} }
@ -152,12 +144,10 @@ class Taskmodification extends Base
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
} } else {
else {
$this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
} }
} } else {
else {
$this->session->flashError(t('Unable to update your task.')); $this->session->flashError(t('Unable to update your task.'));
$this->edit($values, $errors); $this->edit($values, $errors);
} }
@ -173,24 +163,20 @@ class Taskmodification extends Base
$task = $this->getTask(); $task = $this->getTask();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values); list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values);
if ($valid) { if ($valid) {
if ($this->taskModification->update($values)) { if ($this->taskModification->update($values)) {
$this->session->flash(t('Task updated successfully.')); $this->session->flash(t('Task updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your task.')); $this->session->flashError(t('Unable to update your task.'));
} }
$this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
} }
} } else {
else {
$values = $task; $values = $task;
$errors = array(); $errors = array();
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Task Status controller * Task Status controller
@ -37,7 +37,6 @@ class Taskstatus extends Base
private function changeStatus(array $task, $method, $success_message, $failure_message) private function changeStatus(array $task, $method, $success_message, $failure_message)
{ {
if ($this->request->getStringParam('confirmation') === 'yes') { if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->taskStatus->$method($task['id'])) { if ($this->taskStatus->$method($task['id'])) {

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Time Tracking controller * Time Tracking controller
@ -24,8 +24,7 @@ class Timer extends Base
if ($timer === 'start') { if ($timer === 'start') {
$this->subtaskTimeTracking->logStartTime($subtask_id, $this->userSession->getId()); $this->subtaskTimeTracking->logStartTime($subtask_id, $this->userSession->getId());
} } elseif ($timer === 'stop') {
else if ($timer === 'stop') {
$this->subtaskTimeTracking->logEndTime($subtask_id, $this->userSession->getId()); $this->subtaskTimeTracking->logEndTime($subtask_id, $this->userSession->getId());
$this->subtaskTimeTracking->updateTaskTimeTracking($task_id); $this->subtaskTimeTracking->updateTaskTimeTracking($task_id);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Otp\Otp; use Otp\Otp;
use Otp\GoogleAuthenticator; use Otp\GoogleAuthenticator;
@ -63,8 +63,7 @@ class Twofactor extends User
'twofactor_activated' => 1, 'twofactor_activated' => 1,
'twofactor_secret' => GoogleAuthenticator::generateRandom(), 'twofactor_secret' => GoogleAuthenticator::generateRandom(),
)); ));
} } else {
else {
$this->user->update(array( $this->user->update(array(
'id' => $user['id'], 'id' => $user['id'],
'twofactor_activated' => 0, 'twofactor_activated' => 0,
@ -94,8 +93,7 @@ class Twofactor extends User
if (! empty($values['code']) && $otp->checkTotp(Base32::decode($user['twofactor_secret']), $values['code'])) { if (! empty($values['code']) && $otp->checkTotp(Base32::decode($user['twofactor_secret']), $values['code'])) {
$this->session->flash(t('The two factor authentication code is valid.')); $this->session->flash(t('The two factor authentication code is valid.'));
} } else {
else {
$this->session->flashError(t('The two factor authentication code is not valid.')); $this->session->flashError(t('The two factor authentication code is not valid.'));
} }
@ -119,8 +117,7 @@ class Twofactor extends User
$this->session['2fa_validated'] = true; $this->session['2fa_validated'] = true;
$this->session->flash(t('The two factor authentication code is valid.')); $this->session->flash(t('The two factor authentication code is valid.'));
$this->response->redirect($this->helper->url->to('app', 'index')); $this->response->redirect($this->helper->url->to('app', 'index'));
} } else {
else {
$this->session->flashError(t('The two factor authentication code is not valid.')); $this->session->flashError(t('The two factor authentication code is not valid.'));
$this->response->redirect($this->helper->url->to('twofactor', 'code')); $this->response->redirect($this->helper->url->to('twofactor', 'code'));
} }
@ -148,7 +145,6 @@ class Twofactor extends User
$user = $this->getUser(); $user = $this->getUser();
if ($this->request->getStringParam('disable') === 'yes') { if ($this->request->getStringParam('disable') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
$this->user->update(array( $this->user->update(array(

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
use Model\NotificationType; use Kanboard\Model\NotificationType;
/** /**
* User controller * User controller
@ -86,7 +86,6 @@ class User extends Base
list($valid, $errors) = $this->user->validateCreation($values); list($valid, $errors) = $this->user->validateCreation($values);
if ($valid) { if ($valid) {
$project_id = empty($values['project_id']) ? 0 : $values['project_id']; $project_id = empty($values['project_id']) ? 0 : $values['project_id'];
unset($values['project_id']); unset($values['project_id']);
@ -96,13 +95,12 @@ class User extends Base
$this->projectPermission->addMember($project_id, $user_id); $this->projectPermission->addMember($project_id, $user_id);
if (! empty($values['notifications_enabled'])) { if (! empty($values['notifications_enabled'])) {
$this->notificationType->saveUserSelectedTypes($user_id, array(NotificationType::TYPE_EMAIL)); $this->userNotificationType->saveSelectedTypes($user_id, array(NotificationType::TYPE_EMAIL));
} }
$this->session->flash(t('User created successfully.')); $this->session->flash(t('User created successfully.'));
$this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user_id))); $this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user_id)));
} } else {
else {
$this->session->flashError(t('Unable to create your user.')); $this->session->flashError(t('Unable to create your user.'));
$values['project_id'] = $project_id; $values['project_id'] = $project_id;
} }
@ -201,20 +199,42 @@ class User extends Base
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
$this->notification->saveSettings($user['id'], $values); $this->userNotification->saveSettings($user['id'], $values);
$this->session->flash(t('User updated successfully.')); $this->session->flash(t('User updated successfully.'));
$this->response->redirect($this->helper->url->to('user', 'notifications', array('user_id' => $user['id']))); $this->response->redirect($this->helper->url->to('user', 'notifications', array('user_id' => $user['id'])));
} }
$this->response->html($this->layout('user/notifications', array( $this->response->html($this->layout('user/notifications', array(
'projects' => $this->projectPermission->getMemberProjects($user['id']), 'projects' => $this->projectPermission->getMemberProjects($user['id']),
'notifications' => $this->notification->readSettings($user['id']), 'notifications' => $this->userNotification->readSettings($user['id']),
'types' => $this->notificationType->getTypes(), 'types' => $this->userNotificationType->getTypes(),
'filters' => $this->notificationFilter->getFilters(), 'filters' => $this->userNotificationFilter->getFilters(),
'user' => $user, 'user' => $user,
))); )));
} }
/**
* Display user integrations
*
* @access public
*/
public function integrations()
{
$user = $this->getUser();
if ($this->request->isPost()) {
$values = $this->request->getValues();
$this->userMetadata->save($user['id'], $values);
$this->session->flash(t('User updated successfully.'));
$this->response->redirect($this->helper->url->to('user', 'integrations', array('user_id' => $user['id'])));
}
$this->response->html($this->layout('user/integrations', array(
'user' => $user,
'values' => $this->userMetadata->getall($user['id']),
)));
}
/** /**
* Display external accounts * Display external accounts
* *
@ -240,7 +260,6 @@ class User extends Base
$switch = $this->request->getStringParam('switch'); $switch = $this->request->getStringParam('switch');
if ($switch === 'enable' || $switch === 'disable') { if ($switch === 'enable' || $switch === 'disable') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->user->{$switch.'PublicAccess'}($user['id'])) { if ($this->user->{$switch.'PublicAccess'}($user['id'])) {
@ -270,16 +289,13 @@ class User extends Base
$errors = array(); $errors = array();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
list($valid, $errors) = $this->user->validatePasswordModification($values); list($valid, $errors) = $this->user->validatePasswordModification($values);
if ($valid) { if ($valid) {
if ($this->user->update($values)) { if ($this->user->update($values)) {
$this->session->flash(t('Password modified successfully.')); $this->session->flash(t('Password modified successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to change the password.')); $this->session->flashError(t('Unable to change the password.'));
} }
@ -308,13 +324,11 @@ class User extends Base
unset($values['password']); unset($values['password']);
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues(); $values = $this->request->getValues();
if ($this->userSession->isAdmin()) { if ($this->userSession->isAdmin()) {
$values += array('is_admin' => 0, 'is_project_admin' => 0); $values += array('is_admin' => 0, 'is_project_admin' => 0);
} } else {
else {
// Regular users can't be admin // Regular users can't be admin
if (isset($values['is_admin'])) { if (isset($values['is_admin'])) {
unset($values['is_admin']); unset($values['is_admin']);
@ -328,11 +342,9 @@ class User extends Base
list($valid, $errors) = $this->user->validateModification($values); list($valid, $errors) = $this->user->validateModification($values);
if ($valid) { if ($valid) {
if ($this->user->update($values)) { if ($this->user->update($values)) {
$this->session->flash(t('User updated successfully.')); $this->session->flash(t('User updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your user.')); $this->session->flashError(t('Unable to update your user.'));
} }
@ -363,16 +375,13 @@ class User extends Base
unset($values['password']); unset($values['password']);
if ($this->request->isPost()) { if ($this->request->isPost()) {
$values = $this->request->getValues() + array('disable_login_form' => 0, 'is_ldap_user' => 0); $values = $this->request->getValues() + array('disable_login_form' => 0, 'is_ldap_user' => 0);
list($valid, $errors) = $this->user->validateModification($values); list($valid, $errors) = $this->user->validateModification($values);
if ($valid) { if ($valid) {
if ($this->user->update($values)) { if ($this->user->update($values)) {
$this->session->flash(t('User updated successfully.')); $this->session->flash(t('User updated successfully.'));
} } else {
else {
$this->session->flashError(t('Unable to update your user.')); $this->session->flashError(t('Unable to update your user.'));
} }
@ -397,7 +406,6 @@ class User extends Base
$user = $this->getUser(); $user = $this->getUser();
if ($this->request->getStringParam('confirmation') === 'yes') { if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam(); $this->checkCSRFParam();
if ($this->user->remove($user['id'])) { if ($this->user->remove($user['id'])) {

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Controller; namespace Kanboard\Controller;
/** /**
* Webhook controller * Webhook controller
@ -31,7 +31,7 @@ class Webhook extends Base
'category_id' => $this->request->getIntegerParam('category_id'), 'category_id' => $this->request->getIntegerParam('category_id'),
); );
list($valid,) = $this->taskValidator->validateCreation($values); list($valid, ) = $this->taskValidator->validateCreation($values);
if ($valid && $this->taskCreation->create($values)) { if ($valid && $this->taskCreation->create($values)) {
$this->response->text('OK'); $this->response->text('OK');
@ -92,37 +92,4 @@ class Webhook extends Base
echo $result ? 'PARSED' : 'IGNORED'; echo $result ? 'PARSED' : 'IGNORED';
} }
/**
* Handle Postmark webhooks
*
* @access public
*/
public function postmark()
{
$this->checkWebhookToken();
echo $this->postmark->receiveEmail($this->request->getJson()) ? 'PARSED' : 'IGNORED';
}
/**
* Handle Mailgun webhooks
*
* @access public
*/
public function mailgun()
{
$this->checkWebhookToken();
echo $this->mailgun->receiveEmail($_POST) ? 'PARSED' : 'IGNORED';
}
/**
* Handle Sendgrid webhooks
*
* @access public
*/
public function sendgrid()
{
$this->checkWebhookToken();
echo $this->sendgrid->receiveEmail($_POST) ? 'PARSED' : 'IGNORED';
}
} }

View file

@ -1,39 +0,0 @@
<?php
namespace Controller;
/**
* Web notification controller
*
* @package controller
* @author Frederic Guillot
*/
class Webnotification extends Base
{
/**
* Mark all notifications as read
*
* @access public
*/
public function flush()
{
$user_id = $this->userSession->getId();
$this->webNotification->markAllAsRead($user_id);
$this->response->redirect($this->helper->url->to('app', 'notifications', array('user_id' => $user_id)));
}
/**
* Mark a notification as read
*
* @access public
*/
public function remove()
{
$user_id = $this->userSession->getId();
$notification_id = $this->request->getIntegerParam('notification_id');
$this->webNotification->markAsRead($user_id, $notification_id);
$this->response->redirect($this->helper->url->to('app', 'notifications', array('user_id' => $user_id)));
}
}

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Core; namespace Kanboard\Core;
use Pimple\Container; use Pimple\Container;
@ -10,83 +10,83 @@ use Pimple\Container;
* @package core * @package core
* @author Frederic Guillot * @author Frederic Guillot
* *
* @property \Core\Helper $helper * @property \Kanboard\Core\Helper $helper
* @property \Core\EmailClient $emailClient * @property \Kanboard\Core\Mail\Client $emailClient
* @property \Core\HttpClient $httpClient * @property \Kanboard\Core\HttpClient $httpClient
* @property \Core\Paginator $paginator * @property \Kanboard\Core\Paginator $paginator
* @property \Core\Request $request * @property \Kanboard\Core\Request $request
* @property \Core\Session $session * @property \Kanboard\Core\Session $session
* @property \Core\Template $template * @property \Kanboard\Core\Template $template
* @property \Core\OAuth2 $oauth * @property \Kanboard\Core\OAuth2 $oauth
* @property \Core\Router $router * @property \Kanboard\Core\Router $router
* @property \Core\Lexer $lexer * @property \Kanboard\Core\Lexer $lexer
* @property \Core\ObjectStorage\ObjectStorageInterface $objectStorage * @property \Kanboard\Core\ObjectStorage\ObjectStorageInterface $objectStorage
* @property \Core\Cache\Cache $memoryCache * @property \Kanboard\Core\Cache\Cache $memoryCache
* @property \Core\Plugin\Hook $hook * @property \Kanboard\Core\Plugin\Hook $hook
* @property \Core\Plugin\Loader $pluginLoader * @property \Kanboard\Core\Plugin\Loader $pluginLoader
* @property \Integration\BitbucketWebhook $bitbucketWebhook * @property \Kanboard\Integration\BitbucketWebhook $bitbucketWebhook
* @property \Integration\GithubWebhook $githubWebhook * @property \Kanboard\Integration\GithubWebhook $githubWebhook
* @property \Integration\GitlabWebhook $gitlabWebhook * @property \Kanboard\Integration\GitlabWebhook $gitlabWebhook
* @property \Integration\HipchatWebhook $hipchatWebhook * @property \Kanboard\Formatter\ProjectGanttFormatter $projectGanttFormatter
* @property \Integration\Jabber $jabber * @property \Kanboard\Formatter\TaskFilterGanttFormatter $taskFilterGanttFormatter
* @property \Integration\Mailgun $mailgun * @property \Kanboard\Formatter\TaskFilterAutoCompleteFormatter $taskFilterAutoCompleteFormatter
* @property \Integration\Postmark $postmark * @property \Kanboard\Formatter\TaskFilterCalendarFormatter $taskFilterCalendarFormatter
* @property \Integration\Sendgrid $sendgrid * @property \Kanboard\Formatter\TaskFilterICalendarFormatter $taskFilterICalendarFormatter
* @property \Integration\SlackWebhook $slackWebhook * @property \Kanboard\Model\Acl $acl
* @property \Integration\Smtp $smtp * @property \Kanboard\Model\Action $action
* @property \Formatter\ProjectGanttFormatter $projectGanttFormatter * @property \Kanboard\Model\Authentication $authentication
* @property \Formatter\TaskFilterGanttFormatter $taskFilterGanttFormatter * @property \Kanboard\Model\Board $board
* @property \Formatter\TaskFilterAutoCompleteFormatter $taskFilterAutoCompleteFormatter * @property \Kanboard\Model\Category $category
* @property \Formatter\TaskFilterCalendarFormatter $taskFilterCalendarFormatter * @property \Kanboard\Model\Color $color
* @property \Formatter\TaskFilterICalendarFormatter $taskFilterICalendarFormatter * @property \Kanboard\Model\Comment $comment
* @property \Model\Acl $acl * @property \Kanboard\Model\Config $config
* @property \Model\Action $action * @property \Kanboard\Model\Currency $currency
* @property \Model\Authentication $authentication * @property \Kanboard\Model\CustomFilter $customFilter
* @property \Model\Board $board * @property \Kanboard\Model\DateParser $dateParser
* @property \Model\Category $category * @property \Kanboard\Model\File $file
* @property \Model\Color $color * @property \Kanboard\Model\LastLogin $lastLogin
* @property \Model\Comment $comment * @property \Kanboard\Model\Link $link
* @property \Model\Config $config * @property \Kanboard\Model\Notification $notification
* @property \Model\Currency $currency * @property \Kanboard\Model\OverdueNotification $overdueNotification
* @property \Model\CustomFilter $customFilter * @property \Kanboard\Model\Project $project
* @property \Model\DateParser $dateParser * @property \Kanboard\Model\ProjectActivity $projectActivity
* @property \Model\File $file * @property \Kanboard\Model\ProjectAnalytic $projectAnalytic
* @property \Model\LastLogin $lastLogin * @property \Kanboard\Model\ProjectDuplication $projectDuplication
* @property \Model\Link $link * @property \Kanboard\Model\ProjectDailyColumnStats $projectDailyColumnStats
* @property \Model\Notification $notification * @property \Kanboard\Model\ProjectDailyStats $projectDailyStats
* @property \Model\NotificationType $notificationType * @property \Kanboard\Model\ProjectMetadata $projectMetadata
* @property \Model\NotificationFilter $notificationFilter * @property \Kanboard\Model\ProjectPermission $projectPermission
* @property \Model\OverdueNotification $overdueNotification * @property \Kanboard\Model\ProjectNotification $projectNotification
* @property \Model\WebNotification $webNotification * @property \Kanboard\Model\ProjectNotificationType $projectNotificationType
* @property \Model\Project $project * @property \Kanboard\Model\Subtask $subtask
* @property \Model\ProjectActivity $projectActivity * @property \Kanboard\Model\SubtaskExport $subtaskExport
* @property \Model\ProjectAnalytic $projectAnalytic * @property \Kanboard\Model\SubtaskTimeTracking $subtaskTimeTracking
* @property \Model\ProjectDuplication $projectDuplication * @property \Kanboard\Model\Swimlane $swimlane
* @property \Model\ProjectDailyColumnStats $projectDailyColumnStats * @property \Kanboard\Model\Task $task
* @property \Model\ProjectDailyStats $projectDailyStats * @property \Kanboard\Model\TaskAnalytic $taskAnalytic
* @property \Model\ProjectIntegration $projectIntegration * @property \Kanboard\Model\TaskCreation $taskCreation
* @property \Model\ProjectPermission $projectPermission * @property \Kanboard\Model\TaskDuplication $taskDuplication
* @property \Model\Subtask $subtask * @property \Kanboard\Model\TaskExport $taskExport
* @property \Model\SubtaskExport $subtaskExport * @property \Kanboard\Model\TaskImport $taskImport
* @property \Model\SubtaskTimeTracking $subtaskTimeTracking * @property \Kanboard\Model\TaskFinder $taskFinder
* @property \Model\Swimlane $swimlane * @property \Kanboard\Model\TaskFilter $taskFilter
* @property \Model\Task $task * @property \Kanboard\Model\TaskLink $taskLink
* @property \Model\TaskAnalytic $taskAnalytic * @property \Kanboard\Model\TaskModification $taskModification
* @property \Model\TaskCreation $taskCreation * @property \Kanboard\Model\TaskPermission $taskPermission
* @property \Model\TaskDuplication $taskDuplication * @property \Kanboard\Model\TaskPosition $taskPosition
* @property \Model\TaskExport $taskExport * @property \Kanboard\Model\TaskStatus $taskStatus
* @property \Model\TaskFinder $taskFinder * @property \Kanboard\Model\TaskValidator $taskValidator
* @property \Model\TaskFilter $taskFilter * @property \Kanboard\Model\TaskMetadata $taskMetadata
* @property \Model\TaskLink $taskLink * @property \Kanboard\Model\Transition $transition
* @property \Model\TaskModification $taskModification * @property \Kanboard\Model\User $user
* @property \Model\TaskPermission $taskPermission * @property \Kanboard\Model\UserImport $userImport
* @property \Model\TaskPosition $taskPosition * @property \Kanboard\Model\UserNotification $userNotification
* @property \Model\TaskStatus $taskStatus * @property \Kanboard\Model\UserNotificationType $userNotificationType
* @property \Model\TaskValidator $taskValidator * @property \Kanboard\Model\UserNotificationFilter $userNotificationFilter
* @property \Model\Transition $transition * @property \Kanboard\Model\UserUnreadNotification $userUnreadNotification
* @property \Model\User $user * @property \Kanboard\Model\UserSession $userSession
* @property \Model\UserSession $userSession * @property \Kanboard\Model\UserMetadata $userMetadata
* @property \Model\Webhook $webhook * @property \Kanboard\Model\Webhook $webhook
* @property \Psr\Log\LoggerInterface $logger * @property \Psr\Log\LoggerInterface $logger
* @property \League\HTMLToMarkdown\HtmlConverter $htmlConverter * @property \League\HTMLToMarkdown\HtmlConverter $htmlConverter
* @property \PicoDb\Database $db * @property \PicoDb\Database $db

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Core\Cache; namespace Kanboard\Core\Cache;
/** /**
* Base class for cache drivers * Base class for cache drivers

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Core\Cache; namespace Kanboard\Core\Cache;
/** /**
* Cache Interface * Cache Interface

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Core\Cache; namespace Kanboard\Core\Cache;
/** /**
* Memory Cache * Memory Cache

Some files were not shown because too many files have changed in this diff Show more