closes FS#63
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sat, 15 Jan 2005 00:51:12 +0000 (00:51 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:35 +0000 (23:27 +0200)
* create cron
* update various tiny things

git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-324

bin/cron/notifs.birthday.php [new file with mode: 0755]
include/notifs.inc.php
upgrade/0.9.4/60_watch.sql
upgrade/0.9.4/update.sh

diff --git a/bin/cron/notifs.birthday.php b/bin/cron/notifs.birthday.php
new file mode 100755 (executable)
index 0000000..7c99e50
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/php4 -q
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require('./connect.db.inc.php');
+
+$date  = date('Y-m-d');
+$stamp = date('Ymd000000');
+$like  = date('%-m-d');
+
+$globals->db->query("INSERT INTO  watch_ops (uid, cid, known, date)
+                          SELECT  user_id, 4, '$date', $stamp
+                            FROM  auth_user_md5
+                           WHERE  naissance LIKE '$like'");
+
+
+?>
index 4842ce2..08db2cb 100644 (file)
@@ -65,7 +65,7 @@ function _select_notifs_base($table, $mail, $where)
                 'contact_sql' => '1'
             ),
             'watch_promo'  => Array('wfield' => 'promo',   'ufield' => 'promo',   'need_contact' => true,
-                'freq_sql' => ' AND ( wc.type = "basic" OR wc.type="near" AND (w.promo <= u.promo+1 AND w.promo >= u.promo-1) )',
+                'freq_sql' => ' AND ( wc.type = "basic" OR wc.type="near" AND (w.promo <= v.promo+1 AND w.promo >= v.promo-1) )',
                 'contact_sql' => 'NOT (c.contact IS NULL)'
             ),
             'watch_nonins' => Array('wfield' => 'ni_id',   'ufield' => 'user_id', 'need_contact' => false,
@@ -91,10 +91,10 @@ function _select_notifs_base($table, $mail, $where)
     $sql .= "
             FROM  $table          AS w
       INNER JOIN  auth_user_md5   AS u  ON(u.{$our['ufield']} = w.{$our['wfield']})
-      INNER JOIN  auth_user_quick AS q  ON(q.user_id = w.uid)";
+      INNER JOIN  auth_user_quick AS q  ON(q.user_id = w.uid)
+      INNER JOIN  auth_user_md5   AS v  ON(v.user_id = q.user_id)";
     if ($mail) {
         $sql .="
-      INNER JOIN  auth_user_md5   AS v  ON(v.user_id = q.user_id)
       INNER JOIN  aliases         AS b  ON(b.id = q.user_id AND FIND_IN_SET('bestalias', b.flags))";
     }
     if ($our['need_contact']) {
index 44cb1f7..dddfd6c 100644 (file)
@@ -2,3 +2,5 @@ alter table watch_cat add column type enum('basic', 'near', 'often') not null de
 update watch_cat set type='often' where frequent=1;
 alter table watch_cat drop column frequent;
 insert into watch_cat (id, short, mail, type) values(4, 'Anniversaires', 'Ces camarades ont feté leur anniversaire cette semaine', 'near');
+
+replace into watch_sub (uid, cid) select user_id, 4 from auth_user_md5 where perms in ('admin', 'user') and deces=0;
index 2970ad1..07e9d08 100755 (executable)
@@ -29,4 +29,8 @@ You now have to :
 (*) apt-get install php-banana (may not be on public servers)
     and add a rewrite rule on www.polytechnique.org (http and https) :
     ^/banana/([^/]*/.*)$    /usr/share/banana/\$1
+
+(*) install the new cron : bin/cron/notifs.birthday.php
+    suggested :
+    0 1 * * *   ...../bin/cron/notifs.birthday.php
 "