X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp.php;h=47f4a8da0e845409be2c7bf8a477a4fb4b6a4972;hb=c9566e01c2add8f12a858abe0fbb0bc6b8e3c0d4;hp=68e0d3d8b0f97438451fcb0015586e32df63b5f9;hpb=a1c554a92888e0b017ba362817a67cc2849a9154;p=platal.git
diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php
index 68e0d3d..47f4a8d 100644
--- a/modules/xnetgrp.php
+++ b/modules/xnetgrp.php
@@ -29,34 +29,38 @@ class XnetGrpModule extends PLModule
'%grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC),
'%grp/logo' => $this->make_hook('logo', AUTH_PUBLIC),
'%grp/site' => $this->make_hook('site', AUTH_PUBLIC),
- '%grp/edit' => $this->make_hook('edit', AUTH_MDP, 'groupadmin'),
- '%grp/mail' => $this->make_hook('mail', AUTH_MDP, 'groupadmin'),
- '%grp/forum' => $this->make_hook('forum', AUTH_MDP, 'groupmember'),
- '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP, 'groupannu'),
- '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP, 'groupmember:groupannu'),
- '%grp/annuaire/csv' => $this->make_hook('csv', AUTH_MDP, 'groupmember:groupannu'),
- '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP, 'groupannu'),
- '%grp/geoloc' => $this->make_hook('geoloc', AUTH_MDP, 'groupannu'),
- '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP),
- '%grp/subscribe/valid' => $this->make_hook('subscribe_valid', AUTH_MDP, 'groupadmin'),
- '%grp/unsubscribe' => $this->make_hook('unsubscribe', AUTH_MDP, 'groupmember'),
-
- '%grp/change_rights' => $this->make_hook('change_rights', AUTH_MDP),
- '%grp/admin/annuaire' => $this->make_hook('admin_annuaire', AUTH_MDP, 'groupadmin'),
- '%grp/member' => $this->make_hook('admin_member', AUTH_MDP, 'groupadmin'),
- '%grp/member/new' => $this->make_hook('admin_member_new', AUTH_MDP, 'groupadmin'),
- '%grp/member/new/ajax' => $this->make_hook('admin_member_new_ajax', AUTH_MDP, 'user', NO_AUTH),
- '%grp/member/del' => $this->make_hook('admin_member_del', AUTH_MDP, 'groupadmin'),
+ '%grp/edit' => $this->make_hook('edit', AUTH_PASSWD, 'groupadmin'),
+ '%grp/mail' => $this->make_hook('mail', AUTH_PASSWD, 'groupadmin'),
+ '%grp/forum' => $this->make_hook('forum', AUTH_PASSWD, 'groupmember'),
+ '%grp/former_users' => $this->make_hook('former_users', AUTH_PASSWD, 'admin'),
+ '%grp/annuaire' => $this->make_hook('annuaire', AUTH_PASSWD, 'groupannu'),
+ '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_PASSWD, 'groupmember:groupannu'),
+ '%grp/annuaire/csv' => $this->make_hook('csv', AUTH_PASSWD, 'groupmember:groupannu'),
+ '%grp/directory/sync' => $this->make_hook('directory_sync', AUTH_PASSWD, 'groupadmin'),
+ '%grp/directory/unact' => $this->make_hook('non_active', AUTH_PASSWD, 'groupadmin'),
+ '%grp/trombi' => $this->make_hook('trombi', AUTH_PASSWD, 'groupannu'),
+ '%grp/geoloc' => $this->make_hook('geoloc', AUTH_PASSWD, 'groupannu'),
+ '%grp/subscribe' => $this->make_hook('subscribe', AUTH_PASSWD, 'groups'),
+ '%grp/subscribe/valid' => $this->make_hook('subscribe_valid', AUTH_PASSWD, 'groupadmin'),
+ '%grp/unsubscribe' => $this->make_hook('unsubscribe', AUTH_PASSWD, 'groupmember'),
+
+ '%grp/change_rights' => $this->make_hook('change_rights', AUTH_PASSWD, 'groups'),
+ '%grp/admin/annuaire' => $this->make_hook('admin_annuaire', AUTH_PASSWD, 'groupadmin'),
+ '%grp/member' => $this->make_hook('admin_member', AUTH_PASSWD, 'groupadmin'),
+ '%grp/member/new' => $this->make_hook('admin_member_new', AUTH_PASSWD, 'groupadmin'),
+ '%grp/member/new/ajax' => $this->make_hook('admin_member_new_ajax', AUTH_PASSWD, 'groups', NO_AUTH),
+ '%grp/member/del' => $this->make_hook('admin_member_del', AUTH_PASSWD, 'groupadmin'),
+ '%grp/member/suggest' => $this->make_hook('admin_member_suggest', AUTH_PASSWD, 'groupadmin'),
'%grp/rss' => $this->make_token_hook('rss', AUTH_PUBLIC),
- '%grp/announce/new' => $this->make_hook('edit_announce', AUTH_MDP, 'groupadmin'),
- '%grp/announce/edit' => $this->make_hook('edit_announce', AUTH_MDP, 'groupadmin'),
+ '%grp/announce/new' => $this->make_hook('edit_announce', AUTH_PASSWD, 'groupadmin'),
+ '%grp/announce/edit' => $this->make_hook('edit_announce', AUTH_PASSWD, 'groupadmin'),
'%grp/announce/photo' => $this->make_hook('photo_announce', AUTH_PUBLIC),
- '%grp/admin/announces' => $this->make_hook('admin_announce', AUTH_MDP, 'groupadmin'),
+ '%grp/admin/announces' => $this->make_hook('admin_announce', AUTH_PASSWD, 'groupadmin'),
);
}
- function handler_index(&$page, $arg = null)
+ function handler_index($page, $arg = null)
{
global $globals, $platal;
if (!is_null($arg)) {
@@ -116,6 +120,12 @@ class XnetGrpModule extends PLModule
WHERE asso_id = {?} AND expiration >= CURRENT_DATE()
AND FIND_IN_SET('public', flags)",
$globals->asso('id'));
+ $payments = XDB::fetchAllAssoc("SELECT id, text
+ FROM payments
+ WHERE asso_id = {?} AND NOT FIND_IN_SET('old', flags) AND FIND_IN_SET('public', flags)
+ ORDER BY id DESC",
+ $globals->asso('id'));
+ $page->assign('payments', $payments);
}
if (may_update()) {
$subs_valid = XDB::query("SELECT uid
@@ -136,13 +146,13 @@ class XnetGrpModule extends PLModule
$page->assign('articles', $arts);
}
- function handler_logo(&$page)
+ function handler_logo($page)
{
global $globals;
$globals->asso()->getLogo()->send();
}
- function handler_site(&$page)
+ function handler_site($page)
{
global $globals;
$site = $globals->asso('site');
@@ -154,10 +164,19 @@ class XnetGrpModule extends PLModule
exit;
}
- function handler_edit(&$page)
+ function handler_edit($page)
{
global $globals;
$page->changeTpl('xnetgrp/edit.tpl');
+ $error = false;
+
+ if (S::admin()) {
+ $domains = XDB::iterator('SELECT *
+ FROM group_dom
+ ORDER BY nom');
+ $page->assign('domains', $domains);
+ $page->assign('super', true);
+ }
if (Post::has('submit')) {
S::assert_xsrf_token();
@@ -173,17 +192,61 @@ class XnetGrpModule extends PLModule
} 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);
if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) {
$page->trigError('Le domaine doit être un FQDN (aucune modification effectuée) !!!');
- return;
+ $error = true;
}
if (Post::t('nom') == '' || Post::t('diminutif') == '') {
$page->trigError('Ni le nom ni le diminutif du groupe ne peuvent être vide.');
+ $error = true;
+ }
+ if ($error) {
+ $page->assign('nom', Post::t('nom'));
+ $page->assign('diminutif', Post::t('diminutif'));
+ $page->assign('mail_domain', Post::t('mail_domain'));
+ $page->assign('cat', Post::v('cat'));
+ $page->assign('dom', Post::v('dom'));
+ $page->assign('ax', Post::v('ax'));
+ $page->assign('axDate', Post::t('axDate'));
+ $page->assign('site', $site);
+ $page->assign('resp', Post::t('resp'));
+ $page->assign('mail', Post::t('mail'));
+ $page->assign('phone', Post::t('phone'));
+ $page->assign('fax', Post::t('fax'));
+ $page->assign('address', Post::t('address'));
+ $page->assign('forum', Post::t('forum'));
+ $page->assign('inscriptible', Post::v('inscriptible'));
+ $page->assign('sub_url', Post::t('sub_url'));
+ $page->assign('unsub_url', Post::t('unsub_url'));
+ $page->assign('welcome_msg', Post::t('welcome_msg'));
+ $page->assign('pub', Post::v('pub'));
+ $page->assign('notif_unsub', Post::i('notif_unsub'));
+ $page->assign('descr', Post::t('descr'));
+ $page->assign('error', $error);
return;
}
+
$axDate = make_datetime(Post::v('axDate'));
if (Post::t('axDate') != '') {
$axDate = make_datetime(Post::v('axDate'))->format('Y-m-d');
@@ -208,8 +271,13 @@ class XnetGrpModule extends PLModule
Post::v('unsub_url'), $flags, Post::t('welcome_msg'),
$globals->asso('id'));
if (Post::v('mail_domain')) {
- XDB::execute('INSERT IGNORE INTO virtual_domains (domain) VALUES({?})',
- Post::v('mail_domain'));
+ XDB::execute('INSERT IGNORE INTO email_virtual_domains (name)
+ VALUES ({?})',
+ Post::t('mail_domain'));
+ XDB::execute('UPDATE email_virtual_domains
+ SET aliasing = id
+ WHERE name = {?}',
+ Post::t('mail_domain'));
}
} else {
XDB::execute(
@@ -226,6 +294,16 @@ class XnetGrpModule extends PLModule
$globals->asso('id'));
}
+ Phone::deletePhones(0, Phone::LINK_GROUP, $globals->asso('id'));
+ $phone = new Phone(array('link_type' => 'group', 'link_id' => $globals->asso('id'), 'id' => 0,
+ 'type' => 'fixed', 'display' => Post::v('phone'), 'pub' => 'public'));
+ $fax = new Phone(array('link_type' => 'group', 'link_id' => $globals->asso('id'), 'id' => 1,
+ 'type' => 'fax', 'display' => Post::v('fax'), 'pub' => 'public'));
+ $phone->save();
+ $fax->save();
+ Address::deleteAddresses(null, Address::LINK_GROUP, null, $globals->asso('id'));
+ $address = new Address(array('groupid' => $globals->asso('id'), 'type' => Address::LINK_GROUP, 'text' => Post::v('address')));
+ $address->save();
if ($_FILES['logo']['name']) {
$upload = PlUpload::get($_FILES['logo'], $globals->asso('id'), 'asso.logo', true);
@@ -240,19 +318,36 @@ class XnetGrpModule extends PLModule
}
}
+ 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');
}
- if (S::admin()) {
- $dom = XDB::iterator('SELECT *
- FROM group_dom
- ORDER BY nom');
- $page->assign('dom', $dom);
- $page->assign('super', true);
- }
+ $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('ax', $globals->asso('ax'));
+ $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)
+ function handler_mail($page)
{
global $globals;
@@ -289,7 +384,7 @@ class XnetGrpModule extends PLModule
}
}
- function handler_forum(&$page, $group = null, $artid = null)
+ function handler_forum($page, $group = null, $artid = null)
{
global $globals;
$page->changeTpl('xnetgrp/forum.tpl');
@@ -302,86 +397,235 @@ class XnetGrpModule extends PLModule
run_banana($page, 'ForumsBanana', $get);
}
- function handler_annuaire(&$page, $action = null, $subaction = null)
+ function handler_annuaire($page, $action = null, $subaction = null)
{
global $globals;
- if ($action == 'trombi') {
- __autoload('userset');
- if ($action == 'trombi') {
- $view = new ProfileSet(new UFC_Group($globals->asso('id')));
- } else {
- $view = new UserSet(new UFC_Group($globals->asso('id')));
- }
- $view->addMod('trombi', 'Trombinoscope');
- $view->apply('annuaire', $page, $action, $subaction);
- $page->changeTpl('xnetgrp/annuaire.tpl');
- $count = XDB::fetchOneCell('SELECT COUNT(*)
- FROM group_members
- WHERE asso_id = {?}',
- $globals->asso('id'));
- $page->assign('nb_tot', $count);
- return;
+ __autoload('userset');
+ $admins = false;
+ if ($action == 'admins') {
+ $admins = true;
+ $action = $subaction;
}
-
+ $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');
- $sort = Env::s('order', 'directory_name');
- $ofs = Env::i('offset');
- if ($ofs < 0) {
- $ofs = 0;
- }
-
- $sdesc = $sort{0} == '-';
- $sf = $sdesc ? substr($sort, 1) : $sort;
- if ($sf == 'promo') {
- $se = new UFO_Promo(null, $sdesc);
- } else {
- $se = new UFO_Name($sf, null, null, $sdesc);
- }
+ }
- if (Env::b('admin')) {
- $uf = $globals->asso()->getAdminsFilter(null, $se);
- } else {
- $uf = $globals->asso()->getMembersFilter(null, $se);
- }
- $users = $uf->getUsers(new PlLimit(NB_PER_PAGE, $ofs * NB_PER_PAGE));
- $count = $uf->getTotalCount();
+ function handler_former_users($page)
+ {
+ global $globals;
+ require_once 'userset.inc.php';
- $page->assign('nb_tot', $count);
- $page->assign('pages', floor(($count + NB_PER_PAGE - 1) / NB_PER_PAGE));
- $page->assign('current', $ofs);
- $page->assign('order', $sort);
- $page->assign('users', $users);
- $page->assign('only_admin', Env::b('admin'));
+ $view = new UserSet(new UFC_GroupFormerMember($globals->asso('id')));
+ $view->addMod('groupmember', 'Anciens membres', true, array('noadmin' => true));
+ $view->apply('former_users', $page);
+ $page->changeTpl('xnetgrp/former_users.tpl');
}
- function handler_trombi(&$page)
+ function handler_trombi($page)
{
pl_redirect('annuaire/trombi');
}
- function handler_geoloc(&$page)
+ function handler_geoloc($page)
{
pl_redirect('annuaire/geoloc');
}
- function handler_vcard(&$page, $photos = null)
+ function handler_vcard($page, $photos = null)
{
global $globals;
$vcard = new VCard($photos == 'photos', 'Membre du groupe ' . $globals->asso('nom'));
- $vcard->addProfiles($globals->asso()->getMembersFilter()->getProfiles());
+ $vcard->addProfiles($globals->asso()->getMembersFilter()->getProfiles(null, Profile::FETCH_ALL));
$vcard->show();
}
- function handler_csv(&$page, $filename = null)
+ function handler_csv($page, $filename = null)
{
global $globals;
if (is_null($filename)) {
$filename = $globals->asso('diminutif') . '.csv';
}
- $users = $globals->asso()->getMembersFilter(null, new UFO_Name('directory_name'))->getUsers();
- pl_cached_content_headers('text/x-csv', 1);
- $page->changeTpl('xnetgrp/annuaire-csv.tpl', NO_SKIN);
+ $users = $globals->asso()->getMembersFilter(null, new UFO_Name())->getUsers();
+ 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)
+ {
+ global $globals;
+ require_once 'emails.inc.php';
+
+ $page->changeTpl('xnetgrp/sync.tpl');
+ Platal::load('lists', 'lists.inc.php');
+
+ if (Env::has('add_users')) {
+ S::assert_xsrf_token();
+
+ $users = array_keys(Env::v('add_users'));
+ $former_users = XDB::fetchColumn('SELECT uid
+ FROM group_former_members
+ WHERE remember = TRUE AND uid IN {?}',
+ $users);
+ $new_users = array_diff($users, $former_users);
+
+ foreach ($former_users as $uid) {
+ $user = User::getSilentWithUID($uid);
+ $page->trigWarning($user->fullName() . ' est un ancien membre du groupe qui ne souhaite pas y revenir.');
+ }
+ if (count($former_users) > 1) {
+ $page->trigWarning('S\'ils souhaitent revenir dans le groupe, il faut qu\'ils en fassent la demande sur la page d\'accueil du groupe.');
+ } elseif (count($former_users)) {
+ $page->trigWarning('S\'il souhaite revenir dans le groupe, il faut qu\'il en fasse la demande sur la page d\'accueil du groupe.');
+ }
+
+ $data = array();
+ foreach ($new_users as $uid) {
+ $data[] = XDB::format('({?}, {?})', $globals->asso('id'), $uid);
+ }
+ XDB::rawExecute('INSERT INTO group_members (asso_id, uid)
+ VALUES ' . implode(',', $data));
+ }
+
+ if (Env::has('add_nonusers')) {
+ S::assert_xsrf_token();
+
+ $nonusers = array_keys(Env::v('add_nonusers'));
+ foreach ($nonusers as $email) {
+ if ($user = User::getSilent($email) || !isvalid_email($email)) {
+ continue;
+ }
+
+ list($local_part, $domain) = explode('@', strtolower($email));
+ $hruid = User::makeHrid($local_part, $domain, 'ext');
+ if ($user = User::getSilent($hruid)) {
+ continue;
+ }
+
+ $parts = explode('.', $local_part);
+ if (count($parts) == 1) {
+ $lastname = $display_name = $full_name = $directory_name = ucfirst($local_part);
+ $firstname = '';
+ } else {
+ $firstname = ucfirst($parts[0]);
+ $lastname = ucwords(implode(' ', array_slice($parts, 1)));
+ $display_name = $firstname;
+ $full_name = $firstname . ' ' . $lastname;
+ $directory_name = strtoupper($lastname) . ' ' . $firstname;
+ }
+ XDB::execute('INSERT INTO accounts (hruid, display_name, full_name, directory_name, firstname, lastname, email, type, state)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, \'xnet\', \'disabled\')',
+ $hruid, $display_name, $full_name, $directory_name, $firstname, $lastname, $email);
+ $uid = XDB::insertId();
+ XDB::execute('INSERT INTO group_members (asso_id, uid)
+ VALUES ({?}, {?})',
+ $globals->asso('id'), $uid);
+ }
+ }
+
+ if (Env::has('add_users') || Env::has('add_nonusers')) {
+ $page->trigSuccess('Ajouts réalisés avec succès.');
+ }
+
+ $user = S::user();
+ $client = new MMList($user, $globals->asso('mail_domain'));
+ $lists = $client->get_lists();
+ $members = array();
+ foreach ($lists as $list) {
+ $details = $client->get_members($list['list']);
+ $members = array_merge($members, list_extract_members($details[1]));
+ }
+ $members = array_unique($members);
+ $uids = array();
+ $users = array();
+ $nonusers = array();
+ foreach ($members as $email) {
+ if ($user = User::getSilent($email)) {
+ $uids[] = $user->id();
+ } else {
+ $nonusers[] = $email;
+ }
+ }
+
+ $aliases = iterate_list_alias($globals->asso('mail_domain'));
+ foreach ($aliases as $alias) {
+ list($local_part, $domain) = explode('@', $alias);
+ $aliases_members = list_alias_members($local_part, $domain);
+ $users = array_merge($users, $aliases_members['users']);
+ $nonusers = array_merge($nonusers, $aliases_members['nonusers']);
+ }
+ foreach ($users as $user) {
+ $uids[] = $user->id();
+ }
+ $nonusers = array_unique($nonusers);
+ $uids = array_unique($uids);
+ if (count($uids)) {
+ $uids = XDB::fetchColumn('SELECT a.uid
+ FROM accounts AS a
+ WHERE a.uid IN {?} AND NOT EXISTS (SELECT *
+ FROM group_members AS g
+ WHERE a.uid = g.uid AND g.asso_id = {?})',
+ $uids, $globals->asso('id'));
+
+ $users = User::getBulkUsersWithUIDs($uids);
+ usort($users, 'User::compareDirectoryName');
+ } else {
+ $users = array();
+ }
+ sort($nonusers);
+
+ $page->assign('users', $users);
+ $page->assign('nonusers', $nonusers);
+ }
+
+ function handler_non_active($page)
+ {
+ global $globals;
+ $page->changeTpl('xnetgrp/non_active.tpl');
+
+ $uids = XDB::fetchColumn('SELECT g.uid
+ FROM group_members AS g
+ INNER JOIN accounts AS a ON (a.uid = g.uid)
+ LEFT JOIN register_pending_xnet AS p ON (p.uid = g.uid)
+ WHERE a.uid = g.uid AND g.asso_id = {?} AND a.type = \'xnet\' AND a.state = \'disabled\' AND p.uid IS NULL',
+ $globals->asso('id'));
+ foreach ($uids as $key => $uid) {
+ if (AccountReq::isPending($uid) || BulkAccountsReq::isPending($uid)) {
+ unset($uids[$key]);
+ }
+ }
+
+ if (Post::has('enable_accounts')) {
+ S::assert_xsrf_token();
+
+ $uids_to_enable = array_intersect(array_keys(Post::v('enable_accounts')), $uids);
+
+ $user = S::user();
+ $group = Platal::globals()->asso('nom');
+ $request = new BulkAccountsReq($user, $uids_to_enable, $group);
+ $request->submit();
+ $page->trigSuccess('Un email va bientôt être envoyé aux personnes sélectionnées pour l\'activation de leur compte.');
+
+ foreach ($uids as $key => $uid) {
+ if (in_array($uid, $uids_to_enable)) {
+ unset($uids[$key]);
+ }
+ }
+ }
+
+ $users = User::getBulkUsersWithUIDs($uids);
$page->assign('users', $users);
}
@@ -393,13 +637,12 @@ class XnetGrpModule extends PLModule
$globals->asso('id'), $uid);
}
- private function validSubscription(User &$user)
+ private function validSubscription(User $user)
{
global $globals;
$this->removeSubscriptionRequest($user->id());
- XDB::execute("INSERT IGNORE INTO group_members (asso_id, uid)
- VALUES ({?}, {?})",
- $globals->asso('id'), $user->id());
+ Group::subscribe($globals->asso('id'), $user->id());
+
if (XDB::affectedRows() == 1) {
$mailer = new PlMailer();
$mailer->addTo($user->forlifeEmail());
@@ -419,7 +662,7 @@ class XnetGrpModule extends PLModule
}
}
- function handler_subscribe(&$page, $u = null)
+ function handler_subscribe($page, $u = null)
{
global $globals;
$page->changeTpl('xnetgrp/inscrire.tpl');
@@ -497,18 +740,20 @@ class XnetGrpModule extends PLModule
XDB::execute("INSERT INTO group_member_sub_requests (asso_id, uid, ts, reason)
VALUES ({?}, {?}, NOW(), {?})",
$globals->asso('id'), S::i('uid'), Post::v('message'));
- $uf = New UserFilter(New UFC_Group($globals->asso('id'), true));
- $admins = $uf->iterUsers();
+ XDB::execute('DELETE FROM group_former_members
+ WHERE uid = {?} AND asso_id = {?}',
+ S::i('uid'), $globals->asso('id'));
+ $admins = $globals->asso()->iterToNotify();
$admin = $admins->next();
- $to = $admin->bestalias;
+ $to = $admin->bestEmail();
while ($admin = $admins->next()) {
- $to .= ', ' . $admin->bestalias;
+ $to .= ', ' . $admin->bestEmail();
}
$append = "\n"
. "-- \n"
. "Ce message a été envoyé suite à la demande d'inscription de\n"
- . S::user()->fullName() . ' (X' . S::v('promo') . ")\n"
+ . S::user()->fullName(true) . "\n"
. "Via le site www.polytechnique.net. Tu peux choisir de valider ou\n"
. "de refuser sa demande d'inscription depuis la page :\n"
. "http://www.polytechnique.net/" . $globals->asso("diminutif") . "/subscribe/" . S::user()->login() . "\n"
@@ -534,7 +779,7 @@ class XnetGrpModule extends PLModule
}
}
- function handler_subscribe_valid(&$page)
+ function handler_subscribe_valid($page)
{
global $globals;
@@ -563,7 +808,7 @@ class XnetGrpModule extends PLModule
$page->assign('valid', $it);
}
- function handler_change_rights(&$page)
+ function handler_change_rights($page)
{
if (Env::has('right') && (may_update() || S::suid())) {
switch (Env::v('right')) {
@@ -590,7 +835,7 @@ class XnetGrpModule extends PLModule
http_redirect($_SERVER['HTTP_REFERER']);
}
- function handler_admin_annuaire(&$page)
+ function handler_admin_annuaire($page)
{
global $globals;
@@ -630,7 +875,7 @@ class XnetGrpModule extends PLModule
$page->assign('lists', $lists);
}
- function handler_admin_member_new(&$page, $email = null)
+ function handler_admin_member_new($page, $email = null)
{
global $globals;
@@ -641,21 +886,17 @@ class XnetGrpModule extends PLModule
}
S::assert_xsrf_token();
+ $suggest_account_activation = false;
- // Finds or creates account: first cases are for users with an account.
- if (!User::isForeignEmailAddress($email)) {
- // Standard account
- $user = User::get($email);
- } else if (!isvalid_email($email)) {
- // email might not be a regular email but an alias or a hruid
- $user = User::get($email);
- if (!$user) {
- // need a valid email address
- $page->trigError('« ' . $email . ' » n\'est pas une adresse email valide.');
- return;
- }
- } else if (Env::v('x') && Env::i('userid')) {
- $user = User::getWithUID(Env::i('userid'));
+ // FS#703 : $_GET is urldecoded twice, hence
+ // + (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);
+
+ // 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.');
return;
@@ -679,42 +920,124 @@ class XnetGrpModule extends PLModule
}
}
} else {
- // User is of type xnet.
- list($mbox, $domain) = explode('@', strtolower($email));
- $hruid = User::makeHrid($mbox, $domain, 'ext');
- // User might already have an account (in another group for example).
- $user = User::get($hruid);
-
- // If the user has no account yet, creates new account: build names from email address.
- if (empty($user)) {
- $parts = explode('.', $mbox);
- if (count($parts) == 1) {
- $display_name = $full_name = $directory_name = ucfirst($mbox);
- } else {
- $firstname = ucfirst($parts[0]);
- $lastname = ucwords(implode(' ', array_slice($parts, 1)));
- $display_name = $firstname;
- $full_name = "$firstname $lastname";
- $directory_name = strtoupper($lastname) . " " . $firstname;
+ $user = User::getSilent($email);
+
+ // Wrong email and no user: failure.
+ if (is_null($user) && (!$is_valid_email || !User::isForeignEmailAddress($email))) {
+ $page->trigError('« ' . $email . ' » 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
+ // propose to send an email to the user so he can activate
+ // his account,
+ // * the email is known but the user was not contacted in order to
+ // activate yet: we propose to send an email to the user so he
+ // can activate his account,
+ // * the email is known and the user was already contacted or has
+ // an active account: nothing to be done.
+ list($mbox, $domain) = explode('@', strtolower($email));
+ $hruid = User::makeHrid($mbox, $domain, 'ext');
+ // User might already have an account (in another group for example).
+ $user = User::getSilent($hruid);
+
+ // If the user has no account yet, creates new account: build names from email address.
+ if (empty($user)) {
+ $parts = explode('.', $mbox);
+ if (count($parts) == 1) {
+ $lastname = $display_name = $full_name = $directory_name = ucfirst($mbox);
+ $firstname = '';
+ } else {
+ $firstname = ucfirst($parts[0]);
+ $lastname = ucwords(implode(' ', array_slice($parts, 1)));
+ $display_name = $firstname;
+ $full_name = "$firstname $lastname";
+ $directory_name = strtoupper($lastname) . " " . $firstname;
+ }
+ XDB::execute('INSERT INTO accounts (hruid, display_name, full_name, directory_name, firstname, lastname, email, type, state)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, \'xnet\', \'disabled\')',
+ $hruid, $display_name, $full_name, $directory_name, $firstname, $lastname, $email);
+ $user = User::getSilent($hruid);
}
- XDB::execute('INSERT INTO accounts (hruid, display_name, full_name, directory_name,
- email, type)
- VALUES ({?}, {?}, {?}, {?}, {?}, \'xnet\')',
- $hruid, $display_name, $full_name, $directory_name, $email);
- $user = User::get($hruid);
+
+ $suggest_account_activation = $this->suggest($user);
}
}
if ($user) {
- XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id)
- VALUES ({?}, {?})',
- $user->id(), $globals->asso('id'));
+ // First check if the user used to be in this group.
+ XDB::rawExecute('DELETE FROM group_former_members
+ WHERE remember AND DATE_SUB(NOW(), INTERVAL 1 YEAR) > unsubsciption_date');
+ $former_member = XDB::fetchOneCell('SELECT remember
+ FROM group_former_members
+ WHERE uid = {?} AND asso_id = {?}',
+ $user->id(), $globals->asso('id'));
+ if ($former_member === 1) {
+ $page->trigError($user->fullName() . ' est un ancien membre du groupe qui ne souhaite pas y revenir. S\'il souhaite revenir dans le groupe, il faut qu\'il en fasse la demande sur la page d\'accueil du groupe.');
+ return;
+ } elseif (!is_null($former_member) && Post::i('force_continue') == 0) {
+ $page->trigWarning($user->fullName() . ' est un ancien membre du groupe qui s\'est récemment désinscrit. Malgré cela, si tu penses qu\'il souhaite revenir, cliquer sur « Ajouter » l\'ajoutera bien au groupe cette fois.');
+ $page->assign('force_continue', 1);
+ return;
+ }
+
+ Group::subscribe($globals->asso('id'), $user->id());
$this->removeSubscriptionRequest($user->id());
- pl_redirect('member/' . $user->login());
+ if ($suggest_account_activation) {
+ pl_redirect('member/suggest/' . $user->login() . '/' . $email . '/' . $globals->asso('nom'));
+ } else {
+ pl_redirect('member/' . $user->login());
+ }
+ }
+ }
+
+ // Check if the user has a pending or active account, and thus if we should her account's activation.
+ private function suggest(PlUser $user)
+ {
+ $active = XDB::fetchOneCell('SELECT state = \'active\'
+ FROM accounts
+ WHERE uid = {?}',
+ $user->id());
+ $pending = XDB::fetchOneCell('SELECT uid
+ FROM register_pending_xnet
+ WHERE uid = {?}',
+ $user->id());
+ $requested = AccountReq::isPending($user->id()) || BulkAccountsReq::isPending($user->id());
+
+ if ($active || $pending || $requested) {
+ return false;
+ }
+ return true;
+ }
+
+ function handler_admin_member_suggest($page, $hruid, $email)
+ {
+ $page->changeTpl('xnetgrp/membres-suggest.tpl');
+
+ // FS#703 : $_GET is urldecoded twice, hence
+ // + (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);
+
+ if (Post::has('suggest')) {
+ if (Post::t('suggest') == 'yes') {
+ $user = S::user();
+ $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.',
+ Platal::globals()->asso('diminutif') . '/member/' . $hruid);
+ } else {
+ pl_redirect('member/' . $hruid);
+ }
}
+ $page->assign('email', $email);
+ $page->assign('hruid', $hruid);
}
- function handler_admin_member_new_ajax(&$page)
+ function handler_admin_member_new_ajax($page)
{
pl_content_headers("text/html");
$page->changeTpl('xnetgrp/membres-new-search.tpl', NO_SKIN);
@@ -729,10 +1052,10 @@ class XnetGrpModule extends PLModule
list($lastname, $firstname) = str_replace(array('-', ' ', "'"), '%', array(Env::t('nom'), Env::t('prenom')));
$cond = new PFC_And(new PFC_Not(new UFC_Registered()));
if (!empty($lastname)) {
- $cond->addChild(new UFC_Name(Profile::LASTNAME, $lastname, UFC_Name::CONTAINS));
+ $cond->addChild(new UFC_NameTokens($lastname, array(), false, false, Profile::LASTNAME));
}
if (!empty($firstname)) {
- $cond->addChild(new UFC_Name(Profile::FIRSTNAME, $firstname, UFC_Name::CONTAINS));
+ $cond->addChild(new UFC_NameTokens($firstname, array(), false, false, Profile::FIRSTNAME));
}
if (Env::t('promo')) {
$cond->addChild(new UFC_Promo('=', UserFilter::DISPLAY, Env::t('promo')));
@@ -747,16 +1070,14 @@ class XnetGrpModule extends PLModule
$page->assign('users', $users);
}
- function unsubscribe(PlUser &$user)
+ function unsubscribe(PlUser $user, $remember = false)
{
global $globals;
- XDB::execute("DELETE FROM group_members
- WHERE uid = {?} AND asso_id = {?}",
- $user->id(), $globals->asso('id'));
+ Group::unsubscribe($globals->asso('id'), $user->id(), $remember);
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);
}
@@ -793,24 +1114,23 @@ class XnetGrpModule extends PLModule
}
}
- XDB::execute("DELETE FROM virtual_redirect
- USING virtual_redirect
- INNER JOIN virtual USING(vid)
- WHERE redirect={?} AND alias LIKE {?}",
- $user->forlifeEmail(), '%@'.$domain);
+ XDB::execute('DELETE v
+ FROM email_virtual AS v
+ INNER JOIN email_virtual_domains AS d ON (v.domain = d.id)
+ WHERE v.redirect = {?} AND d.name = {?}',
+ $user->forlifeEmail(), $domain);
return !$warning;
}
- function handler_unsubscribe(&$page)
+ function handler_unsubscribe($page)
{
$page->changeTpl('xnetgrp/membres-del.tpl');
$user = S::user();
- $uid = S::user()->id();
- if (empty($uid)) {
+ if (empty($user)) {
return PL_NOT_FOUND;
}
$page->assign('self', true);
- $page->assign('user', $uid);
+ $page->assign('user', $user);
if (!Post::has('confirm')) {
return;
@@ -818,21 +1138,36 @@ class XnetGrpModule extends PLModule
S::assert_xsrf_token();
}
- if ($this->unsubscribe($user)) {
- $page->trigSuccess('Vous avez été désinscrit du groupe avec succès.');
+ $hasSingleGroup = ($user->groupCount() == 1);
+
+ if ($this->unsubscribe($user, Post::b('remember'))) {
+ $page->trigSuccess('Tu as été désinscrit du groupe avec succès.');
} else {
- $page->trigWarning('Vous avez été désinscrit du groupe, mais des erreurs se sont produites lors des désinscriptions des alias et des listes de diffusion.');
+ $page->trigWarning('Tu as été désinscrit du groupe, mais des erreurs se sont produites lors des désinscriptions des alias et des listes de diffusion.');
+ }
+
+ // If user is of type xnet account and this was her last group, disable the account.
+ if ($user->type == 'xnet' && $hasSingleGroup) {
+ $user->clear(true);
}
$page->assign('is_member', is_member(true));
}
- function handler_admin_member_del(&$page, $user = null)
+ function handler_admin_member_del($page, $user = null)
{
$page->changeTpl('xnetgrp/membres-del.tpl');
$user = User::getSilent($user);
if (empty($user)) {
return PL_NOT_FOUND;
}
+
+ global $globals;
+
+ if (!$user->inGroup($globals->asso('id'))) {
+ pl_redirect('annuaire');
+ }
+
+ $page->assign('self', false);
$page->assign('user', $user);
if (!Post::has('confirm')) {
@@ -841,14 +1176,21 @@ class XnetGrpModule extends PLModule
S::assert_xsrf_token();
}
+ $hasSingleGroup = ($user->groupCount() == 1);
+
if ($this->unsubscribe($user)) {
$page->trigSuccess("{$user->fullName()} a été désinscrit du groupe !");
} else {
$page->trigWarning("{$user->fullName()} a été désinscrit du groupe, mais des erreurs subsistent !");
}
+
+ // If user is of type xnet account and this was her last group, disable the account.
+ if ($user->type == 'xnet' && $hasSingleGroup) {
+ $user->clear(true);
+ }
}
- private function changeLogin(PlPage &$page, PlUser &$user, MMList &$mmlist, $login)
+ private function changeLogin(PlPage $page, PlUser $user, $login)
{
// Search the user's uid.
$xuser = User::getSilent($login);
@@ -874,49 +1216,94 @@ class XnetGrpModule extends PLModule
return $user->login();
}
- function handler_admin_member(&$page, $user)
+ function handler_admin_member($page, $user)
{
global $globals;
- $page->changeTpl('xnetgrp/membres-edit.tpl');
-
$user = User::getSilent($user);
if (empty($user)) {
return PL_NOT_FOUND;
}
+ if (!$user->inGroup($globals->asso('id'))) {
+ pl_redirect('annuaire');
+ }
+
+ $page->changeTpl('xnetgrp/membres-edit.tpl');
+
$mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
if (Post::has('change')) {
+ require_once 'emails.inc.php';
S::assert_xsrf_token();
// Convert user status to X
if (!Post::blank('login_X')) {
- $forlife = $this->changeLogin($page, $user, $mmlist, Post::t('login_X'));
+ $forlife = $this->changeLogin($page, $user, Post::t('login_X'));
if ($forlife) {
pl_redirect('member/' . $forlife);
}
}
// Update user info
- $email_changed = (!$user->profile() && strtolower($user->forlifeEmail()) != strtolower(Post::v('email')));
- $from_email = $user->forlifeEmail();
- if (!$user->profile()) {
+ if ($user->type == 'virtual' || ($user->type == 'xnet' && !$user->perms)) {
+ $lastname = Post::s('lastname');
+ if (Post::s('type') != 'virtual') {
+ $firstname = Post::s('firstname');
+ $full_name = $firstname . ' ' . $lastname;
+ $directory_name = mb_strtoupper($lastname) . ' ' . $firstname;
+ } else {
+ $firstname = '';
+ $full_name = $lastname;
+ $directory_name = mb_strtoupper($lastname);
+ }
XDB::query('UPDATE accounts
SET full_name = {?}, directory_name = {?}, display_name = {?},
- sex = {?}, email = {?}, type = {?}
+ firstname = {?}, lastname = {?}, sex = {?}, type = {?}
WHERE uid = {?}',
- Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'),
- (Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'),
+ $full_name, $directory_name, Post::t('display_name'), $firstname, $lastname,
+ (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());
+ $new_email, $user->id());
+ $listClient = new MMList(S::user());
+ $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 mise à jour.');
+ $page->trigSuccess('Données de l\'utilisateur mises à jour.');
+ }
+
+ if (($user->type == 'xnet' && !$user->perms)) {
+ if (Post::b('suggest')) {
+ $request = new AccountReq(S::user(), $user->hruid, Post::t('email'), $globals->asso('nom'));
+ $request->submit();
+ $page->trigSuccess('Le compte va bientôt être activé.');
+ }
+ if (Post::b('again')) {
+ $data = XDB::fetchOneAssoc('SELECT hash, group_name, sender_name, email
+ FROM register_pending_xnet
+ WHERE uid = {?}',
+ $user->id());
+
+ $mailer = new PlMailer('xnet/account.mail.tpl');
+ $mailer->addCc('validation+xnet_account@polytechnique.org');
+ $mailer->setTo($data['email']);
+ $mailer->assign('hash', $data['hash']);
+ $mailer->assign('email', $data['email']);
+ $mailer->assign('group', $data['group_name']);
+ $mailer->assign('sender_name', $data['sender_name']);
+ $mailer->assign('again', true);
+ $mailer->send();
+ $page->trigSuccess('Relance effectuée avec succès.');
+ }
}
// Update group params for user
@@ -949,10 +1336,6 @@ class XnetGrpModule extends PLModule
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') {
@@ -963,52 +1346,61 @@ class XnetGrpModule extends PLModule
$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@.");
}
}
// Change subscriptioin to aliases
foreach (Env::v('ml3', array()) as $ml => $state) {
+ require_once 'emails.inc.php';
$ask = !empty($_REQUEST['ml4'][$ml]);
- if($state == $ask) {
- if ($state && $email_changed) {
- XDB::query("UPDATE virtual_redirect AS vr, virtual AS v
- SET vr.redirect = {?}
- WHERE vr.vid = v.vid AND v.alias = {?} AND vr.redirect = {?}",
- $user->forlifeEmail(), $ml, $from_email);
- $page->trigSuccess("L'abonnement de {$user->fullName()} à $ml a été mis à jour.");
- }
- } else if($ask) {
- XDB::query("INSERT INTO virtual_redirect (vid,redirect)
- SELECT vid,{?} FROM virtual WHERE alias={?}",
- $user->forlifeEmail(), $ml);
+ list($local_part, ) = explode('@', $ml);
+ 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 {
- XDB::query("DELETE FROM virtual_redirect
- USING virtual_redirect
- INNER JOIN virtual USING(vid)
- WHERE redirect={?} AND alias={?}",
- $from_email, $ml);
+ delete_from_list_alias($user->id(), $local_part, $globals->asso('mail_domain'));
$page->trigSuccess("{$user->fullName()} a été désabonné de $ml.");
}
}
+
+ if ($globals->asso('has_nl')) {
+ $nl = NewsLetter::forGroup($globals->asso('shortname'));
+ // Updates group's newsletter subscription.
+ if (Post::i('newsletter') == 1) {
+ $nl->subscribe($user);
+ } else {
+ $nl->unsubscribe(null, $user->id());
+ }
+ }
}
$res = XDB::rawFetchAllAssoc('SHOW COLUMNS FROM group_members LIKE \'position\'');
$positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']);
+ if ($globals->asso('has_nl')) {
+ $nl = NewsLetter::forGroup($globals->asso('shortname'));
+ $nl_registered = $nl->subscriptionState($user);
+ } else {
+ $nl_registered = false;
+ }
$page->assign('user', $user);
+ $page->assign('suggest', $this->suggest($user));
$page->assign('listes', $mmlist->get_lists($user->forlifeEmail()));
- $page->assign('alias', $user->emailAliases($globals->asso('mail_domain'), 'user', true));
+ $page->assign('alias', $user->emailGroupAliases($globals->asso('mail_domain')));
$page->assign('positions', explode(',', $positions));
+ $page->assign('nl_registered', $nl_registered);
+ $page->assign('pending_xnet_account', XDB::fetchOneCell('SELECT 1
+ FROM register_pending_xnet
+ WHERE uid = {?}',
+ $user->id()));
}
- function handler_rss(PlPage& $page, PlUser& $user)
+ function handler_rss(PlPage $page, PlUser $user)
{
global $globals;
$page->assign('asso', $globals->asso());
@@ -1018,7 +1410,7 @@ class XnetGrpModule extends PLModule
return $feed->run($page, $user, false);
}
- private function upload_image(PlPage &$page, PlUpload &$upload)
+ private function upload_image(PlPage $page, PlUpload $upload)
{
if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
return true;
@@ -1030,14 +1422,14 @@ class XnetGrpModule extends PLModule
$page->trigError('Le fichier n\'est pas une image valide au format JPEG, GIF ou PNG.');
$upload->rm();
return false;
- } elseif (!$upload->resizeImage(200, 300, 100, 100, 32284)) {
+ } elseif (!$upload->resizeImage(80, 100, 100, 100, 32284)) {
$page->trigError('Impossible de retraiter l\'image');
return false;
}
return true;
}
- function handler_photo_announce(&$page, $eid = null) {
+ function handler_photo_announce($page, $eid = null) {
if ($eid) {
$res = XDB::query('SELECT *
FROM group_announces_photo
@@ -1062,7 +1454,7 @@ class XnetGrpModule extends PLModule
exit;
}
- function handler_edit_announce(&$page, $aid = null)
+ function handler_edit_announce($page, $aid = null)
{
global $globals, $platal;
$page->changeTpl('xnetgrp/announce-edit.tpl');
@@ -1142,13 +1534,13 @@ class XnetGrpModule extends PLModule
if (!empty($art['contact_html'])) {
$fulltext .= "\n\n'''Contacts :'''\\\\\n" . $art['contact_html'];
}
- $post = null;/*
+ $post = null;
if ($globals->asso('forum')) {
require_once 'banana/forum.inc.php';
$banana = new ForumsBanana(S::user());
$post = $banana->post($globals->asso('forum'), null,
$art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80));
- }*/
+ }
XDB::query('INSERT INTO group_announces (uid, asso_id, create_date, titre, texte, contacts,
expiration, promo_min, promo_max, flags, post_id)
VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
@@ -1227,7 +1619,7 @@ class XnetGrpModule extends PLModule
$page->assign_by_ref('upload', $upload);
}
- function handler_admin_announce(&$page)
+ function handler_admin_announce($page)
{
global $globals;
$page->changeTpl('xnetgrp/announce-admin.tpl');