[Fusionforge-commits] r10706 - trunk/src/www/admin

Roland Mas lolando at libremir.placard.fr.eu.org
Sat Sep 25 21:57:43 CEST 2010


Author: lolando
Date: 2010-09-25 21:57:43 +0200 (Sat, 25 Sep 2010)
New Revision: 10706

Modified:
   trunk/src/www/admin/useredit.php
   trunk/src/www/admin/userlist.php
Log:
Less SQL, and less user_group

Modified: trunk/src/www/admin/useredit.php
===================================================================
--- trunk/src/www/admin/useredit.php	2010-09-25 19:35:51 UTC (rev 10705)
+++ trunk/src/www/admin/useredit.php	2010-09-25 19:57:43 UTC (rev 10706)
@@ -225,17 +225,8 @@
 /*
 	Iterate and show projects this user is in
 */
-$res_cat = db_query_params ('
-	SELECT groups.unix_group_name, groups.group_name AS group_name, 
-		groups.group_id AS group_id, 
-		user_group.admin_flags AS admin_flags
-	FROM groups,user_group
-	WHERE user_group.user_id=$1
-	AND groups.group_id=user_group.group_id
-',
-			array($user_id)) ;
+$projects = $u->getGroups() ;
 
-
 $title=array();
 $title[]=_('Name');
 $title[]=_('Unix name');
@@ -243,14 +234,12 @@
 echo $GLOBALS['HTML']->listTableTop($title);
 
 $i = 0 ;
-while ($row_cat = db_fetch_array($res_cat)) {
-
-	$row_cat['group_name'] = htmlspecialchars($row_cat['group_name']);
+foreach ($projects as $p) {
 	print '
 		<tr '.$GLOBALS['HTML']->boxGetAltRowStyle($i++).'>
-		<td>'.util_unconvert_htmlspecialchars($row_cat['group_name']).'</td>
-		<td>'.$row_cat['unix_group_name'].'</td>
-		<td width="40%">'.util_make_link ('/project/admin/?group_id='.$row_cat['group_id'],_('[Project Admin]')).'</td>
+		<td>'.util_unconvert_htmlspecialchars(htmlspecialchars($p->getPublicName())).'</td>
+		<td>'.$p->getUnixName().'</td>
+		<td width="40%">'.util_make_link ('/project/admin/?group_id='.$p->getID(),_('[Project Admin]')).'</td>
 		</tr>
 	';
 

Modified: trunk/src/www/admin/userlist.php
===================================================================
--- trunk/src/www/admin/userlist.php	2010-09-25 19:35:51 UTC (rev 10705)
+++ trunk/src/www/admin/userlist.php	2010-09-25 19:57:43 UTC (rev 10706)
@@ -61,7 +61,7 @@
 	echo "<div class='feedback'>" .sprintf(_('User updated to %1$s status'), $statusString)."</div>";
 }
 
-function show_users_list ($result) {
+function show_users_list ($users) {
 	echo '<p>' ._('Key') .':
 		<span class="active">'._('Active'). '</span>
 		<span class="deleted">' ._('Deleted') .'</span>
@@ -89,23 +89,23 @@
 	echo $GLOBALS['HTML']->listTableTop($headers, $headerLinks);
 
 	$count = 0;
-	while ($usr = db_fetch_array($result)) {
+	foreach ($users as $u) {
 		print '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($count) . '><td class="';
-		if ($usr['status'] == 'A') print "active";
-		if ($usr['status'] == 'D') print "deleted";
-		if ($usr['status'] == 'S') print "suspended";
-		if ($usr['status'] == 'P') print "pending";
-		print '"><a href="useredit.php?user_id='.$usr['user_id'].'">';
-		if ($usr['status'] == 'P') print "*";
-		echo $usr['firstname'].' '.$usr['lastname'].' ('.$usr['user_name'].')</a>';
+		if ($u->getStatus() == 'A') print "active";
+		if ($u->getStatus() == 'D') print "deleted";
+		if ($u->getStatus() == 'S') print "suspended";
+		if ($u->getStatus() == 'P') print "pending";
+		print '"><a href="useredit.php?user_id='.$u->getID().'">';
+		if ($u->getStatus() == 'P') print "*";
+		echo $u->getRealName().' ('.$u->getUnixName().')</a>';
 		echo '</td>';
 		echo '<td width="15%" style="text-align:center">';
-		echo ($usr['add_date'] ? date(_('Y-m-d H:i'), $usr['add_date']) : '-');
+		echo ($u->getAddDate() ? date(_('Y-m-d H:i'), $u->getAddDate()) : '-');
 		echo '</td>';
-		echo '<td width="15%" style="text-align:center">'.util_make_link ('/developer/?form_dev='.$usr['user_id'],_('[DevProfile]')).'</td>';
-		echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=activate&amp;user_id='.$usr['user_id'],_('[Activate]')).'</td>';
-		echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=delete&amp;user_id='.$usr['user_id'],_('[Delete]')).'</td>';
-		echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=suspend&amp;user_id='.$usr['user_id'],_('[Suspend]')).'</td>';
+		echo '<td width="15%" style="text-align:center">'.util_make_link ('/developer/?form_dev='.$u->getID(),_('[DevProfile]')).'</td>';
+		echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=activate&amp;user_id='.$u->getID(),_('[Activate]')).'</td>';
+		echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=delete&amp;user_id='.$u->getID(),_('[Delete]')).'</td>';
+		echo '<td width="15%" style="text-align:center">'.util_make_link ('/admin/userlist.php?action=suspend&amp;user_id='.$u->getID(),_('[Suspend]')).'</td>';
 		echo '</tr>';
 		$count ++;
 	}
@@ -143,26 +143,24 @@
 	print "\n</p>";
 
 	if ($user_name_search) {
-		$result = db_query_params ('SELECT user_name,lastname,firstname,user_id,status,add_date FROM users WHERE lower(user_name) LIKE $1 OR lower(lastname) LIKE $1 ORDER BY realname',
+		$res = db_query_params ('SELECT user_id FROM users WHERE lower(user_name) LIKE $1 OR lower(lastname) LIKE $1 ORDER BY realname',
 					   array (strtolower("$user_name_search%")));
 	} else {
 		$sortorder = getStringFromRequest('sortorder', 'realname');
-		$result = db_query_params('SELECT user_name,lastname,firstname,user_id,status,add_date FROM users ORDER BY $1', array($sortorder));
+		util_ensure_value_in_set ($sortorder,
+					  array('realname','user_name','lastname','firstname','user_id','status','add_date')) ;
+		$res = db_query_params('SELECT user_id FROM users ORDER BY '.$sortorder,
+					  array ());
 	}
-	show_users_list ($result);
+	show_users_list (user_get_objects(util_result_column_to_array($res,0)));
 } else {
 	/*
 		Show list for one group
 	*/
-	print "<strong>" . group_getname($group_id) . "</strong></p>";
+	$project = group_get_object($group_id) ;
+	print "<strong>" . $project->getPublicName() . "</strong></p>";
 
-
-	$result = db_query_params ('SELECT users.user_id AS user_id,users.user_name AS user_name,users.status AS status, users.add_date AS add_date 
-FROM users,user_group 
-WHERE users.user_id=user_group.user_id AND 
-user_group.group_id=$1 ORDER BY users.user_name',
-			array($group_id));
-	show_users_list ($result);
+	show_users_list ($project->getUsers());
 }
 
 $HTML->footer(array());




More information about the Fusionforge-commits mailing list