Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stable15' into stable15
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed May 2, 2019
2 parents 0cd2bbd + 99b7852 commit 1261d00
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions lib/Service/MembersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@


use Exception;
use OC;
use OC\User\NoUserException;
use OCA\Circles\Db\CirclesRequest;
use OCA\Circles\Db\MembersRequest;
Expand All @@ -36,7 +37,6 @@
use OCA\Circles\Exceptions\EmailAccountInvalidFormatException;
use OCA\Circles\Exceptions\GroupDoesNotExistException;
use OCA\Circles\Exceptions\MemberAlreadyExistsException;
use OCA\Circles\Exceptions\MembersLimitException;
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\Member;
use OCP\IL10N;
Expand Down Expand Up @@ -117,7 +117,7 @@ public function __construct(
* @param int $type
*
* @return array
* @throws \Exception
* @throws Exception
*/
public function addMember($circleUniqueId, $ident, $type) {

Expand All @@ -129,7 +129,7 @@ public function addMember($circleUniqueId, $ident, $type) {
if (!$this->addMassiveMembers($circle, $ident, $type)) {
$this->addSingleMember($circle, $ident, $type);
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}

Expand Down Expand Up @@ -207,7 +207,7 @@ private function addMemberBasedOnItsType(Circle $circle, Member &$member) {
* @param Circle $circle
* @param Member $member
*
* @throws \Exception
* @throws Exception
*/
private function addLocalMember(Circle $circle, Member $member) {

Expand All @@ -224,7 +224,7 @@ private function addLocalMember(Circle $circle, Member $member) {
*
* @param Member $member
*
* @throws \Exception
* @throws Exception
*/
private function addEmailAddress(Member $member) {

Expand All @@ -241,7 +241,7 @@ private function addEmailAddress(Member $member) {
*
* @param Member $member
*
* @throws \Exception
* @throws Exception
*/
private function addContact(Member $member) {

Expand Down Expand Up @@ -338,12 +338,12 @@ private function verifyIdentContact(&$ident, $type) {
* @param string $groupId
*
* @return bool
* @throws \Exception
* @throws Exception
*/
private function addGroupMembers(Circle $circle, $groupId) {

$group = \OC::$server->getGroupManager()
->get($groupId);
$group = OC::$server->getGroupManager()
->get($groupId);
if ($group === null) {
throw new GroupDoesNotExistException($this->l10n->t('This group does not exist'));
}
Expand All @@ -352,7 +352,7 @@ private function addGroupMembers(Circle $circle, $groupId) {
try {
$this->addSingleMember($circle, $user->getUID(), Member::TYPE_USER);
} catch (MemberAlreadyExistsException $e) {
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
Expand All @@ -369,13 +369,17 @@ private function addGroupMembers(Circle $circle, $groupId) {
*/
private function addMassiveMails(Circle $circle, $mails) {

foreach (explode(' ', trim($mails)) as $mail) {
$mails = trim($mails);
if (substr($mails, 0, 6) !== 'mails:') {
return false;
}

$mails = substr($mails, 6);
foreach (explode(' ', $mails) as $mail) {
if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
return false;
continue;
}
}

foreach (explode(' ', trim($mails)) as $mail) {
try {
$this->addMember($circle->getUniqueId(), $mail, Member::TYPE_MAIL);
} catch (Exception $e) {
Expand Down Expand Up @@ -410,7 +414,7 @@ public function getMember($circleId, $userId, $type) {
$member->setNote('');

return $member;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
Expand All @@ -423,7 +427,7 @@ public function getMember($circleId, $userId, $type) {
* @param int $level
*
* @return array
* @throws \Exception
* @throws Exception
*/
public function levelMember($circleUniqueId, $name, $type, $level) {

Expand All @@ -443,7 +447,7 @@ public function levelMember($circleUniqueId, $name, $type, $level) {
return $this->membersRequest->getMembers(
$circle->getUniqueId(), $circle->getHigherViewer()
);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}

Expand Down Expand Up @@ -477,7 +481,7 @@ private function updateMemberLevel(Circle $circle, Member $member, $level) {
* @param Member $member
* @param $level
*
* @throws \Exception
* @throws Exception
*/
private function editMemberLevel(Circle $circle, Member &$member, $level) {
try {
Expand All @@ -491,7 +495,7 @@ private function editMemberLevel(Circle $circle, Member &$member, $level) {

$member->setLevel($level);
$this->membersRequest->updateMember($member);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}

Expand All @@ -501,7 +505,7 @@ private function editMemberLevel(Circle $circle, Member &$member, $level) {
* @param Circle $circle
* @param Member $member
*
* @throws \Exception
* @throws Exception
*/
private function switchOwner(Circle $circle, Member &$member) {
try {
Expand All @@ -519,7 +523,7 @@ private function switchOwner(Circle $circle, Member &$member) {
$isMod->setLevel(Member::LEVEL_ADMIN);
$this->membersRequest->updateMember($isMod);

} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
Expand All @@ -531,7 +535,7 @@ private function switchOwner(Circle $circle, Member &$member) {
* @param $type
*
* @return array
* @throws \Exception
* @throws Exception
*/
public function removeMember($circleUniqueId, $name, $type) {

Expand All @@ -546,7 +550,7 @@ public function removeMember($circleUniqueId, $name, $type) {

$circle->getHigherViewer()
->hasToBeHigherLevel($member->getLevel());
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}

Expand Down

0 comments on commit 1261d00

Please sign in to comment.