<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
$email = str_replace(' ', '+', $email);
// Apply email redirection change requests.
+ $result = SUCCESS;
if ($action == 'remove' && $email) {
- $retour = $redirect->delete_email($email);
- $page->assign('retour', $retour);
+ $result = $redirect->delete_email($email);
}
if ($action == 'active' && $email) {
$actifs = Env::v('emails_actifs', Array());
print_r(Env::v('emails_rewrite'));
if (Env::v('emailop') == "ajouter" && Env::has('email')) {
- $page->assign('retour', $redirect->add_email(Env::v('email')));
+ $result = $redirect->add_email(Env::v('email'));
} elseif (empty($actifs)) {
- $page->assign('retour', ERROR_INACTIVE_REDIRECTION);
+ $result = ERROR_INACTIVE_REDIRECTION;
} elseif (is_array($actifs)) {
- $page->assign('retour', $redirect->modify_email($actifs,
- Env::v('emails_rewrite',Array())));
+ $result = $redirect->modify_email($actifs, Env::v('emails_rewrite', Array()));
}
}
+ switch ($result) {
+ case ERROR_INACTIVE_REDIRECTION:
+ $page->trigError('Tu ne peux pas avoir aucune adresse de redirection active, sinon ton adresse '
+ . $user->forlifeEmail() . ' ne fonctionnerait plus.');
+ break;
+ case ERROR_INVALID_EMAIL:
+ $page->trigError('Erreur: l\'email n\'est pas valide.');
+ break;
+ case ERROR_LOOP_EMAIL:
+ $page->trigError('Erreur : ' . $user->forlifeEmail()
+ . ' ne doit pas être renvoyé vers lui-même, ni vers son équivalent en '
+ . $globals->mail->domain2 . ' ni vers polytechnique.edu.');
+ break;
+ }
+
// Fetch the @alias_dom email alias, if any.
$res = XDB::query(
"SELECT alias