From: Stéphane Jacob
Date: Mon, 7 Jul 2008 21:33:52 +0000 (+0200)
Subject: Integrates the AX emails into the marketing emails, implements an email combobox...
X-Git-Tag: xorg/1.0.0~332^2~562
X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=b715c1e1641250d75c3bf2d3bd951519ad3e1dcd;p=platal.git
Integrates the AX emails into the marketing emails, implements an email combobox and integrates it for use with the email_directory, the professional emails and the email redirections.
---
diff --git a/include/emails.combobox.inc.php b/include/emails.combobox.inc.php
new file mode 100644
index 0000000..1bdab67
--- /dev/null
+++ b/include/emails.combobox.inc.php
@@ -0,0 +1,107 @@
+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:
+?>
diff --git a/modules/email.php b/modules/email.php
index f3fc4f4..32b8692 100644
--- a/modules/email.php
+++ b/modules/email.php
@@ -239,7 +239,15 @@ class EmailModule extends PLModule
$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)) {
@@ -272,6 +280,9 @@ class EmailModule extends PLModule
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)
diff --git a/modules/marketing.php b/modules/marketing.php
index 5c52a44..4bac8ed 100644
--- a/modules/marketing.php
+++ b/modules/marketing.php
@@ -150,7 +150,7 @@ class MarketingModule extends PLModule
$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);
diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php
index 5aa0f4b..8942d4a 100644
--- a/modules/profile/general.inc.php
+++ b/modules/profile/general.inc.php
@@ -107,6 +107,39 @@ class ProfileAppli implements ProfileSetting
}
}
+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;
@@ -138,8 +171,8 @@ class ProfileNetworking implements ProfileSetting
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'];
@@ -191,8 +224,8 @@ class ProfileGeneral extends ProfilePage
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']
@@ -209,12 +242,17 @@ class ProfileGeneral extends ProfilePage
$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()
@@ -222,17 +260,19 @@ class ProfileGeneral extends ProfilePage
// 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();
@@ -257,13 +297,13 @@ class ProfileGeneral extends ProfilePage
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'));
}
@@ -290,6 +330,13 @@ class ProfileGeneral extends ProfilePage
$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'));
@@ -302,12 +349,12 @@ class ProfileGeneral extends ProfilePage
}
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'],
@@ -320,9 +367,12 @@ class ProfileGeneral extends ProfilePage
{
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());
}
}
diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php
index 33690c4..4f0d428 100644
--- a/modules/profile/jobs.inc.php
+++ b/modules/profile/jobs.inc.php
@@ -22,6 +22,7 @@
class ProfileJob extends ProfileGeoloc
{
private $pub;
+ private $mail_new;
private $mail;
private $web;
private $tel;
@@ -31,11 +32,14 @@ class ProfileJob extends ProfileGeoloc
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'));
@@ -47,6 +51,12 @@ class ProfileJob extends ProfileGeoloc
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;
@@ -96,6 +106,10 @@ class ProfileJob extends ProfileGeoloc
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,
@@ -204,6 +218,9 @@ class ProfileJobs extends ProfilePage
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
diff --git a/templates/emails/redirect.tpl b/templates/emails/redirect.tpl
index 3634ebf..0eef01d 100644
--- a/templates/emails/redirect.tpl
+++ b/templates/emails/redirect.tpl
@@ -27,6 +27,7 @@
{/if}
{if $retour == $smarty.const.ERROR_INVALID_EMAIL}
+ {assign var='error_email' value='1'}
Erreur: l'email n'est pas valide.
@@ -180,17 +181,14 @@
{/foreach}
-
-
+
diff --git a/templates/include/emails.combobox.tpl b/templates/include/emails.combobox.tpl
new file mode 100644
index 0000000..b53b494
--- /dev/null
+++ b/templates/include/emails.combobox.tpl
@@ -0,0 +1,119 @@
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+
+
+ {if $name eq "email_directory"}Email annuaire AX
+ {elseif $name eq "email"}Ajouter une adresse email{else}
+ Email professionnel{/if}
+
+ {if $name eq "email"} {/if}
+
+
+ {if $email_type eq "directory"}
+
+ {$email_directory}
+
+ {/if}
+ {if $name eq "email_directory"}
+
+ {if $melix}
+
+ {$melix}@{#globals.mail.alias_dom#}
+
+ {$melix}@{#globals.mail.alias_dom2#}
+ {/if}
+ {foreach from=$list_email_X item=email}
+
+ {$email.alias}@{#globals.mail.domain#}
+
+ {$email.alias}@{#globals.mail.domain2#}
+ {/foreach}
+
+ {/if}
+ {if (($name neq "email") && ($list_email_redir|@count neq 0))}
+
+ {foreach from=$list_email_redir item=email}
+ {$email}
+ {/foreach}
+
+ {/if}
+ {if $list_email_pro|@count neq 0}
+
+ {foreach from=$list_email_pro item=email}
+ {$email}
+ {/foreach}
+
+ {/if}
+
+ Utiliser une autre adresse email
+ {if
+ $name neq "email"}Ne pas mettre d'adresse email{else} {/if}
+
+
+ {if $name eq "email_directory"}
+
+ {icon name="flag_orange" title="Visible sur l'annuaire"}
+ {elseif $name neq "email"}
+
+ {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub}
+
+ {/if}
+
+
+
+
+
+
+ {if $name eq "email"} {/if}
+
+{if $name neq "email"}
+
+
+ Attention : 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
+ l'ajouter là , surtout
+ si tu n'en as plus de valide.
+
+
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/marketing/private.tpl b/templates/marketing/private.tpl
index b09926c..dfecab6 100644
--- a/templates/marketing/private.tpl
+++ b/templates/marketing/private.tpl
@@ -64,7 +64,10 @@ sa dernière relance date du {$relance|date_format}
{iterate from=$addr item=a}
{$a.email}
- {if $a.type eq user}(*){/if}
+
+ {if $a.alias neq ''}
+ {if $a.type eq user}(*){/if}{else}Email connu de l'AX{/if}
+
{$a.date|date_format|default:'-'}
{$a.last|date_format|default:'-'}
{$a.nb|default:"-"}
diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl
index 3b22ec3..0ecaefc 100644
--- a/templates/profile/general.tpl
+++ b/templates/profile/general.tpl
@@ -282,6 +282,9 @@
+ {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}
Messageries, networking et sites web
diff --git a/templates/profile/jobs.job.tpl b/templates/profile/jobs.job.tpl
index d83b6a2..4f7813b 100644
--- a/templates/profile/jobs.job.tpl
+++ b/templates/profile/jobs.job.tpl
@@ -108,16 +108,7 @@
contacte-nous .
-
-
- E-mail professionnel :
-
-
- {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub}
-
-
-
+ {include file="include/emails.combobox.tpl" name=$jobpref|cat:'[email]' val=$job.email class="pair" i=$i error=$job.email_error}
diff --git a/upgrade/fusionax-0.0.1/03_emails.sql b/upgrade/fusionax-0.0.1/03_emails.sql
new file mode 100644
index 0000000..1f2455a
--- /dev/null
+++ b/upgrade/fusionax-0.0.1/03_emails.sql
@@ -0,0 +1,27 @@
+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;
+