<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
{
global $globals;
- if (is_null($user) && is_null($profile)) {
+ if (is_null($user)) {
$user = S::user();
- $profile = $user->profile();
+ }
+ if (is_null($profile)) {
+ /* Always refetch the profile. */
+ $profile = $user->profile(true);
}
$email_type = "directory";
if ($profile) {
- $res = XDB::query(
- "SELECT email_directory
- FROM profile_directory
- WHERE uid = {?}", $profile->id());
- $email_directory = $res->fetchOneCell();
+ $email_directory = $profile->email_directory;
if ($email_directory) {
$page->assign('email_directory', $email_directory);
list($alias, $domain) = explode('@', $email_directory);
$email_type = NULL;
$alias = $domain = '';
}
+
+ $res = XDB::query(
+ "SELECT email
+ FROM profile_job
+ WHERE pid = {?}", $profile->id());
+ $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);
}
if ($user) {
$res = XDB::query(
"SELECT alias
FROM aliases
- WHERE id={?} AND (type='a_vie' OR type='alias')", $user->id());
+ WHERE uid={?} AND (type='a_vie' OR type='alias')", $user->id());
$res = $res->fetchAllAssoc();
$page->assign('list_email_X', $res);
if (($domain == $globals->mail->domain) || ($domain == $globals->mail->domain2)) {
}
}
$page->assign('list_email_redir', $redir);
-
- $res = XDB::query(
- "SELECT email
- FROM profile_job
- WHERE uid = {?}", $user->id());
- $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);
-
} else {
$page->assign('list_email_X', array());
$page->assign('list_email_redir', array());