Merge commit 'origin/master' into fusionax
authorVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 19 Oct 2008 03:11:17 +0000 (05:11 +0200)
committerVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 19 Oct 2008 03:11:17 +0000 (05:11 +0200)
Conflicts:
include/userset.inc.php
modules/email.php
templates/include/minifiche.tpl
templates/include/plview.trombi.tpl
templates/profile/profile.tpl

Signed-off-by: Vincent Zanotti <vincent.zanotti@polytechnique.org>
19 files changed:
1  2 
ChangeLog
bin/cron/checkdb.php
include/emails.combobox.inc.php
include/user.func.inc.php
include/userset.inc.php
modules/email.php
modules/payment/money/paypal.inc.php
modules/profile.php
modules/search.php
modules/search/classes.inc.php
templates/emails/redirect.tpl
templates/events/index.tpl
templates/gadgets/ig-minifiche.tpl
templates/include/minifiche.tpl
templates/include/plview.referent.tpl
templates/include/plview.trombi.tpl
templates/marketing/private.tpl
templates/profile/general.tpl
templates/profile/profile.tpl

diff --cc ChangeLog
+++ b/ChangeLog
@@@ -1,19 -1,10 +1,23 @@@
  ================================================================================
 +VERSION 0.f.0                                                         XX XX XXXX
 +
 +New:
 +    * Core:
 +        - Centralises email management through an email combobox           -JAC
 +
 +Bug/Wish:
 +    * Profile:
 +        - #188: Adds informations about the Corps d'État                   -JAC
 +        - #209: Thoroughly changes education's implementation              -JAC
 +        - #386: Adds the possibility to fill in multiple nationalities     -JAC
 +
 +================================================================================
  VERSION 0.9.18                                                        XX XX XXXX
  
+ New:
+     * Core:
+         - Introduction of 'hruid' as a replacement for 'forlife'           -VZA
  Bug/Wish:
  
      * Search:
@@@ -81,9 -83,12 +81,13 @@@ check("SELECT  u.user_id, nom, prenom, 
             OR  (profile_medals_pub != 'private' AND profile_medals_pub != 'public')",
      "Utilisateur n'ayant pas de flag de publicite pour leurs donnees de profil");
  check("select uid from adresses where pub != 'private' and pub !='ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour une adresse");
 -check("select uid from tels where tel_pub != 'private' and tel_pub !='ax' and tel_pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de telephone");
 +check("select uid from profile_phones where pub != 'private' and pub != 'ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de téléphone");
 +check("select uid from profile_networking where pub != 'private' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicité pour une adresse de networking");
  
+ /* validite des hruid */
+ check("SELECT user_id, nom, prenom, promo FROM auth_user_md5 WHERE hruid IS NULL OR hruid = ''",
+       "Utilisateur n'ayant pas de hruid.");
  /* validite de aliases */
  check("SELECT a.*
          FROM aliases       AS a
index 1b05890,0000000..d91cf9b
mode 100644,000000..100644
--- /dev/null
@@@ -1,107 -1,0 +1,109 @@@
-     $uid        = S::v('uid');
-     $forlife    = S::v('forlife');
 +<?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(PlPage& $page)
 +{
 +    global $globals;
 +
-               WHERE  uid={?}", $uid);
++    $user = S::user();
 +    $email_type = "directory";
 +
 +    $res = XDB::query(
 +            "SELECT  email_directory
 +               FROM  profile_directory
-               WHERE  (redirect={?} OR redirect={?})
++              WHERE  uid = {?}", $user->id());
 +    $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)
-             $forlife . '@' . $globals->mail->domain, $forlife . '@' . $globals->mail->domain2);
++              WHERE  (redirect = {?} OR redirect = {?})
 +                     AND alias LIKE '%@{$globals->mail->alias_dom}'",
-               WHERE  id={?} AND (type='a_vie' OR type='alias')", $uid);
++            $user->forlifeEmail(),
++            // TODO: remove this über-ugly hack. The issue is that you need
++            // to remove all @m4x.org addresses in virtual_redirect first.
++            $user->login() . '@' . $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
-     $redirect = new Redirect($uid);
++              WHERE  id={?} 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)) {
 +        foreach ($res as $res_it) {
 +            if ($alias == $res_it['alias']) {
 +                $email_type = "X";
 +            }
 +        }
 +    }
 +
 +    require_once 'emails.inc.php';
-               WHERE  uid={?}", $uid);
++    $redirect = new Redirect($user);
 +    $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 = {?}", $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);
 +}
 +
 +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 +?>
Simple merge
@@@ -269,15 -245,8 +268,14 @@@ class MentorView extends MultipageVie
  
      public function fields()
      {
-         return "m.uid, u.promo,
-                 a.alias AS bestalias, m.expertise, mp.pid,
-                 ms.secteur, ms.ss_secteur,
 -        return "m.uid, u.prenom, u.nom, u.promo, u.hruid,
 -                m.expertise, mp.pid, ms.secteur, ms.ss_secteur";
++        return "m.uid, u.promo, u.hruid,
++                m.expertise, mp.pid, ms.secteur, ms.ss_secteur,
 +                nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
 +    }
 +
 +    public function joins()
 +    {
 +        return "INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)";
      }
  
      public function bounds()
@@@ -319,7 -288,7 +317,7 @@@ class TrombiView extends MultipageVie
  
      public function fields()
      {
-         return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, a.alias AS forlife ";
 -        return "u.user_id, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo, u.hruid ";
++        return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, u.hruid ";
      }
  
      public function joins()
@@@ -464,8 -432,8 +462,7 @@@ class GadgetView implements PlVie
  
      public function fields()
      {
-         return "u.user_id AS id,
-                 u.*, a.alias AS forlife," .
+         return "u.user_id AS id, u.*," .
 -                (S::logged() ? "q.profile_mobile AS mobile, " : "IF(q.profile_mobile_pub = 'public', q.profile_mobile, NULL) as mobile, ") .
                 "u.perms != 'pending' AS inscrit,
                  u.perms != 'pending' AS wasinscrit,
                  u.deces != 0 AS dcd, u.deces,
@@@ -289,16 -303,13 +311,16 @@@ class EmailModule extends PLModul
                  "SELECT  alias,expire
                     FROM  aliases
                    WHERE  id={?} AND (type='a_vie' OR type='alias')
-                ORDER BY  !FIND_IN_SET('usage',flags), LENGTH(alias)", $uid);
+                ORDER BY  !FIND_IN_SET('usage',flags), LENGTH(alias)", $user->id());
          $page->assign('alias', $res->fetchAllAssoc());
-         $page->assign('emails',$redirect->emails);
+         $page->assign('emails', $redirect->emails);
  
+         // Display GoogleApps acount information.
          require_once 'googleapps.inc.php';
-         $page->assign('googleapps', GoogleAppsAccount::account_status($uid));
+         $page->assign('googleapps', GoogleAppsAccount::account_status($user->id()));
 +
 +        require_once 'emails.combobox.inc.php';
 +        fill_email_combobox($page);
      }
  
      function handler_antispam(&$page, $statut_filtre = null)
Simple merge
Simple merge
Simple merge
      u.perms IN (\'admin\',\'user\', \'disabled\') AS inscrit,
      u.perms != \'pending\' AS wasinscrit,
      FIND_IN_SET(\'femme\', u.flags) AS sexe,
--    a.alias AS forlife,
 -    ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
 -    ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
 +    ede0.name AS eduname0, ede0.url AS eduurl0, edd0.degree AS edudegree0,
 +    edu0.grad_year AS edugrad_year0, f0.field AS edufield0, edu0.program AS eduprogram0,
 +    ede1.name AS eduname1, ede1.url AS eduurl1, edd1.degree AS edudegree1,
 +    edu1.grad_year AS edugrad_year1, f1.field AS edufield1, edu1.program AS eduprogram1,
 +    ede2.name AS eduname2, ede2.url AS eduurl2, edd2.degree AS edudegree2,
 +    edu2.grad_year AS edugrad_year2, f2.field AS edufield2, edu2.program AS eduprogram2,
 +    ede3.name AS eduname3, ede3.url AS eduurl3, edd3.degree AS edudegree3,
 +    edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3.program AS eduprogram3,
      es.label AS secteur, ef.fonction_fr AS fonction,
 -    IF(n.nat=\'\',n.pays,n.nat) AS nat, n.a2 AS iso3166,
 +    IF(n1.nat=\'\',n1.pays,n1.nat) AS nat1, n1.a2 AS iso3166_1,
 +    IF(n2.nat=\'\',n2.pays,n2.nat) AS nat2, n2.a2 AS iso3166_2,
 +    IF(n3.nat=\'\',n3.pays,n3.nat) AS nat3, n3.a2 AS iso3166_3,
      (COUNT(em.email) > 0 OR FIND_IN_SET("googleapps", u.mail_storage) > 0) AS actif,';
  // hide private information if not logged
  if (S::logged())
Simple merge
Simple merge
  <div class="contact" {if $c.inscrit}{if $smarty.session.auth ge AUTH_COOKIE}title="Fiche mise à jour le {$c.date|date_format}"{/if}{/if}>
    <div class="nom">
      {if $c.sexe}&bull;{/if}
-     {if !$c.dcd && $c.inscrit}<a href="profile/{$c.forlife}" class="popup2">{/if}
+     {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}<a href="profile/{$c.hruid}" class="popup2">{/if}
      {if $c.nom_usage}{$c.nom_usage} {$c.prenom}<br />({$c.nom}){else}{$c.nom} {$c.prenom}{/if}
-     {if !$c.dcd && $c.inscrit}</a>{/if}
+     {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}</a>{/if}
    </div>
    <div class="autre">
 -    {if $c.iso3166}
 -    <img src='images/flags/{$c.iso3166}.gif' alt='{$c.nat}' height='11' title='{$c.nat}' />&nbsp;
 +    {if $c.iso3166_1}
 +    <img src='images/flags/{$c.iso3166_1}.gif' alt='{$c.nat1}' height='11' title='{$c.nat1}' />&nbsp;
 +    {/if}
 +    {if $c.iso3166_2}
 +    <img src='images/flags/{$c.iso3166_2}.gif' alt='{$c.nat2}' height='11' title='{$c.nat2}' />&nbsp;
 +    {/if}
 +    {if $c.iso3166_3}
 +    <img src='images/flags/{$c.iso3166_3}.gif' alt='{$c.nat3}' height='11' title='{$c.nat3}' />&nbsp;
      {/if}
      (X {$c.promo})
      {if $c.dcd}décédé{if $c.sexe}e{/if} le {$c.deces|date_format}{/if}
    <div class="identity">
      {if $smarty.session.auth ge AUTH_COOKIE}
      <div class="photo">
-       <img src="photo/{if $c.inscrit}{$c.forlife}{else}{make_forlife nom=$c.nom prenom=$c.prenom promo=$c.promo}{/if}"
+       <img src="photo/{$c.hruid}"
 -           alt="{$c.prenom} {$c.nom}" />
 +           alt="{$c.name_display}" />
      </div>
      {/if}
  
      <div class="nom">
        {if $c.sexe}&bull;{/if}
-       {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}<a href="profile/{if $c.inscrit}{$c.forlife}{else}{make_forlife nom=$c.nom prenom=$c.prenom promo=$c.promo}{/if}" class="popup2">{/if}
+       {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}<a href="profile/{$c.hruid}" class="popup2">{/if}
 -      {if $c.nom_usage}{$c.nom_usage} {$c.prenom}<br />({$c.nom}){else}{$c.nom} {$c.prenom}{/if}
 +      <span {if $c.name_tooltip}class="hinted" title="{$c.name_tooltip}"{/if}>{$c.name_display}</span>
        {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}</a>{/if}
      </div>
  
Simple merge
    </tr>
    <tr>
      <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
-       <a href="{$mainsiteurl}profile/{$set[trombi.index_prev].forlife}" class="popup2">
+       <a href="{$mainsiteurl}profile/{$set[trombi.index_prev].hruid}" class="popup2">
 -        {$set[trombi.index_prev].prenom} {$set[trombi.index_prev].nom}{if $trombi_with_promo} ({$set[trombi.index_prev].promo}){/if}
 +        <span {if $set[trombi.index_prev].name_tooltip}class="hinted" title="{$set[trombi.index_prev].name_tooltip}"{/if}>{$set[trombi.index_prev].name_display}</span>{if $trombi_with_promo} ({$set[trombi.index_prev].promo}){/if}
        </a>
      </td>
      <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
-       <a href="{$mainsiteurl}profile/{$set[trombi].forlife}" class="popup2">
+       <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
 -        {$set[trombi].prenom} {$set[trombi].nom}{if $trombi_with_promo} ({$set[trombi].promo}){/if}
 +        <span {if $set[trombi].name_tooltip}class="hinted" title="{$set[trombi].name_tooltip}"{/if}>{$set[trombi].name_display}</span>{if $trombi_with_promo} ({$set[trombi].promo}){/if}
        </a>
      </td>
      <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
      {if $set[trombi.index_next]}
-       <a href="{$mainsiteurl}profile/{$set[trombi.index_next].forlife}" class="popup2">
+       <a href="{$mainsiteurl}profile/{$set[trombi.index_next].hruid}" class="popup2">
 -        {$set[trombi.index_next].prenom} {$set[trombi.index_next].nom}{if $trombi_with_promo} ({$set[trombi.index_next].promo}){/if}
 +        <span {if $set[trombi.index_next].name_tooltip}class="hinted" title="{$set[trombi.index_next].name_tooltip}"{/if}>{$set[trombi.index_next].name_display}</span>{if $trombi_with_promo} ({$set[trombi.index_next].promo}){/if}
        </a>
      {/if}
      </td>
@@@ -89,8 -89,8 +89,8 @@@
    </tr>
    <tr style="margin-top: 0; padding-top: 0">
      <td class="center" style="vertical-align: bottom">
-       <a href="{$mainsiteurl}profile/{$set[trombi].forlife}" class="popup2">
+       <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
 -        {$set[trombi].prenom} {$set[trombi].nom}{if $trombi_with_promo} ({$set[trombi].promo}){/if}
 +        <span {if $set[trombi].name_tooltip}class="hinted" title="{$set[trombi].name_tooltip}"{/if}>{$set[trombi].name_display}</span>{if $trombi_with_promo} ({$set[trombi].promo}){/if}
        </a>
      </td>
      <td></td><td></td>
Simple merge
Simple merge
@@@ -71,19 -57,20 +71,19 @@@ function chgMainWinLoc(strPage
    </div>
    <div id="fiche_identite" class="part">
      <div class="civilite">
-       {if $x.sexe}&bull;{/if}
+       {if $user->isFemale()}&bull;{/if}
 -      {$user->fullName()}{if $x.nom_usage neq ""} ({$x.nom}){/if}
 +      <span {if $x.name_tooltip neq ""}class="hinted" title="{$x.name_tooltip}"{/if}>{$x.name_display}</span>
        {if $logged}
        {if $x.nickname} (alias {$x.nickname}){/if}
        {/if}
 -      {if $x.web}&nbsp;<a href="{$x.web}">{icon name="world_go" title="Site Web"}</a>{/if}
        {if $logged}
-       &nbsp;{if !$x.dcd}<a href="vcard/{$x.forlife}.vcf">{*
+       &nbsp;{if !$x.dcd}<a href="vcard/{$user->login()}.vcf">{*
          *}{icon name=vcard title="Afficher la carte de visite"}</a>{/if}
        {if !$x.is_contact}
-       <a href="javascript:chgMainWinLoc('carnet/contacts?action=ajouter&amp;user={$x.forlife}&amp;token={xsrf_token}')">
+       <a href="javascript:chgMainWinLoc('carnet/contacts?action=ajouter&amp;user={$user->login()}&amp;token={xsrf_token}')">
          {icon name=add title="Ajouter à mes contacts"}</a>
        {else}
-       <a href="javascript:chgMainWinLoc('carnet/contacts?action=retirer&amp;user={$x.forlife}&amp;token={xsrf_token}')">
+       <a href="javascript:chgMainWinLoc('carnet/contacts?action=retirer&amp;user={$user->login()}&amp;token={xsrf_token}')">
          {icon name=cross title="Retirer de mes contacts"}</a>
        {/if}
        {if hasPerm('admin')}
      </div>
      {/if}
      <div class='formation'>
 -      {if $x.iso3166}
 -      <img src='images/flags/{$x.iso3166}.gif' alt='{$x.nationalite}' height='11' title='{$x.nationalite}' />&nbsp;
 +      {if $x.iso3166_1}
 +      <img src='images/flags/{$x.iso3166_1}.gif' alt='{$x.nationalite}' height='11' title='{$x.nationalite}' />&nbsp;
 +      {/if}
 +      {if $x.iso3166_2}
 +      <img src='images/flags/{$x.iso3166_2}.gif' alt='{$x.nationalite2}' height='11' title='{$x.nationalite2}' />&nbsp;
 +      {/if}
 +      {if $x.iso3166_3}
 +      <img src='images/flags/{$x.iso3166_3}.gif' alt='{$x.nationalite3}' height='11' title='{$x.nationalite3}' />&nbsp;
        {/if}
-       X {$x.promo}
-       {if ($x.promo_sortie-3 > $x.promo)}
+       X {$user->promo()}
+       {if $x.promo_sortie && ($x.promo_sortie-3 > $x.promo)}
          - X {math equation="a-b" a=$x.promo_sortie b=3}
        {/if}
 -      {if $x.applis_join}
 -        &nbsp;-&nbsp;Formation&nbsp;: {$x.applis_join|smarty:nodefaults}
 +      {if $x.education}
 +        &nbsp;-&nbsp;Formation&nbsp;: {$x.education|smarty:nodefaults}
        {/if}
        {if $logged && $x.is_referent}
-       [<a href="referent/{$x.forlife}" class='popup2'>Ma fiche référent</a>]
+       [<a href="referent/{$user->login()}" class='popup2'>Ma fiche référent</a>]
        {/if}
 +      {if $x.corps}
 +        <br />
 +        {$x.corps|smarty:nodefaults}
 +      {/if}
      </div>
    </div>
    {if $x.adr}