Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Gieling <github@dartcafe.de>2020-09-03 15:51:03 +0300
committerGitHub <noreply@github.com>2020-09-03 15:51:03 +0300
commitc72e917f10ca25c691813e191ebec90b7da88d92 (patch)
tree14d8de58d7850ac9fbdaef2e59df1d1cfa636c85
parent9692c2669541f6c1c444e074c4354f8b0fa4c583 (diff)
parent9d857c93d69d39ac46902552c5bc282801af537b (diff)
Merge pull request #1075 from nextcloud/php-cs-fixer
adding linter actions
-rw-r--r--.github/workflows/app-code-check.yml30
-rw-r--r--.github/workflows/lint.yml61
-rw-r--r--.php_cs.cache1
-rw-r--r--.php_cs.dist20
-rw-r--r--composer.json7
-rw-r--r--lib/AppInfo/Application.php3
-rw-r--r--lib/Controller/CommentApiController.php5
-rw-r--r--lib/Controller/CommentController.php4
-rw-r--r--lib/Controller/OptionApiController.php1
-rw-r--r--lib/Controller/OptionController.php3
-rw-r--r--lib/Controller/PageController.php6
-rw-r--r--lib/Controller/PollApiController.php350
-rw-r--r--lib/Controller/PollController.php55
-rw-r--r--lib/Controller/PreferencesController.php7
-rw-r--r--lib/Controller/ShareApiController.php2
-rw-r--r--lib/Controller/ShareController.php17
-rw-r--r--lib/Controller/SubscriptionApiController.php1
-rw-r--r--lib/Controller/SubscriptionController.php1
-rw-r--r--lib/Controller/SystemController.php48
-rw-r--r--lib/Controller/VoteApiController.php2
-rw-r--r--lib/Controller/VoteController.php4
-rw-r--r--lib/Db/Comment.php1
-rw-r--r--lib/Db/CommentMapper.php4
-rw-r--r--lib/Db/LogMapper.php17
-rw-r--r--lib/Db/Option.php5
-rw-r--r--lib/Db/OptionMapper.php6
-rw-r--r--lib/Db/Poll.php3
-rw-r--r--lib/Db/PollMapper.php4
-rw-r--r--lib/Db/Preferences.php2
-rw-r--r--lib/Db/PreferencesMapper.php1
-rw-r--r--lib/Db/Share.php3
-rw-r--r--lib/Db/ShareMapper.php5
-rw-r--r--lib/Db/SubscriptionMapper.php43
-rw-r--r--lib/Db/Vote.php2
-rw-r--r--lib/Db/VoteMapper.php6
-rw-r--r--lib/Exceptions/BadRequestException.php1
-rw-r--r--lib/Exceptions/DuplicateEntryException.php1
-rw-r--r--lib/Exceptions/EmptyTitleException.php1
-rw-r--r--lib/Exceptions/InvalidAccessException.php1
-rw-r--r--lib/Exceptions/InvalidPollTypeException.php1
-rw-r--r--lib/Exceptions/InvalidShareType.php1
-rw-r--r--lib/Exceptions/InvalidShowResultsException.php1
-rw-r--r--lib/Exceptions/InvalidUsername.php1
-rw-r--r--lib/Exceptions/NotAuthorizedException.php1
-rw-r--r--lib/Exceptions/TooShortException.php1
-rw-r--r--lib/Exceptions/UsernameInvalidException.php1
-rw-r--r--lib/Migration/Version0009Date20181125051900.php3
-rw-r--r--lib/Migration/Version0009Date20181125061900.php3
-rw-r--r--lib/Migration/Version0010Date20191227063812.php3
-rw-r--r--lib/Migration/Version0010Date20200119101800.php2
-rw-r--r--lib/Migration/Version0101Date20200122194300.php1
-rw-r--r--lib/Migration/Version0103Date20200130171244.php1
-rw-r--r--lib/Migration/Version0104Date20200205104800.php1
-rw-r--r--lib/Migration/Version0104Date20200314074611.php1
-rw-r--r--lib/Migration/Version0105Date20200508211943.php1
-rw-r--r--lib/Migration/Version0105Date20200523142076.php1
-rw-r--r--lib/Migration/Version0105Date20200704084037.php1
-rw-r--r--lib/Model/Acl.php17
-rw-r--r--lib/Service/AnonymizeService.php6
-rw-r--r--lib/Service/CalendarService.php6
-rw-r--r--lib/Service/CommentService.php9
-rw-r--r--lib/Service/LogService.php2
-rw-r--r--lib/Service/MailService.php71
-rw-r--r--lib/Service/OptionService.php19
-rw-r--r--lib/Service/PollService.php65
-rw-r--r--lib/Service/ShareService.php9
-rw-r--r--lib/Service/SubscriptionService.php7
-rw-r--r--lib/Service/SystemService.php124
-rw-r--r--lib/Service/VoteService.php8
-rw-r--r--templates/no.acc.tmpl.php35
-rw-r--r--templates/no.create.tmpl.php35
-rw-r--r--templates/no.delete.tmpl.php35
72 files changed, 477 insertions, 730 deletions
diff --git a/.github/workflows/app-code-check.yml b/.github/workflows/app-code-check.yml
deleted file mode 100644
index 9e7b0e36..00000000
--- a/.github/workflows/app-code-check.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-name: PHP AppCode Check
-
-on:
- pull_request:
- push:
-
-jobs:
- unit-tests:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- php-versions: ['7.2', '7.3', '7.4']
- nextcloud-versions: ['master']
- name: AppCode check
- steps:
- - name: Set up php${{ matrix.php-versions }}
- uses: shivammathur/setup-php@master
- with:
- php-version: ${{ matrix.php-versions }}
- extensions: ctype,curl,dom,gd,iconv,intl,json,mbstring,openssl,posix,sqlite,xml,zip
- coverage: xdebug
- - name: Checkout Nextcloud
- run: git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.nextcloud-versions }} nextcloud
- - name: Checkout
- uses: actions/checkout@master
- with:
- path: nextcloud/apps/polls
- - name: App Code check
- working-directory: nextcloud
- run: php occ app:check-code polls
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index d2bf8786..50856af7 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -8,19 +8,70 @@ on:
- stable*
jobs:
+ php-cs-fixer:
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ php-versions: [7.4]
+
+ name: php-cs
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@master
+ - name: Set up php
+ uses: shivammathur/setup-php@master
+ with:
+ php-version: ${{ matrix.php-versions }}
+ coverage: none
+ - name: Install dependencies
+ run: composer i
+ - name: Run coding standards check
+ run: composer run cs:check
+
+ app-code-check:
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ php-versions: ['7.2', '7.3', '7.4']
+ nextcloud-versions: ['master']
+
+ name: Nextcloud AppCode check
+
+ steps:
+ - name: Set up php ${{ matrix.php-versions }}
+ uses: shivammathur/setup-php@master
+ with:
+ php-version: ${{ matrix.php-versions }}
+ extensions: ctype,curl,dom,gd,iconv,intl,json,mbstring,openssl,posix,sqlite,xml,zip
+ coverage: xdebug
+ - name: Checkout Nextcloud ${{ matrix.nextcloud-versions }}
+ run: git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.nextcloud-versions }} nextcloud
+ - name: Run tests
+ run: php -f nextcloud/occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database sqlite --database-pass=''
+ - name: Checkout
+ uses: actions/checkout@master
+ with:
+ path: nextcloud/apps/mail
+ - name: Run tests
+ run: php -f nextcloud/occ app:check-code mail
+
node:
runs-on: ubuntu-latest
strategy:
matrix:
- node-version: [12.x]
+ node-versions: [12.x]
+ name: eslint node ${{ matrix.node-versions }}
steps:
- uses: actions/checkout@v2
- - name: Use node ${{ matrix.node-version }}
+ - name: Use node ${{ matrix.node-versions }}
uses: actions/setup-node@v1
with:
- node-version: ${{ matrix.node-version }}
+ node-version: ${{ matrix.node-versions }}
- name: Install dependencies
run: npm ci
- name: ESLint
@@ -33,14 +84,14 @@ jobs:
matrix:
node-versions: [12.x]
- name: stylelint node${{ matrix.node-versions }}
+ name: stylelint node ${{ matrix.node-versions }}
steps:
- uses: actions/checkout@v2
- name: Set up node ${{ matrix.node-versions }}
uses: actions/setup-node@v1
with:
- node-versions: ${{ matrix.node-versions }}
+ node-version: ${{ matrix.node-versions }}
- name: Install dependencies
run: npm ci
diff --git a/.php_cs.cache b/.php_cs.cache
new file mode 100644
index 00000000..1754ff05
--- /dev/null
+++ b/.php_cs.cache
@@ -0,0 +1 @@
+{"php":"7.4.0","version":"2.16.4:v2.16.4#1023c3458137ab052f6ff1e09621a721bfdeca13","indent":"\t","lineEnding":"\n","rules":{"encoding":true,"full_opening_tag":true,"blank_line_after_namespace":true,"braces":{"position_after_anonymous_constructs":"same","position_after_control_structures":"same","position_after_functions_and_oop_constructs":"same"},"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":{"closure_function_spacing":"one"},"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["property","method","const"]},"align_multiline_comment":true,"array_indentation":true,"array_syntax":{"syntax":"short"},"blank_line_after_opening_tag":true,"no_unused_imports":true},"hashes":{"appinfo\\app.php":4283614092,"appinfo\\routes.php":3617738371,"lib\\AppInfo\\Application.php":411266802,"lib\\Controller\\CommentApiController.php":1838790110,"lib\\Controller\\CommentController.php":287678435,"lib\\Controller\\OptionApiController.php":2650695611,"lib\\Controller\\OptionController.php":2698193769,"lib\\Controller\\PageController.php":11149671,"lib\\Controller\\PollApiController.php":4095357940,"lib\\Controller\\PollController.php":1361836821,"lib\\Controller\\PreferencesController.php":1840456828,"lib\\Controller\\ShareApiController.php":2735054074,"lib\\Controller\\ShareController.php":233260947,"lib\\Controller\\SubscriptionApiController.php":3668344078,"lib\\Controller\\SubscriptionController.php":524411373,"lib\\Controller\\SystemController.php":3151042459,"lib\\Controller\\VoteApiController.php":1304499129,"lib\\Controller\\VoteController.php":184787363,"lib\\Cron\\NotificationCron.php":838078031,"lib\\Db\\Comment.php":959534501,"lib\\Db\\CommentMapper.php":488598168,"lib\\Db\\Log.php":467194659,"lib\\Db\\LogMapper.php":731748838,"lib\\Db\\Model.php":1330893510,"lib\\Db\\Option.php":2758206078,"lib\\Db\\OptionMapper.php":2284493626,"lib\\Db\\Poll.php":939114063,"lib\\Db\\PollMapper.php":2726539906,"lib\\Db\\Preferences.php":487756418,"lib\\Db\\PreferencesMapper.php":1210335778,"lib\\Db\\Share.php":557090163,"lib\\Db\\ShareMapper.php":1787427060,"lib\\Db\\Subscription.php":3070850601,"lib\\Db\\SubscriptionMapper.php":184823745,"lib\\Db\\Vote.php":3309199093,"lib\\Db\\VoteMapper.php":2790557761,"lib\\Exceptions\\BadRequestException.php":931432988,"lib\\Exceptions\\DuplicateEntryException.php":2830273467,"lib\\Exceptions\\EmptyTitleException.php":203360807,"lib\\Exceptions\\InvalidAccessException.php":4252219543,"lib\\Exceptions\\InvalidPollTypeException.php":3622042486,"lib\\Exceptions\\InvalidShareType.php":4082190273,"lib\\Exceptions\\InvalidShowResultsException.php":3964362423,"lib\\Exceptions\\InvalidUsername.php":1047919438,"lib\\Exceptions\\NotAuthorizedException.php":1965389984,"lib\\Exceptions\\TooShortException.php":2602737521,"lib\\Exceptions\\UsernameInvalidException.php":4100052390,"lib\\Migration\\Version0009Date20181125051900.php":2716070538,"lib\\Migration\\Version0009Date20181125061900.php":456303295,"lib\\Migration\\Version0009Date20181125062101.php":1154618823,"lib\\Migration\\Version0010Date20191227063812.php":3640377530,"lib\\Migration\\Version0010Date20200119101800.php":3182457632,"lib\\Migration\\Version0101Date20200122194300.php":53872911,"lib\\Migration\\Version0103Date20200130171244.php":1626697525,"lib\\Migration\\Version0104Date20200314074611.php":2104864045,"lib\\Migration\\Version0105Date20200508211943.php":1730649166,"lib\\Migration\\Version0105Date20200523142076.php":2138369535,"lib\\Migration\\Version0105Date20200704084037.php":2068223771,"lib\\Model\\Acl.php":531907010,"lib\\Service\\AnonymizeService.php":3550297122,"lib\\Service\\CalendarService.php":4272559832,"lib\\Service\\CommentService.php":2389208710,"lib\\Service\\LogService.php":2444693224,"lib\\Service\\MailService.php":2918803077,"lib\\Service\\OptionService.php":426529911,"lib\\Service\\PollService.php":655181538,"lib\\Service\\ShareService.php":1935252203,"lib\\Service\\SubscriptionService.php":2286544594,"lib\\Service\\SystemService.php":3406319590,"lib\\Service\\VoteService.php":1188112376,"templates\\no.acc.tmpl.php":1888867333,"templates\\no.create.tmpl.php":3752463492,"templates\\no.delete.tmpl.php":2661558614,"templates\\polls.tmpl.php":1217523484,"tests\\bootstrap.php":664542409,"tests\\Integration\\AppTest.php":612480562,"tests\\Unit\\Controller\\PageControllerTest.php":2027037139,"tests\\Unit\\Db\\CommentMapperTest.php":1274084391,"tests\\Unit\\Db\\OptionMapperTest.php":2678593446,"tests\\Unit\\Db\\PollMapperTest.php":477639475,"tests\\Unit\\Db\\SubscriptionMapperTest.php":3615283060,"tests\\Unit\\Db\\VoteMapperTest.php":4124754083,"tests\\Unit\\Factories\\CommentFactory.php":3727902913,"tests\\Unit\\Factories\\OptionFactory.php":2125760214,"tests\\Unit\\Factories\\PollFactory.php":3091987037,"tests\\Unit\\Factories\\SubscriptionFactory.php":2949916965,"tests\\Unit\\Factories\\VoteFactory.php":1537210955,"tests\\Unit\\FactoryMuffin.php":3610827030,"tests\\Unit\\UnitTestCase.php":604954648,"lib\\Migration\\Version0104Date20200205104800.php":952822163}} \ No newline at end of file
diff --git a/.php_cs.dist b/.php_cs.dist
new file mode 100644
index 00000000..71fd5690
--- /dev/null
+++ b/.php_cs.dist
@@ -0,0 +1,20 @@
+<?php
+
+declare(strict_types=1);
+
+require_once './vendor/autoload.php';
+
+use Nextcloud\CodingStandard\Config;
+
+$config = new Config();
+$config
+ ->getFinder()
+ ->ignoreVCSIgnored(true)
+ ->notPath('build')
+ ->notPath('l10n')
+ ->notPath('lib/Vendor')
+ ->notPath('src')
+ ->notPath('vendor')
+ ->notPath('tests')
+ ->in(__DIR__);
+return $config;
diff --git a/composer.json b/composer.json
index 28f48e26..d1bf68de 100644
--- a/composer.json
+++ b/composer.json
@@ -27,6 +27,11 @@
"christophwurst/nextcloud": "^18.0",
"phpunit/phpunit": "^8.2",
"league/factory-muffin": "^3.0",
- "league/factory-muffin-faker": "^2.0"
+ "league/factory-muffin-faker": "^2.0",
+ "nextcloud/coding-standard": "^0.3.0"
+ },
+ "scripts": {
+ "cs:check": "php-cs-fixer fix --dry-run --diff",
+ "cs:fix": "php-cs-fixer fix"
}
}
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 53922944..1f27607b 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -24,7 +24,6 @@
namespace OCA\Polls\AppInfo;
use OCP\AppFramework\App;
-use OCP\IContainer;
class Application extends App {
@@ -41,7 +40,7 @@ class Application extends App {
*/
public function registerNavigationEntry() {
$container = $this->getContainer();
- $container->query('OCP\INavigationManager')->add(function() use ($container) {
+ $container->query('OCP\INavigationManager')->add(function () use ($container) {
$urlGenerator = $container->query('OCP\IURLGenerator');
$l10n = $container->query('OCP\IL10N');
return [
diff --git a/lib/Controller/CommentApiController.php b/lib/Controller/CommentApiController.php
index e9b8c310..f94c9f3e 100644
--- a/lib/Controller/CommentApiController.php
+++ b/lib/Controller/CommentApiController.php
@@ -23,20 +23,16 @@
namespace OCA\Polls\Controller;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCP\IRequest;
-use OCP\IURLGenerator;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCA\Polls\Service\CommentService;
-
-
class CommentApiController extends ApiController {
/** @var CommentService */
@@ -116,5 +112,4 @@ class CommentApiController extends ApiController {
return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
}
}
-
}
diff --git a/lib/Controller/CommentController.php b/lib/Controller/CommentController.php
index d68d875e..662b170c 100644
--- a/lib/Controller/CommentController.php
+++ b/lib/Controller/CommentController.php
@@ -34,8 +34,6 @@ use OCP\AppFramework\Http\DataResponse;
use OCA\Polls\Service\CommentService;
-
-
class CommentController extends Controller {
/** @var CommentService */
@@ -101,7 +99,5 @@ class CommentController extends Controller {
} catch (DoesNotExistException $e) {
return new DataResponse($e, Http::STATUS_OK);
}
-
}
-
}
diff --git a/lib/Controller/OptionApiController.php b/lib/Controller/OptionApiController.php
index 5183f9fe..1e7994c4 100644
--- a/lib/Controller/OptionApiController.php
+++ b/lib/Controller/OptionApiController.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Controller;
-use \Exception;
use \Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
diff --git a/lib/Controller/OptionController.php b/lib/Controller/OptionController.php
index b523326b..44ddd1fa 100644
--- a/lib/Controller/OptionController.php
+++ b/lib/Controller/OptionController.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Controller;
use DateTime;
use DateInterval;
-use Exception;
use OCA\Polls\Exceptions\DuplicateEntryException;
use OCP\IRequest;
@@ -36,7 +35,6 @@ use OCP\AppFramework\Http\DataResponse;
use OCA\Polls\Service\OptionService;
use OCA\Polls\Service\CalendarService;
-
class OptionController extends Controller {
/** @var OptionService */
@@ -149,7 +147,6 @@ class OptionController extends Controller {
* @return DataResponse
*/
public function findCalendarEvents($optionId) {
-
$searchFrom = new DateTime();
$searchFrom = $searchFrom->setTimestamp($this->optionService->get($optionId)->getTimestamp())->sub(new DateInterval('PT1H'));
$searchTo = clone $searchFrom;
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 587a4184..63321187 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -27,10 +27,6 @@ namespace OCA\Polls\Controller;
use OCP\IRequest;
use OCP\AppFramework\Controller;
-use OCP\AppFramework\Db\DoesNotExistException;
-use OCP\AppFramework\Http\ContentSecurityPolicy;
-use OCP\AppFramework\Http\JSONResponse;
-use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
use OCP\IURLGenerator;
@@ -79,7 +75,5 @@ class PageController extends Controller {
return new PublicTemplateResponse('polls', 'polls.tmpl', [
'urlGenerator' => $this->urlGenerator]);
}
-
}
-
}
diff --git a/lib/Controller/PollApiController.php b/lib/Controller/PollApiController.php
index c9cdc174..e0a92ed6 100644
--- a/lib/Controller/PollApiController.php
+++ b/lib/Controller/PollApiController.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Controller;
- use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\EmptyTitleException;
use OCA\Polls\Exceptions\InvalidAccessException;
@@ -41,7 +40,7 @@
class PollApiController extends ApiController {
- /** @var PollService */
+ /** @var PollService */
private $pollService;
/**
@@ -52,187 +51,184 @@
*/
public function __construct(
- string $appName,
- IRequest $request,
+ string $appName,
+ IRequest $request,
PollService $pollService
- ) {
+ ) {
parent::__construct($appName, $request);
$this->pollService = $pollService;
}
- /**
- * Get list of polls
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @return DataResponse
- */
-
- public function list() {
- try {
- return new DataResponse(['polls' => $this->pollService->list()], Http::STATUS_OK);
- } catch (DoesNotExistException $e) {
- return new DataResponse([], Http::STATUS_NOT_FOUND);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
- }
-
-
- /**
- * get poll configuration
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @param int $pollId
- * @return DataResponse
- */
+ /**
+ * Get list of polls
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @return DataResponse
+ */
+
+ public function list() {
+ try {
+ return new DataResponse(['polls' => $this->pollService->list()], Http::STATUS_OK);
+ } catch (DoesNotExistException $e) {
+ return new DataResponse([], Http::STATUS_NOT_FOUND);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
+ }
+
+
+ /**
+ * get poll configuration
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @param int $pollId
+ * @return DataResponse
+ */
public function get($pollId) {
- try {
- return new DataResponse(['poll' => $this->pollService->get($pollId, '')], Http::STATUS_OK);
- } catch (DoesNotExistException $e) {
- return new DataResponse(['error' => 'Not found'], Http::STATUS_NOT_FOUND);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
+ try {
+ return new DataResponse(['poll' => $this->pollService->get($pollId, '')], Http::STATUS_OK);
+ } catch (DoesNotExistException $e) {
+ return new DataResponse(['error' => 'Not found'], Http::STATUS_NOT_FOUND);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
}
- /**
- * Add poll
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- * @param Array $poll
- * @return DataResponse
- */
-
- public function add($type, $title) {
- try {
- return new DataResponse(['poll' => $this->pollService->add($type, $title)], Http::STATUS_CREATED);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- } catch (InvalidPollTypeException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- } catch (EmptyTitleException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
- }
-
- /**
- * Update poll configuration
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @param int $pollId
- * @param array $poll
- * @return DataResponse
- */
-
- public function update($pollId, $poll) {
- try {
- return new DataResponse(['poll' => $this->pollService->update($pollId, $poll)], Http::STATUS_OK);
- } catch (DoesNotExistException $e) {
- return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- } catch (InvalidAccessException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- } catch (InvalidShowResultsException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- } catch (EmptyTitleException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
- }
-
- /**
- * Switch deleted status (move to deleted polls)
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @param int $pollId
- * @return DataResponse
- */
-
- public function trash($pollId) {
- try {
- return new DataResponse(['poll' => $this->pollService->delete($pollId)], Http::STATUS_OK);
- } catch (DoesNotExistException $e) {
- return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
- }
-
- /**
- * Delete poll
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @param int $pollId
- * @return DataResponse
- */
-
- public function delete($pollId) {
- try {
- return new DataResponse(['poll' => $this->pollService->deletePermanently($pollId)], Http::STATUS_OK);
- } catch (DoesNotExistException $e) {
- return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
-
- }
-
- /**
- * Clone poll
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @param int $pollId
- * @return DataResponse
- */
- public function clone($pollId) {
- try {
- return new DataResponse(['poll' => $this->pollService->clone($pollId)], Http::STATUS_CREATED);
- } catch (DoesNotExistException $e) {
- return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
- }
-
- /**
- * Collect email addresses from particitipants
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @param Array $poll
- * @return DataResponse
- */
-
- public function getParticipantsEmailAddresses($pollId) {
- try {
- return new DataResponse($this->pollService->getParticipantsEmailAddresses($pollId), Http::STATUS_OK);
- } catch (DoesNotExistException $e) {
- return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
- } catch (NotAuthorizedException $e) {
- return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
- }
- }
-
- /**
- * Get valid values for configuration options
- * @NoAdminRequired
- * @CORS
- * @NoCSRFRequired
- * @param Array $poll
- * @return DataResponse
- */
-
- public function enum() {
- return new DataResponse($this->pollService->getValidEnum(), Http::STATUS_OK);
- }
-
-
-}
+ /**
+ * Add poll
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ * @param Array $poll
+ * @return DataResponse
+ */
+
+ public function add($type, $title) {
+ try {
+ return new DataResponse(['poll' => $this->pollService->add($type, $title)], Http::STATUS_CREATED);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ } catch (InvalidPollTypeException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ } catch (EmptyTitleException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
+ }
+
+ /**
+ * Update poll configuration
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @param int $pollId
+ * @param array $poll
+ * @return DataResponse
+ */
+
+ public function update($pollId, $poll) {
+ try {
+ return new DataResponse(['poll' => $this->pollService->update($pollId, $poll)], Http::STATUS_OK);
+ } catch (DoesNotExistException $e) {
+ return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ } catch (InvalidAccessException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ } catch (InvalidShowResultsException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ } catch (EmptyTitleException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
+ }
+
+ /**
+ * Switch deleted status (move to deleted polls)
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @param int $pollId
+ * @return DataResponse
+ */
+
+ public function trash($pollId) {
+ try {
+ return new DataResponse(['poll' => $this->pollService->delete($pollId)], Http::STATUS_OK);
+ } catch (DoesNotExistException $e) {
+ return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
+ }
+
+ /**
+ * Delete poll
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @param int $pollId
+ * @return DataResponse
+ */
+
+ public function delete($pollId) {
+ try {
+ return new DataResponse(['poll' => $this->pollService->deletePermanently($pollId)], Http::STATUS_OK);
+ } catch (DoesNotExistException $e) {
+ return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
+ }
+
+ /**
+ * Clone poll
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @param int $pollId
+ * @return DataResponse
+ */
+ public function clone($pollId) {
+ try {
+ return new DataResponse(['poll' => $this->pollService->clone($pollId)], Http::STATUS_CREATED);
+ } catch (DoesNotExistException $e) {
+ return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
+ }
+
+ /**
+ * Collect email addresses from particitipants
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @param Array $poll
+ * @return DataResponse
+ */
+
+ public function getParticipantsEmailAddresses($pollId) {
+ try {
+ return new DataResponse($this->pollService->getParticipantsEmailAddresses($pollId), Http::STATUS_OK);
+ } catch (DoesNotExistException $e) {
+ return new DataResponse(['error' => 'Poll not found'], Http::STATUS_NOT_FOUND);
+ } catch (NotAuthorizedException $e) {
+ return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
+ }
+ }
+
+ /**
+ * Get valid values for configuration options
+ * @NoAdminRequired
+ * @CORS
+ * @NoCSRFRequired
+ * @param Array $poll
+ * @return DataResponse
+ */
+
+ public function enum() {
+ return new DataResponse($this->pollService->getValidEnum(), Http::STATUS_OK);
+ }
+ }
diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php
index 494cb59a..0357852e 100644
--- a/lib/Controller/PollController.php
+++ b/lib/Controller/PollController.php
@@ -63,35 +63,35 @@ class PollController extends Controller {
/** @var Acl */
private $acl;
- /**
- * PollController constructor.
- * @param string $appName
- * @param IRequest $request
- * @param PollService $pollService
- * @param CommentService $commentService
- * @param OptionService $optionService
- * @param ShareService $shareService
- * @param VoteService $voteService
- * @param Acl $acl
- */
-
- public function __construct(
+ /**
+ * PollController constructor.
+ * @param string $appName
+ * @param IRequest $request
+ * @param PollService $pollService
+ * @param CommentService $commentService
+ * @param OptionService $optionService
+ * @param ShareService $shareService
+ * @param VoteService $voteService
+ * @param Acl $acl
+ */
+
+ public function __construct(
string $appName,
- IRequest $request,
- PollService $pollService,
+ IRequest $request,
+ PollService $pollService,
CommentService $commentService,
- OptionService $optionService,
- ShareService $shareService,
- VoteService $voteService,
- Acl $acl
+ OptionService $optionService,
+ ShareService $shareService,
+ VoteService $voteService,
+ Acl $acl
) {
- parent::__construct($appName, $request);
+ parent::__construct($appName, $request);
$this->pollService = $pollService;
$this->commentService = $commentService;
- $this->optionService = $optionService;
- $this->shareService = $shareService;
- $this->voteService = $voteService;
- $this->acl = $acl;
+ $this->optionService = $optionService;
+ $this->shareService = $shareService;
+ $this->voteService = $voteService;
+ $this->acl = $acl;
}
@@ -120,12 +120,10 @@ class PollController extends Controller {
* @param string $token
* @return DataResponse
*/
- public function get($pollId, $token) {
-
+ public function get($pollId, $token) {
try {
$acl = $this->acl->set($pollId, $token);
$poll = $this->pollService->get($pollId, $token);
-
} catch (DoesNotExistException $e) {
return new DataResponse(['error' => 'Not found'], Http::STATUS_NOT_FOUND);
} catch (NotAuthorizedException $e) {
@@ -172,7 +170,7 @@ class PollController extends Controller {
'shares' => $shares,
'votes' => $votes,
], Http::STATUS_OK);
- }
+ }
/**
* Add poll
@@ -287,5 +285,4 @@ class PollController extends Controller {
return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
}
}
-
}
diff --git a/lib/Controller/PreferencesController.php b/lib/Controller/PreferencesController.php
index e9afb366..f0ee44ab 100644
--- a/lib/Controller/PreferencesController.php
+++ b/lib/Controller/PreferencesController.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Controller;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
@@ -32,13 +31,11 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
-use OCP\IGroupManager;
use OCA\Polls\Db\Preferences;
use OCA\Polls\Db\PreferencesMapper;
class PreferencesController extends Controller {
-
private $userId;
private $preferencesMapper;
@@ -75,13 +72,11 @@ class PreferencesController extends Controller {
* @return DataResponse
*/
public function get() {
-
try {
return new DataResponse($this->preferencesMapper->find($this->userId), Http::STATUS_OK);
} catch (DoesNotExistException $e) {
return new DataResponse($e, Http::STATUS_NOT_FOUND);
}
-
}
/**
@@ -113,7 +108,6 @@ class PreferencesController extends Controller {
}
return new DataResponse($preferences, Http::STATUS_OK);
-
}
// /**
@@ -138,5 +132,4 @@ class PreferencesController extends Controller {
// return new DataResponse(['deleted' => $userId], Http::STATUS_OK);
//
// }
-
}
diff --git a/lib/Controller/ShareApiController.php b/lib/Controller/ShareApiController.php
index 5ffe1a63..de04a5d2 100644
--- a/lib/Controller/ShareApiController.php
+++ b/lib/Controller/ShareApiController.php
@@ -26,7 +26,6 @@ namespace OCA\Polls\Controller;
use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
-use OCA\Polls\Exceptions\InvalidUsername;
use OCP\IRequest;
use OCP\AppFramework\ApiController;
@@ -121,7 +120,6 @@ class ShareApiController extends ApiController {
} catch (Exception $e) {
return new DataResponse(['error' => $e], Http::STATUS_CONFLICT);
}
-
}
/**
diff --git a/lib/Controller/ShareController.php b/lib/Controller/ShareController.php
index 39cb7a4d..c3b0527e 100644
--- a/lib/Controller/ShareController.php
+++ b/lib/Controller/ShareController.php
@@ -81,9 +81,9 @@ class ShareController extends Controller {
* @param string $userEmail
* @return DataResponse
*/
- public function add($pollId, $type, $userId = '', $userEmail = '') {
- try {
- return new DataResponse(['share' => $this->shareService->add($pollId, $type, $userId, $userEmail)], Http::STATUS_CREATED);
+ public function add($pollId, $type, $userId = '', $userEmail = '') {
+ try {
+ return new DataResponse(['share' => $this->shareService->add($pollId, $type, $userId, $userEmail)], Http::STATUS_CREATED);
} catch (NotAuthorizedException $e) {
return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
} catch (\Exception $e) {
@@ -101,9 +101,9 @@ class ShareController extends Controller {
* @param string $userEmail
* @return DataResponse
*/
- public function get($token) {
- try {
- return new DataResponse(['share' => $this->shareService->get($token)], Http::STATUS_CREATED);
+ public function get($token) {
+ try {
+ return new DataResponse(['share' => $this->shareService->get($token)], Http::STATUS_CREATED);
} catch (NotAuthorizedException $e) {
return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
} catch (\Exception $e) {
@@ -121,8 +121,8 @@ class ShareController extends Controller {
* @param string $userEmail
* @return DataResponse
*/
- public function setEmailAddress($token, $userEmail) {
- try {
+ public function setEmailAddress($token, $userEmail) {
+ try {
return new DataResponse(['share' => $this->shareService->setEmailAddress($token, $userEmail)], Http::STATUS_OK);
} catch (NotAuthorizedException $e) {
return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
@@ -143,7 +143,6 @@ class ShareController extends Controller {
* @return DataResponse
*/
public function personal($token, $userName, $emailAddress = '') {
-
try {
return new DataResponse($this->shareService->personal($token, $userName, $emailAddress), Http::STATUS_CREATED);
} catch (NotAuthorizedException $e) {
diff --git a/lib/Controller/SubscriptionApiController.php b/lib/Controller/SubscriptionApiController.php
index 84936691..b5000957 100644
--- a/lib/Controller/SubscriptionApiController.php
+++ b/lib/Controller/SubscriptionApiController.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Controller;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
diff --git a/lib/Controller/SubscriptionController.php b/lib/Controller/SubscriptionController.php
index ea1e9e49..2d9fde04 100644
--- a/lib/Controller/SubscriptionController.php
+++ b/lib/Controller/SubscriptionController.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Controller;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
diff --git a/lib/Controller/SystemController.php b/lib/Controller/SystemController.php
index 3e0a9b68..1d2c6dfb 100644
--- a/lib/Controller/SystemController.php
+++ b/lib/Controller/SystemController.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Controller;
-use Exception;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -52,27 +51,27 @@ class SystemController extends Controller {
$this->systemService = $systemService;
}
- /**
- * Get a list of users
- * @NoAdminRequired
- * @param string $query
- * @param array $skipUsers - usernames to skip in return array
- * @return DataResponse
- */
- public function getSiteUsers($query = '', $skipUsers = array()) {
- return new DataResponse(['users' => $this->systemService->getSiteUsers($query, $skipUsers)], Http::STATUS_OK);
- }
+ /**
+ * Get a list of users
+ * @NoAdminRequired
+ * @param string $query
+ * @param array $skipUsers - usernames to skip in return array
+ * @return DataResponse
+ */
+ public function getSiteUsers($query = '', $skipUsers = []) {
+ return new DataResponse(['users' => $this->systemService->getSiteUsers($query, $skipUsers)], Http::STATUS_OK);
+ }
- /**
- * Get a list of user groups
- * @NoAdminRequired
- * @param string $query
- * @param array $skipGroups - group names to skip in return array
- * @return DataResponse
- */
- public function getSiteGroups($query = '', $skipGroups = array()) {
- return new DataResponse(['groups' => $this->systemService->getSiteGroups($query, $skipGroups)], Http::STATUS_OK);
- }
+ /**
+ * Get a list of user groups
+ * @NoAdminRequired
+ * @param string $query
+ * @param array $skipGroups - group names to skip in return array
+ * @return DataResponse
+ */
+ public function getSiteGroups($query = '', $skipGroups = []) {
+ return new DataResponse(['groups' => $this->systemService->getSiteGroups($query, $skipGroups)], Http::STATUS_OK);
+ }
/**
* Get a list of contacts
@@ -114,11 +113,11 @@ class SystemController extends Controller {
$getContacts = true,
$getContactGroups = true,
$getMail = false,
- $skipGroups = array(),
- $skipUsers = array()
+ $skipGroups = [],
+ $skipUsers = []
) {
return new DataResponse(['siteusers' => $this->systemService->getSiteUsersAndGroups(
- $query, $getGroups, $getUsers, $getContacts, $getContactGroups, $getMail, $skipGroups, $skipUsers )], Http::STATUS_OK);
+ $query, $getGroups, $getUsers, $getContacts, $getContactGroups, $getMail, $skipGroups, $skipUsers)], Http::STATUS_OK);
}
/**
@@ -132,5 +131,4 @@ class SystemController extends Controller {
public function validatePublicUsername($pollId, $userName, $token) {
return new DataResponse(['result' => $this->systemService->validatePublicUsername($pollId, $userName, $token), 'name' => $userName], Http::STATUS_OK);
}
-
}
diff --git a/lib/Controller/VoteApiController.php b/lib/Controller/VoteApiController.php
index 28b1eded..5528ce30 100644
--- a/lib/Controller/VoteApiController.php
+++ b/lib/Controller/VoteApiController.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Controller;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
@@ -93,6 +92,5 @@ class VoteApiController extends ApiController {
} catch (NotAuthorizedException $e) {
return new DataResponse(['error' => $e->getMessage()], $e->getStatus());
}
-
}
}
diff --git a/lib/Controller/VoteController.php b/lib/Controller/VoteController.php
index e8a75eec..02db1278 100644
--- a/lib/Controller/VoteController.php
+++ b/lib/Controller/VoteController.php
@@ -34,7 +34,6 @@ use OCP\AppFramework\Http\DataResponse;
use OCA\Polls\Service\VoteService;
-
class VoteController extends Controller {
/** @var VoteService */
@@ -127,7 +126,6 @@ class VoteController extends Controller {
} catch (DoesNotExistException $e) {
return new DataResponse(['error' => 'Option not found'], Http::STATUS_NOT_FOUND);
}
-
}
/**
@@ -145,7 +143,5 @@ class VoteController extends Controller {
} catch (DoesNotExistException $e) {
return new DataResponse(['error' => 'No votes'], Http::STATUS_NOT_FOUND);
}
-
}
-
}
diff --git a/lib/Db/Comment.php b/lib/Db/Comment.php
index 4165996f..0a9fe955 100644
--- a/lib/Db/Comment.php
+++ b/lib/Db/Comment.php
@@ -94,5 +94,4 @@ class Comment extends Entity implements JsonSerializable {
private function externalUser() {
return (!\OC::$server->getUserManager()->get($this->userId) instanceof IUser);
}
-
}
diff --git a/lib/Db/CommentMapper.php b/lib/Db/CommentMapper.php
index 93da02ae..43663d87 100644
--- a/lib/Db/CommentMapper.php
+++ b/lib/Db/CommentMapper.php
@@ -86,7 +86,7 @@ class CommentMapper extends QBMapper {
$qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
);
- $qb->execute();
+ $qb->execute();
}
/**
@@ -100,6 +100,6 @@ class CommentMapper extends QBMapper {
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
);
- $qb->execute();
+ $qb->execute();
}
}
diff --git a/lib/Db/LogMapper.php b/lib/Db/LogMapper.php
index 88f755c6..ba01beb6 100644
--- a/lib/Db/LogMapper.php
+++ b/lib/Db/LogMapper.php
@@ -4,7 +4,7 @@
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -44,11 +44,10 @@ class LogMapper extends QBMapper {
$qb->select('*')
->from($this->getTableName())
->where(
- $qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
- );
+ $qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
+ );
return $this->findEntities($qb);
-
}
public function findUnprocessed() {
@@ -57,11 +56,10 @@ class LogMapper extends QBMapper {
$qb->select('*')
->from($this->getTableName())
->where(
- $qb->expr()->eq('processed', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))
- );
+ $qb->expr()->eq('processed', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))
+ );
return $this->findEntities($qb);
-
}
public function findUnprocessedPolls() {
@@ -71,7 +69,6 @@ class LogMapper extends QBMapper {
->from($this->getTableName())
->where($qb->expr()->eq('processed', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)));
return $this->findEntities($qb);
-
}
public function getLastRecord($pollId) {
@@ -84,9 +81,5 @@ class LogMapper extends QBMapper {
->orderBy('id', 'DESC');
return $this->findEntity($qb);
-
}
-
-
-
}
diff --git a/lib/Db/Option.php b/lib/Db/Option.php
index d02f167e..f3c8bd7a 100644
--- a/lib/Db/Option.php
+++ b/lib/Db/Option.php
@@ -5,7 +5,7 @@
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author Kai Schröer <git@schroeer.co>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -83,14 +83,13 @@ class Option extends Entity implements JsonSerializable {
'rank' => 0,
'votes' => 0,
];
-
}
/**
* Temporary fix
* Make sure, order is eqal to timestamp in date polls
*/
- // TODO: remove by time
+ // TODO: remove by time
private function orderCorrection($timestamp, $order) {
if ($timestamp) {
return $timestamp;
diff --git a/lib/Db/OptionMapper.php b/lib/Db/OptionMapper.php
index 3044c90c..0cdd8a0a 100644
--- a/lib/Db/OptionMapper.php
+++ b/lib/Db/OptionMapper.php
@@ -4,7 +4,7 @@
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -108,7 +108,7 @@ class OptionMapper extends QBMapper {
$qb->expr()->eq('id', $qb->createNamedParameter($optionId, IQueryBuilder::PARAM_INT))
);
- $qb->execute();
+ $qb->execute();
}
/**
@@ -122,6 +122,6 @@ class OptionMapper extends QBMapper {
$qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
);
- $qb->execute();
+ $qb->execute();
}
}
diff --git a/lib/Db/Poll.php b/lib/Db/Poll.php
index 5674d0f3..7a6b064d 100644
--- a/lib/Db/Poll.php
+++ b/lib/Db/Poll.php
@@ -5,7 +5,7 @@
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author Kai Schröer <git@schroeer.co>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -150,7 +150,6 @@ class Poll extends Entity implements JsonSerializable {
}
private function getDisplayName() {
-
if (\OC::$server->getUserManager()->get($this->owner) instanceof IUser) {
return \OC::$server->getUserManager()->get($this->owner)->getDisplayName();
} else {
diff --git a/lib/Db/PollMapper.php b/lib/Db/PollMapper.php
index 4938c749..586985b0 100644
--- a/lib/Db/PollMapper.php
+++ b/lib/Db/PollMapper.php
@@ -4,7 +4,7 @@
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -27,7 +27,6 @@ namespace OCA\Polls\Db;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\AppFramework\Db\QBMapper;
-use \OCP\AppFramework\Db\DoesNotExistException;
class PollMapper extends QBMapper {
@@ -69,5 +68,4 @@ class PollMapper extends QBMapper {
return $this->findEntities($qb);
}
-
}
diff --git a/lib/Db/Preferences.php b/lib/Db/Preferences.php
index 670260a3..3c68f398 100644
--- a/lib/Db/Preferences.php
+++ b/lib/Db/Preferences.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Db;
use JsonSerializable;
-use OCP\IUser;
use OCP\AppFramework\Db\Entity;
/**
@@ -50,7 +49,6 @@ class Preferences extends Entity implements JsonSerializable {
protected $preferences;
public function jsonSerialize() {
-
return [
'id' => intval($this->id),
'userId' => $this->userId,
diff --git a/lib/Db/PreferencesMapper.php b/lib/Db/PreferencesMapper.php
index b4d81a98..651e46d4 100644
--- a/lib/Db/PreferencesMapper.php
+++ b/lib/Db/PreferencesMapper.php
@@ -70,5 +70,4 @@ class PreferencesMapper extends QBMapper {
//
// $qb->execute();
// }
-
}
diff --git a/lib/Db/Share.php b/lib/Db/Share.php
index 84ae4ea2..ecc5da1d 100644
--- a/lib/Db/Share.php
+++ b/lib/Db/Share.php
@@ -65,7 +65,6 @@ class Share extends Entity implements JsonSerializable {
protected $invitationSent;
public function jsonSerialize() {
-
return [
'id' => intval($this->id),
'token' => $this->token,
@@ -80,7 +79,6 @@ class Share extends Entity implements JsonSerializable {
}
private function getDisplayName() {
-
if (\OC::$server->getUserManager()->get($this->userId) instanceof IUser) {
return \OC::$server->getUserManager()->get($this->userId)->getDisplayName();
} else {
@@ -91,5 +89,4 @@ class Share extends Entity implements JsonSerializable {
private function externalUser() {
return (!\OC::$server->getUserManager()->get($this->userId) instanceof IUser);
}
-
}
diff --git a/lib/Db/ShareMapper.php b/lib/Db/ShareMapper.php
index 87df1051..f1e56727 100644
--- a/lib/Db/ShareMapper.php
+++ b/lib/Db/ShareMapper.php
@@ -121,7 +121,7 @@ class ShareMapper extends QBMapper {
$qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
);
- $qb->execute();
+ $qb->execute();
}
/**
@@ -135,7 +135,6 @@ class ShareMapper extends QBMapper {
$qb->expr()->eq('id', $qb->createNamedParameter($shareId, IQueryBuilder::PARAM_INT))
);
- $qb->execute();
+ $qb->execute();
}
-
}
diff --git a/lib/Db/SubscriptionMapper.php b/lib/Db/SubscriptionMapper.php
index b8b231e0..dd051fee 100644
--- a/lib/Db/SubscriptionMapper.php
+++ b/lib/Db/SubscriptionMapper.php
@@ -4,7 +4,7 @@
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -45,14 +45,14 @@ class SubscriptionMapper extends QBMapper {
* @return array
*/
- public function findAll() {
- $qb = $this->db->getQueryBuilder();
+ public function findAll() {
+ $qb = $this->db->getQueryBuilder();
- $qb->select('*')
+ $qb->select('*')
->from($this->getTableName());
- return $this->findEntities($qb);
- }
+ return $this->findEntities($qb);
+ }
/**
* @param int $pollId
@@ -61,17 +61,17 @@ class SubscriptionMapper extends QBMapper {
* @return array
*/
- public function findAllByPoll($pollId) {
- $qb = $this->db->getQueryBuilder();
+ public function findAllByPoll($pollId) {
+ $qb = $this->db->getQueryBuilder();
- $qb->select('*')
+ $qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
);
- return $this->findEntities($qb);
- }
+ return $this->findEntities($qb);
+ }
/**
* @param int $pollId
@@ -83,7 +83,7 @@ class SubscriptionMapper extends QBMapper {
public function findByUserAndPoll($pollId, $userId) {
$qb = $this->db->getQueryBuilder();
- $qb->select('*')
+ $qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
@@ -92,25 +92,24 @@ class SubscriptionMapper extends QBMapper {
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
);
- return $this->findEntity($qb);
+ return $this->findEntity($qb);
}
/**
* @param int $pollId
*/
- public function unsubscribe($pollId, $currentUser) {
- $qb = $this->db->getQueryBuilder();
+ public function unsubscribe($pollId, $currentUser) {
+ $qb = $this->db->getQueryBuilder();
- $qb->delete($this->getTableName())
- ->where(
- $qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
- )
+ $qb->delete($this->getTableName())
+ ->where(
+ $qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
+ )
->andWhere(
$qb->expr()->eq('user_id', $qb->createNamedParameter($currentUser, IQueryBuilder::PARAM_STR))
);
- $qb->execute();
- }
-
+ $qb->execute();
+ }
}
diff --git a/lib/Db/Vote.php b/lib/Db/Vote.php
index b304c149..e8b31dda 100644
--- a/lib/Db/Vote.php
+++ b/lib/Db/Vote.php
@@ -5,7 +5,7 @@
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author Kai Schröer <git@schroeer.co>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
diff --git a/lib/Db/VoteMapper.php b/lib/Db/VoteMapper.php
index c38d9e4b..b6cf885d 100644
--- a/lib/Db/VoteMapper.php
+++ b/lib/Db/VoteMapper.php
@@ -4,7 +4,7 @@
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -141,7 +141,7 @@ class VoteMapper extends QBMapper {
* @param int $pollId
* @param string $userId
*/
- public function deleteByPollAndUser($pollId, $userId) {
+ public function deleteByPollAndUser($pollId, $userId) {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
@@ -152,7 +152,7 @@ class VoteMapper extends QBMapper {
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
);
- $qb->execute();
+ $qb->execute();
}
/**
diff --git a/lib/Exceptions/BadRequestException.php b/lib/Exceptions/BadRequestException.php
index 8c0c25c3..e8414a69 100644
--- a/lib/Exceptions/BadRequestException.php
+++ b/lib/Exceptions/BadRequestException.php
@@ -36,5 +36,4 @@ class BadRequestException extends \Exception {
public function getStatus() {
return Http::STATUS_BAD_REQUEST;
}
-
}
diff --git a/lib/Exceptions/DuplicateEntryException.php b/lib/Exceptions/DuplicateEntryException.php
index d019414f..bdfa27ba 100644
--- a/lib/Exceptions/DuplicateEntryException.php
+++ b/lib/Exceptions/DuplicateEntryException.php
@@ -36,5 +36,4 @@ class DuplicateEntryException extends \Exception {
public function getStatus() {
return Http::STATUS_CONFLICT;
}
-
}
diff --git a/lib/Exceptions/EmptyTitleException.php b/lib/Exceptions/EmptyTitleException.php
index acfc4c57..66527b1d 100644
--- a/lib/Exceptions/EmptyTitleException.php
+++ b/lib/Exceptions/EmptyTitleException.php
@@ -36,5 +36,4 @@ class EmptyTitleException extends \Exception {
public function getStatus() {
return Http::STATUS_CONFLICT;
}
-
}
diff --git a/lib/Exceptions/InvalidAccessException.php b/lib/Exceptions/InvalidAccessException.php
index c5bfd69a..399d4af5 100644
--- a/lib/Exceptions/InvalidAccessException.php
+++ b/lib/Exceptions/InvalidAccessException.php
@@ -36,5 +36,4 @@ class InvalidAccessException extends \Exception {
public function getStatus() {
return Http::STATUS_CONFLICT;
}
-
}
diff --git a/lib/Exceptions/InvalidPollTypeException.php b/lib/Exceptions/InvalidPollTypeException.php
index bef690f3..26368669 100644
--- a/lib/Exceptions/InvalidPollTypeException.php
+++ b/lib/Exceptions/InvalidPollTypeException.php
@@ -36,5 +36,4 @@ class InvalidPollTypeException extends \Exception {
public function getStatus() {
return Http::STATUS_CONFLICT;
}
-
}
diff --git a/lib/Exceptions/InvalidShareType.php b/lib/Exceptions/InvalidShareType.php
index 056c4c9b..380b3deb 100644
--- a/lib/Exceptions/InvalidShareType.php
+++ b/lib/Exceptions/InvalidShareType.php
@@ -36,5 +36,4 @@ class InvalidShareType extends \Exception {
public function getStatus() {
return Http::STATUS_CONFLICT;
}
-
}
diff --git a/lib/Exceptions/InvalidShowResultsException.php b/lib/Exceptions/InvalidShowResultsException.php
index 67b18a49..e12fb4f4 100644
--- a/lib/Exceptions/InvalidShowResultsException.php
+++ b/lib/Exceptions/InvalidShowResultsException.php
@@ -36,5 +36,4 @@ class InvalidShowResultsException extends \Exception {
public function getStatus() {
return Http::STATUS_CONFLICT;
}
-
}
diff --git a/lib/Exceptions/InvalidUsername.php b/lib/Exceptions/InvalidUsername.php
index b75c8ea0..a33ea5b6 100644
--- a/lib/Exceptions/InvalidUsername.php
+++ b/lib/Exceptions/InvalidUsername.php
@@ -36,5 +36,4 @@ class InvalidUsername extends \Exception {
public function getStatus() {
return Http::STATUS_CONFLICT;
}
-
}
diff --git a/lib/Exceptions/NotAuthorizedException.php b/lib/Exceptions/NotAuthorizedException.php
index 9486790f..8e924610 100644
--- a/lib/Exceptions/NotAuthorizedException.php
+++ b/lib/Exceptions/NotAuthorizedException.php
@@ -36,5 +36,4 @@ class NotAuthorizedException extends \Exception {
public function getStatus() {
return Http::STATUS_FORBIDDEN;
}
-
}
diff --git a/lib/Exceptions/TooShortException.php b/lib/Exceptions/TooShortException.php
index 8b497d28..67bdd63a 100644
--- a/lib/Exceptions/TooShortException.php
+++ b/lib/Exceptions/TooShortException.php
@@ -36,5 +36,4 @@ class TooShortException extends \Exception {
public function getStatus() {
return Http::STATUS_FORBIDDEN;
}
-
}
diff --git a/lib/Exceptions/UsernameInvalidException.php b/lib/Exceptions/UsernameInvalidException.php
index 4c7c4e1a..c1c3feec 100644
--- a/lib/Exceptions/UsernameInvalidException.php
+++ b/lib/Exceptions/UsernameInvalidException.php
@@ -36,5 +36,4 @@ class UsernameInvalidException extends \Exception {
public function getStatus() {
return Http::STATUS_FORBIDDEN;
}
-
}
diff --git a/lib/Migration/Version0009Date20181125051900.php b/lib/Migration/Version0009Date20181125051900.php
index a1a66783..4622cf61 100644
--- a/lib/Migration/Version0009Date20181125051900.php
+++ b/lib/Migration/Version0009Date20181125051900.php
@@ -24,7 +24,6 @@
namespace OCA\Polls\Migration;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
@@ -65,14 +64,12 @@ class Version0009Date20181125051900 extends SimpleMigrationStep {
if ($schema->hasTable('polls_particip') &&
$schema->hasTable('polls_particip_text') &&
$schema->hasTable('polls_votes')) {
-
$schema->dropTable('polls_votes');
}
if ($schema->hasTable('polls_dts') &&
$schema->hasTable('polls_txts') &&
$schema->hasTable('polls_options')) {
-
$schema->dropTable('polls_options');
}
return $schema;
diff --git a/lib/Migration/Version0009Date20181125061900.php b/lib/Migration/Version0009Date20181125061900.php
index ca701d4a..63178d40 100644
--- a/lib/Migration/Version0009Date20181125061900.php
+++ b/lib/Migration/Version0009Date20181125061900.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Migration;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
@@ -113,7 +112,6 @@ class Version0009Date20181125061900 extends SimpleMigrationStep {
]);
$table->setPrimaryKey(['id']);
} else {
-
$table = $schema->getTable('polls_events');
if (!$table->hasColumn('allow_maybe')) {
$table->addColumn('allow_maybe', Type::INTEGER, [
@@ -121,7 +119,6 @@ class Version0009Date20181125061900 extends SimpleMigrationStep {
'default' => 1,
]);
}
-
}
if (!$schema->hasTable('polls_options')) {
diff --git a/lib/Migration/Version0010Date20191227063812.php b/lib/Migration/Version0010Date20191227063812.php
index 5fe7b26e..ff2666bd 100644
--- a/lib/Migration/Version0010Date20191227063812.php
+++ b/lib/Migration/Version0010Date20191227063812.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Migration;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
@@ -328,7 +327,6 @@ class Version0010Date20191227063812 extends SimpleMigrationStep {
->setParameter('show_results', 'always')
->setParameter('admin_access', 0);
$insert->execute();
-
}
$result->closeCursor();
@@ -412,5 +410,4 @@ class Version0010Date20191227063812 extends SimpleMigrationStep {
}
$result->closeCursor();
}
-
}
diff --git a/lib/Migration/Version0010Date20200119101800.php b/lib/Migration/Version0010Date20200119101800.php
index 0152c972..b8d2c68b 100644
--- a/lib/Migration/Version0010Date20200119101800.php
+++ b/lib/Migration/Version0010Date20200119101800.php
@@ -24,7 +24,6 @@
namespace OCA\Polls\Migration;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
@@ -64,7 +63,6 @@ class Version0010Date20200119101800 extends SimpleMigrationStep {
if ($schema->hasTable('polls_polls') &&
$schema->hasTable('polls_events')) {
-
$schema->dropTable('polls_events');
}
diff --git a/lib/Migration/Version0101Date20200122194300.php b/lib/Migration/Version0101Date20200122194300.php
index 381c55bb..4f656dd7 100644
--- a/lib/Migration/Version0101Date20200122194300.php
+++ b/lib/Migration/Version0101Date20200122194300.php
@@ -24,7 +24,6 @@
namespace OCA\Polls\Migration;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Migration/Version0103Date20200130171244.php b/lib/Migration/Version0103Date20200130171244.php
index 69f162b7..9b7b0e08 100644
--- a/lib/Migration/Version0103Date20200130171244.php
+++ b/lib/Migration/Version0103Date20200130171244.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Migration;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Migration/Version0104Date20200205104800.php b/lib/Migration/Version0104Date20200205104800.php
index f869fc4b..076b42cc 100644
--- a/lib/Migration/Version0104Date20200205104800.php
+++ b/lib/Migration/Version0104Date20200205104800.php
@@ -24,7 +24,6 @@
namespace OCA\Polls\Migration;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Migration/Version0104Date20200314074611.php b/lib/Migration/Version0104Date20200314074611.php
index cd587e51..564e73ba 100644
--- a/lib/Migration/Version0104Date20200314074611.php
+++ b/lib/Migration/Version0104Date20200314074611.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Migration;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Migration/Version0105Date20200508211943.php b/lib/Migration/Version0105Date20200508211943.php
index cafee187..a9ce62ac 100644
--- a/lib/Migration/Version0105Date20200508211943.php
+++ b/lib/Migration/Version0105Date20200508211943.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Migration;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Migration/Version0105Date20200523142076.php b/lib/Migration/Version0105Date20200523142076.php
index 87da0be3..3fd9d3c9 100644
--- a/lib/Migration/Version0105Date20200523142076.php
+++ b/lib/Migration/Version0105Date20200523142076.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Migration;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Migration/Version0105Date20200704084037.php b/lib/Migration/Version0105Date20200704084037.php
index 934d2a59..76736c36 100644
--- a/lib/Migration/Version0105Date20200704084037.php
+++ b/lib/Migration/Version0105Date20200704084037.php
@@ -25,7 +25,6 @@ namespace OCA\Polls\Migration;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Model/Acl.php b/lib/Model/Acl.php
index b68386f0..12693dc7 100644
--- a/lib/Model/Acl.php
+++ b/lib/Model/Acl.php
@@ -3,7 +3,7 @@
* @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -25,8 +25,6 @@
namespace OCA\Polls\Model;
use JsonSerializable;
-use Exception;
-use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCP\IUserManager;
@@ -116,7 +114,6 @@ class Acl implements JsonSerializable {
* @return bool
*/
public function set($pollId = 0, $token = ''): Acl {
-
if ($token) {
\OC::$server->getLogger()->debug('Share token: ' . $token);
@@ -155,7 +152,7 @@ class Acl implements JsonSerializable {
* @NoAdminRequired
* @return string
*/
- public function getUserId() {
+ public function getUserId() {
return $this->userId;
}
@@ -243,7 +240,7 @@ class Acl implements JsonSerializable {
*/
public function getGroupShare(): bool {
return count(
- array_filter($this->shareMapper->findByPoll($this->getPollId()), function($item) {
+ array_filter($this->shareMapper->findByPoll($this->getPollId()), function ($item) {
if ($item->getType() === 'group' && $this->groupManager->isInGroup($this->getUserId(), $item->getUserId())) {
return true;
}
@@ -266,9 +263,8 @@ class Acl implements JsonSerializable {
* @return bool
*/
public function getPersonalShare(): bool {
-
return count(
- array_filter($this->shareMapper->findByPoll($this->getPollId()), function($item) {
+ array_filter($this->shareMapper->findByPoll($this->getPollId()), function ($item) {
if (($item->getType() === 'user' || $item->getType() === 'external' || $item->getType() === 'email' || $item->getType() === 'contact') && $item->getUserId() === $this->getUserId()) {
return true;
}
@@ -281,9 +277,8 @@ class Acl implements JsonSerializable {
* @return bool
*/
public function getPublicShare(): bool {
-
return count(
- array_filter($this->shareMapper->findByPoll($this->getPollId()), function($item) {
+ array_filter($this->shareMapper->findByPoll($this->getPollId()), function ($item) {
if ($item->getType() === 'public' && $item->getToken() === $this->getToken()) {
return true;
}
@@ -344,7 +339,7 @@ class Acl implements JsonSerializable {
* @return bool
*/
public function getAllowSeeResults(): bool {
- return $this->poll->getShowResults() === 'always'
+ return $this->poll->getShowResults() === 'always'
|| ($this->poll->getShowResults() === 'expired' && $this->getExpired())
|| $this->getIsOwner();
}
diff --git a/lib/Service/AnonymizeService.php b/lib/Service/AnonymizeService.php
index 27fbdc9b..fcc5988b 100644
--- a/lib/Service/AnonymizeService.php
+++ b/lib/Service/AnonymizeService.php
@@ -3,7 +3,7 @@
* @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -38,7 +38,7 @@ class AnonymizeService {
private $commentMapper;
/** @var array */
- private $anonList = array();
+ private $anonList = [];
/** @var string */
private $userId;
@@ -126,6 +126,4 @@ class AnonymizeService {
public function getVotes() {
return $this->anonymize($this->voteMapper->findByPoll($this->pollId));
}
-
-
}
diff --git a/lib/Service/CalendarService.php b/lib/Service/CalendarService.php
index f9bd0892..cb9bd29e 100644
--- a/lib/Service/CalendarService.php
+++ b/lib/Service/CalendarService.php
@@ -3,7 +3,7 @@
* @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*
* @author René Gieling <github@dartcafe.de>
-*
+ *
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -26,10 +26,8 @@ namespace OCA\Polls\Service;
use DateTime;
use OCP\Calendar\IManager as CalendarManager;
-use OCP\Calendar\ICalendar;
class CalendarService {
-
private $calendarManager;
private $calendars;
@@ -82,6 +80,4 @@ class CalendarService {
public function getCalendars() {
return $this->calendars;
}
-
-
}
diff --git a/lib/Service/CommentService.php b/lib/Service/CommentService.php
index cdb2616a..eeff8a06 100644
--- a/lib/Service/CommentService.php
+++ b/lib/Service/CommentService.php
@@ -29,9 +29,6 @@ use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Db\Comment;
use OCA\Polls\Db\CommentMapper;
use OCA\Polls\Model\Acl;
-use OCA\Polls\Service\AnonymizeService;
-
-
class CommentService {
@@ -77,7 +74,6 @@ class CommentService {
* @throws NotAuthorizedException
*/
public function list($pollId = 0, $token = '') {
-
if (!$this->acl->set($pollId, $token)->getAllowView()) {
throw new NotAuthorizedException;
}
@@ -100,7 +96,6 @@ class CommentService {
* @throws NotAuthorizedException
*/
public function add($pollId = 0, $message, $token = '') {
-
if (!$this->acl->set($pollId, $token)->getAllowComment()) {
throw new NotAuthorizedException;
}
@@ -117,12 +112,10 @@ class CommentService {
} else {
throw new NotAuthorizedException;
}
-
} catch (Exception $e) {
\OC::$server->getLogger()->alert('Error writing comment for pollId ' . $pollId . ': ' . $e);
throw new NotAuthorizedException($e);
}
-
}
/**
@@ -142,7 +135,5 @@ class CommentService {
$this->commentMapper->delete($this->comment);
return $this->comment;
-
}
-
}
diff --git a/lib/Service/LogService.php b/lib/Service/LogService.php
index 950abf44..9c0db75c 100644
--- a/lib/Service/LogService.php
+++ b/lib/Service/LogService.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Service;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Db\Log;
@@ -98,5 +97,4 @@ class LogService {
return $this->logMapper->insert($this->log);
}
}
-
}
diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php
index 3c0b835d..43077414 100644
--- a/lib/Service/MailService.php
+++ b/lib/Service/MailService.php
@@ -36,9 +36,7 @@ use OCP\Mail\IMailer;
use OCP\Mail\IEMailTemplate;
use OCA\Polls\Db\SubscriptionMapper;
-use OCA\Polls\Db\Subscription;
use OCA\Polls\Db\PollMapper;
-use OCA\Polls\Db\Poll;
use OCA\Polls\Db\ShareMapper;
use OCA\Polls\Db\Share;
use OCA\Polls\Db\LogMapper;
@@ -131,14 +129,13 @@ class MailService {
*/
private function sendMail($emailTemplate, $userId = '', $emailAddress = '', $displayName = '') {
-
if ($this->userManager->get($userId) instanceof IUser) {
$emailAddress = \OC::$server->getConfig()->getUserValue($userId, 'settings', 'email');
$displayName = $this->userManager->get($userId)->getDisplayName();
}
if (!$emailAddress || !filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
- throw new Exception('Invalid email address (' . $emailAddress . ')');
+ throw new Exception('Invalid email address (' . $emailAddress . ')');
}
try {
@@ -148,12 +145,10 @@ class MailService {
$this->mailer->send($message);
return null;
-
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'polls']);
throw $e;
}
-
}
@@ -163,7 +158,6 @@ class MailService {
* @return string
*/
public function resolveEmailAddress($pollId, $userId) {
-
if ($this->userManager->get($userId) instanceof IUser) {
return \OC::$server->getConfig()->getUserValue($userId, 'settings', 'email');
}
@@ -192,8 +186,7 @@ class MailService {
$contactsManager = \OC::$server->getContactsManager();
if ($share->getType() === 'user') {
-
- $recipients[] = array(
+ $recipients[] = [
'userId' => $share->getUserId(),
'eMailAddress' => \OC::$server->getConfig()->getUserValue($share->getUserId(), 'settings', 'email'),
'displayName' => $this->userManager->get($share->getUserId())->getDisplayName(),
@@ -204,13 +197,12 @@ class MailService {
'link' => $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute(
'polls.page.indexvote',
- array('id' => $share->getPollId())
+ ['id' => $share->getPollId()]
)
)
- );
-
+ ];
} elseif ($share->getType() === 'email') {
- $recipients[] = array(
+ $recipients[] = [
'userId' => $share->getUserEmail(),
'eMailAddress' => $share->getUserEmail(),
'displayName' => $share->getUserEmail(),
@@ -218,17 +210,16 @@ class MailService {
'link' => $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute(
'polls.page.vote_publicpublic',
- array('token' => $share->getToken())
+ ['token' => $share->getToken()]
)
)
- );
-
+ ];
} elseif ($share->getType() === 'contact') {
- $contacts = $contactsManager->search($share->getUserId(), array('FN'));
+ $contacts = $contactsManager->search($share->getUserId(), ['FN']);
if (is_array($contacts)) {
$contact = $contacts[0];
- $recipients[] = array(
+ $recipients[] = [
'userId' => $share->getUserId(),
'eMailAddress' => $share->getUserEmail(),
'displayName' => $share->getUserId(),
@@ -236,16 +227,15 @@ class MailService {
'link' => $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute(
'polls.page.vote_publicpublic',
- array('token' => $share->getToken())
+ ['token' => $share->getToken()]
)
)
- );
+ ];
} else {
return;
}
-
} elseif ($share->getType() === 'external') {
- $recipients[] = array(
+ $recipients[] = [
'userId' => $share->getUserId(),
'eMailAddress' => $share->getUserEmail(),
'displayName' => $share->getUserId(),
@@ -253,13 +243,11 @@ class MailService {
'link' => $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute(
'polls.page.vote_publicpublic',
- array('token' => $share->getToken())
+ ['token' => $share->getToken()]
)
)
- );
-
+ ];
} elseif ($share->getType() === 'group') {
-
$groupMembers = array_keys($this->groupManager->displayNamesInGroup($share->getUserId()));
foreach ($groupMembers as $member) {
@@ -267,7 +255,7 @@ class MailService {
continue;
}
- $recipients[] = array(
+ $recipients[] = [
'userId' => $member,
'eMailAddress' => \OC::$server->getConfig()->getUserValue($member, 'settings', 'email'),
'displayName' => $this->userManager->get($member)->getDisplayName(),
@@ -277,8 +265,7 @@ class MailService {
'polls.page.indexvote', ['id' => $share->getPollId()]
)
)
- );
-
+ ];
}
}
return $recipients;
@@ -288,7 +275,6 @@ class MailService {
* @param string $token
*/
public function sendInvitationMail($token) {
-
$share = $this->shareMapper->findByToken($token);
$poll = $this->pollMapper->find($share->getPollId());
$owner = $this->userManager->get($poll->getOwner());
@@ -376,7 +362,6 @@ class MailService {
} catch (\Exception $e) {
continue;
}
-
}
$trans = $this->transFactory->get('polls', $lang);
@@ -384,7 +369,7 @@ class MailService {
$url = $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute(
'polls.page.indexvote',
- array('id' => $subscription->getPollId())
+ ['id' => $subscription->getPollId()]
)
);
@@ -413,49 +398,41 @@ class MailService {
if ($logItem->getMessage()) {
$emailTemplate->addBodyText($logItem->getMessage());
-
} elseif ($logItem->getMessageId() === 'setVote') {
$emailTemplate->addBodyText($trans->t(
'- %s voted.',
- array($displayUser)
+ [$displayUser]
));
-
} elseif ($logItem->getMessageId() === 'updatePoll') {
$emailTemplate->addBodyText($trans->t(
'- %s updated the poll configuration. Please check your votes.',
- array($displayUser)
+ [$displayUser]
));
-
} elseif ($logItem->getMessageId() === 'deletePoll') {
$emailTemplate->addBodyText($trans->t(
'- %s deleted the poll.',
- array($displayUser)
+ [$displayUser]
));
-
} elseif ($logItem->getMessageId() === 'restorePoll') {
$emailTemplate->addBodyText($trans->t(
'- %s restored the poll.',
- array($displayUser)
+ [$displayUser]
));
-
} elseif ($logItem->getMessageId() === 'expirePoll') {
$emailTemplate->addBodyText($trans->t(
'- The poll expired.',
- array($displayUser)
+ [$displayUser]
));
-
} elseif ($logItem->getMessageId() === 'addOption') {
$emailTemplate->addBodyText($trans->t(
'- %s added a vote option.',
- array($displayUser)
+ [$displayUser]
));
-
} elseif ($logItem->getMessageId() === 'deleteOption') {
$emailTemplate->addBodyText($trans->t(
'- %s removed a vote option.',
- array($displayUser)
+ [$displayUser]
));
-
} else {
$emailTemplate->addBodyText(
$logItem->getMessageId() . " (" . $displayUser . ")"
diff --git a/lib/Service/OptionService.php b/lib/Service/OptionService.php
index 90014612..298fb863 100644
--- a/lib/Service/OptionService.php
+++ b/lib/Service/OptionService.php
@@ -24,7 +24,6 @@
namespace OCA\Polls\Service;
use DateTime;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Exceptions\BadRequestException;
@@ -35,7 +34,6 @@ use OCA\Polls\Db\OptionMapper;
use OCA\Polls\Db\Option;
use OCA\Polls\Db\PollMapper;
use OCA\Polls\Db\Poll;
-use OCA\Polls\Service\LogService;
use OCA\Polls\Model\Acl;
class OptionService {
@@ -72,7 +70,7 @@ class OptionService {
OptionMapper $optionMapper,
Option $option,
PollMapper $pollMapper,
- Poll $poll,
+ Poll $poll,
LogService $logService,
Acl $acl
) {
@@ -114,7 +112,6 @@ class OptionService {
* @throws NotAuthorizedException
*/
public function get($optionId) {
-
if (!$this->acl->set($this->optionMapper->find($optionId)->getPollId())->getAllowView()) {
throw new NotAuthorizedException;
}
@@ -133,7 +130,6 @@ class OptionService {
* @throws NotAuthorizedException
*/
public function add($pollId, $timestamp = 0, $pollOptionText = '') {
-
$this->poll = $this->pollMapper->find($pollId);
if (!$this->acl->set($pollId)->getAllowEdit()) {
throw new NotAuthorizedException;
@@ -148,7 +144,6 @@ class OptionService {
} catch (UniqueConstraintViolationException $e) {
throw new DuplicateEntryException('This option already exists');
}
-
}
/**
@@ -162,7 +157,6 @@ class OptionService {
* @throws NotAuthorizedException
*/
public function update($optionId, $timestamp = 0, $pollOptionText = '', $order = 0) {
-
$this->option = $this->optionMapper->find($optionId);
$this->poll = $this->pollMapper->find($this->option->getPollId());
@@ -228,7 +222,6 @@ class OptionService {
* @throws NotAuthorizedException
*/
public function sequence($optionId, $step, $unit, $amount) {
-
$baseDate = new DateTime;
$origin = $this->optionMapper->find($optionId);
@@ -243,7 +236,6 @@ class OptionService {
$baseDate->setTimestamp($origin->getTimestamp());
for ($i = 0; $i < $amount; $i++) {
-
$this->option = new Option();
$this->option->setPollId($origin->getPollId());
$this->option->setConfirmed(0);
@@ -268,7 +260,6 @@ class OptionService {
* @throws NotAuthorizedException
*/
public function clone($fromPollId, $toPollId) {
-
if (!$this->acl->set($fromPollId)->getAllowView()) {
throw new NotAuthorizedException;
}
@@ -296,7 +287,6 @@ class OptionService {
* @throws BadRequestException
*/
public function reorder($pollId, $options) {
-
$this->poll = $this->pollMapper->find($pollId);
if (!$this->acl->set($pollId)->getAllowEdit()) {
@@ -329,7 +319,6 @@ class OptionService {
* @throws BadRequestException
*/
public function setOrder($optionId, $newOrder) {
-
$this->option = $this->optionMapper->find($optionId);
$pollId = $this->option->getPollId();
$this->poll = $this->pollMapper->find($pollId);
@@ -353,23 +342,17 @@ class OptionService {
foreach ($this->optionMapper->findByPoll($pollId) as $option) {
$currentOrder = $option->getOrder();
if ($currentOrder > $oldOrder && $currentOrder <= $newOrder) {
-
$option->setOrder($currentOrder - 1);
$this->optionMapper->update($option);
-
} elseif (
($currentOrder < $oldOrder && $currentOrder >= $newOrder)
|| ($currentOrder < $oldOrder && $currentOrder = $newOrder)
) {
-
$option->setOrder($currentOrder + 1);
$this->optionMapper->update($option);
-
} elseif ($currentOrder === $oldOrder) {
-
$option->setOrder($newOrder);
$this->optionMapper->update($option);
-
} else {
continue;
}
diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php
index 5f365cdb..02e50d97 100644
--- a/lib/Service/PollService.php
+++ b/lib/Service/PollService.php
@@ -23,8 +23,6 @@
namespace OCA\Polls\Service;
-use Exception;
-use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\EmptyTitleException;
use OCA\Polls\Exceptions\InvalidAccessException;
use OCA\Polls\Exceptions\InvalidShowResultsException;
@@ -36,8 +34,6 @@ use OCA\Polls\Db\PollMapper;
use OCA\Polls\Db\Poll;
use OCA\Polls\Db\VoteMapper;
use OCA\Polls\Db\Vote;
-use OCA\Polls\Service\LogService;
-use OCA\Polls\Service\MailService;
use OCA\Polls\Model\Acl;
class PollService {
@@ -46,7 +42,7 @@ class PollService {
private $pollMapper;
/** @var Poll */
- private $poll;
+ private $poll;
/** @var VoteMapper */
private $voteMapper;
@@ -55,42 +51,42 @@ class PollService {
private $vote;
/** @var LogService */
- private $logService;
+ private $logService;
/** @var MailService */
- private $mailService;
+ private $mailService;
/** @var Acl */
- private $acl;
-
- /**
- * PollController constructor.
- * @param PollMapper $pollMapper
- * @param Poll $poll
- * @param VoteMapper $voteMapper
- * @param Vote $vote
- * @param LogService $logService
- * @param MailService $mailService
- * @param Acl $acl
- */
-
- public function __construct(
- PollMapper $pollMapper,
- Poll $poll,
+ private $acl;
+
+ /**
+ * PollController constructor.
+ * @param PollMapper $pollMapper
+ * @param Poll $poll
+ * @param VoteMapper $voteMapper
+ * @param Vote $vote
+ * @param LogService $logService
+ * @param MailService $mailService
+ * @param Acl $acl
+ */
+
+ public function __construct(
+ PollMapper $pollMapper,
+ Poll $poll,
VoteMapper $voteMapper,
- Vote $vote,
+ Vote $vote,
LogService $logService,
MailService $mailService,
- Acl $acl
- ) {
- $this->pollMapper = $pollMapper;
- $this->poll = $poll;
+ Acl $acl
+ ) {
+ $this->pollMapper = $pollMapper;
+ $this->poll = $poll;
$this->voteMapper = $voteMapper;
- $this->vote = $vote;
+ $this->vote = $vote;
$this->logService = $logService;
$this->mailService = $mailService;
- $this->acl = $acl;
- }
+ $this->acl = $acl;
+ }
/**
@@ -127,7 +123,7 @@ class PollService {
* @return Poll
* @throws NotAuthorizedException
*/
- public function get($pollId, $token) {
+ public function get($pollId, $token) {
$acl = $this->acl->set($pollId, $token);
if (!$acl->getAllowView()) {
@@ -135,8 +131,7 @@ class PollService {
}
return $this->pollMapper->find($acl->getPollId());
-
- }
+ }
/**
* Add poll
@@ -200,7 +195,6 @@ class PollService {
*/
public function update($pollId, $poll) {
-
$this->poll = $this->pollMapper->find($pollId);
if (!$this->acl->set($this->poll->getId())->getAllowEdit()) {
@@ -281,7 +275,6 @@ class PollService {
* @throws NotAuthorizedException
*/
public function clone($pollId) {
-
$origin = $this->pollMapper->find($pollId);
if (!$this->acl->set($origin->getId())->getAllowView()) {
throw new NotAuthorizedException;
diff --git a/lib/Service/ShareService.php b/lib/Service/ShareService.php
index 83b20dda..ae14935a 100644
--- a/lib/Service/ShareService.php
+++ b/lib/Service/ShareService.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Service;
-use Exception;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Exceptions\InvalidUsername;
use OCA\Polls\Exceptions\InvalidShareType;
@@ -33,7 +32,6 @@ use OCP\Security\ISecureRandom;
use OCA\Polls\Controller\SystemController;
use OCA\Polls\Db\ShareMapper;
use OCA\Polls\Db\Share;
-use OCA\Polls\Service\MailService;
use OCA\Polls\Model\Acl;
class ShareService {
@@ -84,7 +82,7 @@ class ShareService {
*/
public function list($pollId, $token) {
if ($token) {
- return array($this->get($token));
+ return [$this->get($token)];
}
if (!$this->acl->set($pollId)->getAllowEdit()) {
@@ -147,7 +145,6 @@ class ShareService {
* @throws NotAuthorizedException
*/
public function setEmailAddress($token, $emailAddress) {
-
$this->share = $this->shareMapper->findByToken($token);
if ($this->share->getType() === 'external') {
// TODO: Simple validate email address
@@ -181,7 +178,6 @@ class ShareService {
}
if ($this->share->getType() === 'public') {
-
$pollId = $this->share->getPollId();
$this->share = new Share();
$this->share->setToken(\OC::$server->getSecureRandom()->generate(
@@ -198,14 +194,11 @@ class ShareService {
$this->shareMapper->insert($this->share);
$this->mailService->sendInvitationMail($this->share->getToken());
return $this->share;
-
} elseif ($this->share->getType() === 'email') {
-
$this->share->setType('external');
$this->share->setUserId($userName);
$this->share->setUserEmail($emailAddress);
return $this->shareMapper->update($this->share);
-
} else {
throw new NotAuthorizedException;
}
diff --git a/lib/Service/SubscriptionService.php b/lib/Service/SubscriptionService.php
index 9c3f1855..ec824b61 100644
--- a/lib/Service/SubscriptionService.php
+++ b/lib/Service/SubscriptionService.php
@@ -23,7 +23,6 @@
namespace OCA\Polls\Service;
-use Exception;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\Db\DoesNotExistException;
@@ -70,7 +69,6 @@ class SubscriptionService {
// duplicates are removed in $this->set()
return $this->set($pollId, $token, true);
}
-
}
/**
@@ -93,9 +91,7 @@ class SubscriptionService {
// subscription already exists, just return the existing subscription
return ['status' => 'Subscribed to poll ' . $this->acl->getPollId()];
}
-
} catch (DoesNotExistException $e) {
-
if ($subscribed) {
$subscription = new Subscription();
$subscription->setPollId($this->acl->getPollId());
@@ -107,7 +103,6 @@ class SubscriptionService {
// subscription is not found, just approve the unsubscription
return ['status' => 'Unsubscribed from poll ' . $this->acl->getPollId()];
}
-
} catch (MultipleObjectsReturnedException $e) {
// Duplicates should not exist but if found, fix it
// unsubscribe from all and resubscribe, if requested
@@ -124,8 +119,6 @@ class SubscriptionService {
} else {
return ['status' => 'Unsubscribed from poll ' . $this->acl->getPollId()];
}
-
}
-
}
}
diff --git a/lib/Service/SystemService.php b/lib/Service/SystemService.php
index eb47cad6..7ac14284 100644
--- a/lib/Service/SystemService.php
+++ b/lib/Service/SystemService.php
@@ -23,18 +23,14 @@
namespace OCA\Polls\Service;
-use Exception;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Exceptions\TooShortException;
use OCA\Polls\Exceptions\UsernameInvalidException;
use OCP\IGroupManager;
-use OCP\IUser;
use OCP\IUserManager;
-use OCP\IRequest;
use OCA\Polls\Db\Share;
use OCA\Polls\Db\ShareMapper;
-use OCA\Polls\Db\Vote;
use OCA\Polls\Db\VoteMapper;
class SystemService {
@@ -76,50 +72,50 @@ class SystemService {
* @param string $query
* @return bool
*/
- private function isValidEmail($email) {
- return (!preg_match('/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/', $email)) ? false : true;
- }
-
-
- /**
- * Get a list of users
- * @NoAdminRequired
- * @param string $query
- * @param array $skip - usernames to skip in return array
- * @return Array
- */
- public function getSiteUsers($query = '', $skip = array()) {
- $users = array();
- foreach ($this->userManager->searchDisplayName($query) as $user) {
- if (!in_array($user->getUID(), $skip) && $user->isEnabled()) {
- $users[] = [
- 'id' => $user->getUID(),
- 'user' => $user->getUID(),
- 'displayName' => $user->getDisplayName(),
- 'organisation' => '',
- 'emailAddress' => $user->getEMailAddress(),
- 'desc' => 'User',
- 'type' => 'user',
- 'icon' => 'icon-user',
- 'avatarURL' => '',
- 'avatar' => '',
- 'lastLogin' => $user->getLastLogin(),
- 'cloudId' => $user->getCloudId()
- ];
- }
- }
- return $users;
- }
-
- /**
- * Get a list of user groups
- * @NoAdminRequired
- * @param string $query
- * @param array $skip - group names to skip in return array
- * @return Array
- */
- public function getSiteGroups($query = '', $skip = array()) {
- $groups = array();
+ private function isValidEmail($email) {
+ return (!preg_match('/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/', $email)) ? false : true;
+ }
+
+
+ /**
+ * Get a list of users
+ * @NoAdminRequired
+ * @param string $query
+ * @param array $skip - usernames to skip in return array
+ * @return Array
+ */
+ public function getSiteUsers($query = '', $skip = []) {
+ $users = [];
+ foreach ($this->userManager->searchDisplayName($query) as $user) {
+ if (!in_array($user->getUID(), $skip) && $user->isEnabled()) {
+ $users[] = [
+ 'id' => $user->getUID(),
+ 'user' => $user->getUID(),
+ 'displayName' => $user->getDisplayName(),
+ 'organisation' => '',
+ 'emailAddress' => $user->getEMailAddress(),
+ 'desc' => 'User',
+ 'type' => 'user',
+ 'icon' => 'icon-user',
+ 'avatarURL' => '',
+ 'avatar' => '',
+ 'lastLogin' => $user->getLastLogin(),
+ 'cloudId' => $user->getCloudId()
+ ];
+ }
+ }
+ return $users;
+ }
+
+ /**
+ * Get a list of user groups
+ * @NoAdminRequired
+ * @param string $query
+ * @param array $skip - group names to skip in return array
+ * @return Array
+ */
+ public function getSiteGroups($query = '', $skip = []) {
+ $groups = [];
foreach ($this->groupManager->search($query) as $group) {
if (!in_array($group->getGID(), $skip)) {
try {
@@ -157,17 +153,16 @@ class SystemService {
* @return Array
*/
public function getContacts($query = '') {
- $contacts = array();
- foreach (\OC::$server->getContactsManager()->search($query, array('FN', 'EMAIL', 'ORG', 'CATEGORIES')) as $contact) {
+ $contacts = [];
+ foreach (\OC::$server->getContactsManager()->search($query, ['FN', 'EMAIL', 'ORG', 'CATEGORIES']) as $contact) {
if (!array_key_exists('isLocalSystemBook', $contact) && array_key_exists('EMAIL', $contact)) {
-
$emailAdresses = $contact['EMAIL'];
if (!is_array($emailAdresses)) {
- $emailAdresses = array($emailAdresses);
+ $emailAdresses = [$emailAdresses];
} else {
// take the first eMail address for now
- $emailAdresses = array($emailAdresses[0]);
+ $emailAdresses = [$emailAdresses[0]];
}
foreach ($emailAdresses as $emailAddress) {
@@ -186,7 +181,6 @@ class SystemService {
'cloudId' => '',
];
}
-
}
}
return $contacts;
@@ -199,8 +193,8 @@ class SystemService {
* @return Array
*/
public function getContactsGroupMembers($query = '') {
- $contacts = array();
- foreach (\OC::$server->getContactsManager()->search($query, array('CATEGORIES')) as $contact) {
+ $contacts = [];
+ foreach (\OC::$server->getContactsManager()->search($query, ['CATEGORIES']) as $contact) {
if (
!array_key_exists('isLocalSystemBook', $contact)
&& array_key_exists('EMAIL', $contact)
@@ -209,10 +203,10 @@ class SystemService {
$emailAdresses = $contact['EMAIL'];
if (!is_array($emailAdresses)) {
- $emailAdresses = array($emailAdresses);
+ $emailAdresses = [$emailAdresses];
} else {
// take the first eMail address for now
- $emailAdresses = array($emailAdresses[0]);
+ $emailAdresses = [$emailAdresses[0]];
}
foreach ($emailAdresses as $emailAddress) {
@@ -243,11 +237,10 @@ class SystemService {
* @return Array
*/
public function getContactsGroups($query = '') {
- $contactGroups = array();
+ $contactGroups = [];
$foundContacts = [];
- foreach (\OC::$server->getContactsManager()->search($query, array('CATEGORIES')) as $contact) {
-
+ foreach (\OC::$server->getContactsManager()->search($query, ['CATEGORIES']) as $contact) {
foreach (explode(',', $contact['CATEGORIES']) as $contactGroup) {
if (strpos($contactGroup, $query) === 0 && !in_array($contactGroup, $foundContacts)) {
$foundContacts[] = $contactGroup;
@@ -291,10 +284,10 @@ class SystemService {
$getContacts = true,
$getContactGroups = true,
$getMail = false,
- $skipGroups = array(),
- $skipUsers = array()
+ $skipGroups = [],
+ $skipUsers = []
) {
- $list = array();
+ $list = [];
if ($getMail && $this->isValidEmail($query)) {
$list[] = [
@@ -356,7 +349,7 @@ class SystemService {
return new TooShortException('Username must have at least 3 characters');
}
- $list = array();
+ $list = [];
// get all groups
$groups = $this->groupManager->search('');
@@ -417,5 +410,4 @@ class SystemService {
// return true, if username is allowed
return true;
}
-
}
diff --git a/lib/Service/VoteService.php b/lib/Service/VoteService.php
index 5fb0b5c7..f2558667 100644
--- a/lib/Service/VoteService.php
+++ b/lib/Service/VoteService.php
@@ -23,15 +23,12 @@
namespace OCA\Polls\Service;
-use Exception;
use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Db\VoteMapper;
use OCA\Polls\Db\Vote;
use OCA\Polls\Db\OptionMapper;
-use OCA\Polls\Service\AnonymizeService;
-use OCA\Polls\Service\LogService;
use OCA\Polls\Model\Acl;
class VoteService {
@@ -112,7 +109,6 @@ class VoteService {
* @throws NotAuthorizedException
*/
public function set($optionId, $setTo, $token = '') {
-
$option = $this->optionMapper->find($optionId);
if (!$this->acl->set($option->getPollId(), $token)->getAllowVote()) {
@@ -127,7 +123,6 @@ class VoteService {
$this->vote = $this->voteMapper->findSingleVote($this->acl->getPollId(), $option->getPollOptionText(), $this->acl->getUserId());
$this->vote->setVoteAnswer($setTo);
$this->voteMapper->update($this->vote);
-
} catch (DoesNotExistException $e) {
// Vote does not exist, insert as new Vote
$this->vote = new Vote();
@@ -138,7 +133,6 @@ class VoteService {
$this->vote->setVoteOptionId($option->getId());
$this->vote->setVoteAnswer($setTo);
$this->voteMapper->insert($this->vote);
-
} finally {
$this->logService->setLog($this->acl->getPollId(), 'setVote', $this->vote->getUserId());
return $this->vote;
@@ -155,7 +149,6 @@ class VoteService {
* @throws NotAuthorizedException
*/
public function delete($pollId, $userId) {
-
if (!$this->acl->set($pollId)->getAllowEdit()) {
throw new NotAuthorizedException;
}
@@ -163,5 +156,4 @@ class VoteService {
$this->voteMapper->deleteByPollAndUser($pollId, $userId);
return $userId;
}
-
}
diff --git a/templates/no.acc.tmpl.php b/templates/no.acc.tmpl.php
deleted file mode 100644
index e2a52c05..00000000
--- a/templates/no.acc.tmpl.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
- /**
- * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
- use OCP\Util;
- Util::addStyle('polls', 'main');
-?>
-<div id="emptycontent" class="">
- <div class="icon-polls"></div>
- <h1>
- <?php /** @scrutinizer ignore-call */ p($l->t('Access denied')); ?>
- </h1>
- <h2>
- <?php /** @scrutinizer ignore-call */ p($l->t('You are not allowed to view this poll or the poll does not exist.')); ?>
- </h2>
-</div>
diff --git a/templates/no.create.tmpl.php b/templates/no.create.tmpl.php
deleted file mode 100644
index 59a8f828..00000000
--- a/templates/no.create.tmpl.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
- /**
- * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
- use OCP\Util;
- Util::addStyle('polls', 'main');
-?>
-<div id="emptycontent" class="">
- <div class="icon-polls"></div>
- <h1>
- <?php /** @scrutinizer ignore-call */ p($l->t('Access denied')); ?>
- </h1>
- <h2>
- <?php /** @scrutinizer ignore-call */ p($l->t('You are not allowed to edit this poll or the poll does not exist.')); ?>
- </h2>
-</div>
diff --git a/templates/no.delete.tmpl.php b/templates/no.delete.tmpl.php
deleted file mode 100644
index e25b71c2..00000000
--- a/templates/no.delete.tmpl.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
- /**
- * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
- use OCP\Util;
- Util::addStyle('polls', 'main');
-?>
-<div id="emptycontent" class="">
- <div class="icon-polls"></div>
- <h1>
- <?php /** @scrutinizer ignore-call */ p($l->t('Access denied')); ?>
- </h1>
- <h2>
- <?php /** @scrutinizer ignore-call */ p($l->t('You are either not allowed to delete this poll or it doesn\'t exist.')); ?>
- </h2>
-</div>