public function handler_admin_nl_sync($page) { global $globals; $nl = $this->getNl(); if (!$nl) { return PL_FORBIDDEN; } if (Env::has('add_users')) { S::assert_xsrf_token(); $nl->bulkSubscribe(array_keys(Env::v('add_users'))); $page->trigSuccess('Ajouts réalisés avec succès.'); } // TODO(x2006barrois): remove raw SQL query. $uids = XDB::fetchColumn('SELECT DISTINCT(g.uid) FROM group_members AS g WHERE g.asso_id = {?} AND NOT EXISTS (SELECT ni.* FROM newsletter_ins AS ni INNER JOIN newsletters AS n ON (ni.nlid = n.id) WHERE g.uid = ni.uid AND n.group_id = g.asso_id)', $globals->asso('id')); $users = User::getBulkUsersWithUIDs($uids); usort($users, 'User::compareDirectoryName'); $page->setTitle('Synchronisation de la newsletter'); $page->changeTpl('newsletter/sync.tpl'); $page->assign('users', $users); }
public function handler_notifs($page, $action = null, $arg = null) { $page->changeTpl('carnet/notifs.tpl'); if ($action) { S::assert_xsrf_token(); switch ($action) { case 'add_promo': $this->addPromo($page, $arg); break; case 'del_promo': $this->delPromo($page, $arg); break; case 'add_group': $this->addGroup($page, $arg); break; case 'del_group': $this->delGroup($page, $arg); break; case 'del_nonins': $user = User::get($arg); if ($user) { $this->delNonRegistered($page, $user); } break; case 'add_nonins': $user = User::get($arg); if ($user) { $this->addNonRegistered($page, $user); } break; } } if (Env::has('subs')) { S::assert_xsrf_token(); $flags = new PlFlagSet(); foreach (Env::v('sub') as $key => $value) { $flags->addFlag($key, $value); } XDB::execute('UPDATE watch SET actions = {?} WHERE uid = {?}', $flags, S::i('uid')); S::user()->invalidWatchCache(); Platal::session()->updateNbNotifs(); } if (Env::has('flags_contacts')) { S::assert_xsrf_token(); XDB::execute('UPDATE watch SET ' . XDB::changeFlag('flags', 'contacts', Env::b('contacts')) . ' WHERE uid = {?}', S::i('uid')); S::user()->invalidWatchCache(); Platal::session()->updateNbNotifs(); } if (Env::has('flags_mail')) { S::assert_xsrf_token(); XDB::execute('UPDATE watch SET ' . XDB::changeFlag('flags', 'mail', Env::b('mail')) . ' WHERE uid = {?}', S::i('uid')); S::user()->invalidWatchCache(); Platal::session()->updateNbNotifs(); } $user = S::user(); $nonins = new UserFilter(new UFC_WatchRegistration($user)); $promo = XDB::fetchColumn('SELECT promo FROM watch_promo WHERE uid = {?} ORDER BY promo', S::i('uid')); $page->assign('promo_count', count($promo)); $ranges = array(); $range_start = null; $range_end = null; foreach ($promo as $p) { if (is_null($range_start)) { $range_start = $range_end = $p; } else { if ($p != $range_end + 1) { $ranges[] = array($range_start, $range_end); $range_start = $range_end = $p; } else { $range_end = $p; } } } $ranges[] = array($range_start, $range_end); $page->assign('promo_ranges', $ranges); $page->assign('nonins', $nonins->getUsers()); $groups = XDB::fetchColumn('SELECT g.nom FROM watch_group AS w INNER JOIN groups AS g ON (g.id = w.groupid) WHERE w.uid = {?} ORDER BY g.nom', S::i('uid')); $page->assign('groups', $groups); $page->assign('groups_count', count($groups)); list($flags, $actions) = XDB::fetchOneRow('SELECT flags, actions FROM watch WHERE uid = {?}', S::i('uid')); $flags = new PlFlagSet($flags); $actions = new PlFlagSet($actions); $page->assign('flags', $flags); $page->assign('actions', $actions); }
function createAliases($subState) { global $globals; $res = XDB::query("SELECT hruid, state, type\n FROM accounts\n WHERE uid = {?} AND hruid != ''", $subState->i('uid')); if ($res->numRows() == 0) { return "Tu n'as pas d'adresse à vie pré-attribuée.<br />" . "Envoie un mail à <a href=\"mailto:support@{$globals->mail->domain}\">" . "support@{$globals->mail->domain}</a> en expliquant ta situation."; } else { list($forlife, $state, $type) = $res->fetchOneRow(); } if ($state == 'active') { return "Tu es déjà inscrit, si tu ne te souviens plus de ton mot de passe d'accès au site, " . "tu peux suivre <a href=\"recovery\">la procédure de récupération de mot de passe</a>."; } else { if ($state == 'disabled') { return "Ton compte a été désactivé par les administrateurs du site suite à des abus. " . "Pour plus d'information ou pour demander la réactivation du compte, tu peux t'adresser à " . "<a href=\"mailto:support@{$globals->mail->domain}\">support@{$globals->mail->domain}</a>."; } } $emailXorg = PlUser::makeUserName($subState->t('firstname'), $subState->t('lastname')); $suffix = (User::$sub_mail_domains[$type] ? substr(User::$sub_mail_domains[$type], 0, 1) : '') . substr($subState->v('yearpromo'), -2); $emailXorg2 = $emailXorg . '.' . $suffix; // Search for homonyms: // * first case: only one homonym already registered. $res = XDB::query('SELECT uid, expire FROM email_source_account WHERE email = {?} AND type != \'alias_aux\'', $emailXorg); // * second case: at least two homonyms registerd. $result = XDB::query("SELECT hrmid\n FROM email_source_other\n WHERE type = 'homonym' AND email = {?}", $emailXorg); if ($res->numRows() || $result->numRows()) { if ($res->numRows()) { list($h_id, $expire) = $res->fetchOneRow(); if (empty($expire)) { XDB::execute('UPDATE email_source_account SET expire = ADDDATE(NOW(), INTERVAL 1 MONTH) WHERE email = {?} AND type != \'alias_aux\'', $emailXorg); $hrmid = User::makeHomonymHrmid($emailXorg); XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid) VALUES ({?}, {?}), ({?}, {?})', $hrmid, $h_id, $hrmid, $subState->i('uid')); $als = XDB::fetchColumn('SELECT email FROM email_source_account WHERE uid = {?} AND type != \'alias_aux\' AND expire IS NULL', $h_id); $homonym = User::getSilentWithUID($h_id); $mailer = new PlMailer('register/lostalias.mail.tpl'); $mailer->addTo($homonym); $mailer->setSubject("Perte de ton alias {$emailXorg} dans un mois !"); $mailer->assign('emailXorg', $emailXorg); $mailer->assign('als', join(', ', $als)); $mailer->SetTxtBody(wordwrap($msg, 72)); $mailer->send(); } } else { $hrmid = $result->fetchOneCell(); XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid) VALUES ({?}, {?})', $hrmid, $subState->i('uid')); // TODO: insert into source_other if new domain } $subState->set('forlife', $forlife); $subState->set('bestalias', $emailXorg2); $subState->set('emailXorg2', null); } else { $subState->set('forlife', $forlife); $subState->set('bestalias', $emailXorg); $subState->set('emailXorg2', $emailXorg2); } $subState->set('main_mail_domain', User::$sub_mail_domains[$type] . Platal::globals()->mail->domain); return true; }
function handler_recovery($page) { global $globals; $page->changeTpl('platal/recovery.tpl'); if (!Env::has('login') || !Env::has('birth')) { return; } if (!preg_match('/^[0-3][0-9][0-1][0-9][1][9]([0-9]{2})$/', Env::v('birth'))) { $page->trigError('Date de naissance incorrecte ou incohérente'); return; } $birth = sprintf('%s-%s-%s', substr(Env::v('birth'), 4, 4), substr(Env::v('birth'), 2, 2), substr(Env::v('birth'), 0, 2)); $mailorg = strtok(Env::v('login'), '@'); $profile = Profile::get(Env::t('login')); if (is_null($profile) || $profile->birthdate != $birth) { $page->trigError('Les informations que tu as rentrées ne permettent pas de récupérer ton mot de passe.<br />' . 'Si tu as un homonyme, utilise prenom.nom.promo comme login'); return; } $user = $profile->owner(); if ($user->state != 'active') { $page->trigError('Ton compte n\'est pas activé.'); return; } if ($user->lost) { $page->assign('no_addr', true); return; } $page->assign('ok', true); $url = rand_url_id(); XDB::execute('INSERT INTO account_lost_passwords (certificat,uid,created) VALUES ({?},{?},NOW())', $url, $user->id()); $to = XDB::fetchOneCell('SELECT redirect FROM email_redirect_account WHERE uid = {?} AND redirect = {?}', $user->id(), Post::t('email')); if (is_null($to)) { $emails = XDB::fetchColumn('SELECT redirect FROM email_redirect_account WHERE uid = {?} AND flags = \'inactive\' AND type = \'smtp\'', $user->id()); $inactives_to = implode(', ', $emails); } $mymail = new PlMailer(); $mymail->setFrom('"Gestion des mots de passe" <support+password@' . $globals->mail->domain . '>'); if (is_null($to)) { $mymail->addTo($user); $log_to = $user->bestEmail(); if (!is_null($inactives_to)) { $log_to = $inactives_to . ', ' . $log_to; $mymail->addTo($inactives_to); } } else { $mymail->addTo($to); $log_to = $to; } $mymail->setSubject("Ton certificat d'authentification"); $mymail->setTxtBody("Visite la page suivante qui expire dans six heures :\n{$globals->baseurl}/tmpPWD/{$url}\n\nSi en cliquant dessus tu n'y arrives pas, copie intégralement l'adresse dans la barre de ton navigateur. Si tu n'as pas utilisé ce lien dans six heures, tu peux tout simplement recommencer cette procédure.\n\n--\nPolytechnique.org\n\"Le portail des élèves & anciens élèves de l'École polytechnique\"\n\nEmail envoyé à " . Env::v('login') . (is_null($to) ? '' : ' Adresse de secours : ' . $to)); $mymail->send(); S::logger($user->id())->log('recovery', $log_to); }
public function mergeIn(User $newuser) { if ($this->profile()) { // Don't disable user with profile in this way. global $globals; Platal::page()->trigError('Impossible de fusionner les comptes ' . $this->hruid . ' et ' . $newuser->hruid . '. Contacte support@' . $globals->mail->domain . '.'); return false; } if ($this->forlifeEmail()) { // If the new user is not registered and does not have already an email address, // we need to give him the old user's email address if he has any. if (!$newuser->perms) { XDB::execute('UPDATE accounts SET email = {?} WHERE uid = {?} AND email IS NULL', $this->forlifeEmail(), $newuser->id()); // Reftech new user so its forlifeEmail will be correct. $newuser = self::getSilentWithUID($newuser->id()); } // Change email used in mailing lists. if ($this->forlifeEmail() != $newuser->forlifeEmail()) { // The super user is the user who has the right to do the modification. $super_user = S::user(); // group mailing lists $group_domains = XDB::fetchColumn('SELECT g.mail_domain FROM groups AS g INNER JOIN group_members AS gm ON(g.id = gm.asso_id) WHERE g.mail_domain != \'\' AND gm.uid = {?}', $this->id()); foreach ($group_domains as $mail_domain) { $mmlist = new MMList($super_user, $mail_domain); $mmlist->replace_email_in_all($this->forlifeEmail(), $newuser->forlifeEmail()); } // main domain lists $mmlist = new MMList($super_user); $mmlist->replace_email_in_all($this->forlifeEmail(), $newuser->forlifeEmail()); } } // Updates user in following tables. foreach (array('group_announces', 'payment_transactions', 'log_sessions', 'group_events') as $table) { XDB::execute('UPDATE ' . $table . ' SET uid = {?} WHERE uid = {?}', $newuser->id(), $this->id()); } // Merges user in following tables, ie updates when possible, then deletes remaining occurences of the old user. foreach (array('group_announces_read', 'group_event_participants', 'group_member_sub_requests', 'group_members', 'email_redirect_account') as $table) { XDB::execute('UPDATE IGNORE ' . $table . ' SET uid = {?} WHERE uid = {?}', $newuser->id(), $this->id()); XDB::execute('DELETE FROM ' . $table . ' WHERE uid = {?}', $this->id()); } // Eventually updates last session id and deletes old user's accounts entry. $lastSession = XDB::fetchOneCell('SELECT id FROM log_sessions WHERE uid = {?} ORDER BY start DESC LIMIT 1', $newuser->id()); XDB::execute('UPDATE log_last_sessions SET id = {?} WHERE uid = {?}', $lastSession, $newuser->id()); XDB::execute('DELETE FROM accounts WHERE uid = {?}', $this->id()); return true; }
function handler_phd($page, $promo = null, $validate = false) { $page->changeTpl('admin/phd.tpl'); $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); $eduDegrees = array_flip($eduDegrees); // get the list of the years when phd students are supposed to finish but have not yet been flagged as completed $promo_list = XDB::fetchColumn('SELECT DISTINCT(grad_year) FROM profile_education WHERE FIND_IN_SET(\'primary\', flags) AND NOT FIND_IN_SET(\'completed\', flags) AND degreeid = {?} ORDER BY grad_year', $eduDegrees[Profile::DEGREE_D]); // case when no promo was selected that is the admin/phd page if (is_null($promo)) { $page->assign('promo_list', $promo_list); $page->assign('nothing', count($promo_list) == 0); return; } // case when we want to add a list and we have data, that is admin/phd/bulk/validate if ($promo == "bulk" && Post::has('people')) { S::assert_xsrf_token(); $lines = explode("\n", Post::t('people')); $separator = Env::t('separator'); foreach ($lines as $line) { $infos = explode($separator, $line); if (sizeof($infos) !== 2) { $page->trigError("La ligne {$line} n'a pas été ajoutée : mauvais nombre de champs."); continue; } $infos = array_map('trim', $infos); // $info[0] is prenom.nom or hrid. We first try the hrid case, then we try over the possible promos. // We trigger an error if the search was unsuccessful. $user = User::getSilent($infos[0]); if (is_null($user)) { foreach ($promo_list as $promo_possible) { $user = User::getSilent($infos[0] . '.d' . $promo_possible); if (!is_null($user)) { break; } } if (is_null($user)) { $page->trigError("La ligne {$line} n'a pas été ajoutée : aucun compte trouvé."); continue; } } if ($user->type !== 'phd') { $page->trigError("La ligne {$line} n'a pas été ajoutée : le compte n'est pas celui d'un doctorant."); continue; } $grad_year = $infos[1]; if (!$grad_year) { $page->trigError("La ligne {$line} n'a pas été ajoutée : année de soutenance vide."); continue; } $profile = $user->profile(); // We have the pid, we now need the id that completes the PK in profile_education. $res = XDB::fetchOneCell('SELECT pe.id FROM profile_education AS pe WHERE FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags) AND pe.pid = {?}', $profile->id()); if (!$res) { $page->trigError("Le profil " . $profile->hrid() . " a déjà une année de soutenance indiquée."); continue; } // When we are here, we have the pid, id for profile_education table, and $grad_year. Time to UPDATE ! XDB::execute('UPDATE profile_education SET flags = CONCAT(flags, \',completed\'), grad_year = {?} WHERE pid = {?} AND id = {?}', $grad_year, $profile->id(), $res); XDB::execute('UPDATE profile_display SET promo = {?} WHERE pid = {?}', 'D' . $grad_year, $profile->id()); $page->trigSuccess("Promotion de " . $profile->fullName() . " validée."); } $errors = $page->nb_errs(); if ($errors == 0) { $page->trigSuccess("L'opération a été effectuée avec succès."); } else { $page->trigSuccess('L\'opération a été effectuée avec succès, sauf pour ' . ($errors == 1 ? 'l\'erreur signalée' : "les {$errors} erreurs signalées") . ' ci-dessus.'); } } elseif ($validate) { S::assert_xsrf_token(); $list = XDB::iterator('SELECT pe.pid, pd.directory_name FROM profile_education AS pe INNER JOIN profile_display AS pd ON (pe.pid = pd.pid) WHERE FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags) AND pe.degreeid = {?} AND pe.grad_year = {?}', $eduDegrees[Profile::DEGREE_D], $promo); while ($res = $list->next()) { $pid = $res['pid']; $name = $res['directory_name']; if (Post::b('completed_' . $pid)) { $grad_year = Post::t('grad_year_' . $pid); XDB::execute('UPDATE profile_education SET flags = CONCAT(flags, \',completed\'), grad_year = {?} WHERE FIND_IN_SET(\'primary\', flags) AND pid = {?}', $grad_year, $pid); XDB::execute('UPDATE profile_display SET promo = {?} WHERE pid = {?}', 'D' . $grad_year, $pid); $page->trigSuccess("Promotion de {$name} validée."); } } } // case we are on a graduation year page, e.g. admin/phd/2007 or admin/phd/2007/validate $list = XDB::iterator('SELECT pe.pid, pd.directory_name FROM profile_education AS pe INNER JOIN profile_display AS pd ON (pe.pid = pd.pid) WHERE FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags) AND pe.degreeid = {?} AND pe.grad_year = {?} ORDER BY pd.directory_name', $eduDegrees[Profile::DEGREE_D], $promo); $page->assign('list', $list); $page->assign('promo', $promo); }
function fill_email_combobox(PlPage $page, array $retrieve, $user = null) { require_once 'emails.inc.php'; if (is_null($user)) { $user = S::user(); } /* Always refetch the profile. */ $profile = $user->profile(true); $emails = array(); if (in_array('source', $retrieve)) { $emails['Emails polytechniciens'] = XDB::fetchColumn('SELECT CONCAT(s.email, \'@\', d.name) FROM email_source_account AS s INNER JOIN email_virtual_domains AS m ON (s.domain = m.id) INNER JOIN email_virtual_domains AS d ON (d.aliasing = m.id) WHERE s.uid = {?} ORDER BY s.email, d.name', $user->id()); } if (in_array('redirect', $retrieve)) { $redirect = new Redirect($user); $emails['Redirections'] = array(); foreach ($redirect->emails as $redirect_it) { if ($redirect_it->is_redirection()) { $emails['Redirections'][] = $redirect_it->email; } } } if ($profile) { if (in_array('job', $retrieve)) { $emails['Emails professionels'] = XDB::fetchColumn('SELECT email FROM profile_job WHERE pid = {?} AND email IS NOT NULL AND email != \'\'', $profile->id()); } if ($profile->email_directory) { if (in_array('directory', $retrieve)) { foreach ($emails as &$email_list) { foreach ($email_list as $key => $email) { if ($profile->email_directory == $email) { unset($email_list[$key]); } } } $emails['Email annuaire AX'] = array($profile->email_directory); } elseif (in_array('stripped_directory', $retrieve)) { if (User::isForeignEmailAddress($profile->email_directory)) { $is_redirect = XDB::fetchOneCell('SELECT COUNT(*) FROM email_redirect_account WHERE uid = {?} AND redirect = {?}', $user->id(), $profile->email_directory); if ($is_redirect == 0) { $emails['Email annuaire AX'] = array($profile->email_directory); } } } } if (isset($emails['Emails professionels']) && isset($emails['Redirections'])) { $intersect = array_intersect($emails['Emails professionels'], $emails['Redirections']); foreach ($intersect as $key => $email) { unset($emails['Emails professionels'][$key]); } } } $emails_count = 0; foreach ($emails as $email_list) { $emails_count += count($email_list); } $page->assign('emails_count', $emails_count); $page->assign('email_lists', $emails); }
function handler_sync($page, $liste = null) { if (!$this->get_lists_domain()) { return PL_NOT_FOUND; } if (!$liste) { return PL_NOT_FOUND; } $page->changeTpl('xnetlists/sync.tpl'); $mlist = $this->prepare_list($liste); if (Env::has('add')) { S::assert_xsrf_token(); $mlist->subscribeBulk(array_keys(Env::v('add'))); } list(, $members) = $mlist->getMembers(); $mails = array_map(create_function('$arr', 'return $arr[1];'), $members); $subscribers = array_unique($mails); global $globals; $ann = XDB::fetchColumn('SELECT uid FROM group_members WHERE asso_id = {?}', $globals->asso('id')); $users = User::getBulkUsersWithUIDs($ann); $not_in_list = array(); foreach ($users as $user) { if (!in_array(strtolower($user->forlifeEmail()), $subscribers)) { $not_in_list[] = $user; } } $page->assign('not_in_list', $not_in_list); }
public function getBinetsNames() { if ($this->visibility->isVisible(Visibility::EXPORT_PRIVATE)) { return XDB::fetchColumn('SELECT text FROM profile_binets AS pb LEFT JOIN profile_binet_enum AS pbe ON (pbe.id = pb.binet_id) WHERE pb.pid = {?}', $this->id()); } else { return array(); } }
function iterate_list_alias($domain) { return XDB::fetchColumn('SELECT CONCAT(v.email, \'@\', m.name) FROM email_virtual AS v INNER JOIN email_virtual_domains AS m ON (v.domain = m.id) WHERE m.name = {?} AND v.type = \'alias\' GROUP BY v.email', $domain); }
public function getIDs($text, $mode, $subid = null) { if ($mode == XDB::WILDCARD_EXACT) { $options = $this->getOptions($subid); return array_keys($options, $text); } else { if ($this->where == null) { $where = 'WHERE '; } else { $where = $this->where . ' AND '; } if ($subid != null && array_key_exists($subid, $this->suboptions)) { $where .= XDB::format($this->optfield . ' = {?} AND ', $subid); } $conds = array(); $conds[] = $this->valfield . XDB::formatWildcards($mode, $text); if ($this->valfield2 != null) { $conds[] = $this->valfield2 . XDB::formatWildcards($mode, $text); } $where .= '(' . implode(' OR ', $conds) . ')'; return XDB::fetchColumn('SELECT ' . $this->idfield . ' FROM ' . $this->from . ' ' . $this->join . ' ' . $where . ' GROUP BY ' . $this->idfield); } }
function handler_group_admin($page, $group = null) { $group = Group::fromId($group); if ($group && (S::user()->hasRights($group, Rights::admin()) || S::user()->isWeb())) { $group->select(GroupSelect::see()); $page->assign('group', $group); if (Env::has('name') && Env::t('name') != '' && S::user()->isAdmin()) { S::logger()->log("groups/admin", array("gid" => $group->id(), "old_name" => $group->name(), "new_name" => Env::t('name'))); $group->name(Env::t('name')); } if (Env::has('update') && S::user()->isAdmin()) { $group->external(Env::has('external')); $group->leavable(Env::has('leavable')); $group->visible(Env::has('visible')); } if (Env::has('label')) { $group->label(Env::t('label')); } if (Env::has('update')) { $group->description(Env::t('description')); $group->web(Env::t('web')); $group->wikix(Env::t('wikix')); $group->mail(Env::t('mail')); } if (Env::has('image')) { $image = new ImageFilter(new PFC_And(new IFC_Id(Env::i('image')), new IFC_Temp())); $image = $image->get(true); if (!$image) { throw new Exception("This image doesn't exist anymore"); } $image->select(FrankizImageSelect::caste()); $image->label($group->label()); $image->caste($group->caste(Rights::everybody())); $group->image($image); } if (S::user()->isWeb()) { $nss = XDB::fetchColumn('SELECT ns FROM groups GROUP BY ns'); $page->assign('nss', $nss); if (Env::has('ns')) { S::logger()->log("groups/admin", array("gid" => $group->id(), "old_ns" => $group->ns(), "new_ns" => Env::t('ns'))); $group->ns(Env::t('ns')); } } $promos = S::user()->castes()->groups()->filter('ns', Group::NS_PROMO); $page->assign('promos', $promos); $page->assign('title', 'Administration de "' . $group->label() . '"'); $page->addCssLink('groups.css'); $page->changeTpl('groups/admin.tpl'); } else { $page->assign('title', "Ce groupe n'existe pas ou vous n'en êtes pas administrateur"); $page->changeTpl('groups/no_group.tpl'); } }
function handler_awaiting_active($page) { global $globals; $page->changeTpl('xnetgrp/awaiting_active.tpl'); XDB::execute('DELETE FROM register_pending_xnet WHERE DATE_SUB(NOW(), INTERVAL 1 MONTH) > date'); $uids = XDB::fetchColumn('SELECT g.uid FROM group_members AS g INNER JOIN accounts AS a ON (a.uid = g.uid) INNER 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 = \'pending\'', $globals->asso('id')); if (Post::has('again')) { S::assert_xsrf_token(); $uids_to_again = array_intersect(array_keys(Post::v('again')), $uids); foreach ($uids_to_again as $uid) { $this->again($uid); } $page->trigSuccess('Relances effectuées avec succès.'); } if ($uids) { $registration_date = XDB::fetchAllAssoc('uid', 'SELECT uid, date FROM register_pending_xnet WHERE uid IN {?}', $uids); $last_date = XDB::fetchAllAssoc('uid', 'SELECT uid, last_date FROM register_pending_xnet WHERE uid IN {?}', $uids); $users = User::getBulkUsersWithUIDs($uids); $page->assign('users', $users); $page->assign('registration_date', $registration_date); $page->assign('last_date', $last_date); } }
public function getData(PlUser $user) { $data = XDB::fetchColumn("SELECT field\n FROM watch_profile\n WHERE pid = {?} AND ts > FROM_UNIXTIME({?}) AND field != ''\n ORDER BY ts", $user->profile()->id(), $this->date); if (count($data) == 0) { return null; } else { $text = array(); foreach ($data as $f) { $text[] = Profile::$descriptions[$f]; } return $text; } }
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; }
protected function getIDList($ids = null, PlLimit $limit) { $schema = $this->schema(); $as = $schema['as']; $id = $schema['id']; $this->buildQuery(); $lim = $limit->getSql(); $cond = ''; if (!is_null($ids)) { $cond = XDB::format(" AND {$as}.{$id} IN {?}", $ids); } $fetched = XDB::fetchColumn("SELECT SQL_CALC_FOUND_ROWS {$as}.{$id}\n {$this->query}\n {$cond}\n GROUP BY {$as}.{$id}\n {$this->orderby}\n {$lim}"); $this->lastcount = (int) XDB::fetchOneCell('SELECT FOUND_ROWS()'); return $fetched; }
/** Returns a list of either issues or articles corresponding to the search. * @p $search The searched pattern. * @p $field The fields where to search, if none given, search in all possible fields. * @return The list of object found. */ public function issueSearch($search, $field, $user) { $search = XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $search); if ($field == self::SEARCH_ALL) { $where = '(title ' . $search . ' OR mail_title ' . $search . ' OR head ' . $search . ' OR signature ' . $search . ')'; } elseif ($field == self::SEARCH_TITLE) { $where = '(title ' . $search . ' OR mail_title ' . $search . ')'; } else { $where = $field . $search; } $list = XDB::fetchColumn('SELECT DISTINCT(id) FROM newsletter_issues WHERE nlid = {?} AND state = \'sent\' AND ' . $where . ' ORDER BY date DESC', $this->id); $issues = array(); foreach ($list as $id) { $issue = new NLIssue($id, $this, false); if ($issue->checkUser($user)) { $issues[] = $issue; } } return $issues; }