33/*
44 * This file is part of SeAT
55 *
6- * Copyright (C) 2015 to 2022 Leon Jacobs
6+ * Copyright (C) 2015 to present Leon Jacobs
77 *
88 * This program is free software; you can redistribute it and/or modify
99 * it under the terms of the GNU General Public License as published by
2626use Seat \Eveapi \Models \Character \CharacterInfo ;
2727use Seat \Eveapi \Models \Corporation \CorporationInfo ;
2828use Seat \Notifications \Http \DataTables \NotificationGroupDataTable ;
29+ use Seat \Notifications \Http \Validation \CreateGroupMention ;
2930use Seat \Notifications \Http \Validation \Group ;
3031use Seat \Notifications \Http \Validation \GroupAffiliation ;
3132use Seat \Notifications \Http \Validation \GroupAlert ;
3233use Seat \Notifications \Http \Validation \GroupAllAlert ;
3334use Seat \Notifications \Http \Validation \GroupIntegration ;
3435use Seat \Notifications \Models \GroupAffiliation as GroupAffiliationModel ;
3536use Seat \Notifications \Models \GroupAlert as GroupAlertModel ;
37+ use Seat \Notifications \Models \GroupMention ;
3638use Seat \Notifications \Models \Integration ;
3739use Seat \Notifications \Models \NotificationGroup ;
3840use Seat \Web \Http \Controllers \Controller ;
@@ -115,15 +117,6 @@ public function postAddIntegrations(GroupIntegration $request)
115117
116118 // Attach the integrations to the group.
117119 foreach ($ request ->integrations as $ integration_id ) {
118-
119- $ integration = Integration::find ($ integration_id );
120-
121- // Make sure only one integration type is added.
122- if ($ group ->integrations ->contains ('type ' , $ integration ->type ))
123- return redirect ()->back ()
124- ->with ('warning ' , 'A ' . $ integration ->type .
125- ' integration already exists. Please choose another type. ' );
126-
127120 // Add the integration
128121 if (! $ group ->integrations ->contains ($ integration_id ))
129122 $ group ->integrations ()
@@ -150,6 +143,20 @@ public function getDeleteIntegration(int $group_id, int $integration_id)
150143
151144 }
152145
146+ public function postAddGroupMention (CreateGroupMention $ request ) {
147+ $ mention_type = config ('notifications.mentions ' )[$ request ->mention_type ];
148+
149+ // call the controller for creation. It can either show a page to enter more details or directly create the mention.
150+ return app ()->call ($ mention_type ['creation_controller_method ' ]);
151+ }
152+
153+ public function postDeleteGroupMention ($ mention_id ) {
154+ GroupMention::destroy ($ mention_id );
155+
156+ return redirect ()->back ()
157+ ->with ('success ' , 'Removed mention! ' );
158+ }
159+
153160 /**
154161 * @param \Illuminate\Http\Request $request
155162 * @return \Illuminate\Http\JsonResponse
@@ -159,6 +166,13 @@ public function getAjaxAlerts(Request $request)
159166 $ keyword = strtolower ($ request ->query ('q ' , '' ));
160167 $ alerts = collect (config ('notifications.alerts ' , []));
161168
169+ // remove all hidden groups
170+ $ alerts = $ alerts ->filter (function ($ alert ) {
171+ $ is_visible = $ alert ['visible ' ] ?? true ;
172+
173+ return $ is_visible ;
174+ });
175+
162176 if (! empty ($ keyword )) {
163177 $ alerts = $ alerts ->filter (function ($ alert ) use ($ keyword ) {
164178 return strpos (strtolower (trans ($ alert ['label ' ])), $ keyword ) !== false ;
@@ -242,7 +256,7 @@ public function postAddAffiliation(GroupAffiliation $request)
242256 foreach ($ request ->input ('corporations ' ) as $ corp )
243257 if (! $ group ->affiliations ->contains ('affiliation_id ' , $ corp ))
244258 $ group ->affiliations ()->save (new GroupAffiliationModel ([
245- 'type ' => 'corp ' ,
259+ 'type ' => 'corp ' ,
246260 'affiliation_id ' => $ corp ,
247261 ]));
248262
@@ -251,7 +265,7 @@ public function postAddAffiliation(GroupAffiliation $request)
251265 foreach ($ request ->input ('characters ' ) as $ character )
252266 if (! $ group ->affiliations ->contains ('affiliation_id ' , $ character ))
253267 $ group ->affiliations ()->save (new GroupAffiliationModel ([
254- 'type ' => 'char ' ,
268+ 'type ' => 'char ' ,
255269 'affiliation_id ' => $ character ,
256270 ]));
257271
0 commit comments