{
if ($this->hruid !== null && $this->forlife !== null
&& $this->bestalias !== null && $this->display_name !== null
- && $this->full_name !== null && $this->promo !== null && $this->perms !== null
+ && $this->full_name !== null && $this->perms !== null
&& $this->gender !== null && $this->email_format !== null) {
return;
}
global $globals;
/** TODO: promo stuff again */
/** TODO: fix perms field to fit new perms system */
- $res = XDB::query("SELECT a.hruid, d.promo,
+ $res = XDB::query("SELECT a.hruid, a.registration_date,
CONCAT(af.alias, '@{$globals->mail->domain}') AS forlife,
CONCAT(ab.alias, '@{$globals->mail->domain}') AS bestalias,
a.full_name, a.display_name, a.sex = 'female' AS gender,
IF(a.state = 'active', at.perms, '') AS perms,
- a.email_format, a.is_admin
+ 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
FROM accounts AS a
INNER JOIN account_types AS at ON (at.type = a.type)
- INNER JOIN profile_display AS d ON (d.pid = a.uid)
LEFT JOIN aliases AS af ON (af.id = a.uid AND af.type = 'a_vie')
LEFT JOIN aliases AS ab ON (ab.id = a.uid AND FIND_IN_SET('bestalias', ab.flags))
WHERE a.uid = {?}", $this->user_id);
WHERE a.uid = {?}', $this->id());
}
+ /** Overload PlUser::promo(): there no promo defined for a user in the current
+ * schema. The promo is a field from the profile.
+ */
+ public function promo()
+ {
+ if (!$this->hasProfile()) {
+ return '';
+ }
+ return $this->profile()->promo();
+ }
+
/** Return the main profile attached with this account if any.
*/
public function profile()
public function emailAlias()
{
global $globals;
- return XDB::fetchOneCell("SELECT v.alias
- FROM virtual AS v
- INNER JOIN virtual_redirect AS vr ON (v.vid = vr.vid)
- WHERE (vr.redirect = {?} OR vr.redirect = {?})
- AND alias LIKE '%@{$globals->mail->alias_dom}'",
- $this->forlifeEmail(), $this->m4xForlifeEmail(), $this->id());
+ $data = $this->emailAliases($globals->mail->alias_dom);
+ if (count($data) > 0) {
+ return array_pop($data);
+ }
+ return null;
+ }
+
+ /** Get all the aliases the user belongs to.
+ */
+ public function emailAliases($domain = null)
+ {
+ $where = '';
+ if (!is_null($domain)) {
+ $where = XDB::format(' AND alias LIKE CONCAT("%@", {?})', $domain);
+ }
+ return XDB::fetchColumn('SELECT v.alias
+ FROM virtual AS v
+ INNER JOIN virtual_redirect AS vr ON (v.vid = vr.vid)
+ WHERE (vr.redirect = {?} OR vr.redirect = {?})
+ ' . $where,
+ $this->forlifeEmail(), $this->m4xForlifeEmail());
}
/** Get the alternative forlife email
$this->stamp = date('YmdHis');
$this->unique = $_unique;
$this->type = $_type;
- $res = XDB::query("SELECT promo
- FROM profile_display
- WHERE pid={?}", $this->user->id());
- $this->promo = $res->fetchOneCell();
+ $this->promo = $this->user->promo();
}
// }}}
'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'),
'admin/icons' => $this->make_hook('icons', AUTH_MDP, 'admin'),
'admin/accounts' => $this->make_hook('accounts', AUTH_MDP, 'admin'),
+ 'admin/account/types' => $this->make_hook('account_types', AUTH_MDP, 'admin'),
);
}
$page->assign('host', $host);
// Display active aliases.
- $page->assign('virtuals', XDB::iterator(
- "SELECT alias
- FROM virtual
- INNER JOIN virtual_redirect USING (vid)
- WHERE type = 'user' AND (redirect = {?} OR redirect = {?})",
- $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));
-
+ $page->assign('virtuals', $user->emailAliases());
$page->assign('aliases', XDB::iterator(
"SELECT alias, type='a_vie' AS for_life,FIND_IN_SET('bestalias',flags) AS best,expire
FROM aliases
WHERE id = {?} AND type != 'homonyme'
ORDER BY type != 'a_vie'", $user->id()));
+ $page->assign('account_types', XDB::iterator('SELECT * FROM account_types ORDER BY type'));
+ $page->assign('skins', XDB::iterator('SELECT id, name FROM skins ORDER BY name'));
// Displays email redirection and the general profile.
if ($registered && $redirect) {
$table_editor->apply($page, $action, $id);
}
- function handler_downtime(&$page, $action = 'list', $id = null) {
+ function handler_downtime(&$page, $action = 'list', $id = null)
+ {
$page->setTitle('Administration - Coupures');
$page->assign('title', 'Gestion des coupures');
$table_editor = new PLTableEditor('admin/downtime','coupures','id');
$table_editor->apply($page, $action, $id);
}
+ function handler_account_types(&$page, $action = 'list', $id = null)
+ {
+ $page->setTitle('Administration - Types de comptes');
+ $page->assign('title', 'Gestion des types de comptes');
+ $table_editor = new PLTableEditor('admin/account/types', 'account_types', 'type', true);
+ $table_editor->describe('type', 'Catégorie', true);
+ $table_editor->describe('perms', 'Permissions associées', true);
+ $table_editor->apply($page, $action, $id);
+ }
+
function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null)
{
if (S::hasAuthToken()) {
{**************************************************************************}
-<h1>
- Gestion des utilisateurs
-</h1>
-
-
{if $smarty.post.u_kill_conf}
<form method="post" action="admin/user">
{xsrf_token_field}
<input type="submit" name="u_kill" value="continuer" />
</div>
</form>
-{else}
-
-<form method="post" action="admin/user">
- {xsrf_token_field}
- <table class="tinybicol" cellspacing="0" cellpadding="2">
- <tr>
- <th>
- Administrer
- </th>
- </tr>
- {if !$smarty.request.login && !$mr.hruid}
- <tr class="pair">
- <td class="center">
- Il est possible d'entrer ici n'importe quelle adresse email : redirection, melix, ou alias.
- </td>
- </tr>
- {/if}
- <tr>
- <td class="center">
- <input type="text" name="login" size="40" maxlength="255" value="{$smarty.request.login|default:$mr.hruid}" />
- </td>
- </tr>
- <tr>
- <td class="center">
- <input type="hidden" name="hashpass" value="" />
- <input type="submit" name="select" value=" edit " />
- <input type="submit" name="suid_button" value=" su " />
- <input type="submit" name="ax_button" value=" AX " />
- <input type="submit" name="logs_button" value=" logs " />
- </td>
- </tr>
- </table>
-</form>
-
-{if $mr}
-
-<p class="smaller">
-Dernière connexion le <strong>{$lastlogin|date_format:"%d %B %Y, %T"}</strong>
-depuis <strong>{$host}</strong>.
-</p>
+{elseif $user}
{literal}
<script type="text/javascript">
</script>
{/literal}
-<form id="auth" method="post" action="admin/user">
+<form id="auth" method="post" action="admin/user/{$user->login()}">
{xsrf_token_field}
- <table cellspacing="0" cellpadding="2" class="tinybicol">
+ <h1>Informations sur le compte</h1>
+ <p class="smaller">
+ Dernière connexion le <strong>{$lastlogin|date_format:"%d %B %Y, %T"}</strong>
+ depuis <strong>{$host}</strong>.
+ </p>
+
+ <table class="tinybicol">
<tr>
<th colspan="2">
<div style="float: right; text-align: right">
- Matricule = {$mr.matricule}<br />
- Matricule AX = {$mr.matricule_ax}
+ Inscrit le {$user->registration_date|date_format}
</div>
<div style="float: left; text-align: left">
- UID = {$mr.user_id}<br />
- Inscription = {$mr.date_ins|date_format}
+ {icon name=user_gray} {$mr.hruid} (uid {$user->id()})
</div>
- <input type="hidden" name="user_id" value="{$mr.user_id}" />
+ <input type="hidden" name="uid" value="{$user->id()}" />
</th>
</tr>
- <tr class="pair">
- <td class="titre">
- Mot de passe
+ <tr>
+ <td class="titre">Nom complet</td>
+ <td><input type="text" name="full_name" maxlength="255" value="{$user->fullName()}" /></td>
+ </tr>
+ <tr>
+ <td class="titre">Nom affiché</td>
+ <td><input type="text" name="display_name" maxlength="255" value="{$user->displayName()}" /></td>
+ </tr>
+ <tr>
+ <td class="titre">Sexe</td>
+ <td>
+ <label>femme <input type="radio" name="sex" value="female" {if $user->isFemale()}checked="checked"{/if} /></label>
+ <label><input type="radio" name="sexe" value="male" {if !$user->isFemale()}checked="checked"{/if} /> homme</label>
</td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">Mot de passe</td>
<td>
<div style="float: left">
- <input type="text" name="newpass_clair" size="10" maxlength="10" value="********" />
- <input type="hidden" name="passw" size="32" maxlength="32" value="{$mr.password}" />
+ <input type="text" name="newpass_clair" size="10" maxlength="255" value="********" />
<input type="hidden" name="hashpass" value="" />
</div>
<div style="float: left; margin-top: 5px;">
</div>
</td>
</tr>
+ <tr class="impair">
+ <td class="titre">Mot de passe SMTP</td>
+ <td>
+ <div style="float: left">
+ <input type="password" name="weak_password" size="10" maxlength="256" value="" />
+ {if $user->weak_access}
+ <input type="submit" name="disable_weak_access" value="Supprimer" />
+ {/if}
+ </div>
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">Accès RSS</td>
+ <td>
+ <label>
+ <input type="checkbox" name="token_access" {if $user->token_access}checked="checked"{/if} />
+ activer l'accès
+ </label>
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">Skin</td>
+ <td>
+ <select name="skin">
+ <option value="" {if !$user->skin}selected="selected"{/if}>Aucune (défaut du système)</option>
+ {iterate from=$skins item=skin}
+ <option value="{$skin.id}" {if $user->skin eq $skin.id}selected="selected"{/if}>{$skin.name}</option>
+ {/iterate}
+ </select>
+ </td>
+ </tr>
+ <tr class="pair">
+ <td class="titre">Etat du compte</td>
+ <td>
+ <select name="state">
+ <option value="pending" {if $user->state eq 'pending'}selected="selected"{/if}>pending (Non-inscrit)</option>
+ <option value="active" {if $user->state eq 'active'}selected="selected"{/if}>active (Inscrit, peu se logguer)</option>
+ <option value="disabled" {if $user->state eq 'disabled'}selected="selected"{/if}>disabled (Inscrit, accès interdit)</option>
+ </select><br />
+ <label>
+ <input type="checkbox" name="is_admin" value="1" {if $user->is_admin}checked="checked"{/if} />
+ administrateur du site
+ </label>
+ </td>
+ </tr>
+ <tr class="pair">
+ <td class="titre">Type de compte</td>
+ <td>
+ <select name="type">
+ {iterate from=$account_types item=type}
+ <option value="{$type.type}" {if $user->type eq $type.type}selected="selected"{/if}>{$type.type} ({$type.perms})</option>
+ {/iterate}
+ </select>
+ <a href="admin/account/types">gérer</a>
+ </td>
+ </tr>
+ <tr class="pair">
+ <td class="titre">
+ Surveillance
+ </td>
+ <td>
+ <label><input type="checkbox" name="watch" {if $user->watch}checked="checked"{/if} />
+ Surveiller l'activité de ce compte</label><br />
+ <span class="smaller">Cette option permet d'avoir des logs complets de l'activité
+ du compte via le logger, et d'être alerté lors des connexions de l'utilisateur.</span>
+ </td>
+ </tr>
+ <tr class="pair">
+ <td class="titre">
+ Commentaire
+ </td>
+ <td>
+ <input type="text" name="comment" size="40" maxlength="64" value="{$user->comment}" />
+ </td>
+ </tr>
+ </table>
+ <div class="center">
+ <input type="submit" name="update_account" value="Mettre à jour" /><br />
+ <input type="submit" name="su_account" value="Prendre l'identité" />
+ <input type="submit" name="log_account" value="Consulter les logs" />
+ </div>
+
+<!--
+ <h1>Informations sur la fiche</h1>
+ <table cellspacing="0" cellpadding="2" class="tinybicol">
+ <tr>
+ <th colspan="2">
+ <div style="float: right; text-align: right">
+ Matricule = {$mr.matricule}<br />
+ Matricule AX = {$mr.matricule_ax}
+ </div>
+ <div style="float: left; text-align: left">
+ UID = {$mr.user_id}<br />
+ Inscription = {$mr.date_ins|date_format}
+ </div>
+ <input type="hidden" name="user_id" value="{$mr.user_id}" />
+ </th>
+ </tr>
<tr class="pair">
<td class="titre">
Nom
<input type="text" name="promoN" size="4" maxlength="4" value="{$mr.promo}" />
</td>
</tr>
- <tr class="impair">
- <td class="titre">
- Surveillance
- </td>
- <td>
- <label><input type="checkbox" name="watchN" {if $mr.watch}checked="checked"{/if} />
- Surveiller l'activité de ce compte</label><br />
- <span class="smaller">Cette option permet d'avoir des logs complets de l'activité
- du compte via le logger, et d'être alerté lors des connexions de l'utilisateur.</span>
- </td>
- </tr>
- <tr class="impair">
- <td class="titre">
- Commentaire
- </td>
- <td>
- <input type="text" name="commentN" size="40" maxlength="64" value="{$mr.comment}" />
- </td>
- </tr>
{if $mr.perms eq 'pending'}
<tr class="center">
<td colspan="2">
{/if}
</tr>
{/iterate}
- {iterate from=$virtuals item=virtual}
+ {foreach from=$virtuals item=virtual}
<tr class="{cycle values="impair,pair"}">
<td></td>
- <td>{$virtual.alias}</td>
+ <td>{$virtual}</td>
<td></td>
</tr>
- {/iterate}
+ {/foreach}
<tr class="{cycle values="impair,pair"}">
<td colspan="2" class="detail">
<input type="text" name="email" size="29" maxlength="60" value="" />
</tr>
</table>
</form>
+-->
<p><strong>* à ne modifier qu'avec l'accord express de l'utilisateur !!!</strong></p>
-<form id="bans" method="post" action="admin/user">
+<form id="bans" method="post" action="admin/user/{$user->login()}">
{xsrf_token_field}
<table cellspacing="0" cellpadding="2" class="tinybicol">
<tr>
{javascript name="ajax"}
{test_email hruid=$user->login()}
-<form id="fwds" method="post" action="admin/user#fwds">
+<form id="fwds" method="post" action="admin/user/{$user->login()}#fwds">
{xsrf_token_field}
<table class="bicol" cellpadding="2" cellspacing="0">
<tr>
{/if}
{/if}
-{/if}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}