|
33 | 33 | $creator = $user ? $user->username : ''; |
34 | 34 | $created = time(); |
35 | 35 |
|
| 36 | +$canAdmin = can_admin(); |
| 37 | + |
36 | 38 | /** |
37 | 39 | * Check if the user has dropped their connection and delete the wiki if so |
38 | 40 | * |
@@ -216,14 +218,49 @@ function set_progress( float $pc, string $label ) { |
216 | 218 |
|
217 | 219 | if ( |
218 | 220 | $config[ 'requireVerified' ] && |
219 | | - ( $data[0]['labels']['Verified']['approved']['_account_id'] ?? null ) !== 75 |
| 221 | + ( $data[0]['labels']['Verified']['approved']['_account_id'] ?? null ) !== 75 && |
| 222 | + // Admin override |
| 223 | + !( $canAdmin && isset( $_POST['adminVerified'] ) ) |
220 | 224 | ) { |
221 | 225 | // The patch doesn't have V+2, check if the uploader is trusted |
222 | 226 | $uploaderId = $data[0]['revisions'][$revision]['uploader']['_account_id']; |
223 | 227 | $uploader = gerrit_query( 'accounts/' . $uploaderId, true ); |
224 | 228 | check_connection(); |
225 | 229 | if ( !is_trusted_user( $uploader['email'] ) ) { |
226 | | - abandon( "Patch must be approved (Verified+2) by jenkins-bot, or uploaded by a trusted user" ); |
| 230 | + if ( $canAdmin ) { |
| 231 | + echo '<form method="POST" action="" id="resubmit-form"><input type="hidden" name="adminVerified" value="1">'; |
| 232 | + foreach ( $_POST as $k => $v ) { |
| 233 | + if ( is_array( $v ) ) { |
| 234 | + foreach ( $v as $part ) { |
| 235 | + echo '<input type="hidden" name="' . htmlentities( $k ) . '[]" value="' . htmlentities( $part ) . '">'; |
| 236 | + } |
| 237 | + } else { |
| 238 | + echo '<input type="hidden" name="' . htmlentities( $k ) . '" value="' . htmlentities( $v ) . '">'; |
| 239 | + } |
| 240 | + } |
| 241 | + echo '</form>'; |
| 242 | + } |
| 243 | + abandon( |
| 244 | + "Patch must be approved (Verified+2) by jenkins-bot, or uploaded by a trusted user." . |
| 245 | + ( can_admin() ? |
| 246 | + "<p>If you are confident all the patches are safe, as an admin you can bypass these checks:</p>" . |
| 247 | + new OOUI\ButtonWidget( [ |
| 248 | + 'classes' => [ 'resubmit-button' ], |
| 249 | + 'label' => 'Bypass verification', |
| 250 | + 'icon' => 'unLock', |
| 251 | + 'flags' => [ 'destructive', 'primary' ], |
| 252 | + 'infusable' => true, |
| 253 | + ] ) . |
| 254 | + "<script> |
| 255 | + $( '.resubmit-button' ).each( function () { |
| 256 | + OO.ui.infuse( this ).on( 'click', function () { |
| 257 | + document.getElementById( 'resubmit-form' ).submit(); |
| 258 | + } ); |
| 259 | + } ); |
| 260 | + </script>" |
| 261 | + : "" |
| 262 | + ) |
| 263 | + ); |
227 | 264 | } |
228 | 265 | } |
229 | 266 |
|
|
0 commit comments