<?php

include_once './modules/ModuleInterface.inc.php';
include_once './includes/users/MemberLister.inc.php';
include_once './includes/users/Member.inc.php';

/**
 * This class represent the UserBox module.
 *
 * @author Thomas Schwery <thomas.schwery@epfl.ch>
 */
class UserModule implements ModuleInterface {

    public function __construct($moduleId) {
        ;
    }

    public function getContent() {
        $content = "";

        if (key_exists('loggedin', $_SESSION) && $_SESSION['loggedin'] == true) {

            $username = $_SESSION['username'];

            $user = MemberLister::getByLogin($username);
            $fullName = $user->getFullName();

            $logoutLabel = Localization::userLogout;

            $content.= Localization::userLoggedAs . " " . $fullName . "<br>";
            $content.= "<a href=./?page=CentralAdministration>Administration</a><br>";
            $content.= "<a href=./?page=Login&type=logout>$logoutLabel</a>";
        }

        return $content;
    }

    public function getTitle() {
        if (key_exists('loggedin', $_SESSION) && $_SESSION['loggedin'] == true) {
            return Localization::userBox;
        }
    }
}
?>
