}
}
+ private function changeLogin(PlatalPage &$page, array &$user, MMList &$mmlist, $login)
+ {
+ require_once 'user.func.inc.php';
+ // Search the uid of the user...
+ $res = XDB::query("SELECT f.id, f.alias
+ FROM aliases AS a
+ INNER JOIN aliases AS f ON (f.id = a.id AND f.type = 'a_vie')
+ WHERE a.alias = {?}",
+ $login);
+ if ($res->numRows() == 0) {
+ $x = get_not_registered_user($login);
+ if (!$x) {
+ $page->trig("Le login $login ne correspond à aucun X");
+ return false;
+ } else if (count($x) > 1) {
+ $page->trig("Le login $login correspond a plusieurs camarades");
+ return false;
+ }
+ $uid = $x[0]['user_id'];
+ $sub = false;
+ } else {
+ list($uid, $login) = $res->fetchOneRow();
+ $sub = true;
+ }
+
+ // Check if the user is already in the group
+ global $globals;
+ $res = XDB::query("SELECT uid, email
+ FROM groupex.membres
+ WHERE uid = {?} AND asso_id = {?}",
+ $uid, $globals->asso('id'));
+ if ($res->numRows()) {
+ list($uid, $email) = $res->fetchOneRow();
+ XDB::execute("DELETE FROM groupex.membres
+ WHERE uid = {?}",
+ $user['uid']);
+ } else {
+ $email = $user['email'];
+ XDB::execute("UPDATE groupex.membres
+ SET uid = {?}, origine = 'X'
+ WHERE uid = {?} AND asso_id = {?}",
+ $uid, $user['uid'], $globals->asso('id'));
+ }
+ if ($sub) {
+ $email = $login . '@' . $globals->mail->domain;
+ }
+
+ // Update subscription to aliases
+ if ($email != $user['email']) {
+ XDB::execute("UPDATE IGNORE virtual_redirect AS vr
+ INNER JOIN virtual AS v ON(vr.vid = v.vid AND SUBSTRING_INDEX(alias, '@', 2) = {?})
+ SET vr.redirect = {?}
+ WHERE vr.redirect = {?}",
+ $globals->asso('mail_domain'), $email, $user['email']);
+ XDB::execute("DELETE vr.*
+ FROM virtual_redirect AS vr
+ INNER JOIN virtual AS v ON(vr.vid = v.vid AND SUBSTRING_INDEX(alias, '@', 2) = {?})
+ WHERE vr.redirect = {?}",
+ $globals->asso('mail_domain'), $user['email']);
+ foreach (Env::v('ml1', array()) as $ml => $state) {
+ $mmlist->replace_email($ml, $user['email'], $email);
+ }
+ }
+ return $login;
+ }
+
function handler_admin_member(&$page, $user)
{
global $globals;
$globals->asso('mail_domain'));
if (Post::has('change')) {
+ // Convert user status to X
+ if ($user['origine'] == 'ext' && trim(Post::v('login_X'))) {
+ $forlife = $this->changeLogin($page, $user, $mmlist, trim(Post::v('login_X')));
+ if ($forlife) {
+ pl_redirect('member/' . $forlife);
+ }
+ }
+
+ // Update user info
$email_changed = ($user['origine'] != 'X' && strtolower($user['email']) != strtolower(Post::v('email')));
$from_email = $user['email'];
if ($user['origine'] != 'X') {
$page->trig('permissions modifiées');
}
+ // Update ML subscriptions
foreach (Env::v('ml1', array()) as $ml => $state) {
$ask = empty($_REQUEST['ml2'][$ml]) ? 0 : 2;
if ($ask == $state) {
}
}
+ // Change subscriptioin to aliases
foreach (Env::v('ml3', array()) as $ml => $state) {
$ask = !empty($_REQUEST['ml4'][$ml]);
if($state == $ask) continue;
{**************************************************************************}
<script type="text/javascript">
- {literal}
- function showInformations(box)
- {
- var state = (box.value == 'ext') ? '' : 'none';
- document.getElementById('prenom').style.display = state;
- document.getElementById('sexe').style.display = state;
- }
- {/literal}
+{literal}
+ function showInformations(box)
+ {
+ var state = (box.value == 'ext') ? '' : 'none';
+ document.getElementById('prenom').style.display = state;
+ document.getElementById('sexe').style.display = state;
+ document.getElementById('make_X').style.display = state;
+ }
+
+ function showXInput(box)
+ {
+ if (box.checked) {
+ document.getElementById('make_X_cb').style.display = 'none';
+ document.getElementById('make_X_login').style.display = '';
+ }
+ }
+{/literal}
</script>
<h1>{$asso.nom} : gestion des membres</h1>
<input type="text" value="{$user.email}" name="email" size="40" />
</td>
</tr>
+ <tr id="make_X" {if $user.origine eq "groupe"}style="display: none"{/if}>
+ <td colspan="2">
+ <span id="make_X_cb">
+ <input type="checkbox" name="is_x" id="is_x" onchange="showXInput(this);" />
+ <label for="is_x">coche cette case si il s'agit d'un X</label>
+ </span>
+ <span id="make_X_login" style="display: none">
+ <span class="titre">Identifiant (prenom.nom.promo) :</span>
+ <input type="text" name="login_X" value="" />
+ </span>
+ </td>
+ </tr>
{/if}
</table>