Example #1
0
function fix_homonym(PlUser $user, $email)
{
    XDB::execute('DELETE FROM  email_source_account
                        WHERE  email = {?} AND type = \'alias\'', $email);
    $hrmid = User::makeHomonymHrmid($email);
    // TODO: insert twice into source_other if different domains
    XDB::execute('INSERT INTO  email_source_other (hrmid, email, domain, type, expire)
                       SELECT  {?}, {?}, id, \'homonym\', NOW()
                         FROM  email_virtual_domains
                        WHERE  name = {?}', $hrmid, $email, $user->mainEmailDomain());
    XDB::execute("INSERT INTO  email_redirect_other (hrmid, redirect, type, action)\n                       VALUES  ({?}, '', 'homonym', 'homonym')", $hrmid);
    require_once 'emails.inc.php';
    fix_bestalias($user);
}
Example #2
0
function createAliases($subState)
{
    global $globals;
    $res = XDB::query("SELECT  hruid, state, type\n                         FROM  accounts\n                        WHERE  uid = {?} AND hruid != ''", $subState->i('uid'));
    if ($res->numRows() == 0) {
        return "Tu n'as pas d'adresse à vie pré-attribuée.<br />" . "Envoie un mail à <a href=\"mailto:support@{$globals->mail->domain}\">" . "support@{$globals->mail->domain}</a> en expliquant ta situation.";
    } else {
        list($forlife, $state, $type) = $res->fetchOneRow();
    }
    if ($state == 'active') {
        return "Tu es déjà inscrit, si tu ne te souviens plus de ton mot de passe d'accès au site, " . "tu peux suivre <a href=\"recovery\">la procédure de récupération de mot de passe</a>.";
    } else {
        if ($state == 'disabled') {
            return "Ton compte a été désactivé par les administrateurs du site suite à des abus. " . "Pour plus d'information ou pour demander la réactivation du compte, tu peux t'adresser à " . "<a href=\"mailto:support@{$globals->mail->domain}\">support@{$globals->mail->domain}</a>.";
        }
    }
    $emailXorg = PlUser::makeUserName($subState->t('firstname'), $subState->t('lastname'));
    $suffix = (User::$sub_mail_domains[$type] ? substr(User::$sub_mail_domains[$type], 0, 1) : '') . substr($subState->v('yearpromo'), -2);
    $emailXorg2 = $emailXorg . '.' . $suffix;
    // Search for homonyms:
    //  * first case: only one homonym already registered.
    $res = XDB::query('SELECT  uid, expire
                         FROM  email_source_account
                        WHERE  email = {?} AND type != \'alias_aux\'', $emailXorg);
    //  * second case: at least two homonyms registerd.
    $result = XDB::query("SELECT  hrmid\n                            FROM  email_source_other\n                           WHERE  type = 'homonym' AND email = {?}", $emailXorg);
    if ($res->numRows() || $result->numRows()) {
        if ($res->numRows()) {
            list($h_id, $expire) = $res->fetchOneRow();
            if (empty($expire)) {
                XDB::execute('UPDATE  email_source_account
                                 SET  expire = ADDDATE(NOW(), INTERVAL 1 MONTH)
                               WHERE  email = {?} AND type != \'alias_aux\'', $emailXorg);
                $hrmid = User::makeHomonymHrmid($emailXorg);
                XDB::execute('INSERT IGNORE INTO  homonyms_list (hrmid, uid)
                                          VALUES  ({?}, {?}), ({?}, {?})', $hrmid, $h_id, $hrmid, $subState->i('uid'));
                $als = XDB::fetchColumn('SELECT  email
                                           FROM  email_source_account
                                          WHERE  uid = {?} AND type != \'alias_aux\' AND expire IS NULL', $h_id);
                $homonym = User::getSilentWithUID($h_id);
                $mailer = new PlMailer('register/lostalias.mail.tpl');
                $mailer->addTo($homonym);
                $mailer->setSubject("Perte de ton alias {$emailXorg} dans un mois !");
                $mailer->assign('emailXorg', $emailXorg);
                $mailer->assign('als', join(', ', $als));
                $mailer->SetTxtBody(wordwrap($msg, 72));
                $mailer->send();
            }
        } else {
            $hrmid = $result->fetchOneCell();
            XDB::execute('INSERT IGNORE INTO  homonyms_list (hrmid, uid)
                                      VALUES  ({?}, {?})', $hrmid, $subState->i('uid'));
            // TODO: insert into source_other if new domain
        }
        $subState->set('forlife', $forlife);
        $subState->set('bestalias', $emailXorg2);
        $subState->set('emailXorg2', null);
    } else {
        $subState->set('forlife', $forlife);
        $subState->set('bestalias', $emailXorg);
        $subState->set('emailXorg2', $emailXorg2);
    }
    $subState->set('main_mail_domain', User::$sub_mail_domains[$type] . Platal::globals()->mail->domain);
    return true;
}
Example #3
0
 *  it under the terms of the GNU General Public License as published by   *
 *  the Free Software Foundation; either version 2 of the License, or      *
 *  (at your option) any later version.                                    *
 *                                                                         *
 *  This program is distributed in the hope that it will be useful,        *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program; if not, write to the Free Software            *
 *  Foundation, Inc.,                                                      *
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 ***************************************************************************/
/**
 * Requires destruction of aliases: a first notification 7 days before
 * destruction, a second on the date.
 */
require 'connect.db.inc.php';
$resRobot = XDB::iterator("SELECT  uid, email, expire\n                             FROM  email_source_account\n                            WHERE  expire <= NOW() + INTERVAL 7 DAY");
while ($old = $resRobot->next()) {
    $res = XDB::query('SELECT  a.hruid
                         FROM  homonyms_list AS h
                   INNER JOIN  accounts      AS a ON (h.uid = a.uid)
                        WHERE  h.hrmid = {?}', User::makeHomonymHrmid($old['email']));
    $hruids = $res->fetchColumn();
    $homonym = User::getSilent($old['uid']);
    $req = new HomonymeReq($homonym, $old['email'], $hruids, $old['expire'] > date("Y-m-d"));
    $req->submit();
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: