blob: 384be2d2cf9d4c080676ff1725211b060c69683c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
function init_builds_delete(&$S) {
if (!isset($S['user'])) return 'login';
if (!(isset($_REQUEST['build']) && strlen($_REQUEST['build']) == 6 && ctype_alnum($_REQUEST['build']))) return '404';
$r=query('SELECT * FROM `builds` WHERE `id`="'.$_REQUEST['build'].'"');
if ($r->rowCount() == 0) return '404';
$S['build']=new sql_build($r->fetch(PDO::FETCH_ASSOC));
if (!owner_or_admin($S['build']->id)) return '404';
return array('title' => 'Delete Build');
}
function body_builds_delete(&$S) {
switch($S['build']->status) {
case 'queued':
if (isset($S['build']->backend))
die(print_warning('Oops', 'You tried to delete this build just as it was about to start being built. Please try to cancel it in a moment.'));
case 'canceled':
case 'queued':
case 'complete':
$S['build']->delete();
echo print_success('Build deleted.');
break;
case 'cancel':
echo print_error('This build is already queued for cancellation.');
break;
case 'uploading':
case 'building':
default:
$S['build']->unset_flag('f'); // Otherwise doesn't get noticed by backend
$S['build']->status='cancel';
$S['build']->write();
echo print_success('Build queued for cancellation.');
}
}
?>
|