示例#1
0
 function handler_private($page, $hruid = null, $action = null, $value = null)
 {
     global $globals;
     $page->changeTpl('marketing/private.tpl');
     $user = User::getSilent($hruid);
     if (!$user) {
         return PL_NOT_FOUND;
     }
     // Retrieves marketed user details.
     if ($user->state != 'pending') {
         $page->kill('Cet utilisateur est déjà inscrit');
     }
     if (!$user->hasProfile()) {
         $page->kill('Cet utilisateur n\'est pas concerné par le marketing');
     }
     $matricule = $user->profile()->xorg_id;
     $matricule_X = Profile::getSchoolId($matricule);
     $page->assign('full_name', $user->fullName());
     $page->assign('promo', $user->promo());
     $page->assign('matricule', $matricule);
     $page->assign('matricule_X', $matricule_X);
     // Applies in-parameter action to the user.
     if ($action == 'del') {
         S::assert_xsrf_token();
         Marketing::clear($user->id(), $value);
     }
     if ($action == 'rel') {
         $market = Marketing::get($user->id(), $value);
         if ($market == null) {
             $page->trigWarning("Aucun marketing n'a été effectué vers {$value}");
         } else {
             $to = $market->user['to'];
             $title = $market->getTitle();
             $text = $market->getText();
             $from = $market->sender_mail;
             $page->assign('rel_from_user', $from);
             $page->assign('rel_from_staff', '"Equipe Polytechnique.org" <register@' . $globals->mail->domain . '>');
             $page->assign('rel_to', $to);
             $page->assign('rel_title', $title);
             $page->assign('rel_text', $text);
             $page->assign('rel_email', $value);
         }
     }
     if ($action == 'relforce') {
         S::assert_xsrf_token();
         $market = Marketing::get($user->id(), Post::v('to'));
         if (is_null($market)) {
             $market = new Marketing($user->id(), Post::v('to'), 'default', null, 'staff');
         }
         $market->send(Post::v('title'), Post::v('message'));
         $page->trigSuccess("Email envoyé");
     }
     if ($action == 'insrel') {
         S::assert_xsrf_token();
         if (Marketing::relance($user->id())) {
             $page->trigSuccess('relance faite');
         }
     }
     if ($action == 'add' && Post::has('email') && Post::has('type')) {
         $market = new Marketing($user->id(), Post::v('email'), 'default', null, Post::v('type'), S::v('uid'));
         $market->add(false);
     }
     // Retrieves and display the existing marketing attempts.
     $res = XDB::iterator("SELECT  r.*, s.email AS alias\n                   FROM  register_marketing   AS r\n              LEFT JOIN  email_source_account AS s ON (r.sender = s.uid AND s.type = 'forlife')\n                  WHERE  r.uid = {?}\n               ORDER BY  date", $user->id());
     $page->assign('addr', $res);
     $res = XDB::query("SELECT date, relance FROM register_pending\n                            WHERE uid = {?}", $user->id());
     if (list($pending, $relance) = $res->fetchOneRow()) {
         $page->assign('pending', $pending);
         $page->assign('relance', $relance);
     }
     $page->assign('path', 'marketing/private/' . $user->login());
 }
示例#2
0
    exit;
}
$matcol = intval($opts['m']);
$logcol = intval($opts['l']);
$handle = fopen($file, 'r');
while ($data = fgetcsv($handle)) {
    $login = $data[$logcol];
    $xorgid = preg_replace('/1(\\d{2})(\\d{3})/', '20${1}0\\2', $data[$matcol]);
    if (!is_numeric($xorgid)) {
        echo "ERROR The matricule ({$xorgid}) is not a numerical value.\n";
        break;
    }
    $query = XDB::query("SELECT  a.uid\n                           FROM  profiles         AS p\n                     INNER JOIN  account_profiles AS ap ON (p.pid = ap.pid AND FIND_IN_SET('owner', perms)\n                     INNER JOIN  accounts         AS a  ON (a.uid = ap.uid)\n                          WHERE  p.xorg_id = {?}", $xorgid);
    $uid = $query->fetchOneCell();
    if (!$uid) {
        echo "WARNING Can't find uid for matricule {$xorgid} (login {$login})\n";
        continue;
    }
    $market = Marketing::get($uid, "{$login}@poly.polytechnique.fr");
    if (!is_null($market)) {
        echo "WARNING A marketing has already been to {$xorgid} on {$login}\n";
        continue;
    }
    $market = new Marketing($uid, "{$login}@poly.polytechnique.fr", 'default', null, 'staff');
    $market->add(false);
    $market->send();
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
?>