[Fusionforge-commits] r9927 - in trunk/gforge: common/include plugins/scmsvn/etc

Roland Mas lolando at libremir.placard.fr.eu.org
Thu May 27 12:32:45 CEST 2010


Author: lolando
Date: 2010-05-27 12:32:45 +0200 (Thu, 27 May 2010)
New Revision: 9927

Modified:
   trunk/gforge/common/include/config-vars.php
   trunk/gforge/common/include/config.php
   trunk/gforge/plugins/scmsvn/etc/scmsvn.ini
Log:
Define some config vars as boolean, with user-friendly values such as 'yes', 'true', 'on' and '1' being interpreted as true

Modified: trunk/gforge/common/include/config-vars.php
===================================================================
--- trunk/gforge/common/include/config-vars.php	2010-05-27 10:32:35 UTC (rev 9926)
+++ trunk/gforge/common/include/config-vars.php	2010-05-27 10:32:45 UTC (rev 9927)
@@ -24,8 +24,11 @@
 
 forge_define_config_item ('forge_name', 'core', $GLOBALS['sys_name']) ;
 forge_define_config_item ('force_login', 'core', $GLOBALS['sys_force_login']) ;
+forge_config_item_bool ('force_login', 'core') ;
 forge_define_config_item ('user_registration_restricted', 'core', $GLOBALS['sys_user_reg_restricted']) ;
+forge_config_item_bool ('user_registration_restricted', 'core') ;
 forge_define_config_item ('project_registration_restricted', 'core', $GLOBALS['sys_project_reg_restricted']) ;
+forge_config_item_bool ('project_registration_restricted', 'core') ;
 forge_define_config_item ('web_host', 'core', $GLOBALS['sys_default_domain']) ;
 forge_define_config_item ('apache_user', 'core', $GLOBALS['sys_apache_user']) ;
 forge_define_config_item ('apache_group', 'core', $GLOBALS['sys_apache_group']) ;
@@ -38,28 +41,52 @@
 forge_define_config_item ('default_timezone', 'core', $GLOBALS['sys_default_timezone']) ;
 forge_define_config_item ('default_country_code', 'core', $GLOBALS['sys_default_country_code']) ;
 forge_define_config_item ('use_scm', 'core', $GLOBALS['sys_use_scm']) ;
+forge_config_item_bool ('use_scm', 'core') ;
 forge_define_config_item ('use_tracker', 'core', $GLOBALS['sys_use_tracker']) ;
+forge_config_item_bool ('use_tracker', 'core') ;
 forge_define_config_item ('use_forum', 'core', $GLOBALS['sys_use_forum']) ;
-forge_define_config_item ('use_pm', 'core', $GLOBALS['sys_use_pm']) ;
-forge_define_config_item ('use_docman', 'core', $GLOBALS['sys_use_docman']) ;
+forge_config_item_bool ('use_forum', 'core') ;
+forge_item_bool_bool ('use_forum', 'core') ;
+forge_define_config_item ('use_pm') ;
+forge_config_item_bool ('use_pm') ;
+forge_define_config_item ('use_docman', 'core') ;
+forge_config_item_bool ('use_docman', 'core') ;
 forge_define_config_item ('use_news', 'core', $GLOBALS['sys_use_news']) ;
+forge_config_item_bool ('use_news', 'core') ;
 forge_define_config_item ('use_mail', 'core', $GLOBALS['sys_use_mail']) ;
+forge_config_item_bool ('use_mail', 'core') ;
 forge_define_config_item ('use_survey', 'core', $GLOBALS['sys_use_survey']) ;
+forge_config_item_bool ('use_survey', 'core') ;
 forge_define_config_item ('use_frs', 'core', $GLOBALS['sys_use_frs']) ;
+forge_config_item_bool ('use_frs', 'core') ;
 forge_define_config_item ('use_fti', 'core', $GLOBALS['sys_use_fti']) ;
+forge_config_item_bool ('use_fti', 'core') ;
 forge_define_config_item ('use_ftp', 'core', $GLOBALS['sys_use_ftp']) ;
+forge_config_item_bool ('use_ftp', 'core') ;
 forge_define_config_item ('use_trove', 'core', $GLOBALS['sys_use_trove']) ;
+forge_config_item_bool ('use_trove', 'core') ;
 forge_define_config_item ('use_snippet', 'core', $GLOBALS['sys_use_snippet']) ;
+forge_config_item_bool ('use_snippet', 'core') ;
 forge_define_config_item ('use_ssl', 'core', $GLOBALS['sys_use_ssl']) ;
+forge_config_item_bool ('use_ssl', 'core') ;
 forge_define_config_item ('use_people', 'core', $GLOBALS['sys_use_people']) ;
+forge_config_item_bool ('use_people', 'core') ;
 forge_define_config_item ('use_shell', 'core', $GLOBALS['sys_use_shell']) ;
+forge_config_item_bool ('use_shell', 'core') ;
 forge_define_config_item ('use_ratings', 'core', $GLOBALS['sys_use_ratings']) ;
+forge_config_item_bool ('use_ratings', 'core') ;
 forge_define_config_item ('use_ftpuploads', 'core', $GLOBALS['sys_use_ftpuploads']) ;
+forge_config_item_bool ('use_ftpuploads', 'core') ;
 forge_define_config_item ('use_manual_uploads', 'core', $GLOBALS['sys_use_manual_uploads']) ;
+forge_config_item_bool ('use_manual_uploads', 'core') ;
 forge_define_config_item ('use_gateways', 'core', $GLOBALS['sys_use_gateways']) ;
+forge_config_item_bool ('use_gateways', 'core') ;
 forge_define_config_item ('use_project_vhost', 'core', $GLOBALS['sys_use_project_vhost']) ;
+forge_config_item_bool ('use_project_vhost', 'core') ;
 forge_define_config_item ('use_project_database', 'core', $GLOBALS['sys_use_project_database']) ;
+forge_config_item_bool ('use_project_database', 'core') ;
 forge_define_config_item ('use_project_multimedia', 'core', $GLOBALS['sys_use_project_multimedia']) ;
+forge_config_item_bool ('use_project_multimedia', 'core') ;
 forge_define_config_item ('download_host', 'core', $GLOBALS['sys_download_host']) ;
 forge_define_config_item ('shell_host', 'core', $GLOBALS['sys_shell_host']) ;
 forge_define_config_item ('users_host', 'core', $GLOBALS['sys_users_host']) ;
@@ -67,6 +94,7 @@
 forge_define_config_item ('scm_host', 'core', $GLOBALS['sys_scm_host']) ;
 forge_define_config_item ('forum_return_domain', 'core', $GLOBALS['sys_forum_return_domain']) ;
 forge_define_config_item ('use_jabber', 'core', $GLOBALS['sys_use_jabber']) ;
+forge_config_item_bool ('use_jabber', 'core') ;
 forge_define_config_item ('jabber_host', 'core', $GLOBALS['sys_jabber_server']) ;
 forge_define_config_item ('jabber_port', 'core', $GLOBALS['sys_jabber_port']) ;
 forge_define_config_item ('jabber_user', 'core', $GLOBALS['sys_jabber_user']) ;
@@ -205,8 +233,11 @@
 	}
 
 	forge_define_config_item ('use_ssh', 'scmsvn', $use_ssh ? 1 : 0) ;
+	forge_config_item_bool ('use_ssh', 'scmsvn') ;
 	forge_define_config_item ('use_dav', 'scmsvn', $use_dav ? 1 : 0) ;
+	forge_config_item_bool ('use_dav', 'scmsvn') ;
 	forge_define_config_item ('use_ssl', 'scmsvn', $use_ssl ? 1 : 0) ;
+	forge_config_item_bool ('use_ssl', 'scmsvn') ;
 }
 
 // forge_define_config_item ('', 'core', $GLOBALS['sys_']) ;

Modified: trunk/gforge/common/include/config.php
===================================================================
--- trunk/gforge/common/include/config.php	2010-05-27 10:32:35 UTC (rev 9926)
+++ trunk/gforge/common/include/config.php	2010-05-27 10:32:45 UTC (rev 9927)
@@ -25,6 +25,7 @@
 class FusionForgeConfig {
 	static protected $instance = NULL ;
 	private $settings ;
+	private $bools = array () ;
     
 	public function get_instance () {
 		if (self::$instance == NULL) {
@@ -34,20 +35,20 @@
 	}
   
 	public function get_value ($section, $var) {
-		if (!isset (self::$instance->settings[$section])
-		    || !isset (self::$instance->settings[$section][$var])) {
+		if (!isset ($this->settings[$section])
+		    || !isset ($this->settings[$section][$var])) {
 			return NULL ;
 		}
-		return self::$instance->settings[$section][$var] ;
+		return $this->settings[$section][$var] ;
 	}
 
 	public function set_value ($section, $var, $value) {
-		if (!isset (self::$instance->settings[$section])) {
-			self::$instance->settings[$section] = array () ;
+		if (!isset ($this->settings[$section])) {
+			$this->settings[$section] = array () ;
 		}
 
-		if (!isset (self::$instance->settings[$section][$var])) {
-			self::$instance->settings[$section][$var] = $value ;
+		if (!isset ($this->settings[$section][$var])) {
+			$this->settings[$section][$var] = $value ;
 		}
 	}
 
@@ -57,7 +58,11 @@
 			if (is_array($sections)) {
 				foreach ($sections as $section => $options) {
 					foreach ($options as $var => $value) {
-						self::$instance->settings[$section][$var] = $value ;
+						if (isset ($this->bools[$section][$var])) {
+							$this->settings[$section][$var] = $this->_interpret_as_bool ($value) ;
+						} else {
+							$this->settings[$section][$var] = $value ;
+						}
 					}
 				}
 			}
@@ -65,6 +70,31 @@
 		return ;
 	}
 
+	function mark_as_bool ($section, $var) {
+		if (!array_has_key ($this->bools, $section)) {
+			$this->bools[$section] = array () ;
+		}
+		$this->bools[$section][$var] = true ;
+
+		if (isset ($this->settings[$section][$var])) {
+			$this->settings[$section][$var] = $this->_interpret_as_bool ($this->settings[$section][$var]) ;
+		}
+	}
+
+	private function _interpret_as_bool ($val) {
+		$val = strtolower ($val) ;
+		switch ($val) {
+		case 'true':
+		case 'on':
+		case 'yes':
+		case '1':
+		case true:
+			return true ;
+		}
+		
+		return false ;
+	}
+
   }
 
 if (!isset ($fusionforge_config)) {
@@ -127,6 +157,12 @@
 	return $c->set_value ($section, $var, $default) ;
 }
 
+function forge_set_config_item_bool ($var, $section) {
+	$c = FusionForgeConfig::get_instance () ;
+
+	return $c->mark_as_bool ($section, $var) ;
+}
+
 function forge_read_config_file ($file) {
 	$c = FusionForgeConfig::get_instance () ;
 

Modified: trunk/gforge/plugins/scmsvn/etc/scmsvn.ini
===================================================================
--- trunk/gforge/plugins/scmsvn/etc/scmsvn.ini	2010-05-27 10:32:35 UTC (rev 9926)
+++ trunk/gforge/plugins/scmsvn/etc/scmsvn.ini	2010-05-27 10:32:45 UTC (rev 9927)
@@ -1,4 +1,4 @@
 [scmsvn]
-use_dav = 1
-use_ssl = 1
-use_ssh = 0
+use_dav = yes
+use_ssl = yes
+use_ssh = no




More information about the Fusionforge-commits mailing list