From 2585953e0dae631b65c59b0e31196d65bdde84df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 28 Mar 2017 15:04:39 +0200 Subject: Fixed typos --- src/Wallabag/GroupBundle/Controller/ManageController.php | 12 +++++++----- src/Wallabag/GroupBundle/Entity/Group.php | 14 ++++++++------ src/Wallabag/GroupBundle/Entity/Invitation.php | 5 +++-- src/Wallabag/GroupBundle/Entity/UserGroup.php | 9 +++++---- src/Wallabag/GroupBundle/Service/Sha256Salted.php | 2 +- src/Wallabag/UserBundle/Entity/User.php | 8 ++++++++ 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Wallabag/GroupBundle/Controller/ManageController.php b/src/Wallabag/GroupBundle/Controller/ManageController.php index 94196040..31a0c7b1 100644 --- a/src/Wallabag/GroupBundle/Controller/ManageController.php +++ b/src/Wallabag/GroupBundle/Controller/ManageController.php @@ -25,7 +25,7 @@ class ManageController extends Controller /** * Lists all public Group entities. * - * @Route("/{page}", name="group_index", defaults={"page" = "1"}) + * @Route("/{page}", requirements={"page" = "\d+"}, name="group_index", defaults={"page" = "1"}) * @Method("GET") */ public function indexAction($page = 1) @@ -182,24 +182,26 @@ class ManageController extends Controller /** * @Route("/group-user-exclude/{group}/{user}", name="group-user-exclude") + * * @param Group $group - * @param User $user + * @param User $user + * * @return Response */ public function excludeMemberAction(Group $group, User $user) { $logger = $this->get('logger'); - $logger->info('User ' . $this->getUser()->getUsername() . ' wants to exclude user ' . $user->getUsername() . ' from group ' . $group->getName()); + $logger->info('User '.$this->getUser()->getUsername().' wants to exclude user '.$user->getUsername().' from group '.$group->getName()); if (!$this->getUser()->inGroup($group) || $this->getUser()->getGroupRoleForUser($group) < Group::ROLE_MANAGE_USERS) { - $logger->info('User ' . $this->getUser()->getUsername() . ' has not enough rights on group ' . $group->getName() . ' to exclude user ' . $user->getUsername()); + $logger->info('User '.$this->getUser()->getUsername().' has not enough rights on group '.$group->getName().' to exclude user '.$user->getUsername()); throw $this->createAccessDeniedException(); } if ($user->inGroup($group) && $user->getGroupRoleForUser($group) < Group::ROLE_ADMIN) { $em = $this->getDoctrine()->getManager(); - $logger->info('Removing user ' . $this->getUser()->getUsername() . ' from group ' . $group->getName()); + $logger->info('Removing user '.$this->getUser()->getUsername().' from group '.$group->getName()); $em->remove($this->getUser()->getUserGroupFromGroup($group)); $em->flush(); diff --git a/src/Wallabag/GroupBundle/Entity/Group.php b/src/Wallabag/GroupBundle/Entity/Group.php index 31c82837..28b0227c 100644 --- a/src/Wallabag/GroupBundle/Entity/Group.php +++ b/src/Wallabag/GroupBundle/Entity/Group.php @@ -13,9 +13,8 @@ use Wallabag\UserBundle\Entity\User; */ class Group extends BaseGroup { - /** - * User Roles + * User Roles. */ /** User can only preview presentations */ @@ -34,7 +33,7 @@ class Group extends BaseGroup const ROLE_ADMIN = 10; /** - * Group join access + * Group join access. */ /** Any user can join the group */ @@ -99,9 +98,10 @@ class Group extends BaseGroup { $userObj = new ArrayCollection(); foreach ($this->users as $userGroup) { - /** @var UserGroup $userGroup */ + /* @var UserGroup $userGroup */ $userObj->add($userGroup->getUser()); } + return $userObj; } @@ -177,24 +177,26 @@ class Group extends BaseGroup public function getRequests() { $requests = new ArrayCollection(); - foreach ($this->users as $user) /** @var UserGroup $user */ + foreach ($this->users as $user) /* @var UserGroup $user */ { if (!$user->isAccepted()) { $requests->add($user->getUser()); } } + return $requests; } public function getInvited() { $invited = new ArrayCollection(); - foreach ($this->users as $userGroup) /** @var UserGroup $userGroup */ + foreach ($this->users as $userGroup) /* @var UserGroup $userGroup */ { if ($userGroup->getInvitation()) { $invited->add($userGroup); } } + return $invited; } } diff --git a/src/Wallabag/GroupBundle/Entity/Invitation.php b/src/Wallabag/GroupBundle/Entity/Invitation.php index 6946bede..e944b348 100644 --- a/src/Wallabag/GroupBundle/Entity/Invitation.php +++ b/src/Wallabag/GroupBundle/Entity/Invitation.php @@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity + * @ORM\Table(name="invitation") */ class Invitation { @@ -42,7 +43,7 @@ class Invitation /** * @return \DateTime */ - public function getDate(): \DateTime + public function getDate() { return $this->date; } @@ -58,7 +59,7 @@ class Invitation /** * @return mixed */ - public function getUserGroup(): UserGroup + public function getUserGroup() { return $this->userGroup; } diff --git a/src/Wallabag/GroupBundle/Entity/UserGroup.php b/src/Wallabag/GroupBundle/Entity/UserGroup.php index 22d1400a..0c40b0d3 100644 --- a/src/Wallabag/GroupBundle/Entity/UserGroup.php +++ b/src/Wallabag/GroupBundle/Entity/UserGroup.php @@ -3,15 +3,13 @@ namespace Wallabag\GroupBundle\Entity; use Doctrine\ORM\Mapping as ORM; -use FOS\UserBundle\Model\GroupInterface; -use Symfony\Component\Validator\Constraints as Assert; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Wallabag\UserBundle\Entity\User; /** * @ORM\Entity(repositoryClass="Wallabag\GroupBundle\Repository\UserGroupRepository") * @UniqueEntity({"user_id", "group_id"}) - * @ORM\Table(name="fos_user_group") + * @ORM\Table(name="user_group") */ class UserGroup { @@ -52,7 +50,8 @@ class UserGroup /** * UserGroup constructor. - * @param User $user + * + * @param User $user * @param Group $group * @param $role */ @@ -90,11 +89,13 @@ class UserGroup /** * @param int $role + * * @return UserGroup */ public function setRole($role) { $this->role = $role; + return $this; } diff --git a/src/Wallabag/GroupBundle/Service/Sha256Salted.php b/src/Wallabag/GroupBundle/Service/Sha256Salted.php index c72486ad..053aaefa 100644 --- a/src/Wallabag/GroupBundle/Service/Sha256Salted.php +++ b/src/Wallabag/GroupBundle/Service/Sha256Salted.php @@ -8,7 +8,7 @@ class Sha256Salted implements PasswordEncoderInterface { public function encodePassword($raw, $salt) { - return hash('sha256', $salt . $raw); // Custom function for password encrypt + return hash('sha256', $salt.$raw); // Custom function for password encrypt } public function isPasswordValid($encoded, $raw, $salt) diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index 2b73e344..4f24b17a 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php @@ -325,6 +325,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf /** * @param Group $group + * * @return UserGroup */ public function getUserGroupFromGroup(Group $group) @@ -334,6 +335,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf return $userGroup; } } + return null; } @@ -351,6 +353,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf /** * @param Group $group + * * @return int */ public function getGroupRoleForUser(Group $group) @@ -358,19 +361,23 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf if ($userGroup = $this->getUserGroupFromGroup($group)) { return $userGroup->getRole(); } + return 0; } /** * @param Group $group + * * @return bool */ public function inGroup(Group $group) { if ($group::ACCESS_REQUEST === $group->getAcceptSystem()) { $userGroup = $this->getUserGroupFromGroup($group); + return $userGroup->isAccepted(); } + return null !== $this->getUserGroupFromGroup($group); } @@ -383,6 +390,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf foreach ($this->userGroups as $userGroup) { $groups->add($userGroup->getGroup()); } + return $groups; } } -- cgit v1.2.3