<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
'%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/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
+ '%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/photo' => $this->make_hook('photo_announce', AUTH_PUBLIC),
);
}
- function handler_index(&$page, $arg = null)
+ function handler_index($page, $arg = null)
{
global $globals, $platal;
if (!is_null($arg)) {
Env::i('unread'), S::i('uid'));
pl_redirect("#art" . Env::i('unread'));
}
- // XXX: Fix promo_min; promo_max
- $arts = XDB::iterator("SELECT a.*, FIND_IN_SET('photo', a.flags) AS photo
+
+ /* TODO: refines this filter on promotions by using userfilter. */
+ $user = S::user();
+ if ($user->hasProfile()) {
+ $promo = XDB::format('{?}', $user->profile()->entry_year);
+ $minCondition = ' OR promo_min <= ' . $promo;
+ $maxCondition = ' OR promo_max >= ' . $promo;
+ } else {
+ $minCondition = '';
+ $maxCondition = '';
+ }
+ $arts = XDB::iterator('SELECT a.*, FIND_IN_SET(\'photo\', a.flags) AS photo
FROM group_announces AS a
LEFT JOIN group_announces_read AS r ON (r.uid = {?} AND r.announce_id = a.id)
WHERE asso_id = {?} AND expiration >= CURRENT_DATE()
- AND (promo_min = 0 OR promo_min <= {?})
- AND (promo_max = 0 OR promo_max >= {?})
+ AND (promo_min = 0' . $minCondition . ')
+ AND (promo_max = 0' . $maxCondition . ')
AND r.announce_id IS NULL
- ORDER BY a.expiration",
- S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo'));
- $index = XDB::iterator("SELECT a.id, a.titre, r.uid IS NULL AS nonlu
+ ORDER BY a.expiration',
+ S::i('uid'), $globals->asso('id'));
+ $index = XDB::iterator('SELECT a.id, a.titre, r.uid IS NULL AS nonlu
FROM group_announces AS a
LEFT JOIN group_announces_read AS r ON (a.id = r.announce_id AND r.uid = {?})
WHERE asso_id = {?} AND expiration >= CURRENT_DATE()
- AND (promo_min = 0 OR promo_min <= {?})
- AND (promo_max = 0 OR promo_max >= {?})
- ORDER BY a.expiration",
- S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo'));
+ AND (promo_min = 0' . $minCondition . ')
+ AND (promo_max = 0' . $maxCondition . ')
+ ORDER BY a.expiration',
+ S::i('uid'), $globals->asso('id'));
$page->assign('article_index', $index);
} else {
$arts = XDB::iterator("SELECT *, FIND_IN_SET('photo', flags) AS photo
$platal->ns . "rss/rss.xml");
} else {
$page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News",
- $platal->ns . 'rss/'.S::v('hruid') .'/'.S::v('token').'/rss.xml');
+ $platal->ns . 'rss/' . S::v('hruid') . '/' . S::user()->token . '/rss.xml');
}
$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');
exit;
}
- function handler_edit(&$page)
+ function handler_edit($page)
{
global $globals;
$page->changeTpl('xnetgrp/edit.tpl');
$page->trigError('Ni le nom ni le diminutif du groupe ne peuvent être vide.');
return;
}
+ $axDate = make_datetime(Post::v('axDate'));
+ if (Post::t('axDate') != '') {
+ $axDate = make_datetime(Post::v('axDate'))->format('Y-m-d');
+ } else {
+ $axDate = null;
+ }
XDB::execute(
"UPDATE groups
SET nom={?}, diminutif={?}, cat={?}, dom={?},
descr={?}, site={?}, mail={?}, resp={?},
- forum={?}, mail_domain={?}, ax={?}, pub={?},
+ forum={?}, mail_domain={?}, ax={?}, axDate = {?}, pub={?},
sub_url={?}, inscriptible={?}, unsub_url={?},
- flags={?}
+ flags = {?}, welcome_msg = {?}
WHERE id={?}",
Post::v('nom'), Post::v('diminutif'),
- Post::v('cat'), Post::i('dom'),
+ Post::v('cat'), (Post::i('dom') == 0) ? null : Post::i('dom'),
Post::v('descr'), $site,
Post::v('mail'), Post::v('resp'),
Post::v('forum'), Post::v('mail_domain'),
- Post::has('ax'), Post::v('pub'),
+ Post::has('ax'), $axDate, Post::v('pub'),
Post::v('sub_url'), Post::v('inscriptible'),
- Post::v('unsub_url'), $flags, $globals->asso('id'));
+ 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(
"UPDATE groups
SET descr={?}, site={?}, mail={?}, resp={?},
forum={?}, pub= {?}, sub_url={?},
- unsub_url={?},flags={?}
+ unsub_url = {?}, flags = {?}, welcome_msg = {?}
WHERE id={?}",
Post::v('descr'), $site,
Post::v('mail'), Post::v('resp'),
Post::v('forum'), Post::v('pub'),
Post::v('sub_url'), Post::v('unsub_url'),
- $flags, $globals->asso('id'));
+ $flags, Post::t('welcome_msg'),
+ $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);
}
}
- function handler_mail(&$page)
+ function handler_mail($page)
{
global $globals;
$page->changeTpl('xnetgrp/mail.tpl');
- $mmlist = new MMList(S::v('uid'), S::v('password'),
- $globals->asso('mail_domain'));
+ $mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
$page->assign('listes', $mmlist->get_lists());
$page->assign('user', S::user());
- $page->addJsLink('ajax.js');
if (Post::has('send')) {
S::assert_xsrf_token();
}
}
- function handler_forum(&$page, $group = null, $artid = null)
+ function handler_forum($page, $group = null, $artid = null)
{
global $globals;
$page->changeTpl('xnetgrp/forum.tpl');
run_banana($page, 'ForumsBanana', $get);
}
- function handler_annuaire(&$page, $action = null, $subaction = null)
+ function handler_annuaire($page, $action = null, $subaction = null)
{
global $globals;
$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;
}
$users = $uf->getUsers(new PlLimit(NB_PER_PAGE, $ofs * NB_PER_PAGE));
$count = $uf->getTotalCount();
+ $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('only_admin', Env::b('admin'));
}
- 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_content_headers("text/x-csv");
+ pl_cached_content_headers('text/x-csv', 1);
$page->changeTpl('xnetgrp/annuaire-csv.tpl', NO_SKIN);
$page->assign('users', $users);
}
$globals->asso('id'), $uid);
}
- private function validSubscription(User &$user)
+ private function validSubscription(User $user)
{
global $globals;
$this->removeSubscriptionRequest($user->id());
$mailer->setSubject('[' . $globals->asso('nom') . '] Demande d\'inscription');
$message = ($user->isFemale() ? 'Chère' : 'Cher') . " Camarade,\n"
. "\n"
- . " Suite à ta demande d'adhésion à " . $globals->asso('nom') . ",\n"
- . "j'ai le plaisir de t'annoncer que ton inscription a été validée !\n"
+ . " Suite à ta demande d'adhésion à " . $globals->asso('nom')
+ . ", j'ai le plaisir de t'annoncer que ton inscription a été validée !\n"
+ . (is_null($globals->asso('welcome_msg')) ? '' : "\n" . $globals->asso('welcome_msg') . "\n")
. "\n"
. "Bien cordialement,\n"
. "-- \n"
. S::user()->fullName() . '.';
- $mailer->setTxtBody($message);
+ $mailer->setTxtBody(wordwrap($message, 72));
$mailer->send();
}
}
- function handler_subscribe(&$page, $u = null)
+ function handler_subscribe($page, $u = null)
{
global $globals;
$page->changeTpl('xnetgrp/inscrire.tpl');
$uf = New UserFilter(New UFC_Group($globals->asso('id'), true));
$admins = $uf->iterUsers();
$admin = $admins->next();
- $to = $admin->bestalias;
+ $to = $admin->bestEmail();
while ($admin = $admins->next()) {
- $to .= ', ' . $admin->bestalias;
+ $to .= ', ' . $admin->bestEmail();
}
$append = "\n"
}
}
- function handler_subscribe_valid(&$page)
+ function handler_subscribe_valid($page)
{
global $globals;
$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')) {
http_redirect($_SERVER['HTTP_REFERER']);
}
- function handler_admin_annuaire(&$page)
+ function handler_admin_annuaire($page)
{
global $globals;
$page->assign('lists', $lists);
}
- function handler_admin_member_new(&$page, $email = null)
+ function handler_admin_member_new($page, $email = null)
{
global $globals;
$page->changeTpl('xnetgrp/membres-add.tpl');
- $page->addJsLink('ajax.js');
if (is_null($email)) {
return;
S::assert_xsrf_token();
- // Finds or creates account
+ // Finds or creates account: first cases are for users with an account.
if (!User::isForeignEmailAddress($email)) {
- // standard x account
+ // 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("« <strong>$email</strong> » n'est pas une adresse email valide.");
+ $page->trigError('« <strong>' . $email . '</strong> » n\'est pas une adresse email valide.');
return;
}
} else if (Env::v('x') && Env::i('userid')) {
- // user is an x but might not yet be registered
$user = User::getWithUID(Env::i('userid'));
if (!$user) {
- $page->trigError("Utilisateur invalide");
+ $page->trigError('Utilisateur invalide.');
return;
}
- // add email for marketing if unknown
- if ($user->state == 'pending' && Env::v('market')) {
- $market = Marketing::get($user->uid, $email);
- if (!$market) {
- $market = new Marketing($user->uid, $email, 'group', $globals->asso('nom'),
- Env::v('market_from'), S::v('uid'));
- $market->add();
+
+ // User has an account but is not yet registered.
+ if ($user->state == 'pending') {
+ // Add email in account table.
+ XDB::query('UPDATE accounts
+ SET email = {?}
+ WHERE uid = {?} AND email IS NULL',
+ Post::t('email'), $user->id());
+ // Add email for marketing if required.
+ if (Env::v('market')) {
+ $market = Marketing::get($user->uid, $email);
+ if (!$market) {
+ $market = new Marketing($user->uid, $email, 'group', $globals->asso('nom'),
+ Env::v('market_from'), S::v('uid'));
+ $market->add();
+ }
}
}
} else {
- // user is not an x
- $hruid = strtolower(str_replace('@','.',$email).'.ext');
- // might already exists (in another group for example)
+ // 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)) {
- // creates new account: build names from email address
- $display_name = ucwords(strtolower(substr($hruid, strpos('.', $hruid))));
- $full_name = ucwords(strtolower(str_replace('.', ' ',substr($email, strpos('@', $email)))));
- XDB::execute("INSERT INTO accounts (hruid, display_name, full_name, email, type)
- VALUES({?}, {?}, {?}, {?}, 'xnet')",
- $hruid, $display_name, $full_name, $email);
+ $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;
+ }
+ 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);
}
}
+
if ($user) {
- XDB::execute("REPLACE INTO group_members (uid, asso_id)
- VALUES ({?}, {?})",
+ XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id)
+ VALUES ({?}, {?})',
$user->id(), $globals->asso('id'));
$this->removeSubscriptionRequest($user->id());
- pl_redirect("member/" . $user->login());
+ pl_redirect('member/' . $user->login());
}
}
- 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);
}
}
if (empty($users)) {
- list($nom, $prenom) = str_replace(array('-', ' ', "'"), '%', array(Env::t('nom'), Env::t('prenom')));
+ 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($nom)) {
- $cond->addChild(new UFC_Name(Profile::LASTNAME, $nom, UFC_Name::CONTAINS));
+ if (!empty($lastname)) {
+ $cond->addChild(new UFC_Name(Profile::LASTNAME, $lastname, UFC_Name::CONTAINS));
}
- if (!empty($prenom)) {
- $cond->addChild(new UFC_Name(Profile::FIRSTNAME, $prenom, UFC_Name::CONTAINS));
+ if (!empty($firstname)) {
+ $cond->addChild(new UFC_Name(Profile::FIRSTNAME, $firstname, UFC_Name::CONTAINS));
}
- if (Env::i('promo')) {
- $cond->addChild(new UFC_Promo('=', UserFilter::GRADE_ING, Env::i('promo')));
+ if (Env::t('promo')) {
+ $cond->addChild(new UFC_Promo('=', UserFilter::DISPLAY, Env::t('promo')));
}
$uf = new UserFilter($cond);
$users = $uf->getUsers(new PlLimit(30));
$page->assign('users', $users);
}
- function unsubscribe(PlUser &$user)
+ function unsubscribe(PlUser $user)
{
global $globals;
XDB::execute("DELETE FROM group_members
return true;
}
- $mmlist = new MMList($user, $domain);
+ $mmlist = new MMList(S::user(), $domain);
$listes = $mmlist->get_lists($user->forlifeEmail());
$may_update = may_update();
}
}
- 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();
$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);
}
}
- private function changeLogin(PlPage &$page, PlUser &$user, MMList &$mmlist, $login)
+ private function changeLogin(PlPage $page, PlUser $user, MMList $mmlist, $login)
{
- // Search the uid of the user...
+ // Search the user's uid.
$xuser = User::getSilent($login);
if (!$xuser) {
$accounts = User::getPendingAccounts($login);
return false;
}
$xuser = User::getSilent($accounts[0]['uid']);
- $sub = false;
}
if (!$xuser) {
return false;
}
- $user->mergeIn($xuser);
-
- return $xuser->login();
+ if ($user->mergeIn($xuser)) {
+ return $xuser->login();
+ }
+ return $user->login();
}
- function handler_admin_member(&$page, $user)
+ function handler_admin_member($page, $user)
{
global $globals;
return PL_NOT_FOUND;
}
- $mmlist = new MMList($user, $globals->asso('mail_domain'));
+ $mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
if (Post::has('change')) {
S::assert_xsrf_token();
// 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') {
XDB::query('UPDATE accounts
- SET full_name = {?}, display_name = {?}, sex = {?}, email = {?}, type = {?}
+ SET full_name = {?}, directory_name = {?}, display_name = {?},
+ sex = {?}, email = {?}, type = {?}
WHERE uid = {?}',
- Post::v('full_name'), Post::v('display_name'), (Post::v('sex') == 'male')?'male':'female', Post::v('email'), (Post::v('type') == 'xnet')?'xnet':'virtual',
- $user->id());
- if (XDB::affectedRows()) {
- $page->trigSuccess('Données de l\'utilisateur mise à jour.');
- }
+ Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'),
+ (Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'),
+ (Post::t('type') == 'xnet') ? 'xnet' : 'virtual', $user->id());
+ } else if (!$user->perms) {
+ XDB::query('UPDATE accounts
+ SET email = {?}
+ WHERE uid = {?}',
+ Post::t('email'), $user->id());
+ }
+ if (XDB::affectedRows()) {
+ $page->trigSuccess('Données de l\'utilisateur mise à jour.');
}
// Update group params for user
$perms = Post::v('group_perms');
$comm = Post::t('comm');
- if ($user->group_perms != $perms || $user->group_comm != $comm) {
+ $position = (Post::t('group_position') == '') ? null : Post::v('group_position');
+ if ($user->group_perms != $perms || $user->group_comm != $comm || $user->group_position != $position) {
XDB::query('UPDATE group_members
- SET perms = {?}, comm = {?}
+ SET perms = {?}, comm = {?}, position = {?}
WHERE uid = {?} AND asso_id = {?}',
- ($perms == 'admin') ? 'admin' : 'membre', $comm,
+ ($perms == 'admin') ? 'admin' : 'membre', $comm, $position,
$user->id(), $globals->asso('id'));
- if ($perms != $user->group_perms) {
- $page->trigSuccess('Permissions modifiées !');
- }
- if ($comm != $user->group_comm) {
- $page->trigSuccess('Commentaire mis à jour.');
+ if (XDB::affectedRows()) {
+ if ($perms != $user->group_perms) {
+ $page->trigSuccess('Permissions modifiées !');
+ }
+ if ($comm != $user->group_comm) {
+ $page->trigSuccess('Commentaire mis à jour.');
+ }
+ if ($position != $user->group_position) {
+ $page->trigSuccess('Poste mis à jour.');
+ }
}
}
// 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);
+ update_list_alias($user, $from_email, $ml, $globals->asso('mail_domain'));
$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);
+ add_to_list_alias($user, $ml, $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, $ml, $globals->asso('mail_domain'));
$page->trigSuccess("{$user->fullName()} a été désabonné de $ml.");
}
}
}
+ $res = XDB::rawFetchAllAssoc('SHOW COLUMNS FROM group_members LIKE \'position\'');
+ $positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']);
+
$page->assign('user', $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));
}
- function handler_rss(&$page, $user = null, $hash = null)
+ function handler_rss(PlPage $page, PlUser $user)
{
global $globals;
$page->assign('asso', $globals->asso());
$this->load('feed.inc.php');
$feed = new XnetGrpEventFeed();
- return $feed->run($page, $user, $hash, false);
+ 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;
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
exit;
}
- function handler_edit_announce(&$page, $aid = null)
+ function handler_edit_announce($page, $aid = null)
{
global $globals, $platal;
$page->changeTpl('xnetgrp/announce-edit.tpl');
$aid, $imgtype, $imgx, $imgy, $upload->getContents());
}
if ($art['xorg']) {
- require_once('validations.inc.php');
$article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext,
$art['promo_min'], $art['promo_max'], $art['expiration'], "", S::user(),
$upload);
$upload->rm();
}
if ($art['nl']) {
- require_once('validations.inc.php');
$article = new NLReq(S::user(), $globals->asso('nom') . " : " .$art['titre'],
$art['texte'], $art['contact_html']);
$article->submit();
$art['id'], $globals->asso('id'));
if ($art['photo'] && $upload->exists()) {
list($imgx, $imgy, $imgtype) = $upload->imageInfo();
- XDB::execute("REPLACE INTO group_announces_photo
- SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}",
- $aid, $imgtype, $imgx, $imgy, $upload->getContents());
+ XDB::execute('INSERT INTO group_announces_photo (eid, attachmime, attach, x, y)
+ VALUES ({?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)',
+ $aid, $imgtype, $upload->getContents(), $imgx, $imgy);
$upload->rm();
}
}
$page->assign_by_ref('upload', $upload);
}
- function handler_admin_announce(&$page)
+ function handler_admin_announce($page)
{
global $globals;
$page->changeTpl('xnetgrp/announce-admin.tpl');