summaryrefslogtreecommitdiff
blob: aef03d12c06dc0acd0bb338bf69d8626dfe523dd (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
function init_configurations_manager() {
	global $S;
	if (!isset($S['user'])) {
		return 'login';
	}
	return array('title' => 'Manage Configurations');
}
function body_configurations_manager() {
	global $S, $request, $conf;
	echo '<h3>Configurations Manager</h3>';
	$r=$S['pdo']->query('SELECT * FROM `configurations` WHERE `owner`='.$S['user']->id);
	if ($r->rowCount() == 0) {
		echo print_warning('You have no configurations.').'<a href="'.url('create').'">Create a configuration</a>';
		return;
	} elseif (isset($request['build']) && isset($request['configuration'])) {
		$c=new sql_configuration($request['configuration']);
		if ($c->owner!=$S['user']->id) {
			echo print_error('You do not have permission to build this configuration.');
		} else {
			$name=isset($request['name'])?$request['name']:null;
			$build=$c->build($name);
			echo print_success('Submitted for build - <a href="'.url('logs/'.$build->id).'">Logs</a>');
		}
	}
	echo '<form action="'.url('configurations').'" method="post"><table><tr><th>ID</th><th>Name</th>'.(count(explode(' ', $conf['modules'])) > 1?'<th>Module</th>':'').'<th>Status</th><th>Options</th><th>Builds</th></tr>'."\n";
	$ready=0;
	while($c=$r->fetch(PDO::FETCH_ASSOC)) {
		$c=new sql_configuration($c);
		echo "<tr><td>";
		if ($c->status == 0) {
			$ready++;
			echo "<input id=\"radio-$c->id\" type=\"radio\" name=\"configuration\" value=\"$c->id\" /> <label for=\"radio-$c->id\">".$c->id.'</label>';
		} else {
			echo $c->id;
		}
		echo '</td><td>'.(isset($c->name) && strlen($c->name)?htmlentities($c->name):'<i>Unnamed</i>').'</td><td>';
		if (count(explode(' ', $conf['modules'])) > 1) {
			echo "$c->module</td><td>";
		}
		if ($c->status > 0) {
			echo '<a href="'.url("config/$c->id")."\">Step $c->status</a>'";
		} elseif ($c->status == 0) {
			echo '<b>Ready</b>';
		} else {
			echo $c->status;
		}
		echo '</td><td>'.$c->summary().'</td><td>';
		$builds=$c->get_builds();
		if ($builds) {
			foreach ($builds as $build) {
				echo '<a href="'.url('logs/'.$build).'">'.$build.'</a> ';
			}
		} else {
			echo '<i>None</i>';
		}
		echo "</td></tr>\n";
	}
	echo '</table>'.($ready?'Name (optional): <input name="name" /> <input type="submit" name="build" value="Build" />':'').'</form>';
}
?>