public function delNonRegistered(PlPage $page, PlUser $user) { XDB::execute('DELETE FROM watch_nonins WHERE uid = {?} AND ni_id = {?}', S::i('uid'), $user->id()); S::user()->invalidWatchCache(); Platal::session()->updateNbNotifs(); }
/** Check that the user match the given rule. */ public function checkUser(PlUser $user) { $this->requireAccounts(); $this->buildQuery(); $count = (int) XDB::rawFetchOneCell('SELECT COUNT(*) ' . $this->query . XDB::format(' AND a.uid = {?}', $user->id())); return $count == 1; }
public static function relance(PlUser $user, $nbx = -1) { global $globals; if ($nbx < 0) { $nbx = $globals->core->NbIns; } $res = XDB::fetchOneCell('SELECT r.date, r.email, r.bestalias FROM register_pending WHERE r.hash = \'INSCRIT\' AND uid = {?}', $user->id()); if (!$res) { return false; } else { list($date, $email, $alias) = $res; } $hash = rand_url_id(12); $pass = rand_pass(); $pass_encrypted = sha1($pass); $fdate = strftime('%d %B %Y', strtotime($date)); $mymail = new PlMailer('marketing/relance.mail.tpl'); $mymail->assign('nbdix', $nbx); $mymail->assign('fdate', $fdate); $mymail->assign('lusername', $alias); $mymail->assign('nveau_pass', $pass); $mymail->assign('baseurl', $globals->baseurl); $mymail->assign('lins_id', $hash); $mymail->assign('lemail', $email); $mymail->assign('subj', ucfirst($globals->mail->domain) . ' : ' . $alias); $mymail->send(); XDB::execute('UPDATE register_pending SET hash={?}, password={?}, relance=NOW() WHERE uid={?}', $hash, $pass_encrypted, $user->id()); return $user->fullName(); }
function select_if_homonym(PlUser $user) { return XDB::fetchOneCell('SELECT email FROM email_source_account WHERE uid = {?} AND expire IS NOT NULL', $user->id()); }
function unsubscribe(PlUser $user, $remember = false) { global $globals; Group::unsubscribe($globals->asso('id'), $user->id(), $remember); if ($globals->asso('notif_unsub')) { $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl'); $admins = $globals->asso()->iterToNotify(); while ($admin = $admins->next()) { $mailer->addTo($admin); } $mailer->assign('group', $globals->asso('nom')); $mailer->assign('user', $user); $mailer->assign('selfdone', $user->id() == S::i('uid')); $mailer->send(); } $nl = Newsletter::forGroup($globals->asso('shortname')); if (!is_null($nl)) { $nl->unsubscribe(null, S::i('uid')); } $domain = $globals->asso('mail_domain'); if (!$domain) { return true; } $mmlist = new MMList(S::user(), $domain); $listes = $mmlist->get_lists($user->forlifeEmail()); $may_update = may_update(); $warning = false; if (is_array($listes)) { foreach ($listes as $liste) { if ($liste['sub'] == 2) { if ($may_update) { $mmlist->mass_unsubscribe($liste['list'], array($user->forlifeEmail())); } else { $mmlist->unsubscribe($liste['list']); } } elseif ($liste['sub']) { Platal::page()->trigWarning($user->fullName() . " a une" . " demande d'inscription en cours sur la" . " liste {$liste['list']}@ !"); $warning = true; } } } 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; }