<?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 *
public $broken;
public $disabled;
public $rewrite;
+ public $allow_rewrite;
+ public $hash;
// Redirection bounces stats.
public $panne;
$this->user = &$user;
$this->sufficient = true;
- list($this->email, $flags, $this->rewrite, $this->panne, $this->last, $this->panne_level) = $row;
+ list($this->email, $flags, $this->rewrite, $this->allow_rewrite, $this->hash, $this->panne, $this->last, $this->panne_level) = $row;
$this->display_email = $this->email;
$this->active = ($flags == 'active');
$this->broken = ($flags == 'panne');
}
XDB::execute('UPDATE emails SET rewrite = {?} WHERE uid = {?} AND email = {?}', $rewrite, $this->user->id(), $this->email);
$this->rewrite = $rewrite;
+ if (!$this->allow_rewrite) {
+ global $globals;
+ if (empty($this->hash)) {
+ $this->hash = rand_url_id();
+ XDB::execute("UPDATE emails
+ SET hash = {?}
+ WHERE uid = {?} AND email = {?}", $this->hash, $this->user->id(), $this->email);
+ }
+ $mail = new PlMailer('emails/rewrite-in.mail.tpl');
+ $mail->assign('mail', $this);
+ $mail->assign('user', $this->user);
+ $mail->assign('baseurl', $globals->baseurl);
+ $mail->assign('sitename', $globals->core->sitename);
+ $mail->assign('to', $this->email);
+ $mail->send($this->user->isEmailFormatHtml());
+ }
return;
}
// Retrieves the current list of actives storages.
private function get_storages()
{
- $res = XDB::query("SELECT mail_storage
- FROM auth_user_md5
- WHERE user_id = {?}", $this->user->id());
- return new PlFlagSet($res->fetchOneCell());
+ return new PlFlagSet(XDB::fetchOneCell('SELECT storage
+ FROM email_options
+ WHERE uid = {?}',
+ $this->user->id()));
}
// Updates the list of active storages.
private function set_storages($storages)
{
- XDB::execute("UPDATE auth_user_md5
- SET mail_storage = {?}
- WHERE user_id = {?}", $storages, $this->user->id());
+ XDB::execute("UPDATE email_options
+ SET storage = {?}
+ WHERE uid = {?}", $storages, $this->user->id());
}
// Returns the list of allowed storages for the @p user.
$this->bogo = new Bogo($user);
// Adds third-party email redirections.
- $res = XDB::iterRow("SELECT email, flags, rewrite, panne, last, panne_level
+ $res = XDB::iterRow("SELECT email, flags, rewrite, allow_rewrite, hash, panne, last, panne_level
FROM emails
WHERE uid = {?} AND flags != 'filter'", $user->id());
$this->emails = Array();
return SUCCESS;
}
}
- $this->emails[] = new EmailRedirection($this->user, array($email, 'active', '', '0000-00-00', '0000-00-00', 0));
+ $this->emails[] = new EmailRedirection($this->user, array($email, 'active', '', 0, null, '0000-00-00', '0000-00-00', 0));
// security stuff
check_email($email, "Ajout d'une adresse surveillée aux redirections de " . $this->user->login());