function event_change_shortname($page, $eid, $old, $new) { global $globals; require_once 'emails.inc.php'; if (is_null($old)) { $old = ''; } // Quelques vérifications sur l'alias (caractères spéciaux) if ($new && !preg_match("/^[a-zA-Z0-9\\-.]{3,20}\$/", $new)) { $page->trigError("Le raccourci demandé n'est pas valide.\n Vérifie qu'il comporte entre 3 et 20 caractères\n et qu'il ne contient que des lettres non accentuées,\n des chiffres ou les caractères - et ."); return $old; } elseif ($new && (is_int($new) || ctype_digit($new))) { $page->trigError("Le raccourci demandé ne peut être accepté car il\n ne contient que des chiffres. Rajoute-lui par exemple\n une lettre."); return $old; } //vérifier que l'alias n'est pas déja pris if ($new && $old != $new) { $res = XDB::query('SELECT COUNT(*) FROM group_events WHERE short_name = {?}', $new); if ($res->fetchOneCell() > 0) { $page->trigError("Le raccourci demandé est déjà utilisé. Choisis en un autre."); return $old; } } if ($old == $new) { return $new; } if ($old && $new) { // if had a previous shortname change the old lists foreach (explode(',', $globals->xnet->event_lists) as $suffix) { XDB::execute('UPDATE email_virtual SET email = {?} WHERE type = \'event\' AND email = {?}', $new . $suffix, $old . $suffix); } return $new; } if (!$old && $new) { // if we have a first new short_name create the lists $lastid = array(); $where = array($globals->xnet->participant_list => 'g.nb > 0', $globals->xnet->payed_list => '(g.paid > 0 OR p.amount > 0)', $globals->xnet->unpayed_list => 'g.nb > 0 AND g.paid = 0 AND p.amount IS NULL'); foreach (array($globals->xnet->participant_list, $globals->xnet->payed_list, $globals->xnet->unpayed_list) as $suffix) { $uids = XDB::fetchColumn('SELECT g.uid FROM group_event_participants AS g INNER JOIN group_events AS e ON (g.eid = e.eid) LEFT JOIN payment_transactions AS p ON (e.paiement_id = p.ref AND g.uid = p.uid) WHERE g.eid = {?} AND ' . $where[$suffix], $eid); foreach ($uids as $uid) { add_to_list_alias($uid, $new . $suffix, $globals->xnet->evts_domain, 'event'); } } $uids = XDB::fetchColumn('SELECT m.uid FROM group_members AS m LEFT JOIN group_event_participants AS e ON (e.uid = m.uid AND e.eid = {?}) WHERE m.asso_id = {?} AND e.uid IS NULL', $eid, $globals->asso('id')); foreach ($uids as $uid) { add_to_list_alias($uid, $new . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event'); } return $new; } if ($old && !$new) { // if we delete the old short name, delete the lists foreach (explode(',', $globals->xnet->event_lists) as $suffix) { delete_list_alias($old . $suffix, $globals->xnet->evts_domain); } return $new; } // cannot happen return $old; }
function handler_aaliases($page, $alias = null) { global $globals; require_once 'emails.inc.php'; $page->setTitle('Administration - Aliases'); if (Post::has('new_alias')) { pl_redirect('admin/aliases/' . Post::t('new_alias') . '@' . $globals->mail->domain); } // If no alias, list them all. if (is_null($alias)) { $page->changeTpl('lists/admin_aliases.tpl'); $page->assign('aliases', array_merge(iterate_list_alias($globals->mail->domain), iterate_list_alias($globals->mail->domain2))); return; } list($local_part, $domain) = explode('@', $alias); if (!($globals->mail->domain == $domain || $globals->mail->domain2 == $domain) || !preg_match("/^[a-zA-Z0-9\\-\\.]*\$/", $local_part)) { $page->trigErrorRedirect('Le nom de l\'alias est erroné.', $globals->asso('diminutif') . 'admin/aliases'); } // Now we can perform the action. if (Post::has('del_alias')) { S::assert_xsrf_token(); delete_list_alias($local_part, $domain); $page->trigSuccessRedirect($alias . ' supprimé.', 'admin/aliases'); } if (Post::has('add_member')) { S::assert_xsrf_token(); if (add_to_list_alias(Post::t('add_member'), $local_part, $domain)) { $page->trigSuccess('Ajout réussit.'); } else { $page->trigError('Ajout infructueux.'); } } if (Get::has('del_member')) { S::assert_xsrf_token(); if (delete_from_list_alias(Get::t('del_member'), $local_part, $domain)) { $page->trigSuccess('Suppression réussie.'); } else { $page->trigError('Suppression infructueuse.'); } } $page->changeTpl('lists/admin_edit_alias.tpl'); $page->assign('members', list_alias_members($local_part, $domain)); $page->assign('alias', $alias); }
public function commit() { require_once 'emails.inc.php'; if ($this->asso == 'alias') { foreach ($this->members as $member) { add_to_list_alias($member, $this->liste, $this->domain); } } else { $members = User::getBulkForlifeEmails($this->members, true, array('ListsModule', 'no_login_callback')); $owners = User::getBulkForlifeEmails($this->owners, true, array('ListsModule', 'no_login_callback')); // Make sure we send a list (array_values) of unique (array_unique) // emails. $owners = array_values(array_unique($owners)); $members = array_values(array_unique($members)); $success = MailingList::create($this->liste, $this->domain, S::user(), $this->desc, $this->advertise, $this->modlevel, $this->inslevel, $owners, $members); if ($success) { create_list($this->liste, $this->domain); } return $success; } }
function handler_admin_member($page, $user) { global $globals; $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'); $page->addJsLink('xnet_members.js'); $mmlist = new MMList(S::user(), $globals->asso('mail_domain')); if (Post::has('change')) { S::assert_xsrf_token(); require_once 'emails.inc.php'; require_once 'name.func.inc.php'; // Convert user status to X if (!Post::blank('x')) { $forlife = $this->changeLogin($page, $user, Post::i('userid'), Post::b('broken'), Post::b('marketing'), Post::v('marketing_from')); if ($forlife) { pl_redirect('member/' . $forlife); } } // Update user info if ($user->type == 'virtual' || $user->type == 'xnet' && !$user->perms) { $lastname = capitalize_name(Post::t('lastname')); if (Post::s('type') != 'virtual') { $firstname = capitalize_name(Post::t('firstname')); } else { $firstname = ''; } $full_name = build_full_name($firstname, $lastname); $directory_name = build_directory_name($firstname, $lastname); $sort_name = build_sort_name($firstname, $lastname); XDB::query('UPDATE accounts SET full_name = {?}, directory_name = {?}, sort_name = {?}, display_name = {?}, firstname = {?}, lastname = {?}, sex = {?}, type = {?} WHERE uid = {?}', $full_name, $directory_name, $sort_name, Post::t('display_name'), $firstname, $lastname, Post::t('sex') == 'male' ? 'male' : 'female', Post::t('type') == 'xnet' ? 'xnet' : 'virtual', $user->id()); } // Updates email. $new_email = strtolower(Post::t('email')); if (($user->type == 'virtual' || $user->type == 'xnet' && !$user->perms) && require_email_update($user, $new_email)) { XDB::query('UPDATE accounts SET email = {?} WHERE uid = {?}', $new_email, $user->id()); if ($user->forlifeEmail()) { $listClient = new MMList(S::user()); $listClient->change_user_email($user->forlifeEmail(), $new_email); update_alias_user($user->forlifeEmail(), $new_email); } $user = User::getWithUID($user->id()); } if (XDB::affectedRows()) { $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'), $globals->asso('diminutif')); $request->submit(); $page->trigSuccess('Le compte va bientôt être activé.'); } if (Post::b('again')) { $this->again($user->id()); $page->trigSuccess('Relance effectuée avec succès.'); } } // Update group params for user $perms = Post::v('group_perms'); $comm = Post::t('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 = {?}, position = {?} WHERE uid = {?} AND asso_id = {?}', $perms == 'admin' ? 'admin' : 'membre', $comm, $position, $user->id(), $globals->asso('id')); 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.'); } } } // Gets user info again as they might have change $user = User::getSilent($user->id()); // Update ML subscriptions foreach (Env::v('ml1', array()) as $ml => $state) { $ask = empty($_REQUEST['ml2'][$ml]) ? 0 : 2; if ($ask == $state) { continue; } if ($state == '1') { $page->trigWarning("{$user->fullName()} a " . "actuellement une demande d'inscription en " . "cours sur <strong>{$ml}@</strong> !!!"); } elseif ($ask) { $mmlist->mass_subscribe($ml, array($user->forlifeEmail())); $page->trigSuccess("{$user->fullName()} a été abonné à {$ml}@."); } else { $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]); 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 { 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->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_acreate($page) { if (!$this->get_lists_domain()) { return PL_NOT_FOUND; } $page->changeTpl('xnetlists/alias-create.tpl'); if (!Post::has('submit')) { return; } else { S::assert_xsrf_token(); } if (!Post::has('liste')) { $page->trigError('Le champs « adresse souhaitée » est vide.'); return; } $list = Post::v('liste'); if (!preg_match("/^[a-zA-Z0-9\\-\\.]*\$/", $list)) { $page->trigError('Le nom de l\'alias ne doit contenir que des lettres,' . ' chiffres, tirets et points.'); return; } require_once 'emails.inc.php'; $lists_domain = $this->get_lists_domain(); if (list_exist($list, $lists_domain)) { $page->trigError('Cet alias est déjà pris.'); return; } add_to_list_alias(S::i('uid'), $list, $lists_domain); pl_redirect('alias/admin/' . $list . '@' . $lists_domain); }