From 53891176a55bf07ea6e0629a3cf51736aac01f4b Mon Sep 17 00:00:00 2001 From: Eudyptula Date: Wed, 29 Jul 2009 11:53:46 -0400 Subject: Add visibility column to builds, configurations --- frontend/pages/builds/download.php | 2 +- frontend/pages/builds/history.php | 2 +- frontend/pages/builds/log.php | 2 +- shared/classes/build.php | 21 +++++++++++++-------- shared/classes/configuration.php | 5 +++++ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/frontend/pages/builds/download.php b/frontend/pages/builds/download.php index c662cf1..c40606d 100644 --- a/frontend/pages/builds/download.php +++ b/frontend/pages/builds/download.php @@ -14,7 +14,7 @@ function init_builds_download() { return '404'; } $build=new sql_build($r->fetch(PDO::FETCH_ASSOC)); - if (!owner_or_admin($build->owner)) { + if ($build->visibility == 'private' && !owner_or_admin($build->owner)) { debug('builds_download', 'Permission denied'); return '404'; } diff --git a/frontend/pages/builds/history.php b/frontend/pages/builds/history.php index 0ddcbff..cd8e581 100644 --- a/frontend/pages/builds/history.php +++ b/frontend/pages/builds/history.php @@ -8,7 +8,7 @@ function init_builds_history() { $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `id`="'.$request['build'].'"'); if (!$r->rowCount()) return '404'; $S['builds_history']['build']=new sql_build($r->fetch(PDO::FETCH_ASSOC)); - if (!owner_or_admin($S['builds_history']['build']->id)) { + if ($S['builds_history']['build']->visibility == 'private' && !owner_or_admin($S['builds_history']['build']->id)) { return '404'; } return array('title' => 'Download History'); diff --git a/frontend/pages/builds/log.php b/frontend/pages/builds/log.php index ee652f3..699887f 100644 --- a/frontend/pages/builds/log.php +++ b/frontend/pages/builds/log.php @@ -7,7 +7,7 @@ function init_builds_log() { $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `id`="'.$request['build'].'"'); if ($r->rowCount()) { $S['builds_log']=new sql_build($r->fetch(PDO::FETCH_ASSOC)); - if (!owner_or_admin($S['builds_log']->owner)) return '404'; // TODO permission denied + if ($S['builds_log']->visibility == 'private' && !owner_or_admin($S['builds_log']->owner)) return '404'; } else return '404'; if (isset($request['task']) && is_numeric($request['task'])) diff --git a/shared/classes/build.php b/shared/classes/build.php index 4e11407..db12801 100644 --- a/shared/classes/build.php +++ b/shared/classes/build.php @@ -25,6 +25,11 @@ class sql_build extends conf_build_common { 'not_null' => true, 'default' => '' ), + 'visibility' => array ( + 'type' => 'ENUM', + 'length' => '\'public\',\'private\'', + 'not_null' => true + ), 'status' => array ( 'type' => 'TINYINT', 'length' => 4, @@ -51,7 +56,7 @@ class sql_build extends conf_build_common { public function display() { global $S; $format='D j M Y G:i:s T'; - $OoA=owner_or_admin($this->id); + $perms=$this->visibility == 'public' || owner_or_admin($this->id); $html='
'.(isset($this->name) && strlen($this->name)?htmlentities($this->name):'Unnamed Build').' '; $links=array(); if ($this->status == -128) { @@ -60,32 +65,32 @@ class sql_build extends conf_build_common { $html.="[Queued ($num/$total)]"; } elseif ($this->status == -127) { $html.='[uploading]'; - if ($OoA) $links['Build log']="build/$this->id"; + if ($perms) $links['Build log']="build/$this->id"; } elseif ($this->status < 0) { // TODO Build stage X $html.='[building]'; - if ($OoA) { + if ($perms) { //$links['Watch']="build/$this->id/live"; $links['Build Log']="build/$this->id"; } } elseif ($this->status == 0) { $r=$S['pdo']->query('SELECT COUNT(*) as `count`, MAX(`time`) as `time` FROM `downloads` WHERE `build`="'.$this->id.'"')->fetch(PDO::FETCH_ASSOC); - $d=($OoA && $r['count']?'id/history").'">':'').$r['count'].' download'.($r['count'] != 1?'s':'').($r['count']?($OoA?'':'').'
(last at '.date($format, $r['time']).')':''); + $d=($perms && $r['count']?'id/history").'">':'').$r['count'].' download'.($r['count'] != 1?'s':'').($r['count']?($perms?'':'').'
(last at '.date($format, $r['time']).')':''); $html.=''.$d.'[successful]'; $links['Download image']="build/$this->id/download"; - if ($OoA) $links['Build log']="build/$this->id"; + if ($perms) $links['Build log']="build/$this->id"; } elseif ($this->status == 127) { $html.='[upload failed]'; - if ($OoA) $links['Build log']="build/$this->id"; + if ($perms) $links['Build log']="build/$this->id"; } elseif ($this->status == 126) { $html.='[failed]'; - if ($OoA) { + if ($perms) { //$links['View output of failed command']="build/$this->id/failure"; $links['Build log']="build/$this->id"; } } else { $html.='[failed: got signal '.$this->status.']'; - if ($OoA) $links['Build log']="build/$this->id"; + if ($perms) $links['Build log']="build/$this->id"; } if ($this->status >= 0 || $this->status == -128) // Finished or queued $links['Delete']="build/$this->id/delete"; diff --git a/shared/classes/configuration.php b/shared/classes/configuration.php index a3cdec3..c6d5766 100644 --- a/shared/classes/configuration.php +++ b/shared/classes/configuration.php @@ -25,6 +25,11 @@ class sql_configuration extends conf_build_common { 'not_null' => true, 'default' => '' ), + 'visibility' => array ( + 'type' => 'ENUM', + 'length' => '\'public\',\'private\'', + 'not_null' => true + ), 'status' => array ( 'type' => 'TINYINT', 'length' => 4, -- cgit v1.2.3-65-gdbad