11<?php
22
3+ use Engelsystem \Http \Exceptions \HttpForbidden ;
4+ use Engelsystem \Http \Exceptions \HttpNotFound ;
35use Engelsystem \Mail \EngelsystemMailer ;
46use Engelsystem \Models \AngelType ;
57use Engelsystem \Models \User \User ;
@@ -38,19 +40,18 @@ function user_angeltypes_unconfirmed_hint()
3840 $ unconfirmed_links [] = '<a href=" '
3941 . url ('/angeltypes ' , ['action ' => 'view ' , 'angeltype_id ' => $ user_angeltype ->angel_type_id ])
4042 . '"> ' . htmlspecialchars ($ user_angeltype ->angelType ->name )
41- . ' (+ ' . $ user_angeltype ->count . ') '
43+ . ' (+ ' . $ user_angeltype ->users_count . ') '
4244 . '</a> ' ;
4345 }
4446
4547 $ count = $ unconfirmed_user_angeltypes ->count ();
4648 return
4749 _e (
48- 'There is %d unconfirmed angeltype. ' ,
49- 'There are %d unconfirmed angeltypes. ' ,
50+ 'There are unconfirmed angels in %d angel type. Angel type that needs approval: ' ,
51+ 'There are unconfirmed angels in %d angel types. Angel types that need approvals: ' ,
5052 $ count ,
5153 [$ count ]
5254 )
53- . ' ' . __ ('Angel types which need approvals: ' )
5455 . ' ' . join (', ' , $ unconfirmed_links );
5556}
5657
@@ -70,7 +71,7 @@ function user_angeltypes_delete_all_controller(): array
7071
7172 $ angeltype = AngelType::findOrFail ($ request ->input ('angeltype_id ' ));
7273 if (!auth ()->user ()->isAngelTypeSupporter ($ angeltype ) && !auth ()->can ('admin_user_angeltypes ' )) {
73- error (__ ('You are not allowed to delete all users for this angeltype . ' ));
74+ error (__ ('You are not allowed to delete all users for this angel type . ' ));
7475 throw_redirect (url ('/angeltypes ' ));
7576 }
7677
@@ -79,8 +80,8 @@ function user_angeltypes_delete_all_controller(): array
7980 ->whereNull ('confirm_user_id ' )
8081 ->delete ();
8182
82- engelsystem_log (sprintf ('Denied all users for angeltype %s ' , AngelType_name_render ($ angeltype , true )));
83- success (sprintf (__ ('Denied all users for angeltype %s. ' ), $ angeltype ->name ));
83+ engelsystem_log (sprintf ('Denied all users for angel type %s ' , AngelType_name_render ($ angeltype , true )));
84+ success (sprintf (__ ('Denied all users for angel type %s. ' ), $ angeltype ->name ));
8485 throw_redirect (url ('/angeltypes ' , ['action ' => 'view ' , 'angeltype_id ' => $ angeltype ->id ]));
8586 }
8687
@@ -107,7 +108,7 @@ function user_angeltypes_confirm_all_controller(): array
107108
108109 $ angeltype = AngelType::findOrFail ($ request ->input ('angeltype_id ' ));
109110 if (!auth ()->can ('admin_user_angeltypes ' ) && !$ user ->isAngelTypeSupporter ($ angeltype )) {
110- error (__ ('You are not allowed to confirm all users for this angeltype . ' ));
111+ error (__ ('You are not allowed to confirm all users for this angel type . ' ));
111112 throw_redirect (url ('/angeltypes ' ));
112113 }
113114
@@ -118,8 +119,8 @@ function user_angeltypes_confirm_all_controller(): array
118119 ->whereNull ('confirm_user_id ' )
119120 ->update (['confirm_user_id ' => $ user ->id ]);
120121
121- engelsystem_log (sprintf ('Confirmed all users for angeltype %s ' , AngelType_name_render ($ angeltype , true )));
122- success (sprintf (__ ('Confirmed all users for angeltype %s. ' ), $ angeltype ->name ));
122+ engelsystem_log (sprintf ('Confirmed all users for angel type %s ' , AngelType_name_render ($ angeltype , true )));
123+ success (sprintf (__ ('Confirmed all users for angel type %s. ' ), $ angeltype ->name ));
123124
124125 foreach ($ users as $ user ) {
125126 user_angeltype_confirm_email ($ user , $ angeltype );
@@ -145,15 +146,14 @@ function user_angeltype_confirm_controller(): array
145146 $ request = request ();
146147
147148 if (!$ request ->has ('user_angeltype_id ' )) {
148- error (__ ('User angeltype doesn \'t exist. ' ));
149- throw_redirect (url ('/angeltypes ' ));
149+ throw new HttpNotFound ();
150150 }
151151
152152 /** @var UserAngelType $user_angeltype */
153153 $ user_angeltype = UserAngelType::findOrFail ($ request ->input ('user_angeltype_id ' ));
154154 $ angeltype = $ user_angeltype ->angelType ;
155155 if (!$ user ->isAngelTypeSupporter ($ angeltype ) && !auth ()->can ('admin_user_angeltypes ' )) {
156- error (__ ('You are not allowed to confirm this users angeltype . ' ));
156+ error (__ ('You are not allowed to confirm this users angel type . ' ));
157157 throw_redirect (url ('/angeltypes ' ));
158158 }
159159
@@ -163,19 +163,19 @@ function user_angeltype_confirm_controller(): array
163163 $ user_angeltype ->save ();
164164
165165 engelsystem_log (sprintf (
166- '%s confirmed for angeltype %s ' ,
166+ '%s confirmed for angel type %s ' ,
167167 User_Nick_render ($ user_source , true ),
168168 AngelType_name_render ($ angeltype , true )
169169 ));
170- success (sprintf (__ ('%s confirmed for angeltype %s. ' ), $ user_source ->displayName , $ angeltype ->name ));
170+ success (sprintf (__ ('%s confirmed for angel type %s. ' ), $ user_source ->displayName , $ angeltype ->name ));
171171
172172 user_angeltype_confirm_email ($ user_source , $ angeltype );
173173
174174 throw_redirect (url ('/angeltypes ' , ['action ' => 'view ' , 'angeltype_id ' => $ angeltype ->id ]));
175175 }
176176
177177 return [
178- __ ('Confirm angeltype for user ' ),
178+ __ ('Confirm angel type for user ' ),
179179 UserAngelType_confirm_view ($ user_angeltype , $ user_source , $ angeltype ),
180180 ];
181181}
@@ -223,8 +223,7 @@ function user_angeltype_delete_controller(): array
223223 $ user = auth ()->user ();
224224
225225 if (!$ request ->has ('user_angeltype_id ' )) {
226- error (__ ('User angeltype doesn \'t exist. ' ));
227- throw_redirect (url ('/angeltypes ' ));
226+ throw new HttpNotFound ();
228227 }
229228
230229 /** @var UserAngelType $user_angeltype */
@@ -237,7 +236,7 @@ function user_angeltype_delete_controller(): array
237236 && !$ user ->isAngelTypeSupporter ($ angeltype )
238237 && !auth ()->can ('admin_user_angeltypes ' )
239238 ) {
240- error (__ ('You are not allowed to delete this users angeltype . ' ));
239+ error (__ ('You are not allowed to delete this users angel type . ' ));
241240 throw_redirect (url ('/angeltypes ' ));
242241 }
243242
@@ -251,7 +250,7 @@ function user_angeltype_delete_controller(): array
251250 }
252251
253252 return [
254- __ ('Leave angeltype ' ),
253+ __ ('Leave angel type ' ),
255254 UserAngelType_delete_view ($ user_angeltype , $ user_source , $ angeltype , $ isOwnAngelType ),
256255 ];
257256}
@@ -266,14 +265,11 @@ function user_angeltype_update_controller(): array
266265 $ supporter = false ;
267266 $ request = request ();
268267
269- if (!auth ()->can ('admin_angel_types ' ) && !config ('supporters_can_promote ' )) {
270- error (__ ('You are not allowed to set supporter rights. ' ));
271- throw_redirect (url ('/angeltypes ' ));
272- }
273-
274268 if (!$ request ->has ('user_angeltype_id ' )) {
275- error (__ ('User angeltype doesn \'t exist. ' ));
276- throw_redirect (url ('/angeltypes ' ));
269+ throw new HttpNotFound ();
270+ }
271+ if (!auth ()->can ('admin_angel_types ' ) && !config ('supporters_can_promote ' )) {
272+ throw new HttpForbidden ();
277273 }
278274
279275 if ($ request ->has ('supporter ' ) && preg_match ('/^[01]$/ ' , $ request ->input ('supporter ' ))) {
@@ -389,7 +385,7 @@ function user_angeltype_add_controller(): array
389385 }
390386
391387 return [
392- __ ('Add user to angeltype ' ),
388+ __ ('Add user to angel type ' ),
393389 UserAngelType_add_view ($ angeltype , $ users_select , $ user_source ->id ),
394390 ];
395391}
0 commit comments