This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
accm-website/includes/users/MemberListFormatter.inc.php
2010-08-14 22:32:09 +02:00

51 lines
1.4 KiB
PHP

<?php
include_once './includes/users/Member.inc.php';
include_once './includes/users/MemberLister.inc.php';
/**
* This class allows for easy formatting of complete lists of members.
*
* @author Thomas Schwery <thomas.schwery@epfl.ch>
*/
class MemberListFormatter {
/**
* Returns a select entries list containing the users for use in forms.
*
* @param string $inputName
* @param string $selectedUsername
* @return string
*/
public static function getSelectMembers($inputName, $selectedUsername) {
$usersArray = MemberLister::getAllMembers();
$content = '<select name="'.$inputName.'">';
foreach ($usersArray as $user) {
$username = $user->getUsername();
$fullName = $user->getFullname();
if ($username == $selectedUsername) {
$selected = "selected='selected'";
} else {
$selected = "";
}
$content .= '<option value="' . $username . '" ' . $selected . '>' . $fullName . '</option>';
}
$labelEmpty = Localization::generalDelete;
if ($selectedUsername == "delete") {
$content .= '<option value="delete" selected="selected">'.$labelEmpty.'</option>';
} else {
$content .= '<option value="delete">'.$labelEmpty.'</option>';
}
$content .= "</select>";
return $content;
}
}
?>