diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-08-14 11:12:45 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-08-14 11:12:45 -0400 |
commit | 79d0a253da7c8b167624889df7a61083d6203484 (patch) | |
tree | 73efc8d0d4e6541731fce142047522bbb319b0d5 | |
parent | Added ebuild; added ntpd to init deps; builds show [failed] in frontend when ... (diff) | |
download | ingenue-79d0a253da7c8b167624889df7a61083d6203484.tar.gz ingenue-79d0a253da7c8b167624889df7a61083d6203484.tar.bz2 ingenue-79d0a253da7c8b167624889df7a61083d6203484.zip |
Create sql_row_with_flags class, make user, build, configuration subclasses of it, replace visibility in builds, configurations with flags column; fix init script for correct path
-rw-r--r-- | frontend/pages/builds/download.php | 2 | ||||
-rw-r--r-- | frontend/pages/builds/history.php | 2 | ||||
-rw-r--r-- | frontend/pages/builds/log.php | 2 | ||||
-rw-r--r-- | frontend/pages/configurations/wizard.php | 1 | ||||
-rwxr-xr-x | init_script | 2 | ||||
-rw-r--r-- | shared/classes/1sql_row_with_flags.php | 14 | ||||
-rw-r--r-- | shared/classes/2conf_build_common.php (renamed from shared/classes/1conf_build_common.php) | 2 | ||||
-rw-r--r-- | shared/classes/build.php | 8 | ||||
-rw-r--r-- | shared/classes/configuration.php | 8 | ||||
-rw-r--r-- | shared/classes/gentoo_profile.php | 2 | ||||
-rw-r--r-- | shared/classes/user.php | 5 |
11 files changed, 29 insertions, 19 deletions
diff --git a/frontend/pages/builds/download.php b/frontend/pages/builds/download.php index f472046..ec957a1 100644 --- a/frontend/pages/builds/download.php +++ b/frontend/pages/builds/download.php @@ -13,7 +13,7 @@ function init_builds_download(&$S) { return '404'; } $build=new sql_build($r->fetch(PDO::FETCH_ASSOC)); - if ($build->visibility == 'private' && !owner_or_admin($build->owner)) { + if ($build->has_flag('p') && !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 c9789e3..9e965f3 100644 --- a/frontend/pages/builds/history.php +++ b/frontend/pages/builds/history.php @@ -7,7 +7,7 @@ function init_builds_history(&$S) { $r=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 ($S['builds_history']['build']->visibility == 'private' && !owner_or_admin($S['builds_history']['build']->id)) { + if ($S['builds_history']['build']->has_flag('p') && !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 078b816..31ee5c7 100644 --- a/frontend/pages/builds/log.php +++ b/frontend/pages/builds/log.php @@ -6,7 +6,7 @@ function init_builds_log(&$S) { $r=query('SELECT * FROM `builds` WHERE `id`="'.$_REQUEST['build'].'"'); if ($r->rowCount()) { $S['builds_log']=new sql_build($r->fetch(PDO::FETCH_ASSOC)); - if ($S['builds_log']->visibility == 'private' && !owner_or_admin($S['builds_log']->owner)) return '404'; + if ($S['builds_log']->has_flag('p') && !owner_or_admin($S['builds_log']->owner)) return '404'; } else return '404'; if (isset($_REQUEST['task']) && is_numeric($_REQUEST['task'])) diff --git a/frontend/pages/configurations/wizard.php b/frontend/pages/configurations/wizard.php index 33b9949..6dc6a8e 100644 --- a/frontend/pages/configurations/wizard.php +++ b/frontend/pages/configurations/wizard.php @@ -36,7 +36,6 @@ function init_configurations_wizard(&$S) { $S['wizard']['configuration']=new sql_configuration(); $configuration=&$S['wizard']['configuration']; $configuration->name=$_REQUEST['name']; - $configuration->visibility='public'; $mod=isset($_REQUEST['mod']) && isset($S['conf']['modules'][$_REQUEST['mod']])?$S['conf']['modules'][$_REQUEST['mod']]:$S['conf']['modules'][0]; $configuration->module=$mod; $configuration->init(); diff --git a/init_script b/init_script index 8069ef2..18f14dc 100755 --- a/init_script +++ b/init_script @@ -1,6 +1,6 @@ #!/sbin/runscript -INGENUE_PATH="/home/eitan/soc/git" +INGENUE_PATH="/usr/share/ingenue" depend() { need mysql ntpd diff --git a/shared/classes/1sql_row_with_flags.php b/shared/classes/1sql_row_with_flags.php new file mode 100644 index 0000000..43638a6 --- /dev/null +++ b/shared/classes/1sql_row_with_flags.php @@ -0,0 +1,14 @@ +<?php +abstract class sql_row_with_flags extends sql_row_obj { + public function has_flag($flag) { + return (strpos($this->flags, $flag) !== false); + } + public function set_flag($flag) { + if (!$this->has_flag($flag)) + $this->flags.=$flag; + } + public function unset_flag($flag) { + $this->flags=str_replace($flag, '', $this->flags); + } +} +?> diff --git a/shared/classes/1conf_build_common.php b/shared/classes/2conf_build_common.php index 27c2198..acd9c0c 100644 --- a/shared/classes/1conf_build_common.php +++ b/shared/classes/2conf_build_common.php @@ -1,5 +1,5 @@ <?php -abstract class conf_build_common extends sql_row_obj { +abstract class conf_build_common extends sql_row_with_flags { private $info; private function set_vars() { if (isset($this->info)) { diff --git a/shared/classes/build.php b/shared/classes/build.php index 45d8f07..6ba6798 100644 --- a/shared/classes/build.php +++ b/shared/classes/build.php @@ -25,9 +25,9 @@ class sql_build extends conf_build_common { 'not_null' => true, 'default' => '' ), - 'visibility' => array ( - 'type' => 'ENUM', - 'length' => '\'public\',\'private\'', + 'flags' => array ( + 'type' => 'VARCHAR', + 'length' => 255, 'not_null' => true ), 'backend' => array ( @@ -75,7 +75,7 @@ class sql_build extends conf_build_common { public function display() { global $S; $format='D j M Y G:i:s T'; - $perms=$this->visibility == 'public' || owner_or_admin($this->id); + $perms=!$this->has_flag('p') || owner_or_admin($this->id); $html='<div class="build"><span class="name">'.(isset($this->name) && strlen($this->name)?htmlentities($this->name):'Unnamed Build').'</span> '; if ($this->failed == 'true') $html.='<span class="status failed">[failed]</span> '; diff --git a/shared/classes/configuration.php b/shared/classes/configuration.php index 8780b9d..4d7ac60 100644 --- a/shared/classes/configuration.php +++ b/shared/classes/configuration.php @@ -25,9 +25,9 @@ class sql_configuration extends conf_build_common { 'not_null' => true, 'default' => '' ), - 'visibility' => array ( - 'type' => 'ENUM', - 'length' => '\'public\',\'private\'', + 'flags' => array ( + 'type' => 'VARCHAR', + 'length' => 255, 'not_null' => true ), 'status' => array ( @@ -48,10 +48,10 @@ class sql_configuration extends conf_build_common { } } $build=new sql_build(); - $build->visibility='public'; $build->init(); $build->name=$name; $build->module=$this->module; + $build->flags=$this->flags; $opts=$this->get_opts(); $opts['configuration']=$this->id; foreach ($opts as $name => $val) { diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php index d41497b..046de26 100644 --- a/shared/classes/gentoo_profile.php +++ b/shared/classes/gentoo_profile.php @@ -1,5 +1,5 @@ <?php -class sql_gentoo_profile extends sql_row_obj { +class sql_gentoo_profile extends sql_row_with_flags { protected $table='gentoo_profiles', $primary_key=array('id'), $columns=array( 'id' => array ( 'type' => 'TINYINT', diff --git a/shared/classes/user.php b/shared/classes/user.php index eef0977..127397c 100644 --- a/shared/classes/user.php +++ b/shared/classes/user.php @@ -1,5 +1,5 @@ <?php -class sql_user extends sql_row_obj { +class sql_user extends sql_row_with_flags { protected $table='users', $primary_key=array('id'), $columns=array( 'id' => array ( 'type' => 'INT', @@ -35,8 +35,5 @@ class sql_user extends sql_row_obj { ) ); - public function has_flag($flag) { - return (strpos($this->flags, $flag) !== false); - } } ?> |