summaryrefslogtreecommitdiff
blob: 0488a11db28422a1a84d4c85f943b16c7cb898d0 (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
62
63
64
65
66
<?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>';
	if (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);
			if (is_object($build))
				echo print_success('Submitted for build - <a href="'.url('logs/'.$build->id).'">Logs</a>');
			else
				echo print_error('Invalid configuration', 'Your configuration could not be submitted for build.  Please return to <a href="'.url("config/$c->id/$build").'">step '.$build.'</a> and continue configuration from there.');
		}
	}
	$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;
	}
	echo '<form action="'.url('configurations').'" method="post"><table><tr><th>ID</th><th>Name</th>'.(count($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($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 ' (<a href="'.url("config/$c->id/status").'">view</a>)';
		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>';
}
?>