summaryrefslogtreecommitdiff
blob: fedef127a497e710198c0a7ca0df5832066dbb5c (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
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) {
		$build=new sql_build();
		$build->init();
		$build->name=$name;
		$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='build/ready';
		$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;
		}
	}
}
?>