diff options
147 files changed, 476 insertions, 783 deletions
diff --git a/app/Action/TaskEmail.php b/app/Action/TaskEmail.php index 355a49d8..7fb76c4c 100644 --- a/app/Action/TaskEmail.php +++ b/app/Action/TaskEmail.php @@ -67,7 +67,6 @@ class TaskEmail extends Base $user = $this->user->getById($this->getParam('user_id')); if (! empty($user['email'])) { - $task = $this->taskFinder->getDetails($data['task_id']); $this->emailClient->send( diff --git a/app/Api/Action.php b/app/Api/Action.php index eab20a6c..0ae91f10 100644 --- a/app/Api/Action.php +++ b/app/Api/Action.php @@ -35,10 +35,9 @@ class Action extends \Kanboard\Core\Base $actions = $this->action->getAllByProject($project_id); foreach ($actions as $index => $action) { - $params = array(); - foreach($action['params'] as $param) { + foreach ($action['params'] as $param) { $params[$param['name']] = $param['value']; } @@ -57,7 +56,7 @@ class Action extends \Kanboard\Core\Base 'params' => $params, ); - list($valid,) = $this->action->validateCreation($values); + list($valid, ) = $this->action->validateCreation($values); if (! $valid) { return false; @@ -80,14 +79,14 @@ class Action extends \Kanboard\Core\Base $required_params = $action->getActionRequiredParameters(); // Check missing parameters - foreach($required_params as $param => $value) { + foreach ($required_params as $param => $value) { if (! isset($params[$param])) { return false; } } // Check extra parameters - foreach($params as $param => $value) { + foreach ($params as $param => $value) { if (! isset($required_params[$param])) { return false; } diff --git a/app/Api/Auth.php b/app/Api/Auth.php index b741694b..b3627e4b 100644 --- a/app/Api/Auth.php +++ b/app/Api/Auth.php @@ -29,11 +29,9 @@ class Auth extends Base if ($username !== 'jsonrpc' && ! $this->authentication->hasCaptcha($username) && $this->authentication->authenticate($username, $password)) { $this->checkProcedurePermission(true, $method); $this->userSession->refresh($this->user->getByUsername($username)); - } - else if ($username === 'jsonrpc' && $password === $this->config->get('api_token')) { + } elseif ($username === 'jsonrpc' && $password === $this->config->get('api_token')) { $this->checkProcedurePermission(false, $method); - } - else { + } else { throw new AuthenticationFailure('Wrong credentials'); } } diff --git a/app/Api/Base.php b/app/Api/Base.php index 152ceeab..82397b20 100644 --- a/app/Api/Base.php +++ b/app/Api/Base.php @@ -50,8 +50,7 @@ abstract class Base extends \Kanboard\Core\Base if ($is_user && ! $is_both_procedure && ! $is_user_procedure) { throw new AccessDeniedException('Permission denied'); - } - else if (! $is_user && ! $is_both_procedure && $is_user_procedure) { + } elseif (! $is_user && ! $is_both_procedure && $is_user_procedure) { throw new AccessDeniedException('Permission denied'); } diff --git a/app/Api/Category.php b/app/Api/Category.php index 3e5b3a34..458eaef6 100644 --- a/app/Api/Category.php +++ b/app/Api/Category.php @@ -32,7 +32,7 @@ class Category extends \Kanboard\Core\Base 'name' => $name, ); - list($valid,) = $this->category->validateCreation($values); + list($valid, ) = $this->category->validateCreation($values); return $valid ? $this->category->create($values) : false; } @@ -43,7 +43,7 @@ class Category extends \Kanboard\Core\Base 'name' => $name, ); - list($valid,) = $this->category->validateModification($values); + list($valid, ) = $this->category->validateModification($values); return $valid && $this->category->update($values); } } diff --git a/app/Api/Comment.php b/app/Api/Comment.php index a13c36d4..26b632e9 100644 --- a/app/Api/Comment.php +++ b/app/Api/Comment.php @@ -33,7 +33,7 @@ class Comment extends \Kanboard\Core\Base 'comment' => $content, ); - list($valid,) = $this->comment->validateCreation($values); + list($valid, ) = $this->comment->validateCreation($values); return $valid ? $this->comment->create($values) : false; } @@ -45,7 +45,7 @@ class Comment extends \Kanboard\Core\Base 'comment' => $content, ); - list($valid,) = $this->comment->validateModification($values); + list($valid, ) = $this->comment->validateModification($values); return $valid && $this->comment->update($values); } } diff --git a/app/Api/File.php b/app/Api/File.php index 760ee5ed..be415ecb 100644 --- a/app/Api/File.php +++ b/app/Api/File.php @@ -25,14 +25,12 @@ class File extends \Kanboard\Core\Base public function downloadFile($file_id) { try { - $file = $this->file->getById($file_id); if (! empty($file)) { return base64_encode($this->objectStorage->get($file['path'])); } - } - catch (ObjectStorageException $e) { + } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); } diff --git a/app/Api/Link.php b/app/Api/Link.php index 049fcddb..d4df18fe 100644 --- a/app/Api/Link.php +++ b/app/Api/Link.php @@ -72,7 +72,7 @@ class Link extends \Kanboard\Core\Base '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; } @@ -93,7 +93,7 @@ class Link extends \Kanboard\Core\Base 'label' => $label, ); - list($valid,) = $this->link->validateModification($values); + list($valid, ) = $this->link->validateModification($values); return $valid && $this->link->update($values); } diff --git a/app/Api/Me.php b/app/Api/Me.php index f4857b58..16ce0aee 100644 --- a/app/Api/Me.php +++ b/app/Api/Me.php @@ -45,7 +45,7 @@ class Me extends Base '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; } diff --git a/app/Api/Project.php b/app/Api/Project.php index 4c491ced..f934432d 100644 --- a/app/Api/Project.php +++ b/app/Api/Project.php @@ -69,7 +69,7 @@ class Project extends Base 'description' => $description ); - list($valid,) = $this->project->validateCreation($values); + list($valid, ) = $this->project->validateCreation($values); return $valid ? $this->project->create($values) : false; } @@ -81,7 +81,7 @@ class Project extends Base 'description' => $description ); - list($valid,) = $this->project->validateModification($values); + list($valid, ) = $this->project->validateModification($values); return $valid && $this->project->update($values); } } diff --git a/app/Api/Subtask.php b/app/Api/Subtask.php index 7b526023..7baee3d3 100644 --- a/app/Api/Subtask.php +++ b/app/Api/Subtask.php @@ -36,7 +36,7 @@ class Subtask extends \Kanboard\Core\Base 'status' => $status, ); - list($valid,) = $this->subtask->validateCreation($values); + list($valid, ) = $this->subtask->validateCreation($values); return $valid ? $this->subtask->create($values) : false; } @@ -58,7 +58,7 @@ class Subtask extends \Kanboard\Core\Base } } - list($valid,) = $this->subtask->validateApiModification($values); + list($valid, ) = $this->subtask->validateApiModification($values); return $valid && $this->subtask->update($values); } } diff --git a/app/Api/Task.php b/app/Api/Task.php index 8911c2f1..0dceb209 100644 --- a/app/Api/Task.php +++ b/app/Api/Task.php @@ -91,7 +91,7 @@ class Task extends Base 'reference' => $reference, ); - list($valid,) = $this->taskValidator->validateCreation($values); + list($valid, ) = $this->taskValidator->validateCreation($values); return $valid ? $this->taskCreation->create($values) : false; } diff --git a/app/Api/User.php b/app/Api/User.php index 00d35796..105723d3 100644 --- a/app/Api/User.php +++ b/app/Api/User.php @@ -39,7 +39,7 @@ class User extends \Kanboard\Core\Base '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; } @@ -81,7 +81,7 @@ class User extends \Kanboard\Core\Base } } - list($valid,) = $this->user->validateApiModification($values); + list($valid, ) = $this->user->validateApiModification($values); return $valid && $this->user->update($values); } } diff --git a/app/Auth/Ldap.php b/app/Auth/Ldap.php index 78820d2e..687762d3 100644 --- a/app/Auth/Ldap.php +++ b/app/Auth/Ldap.php @@ -217,7 +217,6 @@ class Ldap extends Base $result = $this->findUser($username, $password); if (is_array($result)) { - $user = $this->user->getByUsername($username); if (! empty($user)) { @@ -226,14 +225,12 @@ class Ldap extends Base if ($user['is_ldap_user'] == 0) { return false; } - } - else { + } else { // We create automatically a new user if ($this->isLdapAccountCreationEnabled() && $this->user->create($result) !== false) { $user = $this->user->getByUsername($username); - } - else { + } else { return false; } } @@ -319,12 +316,10 @@ class Ldap extends Base if ($this->getLdapBindType() === 'user') { $ldap_username = sprintf($this->getLdapUsername(), $username); $ldap_password = $password; - } - else if ($this->getLdapBindType() === 'proxy') { + } elseif ($this->getLdapBindType() === 'proxy') { $ldap_username = $this->getLdapUsername(); $ldap_password = $this->getLdapPassword(); - } - else { + } else { $ldap_username = null; $ldap_password = null; } @@ -486,11 +481,9 @@ class Ldap extends Base { if (! empty($username) && ! empty($email)) { return '(&('.$this->getLdapUserPattern($username).')('.$this->getLdapAccountEmail().'='.$email.'))'; - } - else if (! empty($username)) { + } elseif (! empty($username)) { return $this->getLdapUserPattern($username); - } - else if (! empty($email)) { + } elseif (! empty($email)) { return '('.$this->getLdapAccountEmail().'='.$email.')'; } @@ -508,7 +501,7 @@ class Ldap extends Base */ private function getEntry(array $entries, $key, $default = '') { - return isset($entries[0][$key][0]) ? $entries[0][$key][0] : $default; + return isset($entries[0][$key][0]) ? $entries[0][$key][0] : $default; } /** @@ -522,6 +515,6 @@ class Ldap extends Base */ private function getEntries(array $entries, $key, $default = array()) { - return isset($entries[0][$key]) ? $entries[0][$key] : $default; + return isset($entries[0][$key]) ? $entries[0][$key] : $default; } } diff --git a/app/Auth/RememberMe.php b/app/Auth/RememberMe.php index 6569463d..bba2bda6 100644 --- a/app/Auth/RememberMe.php +++ b/app/Auth/RememberMe.php @@ -88,7 +88,6 @@ class RememberMe extends Base $credentials = $this->readCookie(); if ($credentials !== false) { - $record = $this->find($credentials['token'], $credentials['sequence']); if ($record) { @@ -144,7 +143,6 @@ class RememberMe extends Base $credentials = $this->readCookie(); if ($credentials !== false) { - $this->deleteCookie(); $this->db diff --git a/app/Console/LocaleComparator.php b/app/Console/LocaleComparator.php index fcc3a995..8e5e0904 100644 --- a/app/Console/LocaleComparator.php +++ b/app/Console/LocaleComparator.php @@ -25,7 +25,6 @@ class LocaleComparator extends Base $it->rewind(); while ($it->valid()) { - if (! $it->isDot() && substr($it->key(), -4) === '.php') { $strings = array_merge($strings, $this->search($it->key())); } @@ -72,7 +71,7 @@ class LocaleComparator extends Base $strings = array_merge($strings, $matches[1]); } - array_walk($strings, function(&$value) { + array_walk($strings, function (&$value) { $value = trim($value, "'"); $value = str_replace("\'", "'", $value); }); diff --git a/app/Console/LocaleSync.php b/app/Console/LocaleSync.php index bc3918da..d62b40b5 100644 --- a/app/Console/LocaleSync.php +++ b/app/Console/LocaleSync.php @@ -23,9 +23,7 @@ class LocaleSync extends Base $reference = include $reference_file; foreach (new DirectoryIterator('app/Locale') as $fileInfo) { - if (! $fileInfo->isDot() && $fileInfo->isDir() && $fileInfo->getFilename() !== self::REF_LOCALE) { - $filename = 'app/Locale/'.$fileInfo->getFilename().'/translations.php'; echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL; @@ -42,11 +40,9 @@ class LocaleSync extends Base $output .= 'return array('.PHP_EOL; foreach ($reference as $key => $value) { - if (! empty($outdated[$key])) { $output .= " '".str_replace("'", "\'", $key)."' => '".str_replace("'", "\'", $outdated[$key])."',\n"; - } - else { + } else { $output .= " // '".str_replace("'", "\'", $key)."' => '',\n"; } } diff --git a/app/Controller/Action.php b/app/Controller/Action.php index 8e31fb30..37d1c248 100644 --- a/app/Controller/Action.php +++ b/app/Controller/Action.php @@ -115,14 +115,12 @@ class Action extends Base */ private function doCreation(array $project, array $values) { - list($valid,) = $this->action->validateCreation($values); + list($valid, ) = $this->action->validateCreation($values); if ($valid) { - if ($this->action->create($values) !== false) { $this->session->flash(t('Your automatic action have been created successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to create your automatic action.')); } } diff --git a/app/Controller/App.php b/app/Controller/App.php index 3f3f0176..01a74c7a 100644 --- a/app/Controller/App.php +++ b/app/Controller/App.php @@ -236,8 +236,7 @@ class App extends Base // Search by task id or by title if (ctype_digit($search)) { $filter->filterById($search); - } - else { + } else { $filter->filterByTitle($search); } diff --git a/app/Controller/Auth.php b/app/Controller/Auth.php index b40811f4..95ad8d9e 100644 --- a/app/Controller/Auth.php +++ b/app/Controller/Auth.php @@ -43,7 +43,6 @@ class Auth extends Base list($valid, $errors) = $this->authentication->validateForm($values); if ($valid) { - if (! empty($this->session['login_redirect']) && ! filter_var($this->session['login_redirect'], FILTER_VALIDATE_URL)) { $redirect = $this->session['login_redirect']; unset($this->session['login_redirect']); diff --git a/app/Controller/Base.php b/app/Controller/Base.php index 8883a676..1efd4566 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -60,7 +60,6 @@ abstract class Base extends \Kanboard\Core\Base public function __destruct() { if (DEBUG) { - foreach ($this->container['db']->getLogMessages() as $message) { $this->container['logger']->debug($message); } @@ -123,7 +122,6 @@ abstract class Base extends \Kanboard\Core\Base public function handleAuthentication() { if (! $this->authentication->isAuthenticated()) { - if ($this->request->isAjax()) { $this->response->text('Not Authorized', 401); } @@ -143,7 +141,6 @@ abstract class Base extends \Kanboard\Core\Base $ignore = ($controller === 'twofactor' && in_array($action, array('code', 'check'))) || ($controller === 'auth' && $action === 'logout'); if ($ignore === false && $this->userSession->has2FA() && ! $this->userSession->check2FA()) { - if ($this->request->isAjax()) { $this->response->text('Not Authorized', 401); } diff --git a/app/Controller/Board.php b/app/Controller/Board.php index 06c9a2ff..2d75db89 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -239,12 +239,11 @@ class Board extends Base { $values = $this->request->getValues(); - list($valid,) = $this->taskValidator->validateAssigneeModification($values); + list($valid, ) = $this->taskValidator->validateAssigneeModification($values); if ($valid && $this->taskModification->update($values)) { $this->session->flash(t('Task updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update your task.')); } @@ -277,12 +276,11 @@ class Board extends Base { $values = $this->request->getValues(); - list($valid,) = $this->taskValidator->validateCategoryModification($values); + list($valid, ) = $this->taskValidator->validateCategoryModification($values); if ($valid && $this->taskModification->update($values)) { $this->session->flash(t('Task updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update your task.')); } @@ -365,8 +363,7 @@ class Board extends Base if ($this->request->isAjax()) { $this->response->html($this->renderBoard($project_id)); - } - else { + } else { $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id))); } } diff --git a/app/Controller/Calendar.php b/app/Controller/Calendar.php index 131d87aa..67a402d3 100644 --- a/app/Controller/Calendar.php +++ b/app/Controller/Calendar.php @@ -44,8 +44,7 @@ class Calendar extends Base // Tasks if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') { $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(); } @@ -79,8 +78,7 @@ class Calendar extends Base // Tasks 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()); - } - else { + } else { $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() { if ($this->request->isAjax() && $this->request->isPost()) { - $values = $this->request->getJson(); $this->taskModification->update(array( diff --git a/app/Controller/Category.php b/app/Controller/Category.php index 065da80b..4aefd9fe 100644 --- a/app/Controller/Category.php +++ b/app/Controller/Category.php @@ -60,12 +60,10 @@ class Category extends Base list($valid, $errors) = $this->category->validateCreation($values); if ($valid) { - if ($this->category->create($values)) { $this->session->flash(t('Your category have been created successfully.')); $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.')); } } @@ -104,12 +102,10 @@ class Category extends Base list($valid, $errors) = $this->category->validateModification($values); if ($valid) { - if ($this->category->update($values)) { $this->session->flash(t('Your category have been updated successfully.')); $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.')); } } diff --git a/app/Controller/Column.php b/app/Controller/Column.php index a07a1fe1..d28fb293 100644 --- a/app/Controller/Column.php +++ b/app/Controller/Column.php @@ -54,12 +54,10 @@ class Column extends Base list($valid, $errors) = $this->board->validateCreation($data); if ($valid) { - if ($this->board->addColumn($project['id'], $data['title'], $data['task_limit'], $data['description'])) { $this->session->flash(t('Board updated successfully.')); $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.')); } } @@ -99,12 +97,10 @@ class Column extends Base list($valid, $errors) = $this->board->validateModification($values); if ($valid) { - if ($this->board->updateColumn($values['id'], $values['title'], $values['task_limit'], $values['description'])) { $this->session->flash(t('Board updated successfully.')); $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.')); } } @@ -160,8 +156,7 @@ class Column extends Base if (! empty($column) && $this->board->removeColumn($column['id'])) { $this->session->flash(t('Column removed successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to remove this column.')); } diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php index 90d9d6df..d6cbbf1e 100644 --- a/app/Controller/Comment.php +++ b/app/Controller/Comment.php @@ -81,11 +81,9 @@ class Comment extends Base list($valid, $errors) = $this->comment->validateCreation($values); if ($valid) { - if ($this->comment->create($values)) { $this->session->flash(t('Comment added successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to create your comment.')); } @@ -132,11 +130,9 @@ class Comment extends Base list($valid, $errors) = $this->comment->validateModification($values); if ($valid) { - if ($this->comment->update($values)) { $this->session->flash(t('Comment updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update your comment.')); } @@ -176,8 +172,7 @@ class Comment extends Base if ($this->comment->remove($comment['id'])) { $this->session->flash(t('Comment removed successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to remove this comment.')); } diff --git a/app/Controller/Config.php b/app/Controller/Config.php index ba3c690a..9a376b36 100644 --- a/app/Controller/Config.php +++ b/app/Controller/Config.php @@ -37,7 +37,6 @@ class Config extends Base private function common($redirect) { if ($this->request->isPost()) { - $values = $this->request->getValues(); switch ($redirect) { @@ -55,8 +54,7 @@ class Config extends Base if ($this->config->save($values)) { $this->config->reload(); $this->session->flash(t('Settings saved successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to save your settings.')); } diff --git a/app/Controller/Currency.php b/app/Controller/Currency.php index d3f9de5f..9d6b0249 100644 --- a/app/Controller/Currency.php +++ b/app/Controller/Currency.php @@ -54,12 +54,10 @@ class Currency extends Base list($valid, $errors) = $this->currency->validate($values); if ($valid) { - if ($this->currency->create($values['currency'], $values['rate'])) { $this->session->flash(t('The currency rate have been added successfully.')); $this->response->redirect($this->helper->url->to('currency', 'index')); - } - else { + } else { $this->session->flashError(t('Unable to add this currency rate.')); } } @@ -79,8 +77,7 @@ class Currency extends Base if ($this->config->save($values)) { $this->config->reload(); $this->session->flash(t('Settings saved successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to save your settings.')); } diff --git a/app/Controller/Customfilter.php b/app/Controller/Customfilter.php index 26e6cc87..a152c668 100644 --- a/app/Controller/Customfilter.php +++ b/app/Controller/Customfilter.php @@ -46,8 +46,7 @@ class Customfilter extends Base if ($this->customFilter->create($values)) { $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']))); - } - else { + } else { $this->session->flashError(t('Unable to create your custom filter.')); } } @@ -126,8 +125,7 @@ class Customfilter extends Base if ($this->customFilter->update($values)) { $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']))); - } - else { + } else { $this->session->flashError(t('Unable to update custom filter.')); } } diff --git a/app/Controller/Doc.php b/app/Controller/Doc.php index 282f5d15..32413048 100644 --- a/app/Controller/Doc.php +++ b/app/Controller/Doc.php @@ -16,7 +16,7 @@ class Doc extends Base { $url = $this->helper->url; $data = file_get_contents($filename); - list($title,) = explode("\n", $data, 2); + list($title, ) = explode("\n", $data, 2); $replaceUrl = function (array $matches) use ($url) { return '('.$url->to('doc', 'show', array('file' => str_replace('.markdown', '', $matches[1]))).')'; diff --git a/app/Controller/File.php b/app/Controller/File.php index 673e2669..3aadf076 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -22,7 +22,6 @@ class File extends Base $task = $this->getTask(); if ($this->request->isPost() && $this->file->uploadScreenshot($task['project_id'], $task['id'], $this->request->getValue('screenshot')) !== false) { - $this->session->flash(t('Screenshot uploaded successfully.')); if ($this->request->getStringParam('redirect') === 'board') { @@ -77,7 +76,6 @@ class File extends Base public function download() { try { - $task = $this->getTask(); $file = $this->file->getById($this->request->getIntegerParam('file_id')); @@ -87,8 +85,7 @@ class File extends Base $this->response->forceDownload($file['name']); $this->objectStorage->output($file['path']); - } - catch (ObjectStorageException $e) { + } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); } } @@ -119,7 +116,6 @@ class File extends Base public function image() { try { - $task = $this->getTask(); $file = $this->file->getById($this->request->getIntegerParam('file_id')); @@ -129,8 +125,7 @@ class File extends Base $this->response->contentType($this->file->getImageMimeType($file['name'])); $this->objectStorage->output($file['path']); - } - catch (ObjectStorageException $e) { + } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); } } @@ -143,7 +138,6 @@ class File extends Base public function thumbnail() { try { - $task = $this->getTask(); $file = $this->file->getById($this->request->getIntegerParam('file_id')); @@ -153,8 +147,7 @@ class File extends Base $this->response->contentType('image/jpeg'); $this->objectStorage->output($this->file->getThumbnailPath($file['path'])); - } - catch (ObjectStorageException $e) { + } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); } } diff --git a/app/Controller/Gantt.php b/app/Controller/Gantt.php index dd02626f..24d94f02 100644 --- a/app/Controller/Gantt.php +++ b/app/Controller/Gantt.php @@ -19,8 +19,7 @@ class Gantt extends Base { if ($this->userSession->isAdmin()) { $project_ids = $this->project->getAllIds(); - } - else { + } else { $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId()); } @@ -62,8 +61,7 @@ class Gantt extends Base if ($sorting === 'date') { $filter->getQuery()->asc(TaskModel::TABLE.'.date_started')->asc(TaskModel::TABLE.'.date_creation'); - } - else { + } else { $filter->getQuery()->asc('column_position')->asc(TaskModel::TABLE.'.position'); } @@ -134,14 +132,12 @@ class Gantt extends Base list($valid, $errors) = $this->taskValidator->validateCreation($values); if ($valid) { - $task_id = $this->taskCreation->create($values); if ($task_id !== false) { $this->session->flash(t('Task created successfully.')); $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.')); } } diff --git a/app/Controller/Ical.php b/app/Controller/Ical.php index ee2b1518..f8e9e25f 100644 --- a/app/Controller/Ical.php +++ b/app/Controller/Ical.php @@ -89,8 +89,7 @@ class Ical extends Base ->setColumns('date_creation', 'date_completed') ->setCalendar($calendar) ->addDateTimeEvents(); - } - else { + } else { $filter ->copy() ->filterByStartDateRange($start, $end) diff --git a/app/Controller/Link.php b/app/Controller/Link.php index 73cd95f9..0eb3d679 100644 --- a/app/Controller/Link.php +++ b/app/Controller/Link.php @@ -70,12 +70,10 @@ class Link extends Base list($valid, $errors) = $this->link->validateCreation($values); if ($valid) { - if ($this->link->create($values['label'], $values['opposite_label']) !== false) { $this->session->flash(t('Link added successfully.')); $this->response->redirect($this->helper->url->to('link', 'index')); - } - else { + } else { $this->session->flashError(t('Unable to create your link.')); } } @@ -116,8 +114,7 @@ class Link extends Base if ($this->link->update($values)) { $this->session->flash(t('Link updated successfully.')); $this->response->redirect($this->helper->url->to('link', 'index')); - } - else { + } else { $this->session->flashError(t('Unable to update your link.')); } } @@ -152,8 +149,7 @@ class Link extends Base if ($this->link->remove($link['id'])) { $this->session->flash(t('Link removed successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to remove this link.')); } diff --git a/app/Controller/Oauth.php b/app/Controller/Oauth.php index d9fb513b..8c701cf7 100644 --- a/app/Controller/Oauth.php +++ b/app/Controller/Oauth.php @@ -52,8 +52,7 @@ class Oauth extends Base if ($this->authentication->backend($backend)->unlink($this->userSession->getId())) { $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.')); } @@ -71,8 +70,7 @@ class Oauth extends Base if (! empty($code)) { $this->step2($backend, $code); - } - else { + } else { $this->response->redirect($this->authentication->backend($backend)->getService()->getAuthorizationUrl()); } } @@ -102,8 +100,7 @@ class Oauth extends Base { if (empty($profile)) { $this->session->flashError(t('External authentication failed')); - } - else { + } else { $this->session->flash(t('Your external account is linked to your profile successfully.')); $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'])) { $this->response->redirect($this->helper->url->to('app', 'index')); - } - else { + } else { $this->response->html($this->template->layout('auth/index', array( 'errors' => array('login' => t('External authentication failed')), 'values' => array(), diff --git a/app/Controller/Project.php b/app/Controller/Project.php index 5a3edf7a..af01ea77 100644 --- a/app/Controller/Project.php +++ b/app/Controller/Project.php @@ -19,8 +19,7 @@ class Project extends Base { if ($this->userSession->isAdmin()) { $project_ids = $this->project->getAllIds(); - } - else { + } else { $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId()); } @@ -68,13 +67,11 @@ class Project extends Base $switch = $this->request->getStringParam('switch'); if ($switch === 'enable' || $switch === 'disable') { - $this->checkCSRFParam(); if ($this->project->{$switch.'PublicAccess'}($project['id'])) { $this->session->flash(t('Project updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update this project.')); } @@ -145,8 +142,7 @@ class Project extends Base if (! $this->helper->user->isProjectAdministrationAllowed($project['id'])) { unset($values['is_private']); } - } - else if ($project['is_private'] == 1 && ! isset($values['is_private'])) { + } elseif ($project['is_private'] == 1 && ! isset($values['is_private'])) { if ($this->helper->user->isProjectAdministrationAllowed($project['id'])) { $values += array('is_private' => 0); } @@ -155,12 +151,10 @@ class Project extends Base list($valid, $errors) = $this->project->validateModification($values); if ($valid) { - if ($this->project->update($values)) { $this->session->flash(t('Project updated successfully.')); $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.')); } } @@ -193,14 +187,12 @@ class Project extends Base { $project = $this->getProject(); $values = $this->request->getValues() + array('is_everybody_allowed' => 0); - list($valid,) = $this->projectPermission->validateProjectModification($values); + list($valid, ) = $this->projectPermission->validateProjectModification($values); if ($valid) { - if ($this->project->update($values)) { $this->session->flash(t('Project updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update this project.')); } } @@ -216,14 +208,12 @@ class Project extends Base public function allow() { $values = $this->request->getValues(); - list($valid,) = $this->projectPermission->validateUserModification($values); + list($valid, ) = $this->projectPermission->validateUserModification($values); if ($valid) { - if ($this->projectPermission->addMember($values['project_id'], $values['user_id'])) { $this->session->flash(t('Project updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update this project.')); } } @@ -246,14 +236,12 @@ class Project extends Base 'is_owner' => $this->request->getIntegerParam('is_owner'), ); - list($valid,) = $this->projectPermission->validateUserModification($values); + list($valid, ) = $this->projectPermission->validateUserModification($values); if ($valid) { - if ($this->projectPermission->changeRole($values['project_id'], $values['user_id'], $values['is_owner'])) { $this->session->flash(t('Project updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update this project.')); } } @@ -275,14 +263,12 @@ class Project extends Base 'user_id' => $this->request->getIntegerParam('user_id'), ); - list($valid,) = $this->projectPermission->validateUserModification($values); + list($valid, ) = $this->projectPermission->validateUserModification($values); if ($valid) { - if ($this->projectPermission->revokeMember($values['project_id'], $values['user_id'])) { $this->session->flash(t('Project updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update this project.')); } } @@ -300,7 +286,6 @@ class Project extends Base $project = $this->getProject(); if ($this->request->getStringParam('remove') === 'yes') { - $this->checkCSRFParam(); if ($this->project->remove($project['id'])) { @@ -356,7 +341,6 @@ class Project extends Base $project = $this->getProject(); if ($this->request->getStringParam('disable') === 'yes') { - $this->checkCSRFParam(); if ($this->project->disable($project['id'])) { @@ -384,7 +368,6 @@ class Project extends Base $project = $this->getProject(); if ($this->request->getStringParam('enable') === 'yes') { - $this->checkCSRFParam(); if ($this->project->enable($project['id'])) { @@ -431,7 +414,6 @@ class Project extends Base list($valid, $errors) = $this->project->validateCreation($values); if ($valid) { - $project_id = $this->project->create($values, $this->userSession->getId(), true); if ($project_id > 0) { diff --git a/app/Controller/Projectuser.php b/app/Controller/Projectuser.php index 5729d662..18829b3c 100644 --- a/app/Controller/Projectuser.php +++ b/app/Controller/Projectuser.php @@ -36,8 +36,7 @@ class Projectuser extends Base if ($this->userSession->isAdmin()) { $project_ids = $this->project->getAllIds(); - } - else { + } else { $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId()); } diff --git a/app/Controller/Search.php b/app/Controller/Search.php index 67e2df82..08dda1c8 100644 --- a/app/Controller/Search.php +++ b/app/Controller/Search.php @@ -23,7 +23,6 @@ class Search extends Base ->setDirection('DESC'); if ($search !== '') { - $query = $this ->taskFilter ->search($search) diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index 79b74896..4ef3e74e 100644 --- a/app/Controller/Subtask.php +++ b/app/Controller/Subtask.php @@ -66,11 +66,9 @@ class Subtask extends Base list($valid, $errors) = $this->subtask->validateCreation($values); if ($valid) { - if ($this->subtask->create($values)) { $this->session->flash(t('Sub-task added successfully.')); - } - else { + } else { $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); if ($valid) { - if ($this->subtask->update($values)) { $this->session->flash(t('Sub-task updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update your sub-task.')); } @@ -161,8 +157,7 @@ class Subtask extends Base if ($this->subtask->remove($subtask['id'])) { $this->session->flash(t('Sub-task removed successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to remove this sub-task.')); } @@ -183,7 +178,6 @@ class Subtask extends Base $this->subtask->toggleStatus($subtask['id']); if ($redirect === 'board') { - $this->session['has_subtask_inprogress'] = $this->subtask->hasSubtaskInProgress($this->userSession->getId()); $this->response->html($this->template->render('board/tooltip_subtasks', array( diff --git a/app/Controller/Swimlane.php b/app/Controller/Swimlane.php index 69fdf3df..0b29f598 100644 --- a/app/Controller/Swimlane.php +++ b/app/Controller/Swimlane.php @@ -63,12 +63,10 @@ class Swimlane extends Base list($valid, $errors) = $this->swimlane->validateCreation($values); if ($valid) { - if ($this->swimlane->create($values)) { $this->session->flash(t('Your swimlane have been created successfully.')); $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.')); } } @@ -86,15 +84,13 @@ class Swimlane extends Base $project = $this->getProject(); $values = $this->request->getValues() + array('show_default_swimlane' => 0); - list($valid,) = $this->swimlane->validateDefaultModification($values); + list($valid, ) = $this->swimlane->validateDefaultModification($values); if ($valid) { - if ($this->swimlane->updateDefault($values)) { $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']))); - } - else { + } else { $this->session->flashError(t('Unable to update this swimlane.')); } } @@ -136,8 +132,7 @@ class Swimlane extends Base if ($this->swimlane->update($values)) { $this->session->flash(t('Swimlane updated successfully.')); $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.')); } } diff --git a/app/Controller/Task.php b/app/Controller/Task.php index ab7a8a9c..894802d8 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -156,7 +156,6 @@ class Task extends Base } if ($this->request->getStringParam('confirmation') === 'yes') { - $this->checkCSRFParam(); if ($this->task->remove($task['id'])) { diff --git a/app/Controller/TaskImport.php b/app/Controller/TaskImport.php index 387374c5..0e9d2169 100644 --- a/app/Controller/TaskImport.php +++ b/app/Controller/TaskImport.php @@ -53,8 +53,7 @@ class TaskImport extends Base if ($this->taskImport->counter > 0) { $this->session->flash(t('%d task(s) have been imported successfully.', $this->taskImport->counter)); - } - else { + } else { $this->session->flashError(t('Nothing have been imported!')); } diff --git a/app/Controller/Taskcreation.php b/app/Controller/Taskcreation.php index db33a130..e47cd1b7 100644 --- a/app/Controller/Taskcreation.php +++ b/app/Controller/Taskcreation.php @@ -22,7 +22,6 @@ class Taskcreation extends Base $swimlanes_list = $this->swimlane->getList($project['id'], false, true); if (empty($values)) { - $values = array( 'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)), 'column_id' => $this->request->getIntegerParam('column_id'), @@ -62,8 +61,7 @@ class Taskcreation extends Base if ($valid && $this->taskCreation->create($values)) { $this->session->flash(t('Task created successfully.')); $this->afterSave($project, $values); - } - else { + } else { $this->session->flashError(t('Unable to create your task.')); } @@ -79,8 +77,7 @@ class Taskcreation extends Base if (! $this->request->isAjax()) { $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']))); } } diff --git a/app/Controller/Taskduplication.php b/app/Controller/Taskduplication.php index 2eea1567..79f498fc 100644 --- a/app/Controller/Taskduplication.php +++ b/app/Controller/Taskduplication.php @@ -20,7 +20,6 @@ class Taskduplication extends Base $task = $this->getTask(); if ($this->request->getStringParam('confirmation') === 'yes') { - $this->checkCSRFParam(); $task_id = $this->taskDuplication->duplicate($task['id']); @@ -48,9 +47,8 @@ class Taskduplication extends Base $task = $this->getTask(); if ($this->request->isPost()) { - $values = $this->request->getValues(); - list($valid,) = $this->taskValidator->validateProjectModification($values); + list($valid, ) = $this->taskValidator->validateProjectModification($values); if ($valid && $this->taskDuplication->moveToProject($task['id'], $values['project_id'], @@ -58,7 +56,6 @@ class Taskduplication extends Base $values['column_id'], $values['category_id'], $values['owner_id'])) { - $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']))); } @@ -79,9 +76,8 @@ class Taskduplication extends Base $task = $this->getTask(); if ($this->request->isPost()) { - $values = $this->request->getValues(); - list($valid,) = $this->taskValidator->validateProjectModification($values); + list($valid, ) = $this->taskValidator->validateProjectModification($values); if ($valid) { $task_id = $this->taskDuplication->duplicateToProject( @@ -125,8 +121,7 @@ class Taskduplication extends Base $values = $this->taskDuplication->checkDestinationProjectValues($task); $values['project_id'] = $dst_project_id; - } - else { + } else { $swimlanes_list = array(); $columns_list = array(); $categories_list = array(); diff --git a/app/Controller/Tasklink.php b/app/Controller/Tasklink.php index c9649cc6..587769ee 100644 --- a/app/Controller/Tasklink.php +++ b/app/Controller/Tasklink.php @@ -72,7 +72,6 @@ class Tasklink extends Base list($valid, $errors) = $this->taskLink->validateCreation($values); if ($valid) { - if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) { $this->session->flash(t('Link added successfully.')); @@ -129,7 +128,6 @@ class Tasklink extends Base list($valid, $errors) = $this->taskLink->validateModification($values); if ($valid) { - if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) { $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'); @@ -162,15 +160,14 @@ class Tasklink extends Base * * @access public */ - public function remove() + public function remove() { $this->checkCSRFParam(); $task = $this->getTask(); if ($this->taskLink->remove($this->request->getIntegerParam('link_id'))) { $this->session->flash(t('Link removed successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to remove this link.')); } diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php index 6bd2b25e..b1105dcc 100644 --- a/app/Controller/Taskmodification.php +++ b/app/Controller/Taskmodification.php @@ -32,12 +32,11 @@ class Taskmodification extends Base $task = $this->getTask(); $values = $this->request->getValues(); - list($valid,) = $this->taskValidator->validateTimeModification($values); + list($valid, ) = $this->taskValidator->validateTimeModification($values); if ($valid && $this->taskModification->update($values)) { $this->session->flash(t('Task updated successfully.')); - } - else { + } else { $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'); if ($this->request->isPost()) { - $values = $this->request->getValues(); list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values); if ($valid) { - if ($this->taskModification->update($values)) { $this->session->flash(t('Task updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update your task.')); } if ($ajax) { $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']))); } } - } - else { + } else { $values = $task; $errors = array(); } @@ -91,8 +85,7 @@ class Taskmodification extends Base if ($ajax) { $this->response->html($this->template->render('task_modification/edit_description', $params)); - } - else { + } else { $this->response->html($this->taskLayout('task_modification/edit_description', $params)); } } @@ -127,8 +120,7 @@ class Taskmodification extends Base if ($ajax) { $html = $this->template->render('task_modification/edit_task', $params); - } - else { + } else { $html = $this->taskLayout('task_modification/edit_task', $params); } @@ -152,12 +144,10 @@ class Taskmodification extends Base if ($this->request->isAjax()) { $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']))); } - } - else { + } else { $this->session->flashError(t('Unable to update your task.')); $this->edit($values, $errors); } @@ -173,24 +163,20 @@ class Taskmodification extends Base $task = $this->getTask(); if ($this->request->isPost()) { - $values = $this->request->getValues(); list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values); if ($valid) { - if ($this->taskModification->update($values)) { $this->session->flash(t('Task updated successfully.')); - } - else { + } else { $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']))); } - } - else { + } else { $values = $task; $errors = array(); } diff --git a/app/Controller/Taskstatus.php b/app/Controller/Taskstatus.php index b38a143f..c0421ea7 100644 --- a/app/Controller/Taskstatus.php +++ b/app/Controller/Taskstatus.php @@ -37,7 +37,6 @@ class Taskstatus extends Base private function changeStatus(array $task, $method, $success_message, $failure_message) { if ($this->request->getStringParam('confirmation') === 'yes') { - $this->checkCSRFParam(); if ($this->taskStatus->$method($task['id'])) { diff --git a/app/Controller/Timer.php b/app/Controller/Timer.php index b2096f9f..0267fcdd 100644 --- a/app/Controller/Timer.php +++ b/app/Controller/Timer.php @@ -24,8 +24,7 @@ class Timer extends Base if ($timer === 'start') { $this->subtaskTimeTracking->logStartTime($subtask_id, $this->userSession->getId()); - } - else if ($timer === 'stop') { + } elseif ($timer === 'stop') { $this->subtaskTimeTracking->logEndTime($subtask_id, $this->userSession->getId()); $this->subtaskTimeTracking->updateTaskTimeTracking($task_id); } diff --git a/app/Controller/Twofactor.php b/app/Controller/Twofactor.php index 029ee048..179241f8 100644 --- a/app/Controller/Twofactor.php +++ b/app/Controller/Twofactor.php @@ -63,8 +63,7 @@ class Twofactor extends User 'twofactor_activated' => 1, 'twofactor_secret' => GoogleAuthenticator::generateRandom(), )); - } - else { + } else { $this->user->update(array( 'id' => $user['id'], 'twofactor_activated' => 0, @@ -94,8 +93,7 @@ class Twofactor extends User if (! empty($values['code']) && $otp->checkTotp(Base32::decode($user['twofactor_secret']), $values['code'])) { $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.')); } @@ -119,8 +117,7 @@ class Twofactor extends User $this->session['2fa_validated'] = true; $this->session->flash(t('The two factor authentication code is valid.')); $this->response->redirect($this->helper->url->to('app', 'index')); - } - else { + } else { $this->session->flashError(t('The two factor authentication code is not valid.')); $this->response->redirect($this->helper->url->to('twofactor', 'code')); } @@ -148,7 +145,6 @@ class Twofactor extends User $user = $this->getUser(); if ($this->request->getStringParam('disable') === 'yes') { - $this->checkCSRFParam(); $this->user->update(array( diff --git a/app/Controller/User.php b/app/Controller/User.php index 7444ed82..85b80d79 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -86,7 +86,6 @@ class User extends Base list($valid, $errors) = $this->user->validateCreation($values); if ($valid) { - $project_id = empty($values['project_id']) ? 0 : $values['project_id']; unset($values['project_id']); @@ -101,8 +100,7 @@ class User extends Base $this->session->flash(t('User created successfully.')); $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.')); $values['project_id'] = $project_id; } @@ -240,7 +238,6 @@ class User extends Base $switch = $this->request->getStringParam('switch'); if ($switch === 'enable' || $switch === 'disable') { - $this->checkCSRFParam(); if ($this->user->{$switch.'PublicAccess'}($user['id'])) { @@ -270,16 +267,13 @@ class User extends Base $errors = array(); if ($this->request->isPost()) { - $values = $this->request->getValues(); list($valid, $errors) = $this->user->validatePasswordModification($values); if ($valid) { - if ($this->user->update($values)) { $this->session->flash(t('Password modified successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to change the password.')); } @@ -308,13 +302,11 @@ class User extends Base unset($values['password']); if ($this->request->isPost()) { - $values = $this->request->getValues(); if ($this->userSession->isAdmin()) { $values += array('is_admin' => 0, 'is_project_admin' => 0); - } - else { + } else { // Regular users can't be admin if (isset($values['is_admin'])) { unset($values['is_admin']); @@ -328,11 +320,9 @@ class User extends Base list($valid, $errors) = $this->user->validateModification($values); if ($valid) { - if ($this->user->update($values)) { $this->session->flash(t('User updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update your user.')); } @@ -363,16 +353,13 @@ class User extends Base unset($values['password']); if ($this->request->isPost()) { - $values = $this->request->getValues() + array('disable_login_form' => 0, 'is_ldap_user' => 0); list($valid, $errors) = $this->user->validateModification($values); if ($valid) { - if ($this->user->update($values)) { $this->session->flash(t('User updated successfully.')); - } - else { + } else { $this->session->flashError(t('Unable to update your user.')); } @@ -397,7 +384,6 @@ class User extends Base $user = $this->getUser(); if ($this->request->getStringParam('confirmation') === 'yes') { - $this->checkCSRFParam(); if ($this->user->remove($user['id'])) { diff --git a/app/Controller/UserImport.php b/app/Controller/UserImport.php index 59defa0a..32b9a865 100644 --- a/app/Controller/UserImport.php +++ b/app/Controller/UserImport.php @@ -47,8 +47,7 @@ class UserImport extends Base if ($this->userImport->counter > 0) { $this->session->flash(t('%d user(s) have been imported successfully.', $this->userImport->counter)); - } - else { + } else { $this->session->flashError(t('Nothing have been imported!')); } diff --git a/app/Controller/Webhook.php b/app/Controller/Webhook.php index 1186680d..a7e9bde4 100644 --- a/app/Controller/Webhook.php +++ b/app/Controller/Webhook.php @@ -31,7 +31,7 @@ class Webhook extends Base '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)) { $this->response->text('OK'); diff --git a/app/Core/Csv.php b/app/Core/Csv.php index 37f51b27..7c6a4620 100644 --- a/app/Core/Csv.php +++ b/app/Core/Csv.php @@ -93,7 +93,8 @@ class Csv { if (! empty($value)) { $value = trim(strtolower($value)); - return $value === '1' || $value{0} === 't' ? 1 : 0; + return $value === '1' || $value{0} + === 't' ? 1 : 0; } return 0; @@ -187,8 +188,7 @@ class Csv foreach ($this->columns as $sql_name => $csv_name) { if (isset($row[$index])) { $line[$sql_name] = $row[$index]; - } - else { + } else { $line[$sql_name] = ''; } diff --git a/app/Core/DateParser.php b/app/Core/DateParser.php index 026cf305..6577af0f 100644 --- a/app/Core/DateParser.php +++ b/app/Core/DateParser.php @@ -214,8 +214,7 @@ class DateParser extends Base foreach ($fields as $field) { if (! empty($values[$field])) { $values[$field] = date($format, $values[$field]); - } - else { + } else { $values[$field] = ''; } } diff --git a/app/Core/HttpClient.php b/app/Core/HttpClient.php index 4ec5396e..7f4ea47a 100644 --- a/app/Core/HttpClient.php +++ b/app/Core/HttpClient.php @@ -131,8 +131,7 @@ class HttpClient extends Base if (is_resource($stream)) { $response = stream_get_contents($stream); - } - else { + } else { $this->container['logger']->error('HttpClient: request failed'); } diff --git a/app/Core/Lexer.php b/app/Core/Lexer.php index 92443c2c..ca2ef895 100644 --- a/app/Core/Lexer.php +++ b/app/Core/Lexer.php @@ -60,7 +60,6 @@ class Lexer $this->offset = 0; while (isset($input[$this->offset])) { - $result = $this->match(substr($input, $this->offset)); if ($result === false) { @@ -84,7 +83,6 @@ class Lexer { foreach ($this->tokenMap as $pattern => $name) { if (preg_match($pattern, $string, $matches)) { - $this->offset += strlen($matches[1]); return array( @@ -113,7 +111,6 @@ class Lexer ); while (false !== ($token = current($tokens))) { - switch ($token['token']) { case 'T_ASSIGNEE': case 'T_COLOR': diff --git a/app/Core/Mail/Client.php b/app/Core/Mail/Client.php index c7cfaab9..52caef73 100644 --- a/app/Core/Mail/Client.php +++ b/app/Core/Mail/Client.php @@ -87,7 +87,7 @@ class Client extends Base { $container = $this->container; - $this->transports[$transport] = function() use ($class, $container) { + $this->transports[$transport] = function () use ($class, $container) { return new $class($container); }; diff --git a/app/Core/Mail/Transport/Mail.php b/app/Core/Mail/Transport/Mail.php index ca06e208..4d833f8f 100644 --- a/app/Core/Mail/Transport/Mail.php +++ b/app/Core/Mail/Transport/Mail.php @@ -30,7 +30,6 @@ class Mail extends Base implements ClientInterface public function sendEmail($email, $name, $subject, $html, $author) { try { - $message = Swift_Message::newInstance() ->setSubject($subject) ->setFrom(array(MAIL_FROM => $author)) @@ -38,8 +37,7 @@ class Mail extends Base implements ClientInterface ->setTo(array($email => $name)); Swift_Mailer::newInstance($this->getTransport())->send($message); - } - catch (Swift_TransportException $e) { + } catch (Swift_TransportException $e) { $this->logger->error($e->getMessage()); } } diff --git a/app/Core/Markdown.php b/app/Core/Markdown.php index 4101a3b3..f08c486a 100644 --- a/app/Core/Markdown.php +++ b/app/Core/Markdown.php @@ -29,7 +29,6 @@ class Markdown extends Parsedown { // Replace task #123 by a link to the task if (! empty($this->link) && preg_match('!#(\d+)!i', $Excerpt['text'], $matches)) { - $url = $this->helper->href( $this->link['controller'], $this->link['action'], diff --git a/app/Core/OAuth2.php b/app/Core/OAuth2.php index ee6a7837..a5bbba1a 100644 --- a/app/Core/OAuth2.php +++ b/app/Core/OAuth2.php @@ -86,7 +86,6 @@ class OAuth2 extends Base public function getAccessToken($code) { if (empty($this->accessToken) && ! empty($code)) { - $params = array( 'code' => $code, 'client_id' => $this->clientId, diff --git a/app/Core/Paginator.php b/app/Core/Paginator.php index 763cb8b9..cfe89938 100644 --- a/app/Core/Paginator.php +++ b/app/Core/Paginator.php @@ -355,8 +355,7 @@ class Paginator $this->action, $this->getUrlParams($this->page - 1, $this->order, $this->direction) ); - } - else { + } else { $html .= '← '.t('Previous'); } @@ -382,8 +381,7 @@ class Paginator $this->action, $this->getUrlParams($this->page + 1, $this->order, $this->direction) ); - } - else { + } else { $html .= t('Next').' →'; } diff --git a/app/Core/Plugin/Base.php b/app/Core/Plugin/Base.php index e38ffee8..15265370 100644 --- a/app/Core/Plugin/Base.php +++ b/app/Core/Plugin/Base.php @@ -51,7 +51,7 @@ abstract class Base extends \Kanboard\Core\Base { $container = $this->container; - $this->container['dispatcher']->addListener($event, function() use ($container, $callback) { + $this->container['dispatcher']->addListener($event, function () use ($container, $callback) { call_user_func($callback, $container); }); } diff --git a/app/Core/Plugin/Loader.php b/app/Core/Plugin/Loader.php index ea512c4e..e68ba8e6 100644 --- a/app/Core/Plugin/Loader.php +++ b/app/Core/Plugin/Loader.php @@ -94,7 +94,6 @@ class Loader extends \Kanboard\Core\Base $current_version = $this->getSchemaVersion($plugin); try { - $this->db->startTransaction(); $this->db->getDriver()->disableForeignKeys(); @@ -109,8 +108,7 @@ class Loader extends \Kanboard\Core\Base $this->db->getDriver()->enableForeignKeys(); $this->db->closeTransaction(); $this->setSchemaVersion($plugin, $i - 1); - } - catch (PDOException $e) { + } catch (PDOException $e) { $this->db->cancelTransaction(); $this->db->getDriver()->enableForeignKeys(); die('Unable to migrate schema for the plugin: '.$plugin.' => '.$e->getMessage()); diff --git a/app/Core/Request.php b/app/Core/Request.php index f553d7cd..5eda2d02 100644 --- a/app/Core/Request.php +++ b/app/Core/Request.php @@ -218,11 +218,8 @@ class Request ); foreach ($keys as $key) { - if (isset($_SERVER[$key])) { - foreach (explode(',', $_SERVER[$key]) as $ip_address) { - $ip_address = trim($ip_address); if ($only_public) { @@ -231,9 +228,7 @@ class Request if (filter_var($ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) { return $ip_address; } - } - else { - + } else { return $ip_address; } } diff --git a/app/Core/Response.php b/app/Core/Response.php index c27f0a1d..528a6302 100644 --- a/app/Core/Response.php +++ b/app/Core/Response.php @@ -68,8 +68,7 @@ class Response { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { header('X-Ajax-Redirect: '.$url); - } - else { + } else { header('Location: '.$url); } diff --git a/app/Core/Router.php b/app/Core/Router.php index 8f366daf..f4453c71 100644 --- a/app/Core/Router.php +++ b/app/Core/Router.php @@ -127,17 +127,13 @@ class Router extends Base $count = count($parts); foreach ($this->paths as $route) { - if ($count === $route['count']) { - $params = array(); for ($i = 0; $i < $count; $i++) { - if ($route['pattern'][$i]{0} === ':') { $params[substr($route['pattern'][$i], 1)] = $parts[$i]; - } - else if ($route['pattern'][$i] !== $parts[$i]) { + } elseif ($route['pattern'][$i] !== $parts[$i]) { break; } } @@ -168,7 +164,6 @@ class Router extends Base } foreach ($this->urls[$controller][$action] as $pattern) { - if (array_diff_key($params, $pattern['params']) === array()) { $url = $pattern['path']; $i = 0; @@ -213,8 +208,7 @@ class Router extends Base $this->controller = $this->sanitize($_GET['controller'], 'app'); $this->action = $this->sanitize($_GET['action'], 'index'); $plugin = ! empty($_GET['plugin']) ? $this->sanitize($_GET['plugin'], '') : ''; - } - else { + } else { list($this->controller, $this->action) = $this->findRoute($this->getPath($uri, $query_string)); // TODO: add plugin for routes $plugin = ''; } diff --git a/app/Core/Security.php b/app/Core/Security.php index 126de2fd..54207ee1 100644 --- a/app/Core/Security.php +++ b/app/Core/Security.php @@ -10,7 +10,7 @@ namespace Kanboard\Core; */ class Security { - /** + /** * Generate a random token with different methods: openssl or /dev/urandom or fallback to uniqid() * * @static @@ -21,8 +21,7 @@ class Security { if (function_exists('openssl_random_pseudo_bytes')) { return bin2hex(\openssl_random_pseudo_bytes(30)); - } - else if (ini_get('open_basedir') === '' && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { + } elseif (ini_get('open_basedir') === '' && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { return hash('sha256', file_get_contents('/dev/urandom', false, null, 0, 30)); } diff --git a/app/Core/Template.php b/app/Core/Template.php index d1e0c25a..002b20b1 100644 --- a/app/Core/Template.php +++ b/app/Core/Template.php @@ -85,8 +85,7 @@ class Template extends Helper if (strpos($template_name, ':') !== false) { list($plugin, $template) = explode(':', $template_name); $path = __DIR__.'/../../plugins/'.ucfirst($plugin).'/Template/'.$template.'.php'; - } - else { + } else { $path = __DIR__.'/../Template/'.$template_name.'.php'; } diff --git a/app/Core/Tool.php b/app/Core/Tool.php index 1bd43a40..247fda1a 100644 --- a/app/Core/Tool.php +++ b/app/Core/Tool.php @@ -26,8 +26,8 @@ class Tool return ''; } - list($local_part,) = explode('@', $email); - list(,$identifier) = explode('+', $local_part); + list($local_part, ) = explode('@', $email); + list(, $identifier) = explode('+', $local_part); return $identifier; } @@ -83,14 +83,11 @@ class Tool $dst_width = $resize_width; $dst_height = floor($src_height * ($resize_width / $src_width)); $dst_image = imagecreatetruecolor($dst_width, $dst_height); - } - elseif ($resize_width == 0 && $resize_height > 0) { + } elseif ($resize_width == 0 && $resize_height > 0) { $dst_width = floor($src_width * ($resize_height / $src_height)); $dst_height = $resize_height; $dst_image = imagecreatetruecolor($dst_width, $dst_height); - } - else { - + } else { $src_ratio = $src_width / $src_height; $resize_ratio = $resize_width / $resize_height; @@ -99,8 +96,7 @@ class Tool $dst_height = floor($src_height * ($resize_width / $src_width)); $dst_y = ($dst_height - $resize_height) / 2 * (-1); - } - else { + } else { $dst_width = floor($src_width * ($resize_height / $src_height)); $dst_height = $resize_height; diff --git a/app/Core/Translator.php b/app/Core/Translator.php index 7dd67363..96a481f6 100644 --- a/app/Core/Translator.php +++ b/app/Core/Translator.php @@ -184,8 +184,7 @@ class Translator { if (isset(self::$locales[$identifier])) { return self::$locales[$identifier]; - } - else { + } else { return $default; } } diff --git a/app/Formatter/ProjectGanttFormatter.php b/app/Formatter/ProjectGanttFormatter.php index b629bdfa..17496088 100644 --- a/app/Formatter/ProjectGanttFormatter.php +++ b/app/Formatter/ProjectGanttFormatter.php @@ -31,9 +31,7 @@ class ProjectGanttFormatter extends Project implements FormatterInterface { if (empty($project_ids)) { $this->projects = array(); - } - else { - + } else { $this->projects = $this->db ->table(self::TABLE) ->asc('start_date') diff --git a/app/Formatter/TaskFilterICalendarFormatter.php b/app/Formatter/TaskFilterICalendarFormatter.php index bdf6b6c2..25b3aea0 100644 --- a/app/Formatter/TaskFilterICalendarFormatter.php +++ b/app/Formatter/TaskFilterICalendarFormatter.php @@ -56,7 +56,6 @@ class TaskFilterICalendarFormatter extends TaskFilterCalendarEvent implements Fo public function addDateTimeEvents() { foreach ($this->query->findAll() as $task) { - $start = new DateTime; $start->setTimestamp($task[$this->startColumn]); @@ -82,7 +81,6 @@ class TaskFilterICalendarFormatter extends TaskFilterCalendarEvent implements Fo public function addFullDayEvents() { foreach ($this->query->findAll() as $task) { - $date = new DateTime; $date->setTimestamp($task[$this->startColumn]); diff --git a/app/Helper/App.php b/app/Helper/App.php index 0e84f694..19801fa8 100644 --- a/app/Helper/App.php +++ b/app/Helper/App.php @@ -68,8 +68,7 @@ class App extends \Kanboard\Core\Base $html = '<div class="alert alert-success alert-fade-out">'.$this->helper->e($this->session['flash_message']).'</div>'; unset($this->session['flash_message']); unset($this->session['flash_error_message']); - } - else if (isset($this->session['flash_error_message'])) { + } elseif (isset($this->session['flash_error_message'])) { $html = '<div class="alert alert-error">'.$this->helper->e($this->session['flash_error_message']).'</div>'; unset($this->session['flash_message']); unset($this->session['flash_error_message']); diff --git a/app/Helper/Dt.php b/app/Helper/Dt.php index e717a4c0..78002b1b 100644 --- a/app/Helper/Dt.php +++ b/app/Helper/Dt.php @@ -52,11 +52,9 @@ class Dt extends \Kanboard\Core\Base } if ($diff < 1200) { return t('<30m'); - } - else if ($diff < 3600) { + } elseif ($diff < 3600) { return t('<1h'); - } - else if ($diff < 86400) { + } elseif ($diff < 86400) { return '~'.t('%dh', $diff / 3600); } diff --git a/app/Helper/File.php b/app/Helper/File.php index b0a7f675..d2cdfc6a 100644 --- a/app/Helper/File.php +++ b/app/Helper/File.php @@ -17,8 +17,8 @@ class File extends \Kanboard\Core\Base * @param string $filename Filename * @return string Font-Awesome-Icon-Name */ - public function icon($filename){ - + public function icon($filename) + { $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); switch ($extension) { diff --git a/app/Helper/Form.php b/app/Helper/Form.php index 92d07ccc..5f19f2a8 100644 --- a/app/Helper/Form.php +++ b/app/Helper/Form.php @@ -52,11 +52,14 @@ class Form extends \Kanboard\Core\Base $html = '<select name="'.$name.'" id="form-'.$name.'" class="'.$class.'" '.implode(' ', $attributes).'>'; foreach ($options as $id => $value) { - $html .= '<option value="'.$this->helper->e($id).'"'; - if (isset($values->$name) && $id == $values->$name) $html .= ' selected="selected"'; - if (isset($values[$name]) && $id == $values[$name]) $html .= ' selected="selected"'; + if (isset($values->$name) && $id == $values->$name) { + $html .= ' selected="selected"'; + } + if (isset($values[$name]) && $id == $values[$name]) { + $html .= ' selected="selected"'; + } $html .= '>'.$this->helper->e($value).'</option>'; } @@ -328,7 +331,6 @@ class Form extends \Kanboard\Core\Base $html = ''; if (isset($errors[$name])) { - $html .= '<ul class="form-errors">'; foreach ($errors[$name] as $error) { diff --git a/app/Helper/Subtask.php b/app/Helper/Subtask.php index d103d453..1f367b27 100644 --- a/app/Helper/Subtask.php +++ b/app/Helper/Subtask.php @@ -21,7 +21,6 @@ class Subtask extends \Kanboard\Core\Base public function toggleStatus(array $subtask, $redirect) { if ($subtask['status'] == 0 && isset($this->session['has_subtask_inprogress']) && $this->session['has_subtask_inprogress'] === true) { - return $this->helper->url->link( trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']), 'subtask', diff --git a/app/Integration/BitbucketWebhook.php b/app/Integration/BitbucketWebhook.php index b78c4d77..44e5bd74 100644 --- a/app/Integration/BitbucketWebhook.php +++ b/app/Integration/BitbucketWebhook.php @@ -80,7 +80,6 @@ class BitbucketWebhook extends \Kanboard\Core\Base $task = $this->taskFinder->getByReference($this->project_id, $payload['issue']['id']); if (! empty($task)) { - $user = $this->user->getByUsername($payload['actor']['username']); if (! empty($user) && ! $this->projectPermission->isMember($this->project_id, $user['id'])) { @@ -147,8 +146,7 @@ class BitbucketWebhook extends \Kanboard\Core\Base if (isset($payload['changes']['status'])) { return $this->handleStatusChange($task, $payload); - } - else if (isset($payload['changes']['assignee'])) { + } elseif (isset($payload['changes']['assignee'])) { return $this->handleAssigneeChange($task, $payload); } diff --git a/app/Integration/GithubWebhook.php b/app/Integration/GithubWebhook.php index c948ea8b..a4333723 100644 --- a/app/Integration/GithubWebhook.php +++ b/app/Integration/GithubWebhook.php @@ -77,7 +77,6 @@ class GithubWebhook extends \Kanboard\Core\Base public function parsePushEvent(array $payload) { foreach ($payload['commits'] as $commit) { - $task_id = $this->task->getTaskIdFromText($commit['message']); if (empty($task_id)) { @@ -149,7 +148,6 @@ class GithubWebhook extends \Kanboard\Core\Base $task = $this->taskFinder->getByReference($this->project_id, $payload['issue']['number']); if (! empty($task)) { - $user = $this->user->getByUsername($payload['comment']['user']['login']); if (! empty($user) && ! $this->projectPermission->isMember($this->project_id, $user['id'])) { @@ -270,7 +268,6 @@ class GithubWebhook extends \Kanboard\Core\Base $task = $this->taskFinder->getByReference($this->project_id, $issue['number']); if (! empty($user) && ! empty($task) && $this->projectPermission->isMember($this->project_id, $user['id'])) { - $event = array( 'project_id' => $this->project_id, 'task_id' => $task['id'], @@ -301,7 +298,6 @@ class GithubWebhook extends \Kanboard\Core\Base $task = $this->taskFinder->getByReference($this->project_id, $issue['number']); if (! empty($task)) { - $event = array( 'project_id' => $this->project_id, 'task_id' => $task['id'], @@ -333,7 +329,6 @@ class GithubWebhook extends \Kanboard\Core\Base $task = $this->taskFinder->getByReference($this->project_id, $issue['number']); if (! empty($task)) { - $event = array( 'project_id' => $this->project_id, 'task_id' => $task['id'], @@ -365,7 +360,6 @@ class GithubWebhook extends \Kanboard\Core\Base $task = $this->taskFinder->getByReference($this->project_id, $issue['number']); if (! empty($task)) { - $event = array( 'project_id' => $this->project_id, 'task_id' => $task['id'], diff --git a/app/Integration/GitlabWebhook.php b/app/Integration/GitlabWebhook.php index 4b90ef7f..fb75d95a 100644 --- a/app/Integration/GitlabWebhook.php +++ b/app/Integration/GitlabWebhook.php @@ -239,7 +239,6 @@ class GitlabWebhook extends \Kanboard\Core\Base $task = $this->taskFinder->getByReference($this->project_id, $payload['issue']['id']); if (! empty($task)) { - $user = $this->user->getByUsername($payload['user']['username']); if (! empty($user) && ! $this->projectPermission->isMember($this->project_id, $user['id'])) { diff --git a/app/Integration/HipchatWebhook.php b/app/Integration/HipchatWebhook.php index af1e4495..6f789718 100644 --- a/app/Integration/HipchatWebhook.php +++ b/app/Integration/HipchatWebhook.php @@ -60,7 +60,6 @@ class HipchatWebhook extends \Kanboard\Core\Base public function notify($project_id, $task_id, $event_name, array $event) { if ($this->isActivated($project_id)) { - $params = $this->getParameters($project_id); $project = $this->project->getbyId($project_id); diff --git a/app/Integration/Jabber.php b/app/Integration/Jabber.php index 9c7dcd40..d776e560 100644 --- a/app/Integration/Jabber.php +++ b/app/Integration/Jabber.php @@ -72,7 +72,6 @@ class Jabber extends \Kanboard\Core\Base public function notify($project_id, $task_id, $event_name, array $event) { if ($this->isActivated($project_id)) { - $project = $this->project->getbyId($project_id); $event['event_name'] = $event_name; @@ -98,7 +97,6 @@ class Jabber extends \Kanboard\Core\Base public function sendMessage($project_id, $payload) { try { - $params = $this->getParameters($project_id); $options = new Options($params['server']); @@ -121,8 +119,7 @@ class Jabber extends \Kanboard\Core\Base $client->send($message); $client->disconnect(); - } - catch (Exception $e) { + } catch (Exception $e) { $this->container['logger']->error('Jabber error: '.$e->getMessage()); } } diff --git a/app/Integration/SlackWebhook.php b/app/Integration/SlackWebhook.php index e216ed5b..8f4eb422 100644 --- a/app/Integration/SlackWebhook.php +++ b/app/Integration/SlackWebhook.php @@ -70,7 +70,6 @@ class SlackWebhook extends \Kanboard\Core\Base public function notify($project_id, $task_id, $event_name, array $event) { if ($this->isActivated($project_id)) { - $project = $this->project->getbyId($project_id); $event['event_name'] = $event_name; diff --git a/app/Library/password.php b/app/Library/password.php index c6e84cbd..d4972ab4 100644 --- a/app/Library/password.php +++ b/app/Library/password.php @@ -8,220 +8,219 @@ */ if (!defined('PASSWORD_BCRYPT')) { - - define('PASSWORD_BCRYPT', 1); - define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); - - if (version_compare(PHP_VERSION, '5.3.7', '<')) { - - define('PASSWORD_PREFIX', '$2a$'); - } - else { - - define('PASSWORD_PREFIX', '$2y$'); - } - - /** - * Hash the password using the specified algorithm - * - * @param string $password The password to hash - * @param int $algo The algorithm to use (Defined by PASSWORD_* constants) - * @param array $options The options for the algorithm to use - * - * @return string|false The hashed password, or false on error. - */ - function password_hash($password, $algo, array $options = array()) { - if (!function_exists('crypt')) { - trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); - return null; - } - if (!is_string($password)) { - trigger_error("password_hash(): Password must be a string", E_USER_WARNING); - return null; - } - if (!is_int($algo)) { - trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); - return null; - } - switch ($algo) { - case PASSWORD_BCRYPT: - // Note that this is a C constant, but not exposed to PHP, so we don't define it here. - $cost = 10; - if (isset($options['cost'])) { - $cost = $options['cost']; - if ($cost < 4 || $cost > 31) { - trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); - return null; - } - } - $required_salt_len = 22; - $hash_format = sprintf("%s%02d$", PASSWORD_PREFIX, $cost); - break; - default: - trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); - return null; - } - if (isset($options['salt'])) { - switch (gettype($options['salt'])) { - case 'NULL': - case 'boolean': - case 'integer': - case 'double': - case 'string': - $salt = (string) $options['salt']; - break; - case 'object': - if (method_exists($options['salt'], '__tostring')) { - $salt = (string) $options['salt']; - break; - } - case 'array': - case 'resource': - default: - trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); - return null; - } - if (strlen($salt) < $required_salt_len) { - trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", strlen($salt), $required_salt_len), E_USER_WARNING); - return null; - } elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) { - $salt = str_replace('+', '.', base64_encode($salt)); - } - } else { - $buffer = ''; - $raw_length = (int) ($required_salt_len * 3 / 4 + 1); - $buffer_valid = false; - if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { - $buffer = mcrypt_create_iv($raw_length, MCRYPT_DEV_URANDOM); - if ($buffer) { - $buffer_valid = true; - } - } - if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { - $buffer = openssl_random_pseudo_bytes($raw_length); - if ($buffer) { - $buffer_valid = true; - } - } - if (!$buffer_valid && is_readable('/dev/urandom')) { - $f = fopen('/dev/urandom', 'r'); - $read = strlen($buffer); - while ($read < $raw_length) { - $buffer .= fread($f, $raw_length - $read); - $read = strlen($buffer); - } - fclose($f); - if ($read >= $raw_length) { - $buffer_valid = true; - } - } - if (!$buffer_valid || strlen($buffer) < $raw_length) { - $bl = strlen($buffer); - for ($i = 0; $i < $raw_length; $i++) { - if ($i < $bl) { - $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); - } else { - $buffer .= chr(mt_rand(0, 255)); - } - } - } - $salt = str_replace('+', '.', base64_encode($buffer)); - - } - $salt = substr($salt, 0, $required_salt_len); - - $hash = $hash_format . $salt; - - $ret = crypt($password, $hash); - - if (!is_string($ret) || strlen($ret) <= 13) { - return false; - } - - return $ret; - } - - /** - * Get information about the password hash. Returns an array of the information - * that was used to generate the password hash. - * - * array( - * 'algo' => 1, - * 'algoName' => 'bcrypt', - * 'options' => array( - * 'cost' => 10, - * ), - * ) - * - * @param string $hash The password hash to extract info from - * - * @return array The array of information about the hash. - */ - function password_get_info($hash) { - $return = array( - 'algo' => 0, - 'algoName' => 'unknown', - 'options' => array(), - ); - if (substr($hash, 0, 4) == PASSWORD_PREFIX && strlen($hash) == 60) { - $return['algo'] = PASSWORD_BCRYPT; - $return['algoName'] = 'bcrypt'; - list($cost) = sscanf($hash, PASSWORD_PREFIX."%d$"); - $return['options']['cost'] = $cost; - } - return $return; - } - - /** - * Determine if the password hash needs to be rehashed according to the options provided - * - * If the answer is true, after validating the password using password_verify, rehash it. - * - * @param string $hash The hash to test - * @param int $algo The algorithm used for new password hashes - * @param array $options The options array passed to password_hash - * - * @return boolean True if the password needs to be rehashed. - */ - function password_needs_rehash($hash, $algo, array $options = array()) { - $info = password_get_info($hash); - if ($info['algo'] != $algo) { - return true; - } - switch ($algo) { - case PASSWORD_BCRYPT: - $cost = isset($options['cost']) ? $options['cost'] : 10; - if ($cost != $info['options']['cost']) { - return true; - } - break; - } - return false; - } - - /** - * Verify a password against a hash using a timing attack resistant approach - * - * @param string $password The password to verify - * @param string $hash The hash to verify against - * - * @return boolean If the password matches the hash - */ - function password_verify($password, $hash) { - if (!function_exists('crypt')) { - trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); - return false; - } - $ret = crypt($password, $hash); - if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) { - return false; - } - - $status = 0; - for ($i = 0; $i < strlen($ret); $i++) { - $status |= (ord($ret[$i]) ^ ord($hash[$i])); - } - - return $status === 0; - } + define('PASSWORD_BCRYPT', 1); + define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); + + if (version_compare(PHP_VERSION, '5.3.7', '<')) { + define('PASSWORD_PREFIX', '$2a$'); + } else { + define('PASSWORD_PREFIX', '$2y$'); + } + + /** + * Hash the password using the specified algorithm + * + * @param string $password The password to hash + * @param int $algo The algorithm to use (Defined by PASSWORD_* constants) + * @param array $options The options for the algorithm to use + * + * @return string|false The hashed password, or false on error. + */ + function password_hash($password, $algo, array $options = array()) + { + if (!function_exists('crypt')) { + trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); + return null; + } + if (!is_string($password)) { + trigger_error("password_hash(): Password must be a string", E_USER_WARNING); + return null; + } + if (!is_int($algo)) { + trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); + return null; + } + switch ($algo) { + case PASSWORD_BCRYPT: + // Note that this is a C constant, but not exposed to PHP, so we don't define it here. + $cost = 10; + if (isset($options['cost'])) { + $cost = $options['cost']; + if ($cost < 4 || $cost > 31) { + trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); + return null; + } + } + $required_salt_len = 22; + $hash_format = sprintf("%s%02d$", PASSWORD_PREFIX, $cost); + break; + default: + trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); + return null; + } + if (isset($options['salt'])) { + switch (gettype($options['salt'])) { + case 'NULL': + case 'boolean': + case 'integer': + case 'double': + case 'string': + $salt = (string) $options['salt']; + break; + case 'object': + if (method_exists($options['salt'], '__tostring')) { + $salt = (string) $options['salt']; + break; + } + case 'array': + case 'resource': + default: + trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); + return null; + } + if (strlen($salt) < $required_salt_len) { + trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", strlen($salt), $required_salt_len), E_USER_WARNING); + return null; + } elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) { + $salt = str_replace('+', '.', base64_encode($salt)); + } + } else { + $buffer = ''; + $raw_length = (int) ($required_salt_len * 3 / 4 + 1); + $buffer_valid = false; + if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { + $buffer = mcrypt_create_iv($raw_length, MCRYPT_DEV_URANDOM); + if ($buffer) { + $buffer_valid = true; + } + } + if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { + $buffer = openssl_random_pseudo_bytes($raw_length); + if ($buffer) { + $buffer_valid = true; + } + } + if (!$buffer_valid && is_readable('/dev/urandom')) { + $f = fopen('/dev/urandom', 'r'); + $read = strlen($buffer); + while ($read < $raw_length) { + $buffer .= fread($f, $raw_length - $read); + $read = strlen($buffer); + } + fclose($f); + if ($read >= $raw_length) { + $buffer_valid = true; + } + } + if (!$buffer_valid || strlen($buffer) < $raw_length) { + $bl = strlen($buffer); + for ($i = 0; $i < $raw_length; $i++) { + if ($i < $bl) { + $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); + } else { + $buffer .= chr(mt_rand(0, 255)); + } + } + } + $salt = str_replace('+', '.', base64_encode($buffer)); + } + $salt = substr($salt, 0, $required_salt_len); + + $hash = $hash_format . $salt; + + $ret = crypt($password, $hash); + + if (!is_string($ret) || strlen($ret) <= 13) { + return false; + } + + return $ret; + } + + /** + * Get information about the password hash. Returns an array of the information + * that was used to generate the password hash. + * + * array( + * 'algo' => 1, + * 'algoName' => 'bcrypt', + * 'options' => array( + * 'cost' => 10, + * ), + * ) + * + * @param string $hash The password hash to extract info from + * + * @return array The array of information about the hash. + */ + function password_get_info($hash) + { + $return = array( + 'algo' => 0, + 'algoName' => 'unknown', + 'options' => array(), + ); + if (substr($hash, 0, 4) == PASSWORD_PREFIX && strlen($hash) == 60) { + $return['algo'] = PASSWORD_BCRYPT; + $return['algoName'] = 'bcrypt'; + list($cost) = sscanf($hash, PASSWORD_PREFIX."%d$"); + $return['options']['cost'] = $cost; + } + return $return; + } + + /** + * Determine if the password hash needs to be rehashed according to the options provided + * + * If the answer is true, after validating the password using password_verify, rehash it. + * + * @param string $hash The hash to test + * @param int $algo The algorithm used for new password hashes + * @param array $options The options array passed to password_hash + * + * @return boolean True if the password needs to be rehashed. + */ + function password_needs_rehash($hash, $algo, array $options = array()) + { + $info = password_get_info($hash); + if ($info['algo'] != $algo) { + return true; + } + switch ($algo) { + case PASSWORD_BCRYPT: + $cost = isset($options['cost']) ? $options['cost'] : 10; + if ($cost != $info['options']['cost']) { + return true; + } + break; + } + return false; + } + + /** + * Verify a password against a hash using a timing attack resistant approach + * + * @param string $password The password to verify + * @param string $hash The hash to verify against + * + * @return boolean If the password matches the hash + */ + function password_verify($password, $hash) + { + if (!function_exists('crypt')) { + trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); + return false; + } + $ret = crypt($password, $hash); + if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) { + return false; + } + + $status = 0; + for ($i = 0; $i < strlen($ret); $i++) { + $status |= (ord($ret[$i]) ^ ord($hash[$i])); + } + + return $status === 0; + } } diff --git a/app/Model/Action.php b/app/Model/Action.php index b48e3ae3..ba74218f 100644 --- a/app/Model/Action.php +++ b/app/Model/Action.php @@ -184,7 +184,6 @@ class Action extends Base $params = $this->db->table(self::TABLE_PARAMS)->findAll(); foreach ($actions as &$action) { - $action['params'] = array(); foreach ($params as $param) { @@ -270,7 +269,6 @@ class Action extends Base $action_id = $this->db->getLastId(); foreach ($values['params'] as $param_name => $param_value) { - $action_param = array( 'action_id' => $action_id, 'name' => $param_name, @@ -298,7 +296,6 @@ class Action extends Base $actions = $this->getAll(); foreach ($actions as $action) { - $listener = $this->load($action['action_name'], $action['project_id'], $action['event_name']); foreach ($action['params'] as $param) { @@ -320,7 +317,8 @@ class Action extends Base */ public function load($name, $project_id, $event) { - $className = $name{0} !== '\\' ? '\Kanboard\Action\\'.$name : $name; + $className = $name{0} + !== '\\' ? '\Kanboard\Action\\'.$name : $name; return new $className($this->container, $project_id, $event); } @@ -337,7 +335,6 @@ class Action extends Base $actions = $this->action->getAllByProject($src_project_id); foreach ($actions as $action) { - $this->db->startTransaction(); $values = array( @@ -378,7 +375,6 @@ class Action extends Base public function duplicateParameters($project_id, $action_id, array $params) { foreach ($params as $param) { - $value = $this->resolveParameters($param, $project_id); if ($value === false) { diff --git a/app/Model/Authentication.php b/app/Model/Authentication.php index acd563bc..116e0726 100644 --- a/app/Model/Authentication.php +++ b/app/Model/Authentication.php @@ -79,12 +79,10 @@ class Authentication extends Base if ($this->user->isLocked($username)) { $this->container['logger']->error('Account locked: '.$username); return false; - } - else if ($this->backend('database')->authenticate($username, $password)) { + } elseif ($this->backend('database')->authenticate($username, $password)) { $this->user->resetFailedLogin($username); return true; - } - else if (LDAP_AUTH && $this->backend('ldap')->authenticate($username, $password)) { + } elseif (LDAP_AUTH && $this->backend('ldap')->authenticate($username, $password)) { $this->user->resetFailedLogin($username); return true; } @@ -133,11 +131,9 @@ class Authentication extends Base list($result, $errors) = $this->validateFormCredentials($values); if ($result) { - if ($this->validateFormCaptcha($values) && $this->authenticate($values['username'], $values['password'])) { $this->createRememberMeSession($values); - } - else { + } else { $result = false; $errors['login'] = t('Bad username or password'); } @@ -194,7 +190,6 @@ class Authentication extends Base private function createRememberMeSession(array $values) { if (REMEMBER_ME_AUTH && ! empty($values['remember_me'])) { - $credentials = $this->backend('rememberMe') ->create($this->userSession->getId(), Request::getIpAddress(), Request::getUserAgent()); diff --git a/app/Model/Base.php b/app/Model/Base.php index 4c7ada7c..ab07949b 100644 --- a/app/Model/Base.php +++ b/app/Model/Base.php @@ -22,7 +22,7 @@ abstract class Base extends \Kanboard\Core\Base */ public function persist($table, array $values) { - return $this->db->transaction(function($db) use ($table, $values) { + return $this->db->transaction(function ($db) use ($table, $values) { if (! $db->table($table)->save($values)) { return false; diff --git a/app/Model/Board.php b/app/Model/Board.php index 6b450d22..3af2e83d 100644 --- a/app/Model/Board.php +++ b/app/Model/Board.php @@ -43,7 +43,6 @@ class Board extends Base $columns = array(); foreach ($column_names as $column_name) { - $column_name = trim($column_name); if (! empty($column_name)) { @@ -67,7 +66,6 @@ class Board extends Base $position = 0; foreach ($columns as $column) { - $values = array( 'title' => $column['title'], 'position' => ++$position, @@ -120,7 +118,7 @@ class Board extends Base 'title' => $title, 'task_limit' => intval($task_limit), 'position' => $this->getLastColumnPosition($project_id) + 1, - 'description' => $description, + 'description' => $description, ); return $this->persist(self::TABLE, $values); @@ -199,7 +197,6 @@ class Board extends Base $positions = array_flip($columns); if (isset($columns[$column_id]) && $columns[$column_id] < count($columns)) { - $position = ++$columns[$column_id]; $columns[$positions[$position]]--; @@ -223,7 +220,6 @@ class Board extends Base $positions = array_flip($columns); if (isset($columns[$column_id]) && $columns[$column_id] > 1) { - $position = --$columns[$column_id]; $columns[$positions[$position]]++; @@ -248,14 +244,12 @@ class Board extends Base $nb_columns = count($columns); for ($i = 0, $ilen = count($swimlanes); $i < $ilen; $i++) { - $swimlanes[$i]['columns'] = $columns; $swimlanes[$i]['nb_columns'] = $nb_columns; $swimlanes[$i]['nb_tasks'] = 0; $swimlanes[$i]['nb_swimlanes'] = $ilen; for ($j = 0; $j < $nb_columns; $j++) { - $column_id = $columns[$j]['id']; $swimlane_id = $swimlanes[$i]['id']; diff --git a/app/Model/Category.php b/app/Model/Category.php index 9cc2a193..bf40c60a 100644 --- a/app/Model/Category.php +++ b/app/Model/Category.php @@ -128,7 +128,6 @@ class Category extends Base $categories = explode(',', $this->config->get('project_categories')); foreach ($categories as $category) { - $category = trim($category); if (! empty($category)) { @@ -204,7 +203,6 @@ class Category extends Base ->findAll(); foreach ($categories as $category) { - $category['project_id'] = $dst_project_id; if (! $this->db->table(self::TABLE)->save($category)) { diff --git a/app/Model/Color.php b/app/Model/Color.php index 4ded2e1e..d341dd3c 100644 --- a/app/Model/Color.php +++ b/app/Model/Color.php @@ -113,8 +113,7 @@ class Color extends Base foreach ($this->default_colors as $color_id => $params) { if ($color_id === $color) { return $color_id; - } - else if ($color === strtolower($params['name'])) { + } elseif ($color === strtolower($params['name'])) { return $color_id; } } diff --git a/app/Model/File.php b/app/Model/File.php index e4430217..daade517 100644 --- a/app/Model/File.php +++ b/app/Model/File.php @@ -50,7 +50,6 @@ class File extends Base public function remove($file_id) { try { - $file = $this->getbyId($file_id); $this->objectStorage->remove($file['path']); @@ -59,8 +58,7 @@ class File extends Base } return $this->db->table(self::TABLE)->eq('id', $file['id'])->remove(); - } - catch (ObjectStorageException $e) { + } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); return false; } @@ -108,7 +106,6 @@ class File extends Base )); if ($result) { - $this->container['dispatcher']->dispatch( self::EVENT_CREATE, new FileEvent(array('task_id' => $task_id, 'name' => $name)) @@ -266,15 +263,12 @@ class File extends Base public function uploadFiles($project_id, $task_id, $form_name) { try { - if (empty($_FILES[$form_name])) { return false; } foreach ($_FILES[$form_name]['error'] as $key => $error) { - if ($error == UPLOAD_ERR_OK && $_FILES[$form_name]['size'][$key] > 0) { - $original_filename = $_FILES[$form_name]['name'][$key]; $uploaded_filename = $_FILES[$form_name]['tmp_name'][$key]; $destination_filename = $this->generatePath($project_id, $task_id, $original_filename); @@ -295,8 +289,7 @@ class File extends Base } return true; - } - catch (ObjectStorageException $e) { + } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); return false; } @@ -330,7 +323,6 @@ class File extends Base public function uploadContent($project_id, $task_id, $original_filename, $blob) { try { - $data = base64_decode($blob); if (empty($data)) { @@ -350,8 +342,7 @@ class File extends Base $destination_filename, strlen($data) ); - } - catch (ObjectStorageException $e) { + } catch (ObjectStorageException $e) { $this->logger->error($e->getMessage()); return false; } diff --git a/app/Model/LastLogin.php b/app/Model/LastLogin.php index f4be8a9d..0f148ead 100644 --- a/app/Model/LastLogin.php +++ b/app/Model/LastLogin.php @@ -44,7 +44,6 @@ class LastLogin extends Base ->findAllByColumn('id'); if (count($connections) >= self::NB_LOGINS) { - $this->db->table(self::TABLE) ->eq('user_id', $user_id) ->notin('id', array_slice($connections, 0, self::NB_LOGINS - 1)) diff --git a/app/Model/Link.php b/app/Model/Link.php index 4e1b4e6b..00b6dfc5 100644 --- a/app/Model/Link.php +++ b/app/Model/Link.php @@ -126,7 +126,6 @@ class Link extends Base $label_id = $this->db->getLastId(); if (! empty($opposite_label)) { - $this->db ->table(self::TABLE) ->insert(array( diff --git a/app/Model/NotificationType.php b/app/Model/NotificationType.php index 9ec250ab..50d6080f 100644 --- a/app/Model/NotificationType.php +++ b/app/Model/NotificationType.php @@ -53,7 +53,7 @@ abstract class NotificationType extends Base $container = $this->container; $this->labels[$type] = $label; - $this->classes[$type] = function() use ($class, $container) { + $this->classes[$type] = function () use ($class, $container) { return new $class($container); }; } diff --git a/app/Model/ProjectActivity.php b/app/Model/ProjectActivity.php index 527abf58..2cc1c975 100644 --- a/app/Model/ProjectActivity.php +++ b/app/Model/ProjectActivity.php @@ -138,18 +138,17 @@ class ProjectActivity extends Base */ private function getEvents(\PicoDb\Table $query, $start, $end) { - if (! is_null($start)){ + if (! is_null($start)) { $query->gte('date_creation', $start); } - if (! is_null($end)){ + if (! is_null($end)) { $query->lte('date_creation', $end); } $events = $query->findAll(); foreach ($events as &$event) { - $event += $this->decode($event['data']); unset($event['data']); @@ -170,7 +169,6 @@ class ProjectActivity extends Base public function cleanup($max) { if ($this->db->table(self::TABLE)->count() > $max) { - $this->db->execute(' DELETE FROM '.self::TABLE.' WHERE id <= ( diff --git a/app/Model/ProjectAnalytic.php b/app/Model/ProjectAnalytic.php index 34d152d1..92364c0c 100644 --- a/app/Model/ProjectAnalytic.php +++ b/app/Model/ProjectAnalytic.php @@ -24,7 +24,6 @@ class ProjectAnalytic extends Base $columns = $this->board->getColumns($project_id); foreach ($columns as $column) { - $nb_tasks = $this->taskFinder->countByColumnId($project_id, $column['id']); $total += $nb_tasks; @@ -60,7 +59,6 @@ class ProjectAnalytic extends Base $users = $this->projectPermission->getMemberList($project_id); foreach ($tasks as $task) { - $user = isset($users[$task['owner_id']]) ? $users[$task['owner_id']] : $users[0]; $total++; diff --git a/app/Model/ProjectDailyColumnStats.php b/app/Model/ProjectDailyColumnStats.php index 2228dcf8..abab0241 100644 --- a/app/Model/ProjectDailyColumnStats.php +++ b/app/Model/ProjectDailyColumnStats.php @@ -32,7 +32,7 @@ class ProjectDailyColumnStats extends Base { $status = $this->config->get('cfd_include_closed_tasks') == 1 ? array(Task::STATUS_OPEN, Task::STATUS_CLOSED) : array(Task::STATUS_OPEN); - return $this->db->transaction(function($db) use ($project_id, $date, $status) { + return $this->db->transaction(function ($db) use ($project_id, $date, $status) { $column_ids = $db->table(Board::TABLE)->eq('project_id', $project_id)->findAllByColumn('id'); @@ -171,7 +171,6 @@ class ProjectDailyColumnStats extends Base // Aggregate by day foreach ($records as $record) { - if (! isset($aggregates[$record['day']])) { $aggregates[$record['day']] = array($record['day']); } @@ -181,7 +180,6 @@ class ProjectDailyColumnStats extends Base // Aggregate by row foreach ($aggregates as $aggregate) { - $row = array($aggregate[0]); foreach ($column_ids as $column_id) { diff --git a/app/Model/ProjectDailyStats.php b/app/Model/ProjectDailyStats.php index b98c23ff..538aea1a 100644 --- a/app/Model/ProjectDailyStats.php +++ b/app/Model/ProjectDailyStats.php @@ -29,7 +29,7 @@ class ProjectDailyStats extends Base { $lead_cycle_time = $this->projectAnalytic->getAverageLeadAndCycleTime($project_id); - return $this->db->transaction(function($db) use ($project_id, $date, $lead_cycle_time) { + return $this->db->transaction(function ($db) use ($project_id, $date, $lead_cycle_time) { // This call will fail if the record already exists // (cross database driver hack for INSERT..ON DUPLICATE KEY UPDATE) diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php index 36987d47..d9eef4db 100644 --- a/app/Model/ProjectPermission.php +++ b/app/Model/ProjectPermission.php @@ -280,9 +280,9 @@ class ProjectPermission extends Base ->eq('project_id', $project_id) ->eq('user_id', $user_id) ->exists(); - } + } - /** + /** * Check if a specific user is manager of a given project * * @access public @@ -439,7 +439,6 @@ class ProjectPermission extends Base ->findAll(); foreach ($rows as $row) { - $result = $this->db ->table(self::TABLE) ->save(array( diff --git a/app/Model/Subtask.php b/app/Model/Subtask.php index bb6606b3..94b13a0e 100644 --- a/app/Model/Subtask.php +++ b/app/Model/Subtask.php @@ -148,7 +148,6 @@ class Subtask extends Base public function getById($subtask_id, $more = false) { if ($more) { - return $this->db ->table(self::TABLE) ->eq(self::TABLE.'.id', $subtask_id) @@ -341,7 +340,6 @@ class Subtask extends Base $positions = array_flip($subtasks); if (isset($subtasks[$subtask_id]) && $subtasks[$subtask_id] > 1) { - $position = --$subtasks[$subtask_id]; $subtasks[$positions[$position]]++; @@ -446,7 +444,6 @@ class Subtask extends Base ->findAll(); foreach ($subtasks as &$subtask) { - $subtask['task_id'] = $dst_task_id; if (! $db->table(Subtask::TABLE)->save($subtask)) { diff --git a/app/Model/SubtaskTimeTracking.php b/app/Model/SubtaskTimeTracking.php index 86a4b213..a741dbb5 100644 --- a/app/Model/SubtaskTimeTracking.php +++ b/app/Model/SubtaskTimeTracking.php @@ -214,7 +214,6 @@ class SubtaskTimeTracking extends Base $events = array(); foreach ($rows as $row) { - $user = isset($row['username']) ? ' ('.($row['user_fullname'] ?: $row['username']).')' : ''; $events[] = array( diff --git a/app/Model/Swimlane.php b/app/Model/Swimlane.php index 1aa19fee..df44985a 100644 --- a/app/Model/Swimlane.php +++ b/app/Model/Swimlane.php @@ -142,8 +142,7 @@ class Swimlane extends Base if ($status == self::ACTIVE) { $query->asc('position'); - } - else { + } else { $query->asc('name'); } @@ -172,7 +171,6 @@ class Swimlane extends Base ->findOneColumn('default_swimlane'); if ($default_swimlane) { - if ($default_swimlane === 'Default swimlane') { $default_swimlane = t($default_swimlane); } @@ -396,7 +394,6 @@ class Swimlane extends Base $positions = array_flip($swimlanes); if (isset($swimlanes[$swimlane_id]) && $swimlanes[$swimlane_id] < count($swimlanes)) { - $position = ++$swimlanes[$swimlane_id]; $swimlanes[$positions[$position]]--; @@ -430,7 +427,6 @@ class Swimlane extends Base $positions = array_flip($swimlanes); if (isset($swimlanes[$swimlane_id]) && $swimlanes[$swimlane_id] > 1) { - $position = --$swimlanes[$swimlane_id]; $swimlanes[$positions[$position]]++; @@ -459,7 +455,6 @@ class Swimlane extends Base $swimlanes = $this->getAll($project_from); foreach ($swimlanes as $swimlane) { - unset($swimlane['id']); $swimlane['project_id'] = $project_to; diff --git a/app/Model/TaskAnalytic.php b/app/Model/TaskAnalytic.php index c6d4191c..bdfec3cb 100644 --- a/app/Model/TaskAnalytic.php +++ b/app/Model/TaskAnalytic.php @@ -52,7 +52,6 @@ class TaskAnalytic extends Base $sums = $this->transition->getTimeSpentByTask($task['id']); foreach ($columns as $column_id => $column_title) { - $time_spent = isset($sums[$column_id]) ? $sums[$column_id] : 0; if ($task['column_id'] == $column_id) { diff --git a/app/Model/TaskCreation.php b/app/Model/TaskCreation.php index b6d8fbae..5ef1a04b 100644 --- a/app/Model/TaskCreation.php +++ b/app/Model/TaskCreation.php @@ -31,7 +31,6 @@ class TaskCreation extends Base $task_id = $this->persist(Task::TABLE, $values); if ($task_id !== false) { - if ($position > 0 && $values['position'] > 1) { $this->taskPosition->movePosition($values['project_id'], $task_id, $values['column_id'], $position, $values['swimlane_id'], false); } diff --git a/app/Model/TaskDuplication.php b/app/Model/TaskDuplication.php index 60fcac0c..e81fb232 100755 --- a/app/Model/TaskDuplication.php +++ b/app/Model/TaskDuplication.php @@ -63,7 +63,6 @@ class TaskDuplication extends Base $values = $this->copyFields($task_id); if ($values['recurrence_status'] == Task::RECURRING_STATUS_PENDING) { - $values['recurrence_parent'] = $task_id; $values['column_id'] = $this->board->getFirstColumn($values['project_id']); $this->calculateRecurringTaskDueDate($values); @@ -71,7 +70,6 @@ class TaskDuplication extends Base $recurring_task_id = $this->save($task_id, $values); if ($recurring_task_id > 0) { - $parent_update = $this->db ->table(Task::TABLE) ->eq('id', $task_id) @@ -203,7 +201,6 @@ class TaskDuplication extends Base public function calculateRecurringTaskDueDate(array &$values) { if (! empty($values['date_due']) && $values['recurrence_factor'] != 0) { - if ($values['recurrence_basedate'] == Task::RECURRING_BASEDATE_TRIGGERDATE) { $values['date_due'] = time(); } diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php index 6500edda..137a7a8e 100644 --- a/app/Model/TaskFilter.php +++ b/app/Model/TaskFilter.php @@ -193,8 +193,7 @@ class TaskFilter extends Base $this->query->eq(Task::TABLE.'.id', str_replace('#', '', $title)); $this->query->ilike(Task::TABLE.'.title', '%'.$title.'%'); $this->query->closeOr(); - } - else { + } else { $this->query->ilike(Task::TABLE.'.title', '%'.$title.'%'); } @@ -244,8 +243,7 @@ class TaskFilter extends Base foreach ($values as $project) { if (ctype_digit($project)) { $this->query->eq(Task::TABLE.'.project_id', $project); - } - else { + } else { $this->query->ilike(Project::TABLE.'.name', $project); } } @@ -267,8 +265,7 @@ class TaskFilter extends Base foreach ($values as $swimlane) { if ($swimlane === 'default') { $this->query->eq(Task::TABLE.'.swimlane_id', 0); - } - else { + } else { $this->query->ilike(Swimlane::TABLE.'.name', $swimlane); $this->query->addCondition(Task::TABLE.'.swimlane_id=0 AND '.Project::TABLE.'.default_swimlane '.$this->db->getDriver()->getOperator('ILIKE')." '$swimlane'"); } @@ -307,8 +304,7 @@ class TaskFilter extends Base foreach ($values as $category) { if ($category === 'none') { $this->query->eq(Task::TABLE.'.category_id', 0); - } - else { + } else { $this->query->eq(Category::TABLE.'.name', $category); } } @@ -379,8 +375,7 @@ class TaskFilter extends Base foreach ($values as $assignee) { if ($assignee === 'me') { $subtaskQuery->eq(Subtask::TABLE.'.user_id', $this->userSession->getId()); - } - else { + } else { $subtaskQuery->ilike(User::TABLE.'.username', '%'.$assignee.'%'); $subtaskQuery->ilike(User::TABLE.'.name', '%'.$assignee.'%'); } @@ -646,7 +641,7 @@ class TaskFilter extends Base $tasks = $this->filterByProject($project_id)->query->asc(Task::TABLE.'.position')->findAll(); return $this->board->getBoard($project_id, function ($project_id, $column_id, $swimlane_id) use ($tasks) { - return array_filter($tasks, function(array $task) use ($column_id, $swimlane_id) { + return array_filter($tasks, function (array $task) use ($column_id, $swimlane_id) { return $task['column_id'] == $column_id && $task['swimlane_id'] == $swimlane_id; }); }); @@ -682,8 +677,7 @@ class TaskFilter extends Base $timestamp = $this->dateParser->getTimestampFromIsoFormat($value); $this->query->gte($field, $timestamp); $this->query->lte($field, $timestamp + 86399); - } - else { + } else { $this->query->eq($field, $value); } diff --git a/app/Model/TaskImport.php b/app/Model/TaskImport.php index 92c8f400..da34559f 100644 --- a/app/Model/TaskImport.php +++ b/app/Model/TaskImport.php @@ -71,12 +71,10 @@ class TaskImport extends Base if ($this->taskCreation->create($row) > 0) { $this->logger->debug('TaskImport: imported successfully line '.$line_number); $this->counter++; - } - else { + } else { $this->logger->error('TaskImport: creation error at line '.$line_number); } - } - else { + } else { $this->logger->error('TaskImport: validation error at line '.$line_number); } } diff --git a/app/Model/TaskLink.php b/app/Model/TaskLink.php index fafcde65..1ac59203 100644 --- a/app/Model/TaskLink.php +++ b/app/Model/TaskLink.php @@ -112,7 +112,6 @@ class TaskLink extends Base $result = array(); foreach ($links as $link) { - if (! isset($result[$link['label']])) { $result[$link['label']] = array(); } diff --git a/app/Model/TaskModification.php b/app/Model/TaskModification.php index 9cca5b30..781646b8 100644 --- a/app/Model/TaskModification.php +++ b/app/Model/TaskModification.php @@ -51,8 +51,7 @@ class TaskModification extends Base if ($this->isFieldModified('owner_id', $event_data['changes'])) { $events[] = Task::EVENT_ASSIGNEE_CHANGE; - } - else { + } else { $events[] = Task::EVENT_CREATE_UPDATE; $events[] = Task::EVENT_UPDATE; } diff --git a/app/Model/TaskPermission.php b/app/Model/TaskPermission.php index 501c8edc..4bbe6d1d 100644 --- a/app/Model/TaskPermission.php +++ b/app/Model/TaskPermission.php @@ -22,8 +22,7 @@ class TaskPermission extends Base { if ($this->userSession->isAdmin() || $this->projectPermission->isManager($task['project_id'], $this->userSession->getId())) { return true; - } - else if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) { + } elseif (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) { return true; } diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php index 1ad17b36..da363cb3 100644 --- a/app/Model/TaskPosition.php +++ b/app/Model/TaskPosition.php @@ -41,11 +41,9 @@ class TaskPosition extends Base if ($task['swimlane_id'] != $swimlane_id) { $result = $this->saveSwimlaneChange($project_id, $task_id, $position, $task['column_id'], $column_id, $task['swimlane_id'], $swimlane_id); - } - else if ($task['column_id'] != $column_id) { + } elseif ($task['column_id'] != $column_id) { $result = $this->saveColumnChange($project_id, $task_id, $position, $swimlane_id, $task['column_id'], $column_id); - } - else if ($task['position'] != $position) { + } elseif ($task['position'] != $position) { $result = $this->savePositionChange($project_id, $task_id, $position, $column_id, $swimlane_id); } @@ -224,11 +222,9 @@ class TaskPosition extends Base if ($task['swimlane_id'] != $new_swimlane_id) { $this->container['dispatcher']->dispatch(Task::EVENT_MOVE_SWIMLANE, new TaskEvent($event_data)); - } - else if ($task['column_id'] != $new_column_id) { + } elseif ($task['column_id'] != $new_column_id) { $this->container['dispatcher']->dispatch(Task::EVENT_MOVE_COLUMN, new TaskEvent($event_data)); - } - else if ($task['position'] != $new_position) { + } elseif ($task['position'] != $new_position) { $this->container['dispatcher']->dispatch(Task::EVENT_MOVE_POSITION, new TaskEvent($event_data)); } } diff --git a/app/Model/User.php b/app/Model/User.php index 138b77b2..c4d26c9c 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -280,11 +280,9 @@ class User extends Base public function prepare(array &$values) { if (isset($values['password'])) { - if (! empty($values['password'])) { $values['password'] = \password_hash($values['password'], PASSWORD_BCRYPT); - } - else { + } else { unset($values['password']); } } @@ -516,8 +514,7 @@ class User extends Base if (isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1) { $v = new Validator($values, array_merge($rules, $this->commonValidationRules())); - } - else { + } else { $v = new Validator($values, array_merge($rules, $this->commonValidationRules(), $this->commonPasswordValidationRules())); } @@ -591,8 +588,7 @@ class User extends Base // Check password if ($this->authentication->authenticate($this->session['user']['username'], $values['current_password'])) { return array(true, array()); - } - else { + } else { return array(false, array('current_password' => array(t('Wrong password')))); } } diff --git a/app/Model/UserImport.php b/app/Model/UserImport.php index 1a398d12..199f2a90 100644 --- a/app/Model/UserImport.php +++ b/app/Model/UserImport.php @@ -56,12 +56,10 @@ class UserImport extends Base if ($this->user->create($row)) { $this->logger->debug('UserImport: imported successfully line '.$line_number); $this->counter++; - } - else { + } else { $this->logger->error('UserImport: creation error at line '.$line_number); } - } - else { + } else { $this->logger->error('UserImport: validation error at line '.$line_number); } } diff --git a/app/Model/UserNotification.php b/app/Model/UserNotification.php index b4ee77a9..3d98ebe9 100644 --- a/app/Model/UserNotification.php +++ b/app/Model/UserNotification.php @@ -51,8 +51,7 @@ class UserNotification extends Base // Use the user language otherwise use the application language (do not use the session language) if (! empty($user['language'])) { Translator::load($user['language']); - } - else { + } else { Translator::load($this->config->get('application_language', 'en_US')); } @@ -123,8 +122,7 @@ class UserNotification extends Base $this->userNotificationFilter->saveFilter($user_id, $filter); $this->userNotificationFilter->saveSelectedProjects($user_id, $projects); $this->userNotificationType->saveSelectedTypes($user_id, $types); - } - else { + } else { $this->disableNotification($user_id); } diff --git a/app/Model/Webhook.php b/app/Model/Webhook.php index dd277bf8..7c17e61e 100644 --- a/app/Model/Webhook.php +++ b/app/Model/Webhook.php @@ -22,11 +22,9 @@ class Webhook extends Base $token = $this->config->get('webhook_token'); if (! empty($url)) { - if (strpos($url, '?') !== false) { $url .= '&token='.$token; - } - else { + } else { $url .= '?token='.$token; } diff --git a/app/Notification/Mail.php b/app/Notification/Mail.php index 69b8888d..cd8af852 100644 --- a/app/Notification/Mail.php +++ b/app/Notification/Mail.php @@ -46,7 +46,6 @@ class Mail extends Base implements NotificationInterface */ public function notifyProject(array $project, $event_name, array $event_data) { - } /** diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index a0febc1a..edf63919 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -411,7 +411,6 @@ function version_49($pdo) $rq->execute(); foreach ($rq->fetchAll(PDO::FETCH_ASSOC) as $subtask) { - if ($task_id != $subtask['task_id']) { $position = 1; $task_id = $subtask['task_id']; diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index 517ded85..0cc31616 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -399,7 +399,6 @@ function version_30($pdo) $rq->execute(); foreach ($rq->fetchAll(PDO::FETCH_ASSOC) as $subtask) { - if ($task_id != $subtask['task_id']) { $position = 1; $task_id = $subtask['task_id']; @@ -459,13 +458,13 @@ function version_27($pdo) function version_26($pdo) { - $pdo->exec('ALTER TABLE tasks ADD COLUMN date_moved INT DEFAULT 0'); + $pdo->exec('ALTER TABLE tasks ADD COLUMN date_moved INT DEFAULT 0'); - /* Update tasks.date_moved from project_activities table if tasks.date_moved = null or 0. - * We take max project_activities.date_creation where event_name in task.create','task.move.column - * since creation date is always less than task moves - */ - $pdo->exec("UPDATE tasks + /* Update tasks.date_moved from project_activities table if tasks.date_moved = null or 0. + * We take max project_activities.date_creation where event_name in task.create','task.move.column + * since creation date is always less than task moves + */ + $pdo->exec("UPDATE tasks SET date_moved = ( SELECT md FROM ( diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index e9e86fcc..70b9d160 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -359,7 +359,6 @@ function version_48($pdo) $rq->execute(); foreach ($rq->fetchAll(PDO::FETCH_ASSOC) as $subtask) { - if ($task_id != $subtask['task_id']) { $position = 1; $task_id = $subtask['task_id']; @@ -419,13 +418,13 @@ function version_45($pdo) function version_44($pdo) { - $pdo->exec('ALTER TABLE tasks ADD COLUMN date_moved INTEGER DEFAULT 0'); + $pdo->exec('ALTER TABLE tasks ADD COLUMN date_moved INTEGER DEFAULT 0'); - /* Update tasks.date_moved from project_activities table if tasks.date_moved = null or 0. - * We take max project_activities.date_creation where event_name in task.create','task.move.column - * since creation date is always less than task moves - */ - $pdo->exec("UPDATE tasks + /* Update tasks.date_moved from project_activities table if tasks.date_moved = null or 0. + * We take max project_activities.date_creation where event_name in task.create','task.move.column + * since creation date is always less than task moves + */ + $pdo->exec("UPDATE tasks SET date_moved = ( SELECT md FROM ( diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php index 322c1a9b..dde3cf10 100644 --- a/app/ServiceProvider/ClassProvider.php +++ b/app/ServiceProvider/ClassProvider.php @@ -112,15 +112,15 @@ class ClassProvider implements ServiceProviderInterface return new OAuth2($c); }); - $container['htmlConverter'] = function() { + $container['htmlConverter'] = function () { return new HtmlConverter(array('strip_tags' => true)); }; - $container['objectStorage'] = function() { + $container['objectStorage'] = function () { return new FileStorage(FILES_DIR); }; - $container['emailClient'] = function($container) { + $container['emailClient'] = function ($container) { $mailer = new EmailClient($container); $mailer->setTransport('smtp', '\Kanboard\Core\Mail\Transport\Smtp'); $mailer->setTransport('sendmail', '\Kanboard\Core\Mail\Transport\Sendmail'); @@ -128,7 +128,7 @@ class ClassProvider implements ServiceProviderInterface return $mailer; }; - $container['userNotificationType'] = function($container) { + $container['userNotificationType'] = function ($container) { $type = new UserNotificationType($container); $type->setType('email', t('Email'), '\Kanboard\Notification\Mail'); $type->setType('web', t('Web'), '\Kanboard\Notification\Web'); diff --git a/app/ServiceProvider/DatabaseProvider.php b/app/ServiceProvider/DatabaseProvider.php index a49a5f1b..43c4b813 100644 --- a/app/ServiceProvider/DatabaseProvider.php +++ b/app/ServiceProvider/DatabaseProvider.php @@ -42,8 +42,7 @@ class DatabaseProvider implements ServiceProviderInterface if ($db->schema()->check(\Schema\VERSION)) { return $db; - } - else { + } else { $errors = $db->getLogMessages(); die('Unable to migrate database schema: <br/><br/><strong>'.(isset($errors[0]) ? $errors[0] : 'Unknown error').'</strong>'); } diff --git a/app/Subscriber/ProjectActivitySubscriber.php b/app/Subscriber/ProjectActivitySubscriber.php index f8d5d150..a66bbc5a 100644 --- a/app/Subscriber/ProjectActivitySubscriber.php +++ b/app/Subscriber/ProjectActivitySubscriber.php @@ -32,7 +32,6 @@ class ProjectActivitySubscriber extends \Kanboard\Core\Base implements EventSubs { // Executed only when someone is logged if ($this->userSession->isLogged() && isset($event['task_id'])) { - $values = $this->getValues($event); $this->projectActivity->createEvent( diff --git a/app/Subscriber/RecurringTaskSubscriber.php b/app/Subscriber/RecurringTaskSubscriber.php index 793233c6..b03ffcf8 100644 --- a/app/Subscriber/RecurringTaskSubscriber.php +++ b/app/Subscriber/RecurringTaskSubscriber.php @@ -19,11 +19,9 @@ class RecurringTaskSubscriber extends \Kanboard\Core\Base implements EventSubscr public function onMove(TaskEvent $event) { if ($event['recurrence_status'] == Task::RECURRING_STATUS_PENDING) { - if ($event['recurrence_trigger'] == Task::RECURRING_TRIGGER_FIRST_COLUMN && $this->board->getFirstColumn($event['project_id']) == $event['src_column_id']) { $this->taskDuplication->duplicateRecurringTask($event['task_id']); - } - else if ($event['recurrence_trigger'] == Task::RECURRING_TRIGGER_LAST_COLUMN && $this->board->getLastColumn($event['project_id']) == $event['dst_column_id']) { + } elseif ($event['recurrence_trigger'] == Task::RECURRING_TRIGGER_LAST_COLUMN && $this->board->getLastColumn($event['project_id']) == $event['dst_column_id']) { $this->taskDuplication->duplicateRecurringTask($event['task_id']); } } diff --git a/app/Subscriber/SubtaskTimeTrackingSubscriber.php b/app/Subscriber/SubtaskTimeTrackingSubscriber.php index bb522b2e..b5e0354d 100644 --- a/app/Subscriber/SubtaskTimeTrackingSubscriber.php +++ b/app/Subscriber/SubtaskTimeTrackingSubscriber.php @@ -30,7 +30,6 @@ class SubtaskTimeTrackingSubscriber extends \Kanboard\Core\Base implements Event public function logStartEnd(SubtaskEvent $event) { if (isset($event['status']) && $this->config->get('subtask_time_tracking') == 1) { - $subtask = $this->subtask->getById($event['id']); if (empty($subtask['user_id'])) { @@ -39,8 +38,7 @@ class SubtaskTimeTrackingSubscriber extends \Kanboard\Core\Base implements Event if ($subtask['status'] == Subtask::STATUS_INPROGRESS) { return $this->subtaskTimeTracking->logStartTime($subtask['id'], $subtask['user_id']); - } - else { + } else { return $this->subtaskTimeTracking->logEndTime($subtask['id'], $subtask['user_id']); } } diff --git a/app/Subscriber/TransitionSubscriber.php b/app/Subscriber/TransitionSubscriber.php index f14590f7..35352dc7 100644 --- a/app/Subscriber/TransitionSubscriber.php +++ b/app/Subscriber/TransitionSubscriber.php @@ -23,4 +23,4 @@ class TransitionSubscriber extends \Kanboard\Core\Base implements EventSubscribe $this->transition->save($user_id, $event->getAll()); } } -}
\ No newline at end of file +} diff --git a/app/Template/board/tooltip_files.php b/app/Template/board/tooltip_files.php index 96428d3b..407309b3 100644 --- a/app/Template/board/tooltip_files.php +++ b/app/Template/board/tooltip_files.php @@ -1,5 +1,5 @@ <table class="table-small"> - <?php foreach($files as $file): ?> + <?php foreach ($files as $file): ?> <tr> <th> <i class="fa <?= $this->file->icon($file['name']) ?> fa-fw"></i> diff --git a/app/Template/board/tooltip_tasklinks.php b/app/Template/board/tooltip_tasklinks.php index 5991fecc..62304330 100644 --- a/app/Template/board/tooltip_tasklinks.php +++ b/app/Template/board/tooltip_tasklinks.php @@ -1,6 +1,6 @@ <div class="tooltip-tasklinks"> <ul> - <?php foreach($links as $link): ?> + <?php foreach ($links as $link): ?> <li> <strong><?= t($link['label']) ?></strong> [<i><?= $link['project_name'] ?></i>] diff --git a/app/Template/config/plugins.php b/app/Template/config/plugins.php index fea48d58..4a263ce7 100644 --- a/app/Template/config/plugins.php +++ b/app/Template/config/plugins.php @@ -13,7 +13,7 @@ <th><?= t('Description') ?></th> </tr> - <?php foreach($plugins as $plugin): ?> + <?php foreach ($plugins as $plugin): ?> <tr> <td> <?php if ($plugin->getPluginHomepage()): ?> diff --git a/app/Template/header.php b/app/Template/header.php index 19ffbbf5..e8fd90c7 100644 --- a/app/Template/header.php +++ b/app/Template/header.php @@ -18,7 +18,7 @@ data-redirect-regex="PROJECT_ID" data-redirect-url="<?= $this->url->href('board', 'show', array('project_id' => 'PROJECT_ID')) ?>"> <option value=""></option> - <?php foreach($board_selector as $board_id => $board_name): ?> + <?php foreach ($board_selector as $board_id => $board_name): ?> <option value="<?= $board_id ?>"><?= $this->e($board_name) ?></option> <?php endforeach ?> </select> diff --git a/app/Template/project/filters.php b/app/Template/project/filters.php index eee691c5..c17cfb3c 100644 --- a/app/Template/project/filters.php +++ b/app/Template/project/filters.php @@ -68,7 +68,7 @@ <i class="fa fa-caret-down"></i> <a href="#" class="dropdown-menu"><?= t('My filters') ?></a> <ul> <?php foreach ($custom_filters_list as $filter): ?> - <li><a href="#" class="filter-helper" data-<?php if($filter['append']): ?><?= 'append-' ?><?php endif ?>filter='<?= $this->e($filter['filter']) ?>'><?= $this->e($filter['name']) ?></a></li> + <li><a href="#" class="filter-helper" data-<?php if ($filter['append']): ?><?= 'append-' ?><?php endif ?>filter='<?= $this->e($filter['filter']) ?>'><?= $this->e($filter['name']) ?></a></li> <?php endforeach ?> </ul> </div> diff --git a/app/Template/task/changes.php b/app/Template/task/changes.php index c7fc0d52..f288a8f4 100644 --- a/app/Template/task/changes.php +++ b/app/Template/task/changes.php @@ -3,7 +3,6 @@ <?php foreach ($changes as $field => $value) { - switch ($field) { case 'title': echo '<li>'.t('New title: %s', $task['title']).'</li>'; @@ -11,16 +10,14 @@ case 'owner_id': if (empty($task['owner_id'])) { echo '<li>'.t('The task is not assigned anymore').'</li>'; - } - else { + } else { echo '<li>'.t('New assignee: %s', $task['assignee_name'] ?: $task['assignee_username']).'</li>'; } break; case 'category_id': if (empty($task['category_id'])) { echo '<li>'.t('There is no category now').'</li>'; - } - else { + } else { echo '<li>'.t('New category: %s', $task['category_name']).'</li>'; } break; @@ -33,8 +30,7 @@ case 'date_due': if (empty($task['date_due'])) { echo '<li>'.t('The due date have been removed').'</li>'; - } - else { + } else { echo '<li>'.dt('New due date: %B %e, %Y', $task['date_due']).'</li>'; } break; diff --git a/app/Template/user/last.php b/app/Template/user/last.php index 8097d6f1..8879466e 100644 --- a/app/Template/user/last.php +++ b/app/Template/user/last.php @@ -12,7 +12,7 @@ <th class="column-15"><?= t('IP address') ?></th> <th><?= t('User agent') ?></th> </tr> - <?php foreach($last_logins as $login): ?> + <?php foreach ($last_logins as $login): ?> <tr> <td><?= dt('%B %e, %Y at %k:%M %p', $login['date_creation']) ?></td> <td><?= $this->e($login['auth_type']) ?></td> diff --git a/app/Template/user/sessions.php b/app/Template/user/sessions.php index 67b2c8cd..eabf3672 100644 --- a/app/Template/user/sessions.php +++ b/app/Template/user/sessions.php @@ -13,7 +13,7 @@ <th><?= t('User agent') ?></th> <th class="column-10"><?= t('Action') ?></th> </tr> - <?php foreach($sessions as $session): ?> + <?php foreach ($sessions as $session): ?> <tr> <td><?= dt('%B %e, %Y at %k:%M %p', $session['date_creation']) ?></td> <td><?= dt('%B %e, %Y at %k:%M %p', $session['expiration']) ?></td> diff --git a/app/common.php b/app/common.php index 33e45f0d..85a2b7d2 100644 --- a/app/common.php +++ b/app/common.php @@ -4,7 +4,6 @@ require dirname(__DIR__) . '/vendor/autoload.php'; // Automatically parse environment configuration (Heroku) if (getenv('DATABASE_URL')) { - $dbopts = parse_url(getenv('DATABASE_URL')); define('DB_DRIVER', $dbopts['scheme']); diff --git a/doc/coding-standards.markdown b/doc/coding-standards.markdown index e0e762db..4d3db814 100644 --- a/doc/coding-standards.markdown +++ b/doc/coding-standards.markdown @@ -9,7 +9,7 @@ PHP code - Encoding: UTF-8 - Use only the opening tags `<?php` or `<?=` for templates, but **never** use `<?` - Always write PHPdoc comments for methods and class properties -- Coding style: Try to follow [PSR-1](http://www.php-fig.org/psr/psr-1/) and [PSR-2](http://www.php-fig.org/psr/psr-2/) otherwise follow the actual style. +- Coding style: [PSR-1](http://www.php-fig.org/psr/psr-1/) and [PSR-2](http://www.php-fig.org/psr/psr-2/) Javascript code --------------- diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php index 7f2db321..7576f031 100644 --- a/tests/functionals/ApiTest.php +++ b/tests/functionals/ApiTest.php @@ -10,14 +10,12 @@ class Api extends PHPUnit_Framework_TestCase { if (DB_DRIVER === 'sqlite') { @unlink(DB_FILENAME); - } - else if (DB_DRIVER === 'mysql') { + } elseif (DB_DRIVER === 'mysql') { $pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD); $pdo->exec('DROP DATABASE '.DB_NAME); $pdo->exec('CREATE DATABASE '.DB_NAME); $pdo = null; - } - else if (DB_DRIVER === 'postgres') { + } elseif (DB_DRIVER === 'postgres') { $pdo = new PDO('pgsql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD); $pdo->exec('DROP DATABASE '.DB_NAME); $pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME); @@ -1082,4 +1080,4 @@ class Api extends PHPUnit_Framework_TestCase $this->assertEquals('overdue task', $tasks[0]['title']); $this->assertEquals('API test', $tasks[0]['project_name']); } -}
\ No newline at end of file +} diff --git a/tests/functionals/UserApiTest.php b/tests/functionals/UserApiTest.php index 3abb7b28..8a80c706 100644 --- a/tests/functionals/UserApiTest.php +++ b/tests/functionals/UserApiTest.php @@ -12,14 +12,12 @@ class UserApi extends PHPUnit_Framework_TestCase { if (DB_DRIVER === 'sqlite') { @unlink(DB_FILENAME); - } - else if (DB_DRIVER === 'mysql') { + } elseif (DB_DRIVER === 'mysql') { $pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD); $pdo->exec('DROP DATABASE '.DB_NAME); $pdo->exec('CREATE DATABASE '.DB_NAME); $pdo = null; - } - else if (DB_DRIVER === 'postgres') { + } elseif (DB_DRIVER === 'postgres') { $pdo = new PDO('pgsql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD); $pdo->exec('DROP DATABASE '.DB_NAME); $pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME); diff --git a/tests/units/Action/TaskEmailTest.php b/tests/units/Action/TaskEmailTest.php index 863e5677..404865f4 100644 --- a/tests/units/Action/TaskEmailTest.php +++ b/tests/units/Action/TaskEmailTest.php @@ -147,4 +147,4 @@ class TaskEmailTest extends Base // Our event should be executed $this->assertTrue($action->execute(new GenericEvent($event))); } -}
\ No newline at end of file +} diff --git a/tests/units/Base.php b/tests/units/Base.php index fe054344..4a5b303f 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -65,8 +65,7 @@ abstract class Base extends PHPUnit_Framework_TestCase $pdo->exec('DROP DATABASE '.DB_NAME); $pdo->exec('CREATE DATABASE '.DB_NAME); $pdo = null; - } - else if (DB_DRIVER === 'postgres') { + } elseif (DB_DRIVER === 'postgres') { $pdo = new PDO('pgsql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD); $pdo->exec('DROP DATABASE '.DB_NAME); $pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME); diff --git a/tests/units/Core/Plugin/HookTest.php b/tests/units/Core/Plugin/HookTest.php index 8b771697..d1c139b3 100644 --- a/tests/units/Core/Plugin/HookTest.php +++ b/tests/units/Core/Plugin/HookTest.php @@ -42,11 +42,11 @@ class HookTest extends Base $values = array('A', 'B'); $expected = array('A', 'B', 'c', 'D'); - $h->on('myhook', function($p) { + $h->on('myhook', function ($p) { return array($p); }); - $h->on('myhook', function() { + $h->on('myhook', function () { return array('D'); }); @@ -61,7 +61,7 @@ class HookTest extends Base $values = array('A', 'B'); $expected = array('A', 'B'); - $h->on('myhook', function() { + $h->on('myhook', function () { return 'string'; }); @@ -82,11 +82,11 @@ class HookTest extends Base { $h = new Hook; - $h->on('myhook', function($p) { + $h->on('myhook', function ($p) { return $p + 1; }); - $h->on('myhook', function($p) { + $h->on('myhook', function ($p) { return $p; }); diff --git a/tests/units/Integration/BitbucketWebhookTest.php b/tests/units/Integration/BitbucketWebhookTest.php index 66d65d37..1a3b005b 100644 --- a/tests/units/Integration/BitbucketWebhookTest.php +++ b/tests/units/Integration/BitbucketWebhookTest.php @@ -248,7 +248,7 @@ class BitbucketWebhookTest extends Base public function testIssueAssignedWithNoPermission() { - $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, function() {}); + $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, function () {}); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'foobar'))); @@ -272,7 +272,7 @@ class BitbucketWebhookTest extends Base public function testIssueAssignedWithNoUser() { - $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, function() {}); + $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, function () {}); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'foobar'))); @@ -293,7 +293,7 @@ class BitbucketWebhookTest extends Base public function testIssueAssignedWithNoTask() { - $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, function() {}); + $this->container['dispatcher']->addListener(BitbucketWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE, function () {}); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'foobar'))); diff --git a/tests/units/Locale/LocaleTest.php b/tests/units/Locale/LocaleTest.php index 6cace0d5..976dfc58 100644 --- a/tests/units/Locale/LocaleTest.php +++ b/tests/units/Locale/LocaleTest.php @@ -6,21 +6,19 @@ class LocaleTest extends Base { public function testLocales() { - foreach(glob('app/Locale/*') as $file) { - + foreach (glob('app/Locale/*') as $file) { $locale = require($file . '/translations.php'); - foreach($locale as $k => $v) { - - if (strpos($k,'%B %e, %Y') !== false) { + foreach ($locale as $k => $v) { + if (strpos($k, '%B %e, %Y') !== false) { continue; } - if (strpos($k,'%b %e, %Y') !== false) { + if (strpos($k, '%b %e, %Y') !== false) { continue; } - foreach(array('%s', '%d') as $placeholder) { + foreach (array('%s', '%d') as $placeholder) { $this->assertEquals( substr_count($k, $placeholder), substr_count($v, $placeholder), diff --git a/tests/units/Model/SubtaskTest.php b/tests/units/Model/SubtaskTest.php index ba57ab01..04b274cc 100644 --- a/tests/units/Model/SubtaskTest.php +++ b/tests/units/Model/SubtaskTest.php @@ -11,7 +11,7 @@ use Kanboard\Model\User; use Kanboard\Core\Session; use Kanboard\Model\UserSession; -class SubTaskTest extends Base +class SubtaskTest extends Base { public function onSubtaskCreated($event) { diff --git a/tests/units/Model/TaskCreationTest.php b/tests/units/Model/TaskCreationTest.php index ea0d32e6..d76937b2 100644 --- a/tests/units/Model/TaskCreationTest.php +++ b/tests/units/Model/TaskCreationTest.php @@ -28,8 +28,8 @@ class TaskCreationTest extends Base $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function() {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function() {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(0, $tc->create(array('title' => 'test', 'project_id' => 0))); @@ -45,8 +45,8 @@ class TaskCreationTest extends Base $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function() {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function() {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1))); @@ -68,7 +68,7 @@ class TaskCreationTest extends Base $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function() {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); $this->container['dispatcher']->addListener(Task::EVENT_CREATE, array($this, 'onCreate')); $this->assertEquals(1, $p->create(array('name' => 'test'))); diff --git a/tests/units/Model/TaskDuplicationTest.php b/tests/units/Model/TaskDuplicationTest.php index 95c39308..5273928c 100644 --- a/tests/units/Model/TaskDuplicationTest.php +++ b/tests/units/Model/TaskDuplicationTest.php @@ -75,8 +75,8 @@ class TaskDuplicationTest extends Base $this->assertEquals(2, $task['category_id']); $this->assertEquals(4.4, $task['time_spent']); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function() {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function() {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); // We duplicate our task $this->assertEquals(2, $td->duplicate(1)); @@ -117,8 +117,8 @@ class TaskDuplicationTest extends Base // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1))); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function() {}); - $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function() {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function () {}); // We duplicate our task to the 2nd project $this->assertEquals(2, $td->duplicateToProject(1, 2)); diff --git a/tests/units/Model/TaskExportTest.php b/tests/units/Model/TaskExportTest.php index f7f8e2eb..40b3a5a2 100644 --- a/tests/units/Model/TaskExportTest.php +++ b/tests/units/Model/TaskExportTest.php @@ -30,7 +30,6 @@ class TaskExportTest extends Base $this->assertNotFalse($c->create(array('name' => 'Category #3', 'project_id' => 1))); for ($i = 1; $i <= 100; $i++) { - $task = array( 'title' => 'Task #'.$i, 'project_id' => 1, diff --git a/tests/units/Model/TaskPositionTest.php b/tests/units/Model/TaskPositionTest.php index d1838d52..42612f44 100644 --- a/tests/units/Model/TaskPositionTest.php +++ b/tests/units/Model/TaskPositionTest.php @@ -272,9 +272,7 @@ class TaskPositionTest extends Base $task_per_column = 5; foreach (array(1, 2, 3, 4) as $column_id) { - for ($i = 1; $i <= $task_per_column; $i++, $counter++) { - $task = array( 'title' => 'Task #'.$i.'-'.$column_id, 'project_id' => 1, |