Completed
Pull Request — master (#5302)
by Björn
17:26
created
apps/sharebymail/lib/ShareByMailProvider.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 
211 211
 		$passwordPolicy = $this->getPasswordPolicy();
212
-		$passwordCharset = ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS;
212
+		$passwordCharset = ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS;
213 213
 		$passwordLength = 8;
214 214
 		if (!empty($passwordPolicy)) {
215
-			$passwordLength = (int)$passwordPolicy['minLength'] > 0 ? (int)$passwordPolicy['minLength'] : $passwordLength;
215
+			$passwordLength = (int) $passwordPolicy['minLength'] > 0 ? (int) $passwordPolicy['minLength'] : $passwordLength;
216 216
 			$passwordCharset .= $passwordPolicy['enforceSpecialCharacters'] ? ISecureRandom::CHAR_SYMBOLS : '';
217 217
 		}
218 218
 
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
 				$share->getSharedWith()
350 350
 			);
351 351
 		} catch (HintException $hintException) {
352
-			$this->logger->error('Failed to send share by mail: ' . $hintException->getMessage());
352
+			$this->logger->error('Failed to send share by mail: '.$hintException->getMessage());
353 353
 			$this->removeShareFromTable($shareId);
354 354
 			throw $hintException;
355 355
 		} catch (\Exception $e) {
356
-			$this->logger->error('Failed to send share by email: ' . $e->getMessage());
356
+			$this->logger->error('Failed to send share by email: '.$e->getMessage());
357 357
 			$this->removeShareFromTable($shareId);
358 358
 			throw new HintException('Failed to send share by mail',
359 359
 				$this->l->t('Failed to send share by email'));
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 											$shareWith) {
377 377
 		$initiatorUser = $this->userManager->get($initiator);
378 378
 		$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
379
-		$subject = (string)$this->l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename));
379
+		$subject = (string) $this->l->t('%s shared »%s« with you', array($initiatorDisplayName, $filename));
380 380
 
381 381
 		$message = $this->mailer->createMessage();
382 382
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 		$text = $this->l->t('%s shared »%s« with you.', [$initiatorDisplayName, $filename]);
388 388
 
389 389
 		$emailTemplate->addBodyText(
390
-			$text . ' ' . $this->l->t('Click the button below to open it.'),
390
+			$text.' '.$this->l->t('Click the button below to open it.'),
391 391
 			$text
392 392
 		);
393 393
 		$emailTemplate->addBodyButton(
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
 		// The "Reply-To" is set to the sharer if an mail address is configured
412 412
 		// also the default footer contains a "Do not reply" which needs to be adjusted.
413 413
 		$initiatorEmail = $initiatorUser->getEMailAddress();
414
-		if($initiatorEmail !== null) {
414
+		if ($initiatorEmail !== null) {
415 415
 			$message->setReplyTo([$initiatorEmail => $initiatorDisplayName]);
416
-			$emailTemplate->addFooter($instanceName . ' - ' . $this->defaults->getSlogan());
416
+			$emailTemplate->addFooter($instanceName.' - '.$this->defaults->getSlogan());
417 417
 		} else {
418 418
 			$emailTemplate->addFooter();
419 419
 		}
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
446 446
 		$initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
447 447
 
448
-		$subject = (string)$this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]);
448
+		$subject = (string) $this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]);
449 449
 		$plainBodyPart = $this->l->t("%s shared »%s« with you.\nYou should have already received a separate mail with a link to access it.\n", [$initiatorDisplayName, $filename]);
450 450
 		$htmlBodyPart = $this->l->t('%s shared »%s« with you. You should have already received a separate mail with a link to access it.', [$initiatorDisplayName, $filename]);
451 451
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		$message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]);
470 470
 		if ($initiatorEmailAddress !== null) {
471 471
 			$message->setReplyTo([$initiatorEmailAddress => $initiatorDisplayName]);
472
-			$emailTemplate->addFooter($instanceName . ' - ' . $this->defaults->getSlogan());
472
+			$emailTemplate->addFooter($instanceName.' - '.$this->defaults->getSlogan());
473 473
 		} else {
474 474
 			$emailTemplate->addFooter();
475 475
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 			);
509 509
 		}
510 510
 
511
-		$subject = (string)$this->l->t('Password to access »%s« shared with %s', [$filename, $shareWith]);
511
+		$subject = (string) $this->l->t('Password to access »%s« shared with %s', [$filename, $shareWith]);
512 512
 		$bodyPart = $this->l->t("You just shared »%s« with %s. The share was already send to the recipient. Due to the security policies defined by the administrator of %s each share needs to be protected by password and it is not allowed to send the password directly to the recipient. Therefore you need to forward the password manually to the recipient.", [$filename, $shareWith, $this->defaults->getName()]);
513 513
 
514 514
 		$message = $this->mailer->createMessage();
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 */
543 543
 	protected function generateToken($size = 15) {
544 544
 		$token = $this->secureRandom->generate(
545
-			$size, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
545
+			$size, ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS);
546 546
 		return $token;
547 547
 	}
548 548
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 			->orderBy('id');
564 564
 
565 565
 		$cursor = $qb->execute();
566
-		while($data = $cursor->fetch()) {
566
+		while ($data = $cursor->fetch()) {
567 567
 			$children[] = $this->createShareObject($data);
568 568
 		}
569 569
 		$cursor->closeCursor();
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 		$qb->execute();
608 608
 		$id = $qb->getLastInsertId();
609 609
 
610
-		return (int)$id;
610
+		return (int) $id;
611 611
 	}
612 612
 
613 613
 	/**
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 		// a real password was given
625 625
 		$validPassword = $plainTextPassword !== null && $plainTextPassword !== '';
626 626
 
627
-		if($validPassword && $originalShare->getPassword() !== $share->getPassword()) {
627
+		if ($validPassword && $originalShare->getPassword() !== $share->getPassword()) {
628 628
 			$this->sendPassword($share, $plainTextPassword);
629 629
 		}
630 630
 		/*
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 
719 719
 		$cursor = $qb->execute();
720 720
 		$shares = [];
721
-		while($data = $cursor->fetch()) {
721
+		while ($data = $cursor->fetch()) {
722 722
 			$shares[] = $this->createShareObject($data);
723 723
 		}
724 724
 		$cursor->closeCursor();
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 			->execute();
771 771
 
772 772
 		$shares = [];
773
-		while($data = $cursor->fetch()) {
773
+		while ($data = $cursor->fetch()) {
774 774
 			$shares[] = $this->createShareObject($data);
775 775
 		}
776 776
 		$cursor->closeCursor();
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 
810 810
 		$cursor = $qb->execute();
811 811
 
812
-		while($data = $cursor->fetch()) {
812
+		while ($data = $cursor->fetch()) {
813 813
 			$shares[] = $this->createShareObject($data);
814 814
 		}
815 815
 		$cursor->closeCursor();
@@ -872,15 +872,15 @@  discard block
 block discarded – undo
872 872
 	protected function createShareObject($data) {
873 873
 
874 874
 		$share = new Share($this->rootFolder, $this->userManager);
875
-		$share->setId((int)$data['id'])
876
-			->setShareType((int)$data['share_type'])
877
-			->setPermissions((int)$data['permissions'])
875
+		$share->setId((int) $data['id'])
876
+			->setShareType((int) $data['share_type'])
877
+			->setPermissions((int) $data['permissions'])
878 878
 			->setTarget($data['file_target'])
879
-			->setMailSend((bool)$data['mail_send'])
879
+			->setMailSend((bool) $data['mail_send'])
880 880
 			->setToken($data['token']);
881 881
 
882 882
 		$shareTime = new \DateTime();
883
-		$shareTime->setTimestamp((int)$data['stime']);
883
+		$shareTime->setTimestamp((int) $data['stime']);
884 884
 		$share->setShareTime($shareTime);
885 885
 		$share->setSharedWith($data['share_with']);
886 886
 		$share->setPassword($data['password']);
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 		} else {
892 892
 			//OLD SHARE
893 893
 			$share->setSharedBy($data['uid_owner']);
894
-			$path = $this->getNode($share->getSharedBy(), (int)$data['file_source']);
894
+			$path = $this->getNode($share->getSharedBy(), (int) $data['file_source']);
895 895
 
896 896
 			$owner = $path->getOwner();
897 897
 			$share->setShareOwner($owner->getUID());
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 			}
905 905
 		}
906 906
 
907
-		$share->setNodeId((int)$data['file_source']);
907
+		$share->setNodeId((int) $data['file_source']);
908 908
 		$share->setNodeType($data['item_type']);
909 909
 
910 910
 		$share->setProviderId($this->identifier());
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 			);
1024 1024
 		}
1025 1025
 
1026
-		$qb->innerJoin('s', 'filecache' ,'f', $qb->expr()->eq('s.file_source', 'f.fileid'));
1026
+		$qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid'));
1027 1027
 		$qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())));
1028 1028
 
1029 1029
 		$qb->orderBy('id');
Please login to merge, or discard this patch.