summaryrefslogtreecommitdiff
blob: dfadf4a4092d756fb811da4d3f7176aa88a4df8a (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
<?php
function init_configurations_manage() {
	global $S;
	if (!isset($S['user'])) {
		return 'login';
	}
	return array('title' => 'Manage Configurations');
}
function body_configurations_manager() {
	global $S, $request;
	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><th>Status</th><th>Options</th><th>Builds</th></tr>'."\n";
	while($c=$r->fetch(PDO::FETCH_ASSOC)) {
		$c=new sql_configuration($c);
		echo "<tr><td><input id=\"radio-$c->id\" type=\"radio\" name=\"configuration\" value=\"$c->id\" /> <label for=\"radio-$c->id\">$c->id</label></td><td>".(isset($c->name) && strlen($c->name)?htmlentities($c->name):'<i>Unnamed</i>')."</td><td>$c->status</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>Name (optional): <input name="name" /> <input type="submit" name="build" value="Build" /></form>';
}
?>