X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Femails.combobox.inc.php;h=288aa66ce47e0c2943230eb8539ed96990d31570;hb=4abb0fe4bcefc73a18891e9768640d8811a09acc;hp=546063bbe64640a409e03481dacaa9f3a55242c2;hpb=4ca15c312b905eea712b71d077c7a8b24f9d3b01;p=platal.git diff --git a/include/emails.combobox.inc.php b/include/emails.combobox.inc.php index 546063b..288aa66 100644 --- a/include/emails.combobox.inc.php +++ b/include/emails.combobox.inc.php @@ -1,6 +1,6 @@ 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); @@ -43,6 +42,22 @@ function fill_email_combobox(PlPage& $page, $user = null, $profile = null) $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) { @@ -58,7 +73,7 @@ function fill_email_combobox(PlPage& $page, $user = null, $profile = null) $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)) { @@ -81,24 +96,7 @@ function fill_email_combobox(PlPage& $page, $user = null, $profile = null) } } $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());