@@ -295,7 +295,7 @@ |
||
| 295 | 295 | /** |
| 296 | 296 | * @NoAdminRequired |
| 297 | 297 | * @return string |
| 298 | - */ |
|
| 298 | + */ |
|
| 299 | 299 | public function getAccessLevel(): string { |
| 300 | 300 | if ($this->getIsOwner()) { |
| 301 | 301 | return 'owner'; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | public function getGroupShare(): bool { |
| 183 | 183 | return count( |
| 184 | 184 | array_filter($this->shareMapper->findByPoll($this->getPollId()), function($item) { |
| 185 | - if ($item->getType() === 'group' && $this->groupManager->isInGroup($this->getUserId(),$item->getUserId())) { |
|
| 185 | + if ($item->getType() === 'group' && $this->groupManager->isInGroup($this->getUserId(), $item->getUserId())) { |
|
| 186 | 186 | return true; |
| 187 | 187 | } |
| 188 | 188 | }) |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @return bool |
| 253 | 253 | */ |
| 254 | 254 | public function getAllowSeeUsernames(): bool { |
| 255 | - return !(($this->poll->getAnonymous() && !$this->getIsOwner()) || $this->poll->getFullAnonymous());; |
|
| 255 | + return !(($this->poll->getAnonymous() && !$this->getIsOwner()) || $this->poll->getFullAnonymous()); ; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $this->foundByToken = true; |
| 297 | 297 | $this->setPollId($share->getPollId()); |
| 298 | 298 | |
| 299 | - if (($share->getType() === 'group' || $share->getType() === 'user') && !\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 299 | + if (($share->getType() === 'group' || $share->getType() === 'user') && !\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 300 | 300 | // User must be logged in for shareType user and group |
| 301 | 301 | $this->setPollId(0); |
| 302 | 302 | $this->setUserId(null); |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * Anonymizes the participants of a poll |
|
| 49 | - * @NoAdminRequired |
|
| 50 | - * @param Array $array Input list which should be anonymized must be a collection of Vote or Comment |
|
| 51 | - * @return array Returns the original array with anonymized user names |
|
| 52 | - */ |
|
| 48 | + * Anonymizes the participants of a poll |
|
| 49 | + * @NoAdminRequired |
|
| 50 | + * @param Array $array Input list which should be anonymized must be a collection of Vote or Comment |
|
| 51 | + * @return array Returns the original array with anonymized user names |
|
| 52 | + */ |
|
| 53 | 53 | private function anonymize($array) { |
| 54 | 54 | // get mapping for the complete poll |
| 55 | 55 | foreach ($array as &$element) { |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | - * Initialize anonymizer with pollId and userId |
|
| 74 | - * Creates a mapping list with unique Anonymous strings based on the partcipants of a poll |
|
| 75 | - * @NoAdminRequired |
|
| 76 | - * @param integer $pollId |
|
| 77 | - * @param string $userId - usernames, which will not be anonymized |
|
| 78 | - */ |
|
| 73 | + * Initialize anonymizer with pollId and userId |
|
| 74 | + * Creates a mapping list with unique Anonymous strings based on the partcipants of a poll |
|
| 75 | + * @NoAdminRequired |
|
| 76 | + * @param integer $pollId |
|
| 77 | + * @param string $userId - usernames, which will not be anonymized |
|
| 78 | + */ |
|
| 79 | 79 | |
| 80 | 80 | public function set($pollId, $userId) { |
| 81 | 81 | $this->pollId = $pollId; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | $votes = $this->voteMapper->findParticipantsByPoll($pollId); |
| 172 | 172 | foreach ($votes as $vote) { |
| 173 | - if ($vote->getUserId() !== '' && $vote->getUserId() !== null ) { |
|
| 173 | + if ($vote->getUserId() !== '' && $vote->getUserId() !== null) { |
|
| 174 | 174 | $list[] = [ |
| 175 | 175 | 'id' => $vote->getUserId(), |
| 176 | 176 | 'user' => $vote->getUserId(), |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $shares = $this->shareMapper->findByPoll($pollId); |
| 184 | 184 | foreach ($shares as $share) { |
| 185 | - if ($share->getUserId() !== '' && $share->getUserId() !== null ) { |
|
| 185 | + if ($share->getUserId() !== '' && $share->getUserId() !== null) { |
|
| 186 | 186 | $list[] = [ |
| 187 | 187 | 'id' => $share->getUserId(), |
| 188 | 188 | 'user' => $share->getUserId(), |
@@ -52,11 +52,11 @@ |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Read acl with poll id for current user |
|
| 56 | - * @NoAdminRequired |
|
| 57 | - * @param integer $pollId |
|
| 58 | - * @return array |
|
| 59 | - */ |
|
| 55 | + * Read acl with poll id for current user |
|
| 56 | + * @NoAdminRequired |
|
| 57 | + * @param integer $pollId |
|
| 58 | + * @return array |
|
| 59 | + */ |
|
| 60 | 60 | public function get($id) { |
| 61 | 61 | $acl = $this->acl->setPollId($id); |
| 62 | 62 | // $acl = $this->acl->setUserId('dartcafe'); |
@@ -7,30 +7,30 @@ |
||
| 7 | 7 | |
| 8 | 8 | class FactoryMuffin extends OriginalFactoryMuffin |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Generate and set the model attributes. |
|
| 12 | - * NOTE: Patch the original method to support dynamic setter and getter |
|
| 13 | - * of the OCP\AppFramework\Db\Entity class |
|
| 14 | - * |
|
| 15 | - * @param object $model The model instance. |
|
| 16 | - * @param array $attr The model attributes. |
|
| 17 | - * |
|
| 18 | - * @return void |
|
| 19 | - */ |
|
| 20 | - protected function generate($model, array $attr = []) |
|
| 21 | - { |
|
| 22 | - foreach ($attr as $key => $kind) { |
|
| 23 | - $value = $this->factory->generate($kind, $model, $this); |
|
| 10 | + /** |
|
| 11 | + * Generate and set the model attributes. |
|
| 12 | + * NOTE: Patch the original method to support dynamic setter and getter |
|
| 13 | + * of the OCP\AppFramework\Db\Entity class |
|
| 14 | + * |
|
| 15 | + * @param object $model The model instance. |
|
| 16 | + * @param array $attr The model attributes. |
|
| 17 | + * |
|
| 18 | + * @return void |
|
| 19 | + */ |
|
| 20 | + protected function generate($model, array $attr = []) |
|
| 21 | + { |
|
| 22 | + foreach ($attr as $key => $kind) { |
|
| 23 | + $value = $this->factory->generate($kind, $model, $this); |
|
| 24 | 24 | |
| 25 | - $setter = 'set'.ucfirst(static::camelize($key)); |
|
| 26 | - // check if there is a setter and use it instead |
|
| 27 | - if ($model instanceof Entity && is_callable([$model, $setter])) { |
|
| 28 | - $model->$setter($value); |
|
| 29 | - } elseif (method_exists($model, $setter) && is_callable([$model, $setter])) { |
|
| 30 | - $model->$setter($value); |
|
| 31 | - } else { |
|
| 32 | - $model->$key = $value; |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 25 | + $setter = 'set'.ucfirst(static::camelize($key)); |
|
| 26 | + // check if there is a setter and use it instead |
|
| 27 | + if ($model instanceof Entity && is_callable([$model, $setter])) { |
|
| 28 | + $model->$setter($value); |
|
| 29 | + } elseif (method_exists($model, $setter) && is_callable([$model, $setter])) { |
|
| 30 | + $model->$setter($value); |
|
| 31 | + } else { |
|
| 32 | + $model->$key = $value; |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | foreach ($attr as $key => $kind) { |
| 23 | 23 | $value = $this->factory->generate($kind, $model, $this); |
| 24 | 24 | |
| 25 | - $setter = 'set'.ucfirst(static::camelize($key)); |
|
| 25 | + $setter = 'set' . ucfirst(static::camelize($key)); |
|
| 26 | 26 | // check if there is a setter and use it instead |
| 27 | 27 | if ($model instanceof Entity && is_callable([$model, $setter])) { |
| 28 | 28 | $model->$setter($value); |
@@ -5,8 +5,7 @@ discard block |
||
| 5 | 5 | use League\FactoryMuffin\FactoryMuffin as OriginalFactoryMuffin; |
| 6 | 6 | use OCP\AppFramework\Db\Entity; |
| 7 | 7 | |
| 8 | -class FactoryMuffin extends OriginalFactoryMuffin |
|
| 9 | -{ |
|
| 8 | +class FactoryMuffin extends OriginalFactoryMuffin { |
|
| 10 | 9 | /** |
| 11 | 10 | * Generate and set the model attributes. |
| 12 | 11 | * NOTE: Patch the original method to support dynamic setter and getter |
@@ -17,8 +16,7 @@ discard block |
||
| 17 | 16 | * |
| 18 | 17 | * @return void |
| 19 | 18 | */ |
| 20 | - protected function generate($model, array $attr = []) |
|
| 21 | - { |
|
| 19 | + protected function generate($model, array $attr = []) { |
|
| 22 | 20 | foreach ($attr as $key => $kind) { |
| 23 | 21 | $value = $this->factory->generate($kind, $model, $this); |
| 24 | 22 | |
@@ -154,18 +154,18 @@ |
||
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * Public functions |
| 157 | - */ |
|
| 157 | + */ |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | - * setByToken |
|
| 161 | - * @NoAdminRequired |
|
| 162 | - * @PublicPage |
|
| 163 | - * @NoCSRFRequired |
|
| 164 | - * @param Array $option |
|
| 165 | - * @param string $setTo |
|
| 166 | - * @param string $token |
|
| 167 | - * @return DataResponse |
|
| 168 | - */ |
|
| 160 | + * setByToken |
|
| 161 | + * @NoAdminRequired |
|
| 162 | + * @PublicPage |
|
| 163 | + * @NoCSRFRequired |
|
| 164 | + * @param Array $option |
|
| 165 | + * @param string $setTo |
|
| 166 | + * @param string $token |
|
| 167 | + * @return DataResponse |
|
| 168 | + */ |
|
| 169 | 169 | public function setByToken($option, $setTo, $token) { |
| 170 | 170 | try { |
| 171 | 171 | $this->acl->setToken($token); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | use OCA\Polls\Db\Log; |
| 30 | 30 | use OCA\Polls\Db\LogMapper; |
| 31 | 31 | |
| 32 | -class LogService { |
|
| 32 | +class LogService { |
|
| 33 | 33 | |
| 34 | 34 | private $mapper; |
| 35 | 35 | private $logItem; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function isRepetition() { |
| 58 | 58 | try { |
| 59 | 59 | $lastRecord = $this->mapper->getLastRecord($this->logItem->getPollId()); |
| 60 | - return ( intval($lastRecord->getPollId()) === intval($this->logItem->getPollId()) |
|
| 60 | + return (intval($lastRecord->getPollId()) === intval($this->logItem->getPollId()) |
|
| 61 | 61 | && $lastRecord->getUserId() === $this->logItem->getUserId() |
| 62 | 62 | && $lastRecord->getMessageId() === $this->logItem->getMessageId() |
| 63 | 63 | && $lastRecord->getMessage() === $this->logItem->getMessage() |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | use OCA\Polls\Db\Log; |
| 30 | 30 | use OCA\Polls\Db\LogMapper; |
| 31 | 31 | |
| 32 | -class LogService { |
|
| 32 | +class LogService { |
|
| 33 | 33 | |
| 34 | 34 | private $mapper; |
| 35 | 35 | private $logItem; |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Prevent repetition of the same log event |
|
| 54 | - * @NoAdminRequired |
|
| 55 | - * @return Bool |
|
| 56 | - */ |
|
| 53 | + * Prevent repetition of the same log event |
|
| 54 | + * @NoAdminRequired |
|
| 55 | + * @return Bool |
|
| 56 | + */ |
|
| 57 | 57 | public function isRepetition() { |
| 58 | 58 | try { |
| 59 | 59 | $lastRecord = $this->mapper->getLastRecord($this->logItem->getPollId()); |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Log poll activity |
|
| 72 | - * @NoAdminRequired |
|
| 73 | - * @param $pollId |
|
| 74 | - * @param $messageId |
|
| 75 | - * @param $userId |
|
| 76 | - * @param $message |
|
| 77 | - * @return Log |
|
| 78 | - */ |
|
| 71 | + * Log poll activity |
|
| 72 | + * @NoAdminRequired |
|
| 73 | + * @param $pollId |
|
| 74 | + * @param $messageId |
|
| 75 | + * @param $userId |
|
| 76 | + * @param $message |
|
| 77 | + * @return Log |
|
| 78 | + */ |
|
| 79 | 79 | public function setLog($pollId, $messageId, $userId = null, $message = null) { |
| 80 | 80 | $this->logItem = new Log(); |
| 81 | 81 | $this->logItem->setPollId($pollId); |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | if (!$toEmail || !filter_var($toEmail, FILTER_VALIDATE_EMAIL)) { |
| 123 | - throw new Exception( 'Invalid email address (' . $toEmail .')' ); |
|
| 123 | + throw new Exception( 'Invalid email address (' . $toEmail .')' ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | try { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | use OCA\Polls\Db\Share; |
| 42 | 42 | use OCA\Polls\Db\LogMapper; |
| 43 | 43 | |
| 44 | -class MailService { |
|
| 44 | +class MailService { |
|
| 45 | 45 | |
| 46 | 46 | private $userManager; |
| 47 | 47 | private $groupManager; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | use OCA\Polls\Db\Share; |
| 42 | 42 | use OCA\Polls\Db\LogMapper; |
| 43 | 43 | |
| 44 | -class MailService { |
|
| 44 | +class MailService { |
|
| 45 | 45 | |
| 46 | 46 | private $userManager; |
| 47 | 47 | private $groupManager; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | if (!$toEmail || !filter_var($toEmail, FILTER_VALIDATE_EMAIL)) { |
| 123 | - throw new Exception( 'Invalid email address (' . $toEmail .')' ); |
|
| 123 | + throw new Exception('Invalid email address (' . $toEmail . ')'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | try { |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $emailTemplate->addBodyText(str_replace( |
| 253 | 253 | ['{owner}', '{title}'], |
| 254 | 254 | [$owner->getDisplayName(), $poll->getTitle()], |
| 255 | - $trans->t('{owner} invited you to take part in the poll "{title}"' ) |
|
| 255 | + $trans->t('{owner} invited you to take part in the poll "{title}"') |
|
| 256 | 256 | )); |
| 257 | 257 | |
| 258 | 258 | $emailTemplate->addBodyButton( |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $recipient['link'] |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | - $emailTemplate->addFooter($trans->t('This email is sent to you, because you are invited to vote in this poll by the poll owner.' )); |
|
| 263 | + $emailTemplate->addFooter($trans->t('This email is sent to you, because you are invited to vote in this poll by the poll owner.')); |
|
| 264 | 264 | |
| 265 | 265 | try { |
| 266 | 266 | $this->sendMail( |
@@ -325,27 +325,27 @@ discard block |
||
| 325 | 325 | } elseif ($logItem->getMessageId() === 'setVote') { |
| 326 | 326 | $emailTemplate->addBodyText($trans->t( |
| 327 | 327 | '- %s voted.', |
| 328 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 328 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 329 | 329 | ); |
| 330 | 330 | } elseif ($logItem->getMessageId() === 'updatePoll') { |
| 331 | 331 | $emailTemplate->addBodyText($trans->t( |
| 332 | 332 | '- %s updated the poll configuration. Please check your votes.', |
| 333 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 333 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 334 | 334 | ); |
| 335 | 335 | } elseif ($logItem->getMessageId() === 'deletePoll') { |
| 336 | 336 | $emailTemplate->addBodyText($trans->t( |
| 337 | 337 | '- %s deleted the poll.', |
| 338 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 338 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 339 | 339 | ); |
| 340 | 340 | } elseif ($logItem->getMessageId() === 'restorePoll') { |
| 341 | 341 | $emailTemplate->addBodyText($trans->t( |
| 342 | 342 | '- %s restored the poll.', |
| 343 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 343 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 344 | 344 | ); |
| 345 | 345 | } elseif ($logItem->getMessageId() === 'expirePoll') { |
| 346 | 346 | $emailTemplate->addBodyText($trans->t( |
| 347 | 347 | '- The poll expired.', |
| 348 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 348 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 349 | 349 | ); |
| 350 | 350 | } |
| 351 | 351 | |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | $url, |
| 361 | 361 | /** @scrutinizer ignore-type */ false |
| 362 | 362 | ); |
| 363 | - $emailTemplate->addFooter($trans->t('This email is sent to you, because you subscribed to notifications of this poll. To opt out, visit the poll and remove your subscription.' )); |
|
| 363 | + $emailTemplate->addFooter($trans->t('This email is sent to you, because you subscribed to notifications of this poll. To opt out, visit the poll and remove your subscription.')); |
|
| 364 | 364 | |
| 365 | 365 | try { |
| 366 | - $this->sendMail( $emailTemplate, $subscription->getUserId()); |
|
| 366 | + $this->sendMail($emailTemplate, $subscription->getUserId()); |
|
| 367 | 367 | } catch (Exeption $e) { |
| 368 | 368 | // todo alert Owner |
| 369 | 369 | // Notification to $subscription->getUserId() could not be sent |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | ->from($this->getTableName()) |
| 82 | 82 | ->where($qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))) |
| 83 | 83 | ->setMaxResults( 1 ) |
| 84 | - ->orderBy('id', 'DESC'); |
|
| 84 | + ->orderBy('id', 'DESC'); |
|
| 85 | 85 | |
| 86 | 86 | return $this->findEntity($qb); |
| 87 | 87 | |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $qb->select('*') |
| 81 | 81 | ->from($this->getTableName()) |
| 82 | 82 | ->where($qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))) |
| 83 | - ->setMaxResults( 1 ) |
|
| 83 | + ->setMaxResults(1) |
|
| 84 | 84 | ->orderBy('id', 'DESC'); |
| 85 | 85 | |
| 86 | 86 | return $this->findEntity($qb); |