[Fusionforge-commits] r12578 - in trunk/src: common/include plugins/scmgit/common www/scm www/scm/admin

Franck VILLAUME nerville at fusionforge.org
Fri Mar 4 18:47:22 CET 2011


Author: nerville
Date: 2011-03-04 18:47:21 +0100 (Fri, 04 Mar 2011)
New Revision: 12578

Modified:
   trunk/src/common/include/SCMPlugin.class.php
   trunk/src/plugins/scmgit/common/GitPlugin.class.php
   trunk/src/www/scm/admin/index.php
   trunk/src/www/scm/index.php
Log:
cleanup & warnings

Modified: trunk/src/common/include/SCMPlugin.class.php
===================================================================
--- trunk/src/common/include/SCMPlugin.class.php	2011-03-04 17:34:16 UTC (rev 12577)
+++ trunk/src/common/include/SCMPlugin.class.php	2011-03-04 17:47:21 UTC (rev 12578)
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License as published
  * by the Free Software Foundation; either version 2 of the License,
  * or (at your option) any later version.
- * 
+ *
  * FusionForge is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -46,7 +46,7 @@
 
 	function CallHook ($hookname, &$params) {
 		global $HTML ;
-		
+
 		switch ($hookname) {
 		case 'scm_plugin':
 			$scm_plugins=& $params['scm_plugins'];
@@ -62,7 +62,7 @@
 			$this->printAdminPage ($params) ;
 			break ;
 		case 'scm_admin_update':
-			$this->adminUpdate ($params) ;
+			$this->adminUpdate($params);
 			break ;
 		case 'scm_stats':
 			$this->printShortStats ($params) ;
@@ -94,13 +94,13 @@
 		$scm_list[] = $this->name ;
 	}
 
-	function browserDisplayable ($project) {
-		if ($project->usesSCM ()
+	function browserDisplayable($project) {
+		if ($project->usesSCM()
 		    && $project->usesPlugin($this->name)
 		    && $project->enableAnonSCM()) {
-			return true ;
+			return true;
 		} else {
-			return false ;
+			return false;
 		}
 	}
 
@@ -111,7 +111,7 @@
 		if (!$project) {
 			return false ;
 		}
-		
+
 		if ($project->usesPlugin ($this->name)) {
 			echo ' ('.$this->text.')' ;
 		}
@@ -172,7 +172,7 @@
 		if (!$project) {
 			return false ;
 		}
-		
+
 		if ($project->usesPlugin ($this->name)) {
 
 			// Table for summary info
@@ -183,7 +183,7 @@
 			if ($project->enableAnonSCM()) {
 				print $this->getInstructionsForAnon ($project) ;
 			}
-	
+
 			// Instructions for developer access
 			print $this->getInstructionsForRW ($project) ;
 
@@ -196,24 +196,24 @@
 			// Browsing
 			echo $HTML->boxTop(_('Repository History'));
 			echo _('Data about current and past states of the repository') ;
-			if ($this->browserDisplayable ($project)) {
-				echo $this->getStatsBlock($project) ;
-				echo $this->getBrowserLinkBlock ($project) ;
+			if ($this->browserDisplayable($project)) {
+				echo $this->getStatsBlock($project);
+				echo $this->getBrowserLinkBlock($project);
 			}
-			
+
 			echo $HTML->boxBottom();
 			print '</td></tr></table>' ;
 		}
 	}
 
-	function printBrowserPage ($params) {
+	function printBrowserPage($params) {
 		global $HTML;
 
 		$project = $this->checkParams ($params) ;
 		if (!$project) {
 			return false ;
 		}
-		
+
 		if ($project->usesPlugin ($this->name)) {
 			if ($this->browserDisplayable ($project)) {
 				// print '<iframe src="'.util_make_url('/scm/browser.php?title='.$group->getUnixName()).'" frameborder="0" width=100% height=700></iframe>' ;
@@ -221,28 +221,28 @@
 		}
 	}
 
-	function printAdminPage ($params) {
+	function printAdminPage($params) {
 		$group = group_get_object($params['group_id']);
-		if ( $group->usesPlugin ( $this->name ) && $group->isPublic()) {
+		if ( $group->usesPlugin($this->name) && $group->isPublic()) {
 			print '<p><input type="checkbox" name="scm_enable_anonymous" value="1" '.$this->c($group->enableAnonSCM()).' /><strong>'._('Enable Anonymous Access').'</strong></p>';
 		}
 	}
-	
-	function adminUpdate ($params) {
-		$project = $this->checkParams ($params) ;
+
+	function adminUpdate($params) {
+		$project = $this->checkParams($params);
 		if (!$project) {
-			return false ;
+			return false;
 		}
-		
-		if ($project->usesPlugin ($this->name) ) {
-			if ($params['scm_enable_anonymous']) {
+
+		if ($project->usesPlugin($this->name) ) {
+			if (isset($params['scm_enable_anonymous']) && $params['scm_enable_anonymous']) {
 				$project->SetUsesAnonSCM(true);
 			} else {
 				$project->SetUsesAnonSCM(false);
 			}
 		}
 	}
-	
+
 	function checkParams ($params) {
 		$group_id = $params['group_id'] ;
 		$project = group_get_object($group_id);
@@ -251,10 +251,10 @@
 		} elseif ($project->isError()) {
 			return false;
 		}
-		
+
 		return $project ;
 	}
-	
+
 	function c($v) {
 		if ($v) {
 			return 'checked="checked"';
@@ -262,7 +262,7 @@
 			return '';
 		}
 	}
-	
+
 }
 
 // Local Variables:

Modified: trunk/src/plugins/scmgit/common/GitPlugin.class.php
===================================================================
--- trunk/src/plugins/scmgit/common/GitPlugin.class.php	2011-03-04 17:34:16 UTC (rev 12577)
+++ trunk/src/plugins/scmgit/common/GitPlugin.class.php	2011-03-04 17:47:21 UTC (rev 12578)
@@ -130,7 +130,6 @@
 				$b = '<p class="warning">'._('Missing configuration for access in scmgit.ini : use_ssh and use_dav disabled').'</p>';
 			}
 		} else {
-			echo 'TOTO';
 			$b = '<h2>';
 			$b .= _('Developer GIT Access via SSH');
 			$b .= '</h2>';
@@ -173,40 +172,39 @@
 				}
 			}
 		}
-
 		return $b;
 	}
 
-	function getSnapshotPara ($project) {
+	function getSnapshotPara($project) {
 
 		$b = "" ;
 		$filename = $project->getUnixName().'-scm-latest.tar'.util_get_compressed_file_extension();
 		if (file_exists(forge_get_config('scm_snapshots_path').'/'.$filename)) {
 			$b .= '<p>[' ;
-			$b .= util_make_link ("/snapshots.php?group_id=".$project->getID(),
+			$b .= util_make_link("/snapshots.php?group_id=".$project->getID(),
 					      _('Download the nightly snapshot')
-				) ;
+				);
 			$b .= ']</p>';
 		}
 		return $b ;
 	}
 
-	function printBrowserPage ($params) {
+	function printBrowserPage($params) {
 		global $HTML;
 
-		$project = $this->checkParams ($params) ;
+		$project = $this->checkParams($params);
 		if (!$project) {
-			return false ;
+			return false;
 		}
 
-		if ($project->usesPlugin ($this->name)) {
-			if ($this->browserDisplayable ($project)) {
-				print '<iframe src="'.util_make_url ("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/'.$project->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>' ;
+		if ($project->usesPlugin($this->name)) {
+			if ($this->browserDisplayable($project)) {
+				print '<iframe src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/'.$project->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>' ;
 			}
 		}
 	}
 
-	function getBrowserLinkBlock ($project) {
+	function getBrowserLinkBlock($project) {
 		global $HTML ;
 		$b = $HTML->boxMiddle(_('Git Repository Browser'));
 		$b .= '<p>';
@@ -346,25 +344,25 @@
 		}
 	}
 
-	function updateRepositoryList ($params) {
-		$groups = $this->getGroups () ;
-		$list = array () ;
+	function updateRepositoryList($params) {
+		$groups = $this->getGroups();
+		$list = array();
 		foreach ($groups as $project) {
-			if ($this->browserDisplayable ($project)) {
-				$list[] = $project ;
+			if ($this->browserDisplayable($project)) {
+				$list[] = $project;
 			}
 		}
 
-		$config_dir = '/etc/gforge/plugins/scmgit' ;
+		$config_dir = forge_get_config('config_path').'/plugins/scmgit';
 		$fname = $config_dir . '/gitweb.conf' ;
-		$config_f = fopen ($fname.'.new', 'w') ;
+		$config_f = fopen($fname.'.new', 'w') ;
 		$rootdir = forge_get_config('repos_path', 'scmgit');
 		fwrite($config_f, "\$projectroot = '$rootdir';\n");
 		fwrite($config_f, "\$projects_list = '$config_dir/gitweb.list';\n");
-		fwrite($config_f, "@git_base_url_list = ('". util_make_url ('/anonscm/git') . "');\n");
-		fwrite($config_f, "\$logo = '". util_make_url ('/plugins/scmgit/git-logo.png') . "';\n");
-		fwrite($config_f, "\$favicon = '". util_make_url ('/plugins/scmgit/git-favicon.png')."';\n");
-		fwrite($config_f, "\$stylesheet = '". util_make_url ('/plugins/scmgit/gitweb.css')."';\n");
+		fwrite($config_f, "@git_base_url_list = ('". util_make_url('/anonscm/git') . "');\n");
+		fwrite($config_f, "\$logo = '". util_make_url('/plugins/scmgit/git-logo.png') . "';\n");
+		fwrite($config_f, "\$favicon = '". util_make_url('/plugins/scmgit/git-favicon.png')."';\n");
+		fwrite($config_f, "\$stylesheet = '". util_make_url('/plugins/scmgit/gitweb.css')."';\n");
 		fwrite($config_f, "\$prevent_xss = 'true';\n");
 		fclose($config_f);
 		chmod ($fname.'.new', 0644) ;
@@ -372,39 +370,41 @@
 
 		$fname = $config_dir . '/gitweb.list' ;
 
-		$f = fopen ($fname.'.new', 'w') ;
+		$f = fopen ($fname.'.new', 'w');
 		foreach ($list as $project) {
                         $repos = $this->getRepositories($rootdir . "/" .  $project->getUnixName());
                         foreach ($repos as $repo) {
                                 $reldir = substr($repo, strlen($rootdir) + 1);
-			        fwrite ($f, $reldir . "\n");
+			        fwrite($f, $reldir . "\n");
                         }
 		}
-		fclose ($f) ;
-		chmod ($fname.'.new', 0644) ;
-		rename ($fname.'.new', $fname) ;
+		fclose($f);
+		chmod($fname.'.new', 0644);
+		rename($fname.'.new', $fname);
 	}
 
-        function getRepositories($path) {
-                if (! is_dir($path))
-                        return;
-                $list = array();
-                $entries = scandir($path);
-                foreach ($entries as $entry) {
-                        $fullname = $path . "/" . $entry;
-                        if (($entry == ".") or ($entry == ".."))
-                                continue;
-                        if (is_dir($fullname)) {
-                                if (is_link($fullname))
-                                        continue;
-                                $result = $this->getRepositories($fullname);
-                                $list = array_merge($list, $result);
-                        } else if ($entry == "HEAD") {
-                                $list[] = $path;
-                        }
-                }
-                return $list;
-        }
+	function getRepositories($path) {
+		if (! is_dir($path)) {
+			echo 'pas de path ?';
+			return;
+		}
+		$list = array();
+		$entries = scandir($path);
+		foreach ($entries as $entry) {
+			$fullname = $path . "/" . $entry;
+			if (($entry == ".") or ($entry == ".."))
+				continue;
+			if (is_dir($fullname)) {
+				if (is_link($fullname))
+					continue;
+				$result = $this->getRepositories($fullname);
+				$list = array_merge($list, $result);
+			} else if ($entry == "HEAD") {
+				$list[] = $path;
+			}
+		}
+		return $list;
+	}
 
 	function gatherStats ($params) {
 		global $last_user, $usr_adds, $usr_deletes,

Modified: trunk/src/www/scm/admin/index.php
===================================================================
--- trunk/src/www/scm/admin/index.php	2011-03-04 17:34:16 UTC (rev 12577)
+++ trunk/src/www/scm/admin/index.php	2011-03-04 17:47:21 UTC (rev 12578)
@@ -30,14 +30,14 @@
 $group_id = getIntFromRequest('group_id');
 
 // Check permissions
-session_require_perm ('project_admin', $group_id) ;
+session_require_perm('project_admin', $group_id);
 
 if (getStringFromRequest('submit')) {
-	$hook_params = array ();
+	$hook_params = array();
 	$hook_params['group_id'] = $group_id;
 
 	$scmradio = '';
-	$scmvars = array_keys (_getRequestArray());
+	$scmvars = array_keys(_getRequestArray());
 	foreach (_getRequestArray() as $key => $value) {
 		foreach ($scm_list as $scm) {
 			if ($key == strstr($key, $scm . "_")) {
@@ -67,7 +67,7 @@
 		}
 	}
 
-	plugin_hook ("scm_admin_update", $hook_params);
+	plugin_hook("scm_admin_update", $hook_params);
 }
 
 scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
@@ -81,7 +81,7 @@
 
 	$SCMFactory = new SCMFactory();
 	$scm_plugins = $SCMFactory->getSCMs();
-	if (count($scm_plugins) != 0) {	
+	if (count($scm_plugins) != 0) {
 		if (count($scm_plugins) == 1) {
 			$myPlugin = plugin_get_object($scm_plugins[0]);
 			echo '<input type="hidden" name="scmradio" value="'.$myPlugin->name.'" />' ;

Modified: trunk/src/www/scm/index.php
===================================================================
--- trunk/src/www/scm/index.php	2011-03-04 17:34:16 UTC (rev 12577)
+++ trunk/src/www/scm/index.php	2011-03-04 17:47:21 UTC (rev 12578)
@@ -23,7 +23,7 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'scm/include/scm_utils.php';    
+require_once $gfwww.'scm/include/scm_utils.php';
 
 $group_id = getIntFromRequest("group_id");
 $group = group_get_object($group_id);
@@ -32,12 +32,12 @@
 }
 scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
 
-plugin_hook ("blocks", "scm index");
+plugin_hook("blocks", "scm index");
 
-$hook_params = array () ;
-$hook_params['group_id'] = $group_id ;
-plugin_hook ("scm_page", $hook_params) ;
+$hook_params = array();
+$hook_params['group_id'] = $group_id;
+plugin_hook("scm_page", $hook_params);
 
-scm_footer(); 
+scm_footer();
 
 ?>




More information about the Fusionforge-commits mailing list