aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-03-28 15:04:39 +0200
committerThomas Citharel <tcit@tcit.fr>2017-06-23 09:26:41 +0200
commit2585953e0dae631b65c59b0e31196d65bdde84df (patch)
treeaa40f9658d13361c27399940e72d0d25e4b8d918
parent2041810adbc6e663e4520337805c0003c77762e2 (diff)
downloadwallabag-2585953e0dae631b65c59b0e31196d65bdde84df.tar.gz
wallabag-2585953e0dae631b65c59b0e31196d65bdde84df.tar.zst
wallabag-2585953e0dae631b65c59b0e31196d65bdde84df.zip
Fixed typos
-rw-r--r--src/Wallabag/GroupBundle/Controller/ManageController.php12
-rw-r--r--src/Wallabag/GroupBundle/Entity/Group.php14
-rw-r--r--src/Wallabag/GroupBundle/Entity/Invitation.php5
-rw-r--r--src/Wallabag/GroupBundle/Entity/UserGroup.php9
-rw-r--r--src/Wallabag/GroupBundle/Service/Sha256Salted.php2
-rw-r--r--src/Wallabag/UserBundle/Entity/User.php8
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
25 /** 25 /**
26 * Lists all public Group entities. 26 * Lists all public Group entities.
27 * 27 *
28 * @Route("/{page}", name="group_index", defaults={"page" = "1"}) 28 * @Route("/{page}", requirements={"page" = "\d+"}, name="group_index", defaults={"page" = "1"})
29 * @Method("GET") 29 * @Method("GET")
30 */ 30 */
31 public function indexAction($page = 1) 31 public function indexAction($page = 1)
@@ -182,24 +182,26 @@ class ManageController extends Controller
182 182
183 /** 183 /**
184 * @Route("/group-user-exclude/{group}/{user}", name="group-user-exclude") 184 * @Route("/group-user-exclude/{group}/{user}", name="group-user-exclude")
185 *
185 * @param Group $group 186 * @param Group $group
186 * @param User $user 187 * @param User $user
188 *
187 * @return Response 189 * @return Response
188 */ 190 */
189 public function excludeMemberAction(Group $group, User $user) 191 public function excludeMemberAction(Group $group, User $user)
190 { 192 {
191 $logger = $this->get('logger'); 193 $logger = $this->get('logger');
192 $logger->info('User ' . $this->getUser()->getUsername() . ' wants to exclude user ' . $user->getUsername() . ' from group ' . $group->getName()); 194 $logger->info('User '.$this->getUser()->getUsername().' wants to exclude user '.$user->getUsername().' from group '.$group->getName());
193 195
194 if (!$this->getUser()->inGroup($group) || $this->getUser()->getGroupRoleForUser($group) < Group::ROLE_MANAGE_USERS) { 196 if (!$this->getUser()->inGroup($group) || $this->getUser()->getGroupRoleForUser($group) < Group::ROLE_MANAGE_USERS) {
195 $logger->info('User ' . $this->getUser()->getUsername() . ' has not enough rights on group ' . $group->getName() . ' to exclude user ' . $user->getUsername()); 197 $logger->info('User '.$this->getUser()->getUsername().' has not enough rights on group '.$group->getName().' to exclude user '.$user->getUsername());
196 throw $this->createAccessDeniedException(); 198 throw $this->createAccessDeniedException();
197 } 199 }
198 200
199 if ($user->inGroup($group) && $user->getGroupRoleForUser($group) < Group::ROLE_ADMIN) { 201 if ($user->inGroup($group) && $user->getGroupRoleForUser($group) < Group::ROLE_ADMIN) {
200 $em = $this->getDoctrine()->getManager(); 202 $em = $this->getDoctrine()->getManager();
201 203
202 $logger->info('Removing user ' . $this->getUser()->getUsername() . ' from group ' . $group->getName()); 204 $logger->info('Removing user '.$this->getUser()->getUsername().' from group '.$group->getName());
203 $em->remove($this->getUser()->getUserGroupFromGroup($group)); 205 $em->remove($this->getUser()->getUserGroupFromGroup($group));
204 206
205 $em->flush(); 207 $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;
13 */ 13 */
14class Group extends BaseGroup 14class Group extends BaseGroup
15{ 15{
16
17 /** 16 /**
18 * User Roles 17 * User Roles.
19 */ 18 */
20 19
21 /** User can only preview presentations */ 20 /** User can only preview presentations */
@@ -34,7 +33,7 @@ class Group extends BaseGroup
34 const ROLE_ADMIN = 10; 33 const ROLE_ADMIN = 10;
35 34
36 /** 35 /**
37 * Group join access 36 * Group join access.
38 */ 37 */
39 38
40 /** Any user can join the group */ 39 /** Any user can join the group */
@@ -99,9 +98,10 @@ class Group extends BaseGroup
99 { 98 {
100 $userObj = new ArrayCollection(); 99 $userObj = new ArrayCollection();
101 foreach ($this->users as $userGroup) { 100 foreach ($this->users as $userGroup) {
102 /** @var UserGroup $userGroup */ 101 /* @var UserGroup $userGroup */
103 $userObj->add($userGroup->getUser()); 102 $userObj->add($userGroup->getUser());
104 } 103 }
104
105 return $userObj; 105 return $userObj;
106 } 106 }
107 107
@@ -177,24 +177,26 @@ class Group extends BaseGroup
177 public function getRequests() 177 public function getRequests()
178 { 178 {
179 $requests = new ArrayCollection(); 179 $requests = new ArrayCollection();
180 foreach ($this->users as $user) /** @var UserGroup $user */ 180 foreach ($this->users as $user) /* @var UserGroup $user */
181 { 181 {
182 if (!$user->isAccepted()) { 182 if (!$user->isAccepted()) {
183 $requests->add($user->getUser()); 183 $requests->add($user->getUser());
184 } 184 }
185 } 185 }
186
186 return $requests; 187 return $requests;
187 } 188 }
188 189
189 public function getInvited() 190 public function getInvited()
190 { 191 {
191 $invited = new ArrayCollection(); 192 $invited = new ArrayCollection();
192 foreach ($this->users as $userGroup) /** @var UserGroup $userGroup */ 193 foreach ($this->users as $userGroup) /* @var UserGroup $userGroup */
193 { 194 {
194 if ($userGroup->getInvitation()) { 195 if ($userGroup->getInvitation()) {
195 $invited->add($userGroup); 196 $invited->add($userGroup);
196 } 197 }
197 } 198 }
199
198 return $invited; 200 return $invited;
199 } 201 }
200} 202}
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;
6 6
7/** 7/**
8 * @ORM\Entity 8 * @ORM\Entity
9 * @ORM\Table(name="invitation")
9 */ 10 */
10class Invitation 11class Invitation
11{ 12{
@@ -42,7 +43,7 @@ class Invitation
42 /** 43 /**
43 * @return \DateTime 44 * @return \DateTime
44 */ 45 */
45 public function getDate(): \DateTime 46 public function getDate()
46 { 47 {
47 return $this->date; 48 return $this->date;
48 } 49 }
@@ -58,7 +59,7 @@ class Invitation
58 /** 59 /**
59 * @return mixed 60 * @return mixed
60 */ 61 */
61 public function getUserGroup(): UserGroup 62 public function getUserGroup()
62 { 63 {
63 return $this->userGroup; 64 return $this->userGroup;
64 } 65 }
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 @@
3namespace Wallabag\GroupBundle\Entity; 3namespace Wallabag\GroupBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use FOS\UserBundle\Model\GroupInterface;
7use Symfony\Component\Validator\Constraints as Assert;
8use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 6use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9use Wallabag\UserBundle\Entity\User; 7use Wallabag\UserBundle\Entity\User;
10 8
11/** 9/**
12 * @ORM\Entity(repositoryClass="Wallabag\GroupBundle\Repository\UserGroupRepository") 10 * @ORM\Entity(repositoryClass="Wallabag\GroupBundle\Repository\UserGroupRepository")
13 * @UniqueEntity({"user_id", "group_id"}) 11 * @UniqueEntity({"user_id", "group_id"})
14 * @ORM\Table(name="fos_user_group") 12 * @ORM\Table(name="user_group")
15 */ 13 */
16class UserGroup 14class UserGroup
17{ 15{
@@ -52,7 +50,8 @@ class UserGroup
52 50
53 /** 51 /**
54 * UserGroup constructor. 52 * UserGroup constructor.
55 * @param User $user 53 *
54 * @param User $user
56 * @param Group $group 55 * @param Group $group
57 * @param $role 56 * @param $role
58 */ 57 */
@@ -90,11 +89,13 @@ class UserGroup
90 89
91 /** 90 /**
92 * @param int $role 91 * @param int $role
92 *
93 * @return UserGroup 93 * @return UserGroup
94 */ 94 */
95 public function setRole($role) 95 public function setRole($role)
96 { 96 {
97 $this->role = $role; 97 $this->role = $role;
98
98 return $this; 99 return $this;
99 } 100 }
100 101
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
8{ 8{
9 public function encodePassword($raw, $salt) 9 public function encodePassword($raw, $salt)
10 { 10 {
11 return hash('sha256', $salt . $raw); // Custom function for password encrypt 11 return hash('sha256', $salt.$raw); // Custom function for password encrypt
12 } 12 }
13 13
14 public function isPasswordValid($encoded, $raw, $salt) 14 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
325 325
326 /** 326 /**
327 * @param Group $group 327 * @param Group $group
328 *
328 * @return UserGroup 329 * @return UserGroup
329 */ 330 */
330 public function getUserGroupFromGroup(Group $group) 331 public function getUserGroupFromGroup(Group $group)
@@ -334,6 +335,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
334 return $userGroup; 335 return $userGroup;
335 } 336 }
336 } 337 }
338
337 return null; 339 return null;
338 } 340 }
339 341
@@ -351,6 +353,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
351 353
352 /** 354 /**
353 * @param Group $group 355 * @param Group $group
356 *
354 * @return int 357 * @return int
355 */ 358 */
356 public function getGroupRoleForUser(Group $group) 359 public function getGroupRoleForUser(Group $group)
@@ -358,19 +361,23 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
358 if ($userGroup = $this->getUserGroupFromGroup($group)) { 361 if ($userGroup = $this->getUserGroupFromGroup($group)) {
359 return $userGroup->getRole(); 362 return $userGroup->getRole();
360 } 363 }
364
361 return 0; 365 return 0;
362 } 366 }
363 367
364 /** 368 /**
365 * @param Group $group 369 * @param Group $group
370 *
366 * @return bool 371 * @return bool
367 */ 372 */
368 public function inGroup(Group $group) 373 public function inGroup(Group $group)
369 { 374 {
370 if ($group::ACCESS_REQUEST === $group->getAcceptSystem()) { 375 if ($group::ACCESS_REQUEST === $group->getAcceptSystem()) {
371 $userGroup = $this->getUserGroupFromGroup($group); 376 $userGroup = $this->getUserGroupFromGroup($group);
377
372 return $userGroup->isAccepted(); 378 return $userGroup->isAccepted();
373 } 379 }
380
374 return null !== $this->getUserGroupFromGroup($group); 381 return null !== $this->getUserGroupFromGroup($group);
375 } 382 }
376 383
@@ -383,6 +390,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
383 foreach ($this->userGroups as $userGroup) { 390 foreach ($this->userGroups as $userGroup) {
384 $groups->add($userGroup->getGroup()); 391 $groups->add($userGroup->getGroup());
385 } 392 }
393
386 return $groups; 394 return $groups;
387 } 395 }
388} 396}