} else {
$site = "";
}
+
+ $notify_all = (Post::v('notify_all') ? true : false);
+ if (!$notify_all) {
+ $to_notify = array();
+ $uf = New UserFilter(New UFC_Group($globals->asso('id'), true));
+ $uids = $uf->getIds();
+ foreach ($uids as $uid) {
+ if (Post::b('to_notify_' . $uid)) {
+ $to_notify[] = $uid;
+ }
+ }
+ if (count($to_notify) == 0) {
+ $notify_all = true;
+ $page->trigWarning("Aucun animateur n'ayant été selectionné pour recevoir les demandes d'inscriptions, tous le seront.");
+ }
+ }
+ $flags->addFlag('notify_all', $notify_all);
+
if (S::admin()) {
$page->assign('super', true);
}
}
+ XDB::execute("UPDATE group_members
+ SET flags = ''
+ WHERE asso_id = {?}",
+ $globals->asso('id'));
+ if (!$notify_all) {
+ XDB::execute("UPDATE group_members
+ SET flags = 'notify'
+ WHERE asso_id = {?} AND uid IN {?}",
+ $globals->asso('id'), $to_notify);
+ }
+
pl_redirect('../' . Post::v('diminutif', $globals->asso('diminutif')) . '/edit');
}
+
+ $uf = New UserFilter(New UFC_Group($globals->asso('id'), true, UFC_Group::NOTIFIED));
+ $page->assign('notified', $uf->getUsers());
+ $uf = New UserFilter(New UFC_Group($globals->asso('id'), true, UFC_Group::UNNOTIFIED));
+ $page->assign('unnotified', $uf->getUsers());
+
$page->assign('error', $error);
$page->assign('cat', $globals->asso('cat'));
$page->assign('dom', $globals->asso('dom'));
$page->assign('inscriptible', $globals->asso('inscriptible'));
$page->assign('pub', $globals->asso('pub'));
$page->assign('notif_unsub', $globals->asso('notif_unsub'));
+ $page->assign('notify_all', $globals->asso('notify_all'));
}
function handler_mail($page)
$view = new UserSet(new UFC_Group($globals->asso('id'), $admins));
$view->addMod('groupmember', 'Annuaire');
$view->addMod('trombi', 'Trombinoscope');
+ $view->addMod('map', 'Planisphère');
$view->apply('annuaire', $page, $action);
$page->assign('only_admin', $admins);
$page->changeTpl('xnetgrp/annuaire.tpl');
$filename = $globals->asso('diminutif') . '.csv';
}
$users = $globals->asso()->getMembersFilter(null, new UFO_Name())->getUsers();
- pl_cached_content_headers('text/x-csv', 1);
- $page->changeTpl('xnetgrp/annuaire-csv.tpl', NO_SKIN);
- $page->assign('users', $users);
+ pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1);
+
+ echo utf8_decode("Nom;Prénom;Sexe;Promotion;Commentaire\n");
+ foreach ($users as $user) {
+ $line = $user->lastName() . ';' . $user->firstName() . ';' . ($user->isFemale() ? 'F' : 'M')
+ . ';' . $user->promo() . ';' . strtr($user->group_comm, ';', ',');
+ echo utf8_decode($line) . "\n";
+ }
+ exit();
}
function handler_directory_sync($page)
XDB::execute('DELETE FROM group_former_members
WHERE uid = {?} AND asso_id = {?}',
S::i('uid'), $globals->asso('id'));
- $uf = New UserFilter(New UFC_Group($globals->asso('id'), true));
- $admins = $uf->iterUsers();
+ $admins = $globals->asso()->iterToNotify();
$admin = $admins->next();
$to = $admin->bestEmail();
while ($admin = $admins->next()) {
// + (the data) => %2B (in the url) => + (first decoding) => ' ' (second decoding)
// Since there can be no spaces in emails, we can fix this with :
$email = str_replace(' ', '+', $email);
+ $is_valid_email = isvalid_email($email);
- // Finds or creates account: first cases are for users with an account.
- if (!User::isForeignEmailAddress($email)) {
- // Standard account
- $user = User::getSilent($email);
- } else if (!isvalid_email($email)) {
- // email might not be a regular email but an alias or a hruid
- $user = User::getSilent($email);
- if (!$user) {
- // need a valid email address
- $page->trigError('« <strong>' . $email . '</strong> » n\'est pas une adresse email valide.');
- return;
- }
- } else if (Env::v('x') && Env::i('userid')) {
+ // X not registered to main site.
+ if (Env::v('x') && Env::i('userid') && $is_valid_email) {
$user = User::getSilentWithUID(Env::i('userid'));
if (!$user) {
$page->trigError('Utilisateur invalide.');
}
}
} else {
- // Check if the email is a redirection.
$user = User::getSilent($email);
+ // Wrong email and no user: failure.
+ if (is_null($user) && (!$is_valid_email || !User::isForeignEmailAddress($email))) {
+ $page->trigError('« <strong>' . $email . '</strong> » n\'est pas une adresse email valide.');
+ return;
+ }
+
+ // Deals with xnet accounts.
if (is_null($user) || $user->type == 'xnet') {
// User is of type xnet. There are 3 possible cases:
// * the email is not known yet: we create a new account and
if (Post::has('suggest')) {
if (Post::t('suggest') == 'yes') {
$user = S::user();
- $group = Platal::globals()->asso('nom');
- $request = new AccountReq($user, $hruid, $email, $group);
+ $request = new AccountReq($user, $hruid, $email, Platal::globals()->asso('nom'));
$request->submit();
$page->trigSuccessRedirect('Un email va bien être envoyé à ' . $email . ' pour l\'activation de son compte.',
- $group . '/member/' . $hruid);
+ Platal::globals()->asso('diminutif') . '/member/' . $hruid);
} else {
pl_redirect('member/' . $hruid);
}
if ($globals->asso('notif_unsub')) {
$mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl');
- $admins = $globals->asso()->iterAdmins();
+ $admins = $globals->asso()->iterToNotify();
while ($admin = $admins->next()) {
$mailer->addTo($admin);
}
}
// Update user info
- $email_changed = (!$user->profile() && strtolower($user->forlifeEmail()) != strtolower(Post::v('email')));
- $from_email = $user->forlifeEmail();
if ($user->type == 'virtual' || ($user->type == 'xnet' && !$user->perms)) {
$lastname = Post::s('lastname');
if (Post::s('type') != 'virtual') {
}
XDB::query('UPDATE accounts
SET full_name = {?}, directory_name = {?}, display_name = {?},
- firstname = {?}, lastname = {?}, sex = {?}, email = {?}, type = {?}
+ firstname = {?}, lastname = {?}, sex = {?}, type = {?}
WHERE uid = {?}',
$full_name, $directory_name, Post::t('display_name'), $firstname, $lastname,
- (Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'),
+ (Post::t('sex') == 'male') ? 'male' : 'female',
(Post::t('type') == 'xnet') ? 'xnet' : 'virtual', $user->id());
- } else if (!$user->perms) {
+ }
+
+ // Updates email.
+ $new_email = strtolower(Post::t('email'));
+ if (!$user->perms && require_email_update($user, $new_email)) {
XDB::query('UPDATE accounts
SET email = {?}
WHERE uid = {?}',
- Post::t('email'), $user->id());
- }
- if (require_email_update($user, Post::t('email'))) {
+ $new_email, $user->id());
$listClient = new MMList(S::user());
- $listClient->change_user_email($user->forlifeEmail(), Post::t('email'));
- update_alias_user($user->forlifeEmail(), Post::t('email'));
+ $listClient->change_user_email($user->forlifeEmail(), $new_email);
+ update_alias_user($user->forlifeEmail(), $new_email);
}
if (XDB::affectedRows()) {
$page->trigSuccess('Données de l\'utilisateur mises à jour.');
foreach (Env::v('ml1', array()) as $ml => $state) {
$ask = empty($_REQUEST['ml2'][$ml]) ? 0 : 2;
if ($ask == $state) {
- if ($state && $email_changed) {
- $mmlist->replace_email($ml, $from_email, $user->forlifeEmail());
- $page->trigSuccess("L'abonnement de {$user->fullName()} à $ml@ a été mis à jour.");
- }
continue;
}
if ($state == '1') {
$mmlist->mass_subscribe($ml, Array($user->forlifeEmail()));
$page->trigSuccess("{$user->fullName()} a été abonné à $ml@.");
} else {
- if ($email_changed) {
- $mmlist->mass_unsubscribe($ml, Array($from_email));
- } else {
- $mmlist->mass_unsubscribe($ml, Array($user->forlifeEmail()));
- }
+ $mmlist->mass_unsubscribe($ml, Array($user->forlifeEmail()));
$page->trigSuccess("{$user->fullName()} a été désabonné de $ml@.");
}
}
require_once 'emails.inc.php';
$ask = !empty($_REQUEST['ml4'][$ml]);
list($local_part, ) = explode('@', $ml);
- if($state == $ask) {
- if ($state && $email_changed) {
- update_list_alias($user->id(), $from_email, $local_part, $globals->asso('mail_domain'));
- $page->trigSuccess("L'abonnement de {$user->fullName()} à $ml a été mis à jour.");
- }
- } else if($ask) {
+ if ($ask == $state) {
+ continue;
+ }
+ if ($ask) {
add_to_list_alias($user->id(), $local_part, $globals->asso('mail_domain'));
$page->trigSuccess("{$user->fullName()} a été abonné à $ml.");
} else {