3 /***************************************************************************
4 * Copyright (C) 2003-2006 Polytechnique.org *
5 * http://opensource.polytechnique.org/ *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
21 ***************************************************************************/
23 require('./connect.db.inc.php');
24 require("newsletter.inc.php");
28 if(empty($opt['i']) ||
isset($opt['h'])) {
30 usage: send_nl.php -i nl_id
31 sends the NewsLetter of id "id"
36 $id = intval($opt['i']);
37 $nl = new NewsLetter($id);
42 "SELECT ni.user_id, a.alias,
43 u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage),
44 FIND_IN_SET('femme', u.flags),
45 q.core_mail_fmt AS pref
46 FROM newsletter_ins AS ni
47 INNER JOIN auth_user_md5 AS u USING(user_id)
48 INNER JOIN auth_user_quick AS q ON(q.user_id = u.user_id)
49 INNER JOIN aliases AS a ON(u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags))
52 if (!$res->total()) { exit; }
55 while (list($uid, $bestalias, $prenom, $nom, $sexe, $fmt) = $res->next()) {
56 $sent[] = "user_id='$uid'";
57 $nl->sendTo($prenom, $nom, $bestalias, $sexe, $fmt=='html');
59 XDB
::execute('UPDATE newsletter_ins SET last={?} WHERE '.implode(' OR ', $sent), $id);