- set_alias_names($this->sn_new, $this->sn_old, $this->profile->id(),
- $this->profileOwner, true, $this->new_alias);
+ if (!is_null($this->old_alias)) {
+ XDB::execute('DELETE FROM email_source_account
+ WHERE FIND_IN_SET(\'usage\', flags) AND uid = {?} AND type = \'alias\'',
+ $this->profileOwner->id());
+ }
+ if (!is_null($this->new_alias)) {
+ XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain)
+ SELECT {?}, {?}, \'alias\', \'usage\', id
+ FROM email_virtual_domains
+ WHERE name = {?}',
+ $this->new_alias, $this->profileOwner->id(), $this->profileOwner->mainEmailDomain());
+ }
+ require_once 'emails.inc.php';
+ fix_bestalias($this->profileOwner);