[Fusionforge-commits] r11878 - trunk/src/common/widget

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Wed Dec 22 15:12:17 CET 2010


Author: nerville
Date: 2010-12-22 15:12:17 +0100 (Wed, 22 Dec 2010)
New Revision: 11878

Modified:
   trunk/src/common/widget/Widget_MyProjects.class.php
Log:
cleanup code

Modified: trunk/src/common/widget/Widget_MyProjects.class.php
===================================================================
--- trunk/src/common/widget/Widget_MyProjects.class.php	2010-12-22 14:08:56 UTC (rev 11877)
+++ trunk/src/common/widget/Widget_MyProjects.class.php	2010-12-22 14:12:17 UTC (rev 11878)
@@ -1,6 +1,7 @@
 <?php
 /**
  * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
+ * Copyright 2010, Franck Villaume - Capgemini
  *
  * This file is a part of Codendi.
  *
@@ -27,110 +28,107 @@
 * PROJECT LIST
 */
 class Widget_MyProjects extends Widget {
-    function Widget_MyProjects() {
-        $this->Widget('myprojects');
-    }
-    function getTitle() {
-        return _("My Projects");
-    }
-    function getContent() {
-        $html_my_projects = '';
+	function Widget_MyProjects() {
+		$this->Widget('myprojects');
+	}
+	function getTitle() {
+		return _("My Projects");
+	}
 
-	$user = session_get_user () ;
-	$groups = $user->getGroups() ;
-	sortProjectList ($groups) ;
-	$roles = RBACEngine::getInstance()->getAvailableRolesForUser ($user) ;
-	sortRoleList ($roles) ;
+	function getContent() {
+		global $HTML;
+		$html_my_projects = '';
 
-	if (count ($groups) < 1) {
-		$html_my_projects .= _("You're not a member of any project");
-        } else {
-		$html_my_projects .= '<table style="width:100%">';
-		$i = 0 ;
-		foreach ($groups as $g) {
-			$i++ ;
-			if ($i % 2 == 0) {
-				$class="bgcolor-white";
-			}
-			else {
-				$class="bgcolor-grey";
-			}
-			
-			$html_my_projects .= '
-			<TR class="'. $class .'"><TD WIDTH="99%">'.
-				'<A href="/projects/'. $g->getUnixName() .'/">'.
-				$g->getPublicName().'</A>';
-			
-			$isadmin = false ;
-			$role_names = array () ;
-			foreach ($roles as $r) {
-				if ($r instanceof RoleExplicit
-				    && $r->getHomeProject() != NULL
-				    && $r->getHomeProject()->getID() == $g->getID()) {
-					$role_names[] = $r->getName() ;
-					if ($r->hasPermission ('project_admin', $g->getID())) {
-						$isadmin = true ;
+		$user = session_get_user();
+		$groups = $user->getGroups();
+		sortProjectList($groups);
+		$roles = RBACEngine::getInstance()->getAvailableRolesForUser($user);
+		sortRoleList ($roles) ;
+
+		if (count ($groups) < 1) {
+			$html_my_projects .= '<div class="warning">'. _("You're not a member of any project") .'</div>';
+		} else {
+			$html_my_projects .= '<table style="width:100%">';
+			$i = 0;
+			foreach ($groups as $g) {
+				$i++;
+				$html_my_projects .= '
+				<TR '. $HTML->boxGetAltRowStyle($i) .'"><TD WIDTH="99%">'.
+					'<A href="/projects/'. $g->getUnixName() .'/">'.
+					$g->getPublicName().'</A>';
+
+				$isadmin = false;
+				$role_names = array();
+				foreach ($roles as $r) {
+					if ($r instanceof RoleExplicit
+					    && $r->getHomeProject() != NULL
+					    && $r->getHomeProject()->getID() == $g->getID()) {
+						$role_names[] = $r->getName();
+						if ($r->hasPermission('project_admin', $g->getID())) {
+							$isadmin = true;
+						}
 					}
 				}
+				if ($isadmin) {
+					$html_my_projects .= ' <small><A HREF="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</A></small>';
+				}
+				$html_my_projects .= ' <small>('.htmlspecialchars (implode (', ', $role_names)).')</small>';
+				if (!$g->isPublic()) {
+					$html_my_projects .= ' (*)';
+					$private_shown = true;
+				}
+				if (!$isadmin) {
+					$html_my_projects .= '</TD>'.
+						'<td><A href="rmproject.php?group_id='. $g->getID().
+						'" onClick="return confirm(\''._("Quit this project?").'\')">'.
+						'<IMG SRC="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" HEIGHT="16" WIDTH="16" BORDER="0"></A></TD></TR>';
+				} else {
+					$html_my_projects .= '</td><td>&nbsp;</td></TR>';
+				}
 			}
-			if ($isadmin) {
-				$html_my_projects .= ' <small><A HREF="/project/admin/?group_id='.$g->getID().'">['._("Admin").']</A></small>';
+
+			if (isset($private_shown) && $private_shown) {
+				$html_my_projects .= '
+				    <TR '. $HTML->boxGetAltRowStyle($i) .'"><TD colspan="2" class="small">'.
+					'(*)&nbsp;'._("<em>Private project</em>").'</td></tr>';
 			}
-			$html_my_projects .= ' <small>('.htmlspecialchars (implode (', ', $role_names)).')</small>';
-			if (!$g->isPublic()) {
-				$html_my_projects .= ' (*)';
-				$private_shown = true;
-			}
-			if (!$isadmin) {
-				$html_my_projects .= '</TD>'.
-					'<td><A href="rmproject.php?group_id='. $g->getID().
-					'" onClick="return confirm(\''._("Quit this project?").'\')">'.
-					'<IMG SRC="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" HEIGHT="16" WIDTH="16" BORDER="0"></A></TD></TR>';
-			} else {
-				$html_my_projects .= '</td><td>&nbsp;</td></TR>';
-			}
+			$html_my_projects .= '</table>';
 		}
-		
-		if (isset($private_shown) && $private_shown) {
-			$html_my_projects .= '
-			    <TR class="'.$class .'"><TD colspan="2" class="small">'.
-				'(*)&nbsp;'._("<em>Private project</em>").'</td></tr>';
-		}
-		$html_my_projects .= '</table>';
+		return $html_my_projects;
 	}
-	return $html_my_projects;
-    }
-    function hasRss() {
-	    return true;
-    }
-    function displayRss() {
-	    $rss = new RSS(array(
-            		'title'       => forge_get_config('forge_name').' - MyProjects',
-				    'description' => 'My projects',
-				    'link'        => get_server_url(),
-				    'language'    => 'en-us',
-				    'copyright'   => 'Copyright Xerox',
-				    'pubDate'     => gmdate('D, d M Y G:i:s',time()).' GMT',
-				));
-	    $projects = UserManager::instance()->getCurrentUser()->getGroups() ;
-	    sortProjectList ($projects) ;
 
-	    if (!$result || $rows < 1) {
-		    $rss->addItem(array(
+	function hasRss() {
+		return true;
+	}
+
+	function displayRss() {
+		$rss = new RSS(array(
+				'title'       => forge_get_config('forge_name').' - MyProjects',
+				'description' => 'My projects',
+				'link'        => get_server_url(),
+				'language'    => 'en-us',
+				'copyright'   => 'Copyright Xerox',
+				'pubDate'     => gmdate('D, d M Y G:i:s',time()).' GMT',
+			));
+		$projects = UserManager::instance()->getCurrentUser()->getGroups();
+		sortProjectList($projects);
+
+		if (!$result || $rows < 1) {
+			$rss->addItem(array(
 					  'title'       => 'Error',
 					  'description' => _("You're not a member of any project") . db_error(),
 					  'link'        => util_make_url()
-					  ));
-		    $rss->display();
-		    return ;
-	    } 
+				  ));
+			$rss->display();
+			return ;
+		}
 
-	    foreach ($projects as $project) {
-		    $pid = $project->getID() ;
-		    $title = $project->getPublicName() ;
-		    $url = util_make_url('/projects/' . $project->getUnixName()) ;
+		foreach ($projects as $project) {
+			$pid = $project->getID();
+			$title = $project->getPublicName();
+			$url = util_make_url('/projects/' . $project->getUnixName());
 
-		    if ( !RoleAnonymous::getInstance()->hasPermission('project_read',$pid)) {
+			if ( !RoleAnonymous::getInstance()->hasPermission('project_read',$pid)) {
 			    $title .= ' (*)';
 		    }
 		    
@@ -143,12 +141,13 @@
 					  'title'       => $title,
 					  'description' => $desc,
 					  'link'        => $url)
-			    );
-	    }
-    }
-    function getDescription() {
-	    return _("List the projects you belong to. Selecting any of these projects brings you to the corresponding Project Summary page.");
-    }
+				);
+		}
+	}
+
+	function getDescription() {
+		return _("List the projects you belong to. Selecting any of these projects brings you to the corresponding Project Summary page.");
+	}
 }
 
 // Local Variables:




More information about the Fusionforge-commits mailing list