@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | public function userInfo(?User $user, Packages $packages) |
57 | 57 | { |
58 | 58 | //If no user id was passed, then we show info about the current user |
59 | - if($user == null) { |
|
59 | + if ($user == null) { |
|
60 | 60 | $user = $this->getUser(); |
61 | 61 | } else { |
62 | 62 | //Else we must check, if the current user is allowed to access $user |
63 | 63 | $this->denyAccessUnlessGranted('read', $user); |
64 | 64 | } |
65 | 65 | |
66 | - if($this->getParameter("use_gravatar")) { |
|
66 | + if ($this->getParameter("use_gravatar")) { |
|
67 | 67 | $avatar = $this->getGravatar($user->getEmail(), 200, 'identicon'); |
68 | 68 | } else { |
69 | 69 | $avatar = $packages->getUrl("/img/default_avatar.png"); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $pw_form->handleRequest($request); |
128 | 128 | |
129 | 129 | //Check if password if everything was correct, then save it to User and DB |
130 | - if($pw_form->isSubmitted() && $pw_form->isValid()) { |
|
130 | + if ($pw_form->isSubmitted() && $pw_form->isValid()) { |
|
131 | 131 | $password = $passwordEncoder->encodePassword($user, $pw_form['new_password']->getData()); |
132 | 132 | $user->setPassword($password); |
133 | 133 | $em->persist($user); |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | $url .= md5(strtolower(trim($email))); |
165 | 165 | $url .= "?s=$s&d=$d&r=$r"; |
166 | 166 | if ($img) { |
167 | - $url = '<img src="' . $url . '"'; |
|
167 | + $url = '<img src="'.$url.'"'; |
|
168 | 168 | foreach ($atts as $key => $val) { |
169 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
169 | + $url .= ' '.$key.'="'.$val.'"'; |
|
170 | 170 | } |
171 | 171 | $url .= ' />'; |
172 | 172 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function supports($attribute, $subject) |
49 | 49 | { |
50 | - if($subject instanceof User) |
|
50 | + if ($subject instanceof User) |
|
51 | 51 | { |
52 | 52 | return in_array($attribute, array_merge( |
53 | 53 | $this->resolver->listOperationsForPermission('users'), |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function voteOnUser($attribute, $subject, User $user): bool |
71 | 71 | { |
72 | - if($subject instanceof User) |
|
72 | + if ($subject instanceof User) |
|
73 | 73 | { |
74 | 74 | //Check if the checked user is the user itself |
75 | - if($subject->getID() === $user->getID() && |
|
75 | + if ($subject->getID() === $user->getID() && |
|
76 | 76 | $this->resolver->isValidOperation('self', $attribute)) { |
77 | 77 | //Then we also need to check the self permission |
78 | 78 | $tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false; |
79 | 79 | //But if the self value is not allowed then use just the user value: |
80 | - if($tmp) |
|
80 | + if ($tmp) |
|
81 | 81 | return $tmp; |
82 | 82 | } |
83 | 83 | //Else just check users permission: |
@@ -77,8 +77,9 @@ |
||
77 | 77 | //Then we also need to check the self permission |
78 | 78 | $tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false; |
79 | 79 | //But if the self value is not allowed then use just the user value: |
80 | - if($tmp) |
|
81 | - return $tmp; |
|
80 | + if($tmp) { |
|
81 | + return $tmp; |
|
82 | + } |
|
82 | 83 | } |
83 | 84 | //Else just check users permission: |
84 | 85 | return $this->resolver->inherit($user, 'users', $attribute) ?? false; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | |
35 | 35 | //Check if a sub permission should be checked -> $attribute has format name.edit |
36 | - if(strpos($attribute, '.') !== false) { |
|
36 | + if (strpos($attribute, '.') !== false) { |
|
37 | 37 | [$perm, $op] = explode('.', $attribute); |
38 | 38 | return in_array($op, $this->resolver->listOperationsForPermission('parts_'.$perm), false); |
39 | 39 | } |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | |
49 | 49 | protected function voteOnUser($attribute, $subject, User $user): bool |
50 | 50 | { |
51 | - if($subject instanceof Part) { |
|
51 | + if ($subject instanceof Part) { |
|
52 | 52 | |
53 | 53 | //Check for sub permissions |
54 | - if(strpos($attribute, '.') !== false) { |
|
54 | + if (strpos($attribute, '.') !== false) { |
|
55 | 55 | [$perm, $op] = explode('.', $attribute); |
56 | - return $this->resolver->inherit($user, 'parts_'. $perm, $op) ?? false; |
|
56 | + return $this->resolver->inherit($user, 'parts_'.$perm, $op) ?? false; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | //Null concealing operator means, that no |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $em->persist($new_part); |
118 | 118 | $em->flush(); |
119 | 119 | $this->addFlash('success', $translator->trans('part.created_flash')); |
120 | - return $this->redirectToRoute('part_edit',['id' => $new_part->getID()]); |
|
120 | + return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $em->persist($new_part); |
149 | 149 | $em->flush(); |
150 | 150 | $this->addFlash('success', $translator->trans('part.created_flash')); |
151 | - return $this->redirectToRoute('part_edit',['id' => $new_part->getID()]); |
|
151 | + return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function infoURL($entity) : string |
62 | 62 | { |
63 | - if($entity instanceof Part) |
|
63 | + if ($entity instanceof Part) |
|
64 | 64 | { |
65 | 65 | return $this->urlGenerator->generate('part_info', ['id' => $entity->getID()]); |
66 | 66 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | public function editURL($entity) : string |
73 | 73 | { |
74 | - if($entity instanceof Part) |
|
74 | + if ($entity instanceof Part) |
|
75 | 75 | { |
76 | 76 | return $this->urlGenerator->generate('part_edit', ['id' => $entity->getID()]); |
77 | 77 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | public function createURL($entity) : string |
84 | 84 | { |
85 | - if($entity instanceof Part) |
|
85 | + if ($entity instanceof Part) |
|
86 | 86 | { |
87 | 87 | return $this->urlGenerator->generate('part_new'); |
88 | 88 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | public function cloneURL($entity) : string |
94 | 94 | { |
95 | - if($entity instanceof Part) |
|
95 | + if ($entity instanceof Part) |
|
96 | 96 | { |
97 | 97 | return $this->urlGenerator->generate('part_clone', ['id' => $entity->getID()]); |
98 | 98 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $href = $this->infoURL($entity); |
113 | 113 | |
114 | - if($entity instanceof NamedDBElement) |
|
114 | + if ($entity instanceof NamedDBElement) |
|
115 | 115 | { |
116 | 116 | return sprintf('<a href="%s">%s</a>', $href, $entity->getName()); |
117 | 117 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $user = $users[0]; |
51 | 51 | |
52 | 52 | |
53 | - if($user == null) |
|
53 | + if ($user == null) |
|
54 | 54 | { |
55 | 55 | $io->error(sprintf('No user with the given username %s found in the database!', $user_name)); |
56 | 56 | return; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | sprintf('You are going to change the password of %s with ID %d. Proceed?', |
63 | 63 | $user->getFullName(true), $user->getID())); |
64 | 64 | |
65 | - if(!$proceed) |
|
65 | + if (!$proceed) |
|
66 | 66 | { |
67 | 67 | return; |
68 | 68 | } |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | $success = false; |
71 | 71 | $new_password = ""; |
72 | 72 | |
73 | - while(!$success) { |
|
73 | + while (!$success) { |
|
74 | 74 | $pw1 = $io->askHidden("Please enter new password:"); |
75 | 75 | $pw2 = $io->askHidden('Please confirm:'); |
76 | - if($pw1 !== $pw2) { |
|
76 | + if ($pw1 !== $pw2) { |
|
77 | 77 | $io->error('The entered password did not match! Please try again.'); |
78 | 78 | } else { |
79 | 79 | //Exit loop |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | class User extends NamedDBElement implements UserInterface, HasPermissionsInterface |
49 | 49 | { |
50 | 50 | /** The User id of the anonymous user */ |
51 | - const ID_ANONYMOUS = 1; |
|
51 | + const ID_ANONYMOUS = 1; |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @ORM\Id() |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function getIDString(): string |
223 | 223 | { |
224 | - return 'U' . sprintf('%06d', $this->getID()); |
|
224 | + return 'U'.sprintf('%06d', $this->getID()); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function getFullName(bool $including_username = false) |
244 | 244 | { |
245 | - $str = $this->getFirstName() . ' ' . $this->getLastName(); |
|
245 | + $str = $this->getFirstName().' '.$this->getLastName(); |
|
246 | 246 | if ($including_username) { |
247 | - $str .= ' (' . $this->getName() . ')'; |
|
247 | + $str .= ' ('.$this->getName().')'; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | return $str; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | public function setName(string $new_name) : NamedDBElement |
255 | 255 | { |
256 | 256 | // Anonymous user is not allowed to change its username |
257 | - if(!$this->isAnonymousUser()) { |
|
257 | + if (!$this->isAnonymousUser()) { |
|
258 | 258 | $this->name = $new_name; |
259 | 259 | } |
260 | 260 |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | |
75 | 75 | public function getReadOperationName() : string |
76 | 76 | { |
77 | - if($this->prefix !== '') { |
|
78 | - return $this->prefix . '.' . $this->read; |
|
77 | + if ($this->prefix !== '') { |
|
78 | + return $this->prefix.'.'.$this->read; |
|
79 | 79 | } |
80 | 80 | return $this->read; |
81 | 81 | } |
82 | 82 | |
83 | 83 | public function getEditOperationName() : string |
84 | 84 | { |
85 | - if($this->prefix !== '') { |
|
86 | - return $this->prefix . '.' . $this->edit; |
|
85 | + if ($this->prefix !== '') { |
|
86 | + return $this->prefix.'.'.$this->edit; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $this->edit; |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | |
92 | 92 | public function getPlaceholder() |
93 | 93 | { |
94 | - if($this->placeholder === null) |
|
94 | + if ($this->placeholder === null) |
|
95 | 95 | { |
96 | - switch($this->type) |
|
96 | + switch ($this->type) |
|
97 | 97 | { |
98 | 98 | case 'integer': |
99 | 99 | return 0; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $properties = $reflectionClass->getProperties(); |
76 | 76 | $reader = new AnnotationReader(); |
77 | 77 | |
78 | - foreach($properties as $property) |
|
78 | + foreach ($properties as $property) |
|
79 | 79 | { |
80 | 80 | /** |
81 | 81 | * @var ColumnSecurity $annotation |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | $annotation = $reader->getPropertyAnnotation($property, |
84 | 84 | ColumnSecurity::class); |
85 | 85 | |
86 | - if($annotation !== null) |
|
86 | + if ($annotation !== null) |
|
87 | 87 | { |
88 | 88 | //Check if user is allowed to read info, otherwise apply placeholder |
89 | - if(!$this->security->isGranted($annotation->getReadOperationName(), $element)) |
|
89 | + if (!$this->security->isGranted($annotation->getReadOperationName(), $element)) |
|
90 | 90 | { |
91 | 91 | $property->setAccessible(true); |
92 | 92 | $property->setValue($element, $annotation->getPlaceholder()); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $properties = $reflectionClass->getProperties(); |
107 | 107 | $reader = new AnnotationReader(); |
108 | 108 | |
109 | - foreach($properties as $property) |
|
109 | + foreach ($properties as $property) |
|
110 | 110 | { |
111 | 111 | /** |
112 | 112 | * @var ColumnSecurity $annotation |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | $annotation = $reader->getPropertyAnnotation($property, |
115 | 115 | ColumnSecurity::class); |
116 | 116 | |
117 | - if($annotation !== null) |
|
117 | + if ($annotation !== null) |
|
118 | 118 | { |
119 | 119 | $field_name = $property->getName(); |
120 | 120 | |
121 | 121 | //Check if user is allowed to edit info, otherwise overwrite the new value |
122 | 122 | // so that nothing is changed in the DB. |
123 | - if($event->hasChangedField($field_name) && |
|
123 | + if ($event->hasChangedField($field_name) && |
|
124 | 124 | !$this->security->isGranted($annotation->getEditOperationName(), $element)) |
125 | 125 | { |
126 | 126 | $event->setNewValue($field_name, $event->getOldValue($field_name)); |