<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
// {{{ function checkId
-function checkId(&$subState)
+function checkId($subState)
{
$subState->set('xorgid', Profile::getXorgId($subState->i('schoolid')));
if (!$subState->v('xorgid')) {
// }}}
// {{{ function checkOldId
-function checkOldId(&$subState)
+function checkOldId($subState)
{
$uf = new UserFilter(new PFC_And(
new PFC_Not(new UFC_Dead()),
// }}}
// {{{ function checkNewUser
-function checkNewUser(&$subState)
+function checkNewUser($subState)
{
$firstname = preg_replace("/[ \t]+/", ' ', $subState->t('firstname'));
$firstname = preg_replace("/--+/", '-', $firstname);
// }}}
// {{{ function createAliases
-function createAliases(&$subState)
+function createAliases($subState)
{
global $globals;
. "<a href=\"mailto:support@{$globals->mail->domain}\">support@{$globals->mail->domain}</a>.";
}
- $res = XDB::query('SELECT uid, type, expire
- FROM aliases
- WHERE alias = {?}', $emailXorg);
- if ($res->numRows()) {
+ $count = XDB::numRows('SELECT *
+ FROM email_source_account AS s
+ INNER JOIN email_virtual_domains AS d ON (s.domain = d.id)
+ WHERE s.email = {?} AND d.name = {?}',
+ $emailXorg, $globals->mail->domain);
+ if ($count) {
list($h_id, $h_type, $expire) = $res->fetchOneRow();
if ($h_type != 'homonyme' and empty($expire)) {
- XDB::execute('UPDATE aliases
- SET expire = ADDDATE(NOW(), INTERVAL 1 MONTH)
- WHERE alias = {?}', $emailXorg);
- XDB::execute('INSERT IGNORE INTO homonyms (homonyme_id, uid)
+ XDB::execute('UPDATE email_source_account AS e
+ INNER JOIN email_virtual_domains AS d ON (e.domain = d.id)
+ SET e.expire = ADDDATE(NOW(), INTERVAL 1 MONTH)
+ WHERE e.email = {?} AND d.name = {?}',
+ $emailXorg, $globals->mail->domain);
+ $hrmid = 'h.' . $emailXorg . '.' . $globals->mail->domain;
+ XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid)
VALUES ({?}, {?}), ({?}, {?})',
- $subState->i('uid'), $h_id, $h_id, $subState->i('uid'));
- $res = XDB::query('SELECT alias
- FROM aliases
- WHERE uid = {?} AND expire IS NULL', $h_id);
- $als = $res->fetchColumn();
+ $hrmid, $h_id, $hrmid, $subState->i('uid'));
+ $als = XDB::fetchColumn('SELECT *
+ FROM email_source_account AS s
+ INNER JOIN email_virtual_domains AS d ON (s.domain = d.id)
+ WHERE s.uid = {?} AND d.name = {?} AND s.expire IS NULL',
+ $h_id, $globals->mail->domain);
$mailer = new PlMailer('register/lostalias.mail.tpl');
$mailer->addTo($emailXorg . '@' . $globals->mail->domain);
global $globals;
$hash = rand_url_id(12);
- XDB::execute('INSERT IGNORE INTO register_pending (uid, forlife, bestalias, mailorg2, password,
- email, date, relance, naissance, hash, services)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO register_pending (uid, forlife, bestalias, mailorg2, password,
+ email, date, relance, naissance, hash, services)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE password=VALUES(password), email=VALUES(email),
+ date=VALUES(date), naissance=VALUES(naissance),
+ hash=VALUES(hash), services=VALUES(services)',
$subState->i('uid'), $subState->s('forlife'), $subState->s('bestalias'),
$subState->s('emailXorg2'), $subState->s('password'), $subState->s('email'),
$subState->s('birthdate'), $hash, implode(',', $subState->v('services')));