categories
authorx2000habouzit <x2000habouzit>
Fri, 15 Oct 2004 14:30:53 +0000 (14:30 +0000)
committerx2000habouzit <x2000habouzit>
Fri, 15 Oct 2004 14:30:53 +0000 (14:30 +0000)
htdocs/admin/newsletter_cats.php [new file with mode: 0644]
include/newsletter.inc.php
scripts/migration/0.9.1/newsleter.sql
templates/admin/index.tpl

diff --git a/htdocs/admin/newsletter_cats.php b/htdocs/admin/newsletter_cats.php
new file mode 100644 (file)
index 0000000..927d965
--- /dev/null
@@ -0,0 +1,33 @@
+<?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                *
+ ***************************************************************************
+        $Id: newsletter_cats.php,v 1.1 2004-10-15 14:30:53 x2000habouzit Exp $
+ ***************************************************************************/
+
+require('auto.prepend.inc.php');
+new_admin_table_editor('newsletter_cat','cid');
+
+$editor->describe('titre','intitulé',true);
+$editor->describe('pos','position',true);
+
+$editor->assign('title', 'Gestion des catégories de la newsletter');
+
+$editor->run();
+?>
index 8d291ff..3778bca 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: newsletter.inc.php,v 1.2 2004-10-15 12:57:10 x2000habouzit Exp $
+        $Id: newsletter.inc.php,v 1.3 2004-10-15 14:30:54 x2000habouzit Exp $
  ***************************************************************************/
 
+
+define('FEMME', 1);
+define('HOMME', 0);
+
 class NewsLetter {
     function NewsLetter() { }
 }
 
+class NLArticle {
+    function NLArticle() { }
+}
+
+class NLConstraint {
+    var $_func;
+    var $_arg;
+    
+    function NLConstraint($func, $arg) {
+       $this->_func = $func;
+       $this->_arg = $arg;
+    }
+
+    function check($user) { return false; }
+}
+
+class NLPromoConstraint {
+    function check($user) {
+       $promo = $user['promo'];
+       switch($this->_func) {
+           case 'eq':   return ( $promo == $this->_arg );
+           case 'neq':  return ( $promo != $this->_arg );
+           case 'geq':  return ( $promo >= $this->_arg );
+           case 'leq':  return ( $promo <= $this->_arg );
+           case 'odd':  return ( $promo % 2 == 1 );
+           case 'even': return ( $promo % 2 == 0 );
+           default: return false;
+       }
+    }
+}
+
+class NLSexeConstraint {
+    function check($user) { return $user['sexe'] == $_arg; }
+}
+       
+
 function get_nl_list() {
     global $globals;
     $res = $globals->db->query("SELECT id,date,titre FROM newsletter ORDER BY date DESC");
@@ -49,7 +89,7 @@ function unsubscribe_nl() {
  
 function subscribe_nl() {
     global $globals;
-    $globals->db->query("INSERT INTO newsletter_ins (user_id) VALUES ({$_SESSION['uid']})");
+    $globals->db->query("REPLACE INTO newsletter_ins (user_id,last) SELECT {$_SESSION['uid']}, MAX(id) FROM newsletter WHERE bits!='new'");
 }
  
 ?>
index 6acec7b..19cce45 100644 (file)
@@ -1,6 +1,20 @@
 alter table newsletter change id id int not null;
 alter table newsletter change `date` `date` date not null;
 alter table newsletter add column bits enum('old','sent','new') default 'new' not null;
+update newsletter set bits='old';
 
 alter table newsletter_ins add column last int;
 alter table newsletter_ins add index (last);
+
+create table newsletter_cat (
+    cid tinyint unsigned not null auto_increment,
+    pos tinyint unsigned not null,
+    titre varchar(128) not null,
+    PRIMARY KEY (cid),
+    INDEX (pos)
+);
+insert into newsletter_cat values(1,1,'Flash Info');
+insert into newsletter_cat values(2,2,'Communications institutionnelles');
+insert into newsletter_cat values(3,3,'Groupes X');
+insert into newsletter_cat values(4,4,'Activités polytechniciennes');
+
index 08d9f4c..bd970de 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: index.tpl,v 1.8 2004-10-08 12:04:05 x2000habouzit Exp $
+        $Id: index.tpl,v 1.9 2004-10-15 14:30:55 x2000habouzit Exp $
  ***************************************************************************}
 
 
@@ -68,6 +68,7 @@
   </td></tr>
   <tr class="pair"><td>
       <strong>Newsletter : </strong>
+      <a href="newsletter_cats.php">Catégories</a> &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="newsletter_prep.php">Préparation</a> &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="newsletter_archi.php">Archives</a> &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="newsletter_pattecassee.php">Adresses en panne</a>