summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-07-29 11:53:46 -0400
committerEudyptula <eitan@mosenkis.net>2009-07-29 11:53:46 -0400
commit53891176a55bf07ea6e0629a3cf51736aac01f4b (patch)
tree73b62aafd5df3a9fefb880a90e933e23c6ef70e4
parentImplement init script and package pruning in backend (diff)
downloadingenue-53891176a55bf07ea6e0629a3cf51736aac01f4b.tar.gz
ingenue-53891176a55bf07ea6e0629a3cf51736aac01f4b.tar.bz2
ingenue-53891176a55bf07ea6e0629a3cf51736aac01f4b.zip
Add visibility column to builds, configurations
-rw-r--r--frontend/pages/builds/download.php2
-rw-r--r--frontend/pages/builds/history.php2
-rw-r--r--frontend/pages/builds/log.php2
-rw-r--r--shared/classes/build.php21
-rw-r--r--shared/classes/configuration.php5
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='<div class="build"><span class="name">'.(isset($this->name) && strlen($this->name)?htmlentities($this->name):'Unnamed Build').'</span> ';
$links=array();
if ($this->status == -128) {
@@ -60,32 +65,32 @@ class sql_build extends conf_build_common {
$html.="<span class=\"status queued\">[Queued ($num/$total)]</span>";
} elseif ($this->status == -127) {
$html.='<span class="status successful">[uploading]</span>';
- 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.='<span class="status building">[building]</span>';
- 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']?'<a href="'.url("build/$this->id/history").'">':'').$r['count'].' download'.($r['count'] != 1?'s':'').($r['count']?($OoA?'</a>':'').'<br/><span class="time">(last at '.date($format, $r['time']).')</span>':'');
+ $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 ($OoA) $links['Build log']="build/$this->id";
+ if ($perms) $links['Build log']="build/$this->id";
} elseif ($this->status == 127) {
$html.='<span class="status failed">[upload failed]</span>';
- if ($OoA) $links['Build log']="build/$this->id";
+ if ($perms) $links['Build log']="build/$this->id";
} elseif ($this->status == 126) {
$html.='<span class="status failed">[failed]</span>';
- if ($OoA) {
+ if ($perms) {
//$links['View output of failed command']="build/$this->id/failure";
$links['Build log']="build/$this->id";
}
} else {
$html.='<span class="status failed">[failed: got signal '.$this->status.']</span>';
- 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,