diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-08-06 19:12:48 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-08-06 19:12:48 -0400 |
commit | ed4e6670c58817a6dece1a5531f683445dfedb84 (patch) | |
tree | c8e13990de43d86adcd1262dcb6c22d98bfe1915 /shared | |
parent | Added more package sets, created status document from Gentoo install guide, u... (diff) | |
download | ingenue-ed4e6670c58817a6dece1a5531f683445dfedb84.tar.gz ingenue-ed4e6670c58817a6dece1a5531f683445dfedb84.tar.bz2 ingenue-ed4e6670c58817a6dece1a5531f683445dfedb84.zip |
Numerous backend bugs fixed; use portage snapshot if available; frontend figures out its own URL; choose hostname; timezone config file set up; Fix setup.php; etc.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/classes/0sql_row_obj.php | 6 | ||||
-rw-r--r-- | shared/classes/build.php | 20 | ||||
-rw-r--r-- | shared/classes/session.php | 2 | ||||
-rw-r--r-- | shared/functions/url.php | 9 | ||||
-rw-r--r-- | shared/include/definitions.php | 9 | ||||
-rw-r--r-- | shared/include/includes.php | 1 |
6 files changed, 32 insertions, 15 deletions
diff --git a/shared/classes/0sql_row_obj.php b/shared/classes/0sql_row_obj.php index 4efacbd..30fe479 100644 --- a/shared/classes/0sql_row_obj.php +++ b/shared/classes/0sql_row_obj.php @@ -277,7 +277,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up return $cols_filled; } // Writes the object's data to the database, either by UPDATE or INSERT - function write() { + public function write() { $q=($this->is_in_db()?'UPDATE':'INSERT INTO').' `'.$this->table.'` SET '; $i=0; // Number of columns we've set so far $to_change=array(); @@ -310,14 +310,14 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up return $r; } // (Re-)Loads data from the database - function load() { + public function load() { if ($this->is_in_db()) { $r=self::sql_query('SELECT * FROM `'.$this->table.'` WHERE '.$this->sql_id()); $this->from_array($r->fetch(PDO::FETCH_ASSOC), true); } } // Deletes this row from the database and clears db_values array - function delete() { + public function delete() { if ($this->is_in_db()) { self::sql_query('DELETE FROM `'.$this->table.'` WHERE '.$this->sql_id()); $this->db_values=array(); diff --git a/shared/classes/build.php b/shared/classes/build.php index 7230673..c863f1f 100644 --- a/shared/classes/build.php +++ b/shared/classes/build.php @@ -59,13 +59,16 @@ class sql_build extends conf_build_common { $perms=$this->visibility == 'public' || owner_or_admin($this->id); $html='<div class="build"><span class="name">'.(isset($this->name) && strlen($this->name)?htmlentities($this->name):'Unnamed Build').'</span> '; $links=array(); - if ($this->status == -128) { + if ($this->status == INGENUE_BUILD_QUEUED) { $total=query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128')->fetch(PDO::FETCH_COLUMN); $num=query('SELECT COUNT(*) FROM `builds` WHERE `status`=-128 AND `ctime` <= '.$this->ctime)->fetch(PDO::FETCH_COLUMN); - $html.="<span class=\"status queued\">[Queued ($num/$total)]</span>"; - } elseif ($this->status == -127) { + $html.="<span class=\"status queued\">[queued ($num/$total)]</span>"; + } elseif ($this->status == INGENUE_BUILD_UPLOADING) { $html.='<span class="status successful">[uploading]</span>'; if ($perms) $links['Build log']="build/$this->id"; + } elseif ($this->status == INGENUE_BUILD_CANCEL) { + $html.='<span class="status queued">[pending cancellation]</span>'; + if ($perms) $links['Build log']="build/$this->id"; } elseif ($this->status < 0) { // TODO Build stage X $html.='<span class="status building">[building]</span>'; @@ -73,26 +76,29 @@ class sql_build extends conf_build_common { //$links['Watch']="build/$this->id/live"; $links['Build Log']="build/$this->id"; } - } elseif ($this->status == 0) { + } elseif ($this->status == INGENUE_BUILD_COMPLETE) { $r=query('SELECT COUNT(*) as `count`, MAX(`time`) as `time` FROM `downloads` WHERE `build`="'.$this->id.'"')->fetch(PDO::FETCH_ASSOC); $d=($perms && $r['count']?'<a href="'.url("build/$this->id/history").'">':'').$r['count'].' download'.($r['count'] != 1?'s':'').($r['count']?($perms?'</a>':'').'<br/><span class="time">(last at '.date($format, $r['time']).')</span>':''); $html.='<span class="downloads">'.$d.'</span><span class="status successful">[successful]</span>'; $links['Download image']="build/$this->id/download"; if ($perms) $links['Build log']="build/$this->id"; - } elseif ($this->status == 127) { + } elseif ($this->status == INGENUE_BUILD_UPLOAD_FAILED) { $html.='<span class="status failed">[upload failed]</span>'; if ($perms) $links['Build log']="build/$this->id"; - } elseif ($this->status == 126) { + } elseif ($this->status == INGENUE_BUILD_FAILED) { $html.='<span class="status failed">[failed]</span>'; if ($perms) { //$links['View output of failed command']="build/$this->id/failure"; $links['Build log']="build/$this->id"; } + } elseif ($this->status == INGENUE_BUILD_CANCELED) { + $html.='<span class="status failed">[canceled]</span>'; + if ($perms) $links['Build log']="build/$this->id"; } else { $html.='<span class="status failed">[failed: got signal '.$this->status.']</span>'; if ($perms) $links['Build log']="build/$this->id"; } - if ($this->status >= 0 || $this->status == -128) // Finished or queued + if ($this->status >= 0 || $this->status == INGENUE_BUILD_QUEUED) // Finished or queued $links['Delete']="build/$this->id/delete"; if ($links) { foreach ($links as $label => $url) { diff --git a/shared/classes/session.php b/shared/classes/session.php index 1233a71..d9df028 100644 --- a/shared/classes/session.php +++ b/shared/classes/session.php @@ -32,7 +32,7 @@ class sql_session extends sql_row_obj { ); // Creates a new session for the user at $S['user'] with a unique id, sends a cookie to the user and returns true for success, false for failure - static function create() { + public static function create() { global $S; $id=null; while (!$id) { diff --git a/shared/functions/url.php b/shared/functions/url.php index 0234b2b..b8e5c31 100644 --- a/shared/functions/url.php +++ b/shared/functions/url.php @@ -2,22 +2,23 @@ // Makes all URLs absolute function url($url='') { global $S; + $base=isset($S['url'])?$S['url']:$S['conf']['url']; if (strlen($url) == 0) { - return $S['conf']['url'].($S['conf']['mod_rewrite']?'':'/index.php'); + return $base.($S['conf']['mod_rewrite']?'':'/index.php'); } elseif (substr($url, 0, 7) == 'http://') { return $url; } if ($S['conf']['mod_rewrite']) { - return $S['conf']['url'].'/'.$url; + return $base.'/'.$url; } else { if (strpos($url, '?')) { $q=substr($url, strpos($url, '?')+1); $url=substr($url, 0, strpos($url, '?')); } if (strlen($url)) { - return $S['conf']['url'].'/index.php?req='.$url.(isset($q)?'&'.$q:''); + return $base.'/index.php?req='.$url.(isset($q)?'&'.$q:''); } else { - return $S['conf']['url'].'/index.php?'.$q; + return $base.'/index.php?'.$q; } } } diff --git a/shared/include/definitions.php b/shared/include/definitions.php new file mode 100644 index 0000000..b568959 --- /dev/null +++ b/shared/include/definitions.php @@ -0,0 +1,9 @@ +<?php +define('INGENUE_BUILD_QUEUED', -128); +define('INGENUE_BUILD_UPLOADING', -127); +define('INGENUE_BUILD_CANCEL', -126); +define('INGENUE_BUILD_COMPLETE', 0); +define('INGENUE_BUILD_UPLOAD_FAILED', 127); +define('INGENUE_BUILD_FAILED', 126); +define('INGENUE_BUILD_CANCELED', 125); +?> diff --git a/shared/include/includes.php b/shared/include/includes.php index 8a75b58..1394049 100644 --- a/shared/include/includes.php +++ b/shared/include/includes.php @@ -1,6 +1,7 @@ <?php date_default_timezone_set('UTC'); require_once(dirname(__FILE__).'/paths.php'); // USE __dir__ in 5.3.0 +require_once(SHARED.'/include/definitions.php'); // Load functions and classes from the shared directory and either foreground or background foreach (array('functions', 'classes') as $type) { foreach (array(SHARED, ($_SERVER['DOCUMENT_ROOT']?FRONTEND:BACKEND)) as $dir) { |