--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * 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 *
+ ***************************************************************************/
+
+function fill_email_combobox(PlatalPage& $page)
+{
+ global $globals;
+
+ $uid = S::v('uid');
+ $forlife = S::v('forlife');
+ $email_type = "directory";
+
+ $res = XDB::query(
+ "SELECT email_directory
+ FROM profile_directory
+ WHERE uid={?}", $uid);
+ $email_directory = $res->fetchOneCell();
+ if ($email_directory) {
+ $page->assign('email_directory', $email_directory);
+ list($alias, $domain) = explode('@', $email_directory);
+ } else {
+ $page->assign('email_directory', '');
+ $email_type = NULL;
+ $alias = $domain = '';
+ }
+
+ $res = XDB::query(
+ "SELECT alias
+ FROM virtual
+ INNER JOIN virtual_redirect USING(vid)
+ WHERE (redirect={?} OR redirect={?})
+ AND alias LIKE '%@{$globals->mail->alias_dom}'",
+ $forlife . '@' . $globals->mail->domain, $forlife . '@' . $globals->mail->domain2);
+ $melix = $res->fetchOneCell();
+ if ($melix) {
+ list($melix) = explode('@', $melix);
+ $page->assign('melix', $melix);
+ if (($domain == $globals->mail->alias_dom) || ($domain == $globals->mail->alias_dom2)) {
+ $email_type = "melix";
+ }
+ }
+
+ $res = XDB::query(
+ "SELECT alias
+ FROM aliases
+ WHERE id={?} AND (type='a_vie' OR type='alias')", $uid);
+ $res = $res->fetchAllAssoc();
+ $page->assign('list_email_X', $res);
+ if (($domain == $globals->mail->domain) || ($domain == $globals->mail->domain2)) {
+ foreach ($res as $res_it) {
+ if ($alias == $res_it['alias']) {
+ $email_type = "X";
+ }
+ }
+ }
+
+ require_once 'emails.inc.php';
+ $redirect = new Redirect($uid);
+ $redir = array();
+ foreach ($redirect->emails as $redirect_it) {
+ if ($redirect_it instanceof EmailRedirection) {
+ $redir[] = $redirect_it->email;
+ if ($email_directory == $redirect_it->email) {
+ $email_type = "redir";
+ }
+ }
+ }
+ $page->assign('list_email_redir', $redir);
+
+ $res = XDB::query(
+ "SELECT email
+ FROM entreprises
+ WHERE uid={?}", $uid);
+ $res = $res->fetchAllAssoc();
+ $pro = array();
+ foreach ($res as $res_it) {
+ if ($res_it['email'] != '') {
+ $pro[] = $res_it['email'];
+ if ($email_directory == $res_it['email']) {
+ $email_type = "pro";
+ }
+ }
+ }
+ $page->assign('list_email_pro', $pro);
+
+ $page->assign('email_type', $email_type);
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
$actifs = Env::v('emails_actifs', Array());
print_r(Env::v('emails_rewrite'));
if (Env::v('emailop') == "ajouter" && Env::has('email')) {
- $page->assign('retour', $redirect->add_email(Env::v('email')));
+ $new_email = Env::v('email');
+ if ($new_email == "new@new.new") {
+ $new_email = Env::v('email_new');
+ }
+ $retour = $redirect->add_email($new_email);
+ if ($retour == ERROR_INVALID_EMAIL) {
+ $page->assign('email', $new_email);
+ }
+ $page->assign('retour', $retour);
} elseif (empty($actifs)) {
$page->assign('retour', ERROR_INACTIVE_REDIRECTION);
} elseif (is_array($actifs)) {
require_once 'googleapps.inc.php';
$page->assign('googleapps', GoogleAppsAccount::account_status($uid));
+
+ require_once 'emails.combobox.inc.php';
+ fill_email_combobox($page);
}
function handler_antispam(&$page, $statut_filtre = null)
$res = XDB::iterator(
"SELECT r.*, a.alias
FROM register_marketing AS r
- INNER JOIN aliases AS a ON (r.sender=a.id AND a.type = 'a_vie')
+ LEFT JOIN aliases AS a ON (r.sender=a.id AND a.type = 'a_vie')
WHERE uid={?}
ORDER BY date", $uid);
$page->assign('addr', $res);
}
}
+class ProfileEmailDirectory implements ProfileSetting
+{
+ private $email;
+
+ public function __construct()
+ {
+ }
+
+ public function value(ProfilePage &$page, $field, $value, &$success)
+ {
+ $p = $page;
+ global $page;
+
+ $success = true;
+ if (!is_null($value)) {
+ $email_stripped = strtolower(trim($value));
+ if ((!isvalid_email($email_stripped)) && ($email_stripped) && ($p->values['email_directory'] == "new@new.new")) {
+ $page->assign('email_error', '1');
+ $page->assign('email_directory_error', $email_stripped);
+ $page->trigError('Adresse Email invalide');
+ $success = false;
+ } else {
+ $page->assign('email_error', '0');
+ }
+ }
+ return $value;
+ }
+
+ public function save(ProfilePage &$page, $field, $value)
+ {
+ }
+}
+
class ProfileNetworking implements ProfileSetting
{
private $email;
if (!is_array($value)) {
$value = array();
}
- $res = XDB::iterator("SELECT filter, network_type AS type
- FROM profile_networking_enum;");
+ $res = XDB::iterator("SELECT filter, network_type AS type
+ FROM profile_networking_enum;");
$filters = array();
while($filter = $res->next()) {
$filters[$filter['type']] = $filter['filter'];
public function __construct(PlWizard &$wiz)
{
parent::__construct($wiz);
- $this->settings['nom'] = $this->settings['prenom']
- = new ProfileNom();
+ $this->settings['nom'] = $this->settings['prenom']
+ = new ProfileNom();
$this->settings['naissance'] = new ProfileDate();
$this->settings['mobile_pub']
= $this->settings['freetext_pub']
$this->settings['synchro_ax']
= new ProfileBool();
$this->settings['mobile'] = new ProfileTel();
+ $this->settings['email_directory']
+ = new ProfileEmail();
+ $this->settings['email_directory_new']
+ = new ProfileEmailDirectory();
$this->settings['networking'] = new ProfileNetworking();
$this->settings['appli1']
= $this->settings['appli2']
= new ProfileAppli();
- $this->watched= array('nom' => true, 'freetext' => true, 'mobile' => true, 'networking' => true,
- 'appli1' => true, 'appli2' => true, 'nationalite' => true, 'nick' => true);
+ $this->watched= array('nom' => true, 'freetext' => true, 'mobile' => true,
+ 'networking' => true, 'appli1' => true, 'appli2' => true,
+ 'nationalite' => true, 'nick' => true);
}
protected function _fetchData()
// Checkout all data...
$res = XDB::query("SELECT u.promo, u.promo_sortie, u.nom_usage, u.nationalite, u.naissance,
q.profile_mobile as mobile, q.profile_mobile_pub as mobile_pub,
+ d.email_directory as email_directory,
q.profile_freetext as freetext, q.profile_freetext_pub as freetext_pub,
q.profile_nick as nick, q.profile_from_ax as synchro_ax, u.matricule_ax,
IF(a1.aid IS NULL, -1, a1.aid) as appli_id1, a1.type as appli_type1,
IF(a2.aid IS NULL, -1, a2.aid) as appli_id2, a2.type as appli_type2,
n.yourself, n.display AS display_name, n.sort AS sort_name,
n.tooltip AS tooltip_name
- FROM auth_user_md5 AS u
- INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id)
- INNER JOIN profile_names_display AS n ON(n.user_id = u.user_id)
- LEFT JOIN applis_ins AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)
- LEFT JOIN applis_ins AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)
+ FROM auth_user_md5 AS u
+ INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id)
+ INNER JOIN profile_names_display AS n ON(n.user_id = u.user_id)
+ LEFT JOIN profile_directory AS d ON(d.uid = u.user_id)
+ LEFT JOIN applis_ins AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)
+ LEFT JOIN applis_ins AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)
WHERE u.user_id = {?}", S::v('uid', -1));
$this->values = $res->fetchOneAssoc();
WHERE type='photo' AND user_id = {?}",
S::v('uid'));
$this->values['nouvellephoto'] = $res->fetchOneCell();
-
+
// Retreive search names info
$this->values['search_names'] = XDB::iterator("
- SELECT sn.search_name, sn.name_type, sn.pub, sn.sn_id
- FROM profile_names_search AS sn
- WHERE sn.user_id = {?}
- ORDER BY sn.name_type, search_score, search_name",
+ SELECT sn.search_name, sn.name_type, sn.pub, sn.sn_id
+ FROM profile_names_search AS sn
+ WHERE sn.user_id = {?}
+ ORDER BY sn.name_type, search_score, search_name",
S::v('uid'));
}
$this->values['freetext'], $this->values['freetext_pub'],
$this->values['synchro_ax'], S::v('uid'));
}
+ if ($this->changed['email_directory']) {
+ $new_email = ($this->values['email_directory'] == "new@new.new") ?
+ $this->values['email_directory_new'] : $this->values['email_directory'];
+ XDB::execute("REPLACE INTO profile_directory (uid, email_directory)
+ VALUES ({?}, {?})",
+ S::v('uid'), $new_email);
+ }
if ($this->changed['nick']) {
require_once('user.func.inc.php');
user_reindex(S::v('uid'));
}
if ($this->changed['yourself'] || $this->changed['sort_name'] ||
$this-> changed['display_name'] || $this->changed['tooltip_name']) {
- XDB::execute("UPDATE profile_names_display AS n
- SET n.yourself = {?},
- n.sort = {?}, ". // SET
- "n.display = {?}, ". // SET
- "n.tooltip = {?} ". // SET
- "WHERE n.user_id = {?}",
+ XDB::execute("UPDATE profile_names_display AS n
+ SET n.yourself = {?},
+ n.sort = {?}, ". // SET
+ "n.display = {?}, ". // SET
+ "n.tooltip = {?} ". // SET
+ "WHERE n.user_id = {?}",
$this->values['yourself'],
$this->values['sort_name'],
$this->values['display_name'],
{
require_once "applis.func.inc.php";
- $res = XDB::iterator("SELECT nw.network_type AS type, nw.name
- FROM profile_networking_enum AS nw
- ORDER BY name");
+ require_once "emails.combobox.inc.php";
+ fill_email_combobox($page);
+
+ $res = XDB::iterator("SELECT nw.network_type AS type, nw.name
+ FROM profile_networking_enum AS nw
+ ORDER BY name");
$page->assign('network_list', $res->fetchAllAssoc());
}
}
class ProfileJob extends ProfileGeoloc
{
private $pub;
+ private $mail_new;
private $mail;
private $web;
private $tel;
public function __construct()
{
$this->pub = new ProfilePub();
- $this->mail = new ProfileEmail();
+ $this->mail
+ = $this->mail_new
+ = new ProfileEmail();
$this->web = new ProfileWeb();
$this->tel = new ProfileTel();
$this->bool = new ProfileBool();
$this->checks = array('web' => array('web'),
+ 'mail_new' => array('email_new'),
'mail' => array('email'),
'tel' => array('tel', 'fax', 'mobile'),
'pub' => array('pub', 'tel_pub', 'email_pub'));
foreach ($this->checks as $obj=>&$fields) {
$chk =& $this->$obj;
foreach ($fields as $field) {
+ if ($field == "email_new") {
+ if ($job['email'] == "new@new.new") {
+ $job['email'] = $job[$field];
+ }
+ continue;
+ }
$job[$field] = $chk->value($page, $field, $job[$field], $s);
if (!$s) {
$success = false;
S::i('uid'));
$i = 0;
foreach ($value as &$job) {
+ if ($job['email'] == "new@new.new") {
+ $job['email'] = $job['email_new'];
+ }
+
XDB::execute("INSERT INTO entreprises (uid, entrid, entreprise, secteur, ss_secteur,
fonction, poste, adr1, adr2, adr3, postcode,
city, cityid, country, region, regiontxt,
public function _prepare(PlatalPage &$page, $id)
{
+ require_once "emails.combobox.inc.php";
+ fill_email_combobox($page);
+
$page->assign('secteurs', XDB::iterator("SELECT id, label
FROM emploi_secteur"));
$page->assign('fonctions', XDB::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
</p>
{/if}
{if $retour == $smarty.const.ERROR_INVALID_EMAIL}
+ {assign var='error_email' value='1'}
<p class="erreur">
Erreur: l'email n'est pas valide.
</p>
</td>
</tr>
{/foreach}
- <tr class="{cycle values="pair,impair"}"><td colspan="4">
- <form action="emails/redirect" method="post">
- <div>
- <br />
- Ajouter une adresse email :
- <input type="text" size="35" maxlength="60" name="email" value="" />
- <input type="submit" value="ajouter" name="emailop" />
+ <form action="emails/redirect" method="post">
+ {cycle values="pair,impair" assign=class_combobox}
+ {include file="include/emails.combobox.tpl" name="email" val=$email class=$class_combobox error=$error_email}
+ <tr class=$class_combobox><td colspan="4"><div>
+ <input type="submit" value="ajouter" name="emailop" />
{xsrf_token_field}
- </div>
- </form>
- </td></tr>
+ </div></td></tr>
+ </form>
</table>
<script type="text/javascript">showRemove(); activeEnable();</script>
</div>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2008 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<tr {if $class}class="{$class}"{/if}>
+ <td>
+ <span class="titre">{if $name eq "email_directory"}Email annuaire AX
+ {elseif $name eq "email"}Ajouter une adresse email{else}
+ Email professionnel{/if}</span>
+ </td>
+ {if $name eq "email"}<td></td>{/if}
+ <td>
+ <select name="{$name}" id="combobox">
+ {if $email_type eq "directory"}
+ <optgroup label="Email annuaire AX">
+ <option value="{$email_directory}" {if
+ $val eq $email_directory}selected="selected"{/if}>{$email_directory}</option>
+ </optgroup>
+ {/if}
+ {if $name eq "email_directory"}
+ <optgroup label="Emails polytechniciens">
+ {if $melix}
+ <option value="{$melix}@{#globals.mail.alias_dom#}" {if
+ $val eq $melix|cat:'@'|cat:#globals.mail.alias_dom#}selected="selected"{/if}>
+ {$melix}@{#globals.mail.alias_dom#}</option>
+ <option value="{$melix}@{#globals.mail.alias_dom2#}" {if
+ $val eq $melix|cat:'@'|cat:#globals.mail.alias_dom2#}selected="selected"{/if}>
+ {$melix}@{#globals.mail.alias_dom2#}</option>
+ {/if}
+ {foreach from=$list_email_X item=email}
+ <option value="{$email.alias}@{#globals.mail.domain#}" {if
+ $val eq $email.alias|cat:'@'|cat:#globals.mail.domain#}selected="selected"{/if}>
+ {$email.alias}@{#globals.mail.domain#}</option>
+ <option value="{$email.alias}@{#globals.mail.domain2#}" {if
+ $val eq $email.alias|cat:'@'|cat:#globals.mail.domain2#}selected="selected"{/if}>
+ {$email.alias}@{#globals.mail.domain2#}</option>
+ {/foreach}
+ </optgroup>
+ {/if}
+ {if (($name neq "email") && ($list_email_redir|@count neq 0))}
+ <optgroup label="Redirections">
+ {foreach from=$list_email_redir item=email}
+ <option value="{$email}" {if $val eq $email}selected="selected"{/if}>{$email}</option>
+ {/foreach}
+ </optgroup>
+ {/if}
+ {if $list_email_pro|@count neq 0}
+ <optgroup label="Emails professionels">
+ {foreach from=$list_email_pro item=email}
+ <option value="{$email}" {if
+ $val eq $email}selected="selected"{/if}>{$email}</option>
+ {/foreach}
+ </optgroup>
+ {/if}
+ <optgroup label="Autres choix">
+ <option value="new@new.new" {if $error}selected="selected"{/if}>Utiliser une autre adresse email</option>
+ <option value="" {if (($val eq '') && (!$error))}selected="selected"{/if}>{if
+ $name neq "email"}Ne pas mettre d'adresse email{else} {/if}</option>
+ </optgroup>
+ </select>
+ {if $name eq "email_directory"}
+ <input type="checkbox" disabled="disabled" checked="checked"/>
+ {icon name="flag_orange" title="Visible sur l'annuaire"}
+ {elseif $name neq "email"}
+ <span class="flags">
+ {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub}
+ </span>
+ {/if}
+ <br />
+ <span class="new" style="display: none">
+ <input type="text" maxlength="60" {if $error}class="error" value="{$val}"{/if} name="{if (($name neq "email_directory")
+ && ($name neq "email"))}jobs[{$i}][email_new]{else}{$name}_new{/if}"/>
+ </span>
+ <script type="text/javascript">//<![CDATA[
+ {literal}
+ $(function() {
+ $("select#combobox").change(function() {
+ $(".new").hide();
+ if ($("select#combobox").val() == "new@new.new") {
+ $(".new").show();
+ }
+ }).change();
+ });
+ {/literal}
+ // ]]></script>
+ </td>
+ {if $name eq "email"}<td></td>{/if}
+</tr>
+{if $name neq "email"}
+ <tr {if $class}class="{$class}"{/if} class="new" style="display: none">
+ <td colspan="2">
+ <p><small><strong><em>Attention :</em></strong> cette adresse email figurera dans
+ {if $name eq "email_directory"}l'annuaire papier{else}tes informations professionnelles
+ {/if} mais n'est pas ajoutée à la liste de tes redirections. Nous te conseillons fortement de
+ <strong><a href="emails/redirect">l'ajouter là</a></strong>, surtout
+ si tu n'en as plus de valide.</small></p>
+ </td>
+ </tr>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{iterate from=$addr item=a}
<tr class="{cycle values='impair,pair'}">
<td>{$a.email}</td>
- <td><a href="profile/{$a.alias}" class="popup2">{$a.alias}</a> {if $a.type eq user}(*){/if}</td>
+ <td>
+ {if $a.alias neq ''}<a href="profile/{$a.alias}" class="popup2">{$a.alias}</a>
+ {if $a.type eq user}(*){/if}{else}Email connu de l'AX{/if}
+ </td>
<td>{$a.date|date_format|default:'-'}</td>
<td>{$a.last|date_format|default:'-'}</td>
<td class='center'>{$a.nb|default:"-"}</td>
</span>
</td>
</tr>
+ {if $email_error}
+ {include file="include/emails.combobox.tpl" name="email_directory" val=$email_directory_error error=$email_error}
+ {else}{include file="include/emails.combobox.tpl" name="email_directory" val=$email_directory error=$email_error}{/if}
<tr>
<td colspan="2">
<span class="titre">Messageries, networking et sites web</span>
<a href="mailto:support@{#globals.mail.domain#}">contacte-nous</a>.</small>
</td>
</tr>
- <tr class="pair">
- <td colspan="2">
- <span class="titre">E-mail professionnel :</span>
- <input type="text" size="30" maxlength="60" {if $job.email_error}class="error"{/if}
- name="{$jobpref}[email]" value="{$job.email}" />
- <span class="flags">
- {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub}
- </span>
- </td>
- </tr>
+ {include file="include/emails.combobox.tpl" name=$jobpref|cat:'[email]' val=$job.email class="pair" i=$i error=$job.email_error}
<tr class="pair">
<td colspan="2">
<div style="float: left">
--- /dev/null
+CREATE TABLE IF NOT EXISTS profile_directory (
+ uid INT NOT NULL,
+ email_directory VARCHAR(255) DEFAULT NULL,
+ PRIMARY KEY (uid)
+) CHARSET=utf8;
+
+INSERT INTO profile_directory (uid, email_directory)
+ SELECT user_id, Mel_usage
+ FROM fusionax_anciens AS ax
+ INNER JOIN auth_user_md5 AS u ON (ax.id_ancien = CONVERT(u.matricule_ax, BINARY))
+ WHERE Mel_publiable != '0' AND Mel_usage != '';
+
+
+ALTER TABLE register_marketing MODIFY COLUMN type ENUM('user', 'staff', 'ax');
+
+INSERT IGNORE INTO register_marketing (uid, email, type)
+ SELECT user_id, Mel_usage, 'ax'
+ FROM fusionax_anciens AS ax
+ INNER JOIN auth_user_md5 AS u ON (ax.id_ancien = CONVERT(u.matricule_ax, BINARY))
+ LEFT JOIN emails AS e ON (e.uid = u.user_id AND e.flags = 'active')
+ WHERE Mel_usage != '' AND
+ Mel_usage NOT LIKE '%@polytechnique.edu' AND
+ Mel_usage NOT LIKE '%@polytechnique.org' AND
+ Mel_usage NOT LIKE '%@m4x.org' AND
+ Mel_usage NOT LIKE '%@melix.%' AND
+ e.email IS NULL;
+