plug registrations of watched evs in the site
authorx2000habouzit <x2000habouzit>
Thu, 4 Nov 2004 20:19:35 +0000 (20:19 +0000)
committerx2000habouzit <x2000habouzit>
Thu, 4 Nov 2004 20:19:35 +0000 (20:19 +0000)
htdocs/admin/deces_promo.php
htdocs/inscription/step4.php
htdocs/profil.php
include/notifs.inc.php
include/valid_photos.inc.php
scripts/migration/0.9.2/notifs.sql
templates/admin/deces_promo.tpl

index 8cd49fc..113d751 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: deces_promo.php,v 1.5 2004-10-31 16:39:04 x2000chevalier Exp $
+        $Id: deces_promo.php,v 1.6 2004-11-04 20:19:36 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -33,9 +33,14 @@ if(isset($_REQUEST['add10']))   $promo += 10;
 $page->assign('promo',$promo);
 
 if (isset($_REQUEST["valider"]) && $_REQUEST["valider"] == "Valider") {
-    $res = $globals->db->query("SELECT matricule FROM auth_user_md5 WHERE promo = $promo");
-    while (list($mat) = mysql_fetch_row($res)) {
-        $globals->db->query("UPDATE auth_user_md5 SET deces='".$_REQUEST[$mat]."' WHERE matricule = '".$mat."'");
+    $res = $globals->db->query("SELECT user_id,matricule,deces FROM auth_user_md5 WHERE promo = $promo");
+    while (list($uid,$mat,$deces) = mysql_fetch_row($res)) {
+       if($_REQUEST[$mat] == $deces) continue;
+       $globals->db->query("UPDATE auth_user_md5 SET deces='".$_REQUEST[$mat]."' WHERE matricule = '".$mat."'");
+       if($deces=='0000-00-00' or empty($deces)) {
+           require_once('notifs.inc.php');
+           register_watch_op($uid,'death');
+       }
     }
 }
 
index 879465e..015698e 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: step4.php,v 1.7 2004-11-03 15:55:23 x2000habouzit Exp $
+        $Id: step4.php,v 1.8 2004-11-04 20:19:36 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -121,6 +121,8 @@ if (!empty($_REQUEST['ref'])) {
 
     // insérer l'inscription dans la table des inscriptions confirmé
     $globals->db->query("INSERT INTO ins_confirmees SET id=$uid");
+    require_once('notifs.inc.php');
+    register_watch_op($uid,'ins');
 
     // insérer une ligne dans user_changes pour que les coordonnées complè
     // soient envoyées a l'
index bf8d5b6..c160bd4 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: profil.php,v 1.10 2004-09-04 21:04:25 x2000habouzit Exp $
+        $Id: profil.php,v 1.11 2004-11-04 20:19:35 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -97,14 +97,14 @@ if (isset($_REQUEST['modifier']) || isset($_REQUEST['suivant'])) {
     if ($web_public) $bits_reply .= 'web_public,';
     if ($libre_public) $bits_reply .= 'libre_public,';
     if (!empty($bits_reply)) $bits_reply = substr($bits_reply, 0, -1);
-    $sql = "UPDATE auth_user_md5 set bits = '$bits_reply'";
-    // si on est en suid on ne met pas à jour la date
-    if(isset($_SESSION['suid'])) {
-        $sql = $sql." WHERE user_id={$_SESSION['uid']}";
-    } else {
+    $sql = "UPDATE auth_user_md5 set bits = '$bits_reply' WHERE user_id={$_SESSION['uid']}";
+    $globals->db->query($sql);
+    
+    if(empty($_SESSION['suid'])) {
         $sql = $sql.",date='$date' WHERE user_id={$_SESSION['uid']}";
+       require_once('notifs.inc.php');
+       register_watch_op($this->uid,'fiche');
     }
-    $globals->db->query($sql);
 
     // mise a jour des champs relatifs au tab ouvert
     require_once("profil/update_{$opened_tab}.inc.php");
index 8cd93b8..5f11e0e 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: notifs.inc.php,v 1.1 2004-11-04 19:57:43 x2000habouzit Exp $
+        $Id: notifs.inc.php,v 1.2 2004-11-04 20:19:36 x2000habouzit Exp $
  ***************************************************************************/
 
 require_once('diogenes.flagset.inc.php');
+
+function register_watch_op($uid, $type) {
+    global $globals;
+    if(in_array($type, Array('fiche','death','photo','ins'))) {
+       $globals->db->query("REPLACE INTO watch_ops (user_id,op) VALUES('$uid','$type')");
+    }
+    if($type == 'fiche') {
+       $globals->db->query("UPDATE auth_user_md5 SET DATE=NOW() WHERE user_id='$uid'");
+    }
+}
+
 class Notifs {
     var $uid;
     var $flags;
index d20f97d..d062e82 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: valid_photos.inc.php,v 1.13 2004-11-02 08:10:55 x2000habouzit Exp $
+        $Id: valid_photos.inc.php,v 1.14 2004-11-04 20:19:36 x2000habouzit Exp $
  ***************************************************************************/
 
 
@@ -107,7 +107,8 @@ class PhotoReq extends Validate {
         
         $globals->db->query("REPLACE INTO photo set uid='".$this->uid."', attachmime = '".$this->mimetype."', attach='"
             .addslashes($this->data)."', x='".$this->x."', y='".$this->y."'");
-       $globals->db->query("UPDATE auth_user_md5 SET date=NOW() WHERE user_id='{$this->uid}'");
+       require('notifs.inc.php');
+       register_watch_op($this->uid,'fiche');
     }
 }
 
index 6f3e5d8..8a0e731 100644 (file)
@@ -9,6 +9,6 @@ create table watch (
 
 create table watch_ops (
     user_id smallint not null,
-    op enum('fiche','death','photo','ins') not null,
+    op enum('fiche','death','ins') not null,
     primary key (user_id,op)
 );
index 8230bed..04e1cb9 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: deces_promo.tpl,v 1.5 2004-08-31 11:25:39 x2000habouzit Exp $
+        $Id: deces_promo.tpl,v 1.6 2004-11-04 20:19:37 x2000habouzit Exp $
  ***************************************************************************}
 
 
-<form action="{$smarty.server.PHP_SELF}" method="post">
-<table class="tinybicol">
-  <tr>
-    <td><input type="submit" value="&lt;&lt;" name="sub10" /></td>
-    <td><input type="submit" value="&lt;"  name="sub01" /></td>
-    <td>
-      Promotion :
 {dynamic}
-      <input type="text" name="promo" value="{$promo}" size="4" maxlength="4" />
-{/dynamic}
-      <input type="submit" value="GO" />
-    </td>
-    <td><input type="submit" value="&gt;"  name="add01" /></td>
-    <td><input type="submit" value="&gt;&gt;" name="add10" /></td>
-  </tr>
-</table>
+
+<form action="{$smarty.server.PHP_SELF}" method="get">
+  <table class="tinybicol">
+    <tr>
+      <td><input type="submit" value="&lt;&lt;" name="sub10" /></td>
+      <td><input type="submit" value="&lt;"  name="sub01" /></td>
+      <td>
+        Promotion :
+        <input type="text" name="promo" value="{$promo}" size="4" maxlength="4" />
+        <input type="submit" value="GO" />
+      </td>
+      <td><input type="submit" value="&gt;"  name="add01" /></td>
+      <td><input type="submit" value="&gt;&gt;" name="add10" /></td>
+    </tr>
+  </table>
 </form>
 
-<form action="{$smarty.server.PHP_SELF}" method="post">
-<table class="bicol" summary="liste des dates de décès">
-  <tr>
-    <th>Nom</th>
-    <th>Date de décès</th>
-  </tr>
-{dynamic}
-{foreach item=x from=$decedes}
-  <tr class="{cycle values="impair,pair"}">
-    <td>{$x.nom} {$x.prenom}</td>
-    <td class="center">
-      <input type="text" name="{$x.matricule}" value="{$x.deces}" size="10" maxlength="10" />
-    </td>
-  </tr>
-{/foreach}
-{/dynamic}
-  <tr>
-    <td class="center" colspan="2">
-      <input type="hidden" name="promo" value="{$promo}" />
-      <input type="submit" name="valider" value="Valider" />
-    </td>
-  </tr>
-</table>
+<form action="{$smarty.server.REQUEST_URI}" method="post">
+  <table class="bicol" summary="liste des dates de décès">
+    <tr>
+      <th>Nom</th>
+      <th>Date de décès</th>
+    </tr>
+    {foreach item=x from=$decedes}
+    <tr class="{cycle values="impair,pair"}">
+      <td>{$x.nom} {$x.prenom}</td>
+      <td class="center">
+        <input type="text" name="{$x.matricule}" value="{$x.deces}" size="10" maxlength="10" />
+      </td>
+    </tr>
+    {/foreach}
+    <tr>
+      <td class="center" colspan="2">
+        <input type="hidden" name="promo" value="{$promo}" />
+        <input type="submit" name="valider" value="Valider" />
+      </td>
+    </tr>
+  </table>
 </form>
-       
+
+{/dynamic}
+
 {* vim:set et sw=2 sts=2 sws=2: *}