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
|
<?php
class sql_configuration extends conf_build_common {
protected $table='configurations', $primary_key=array('id'), $columns=array(
'id' => array (
'type' => 'CHAR',
'length' => 6,
'not_null' => true,
'default' => ''
),
'owner' => array (
'type' => 'INT',
'length' => 10,
'unsigned' => true,
'not_null' => true,
'default' => 0,
'refers_to' => 'users.id'
),
'name' => array (
'type' => 'VARCHAR',
'length' => 255
),
'module' => array (
'type' => 'VARCHAR',
'length' => 255,
'not_null' => true,
'default' => ''
),
'status' => array (
'type' => 'TINYINT',
'length' => 4,
'not_null' => true,
'default' => 0
)
);
public function build($name=null) {
$module=new module($this->module);
for ($i=1; $i<=$module->numsteps; $i++) {
$step=new wizard_step($this, $i);
if (!$step->verify()) {
$this->status=$i;
$this->write();
return $i;
}
}
$build=new sql_build();
$build->init();
$build->name=$name;
$build->module=$this->module;
$opts=$this->get_opts();
$opts['configuration']=$this->id;
foreach ($opts as $name => $val) {
$opt=new sql_buildopt($build->id, $name, $val);
$opt->write();
}
$build->ctime=time();
$build->status=-128;
$build->write();
return $build;
}
// Returns an array of the IDs of all the builds that report this configuration as their source
public function get_builds() {
global $S;
$r=$S['pdo']->query('SELECT `build` FROM `buildopts` WHERE `name`="configuration" AND `value`="'.$this->id.'"');
if ($r->rowCount()) {
$builds=array();
while ($b=$r->fetch(PDO::FETCH_COLUMN)) {
$builds[]=$b;
}
return $builds;
} else {
return null;
}
}
}
?>
|