Beispiel #1
0
function strongCheckId($subState)
{
    $subState->set('xorgid', Profile::getXorgId($subState->i('schoolid')));
    if (!$subState->v('xorgid')) {
        return 'Le matricule est incorrect.';
    }
    $uf = new UserFilter(new PFC_And(new UFC_SchoolId('xorg', $subState->i('xorgid')), new PFC_Not(new UFC_Dead()), new PFC_Not(new UFC_Registered(true))));
    $profile = $uf->getProfile();
    if (is_null($profile)) {
        $max_promo_year = XDB::fetchOneCell("SELECT  MAX(promo_year)\n                                               FROM  profile_education\n                                              WHERE  FIND_IN_SET(flags, 'primary')\n                                                     AND eduid = (\n                                                         SELECT  id\n                                                         FROM    profile_education_enum\n                                                         WHERE   abbreviation='X'\n                                                     )\n                                                     AND degreeid = (\n                                                         SELECT  id\n                                                         FROM    profile_education_degree_enum\n                                                         WHERE   abbreviation = 'Ing.'\n                                                     )");
        if ($subState->i('yearpromo') > $max_promo_year) {
            return "Ta promo n'est pas encore dans l'annuaire, réessaie dans quelques semaines.";
        }
        return "Cherche ton nom dans l'annuaire public. Si tu te trouves, tu es déjà inscrit ou ton matricule est incorrect ! Sinon envoie-nous un email à support@polytechnique.org";
    }
    if ($profile->promo() != $subState->s('promo')) {
        return 'Le matricule est incorrect.';
    }
    if (!$profile->compareNames($subState->s('firstname'), $subState->s('lastname'))) {
        return "Erreur dans l'identification. Réessaie, il y a une erreur quelque part !";
    }
    $subState->set('lastname', $profile->lastName());
    $subState->set('firstname', $profile->firstName());
    $subState->set('uid', $profile->owner()->id());
    $subState->set('watch', $profile->owner()->watch);
    $subState->set('comment', $profile->owner()->comment);
    $subState->set('birthdateRef', $profile->__get('birthdate_ref'));
    return true;
}