@@ -68,10 +68,7 @@ public function subscribeProject(): View|RedirectResponse
6868 }
6969
7070 // If we ask to subscribe
71- @$ Subscribe = $ _POST ['subscribe ' ];
7271 @$ UpdateSubscription = $ _POST ['updatesubscription ' ];
73- @$ Unsubscribe = $ _POST ['unsubscribe ' ];
74- @$ Role = $ _POST ['role ' ];
7572 @$ EmailType = $ _POST ['emailtype ' ];
7673 if (!isset ($ _POST ['emailmissingsites ' ])) {
7774 $ EmailMissingSites = 0 ;
@@ -90,26 +87,7 @@ public function subscribeProject(): View|RedirectResponse
9087 $ LabelEmail ->ProjectId = $ this ->project ->Id ;
9188 $ LabelEmail ->UserId = $ user ->id ;
9289
93- if ($ Unsubscribe ) {
94- DB ::delete ('DELETE FROM user2project WHERE userid=? AND projectid=? ' , [$ user ->id , $ this ->project ->Id ]);
95-
96- // Remove the claim sites for this project if they are only part of this project
97- DB ::delete ('
98- DELETE FROM site2user
99- WHERE
100- userid=?
101- AND siteid NOT IN (
102- SELECT build.siteid
103- FROM build, user2project AS up
104- WHERE
105- up.projectid = build.projectid
106- AND up.userid=?
107- AND up.role>0
108- GROUP BY build.siteid
109- )
110- ' , [$ user ->id , $ user ->id ]);
111- return redirect ('/user?note=unsubscribedtoproject ' );
112- } elseif ($ UpdateSubscription ) {
90+ if ($ UpdateSubscription ) {
11391 $ emailcategory_update = intval ($ _POST ['emailcategory_update ' ] ?? 0 );
11492 $ emailcategory_configure = intval ($ _POST ['emailcategory_configure ' ] ?? 0 );
11593 $ emailcategory_warning = intval ($ _POST ['emailcategory_warning ' ] ?? 0 );
@@ -122,7 +100,6 @@ public function subscribeProject(): View|RedirectResponse
122100 $ db ->executePrepared ('
123101 UPDATE user2project
124102 SET
125- role=?,
126103 emailtype=?,
127104 emailcategory=?,
128105 emailmissingsites=?,
@@ -131,32 +108,13 @@ public function subscribeProject(): View|RedirectResponse
131108 userid=?
132109 AND projectid=?
133110 ' , [
134- $ Role ,
135111 $ EmailType ,
136112 $ EmailCategory ,
137113 $ EmailMissingSites ,
138114 $ EmailSuccess ,
139115 $ user ->id ,
140116 $ this ->project ->Id ,
141117 ]);
142-
143- if ($ Role == 0 ) {
144- // Remove the claim sites for this project if they are only part of this project
145- DB ::delete ('
146- DELETE FROM site2user
147- WHERE
148- userid=?
149- AND siteid NOT IN (
150- SELECT build.siteid
151- FROM build, user2project AS up
152- WHERE
153- up.projectid=build.projectid
154- AND up.userid=?
155- AND up.role>0
156- GROUP BY build.siteid
157- )
158- ' , [$ user ->id , $ user ->id ]);
159- }
160118 }
161119
162120 if (isset ($ _POST ['emaillabels ' ])) {
@@ -166,77 +124,6 @@ public function subscribeProject(): View|RedirectResponse
166124 }
167125 // Redirect
168126 return redirect ('/user ' );
169- } elseif ($ Subscribe ) {
170- $ emailcategory_update = intval ($ _POST ['emailcategory_update ' ] ?? 0 );
171- $ emailcategory_configure = intval ($ _POST ['emailcategory_configure ' ] ?? 0 );
172- $ emailcategory_warning = intval ($ _POST ['emailcategory_warning ' ] ?? 0 );
173- $ emailcategory_error = intval ($ _POST ['emailcategory_error ' ] ?? 0 );
174- $ emailcategory_test = intval ($ _POST ['emailcategory_test ' ] ?? 0 );
175- $ emailcategory_dynamicanalysis = intval ($ _POST ['emailcategory_dynamicanalysis ' ] ?? 0 );
176-
177- $ EmailCategory = $ emailcategory_update + $ emailcategory_configure + $ emailcategory_warning + $ emailcategory_error + $ emailcategory_test + $ emailcategory_dynamicanalysis ;
178- if (!empty ($ user2project )) {
179- $ db ->executePrepared ('
180- UPDATE user2project
181- SET
182- role=?,
183- emailtype=?,
184- emailcategory=?.
185- emailmissingsites=?,
186- emailsuccess=?
187- WHERE
188- userid=?
189- AND projectid=?
190- ' , [
191- $ Role ,
192- $ EmailType ,
193- $ EmailCategory ,
194- $ EmailMissingSites ,
195- $ EmailSuccess ,
196- $ user ->id ,
197- $ this ->project ->Id ,
198- ]);
199-
200- if ($ Role == 0 ) {
201- // Remove the claim sites for this project if they are only part of this project
202- DB ::delete ('
203- DELETE FROM site2user
204- WHERE
205- userid=?
206- AND siteid NOT IN (
207- SELECT build.siteid
208- FROM build, user2project AS up
209- WHERE
210- up.projectid0=build.projectid
211- AND up.userid=?
212- AND up.role>0
213- GROUP BY build.siteid
214- )
215- ' , [$ user ->id , $ user ->id ]);
216- }
217- } else {
218- $ db ->executePrepared ('
219- INSERT INTO user2project (
220- role,
221- userid,
222- projectid,
223- emailtype,
224- emailcategory,
225- emailsuccess,
226- emailmissingsites
227- )
228- VALUES (?, ?, ?, ?, ?, ?, ?)
229- ' , [
230- $ Role ,
231- $ user ->id ,
232- $ this ->project ->Id ,
233- $ EmailType ,
234- $ EmailCategory ,
235- $ EmailSuccess ,
236- $ EmailMissingSites ,
237- ]);
238- }
239- return redirect ('/user?note=subscribedtoproject ' );
240127 }
241128
242129 $ xml .= '<project> ' ;
0 commit comments