IF(a.state = \'active\', at.perms, \'\') AS perms,
a.email_format, a.is_admin, a.state, a.type, a.skin,
FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment,
- a.weak_password IS NOT NULL AS weak_access,
- a.token IS NOT NULL AS token_access,
- (e.email IS NULL AND NOT FIND_IN_SET(\'googleapps\', eo.storage)) AND a.state != \'pending\' AS lost
+ a.weak_password IS NOT NULL AS weak_access, g.g_account_name IS NOT NULL AS googleapps,
+ a.token IS NOT NULL AS token_access, a.token, a.last_version,
+ (e.email IS NULL AND NOT FIND_IN_SET(\'googleapps\', eo.storage)) AND a.state != \'pending\' AS lost,
+ UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, UNIX_TIMESTAMP(fp.last_seen) AS banana_last
' . $fields . '
FROM accounts AS a
INNER JOIN account_types AS at ON (at.type = a.type)
LEFT JOIN aliases AS ah ON (ah.uid = a.uid AND ah.type = \'homonyme\')
LEFT JOIN emails AS e ON (e.uid = a.uid AND e.flags = \'active\')
LEFT JOIN email_options AS eo ON (eo.uid = a.uid)
+ LEFT JOIN gapps_accounts AS g ON (a.uid = g.l_userid AND g.g_status = \'active\')
+ LEFT JOIN log_last_sessions AS ls ON (ls.uid = a.uid)
+ LEFT JOIN log_sessions AS s ON (s.id = ls.id)
+ LEFT JOIN forum_profiles AS fp ON (fp.uid = a.uid)
' . $joins . '
WHERE a.uid IN (' . implode(', ', $uids) . ')
GROUP BY a.uid
return $this->profile()->lastName();
}
+ public function displayName()
+ {
+ if (!$this->hasProfile()) {
+ return $this->display_name;
+ }
+ return $this->profile()->yourself;
+ }
+
public function fullName($with_promo = false)
{
if (!$this->hasProfile()) {
$this->email_format = $format;
}
-
/** Get watch informations
*/
private function fetchWatchData()
LIMIT 1", $user->id());
$sess = $res->fetchOneAssoc();
$_SESSION = array_merge($_SESSION, $sess);
- $this->makePerms(S::s('perms'), S::b('is_admin'));
+ $this->makePerms(S::s('perms'), S::user()->is_admin);
S::kill('challenge');
S::kill('loginX');
S::kill('may_update');
S::set('auth', AUTH_MDP);
}
- // Retrieves main user properties.
- /** TODO: Move needed informations to account tables */
- /** TODO: Currently suppressed data are matricule, promo */
- /** TODO: Use the User object to fetch all this */
- $res = XDB::query("SELECT a.uid, a.hruid, a.display_name, a.full_name,
- a.sex = 'female' AS femme, a.email_format,
- a.token, FIND_IN_SET('watch', a.flags) AS watch_account,
- UNIX_TIMESTAMP(fp.last_seen) AS banana_last,
- a.last_version, g.g_account_name IS NOT NULL AS googleapps,
- UNIX_TIMESTAMP(s.start) AS lastlogin, s.host,
- a.is_admin, at.perms
- FROM accounts AS a
- INNER JOIN account_types AS at ON (a.type = at.type)
- LEFT JOIN watch AS w ON (w.uid = a.uid)
- LEFT JOIN forum_profiles AS fp ON (fp.uid = a.uid)
- LEFT JOIN gapps_accounts AS g ON (a.uid = g.l_userid AND g.g_status = 'active')
- LEFT JOIN log_last_sessions AS ls ON (ls.uid = a.uid)
- LEFT JOIN log_sessions AS s ON(s.id = ls.id)
- WHERE a.uid = {?} AND a.state = 'active'", $user->id());
- if ($res->numRows() != 1) {
- return false;
- }
-
- $sess = $res->fetchOneAssoc();
- $perms = $sess['perms'];
- unset($sess['perms']);
-
- // Loads the data into the real session.
- $_SESSION = array_merge($_SESSION, $sess);
+ // Loads uid and hruid into the session for developement conveniance.
+ $_SESSION = array_merge($_SESSION, array('uid' => $user->id(), 'hruid' => $user->hruid));
// Starts the session's logger, and sets up the permanent cookie.
if (S::suid()) {
}
// Finalizes the session setup.
- $this->makePerms($perms, S::b('is_admin'));
+ $this->makePerms($user->perms, $user->is_admin);
$this->securityChecks();
$this->setSkin();
$this->updateNbNotifs();
$time = null;
if (!is_null($this->params) && isset($this->params['updateall'])) {
$time = intval($this->params['updateall']);
- S::set('banana_last', $time);
+ S::user()->banana_last = $time;
}
$infos = $this->fetchProfile();
Banana::$profile['signature'] = $infos['sig'];
Banana::$profile['display'] = $infos['threads'];
Banana::$profile['autoup'] = $infos['maj'];
- Banana::$profile['lastnews'] = S::v('banana_last');
+ Banana::$profile['lastnews'] = S::user()->banana_last;
Banana::$profile['subscribe'] = $req->fetchColumn();
Banana::$tree_unread = $infos['tree_unread'];
Banana::$tree_read = $infos['tree_read'];
} else {
$group = '';
}
- return '/rss/' . $group . S::v('hruid') . '/' . S::s('token') . '/rss.xml';
+ return '/rss/' . $group . S::v('hruid') . '/' . S::user()->token . '/rss.xml';
}
function hook_platalMessageLink($params)
function check_account()
{
- return S::v('watch_account');
+ return S::user()->watch;
}
function check_redirect($red = null)
{
if (S::hasAuthToken()) {
$page->setRssLink('Changement Récents',
- '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::v('token'));
+ '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::user()->token);
}
// update wiki perms
return;
}
$page->setRssLink('Polytechnique.org :: Carnet',
- '/carnet/rss/'.S::v('hruid').'/'.S::v('token').'/rss.xml');
+ '/carnet/rss/' . S::v('hruid') . '/' . S::user()->token . '/rss.xml');
}
function handler_index(&$page)
// For XSRF protection, checks both the normal xsrf token, and the special RSS token.
// It allows direct linking to contact adding in the RSS feed.
- if (Env::v('action') && Env::v('token') !== S::v('token')) {
+ if (Env::v('action') && Env::v('token') !== S::user()->token) {
S::assert_xsrf_token();
}
switch (Env::v('action')) {
$storage = new EmailStorage(S::user(), 'imap');
$storage->activate();
$page->assign('ok', true);
- $page->assign('prenom', S::v('prenom'));
- $page->assign('sexe', S::v('femme'));
+ $page->assign('yourself', S::user()->displayName());
+ $page->assign('sexe', S::user()->isFemale());
} else if (!S::logged() && $user) {
$storage = new EmailStorage($user, 'imap');
$storage->activate();
$page->assign('ok', true);
- $page->assign('prenom', $user->displayName());
+ $page->assign('yourself', $user->displayName());
$page->assign('sexe', $user->isFemale());
}
}
{
global $globals;
// Add a new special tip when changing plat/al version
- if ($globals->version != S::v('last_version') && is_null($exclude)) {
+ if ($globals->version != S::user()->last_version && is_null($exclude)) {
XDB::execute('UPDATE accounts
SET last_version = {?}
WHERE uid = {?}',
// Direct link to the RSS feed, when available.
if (S::hasAuthToken()) {
$page->setRssLink('Polytechnique.org :: News',
- '/rss/'.S::v('hruid') .'/'.S::v('token').'/rss.xml');
+ '/rss/' . S::v('hruid') . '/' . S::user()->token . '/rss.xml');
}
// Hide the read event, and reload the page to get to the next event.
function __set_rss_state($state)
{
if ($state) {
- S::set('token', rand_url_id(16));
+ S::user()->token = rand_url_id(16);
XDB::execute('UPDATE accounts
SET token = {?}
- WHERE uid = {?}', S::s('token'), S::i('uid'));
+ WHERE uid = {?}', S::user()->token, S::i('uid'));
} else {
S::kill('token');
XDB::execute('UPDATE accounts
if (Post::has('email_format')) {
$fmt = Post::s('email_format');
S::user()->setEmailFormat($fmt);
- S::set('email_format', $fmt);
}
if (Post::has('rss')) {
$platal->ns . "rss/rss.xml");
} else {
$page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News",
- $platal->ns . 'rss/'.S::v('hruid') .'/'.S::v('token').'/rss.xml');
+ $platal->ns . 'rss/' . S::v('hruid') . '/' . S::user()->token . '/rss.xml');
}
$page->assign('articles', $arts);
{/literal}
<p class="center">
- <a href="Site/AllRecentChanges?action=rss&user={$smarty.session.hruid}&hash={$smarty.session.token}" style="display:block;float:right" title="Changements">{icon name=feed title='fil rss'}</a>
+ <a href="Site/AllRecentChanges?action=rss&user={$smarty.session.hruid}&hash={$smarty.session.user->token}" style="display:block;float:right" title="Changements">{icon name=feed title='fil rss'}</a>
{icon name=magnifier} <a href="Site/AllRecentChanges">Voir les changements récents</a>
</p>
<table class="bicol">
<tr>
<th colspan="2">
- {if $smarty.session.token}
- <a href="carnet/rss/{$smarty.session.hruid}/{$smarty.session.token}/rss.xml" style="display:block;float:right" title="Notifications">
+ {if $smarty.session.user->token}
+ <a href="carnet/rss/{$smarty.session.hruid}/{$smarty.session.user->token}/rss.xml" style="display:block;float:right" title="Notifications">
{icon name=feed title='fil rss'}
</a>
{else}
</li>
<li>
Le calendrier des anniversaires :
- <a href="carnet/contacts/ical/{$smarty.session.hruid}/{$smarty.session.token}/anniv-x.ics">
+ <a href="carnet/contacts/ical/{$smarty.session.hruid}/{$smarty.session.user->token}/anniv-x.ics">
{icon name=calendar_view_day title='Anniversaires au format iCal'}
</a>
- <a href="carnet/contacts/csv/birthday/{$smarty.session.hruid}/{$smarty.session.token}/anniv-x.csv">
+ <a href="carnet/contacts/csv/birthday/{$smarty.session.hruid}/{$smarty.session.user->token}/anniv-x.csv">
{icon name=outlook title='Anniversaires au format Outlook'}
</a>
</li>
{icon name=vcard title='Carte de visite au format vCard'}
</a>
(<a href="carnet/contacts/vcard/MesContactsXorg.vcf">sans les photos</a>)
- <a href="carnet/contacts/csv/{$smarty.session.hruid}/{$smarty.session.token}/MesContactsXorg.csv">
+ <a href="carnet/contacts/csv/{$smarty.session.hruid}/{$smarty.session.user->token}/MesContactsXorg.csv">
{icon name=outlook title='Contacts au format Outlook'}
</a>
</li>
</p>
<div class="right">
-{if $smarty.session.token}
-<a href="carnet/rss/{$smarty.session.hruid}/{$smarty.session.token}/rss.xml" title="Notifications">{icon name=feed title='fil rss'}</a>
+{if $smarty.session.user->token}
+<a href="carnet/rss/{$smarty.session.hruid}/{$smarty.session.user->token}/rss.xml" title="Notifications">{icon name=feed title='fil rss'}</a>
{/if}
</div>
{if $ok}
<p>
- {if $sexe}Chère{else}Cher{/if} {$prenom},
+ {if $sexe}Chère{else}Cher{/if} {$yourself},
</p>
<p>
{else}
<h1 id='pagetop'>
-Bienvenue {$smarty.session.display_name}{if $birthday}
+Bienvenue {$smarty.session.user->displayName()}{if $birthday}
et joyeux anniversaire de la part de toute l'équipe !
{else},
{/if}
</h1>
-{if $smarty.session.host}
+{if $smarty.session.user->host}
<div class="smaller">
{if $birthday}T{else}t{/if}a connexion précédente date du
- <strong>{$smarty.session.lastlogin|date_format:"%x, %X"}</strong>
- depuis la machine <strong>{$smarty.session.host}</strong>.
+ <strong>{$smarty.session.user->lastlogin|date_format:"%x, %X"}</strong>
+ depuis la machine <strong>{$smarty.session.user->host}</strong>.
</div>
{/if}
<tr class="pair" style="height: 18px">
<td class="half titre" style="height: 18px; padding-top: 1px; padding-bottom: 1px;">
{if $smarty.foreach.events.first}
- {if $smarty.session.token}
- <a href="rss/{$smarty.session.hruid}/{$smarty.session.token}/rss.xml" style="display:block;float:right" title="Annonces">
+ {if $smarty.session.user->token}
+ <a href="rss/{$smarty.session.hruid}/{$smarty.session.user->token}/rss.xml" style="display:block;float:right" title="Annonces">
{icon name=feed title='fil rss'}
</a>
{else}
{if !$has_evts}
<tr>
<td class="half">
- {if $smarty.session.token}
- <a href="rss/{$smarty.session.hruid}/{$smarty.session.token}/rss.xml" style="display:block;float:right" title="Annonces">
+ {if $smarty.session.user->token}
+ <a href="rss/{$smarty.session.hruid}/{$smarty.session.user->token}/rss.xml" style="display:block;float:right" title="Annonces">
{icon name=feed title='fil rss'}
</a>
{else}
{elseif $user->last}
<p>
{$user->fullName()} a encore des adresses de redirection actives malgré des pannes détectées sur certaines d'entre elles. Si
- tu es sûr{if $smarty.session.femme}e{/if} que son adresse Polytechnique.org est en panne, tu peux proposer une nouvelle
+ tu es sûr{if $smarty.session.user->gender}e{/if} que son adresse Polytechnique.org est en panne, tu peux proposer une nouvelle
adresse email à ajouter à ses redirections. Merci d'ajouter un commentaire pour nous indiquer la raison de cette proposition.
</p>
{else}
<p>
Nous n'avons actuellement enregistré aucune panne sur les adresses de redirection de {$user->fullName()}. Si tu es
- sûr{if $smarty.session.femme}e{/if} que son adresse de redirection actuelle est en panne, tu peux nous proposer
+ sûr{if $smarty.session.user->gender}e{/if} que son adresse de redirection actuelle est en panne, tu peux nous proposer
une nouvelle adresse, accompagnée d'un commentaire nous expliquant les raisons exactes de cette proposition.
</p>
{/if}
<h1>Fil RSS</h1>
-{if !$smarty.session.token}
+{if !$smarty.session.user->token}
<p>
Tu viens de cliquer sur le lien d'activation des fils RSS. Les fils RSS du site
ne sont pas activés dans tes préférences.
<ul>
<li>
Anonces sur la page d'entrée :
- <a href="rss/{$smarty.session.hruid}/{$smarty.session.token}/rss.xml" title="Annonces">{icon name=feed title='fil rss'}</a>
+ <a href="rss/{$smarty.session.hruid}/{$smarty.session.user->token}/rss.xml" title="Annonces">{icon name=feed title='fil rss'}</a>
</li>
<li>
Ton carnet polytechnicien :
- <a href="carnet/rss/{$smarty.session.hruid}/{$smarty.session.token}/rss.xml" title="Notifications">{icon name=feed title='fil rss'}</a>
+ <a href="carnet/rss/{$smarty.session.hruid}/{$smarty.session.user->token}/rss.xml" title="Notifications">{icon name=feed title='fil rss'}</a>
</li>
</ul>
<p>
</tr>
<tr class="impair">
<td class="half">
- {if $smarty.session.email_format eq html}
+ {if $smarty.session.user->email_format eq html}
<h3>
<a href="javascript:dynpostkv('prefs','email_format','text')">Recevoir les emails en format texte</a>
</h3>
</td>
<td class="half">
<h3>
- {if $smarty.session.token}
+ {if $smarty.session.user->token}
<a href="javascript:dynpostkv('prefs','rss',0)">Désactiver les fils rss</a>
{else}
<a href="javascript:dynpostkv('prefs','rss',1)">Activer les fils rss</a>
<div class="menu_title">Services</div>
<div class="menu_item"><a href="emails/send">Envoyer un email</a></div>
<div class="menu_item"><a href="banana/">Forums & PA</a></div>
-{if $smarty.session.googleapps}
+{if $smarty.session.user->googleapps}
<div class="menu_item"><a href="http://gmail.polytechnique.org/">Emails Google Apps</a></div>
{/if}
<div class="menu_item"><a href="lists">Listes de diffusion</a></div>
<table class="tinybicol">
<tr>
<th>
- {if $smarty.session.token}
- <a href='{$platal->ns}rss/{$smarty.session.hruid}/{$smarty.session.token}/rss.xml' style="display:block;float:right">
+ {if $smarty.session.user->token}
+ <a href='{$platal->ns}rss/{$smarty.session.hruid}/{$smarty.session.user->token}/rss.xml' style="display:block;float:right">
{icon name=feed title='fil rss'}
</a>
{else}
{elseif $smarty.post.inscrire}
<p class="descr">
-<strong>Ta demande d'inscription a bien été envoyée !</strong> Tu seras averti{if $smarty.session.femme}e{/if} par email de la suite qui lui sera donnée.
+<strong>Ta demande d'inscription a bien été envoyée !</strong> Tu seras averti{if $smarty.session.user->gender}e{/if} par email de la suite qui lui sera donnée.
<p>
<p class="descr">[<a href="{$platal->ns}">Retour à la page d'accueil de {$asso->nom}</a>]</p>
l'accord préalable des responsables du groupe.
</p>
<p class="descr">
-La dernière colonne du tableau t'indique si tu es inscrit{if $smarty.session.femme}e{/if} ou non à
+La dernière colonne du tableau t'indique si tu es inscrit{if $smarty.session.user->gender}e{/if} ou non à
la liste. Dans le premier cas, une croix rouge te permet de te désabonner. Dans le second cas, une
croix verte te permet de t'inscrire, après accord des responsables si l'inscription est modérée.
</p>
</table>
<p class="descr">
-{icon name=wrench title="Modérateur"} tu es {if $smarty.session.femme}modératrice{else}moderateur{/if} sur cette liste.<br />
+{icon name=wrench title="Modérateur"} tu es {if $smarty.session.user->gender}modératrice{else}moderateur{/if} sur cette liste.<br />
{icon name=weather_cloudy title="Liste privée"} cette liste est invisible aux non-membres de la liste. S'en désabonner
t'empêcherait de t'y réabonner par la suite sans l'aide d'un administrateur.
</p>