@@ -79,13 +79,7 @@ public function requestGroup(
7979 if ($ this ->SQL ->accDeletionRequestExists ($ this ->getOwner ()->uid )) {
8080 return ;
8181 }
82- $ this ->SQL ->addRequest (
83- $ this ->getOwner ()->uid ,
84- $ firstname ,
85- $ lastname ,
86- $ email ,
87- $ org ,
88- );
82+ $ this ->SQL ->addRequest ($ this ->getOwner ()->uid , $ firstname , $ lastname , $ email , $ org );
8983 if ($ send_mail ) {
9084 $ this ->MAILER ->sendMail ($ email , "group_request " );
9185 $ this ->WEBHOOK ->sendWebhook ("group_request_admin " , [
@@ -114,10 +108,8 @@ public function requestGroup(
114108 /**
115109 * This method will create the group (this is what is executed when an admin approved the group)
116110 */
117- public function approveGroup (
118- ?UnityUser $ operator = null ,
119- bool $ send_mail = true ,
120- ): void {
111+ public function approveGroup (?UnityUser $ operator = null , bool $ send_mail = true ): void
112+ {
121113 $ uid = $ this ->getOwner ()->uid ;
122114 $ request = $ this ->SQL ->getRequest ($ uid , UnitySQL::REQUEST_BECOME_PI );
123115 if ($ this ->exists ()) {
@@ -134,9 +126,7 @@ public function approveGroup(
134126 }
135127 $ this ->init ();
136128 $ this ->SQL ->removeRequest ($ this ->getOwner ()->uid );
137- $ operator = is_null ($ operator )
138- ? $ this ->getOwner ()->uid
139- : $ operator ->uid ;
129+ $ operator = is_null ($ operator ) ? $ this ->getOwner ()->uid : $ operator ->uid ;
140130 $ this ->SQL ->addLog (
141131 $ operator ,
142132 $ _SERVER ["REMOTE_ADDR " ],
@@ -151,21 +141,14 @@ public function approveGroup(
151141 /**
152142 * This method is executed when an admin denys the PI group request
153143 */
154- public function denyGroup (
155- ?UnityUser $ operator = null ,
156- bool $ send_mail = true ,
157- ): void {
158- $ request = $ this ->SQL ->getRequest (
159- $ this ->getOwner ()->uid ,
160- UnitySQL::REQUEST_BECOME_PI ,
161- );
144+ public function denyGroup (?UnityUser $ operator = null , bool $ send_mail = true ): void
145+ {
146+ $ request = $ this ->SQL ->getRequest ($ this ->getOwner ()->uid , UnitySQL::REQUEST_BECOME_PI );
162147 $ this ->SQL ->removeRequest ($ this ->getOwner ()->uid );
163148 if ($ this ->exists ()) {
164149 return ;
165150 }
166- $ operator = is_null ($ operator )
167- ? $ this ->getOwner ()->uid
168- : $ operator ->uid ;
151+ $ operator = is_null ($ operator ) ? $ this ->getOwner ()->uid : $ operator ->uid ;
169152 $ this ->SQL ->addLog (
170153 $ operator ,
171154 $ _SERVER ["REMOTE_ADDR " ],
@@ -190,20 +173,16 @@ public function cancelGroupRequest(bool $send_mail = true): void
190173 }
191174 }
192175
193- public function cancelGroupJoinRequest (
194- UnityUser $ user ,
195- bool $ send_mail = true ,
196- ): void {
176+ public function cancelGroupJoinRequest (UnityUser $ user , bool $ send_mail = true ): void
177+ {
197178 if (!$ this ->requestExists ($ user )) {
198179 return ;
199180 }
200181 $ this ->SQL ->removeRequest ($ user ->uid , $ this ->gid );
201182 if ($ send_mail ) {
202- $ this ->MAILER ->sendMail (
203- $ this ->getOwner ()->getMail (),
204- "group_join_request_cancelled " ,
205- ["uid " => $ user ->uid ],
206- );
183+ $ this ->MAILER ->sendMail ($ this ->getOwner ()->getMail (), "group_join_request_cancelled " , [
184+ "uid " => $ user ->uid ,
185+ ]);
207186 }
208187 }
209188
@@ -248,10 +227,8 @@ public function cancelGroupJoinRequest(
248227 * This method is executed when a user is approved to join the group
249228 * (either by admin or the group owner)
250229 */
251- public function approveUser (
252- UnityUser $ new_user ,
253- bool $ send_mail = true ,
254- ): void {
230+ public function approveUser (UnityUser $ new_user , bool $ send_mail = true ): void
231+ {
255232 $ request = $ this ->SQL ->getRequest ($ new_user ->uid , $ this ->gid );
256233 if (!$ new_user ->exists ()) {
257234 $ new_user ->init (
@@ -267,18 +244,13 @@ public function approveUser(
267244 $ this ->MAILER ->sendMail ($ new_user ->getMail (), "group_user_added " , [
268245 "group " => $ this ->gid ,
269246 ]);
270- $ this ->MAILER ->sendMail (
271- $ this ->getOwner ()->getMail (),
272- "group_user_added_owner " ,
273- [
274- "group " => $ this ->gid ,
275- "user " => $ new_user ->uid ,
276- "name " =>
277- $ request ["firstname " ] . " " . $ request ["lastname " ],
278- "email " => $ request ["email " ],
279- "org " => $ request ["org " ],
280- ],
281- );
247+ $ this ->MAILER ->sendMail ($ this ->getOwner ()->getMail (), "group_user_added_owner " , [
248+ "group " => $ this ->gid ,
249+ "user " => $ new_user ->uid ,
250+ "name " => $ request ["firstname " ] . " " . $ request ["lastname " ],
251+ "email " => $ request ["email " ],
252+ "org " => $ request ["org " ],
253+ ]);
282254 }
283255 }
284256
@@ -291,51 +263,37 @@ public function denyUser(UnityUser $new_user, bool $send_mail = true): void
291263 $ this ->MAILER ->sendMail ($ request ["email " ], "group_user_denied " , [
292264 "group " => $ this ->gid ,
293265 ]);
294- $ this ->MAILER ->sendMail (
295- $ this ->getOwner ()->getMail (),
296- "group_user_denied_owner " ,
297- [
298- "group " => $ this ->gid ,
299- "user " => $ new_user ->uid ,
300- "name " => $ new_user ->getFullName (),
301- "email " => $ new_user ->getMail (),
302- "org " => $ new_user ->getOrg (),
303- ],
304- );
266+ $ this ->MAILER ->sendMail ($ this ->getOwner ()->getMail (), "group_user_denied_owner " , [
267+ "group " => $ this ->gid ,
268+ "user " => $ new_user ->uid ,
269+ "name " => $ new_user ->getFullName (),
270+ "email " => $ new_user ->getMail (),
271+ "org " => $ new_user ->getOrg (),
272+ ]);
305273 }
306274 }
307275
308- public function removeUser (
309- UnityUser $ new_user ,
310- bool $ send_mail = true ,
311- ): void {
276+ public function removeUser (UnityUser $ new_user , bool $ send_mail = true ): void
277+ {
312278 if (!$ this ->memberExists ($ new_user )) {
313279 return ;
314280 }
315281 if ($ new_user ->uid == $ this ->getOwner ()->uid ) {
316- throw new Exception (
317- "Cannot delete group owner from group. Disband group instead " ,
318- );
282+ throw new Exception ("Cannot delete group owner from group. Disband group instead " );
319283 }
320284 // remove request, this will fail silently if the request doesn't exist
321285 $ this ->removeUserFromGroup ($ new_user );
322286 if ($ send_mail ) {
323- $ this ->MAILER ->sendMail (
324- $ new_user ->getMail (),
325- "group_user_removed " ,
326- ["group " => $ this ->gid ],
327- );
328- $ this ->MAILER ->sendMail (
329- $ this ->getOwner ()->getMail (),
330- "group_user_removed_owner " ,
331- [
332- "group " => $ this ->gid ,
333- "user " => $ new_user ->uid ,
334- "name " => $ new_user ->getFullName (),
335- "email " => $ new_user ->getMail (),
336- "org " => $ new_user ->getOrg (),
337- ],
338- );
287+ $ this ->MAILER ->sendMail ($ new_user ->getMail (), "group_user_removed " , [
288+ "group " => $ this ->gid ,
289+ ]);
290+ $ this ->MAILER ->sendMail ($ this ->getOwner ()->getMail (), "group_user_removed_owner " , [
291+ "group " => $ this ->gid ,
292+ "user " => $ new_user ->uid ,
293+ "name " => $ new_user ->getFullName (),
294+ "email " => $ new_user ->getMail (),
295+ "org " => $ new_user ->getOrg (),
296+ ]);
339297 }
340298 }
341299
@@ -348,17 +306,11 @@ public function newUserRequest(
348306 bool $ send_mail = true ,
349307 ): void {
350308 if ($ this ->memberExists ($ new_user )) {
351- UnityHTTPD::errorLog (
352- "warning " ,
353- "user ' $ new_user' already in group " ,
354- );
309+ UnityHTTPD::errorLog ("warning " , "user ' $ new_user' already in group " );
355310 return ;
356311 }
357312 if ($ this ->requestExists ($ new_user )) {
358- UnityHTTPD::errorLog (
359- "warning " ,
360- "user ' $ new_user' already requested group membership " ,
361- );
313+ UnityHTTPD::errorLog ("warning " , "user ' $ new_user' already requested group membership " );
362314 return ;
363315 }
364316 if ($ this ->SQL ->accDeletionRequestExists ($ new_user ->uid )) {
@@ -370,17 +322,13 @@ public function newUserRequest(
370322 $ this ->MAILER ->sendMail ($ email , "group_user_request " , [
371323 "group " => $ this ->gid ,
372324 ]);
373- $ this ->MAILER ->sendMail (
374- $ this ->getOwner ()->getMail (),
375- "group_user_request_owner " ,
376- [
377- "group " => $ this ->gid ,
378- "user " => $ new_user ->uid ,
379- "name " => "$ firstname $ lastname " ,
380- "email " => $ email ,
381- "org " => $ org ,
382- ],
383- );
325+ $ this ->MAILER ->sendMail ($ this ->getOwner ()->getMail (), "group_user_request_owner " , [
326+ "group " => $ this ->gid ,
327+ "user " => $ new_user ->uid ,
328+ "name " => "$ firstname $ lastname " ,
329+ "email " => $ email ,
330+ "org " => $ org ,
331+ ]);
384332 }
385333 }
386334
@@ -502,14 +450,7 @@ private function addRequest(
502450 string $ email ,
503451 string $ org ,
504452 ): void {
505- $ this ->SQL ->addRequest (
506- $ uid ,
507- $ firstname ,
508- $ lastname ,
509- $ email ,
510- $ org ,
511- $ this ->gid ,
512- );
453+ $ this ->SQL ->addRequest ($ uid , $ firstname , $ lastname , $ email , $ org , $ this ->gid );
513454 }
514455
515456 public function getOwner (): UnityUser
@@ -532,9 +473,7 @@ public static function ownerUID2GID(string $uid): string
532473 public static function GID2OwnerUID (string $ gid ): string
533474 {
534475 if (substr ($ gid , 0 , strlen (self ::PI_PREFIX )) != self ::PI_PREFIX ) {
535- throw new Exception (
536- "PI group GID doesn't have the correct prefix. " ,
537- );
476+ throw new Exception ("PI group GID doesn't have the correct prefix. " );
538477 }
539478 return substr ($ gid , strlen (self ::PI_PREFIX ));
540479 }
0 commit comments