summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-19 16:33:50 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-19 16:33:50 -0400
commit62e2432de3c2fb3bcd14faee86029c1c0eefdb23 (patch)
tree6f52ea4d6babdff4ff0d45420fa133bd70cab0f1 /shared
parentTransitioned to support multiple profiles, chosen in the frontend, to use dat... (diff)
downloadingenue-62e2432de3c2fb3bcd14faee86029c1c0eefdb23.tar.gz
ingenue-62e2432de3c2fb3bcd14faee86029c1c0eefdb23.tar.bz2
ingenue-62e2432de3c2fb3bcd14faee86029c1c0eefdb23.zip
Finished infrastructure for 1st gen. build wizard, enhanced backend logging
Diffstat (limited to 'shared')
-rw-r--r--shared/classes/0sql_row_obj.php1
-rw-r--r--shared/classes/build.php43
-rw-r--r--shared/classes/buildlog_entry.php2
-rw-r--r--shared/classes/buildopt.php3
-rw-r--r--shared/classes/session.php3
-rw-r--r--shared/classes/task.php25
6 files changed, 64 insertions, 13 deletions
diff --git a/shared/classes/0sql_row_obj.php b/shared/classes/0sql_row_obj.php
index cf82e4b..0d75d37 100644
--- a/shared/classes/0sql_row_obj.php
+++ b/shared/classes/0sql_row_obj.php
@@ -1,5 +1,6 @@
<?php
// TODO
+// Fall back to multi key if single key didn't work (so unique key can be null)
// consider replacing the one sql_col class with a bunch of child classes for different types (will work well with defaults() when 5.3.0 comes out)
// make sure things really work with enum
// replace the functionality of hasattrs and getattr somehow - more complex custom queries than refers_to
diff --git a/shared/classes/build.php b/shared/classes/build.php
index 305dd8e..6034cf5 100644
--- a/shared/classes/build.php
+++ b/shared/classes/build.php
@@ -1,17 +1,17 @@
<?php
class sql_build extends sql_row_obj {
- protected $table='builds', $columns=array(
+ protected $table='builds', $ids='id owner', $columns=array(
'id' => array (
'type' => 'CHAR',
'length' => 6,
'not_null' => true,
- 'unique' => true
),
'owner' => array (
'type' => 'INT',
'length' => 10,
'unsigned' => true,
- 'not_null' => true
+ 'not_null' => true,
+ 'refers to' => 'users.id'
),
'name' => array (
'type' => 'VARCHAR',
@@ -22,6 +22,11 @@ class sql_build extends sql_row_obj {
'length' => 255,
'not_null' => true
),
+ 'ctime' => array (
+ 'type' => 'INT',
+ 'length' => 10,
+ 'unsigned' => true
+ ),
'start' => array (
'type' => 'INT',
'length' => 10,
@@ -32,7 +37,37 @@ class sql_build extends sql_row_obj {
'length' => 10,
'unsigned' => true
)
-
);
+ // Generates a unique id and sets status to config/step0, writes self to db and returns id
+ public function init() {
+ global $S;
+ $this->owner=$S['user']->id;
+ $this->status='config/step0';
+ $fails=0;
+ while (true) {
+ $id=randstring(6);
+ debug("Trying id=$id...");
+ $r=$S['pdo']->query('SELECT `id` FROM `builds` WHERE `id`="'.$id.'"');
+ if ($r->rowCount() == 0) {
+ break;
+ }
+ if (++$fails == 10) {
+ throw new Exception('Failed 10 times to find a unique build id... this shouldn\'t happen.');
+ }
+ }
+ $this->id=$id;
+ $this->write();
+ return $this->id;
+ }
+ // Fetches all available buildopts pertaining to this build in a nice array
+ function get_buildopts() {
+ global $S;
+ $r=$S['pdo']->query('SELECT * FROM `buildopts` WHERE `build`="'.$this->id.'"');
+ $opts=array();
+ while ($opt=$r->fetch(PDO::FETCH_ASSOC)) {
+ $opt=new sql_buildopt($opt);
+ $opts=&$opt;
+ }
+ }
}
?>
diff --git a/shared/classes/buildlog_entry.php b/shared/classes/buildlog_entry.php
index f060e9e..69d689f 100644
--- a/shared/classes/buildlog_entry.php
+++ b/shared/classes/buildlog_entry.php
@@ -6,7 +6,7 @@ class sql_buildlog_entry extends sql_row_obj {
'length' => 10,
'unsigned' => true,
'not_null' => true,
- 'default' => 0
+ 'refers to' => 'tasks.id'
),
'order' => array (
'type' => 'INT',
diff --git a/shared/classes/buildopt.php b/shared/classes/buildopt.php
index e05192b..4999585 100644
--- a/shared/classes/buildopt.php
+++ b/shared/classes/buildopt.php
@@ -4,7 +4,8 @@ class sql_buildopt extends sql_row_obj {
'build' => array (
'type' => 'CHAR',
'length' => 6,
- 'not_null' => true
+ 'not_null' => true,
+ 'refers to' => 'builds.id'
),
'name' => array (
'type' => 'VARCHAR',
diff --git a/shared/classes/session.php b/shared/classes/session.php
index 9b8a0a2..2cab1cb 100644
--- a/shared/classes/session.php
+++ b/shared/classes/session.php
@@ -10,7 +10,8 @@ class sql_session extends sql_row_obj {
'type' => 'INT',
'length' => 10,
'unsigned' => true,
- 'not_null' => true
+ 'not_null' => true,
+ 'refers to' => 'users.id'
),
'atime' => array (
'type' => 'INT',
diff --git a/shared/classes/task.php b/shared/classes/task.php
index 3eecdeb..cdea343 100644
--- a/shared/classes/task.php
+++ b/shared/classes/task.php
@@ -5,23 +5,36 @@ class sql_task extends sql_row_obj {
'type' => 'INT',
'length' => 10,
'unsigned' => true,
- 'not null' => true,
- 'auto increment' => true,
+ 'not_null' => true,
+ 'auto_increment' => true
),
- 'build' => array(
+ 'build' => array (
'type' => 'CHAR',
'length' => 6,
- 'not null' => true,
+ 'not_null' => true,
+ 'default' => ''
),
'command' => array (
'type' => 'VARCHAR',
'length' => 255,
- 'not null' => true,
+ 'not_null' => true,
+ 'default' => ''
+ ),
+ 'start' => array (
+ 'type' => 'INT',
+ 'length' => 10,
+ 'unsigned' => true,
+ 'not_null' => true
+ ),
+ 'end' => array (
+ 'type' => 'INT',
+ 'length' => 10,
+ 'unsigned' => true
),
'exit' => array (
'type' => 'TINYINT',
'length' => 3,
- 'unsigned' => true,
+ 'unsigned' => true
)
);