function display()
    {
        if ($this->is_submitted() && $this->get_reason() == '') {
            $reason_is_mandatory = get_lang('ReasonIsMandatory');
            Display::display_error_message($reason_is_mandatory);
        }
        $status_request_message = get_lang('StatusRequestMessage');
        $label_new_status = get_lang('NewStatus');
        $label_reason = get_lang('Reason');
        $label_ok = get_lang('Ok');
        $label_cancel = get_lang('Cancel');
        $user = Shibboleth::session()->user();
        $items = array();
        if ($user['status'] == Shibboleth::UNKNOWN_STATUS) {
            $items[Shibboleth::STUDENT_STATUS] = get_lang('Student');
        }
        $items[Shibboleth::TEACHER_STATUS] = get_lang('Teacher');
        $status_options = '';
        foreach ($items as $key => $value) {
            $status_options .= "<option value=\"{$key}\">{$value}</option>";
        }
        return <<<EOT
            <div id="askAccountText">
                <p>{$status_request_message}</p>
            </div>
            <form method="post" action="request.php" id="status_request_form">
    
                <input type="hidden" name="formPosted" value="true"/>
    
            <label for="status">{$label_new_status}:</label>
            <select name="status">
                    {$status_options}
            </select>
            <label for="reason">{$label_reason}:</label>
            <textarea name="reason" style="min-width:400px; min-height:100px;"></textarea>
            <p><input name="submit" type="submit" value="{$label_ok}" style="margin-right:10px;"/><input name="cancel" type="submit" value="{$label_cancel}" /></p>
            </form>
EOT;
    }
    /**
     * Display the request new status page to administrator for new users.
     */
    public function request_status()
    {
        /*
         * That may happen if a user visit that url again.
         */
        if (!Shibboleth::session()->is_logged_in()) {
            Shibboleth::redirect();
        }
        $user = Shibboleth::session()->user();
        if ($user['status'] == Shibboleth::TEACHER_STATUS) {
            //Maximum user right is reached.
            Shibboleth::redirect();
        }
        $form = ShibbolethStatusRequestForm::instance();
        if ($form->cancelled()) {
            Shibboleth::redirect();
        }
        if ($reason = $form->get_reason()) {
            $subject = get_lang('request_status');
            $status = $form->get_status();
            $status = Shibboleth::format_status($status);
            $message = <<<EOT
New status: {$status}

Reason:
{$reason}
EOT;
            $success = Shibboleth::email_admin($subject, $message);
            if ($success) {
                $request_submitted = get_lang('request_submitted');
                Shibboleth::display()->message_page($request_submitted);
            } else {
                $request_failed = get_lang('request_failed');
                Shibboleth::display()->error_page($request_failed);
            }
        }
        $title = get_lang('request_status');
        Display::display_header($title);
        echo $form->display();
        Display::display_footer();
    }
    /**
     * Sends an email to the Chamilo and Shibboleth administrators in the name
     * of the logged-in user.
     *
     */
    public static function email_admin($subject, $message)
    {
        $user = Shibboleth::session()->user();
        $firstname = $user['firstname'];
        $lastname = $user['lastname'];
        $email = $user['email'];
        $status = $user['status'];
        $status = self::format_status($status);
        $signagure = <<<EOT

_________________________ 
{$firstname} {$lastname} 
{$email} 
{$status}
EOT;
        $message .= $signagure;
        $header = "From: {$email} \n";
        $shibb_admin_email = Shibboleth::config()->admnistrator_email;
        if ($shibb_admin_email) {
            $header .= "Cc: {$shibb_admin_email}";
        }
        $administrator_email = get_setting('emailAdministrator');
        $result = mail($administrator_email, $subject, $message);
        return (bool) $result;
    }