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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<?php
function init_configurations_manager(&$S) {
if (!isset($S['user'])) {
return 'login';
}
return array('title' => 'Manage Configurations');
}
function body_configurations_manager(&$S) {
echo '<h3>Configurations Manager</h3>';
if (isset($_REQUEST['build'], $_REQUEST['configuration'])) {
$c=new sql_configuration($_REQUEST['configuration']);
if (!owner_or_admin($c->owner)) {
echo print_error('You do not have permission to build this configuration.');
} else {
$name=isset($_REQUEST['name'])?$_REQUEST['name']:null;
$bundler=isset($_REQUEST['bundler'])?$_REQUEST['bundler']:'tbz2';
$build=$c->build($name, $bundler);
if (is_object($build))
echo print_success('Submitted for build - <a href="'.url("build/$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=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($S['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($S['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><a href="'.url("config/$c->id/status").'">View</a></td><td>';
$builds=$c->get_builds();
if ($builds) {
$buildlinks=array();
foreach ($builds as $build) {
$buildlinks[]='<a href="'.url("build/$build->id").'">'.($build->name?htmlentities($build->name):$build->id).'</a>';
}
echo implode(', ', $buildlinks);
} else {
echo '<i>None</i>';
}
echo "</td></tr>\n";
}
echo '</table>';
if ($ready) {
echo 'Name (optional): <input name="name" /><br/>
Bundler: <select name="bundler">
<option value="tbz2">Tar/Bzip2</option>
<option value="tgz">Tar/Gzip</option>
<option value="installcd">Install CD with Tar/Bzip2</option>
<option value="livecd">LiveCD</option>
<option value="ext2">ext2</option>
<option value="jffs2">jffs2</option>
</select><br/>
<input type="submit" name="build" value="Build" />';
}
echo '</form>';
/*$this->select('bundler', 'bundler', 'Image type', array(
'tgz' => 'Tar/Gzip',
'tbz2' => 'Tar/Bzip2',
'installcd' => 'Installer CD with Tar/Bzip2',
'livecd' => 'LiveCD',
'ext2' => 'ext2',
'jffs2' => 'jffs2'
));*/
}
?>
|