<?php
/***************************************************************************
- * Copyright (C) 2003-2013 Polytechnique.org *
+ * Copyright (C) 2003-2014 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
$filename = $globals->asso('diminutif') . '.csv';
}
$users = $globals->asso()->getMembersFilter(null, new UFO_Name())->getUsers();
+ $admin = may_update();
pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1);
- echo utf8_decode("Nom;Prénom;Sexe;Promotion;Commentaire\n");
+ echo utf8_decode("Nom;Prénom;Sexe;Promotion;Commentaire");
+ if ($admin) {
+ echo utf8_decode(";Société;Poste\n");
+ } else {
+ echo utf8_decode("\n");
+ }
foreach ($users as $user) {
$line = $user->lastName() . ';' . $user->firstName() . ';' . ($user->isFemale() ? 'F' : 'M')
- . ';' . $user->promo() . ';' . strtr($user->group_comm, ';', ',');
+ . ';' . $user->promo() . ';' . strtr($user->group_comm, ';', ',');
+ if ($admin) {
+ if ($user->hasProfile()) {
+ $line .= ';' . $user->profile()->getMainJob()->company->name . ';' . $user->profile()->getMainJob()->description;
+ } else {
+ $line .= ';;';
+ }
+ }
echo utf8_decode($line) . "\n";
}
exit();
$users = array_keys(Env::v('add_users'));
$former_users = XDB::fetchColumn('SELECT uid
FROM group_former_members
- WHERE remember = TRUE AND uid IN {?}',
- $users);
+ WHERE remember = TRUE AND asso_id = {?} AND uid IN {?}',
+ $globals->asso('id'), $users);
$new_users = array_diff($users, $former_users);
foreach ($former_users as $uid) {
$data = array();
foreach ($new_users as $uid) {
- $data[] = XDB::format('({?}, {?})', $globals->asso('id'), $uid);
+ Group::subscribe($globals->asso('id'), $uid);
}
- XDB::rawExecute('INSERT INTO group_members (asso_id, uid)
- VALUES ' . implode(',', $data));
}
if (Env::has('add_nonusers')) {
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, \'xnet\', \'disabled\')',
$hruid, $display_name, $full_name, $directory_name, $sort_name, $firstname, $lastname, $email);
$uid = XDB::insertId();
- XDB::execute('INSERT INTO group_members (asso_id, uid)
- VALUES ({?}, {?})',
- $globals->asso('id'), $uid);
+ Group::subscribe($globals->asso('id'), $uid);
}
}
$this->removeSubscriptionRequest($user->id());
Group::subscribe($globals->asso('id'), $user->id());
- if (XDB::affectedRows() == 1) {
+ if (XDB::affectedRows() == 1 && $user->forlifeEmail()) {
$mailer = new PlMailer();
$mailer->addTo($user->forlifeEmail());
$mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
S::assert_xsrf_token();
$this->removeSubscriptionRequest($user->id());
- $mailer = new PlMailer();
- $mailer->addTo($user->forlifeEmail());
- $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
- $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée');
- $mailer->setTxtBody(Env::v('motif'));
- $mailer->send();
+ if ($user->forlifeEmail()) {
+ $mailer = new PlMailer();
+ $mailer->addTo($user->forlifeEmail());
+ $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
+ $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée');
+ $mailer->setTxtBody(Env::v('motif'));
+ $mailer->send();
+ }
$page->killSuccess("La demande de {$user->fullName()} a bien été refusée.");
} else {
$page->assign('show_form', true);
S::i('uid'), $globals->asso('id'));
$admins = $globals->asso()->iterToNotify();
$admin = $admins->next();
- $to = $admin->bestEmail();
- while ($admin = $admins->next()) {
- $to .= ', ' . $admin->bestEmail();
+ if (!is_null($admin)) {
+ $to = $admin->bestEmail();
+ while ($admin = $admins->next()) {
+ $to .= ', ' . $admin->bestEmail();
+ }
+ } else {
+ $to = '';
}
$append = "\n"
break;
}
}
- http_redirect($_SERVER['HTTP_REFERER']);
+ if (!empty($_SERVER['HTTP_REFERER'])) {
+ http_redirect($_SERVER['HTTP_REFERER']);
+ } else {
+ pl_redirect('');
+ }
}
function handler_admin_annuaire($page)
Group::subscribe($globals->asso('id'), $user->id());
$this->removeSubscriptionRequest($user->id());
+ if ($user->isActive() && $user->bestEmail()) {
+ $mailer = new PlMailer('xnetgrp/forced-subscription.mail.tpl');
+ $mailer->addTo($user->bestEmail());
+ $mailer->assign('group', $globals->asso('nom'));
+ $mailer->assign('anim', S::user()->fullname());
+ $mailer->assign('diminutif', $globals->asso('diminutif'));
+ $mailer->send();
+ }
+
+ // Check if the group has more than 1000 members, if so, disable the "send mail" function.
+ $full_count = XDB::fetchOneCell('SELECT COUNT(*)
+ FROM group_members
+ WHERE asso_id = {?}',
+ $globals->asso('id'));
+ if ($full_count > 999) {
+ XDB::execute(
+ "UPDATE groups
+ SET disable_mails = 1
+ WHERE id = {?}",
+ $globals->asso('id'));
+ }
+
if ($suggest_account_activation) {
pl_redirect('member/suggest/' . $user->login() . '/' . $email . '/' . $globals->asso('nom'));
} else {
$mailer->send();
}
+ $nl = Newsletter::forGroup($globals->asso('shortname'));
+ if (!is_null($nl)) {
+ $nl->unsubscribe(null, S::i('uid'));
+ }
+
$domain = $globals->asso('mail_domain');
if (!$domain) {
return true;
}
}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
?>