<?php
/***************************************************************************
- * Copyright (C) 2003-2011 Polytechnique.org *
+ * Copyright (C) 2003-2014 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
INNER JOIN email_virtual_domains AS m ON (s.domain = m.id)
INNER JOIN email_virtual_domains AS d ON (d.aliasing = m.id)
WHERE s.uid = {?}
- ORDER BY !alias, s.email",
+ ORDER BY !alias, s.email, d.name",
$user->id());
- $page->assign('aliases', $aliases);
+ $aliases_forlife = array();
+ $aliases_hundred = array();
+ $aliases_other = array();
+ while ($a = $aliases->next()) {
+ if ($a['forlife']) {
+ $aliases_forlife[] = $a;
+ } elseif ($a['hundred_year']) {
+ $aliases_hundred[] = $a;
+ } else {
+ $aliases_other[] = $a;
+ }
+ }
+ $page->assign('aliases_forlife', $aliases_forlife);
+ $page->assign('aliases_hundred', $aliases_hundred);
+ $page->assign('aliases_other', $aliases_other);
$alias = XDB::fetchOneCell('SELECT COUNT(email)
FROM email_source_account
INNER JOIN email_virtual_domains AS d ON (s.domain = d.id)
WHERE s.uid = {?} AND s.type = \'alias_aux\'',
$user->id());
- $visibility = $user->hasProfile() && ($user->profile(true)->alias_pub == 'public');
+ $visibility = $user->hasProfile() && $user->profile()->isVisible($user->profile()->alias_pub);
$page->assign('current', $alias);
$page->assign('user', $user);
$page->assign('mail_public', $visibility);
// Retrieves user request.
$new_alias = Env::v('alias');
$reason = Env::v('reason');
- $public = (Env::v('public', 'off') == 'on') ? 'public' : 'private';
+ $public = (Env::v('public', 'off') == 'on') ? 'private' : 'hidden';
$page->assign('r_alias', $new_alias);
$page->assign('r_reason', $reason);
- if ($public == 'public') {
+ if ($public == 'private') {
$page->assign('r_public', true);
}
// Checks special charaters in alias.
- if (!preg_match("/^[a-zA-Z0-9\-.]{3,20}$/", $new_alias)) {
+ if (!preg_match("/^[a-zA-Z0-9\-.]{2,19}[a-zA-Z0-9\-]$/", $new_alias)) {
$page->trigError("L'adresse demandée n'est pas valide."
. " Vérifie qu'elle comporte entre 3 et 20 caractères"
. " et qu'elle ne contient que des lettres non accentuées,"
- . " des chiffres ou les caractères - et .");
+ . " des chiffres ou les caractères '-' et '.'. De plus, elle ne"
+ . " peut pas se terminer par un point.");
return;
} else {
// Checks if the alias has already been given.
if ($uid) {
$dest = User::getWithUID($uid);
+ $active = XDB::fetchOneCell('SELECT flags
+ FROM email_redirect_account
+ WHERE redirect = {?} AND uid = {?}', $email, $uid) == 'active';
$mail = new PlMailer('emails/broken-web.mail.tpl');
$mail->assign('email', $email);
AND er.type != \'imap\' AND er.type != \'homonym\')
LEFT JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', ap.perms))
LEFT JOIN profile_display AS pd ON (ap.pid = pd.pid)
- WHERE a.state = \'active\' AND er.redirect IS NULL AND FIND_IN_SET(\'mail\', at.perms)
+ LEFT JOIN profiles AS p ON (ap.pid = p.pid)
+ WHERE a.state = \'active\' AND er.redirect IS NULL AND FIND_IN_SET(\'mail\', at.perms) AND p.deathdate IS NULL
GROUP BY a.uid
ORDER BY pd.promo, a.hruid'));
}
$broken_user_list = array();
$broken_user_email_count = array();
+ $broken_user_profiles = array();
$broken_list = explode("\n", $list);
sort($broken_list);
foreach ($broken_list as $email) {
+ $userobj = null;
if ($user = mark_broken_email($email, true)) {
- if ($user['nb_mails'] > 0 && $user['notify']) {
- $mail = new PlMailer('emails/broken.mail.tpl');
- $dest = User::getSilentWithUID($user['uid']);
- $mail->setTo($dest);
- $mail->assign('user', $user);
- $mail->assign('email', $email);
- $mail->send();
- } else {
- $profile = Profile::get($user['alias']);
- WatchProfileUpdate::register($profile, 'broken');
- }
+ $userobj = User::getSilentWithUID($user['uid']);
+ }
+ if (is_null($userobj)) {
+ continue;
+ }
+ $profile = $userobj->profile();
+ if (is_null($profile)) {
+ continue;
+ }
+ if ($user['nb_mails'] > 0 && $user['notify']) {
+ $mail = new PlMailer('emails/broken.mail.tpl');
+ $mail->setTo($userobj);
+ $mail->assign('user', $user);
+ $mail->assign('email', $email);
+ $mail->send();
+ } else {
+ WatchProfileUpdate::register($profile, 'broken');
+ }
- if (!isset($broken_user_list[$user['uid']])) {
- $broken_user_list[$user['uid']] = array($email);
- } else {
- $broken_user_list[$user['uid']][] = $email;
- }
- $broken_user_email_count[$user['uid']] = $user['nb_mails'];
+ $pid = $profile->id();
+ if (!isset($broken_user_list[$pid])) {
+ $broken_user_list[$pid] = array($email);
+ } else {
+ $broken_user_list[$pid][] = $email;
}
+ $broken_user_email_count[$pid] = $user['nb_mails'];
+ $broken_user_profiles[$pid] = $profile;
}
XDB::execute('UPDATE email_redirect_account
$csv = fopen('php://output', 'w');
fputcsv($csv, array('nom', 'promo', 'bounces', 'nbmails', 'url', 'corps', 'job', 'networking'), ';');
$corpsList = DirEnum::getOptions(DirEnum::CURRENTCORPS);
- foreach ($broken_user_list as $uid => $mails) {
- $profile = Profile::get($uid);
- $corps = $profile->getCorps();
- $current_corps = ($corps && $corps->current) ? $corpsList[$corps->current] : '';
+ foreach ($broken_user_list as $pid => $mails) {
+ $profile = $broken_user_profiles[$pid];
+ $current_corps = $profile->getCorpsName();
$jobs = $profile->getJobs();
$companies = array();
foreach ($jobs as $job) {
$networking_list[] = $networking['address'];
}
fputcsv($csv, array($profile->fullName(), $profile->promo(),
- join(',', $mails), $broken_user_email_count[$uid],
+ join(',', $mails), $broken_user_email_count[$pid],
'https://www.polytechnique.org/marketing/broken/' . $profile->hrid(),
$current_corps, implode(',', $companies), implode(',', $networking_list)), ';');
}
}
}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
?>