I got really annoyed with the membership page for groups. The list was in seemingly random order and it make finding a particular member a bit of a pain. Plus I like things sorted.
I basically copied a an existing function and modified it to do what I wanted, then made the calling page use the new function. This way I didn’t step on anything FOG was doing elsewhere. I’m pretty sure now that I could have just modified the original function, but I haven’t had the time to verify.
First, you’ll want to make a copy of the original file before modifying it.
[CODE]
sudo cp /var/www/fog/commons/functions.include.php /var/www/fog/commons/functions.include.BACKUP.php
[/CODE]
Then open up the /var/www/fog/commons/functions.include.php and go to line 1425. This should be the end of the function getImageMembersByGroupID.
Make a few blank lines below the end of the function and paste in the following.
[CODE]
function getImageMembersByGroupIDSorted( $conn, $groupID )
{
$arM = array();
if ( $conn != null && $groupID != null )
{
$sql = “SELECT
groupMembers.gmHostID
FROM
groups inner join groupMembers
on (groups.groupID = groupMembers.gmGroupID)
inner join hosts
on (hosts.hostID = gmHostID)
WHERE groups.groupID = $groupID
ORDER BY hosts.hostName”;
$res = mysql_query( $sql, $conn ) or criticalError( mysql_error(), _("FOG :: Database error!") );
$arHosts = array();
while( $ar = mysql_fetch_array( $res ) )
{
$arHosts[] = $ar["gmHostID"];
}
for( $i = 0; $i < count( $arHosts ); $i++ )
{
$tmpMember = getImageMemberFromHostID( $conn, $arHosts[$i] );
if( $tmpMember != null )
$arM[] = $tmpMember;
}
}
return $arM;
}
[/CODE]
Save the file.
Now to edit the file that uses this function.
Make a backup of the file, just in case.
[CODE] sudo cp /var/www/fog/management/includes/groups.edit.include.php /var/www/fog/management/includes/groups.edit.include.BACKUP.php[/CODE]
Now open the file for editing.
[CODE]
sudo nano -w /var/www/fog/management/includes/groups.edit.include.php
[/CODE]
On or near line 641, you’ll be inside the if ( $_GET[“tab”] == “member” ) block. Change the function call to your new function name.
Original line:
[CODE]$members = getImageMembersByGroupID( $conn, $ar[“groupID”] );[/CODE]
Modified line:
[CODE]$members = getImageMembersByGroupIDSorted( $conn, $ar[“groupID”] );[/CODE]
Save the file. Now membership listing should display sorted by hostname.