<?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 *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'validations.inc.php';
// {{{ class HomonymeReq
class HomonymeReq extends Validate
// }}}
// {{{ constructor
- public function __construct(User &$_user, $_loginbis, $_homonymes_hruid, $warning=true)
+ public function __construct(User $_user, $_loginbis, $_homonymes_hruid, $warning=true)
{
$this->warning = $warning;
public function commit()
{
Platal::load('admin', 'homonyms.inc.php');
- switch_bestalias($this->user, $this->loginbis);
if (!$this->warning) {
- XDB::execute("UPDATE aliases SET type = 'homonyme', expire = NOW() WHERE alias = {?}", $this->loginbis);
- XDB::execute("REPLACE INTO homonyms (homonyme_id, uid) VALUES({?}, {?})", $this->user->id(), $this->user->id());
+ global $globals;
+ require_once 'emails.inc.php';
+
+ XDB::execute('DELETE e
+ FROM email_source_account AS e
+ INNER JOIN email_virtual_domains AS d ON (e.domain = d.id)
+ WHERE e.email = {?} AND d.name = {?}',
+ $this->loginbis, $globals->mail->domain);
+ XDB::execute('INSERT INTO email_source_other (hrmid, email, domain, type, expire)
+ SELECT CONCAT(\'h.\', {?}, \'.\', {?}), {?}, id, \'homonym\', NOW()
+ FROM email_virtual_domains
+ WHERE name = {?}',
+ $this->loginbis, $globals->mail->domain, $this->loginbis, $globals->mail->domain);
+ XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid)
+ VALUES ({?}, {?})',
+ 'h.' . $this->loginbis . '.' . $globals->mail->domain, $this->user->id());
+ fix_bestalias($this->user);
}
return true;