/**
  * Log user in with Shibboleth authentication
  */
 function login()
 {
     if (Shibboleth::session()->is_logged_in()) {
         Redirect::home();
     }
     $user = Shibboleth::store()->get_user();
     if ($user->is_empty()) {
         $message = get_lang('no_login');
         Shibboleth::display()->error_page($message);
     }
     $is_new_user = !User::store()->shibboleth_id_exists($user->unique_id);
     if ($is_new_user && empty($user->email) && Shibboleth::config()->is_email_mandatory) {
         $form = ShibbolethEmailForm::instance();
         if ($email = $form->get_email()) {
             $user->email = $email;
         } else {
             $content = $form->display();
             Shibboleth::display()->page($content);
         }
     }
     Shibboleth::save($user);
     $chamilo_user = User::store()->get_by_shibboleth_id($user->unique_id);
     Shibboleth::session()->login($chamilo_user->user_id);
     if ($is_new_user && $user->status_request) {
         Shibboleth::redirect('/main/auth/shibboleth/app/view/request.php');
     } else {
         Shibboleth::redirect();
     }
 }
    /**
     * 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;
    }