summaryrefslogtreecommitdiff
path: root/app/Core
diff options
context:
space:
mode:
Diffstat (limited to 'app/Core')
-rw-r--r--app/Core/Action/ActionManager.php16
-rw-r--r--app/Core/Base.php39
-rw-r--r--app/Core/Cache/BaseCache.php (renamed from app/Core/Cache/Base.php)6
-rw-r--r--app/Core/Cache/CacheInterface.php14
-rw-r--r--app/Core/Cache/FileCache.php98
-rw-r--r--app/Core/Cache/MemoryCache.php10
-rw-r--r--app/Core/ExternalLink/ExternalLinkManager.php24
-rw-r--r--app/Core/Filter/Lexer.php2
-rw-r--r--app/Core/Filter/LexerBuilder.php4
-rw-r--r--app/Core/Http/Request.php1
-rw-r--r--app/Core/Ldap/User.php8
-rw-r--r--app/Core/Mail/Transport/Smtp.php9
-rw-r--r--app/Core/Plugin/Hook.php17
-rw-r--r--app/Core/Plugin/Installer.php27
-rw-r--r--app/Core/Queue/JobHandler.php35
-rw-r--r--app/Core/Queue/QueueManager.php6
-rw-r--r--app/Core/Tool.php28
-rw-r--r--app/Core/User/UserSession.php46
18 files changed, 284 insertions, 106 deletions
diff --git a/app/Core/Action/ActionManager.php b/app/Core/Action/ActionManager.php
index 1dfd820c..aec9ef02 100644
--- a/app/Core/Action/ActionManager.php
+++ b/app/Core/Action/ActionManager.php
@@ -139,4 +139,20 @@ class ActionManager extends Base
return $this;
}
+
+ /**
+ * Remove all listeners for automated actions
+ *
+ * @access public
+ */
+ public function removeEvents()
+ {
+ foreach ($this->dispatcher->getListeners() as $eventName => $listeners) {
+ foreach ($listeners as $listener) {
+ if (is_array($listener) && $listener[0] instanceof ActionBase) {
+ $this->dispatcher->removeListener($eventName, $listener);
+ }
+ }
+ }
+ }
}
diff --git a/app/Core/Base.php b/app/Core/Base.php
index 7b4462e2..3b7c5e66 100644
--- a/app/Core/Base.php
+++ b/app/Core/Base.php
@@ -18,6 +18,7 @@ use Pimple\Container;
* @property \Kanboard\Core\Action\ActionManager $actionManager
* @property \Kanboard\Core\ExternalLink\ExternalLinkManager $externalLinkManager
* @property \Kanboard\Core\Cache\MemoryCache $memoryCache
+ * @property \Kanboard\Core\Cache\BaseCache $cacheDriver
* @property \Kanboard\Core\Event\EventManager $eventManager
* @property \Kanboard\Core\Group\GroupManager $groupManager
* @property \Kanboard\Core\Http\Client $httpClient
@@ -35,8 +36,12 @@ use Pimple\Container;
* @property \Kanboard\Core\Security\AuthenticationManager $authenticationManager
* @property \Kanboard\Core\Security\AccessMap $applicationAccessMap
* @property \Kanboard\Core\Security\AccessMap $projectAccessMap
+ * @property \Kanboard\Core\Security\AccessMap $apiAccessMap
+ * @property \Kanboard\Core\Security\AccessMap $apiProjectAccessMap
* @property \Kanboard\Core\Security\Authorization $applicationAuthorization
* @property \Kanboard\Core\Security\Authorization $projectAuthorization
+ * @property \Kanboard\Core\Security\Authorization $apiAuthorization
+ * @property \Kanboard\Core\Security\Authorization $apiProjectAuthorization
* @property \Kanboard\Core\Security\Role $role
* @property \Kanboard\Core\Security\Token $token
* @property \Kanboard\Core\Session\FlashMessage $flash
@@ -51,6 +56,7 @@ use Pimple\Container;
* @property \Kanboard\Core\Helper $helper
* @property \Kanboard\Core\Paginator $paginator
* @property \Kanboard\Core\Template $template
+ * @property \Kanboard\Decorator\MetadataCacheDecorator $userMetadataCacheDecorator
* @property \Kanboard\Model\ActionModel $actionModel
* @property \Kanboard\Model\ActionParameterModel $actionParameterModel
* @property \Kanboard\Model\AvatarFileModel $avatarFileModel
@@ -82,20 +88,31 @@ use Pimple\Container;
* @property \Kanboard\Model\ProjectGroupRoleModel $projectGroupRoleModel
* @property \Kanboard\Model\ProjectNotificationModel $projectNotificationModel
* @property \Kanboard\Model\ProjectNotificationTypeModel $projectNotificationTypeModel
+ * @property \Kanboard\Model\ProjectTaskDuplicationModel $projectTaskDuplicationModel
+ * @property \Kanboard\Model\ProjectTaskPriorityModel $projectTaskPriorityModel
* @property \Kanboard\Model\RememberMeSessionModel $rememberMeSessionModel
* @property \Kanboard\Model\SubtaskModel $subtaskModel
+ * @property \Kanboard\Model\SubtaskPositionModel $subtaskPositionModel
+ * @property \Kanboard\Model\SubtaskStatusModel $subtaskStatusModel
+ * @property \Kanboard\Model\SubtaskTaskConversionModel $subtaskTaskConversionModel
* @property \Kanboard\Model\SubtaskTimeTrackingModel $subtaskTimeTrackingModel
* @property \Kanboard\Model\SwimlaneModel $swimlaneModel
+ * @property \Kanboard\Model\TagDuplicationModel $tagDuplicationModel
+ * @property \Kanboard\Model\TagModel $tagModel
* @property \Kanboard\Model\TaskModel $taskModel
* @property \Kanboard\Model\TaskAnalyticModel $taskAnalyticModel
* @property \Kanboard\Model\TaskCreationModel $taskCreationModel
* @property \Kanboard\Model\TaskDuplicationModel $taskDuplicationModel
+ * @property \Kanboard\Model\TaskProjectDuplicationModel $taskProjectDuplicationModel
+ * @property \Kanboard\Model\TaskProjectMoveModel $taskProjectMoveModel
+ * @property \Kanboard\Model\TaskRecurrenceModel $taskRecurrenceModel
* @property \Kanboard\Model\TaskExternalLinkModel $taskExternalLinkModel
* @property \Kanboard\Model\TaskFinderModel $taskFinderModel
* @property \Kanboard\Model\TaskLinkModel $taskLinkModel
* @property \Kanboard\Model\TaskModificationModel $taskModificationModel
* @property \Kanboard\Model\TaskPositionModel $taskPositionModel
* @property \Kanboard\Model\TaskStatusModel $taskStatusModel
+ * @property \Kanboard\Model\TaskTagModel $taskTagModel
* @property \Kanboard\Model\TaskMetadataModel $taskMetadataModel
* @property \Kanboard\Model\TimezoneModel $timezoneModel
* @property \Kanboard\Model\TransitionModel $transitionModel
@@ -107,6 +124,10 @@ use Pimple\Container;
* @property \Kanboard\Model\UserNotificationFilterModel $userNotificationFilterModel
* @property \Kanboard\Model\UserUnreadNotificationModel $userUnreadNotificationModel
* @property \Kanboard\Model\UserMetadataModel $userMetadataModel
+ * @property \Kanboard\Pagination\TaskPagination $taskPagination
+ * @property \Kanboard\Pagination\SubtaskPagination $subtaskPagination
+ * @property \Kanboard\Pagination\ProjectPagination $projectPagination
+ * @property \Kanboard\Pagination\UserPagination $userPagination
* @property \Kanboard\Validator\ActionValidator $actionValidator
* @property \Kanboard\Validator\AuthValidator $authValidator
* @property \Kanboard\Validator\ColumnValidator $columnValidator
@@ -114,14 +135,15 @@ use Pimple\Container;
* @property \Kanboard\Validator\CommentValidator $commentValidator
* @property \Kanboard\Validator\CurrencyValidator $currencyValidator
* @property \Kanboard\Validator\CustomFilterValidator $customFilterValidator
+ * @property \Kanboard\Validator\ExternalLinkValidator $externalLinkValidator
* @property \Kanboard\Validator\GroupValidator $groupValidator
* @property \Kanboard\Validator\LinkValidator $linkValidator
* @property \Kanboard\Validator\PasswordResetValidator $passwordResetValidator
* @property \Kanboard\Validator\ProjectValidator $projectValidator
* @property \Kanboard\Validator\SubtaskValidator $subtaskValidator
* @property \Kanboard\Validator\SwimlaneValidator $swimlaneValidator
+ * @property \Kanboard\Validator\TagValidator $tagValidator
* @property \Kanboard\Validator\TaskLinkValidator $taskLinkValidator
- * @property \Kanboard\Validator\ExternalLinkValidator $externalLinkValidator
* @property \Kanboard\Validator\TaskValidator $taskValidator
* @property \Kanboard\Validator\UserValidator $userValidator
* @property \Kanboard\Import\TaskImport $taskImport
@@ -137,6 +159,14 @@ use Pimple\Container;
* @property \Kanboard\Core\Filter\QueryBuilder $taskQuery
* @property \Kanboard\Core\Filter\LexerBuilder $taskLexer
* @property \Kanboard\Core\Filter\LexerBuilder $projectActivityLexer
+ * @property \Kanboard\Job\CommentEventJob $commentEventJob
+ * @property \Kanboard\Job\SubtaskEventJob $subtaskEventJob
+ * @property \Kanboard\Job\TaskEventJob $taskEventJob
+ * @property \Kanboard\Job\TaskFileEventJob $taskFileEventJob
+ * @property \Kanboard\Job\TaskLinkEventJob $taskLinkEventJob
+ * @property \Kanboard\Job\ProjectFileEventJob $projectFileEventJob
+ * @property \Kanboard\Job\NotificationJob $notificationJob
+ * @property \Kanboard\Job\ProjectMetricJob $projectMetricJob
* @property \Psr\Log\LoggerInterface $logger
* @property \PicoDb\Database $db
* @property \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher
@@ -165,10 +195,10 @@ abstract class Base
}
/**
- * Load automatically models
+ * Load automatically dependencies
*
* @access public
- * @param string $name Model name
+ * @param string $name Class name
* @return mixed
*/
public function __get($name)
@@ -186,7 +216,6 @@ abstract class Base
*/
public static function getInstance(Container $container)
{
- $self = new static($container);
- return $self;
+ return new static($container);
}
}
diff --git a/app/Core/Cache/Base.php b/app/Core/Cache/BaseCache.php
index d62b8507..b51c4c0c 100644
--- a/app/Core/Cache/Base.php
+++ b/app/Core/Cache/BaseCache.php
@@ -3,12 +3,12 @@
namespace Kanboard\Core\Cache;
/**
- * Base class for cache drivers
+ * Base Class for Cache Drivers
*
- * @package cache
+ * @package Kanboard\Core\Cache
* @author Frederic Guillot
*/
-abstract class Base
+abstract class BaseCache implements CacheInterface
{
/**
* Proxy cache
diff --git a/app/Core/Cache/CacheInterface.php b/app/Core/Cache/CacheInterface.php
index d9e9747a..19bd6ef7 100644
--- a/app/Core/Cache/CacheInterface.php
+++ b/app/Core/Cache/CacheInterface.php
@@ -3,15 +3,15 @@
namespace Kanboard\Core\Cache;
/**
- * Cache Interface
+ * Interface CacheInterface
*
- * @package cache
- * @author Frederic Guillot
+ * @package Kanboard\Core\Cache
+ * @author Frederic Guillot
*/
interface CacheInterface
{
/**
- * Save a new value in the cache
+ * Store an item in the cache
*
* @access public
* @param string $key
@@ -20,7 +20,7 @@ interface CacheInterface
public function set($key, $value);
/**
- * Fetch value from cache
+ * Retrieve an item from the cache by key
*
* @access public
* @param string $key
@@ -29,14 +29,14 @@ interface CacheInterface
public function get($key);
/**
- * Clear all cache
+ * Remove all items from the cache
*
* @access public
*/
public function flush();
/**
- * Remove cached value
+ * Remove an item from the cache
*
* @access public
* @param string $key
diff --git a/app/Core/Cache/FileCache.php b/app/Core/Cache/FileCache.php
new file mode 100644
index 00000000..d477a1f3
--- /dev/null
+++ b/app/Core/Cache/FileCache.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace Kanboard\Core\Cache;
+
+use Kanboard\Core\Tool;
+use LogicException;
+
+/**
+ * Class FileCache
+ *
+ * @package Kanboard\Core\Cache
+ */
+class FileCache extends BaseCache
+{
+ /**
+ * Store an item in the cache
+ *
+ * @access public
+ * @param string $key
+ * @param string $value
+ */
+ public function set($key, $value)
+ {
+ $this->createCacheFolder();
+ file_put_contents($this->getFilenameFromKey($key), serialize($value));
+ }
+
+ /**
+ * Retrieve an item from the cache by key
+ *
+ * @access public
+ * @param string $key
+ * @return mixed Null when not found, cached value otherwise
+ */
+ public function get($key)
+ {
+ $filename = $this->getFilenameFromKey($key);
+
+ if (file_exists($filename)) {
+ return unserialize(file_get_contents($filename));
+ }
+
+ return null;
+ }
+
+ /**
+ * Remove all items from the cache
+ *
+ * @access public
+ */
+ public function flush()
+ {
+ $this->createCacheFolder();
+ Tool::removeAllFiles(CACHE_DIR, false);
+ }
+
+ /**
+ * Remove an item from the cache
+ *
+ * @access public
+ * @param string $key
+ */
+ public function remove($key)
+ {
+ $filename = $this->getFilenameFromKey($key);
+
+ if (file_exists($filename)) {
+ unlink($filename);
+ }
+ }
+
+ /**
+ * Get absolute filename from the key
+ *
+ * @access protected
+ * @param string $key
+ * @return string
+ */
+ protected function getFilenameFromKey($key)
+ {
+ return CACHE_DIR.DIRECTORY_SEPARATOR.$key;
+ }
+
+ /**
+ * Create cache folder if missing
+ *
+ * @access protected
+ * @throws LogicException
+ */
+ protected function createCacheFolder()
+ {
+ if (! is_dir(CACHE_DIR)) {
+ if (! mkdir(CACHE_DIR, 0755)) {
+ throw new LogicException('Unable to create cache directory: '.CACHE_DIR);
+ }
+ }
+ }
+}
diff --git a/app/Core/Cache/MemoryCache.php b/app/Core/Cache/MemoryCache.php
index 39e3947b..4fb94728 100644
--- a/app/Core/Cache/MemoryCache.php
+++ b/app/Core/Cache/MemoryCache.php
@@ -3,12 +3,12 @@
namespace Kanboard\Core\Cache;
/**
- * Memory Cache
+ * Memory Cache Driver
*
- * @package cache
+ * @package Kanboard\Core\Cache
* @author Frederic Guillot
*/
-class MemoryCache extends Base implements CacheInterface
+class MemoryCache extends BaseCache
{
/**
* Container
@@ -19,7 +19,7 @@ class MemoryCache extends Base implements CacheInterface
private $storage = array();
/**
- * Save a new value in the cache
+ * Store an item in the cache
*
* @access public
* @param string $key
@@ -31,7 +31,7 @@ class MemoryCache extends Base implements CacheInterface
}
/**
- * Fetch value from cache
+ * Retrieve an item from the cache by key
*
* @access public
* @param string $key
diff --git a/app/Core/ExternalLink/ExternalLinkManager.php b/app/Core/ExternalLink/ExternalLinkManager.php
index 804e6b34..5a037999 100644
--- a/app/Core/ExternalLink/ExternalLinkManager.php
+++ b/app/Core/ExternalLink/ExternalLinkManager.php
@@ -153,6 +153,30 @@ class ExternalLinkManager extends Base
}
/**
+ * Set provider type
+ *
+ * @access public
+ * @param string $userInputType
+ * @return ExternalLinkManager
+ */
+ public function setUserInputType($userInputType)
+ {
+ $this->userInputType = $userInputType;
+ return $this;
+ }
+
+ /**
+ * Set external link
+ * @param string $userInputText
+ * @return ExternalLinkManager
+ */
+ public function setUserInputText($userInputText)
+ {
+ $this->userInputText = $userInputText;
+ return $this;
+ }
+
+ /**
* Find a provider that user input
*
* @access private
diff --git a/app/Core/Filter/Lexer.php b/app/Core/Filter/Lexer.php
index fa5b8d2d..3ff57641 100644
--- a/app/Core/Filter/Lexer.php
+++ b/app/Core/Filter/Lexer.php
@@ -30,7 +30,7 @@ class Lexer
'/^([<=>]{1,2}\w+)/u' => 'T_STRING',
'/^([<=>]{1,2}".+")/' => 'T_STRING',
'/^("(.+)")/' => 'T_STRING',
- '/^(\w+)/u' => 'T_STRING',
+ '/^(\S+)/u' => 'T_STRING',
'/^(#\d+)/' => 'T_STRING',
);
diff --git a/app/Core/Filter/LexerBuilder.php b/app/Core/Filter/LexerBuilder.php
index 7a9a714f..e3ab725b 100644
--- a/app/Core/Filter/LexerBuilder.php
+++ b/app/Core/Filter/LexerBuilder.php
@@ -51,7 +51,7 @@ class LexerBuilder
*/
public function __construct()
{
- $this->lexer = new Lexer;
+ $this->lexer = new Lexer();
$this->queryBuilder = new QueryBuilder();
}
@@ -69,7 +69,7 @@ class LexerBuilder
foreach ($attributes as $attribute) {
$this->filters[$attribute] = $filter;
- $this->lexer->addToken(sprintf("/^(%s:)/", $attribute), $attribute);
+ $this->lexer->addToken(sprintf("/^(%s:)/i", $attribute), $attribute);
if ($default) {
$this->lexer->setDefaultToken($attribute);
diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php
index e0df2d3c..2e84958d 100644
--- a/app/Core/Http/Request.php
+++ b/app/Core/Http/Request.php
@@ -301,6 +301,7 @@ class Request extends Base
public function getIpAddress()
{
$keys = array(
+ 'HTTP_X_REAL_IP',
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
diff --git a/app/Core/Ldap/User.php b/app/Core/Ldap/User.php
index 91b48530..4bc1f5f9 100644
--- a/app/Core/Ldap/User.php
+++ b/app/Core/Ldap/User.php
@@ -116,7 +116,7 @@ class User
*/
protected function getRole(array $groupIds)
{
- if ($this->hasGroupsNotConfigured()) {
+ if (! $this->hasGroupsConfigured()) {
return null;
}
@@ -278,14 +278,14 @@ class User
}
/**
- * Return true if LDAP Group mapping is not configured
+ * Return true if LDAP Group mapping are configured
*
* @access public
* @return boolean
*/
- public function hasGroupsNotConfigured()
+ public function hasGroupsConfigured()
{
- return !$this->getGroupAdminDn() && !$this->getGroupManagerDn();
+ return $this->getGroupAdminDn() || $this->getGroupManagerDn();
}
/**
diff --git a/app/Core/Mail/Transport/Smtp.php b/app/Core/Mail/Transport/Smtp.php
index 66f0a3aa..1f4e54ce 100644
--- a/app/Core/Mail/Transport/Smtp.php
+++ b/app/Core/Mail/Transport/Smtp.php
@@ -24,6 +24,15 @@ class Smtp extends Mail
$transport->setUsername(MAIL_SMTP_USERNAME);
$transport->setPassword(MAIL_SMTP_PASSWORD);
$transport->setEncryption(MAIL_SMTP_ENCRYPTION);
+ if (HTTP_VERIFY_SSL_CERTIFICATE === false) {
+ $transport->setStreamOptions(array(
+ 'ssl' => array(
+ 'allow_self_signed' => true,
+ 'verify_peer' => false,
+ 'verify_peer_name' => false,
+ )
+ ));
+ }
return $transport;
}
diff --git a/app/Core/Plugin/Hook.php b/app/Core/Plugin/Hook.php
index ade69150..ca197937 100644
--- a/app/Core/Plugin/Hook.php
+++ b/app/Core/Plugin/Hook.php
@@ -96,4 +96,21 @@ class Hook
return null;
}
+
+ /**
+ * Hook with reference
+ *
+ * @access public
+ * @param string $hook
+ * @param mixed $param
+ * @return mixed
+ */
+ public function reference($hook, &$param)
+ {
+ foreach ($this->getListeners($hook) as $listener) {
+ $listener($param);
+ }
+
+ return $param;
+ }
}
diff --git a/app/Core/Plugin/Installer.php b/app/Core/Plugin/Installer.php
index 48c4d978..b3618aeb 100644
--- a/app/Core/Plugin/Installer.php
+++ b/app/Core/Plugin/Installer.php
@@ -2,9 +2,8 @@
namespace Kanboard\Core\Plugin;
-use RecursiveDirectoryIterator;
-use RecursiveIteratorIterator;
use ZipArchive;
+use Kanboard\Core\Tool;
/**
* Class Installer
@@ -64,7 +63,7 @@ class Installer extends \Kanboard\Core\Base
throw new PluginInstallerException(e('You don\'t have the permission to remove this plugin.'));
}
- $this->removeAllDirectories($pluginFolder);
+ Tool::removeAllFiles($pluginFolder);
}
/**
@@ -137,26 +136,4 @@ class Installer extends \Kanboard\Core\Base
unlink($zip->filename);
$zip->close();
}
-
- /**
- * Remove recursively a directory
- *
- * @access protected
- * @param string $directory
- */
- protected function removeAllDirectories($directory)
- {
- $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
- $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
-
- foreach ($files as $file) {
- if ($file->isDir()) {
- rmdir($file->getRealPath());
- } else {
- unlink($file->getRealPath());
- }
- }
-
- rmdir($directory);
- }
}
diff --git a/app/Core/Queue/JobHandler.php b/app/Core/Queue/JobHandler.php
index f8736cce..11c1fb69 100644
--- a/app/Core/Queue/JobHandler.php
+++ b/app/Core/Queue/JobHandler.php
@@ -2,6 +2,7 @@
namespace Kanboard\Core\Queue;
+use Exception;
use Kanboard\Core\Base;
use Kanboard\Job\BaseJob;
use SimpleQueue\Job;
@@ -39,15 +40,23 @@ class JobHandler extends Base
public function executeJob(Job $job)
{
$payload = $job->getBody();
- $className = $payload['class'];
- $this->prepareJobSession($payload['user_id']);
- if (DEBUG) {
- $this->logger->debug(__METHOD__.' Received job => '.$className.' ('.getmypid().')');
- }
+ try {
+ $className = $payload['class'];
+ $this->prepareJobSession($payload['user_id']);
+ $this->prepareJobEnvironment();
+
+ if (DEBUG) {
+ $this->logger->debug(__METHOD__.' Received job => '.$className.' ('.getmypid().')');
+ $this->logger->debug(__METHOD__.' => '.json_encode($payload));
+ }
- $worker = new $className($this->container);
- call_user_func_array(array($worker, 'execute'), $payload['params']);
+ $worker = new $className($this->container);
+ call_user_func_array(array($worker, 'execute'), $payload['params']);
+ } catch (Exception $e) {
+ $this->logger->error(__METHOD__.': Error during job execution: '.$e->getMessage());
+ $this->logger->error(__METHOD__ .' => '.json_encode($payload));
+ }
}
/**
@@ -66,4 +75,16 @@ class JobHandler extends Base
$this->userSession->initialize($user);
}
}
+
+ /**
+ * Flush in-memory caching and specific events
+ *
+ * @access protected
+ */
+ protected function prepareJobEnvironment()
+ {
+ $this->memoryCache->flush();
+ $this->actionManager->removeEvents();
+ $this->dispatcher->dispatch('app.bootstrap');
+ }
}
diff --git a/app/Core/Queue/QueueManager.php b/app/Core/Queue/QueueManager.php
index f34cb220..dcf0ebf5 100644
--- a/app/Core/Queue/QueueManager.php
+++ b/app/Core/Queue/QueueManager.php
@@ -42,9 +42,13 @@ class QueueManager extends Base
*/
public function push(BaseJob $job)
{
+ $jobClassName = get_class($job);
+
if ($this->queue !== null) {
+ $this->logger->debug(__METHOD__.': Job pushed in queue: '.$jobClassName);
$this->queue->push(JobHandler::getInstance($this->container)->serializeJob($job));
} else {
+ $this->logger->debug(__METHOD__.': Job executed synchronously: '.$jobClassName);
call_user_func_array(array($job, 'execute'), $job->getJobParams());
}
@@ -60,7 +64,7 @@ class QueueManager extends Base
public function listen()
{
if ($this->queue === null) {
- throw new LogicException('No Queue Driver defined!');
+ throw new LogicException('No queue driver defined!');
}
while ($job = $this->queue->pull()) {
diff --git a/app/Core/Tool.php b/app/Core/Tool.php
index bfa6c955..9b8820eb 100644
--- a/app/Core/Tool.php
+++ b/app/Core/Tool.php
@@ -3,6 +3,8 @@
namespace Kanboard\Core;
use Pimple\Container;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
/**
* Tool class
@@ -13,6 +15,32 @@ use Pimple\Container;
class Tool
{
/**
+ * Remove recursively a directory
+ *
+ * @static
+ * @access public
+ * @param string $directory
+ * @param bool $removeDirectory
+ */
+ public static function removeAllFiles($directory, $removeDirectory = true)
+ {
+ $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
+ $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
+
+ foreach ($files as $file) {
+ if ($file->isDir()) {
+ rmdir($file->getRealPath());
+ } else {
+ unlink($file->getRealPath());
+ }
+ }
+
+ if ($removeDirectory) {
+ rmdir($directory);
+ }
+ }
+
+ /**
* Build dependency injection container from an array
*
* @static
diff --git a/app/Core/User/UserSession.php b/app/Core/User/UserSession.php
index 9c63f07a..7917b223 100644
--- a/app/Core/User/UserSession.php
+++ b/app/Core/User/UserSession.php
@@ -179,50 +179,4 @@ class UserSession extends Base
{
$this->sessionStorage->filters[$project_id] = $filters;
}
-
- /**
- * Is board collapsed or expanded
- *
- * @access public
- * @param integer $project_id
- * @return boolean
- */
- public function isBoardCollapsed($project_id)
- {
- return ! empty($this->sessionStorage->boardCollapsed[$project_id]) ? $this->sessionStorage->boardCollapsed[$project_id] : false;
- }
-
- /**
- * Set board display mode
- *
- * @access public
- * @param integer $project_id
- * @param boolean $is_collapsed
- */
- public function setBoardDisplayMode($project_id, $is_collapsed)
- {
- $this->sessionStorage->boardCollapsed[$project_id] = $is_collapsed;
- }
-
- /**
- * Set comments sorting
- *
- * @access public
- * @param string $order
- */
- public function setCommentSorting($order)
- {
- $this->sessionStorage->commentSorting = $order;
- }
-
- /**
- * Get comments sorting direction
- *
- * @access public
- * @return string
- */
- public function getCommentSorting()
- {
- return empty($this->sessionStorage->commentSorting) ? 'ASC' : $this->sessionStorage->commentSorting;
- }
}