function handler_broken($page, $uid = null) { $page->changeTpl('marketing/broken.tpl'); if (is_null($uid)) { return PL_NOT_FOUND; } $user = User::get($uid); if (!$user) { return PL_NOT_FOUND; } elseif ($user->login() == S::user()->login()) { pl_redirect('emails/redirect'); } $res = XDB::query('SELECT p.deathdate IS NULL AS alive, r.last, IF(r.type = \'googleapps\', \'googleapps\', r.redirect) AS active_email FROM accounts AS a LEFT JOIN email_redirect_account AS r ON (a.uid = r.uid AND r.type IN (\'smtp\', \'googleapps\') AND r.flags = \'active\') LEFT JOIN account_profiles AS ap ON (ap.uid = r.uid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profiles AS p ON (p.pid = ap.pid) WHERE a.uid = {?} ORDER BY r.broken_level, r.last', $user->id()); if (!$res->numRows()) { return PL_NOT_FOUND; } $user->addProperties($res->fetchOneAssoc()); $page->assign('user', $user); $email = null; require_once 'emails.inc.php'; if (Post::has('mail')) { $email = valide_email(Post::v('mail')); } if (Post::has('valide') && isvalid_email_redirection($email, $user)) { S::assert_xsrf_token(); // security stuff check_email($email, "Proposition d'une adresse surveillee pour " . $user->login() . " par " . S::user()->login()); $state = XDB::fetchOneCell('SELECT flags FROM email_redirect_account WHERE redirect = {?} AND uid = {?}', $email, $user->id()); if ($state == 'broken') { $page->trigWarning("L'adresse que tu as fournie est l'adresse actuelle de {$user->fullName()} et est en panne."); } elseif ($state == 'active') { $page->trigWarning("L'adresse que tu as fournie est l'adresse actuelle de {$user->fullName()}"); } elseif ($user->email && !Post::t('comment')) { $page->trigError("Il faut que tu ajoutes un commentaire à ta proposition pour justifier le " . "besoin de changer la redirection de {$user->fullName()}."); } else { $valid = new BrokenReq(S::user(), $user, $email, trim(Post::v('comment'))); $valid->submit(); $page->assign('sent', true); } } elseif ($email) { $page->trigError("L'adresse proposée n'est pas une adresse acceptable pour une redirection."); } }
private function changeLogin(PlPage $page, PlUser $user, $login, $req_broken = false, $req_marketing = false, $marketing_from = 'user') { // Search the user's uid. $xuser = User::getSilent($login); if (!$xuser) { $accounts = User::getPendingAccounts($login); if (!$accounts) { $page->trigError("L'identifiant {$login} ne correspond à aucun X."); return false; } else { if (count($accounts) > 1) { $page->trigError("L'identifiant {$login} correspond à plusieurs camarades."); return false; } } $xuser = User::getSilent($accounts[0]['uid']); } if (!$xuser) { return false; } // Market or suggest new redirection if required. $email = $user->bestEmail(); if ($req_broken) { $valid = new BrokenReq(S::user(), $xuser, $email, 'Groupe : ' . Platal::globals()->asso('nom')); $valid->submit(); } elseif ($req_marketing) { $market = Marketing::get($xuser->uid, $email); if (!$market) { $market = new Marketing($xuser->uid, $email, 'group', Platal::globals()->asso('nom'), $marketing_from, S::i('uid')); $market->add(); } } if ($user->mergeIn($xuser)) { return $xuser->login(); } return $user->login(); }