smallint en int et domaine evenements, attention config a changer
authorPascal Corpet <pascal.corpet@m4x.org>
Sun, 19 Jun 2005 19:38:22 +0000 (19:38 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:29:20 +0000 (23:29 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-729

hooks/xnet.inc.php
htdocs.net/groupe/evenements.php
include/xnet/evenements.php
templates/xnet/groupe/evt-admin.tpl
upgrade/0.9.7/00_xnet.sql

index 28c9707..c82ab8c 100644 (file)
@@ -26,6 +26,7 @@
 class XnetConfig
 {
     var $secret       = '';
+    var $evts_domain = '';
 }
 
 // }}}
index 23c0f0f..8f5ab63 100644 (file)
@@ -9,6 +9,8 @@ $page->assign('admin', may_update());
 $moments = range(1, 4);
 $page->assign('moments', $moments);
 
+$page->assign('eid', Env::get('eid'));
+
 if ($eid = Env::get('eid')) {
        $res = $globals->xdb->query("SELECT asso_id, short_name FROM groupex.evenements WHERE eid = {?}", $eid);
        $infos = $res->fetchOneAssoc();
@@ -27,6 +29,7 @@ if (may_update() && Post::get('intitule')) {
                            et qu'il ne contient que des lettres non accentuées,
                            des chiffres ou les caractères - et .");
                $short_name = $infos['short_name'];
+               $page->assign('get_form', true);
        }
        //vérifier que l'alias n'est pas déja pris
        if ($short_name && $short_name != $infos['short_name']) {
@@ -34,13 +37,14 @@ if (may_update() && Post::get('intitule')) {
                if ($res->fetchOneCell() > 0) {
                        $page->trig("Le raccourci demandé est déjà utilisé. Choisis en un autre.");
                        $short_name = $infos['short_name'];
+                       $page->assign('get_form', true);
                }
        }
        if ($short_name && $infos['short_name'] && $short_name != $infos['short_name']) {
                $globals->xdb->execute("UPDATE virtual SET alias = REPLACE(alias, {?}, {?}) WHERE type = 'evt' AND alias LIKE {?}",
                        $infos['short_name'], $short_name, $infos['short_name']."-%");
        } elseif ($short_name && !$infos['short_name']) {
-               $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $short_name."-participants@".$globals->mail->domain);
+               $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $short_name."-participants@".$globals->xnet->evts_domain);
                $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
                $globals->xdb->execute("INSERT INTO virtual_redirect (
                        SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
@@ -52,7 +56,7 @@ if (may_update() && Post::get('intitule')) {
                      GROUP BY ep.uid)",
                         $res->fetchOneCell(), "@".$globals->mail->domain, $eid);
 
-               $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $short_name."-absents@".$globals->mail->domain);
+               $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $short_name."-absents@".$globals->xnet->evts_domain);
                $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
                $globals->xdb->execute("INSERT INTO virtual_redirect (
                        SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
@@ -68,17 +72,16 @@ if (may_update() && Post::get('intitule')) {
                        $infos['short_name']."-%");
        }
 
-       $globals->xdb->execute("REPLACE INTO groupex.evenements VALUES (
-               {?}, {?}, {?}, {?},
-               {?}, {?},
-               {?},
-               {?},
-               {?}, {?}, {?}, {?})",
+       $globals->xdb->execute("REPLACE INTO groupex.evenements 
+               SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?},
+               paiement_id = {?}, descriptif = {?},
+               debut = {?}, fin = {?},
+               membres_only = {?}, advertise = {?}, show_participants = {?}, short_name = {?}",
                $eid, $globals->asso('id'), Session::get('uid'), Post::get('intitule'),
                (Post::get('paiement')>0)?Post::get('paiement'):NULL, Post::get('descriptif'),
                Post::get('deb_Year')."-".Post::get('deb_Month')."-".Post::get('deb_Day')." ".Post::get('deb_Hour').":".Post::get('deb_Minute').":00",
                Post::get('fin_Year')."-".Post::get('fin_Month')."-".Post::get('fin_Day')." ".Post::get('fin_Hour').":".Post::get('fin_Minute').":00",
-               Post::get('membres_only'), Post::get('advertise'), Post::get('show_participants'), $short_name);
+               Post::get('membres_only'), Post::get('advertise'), Post::get('show_participants'), $short_name, $eid);
 
        if (!$eid) {
                $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
@@ -132,14 +135,16 @@ if (may_update() && (Env::has('add') || (Env::has('mod') && $eid))) {
        $page->assign('paiements', $paiements);
 }
 
-if (may_update() && Env::has('mod') && $eid) {
+if ($eid) {
        $res = $globals->xdb->query(
                "SELECT eid, intitule, descriptif, debut, fin, membres_only, advertise, show_participants, paiement_id, short_name
                   FROM groupex.evenements
                  WHERE eid = {?}", $eid);
        $evt = $res->fetchOneAssoc();
        $page->assign('evt', $evt);
-       
+}
+
+if (may_update() && Env::has('mod') && $eid) {
        $res = $globals->xdb->iterator(
                "SELECT item_id, titre, details, montant
                   FROM groupex.evenements_items AS ei
index 3673ab0..d0502e0 100644 (file)
@@ -36,8 +36,8 @@ function get_event_detail($eid, $item_id = false) {
       LEFT JOIN auth_user_md5 AS a ON (a.user_id = e.organisateur_uid)
           WHERE        e.eid = {?} AND ei.item_id = {?} AND e.asso_id = {?} 
        GROUP BY ei.item_id",
-       '-absents@'.$globals->mail->domain,
-       '-participants@'.$globals->mail->domain,
+       '-absents@'.$globals->xnet->evts_domain,
+       '-participants@'.$globals->xnet->evts_domain,
        $eid, $item_id?$item_id:1, $globals->asso('id'));
     $evt = $res->fetchOneAssoc();
     if (!$evt) return false;
index cdfa7c0..8287cd9 100644 (file)
@@ -28,7 +28,7 @@ L'
 
 {if $evt.participant_list}
 <p class="center">
-[<a href="mailto:{$evt.short_name}-participants@polytechnique.org">envoyer un mail à ceux qui viennent</a>] - [<a href="mailto:{$evt.short_name}-absents@polytechnique.org">envoyer un mail aux membres non inscrits</a>]
+[<a href="mailto:{$evt.short_name}-participants@evts.polytechnique.org">envoyer un mail à ceux qui viennent</a>] - [<a href="mailto:{$evt.short_name}-absents@evts.polytechnique.org">envoyer un mail aux membres non inscrits</a>]
 </p>
 {/if}
 
index c4c55c7..e99e126 100644 (file)
@@ -1,7 +1,22 @@
 ALTER TABLE groupex.asso ADD `pub` ENUM( 'public', 'private' ) DEFAULT 'public' NOT NULL AFTER `ax` ;
 ALTER TABLE groupex.evenements_participants ADD PRIMARY KEY (eid, item_id, uid);
-ALTER TABLE groupex.evenements ADD `show_participants` TINYINT( 1 ) NOT NULL ;
 ALTER TABLE groupex.evenements_participants ADD paid FLOAT DEFAULT 0 NOT NULL;
 ALTER TABLE virtual CHANGE `type` `type` ENUM('user', 'list', 'dom', 'evt') DEFAULT 'user' NOT NULL;
-ALTER TABLE groupex.evenements ADD `short_name` VARCHAR(30) DEFAULT '' NOT NULL;
+DROP TABLE groupex.evenements;
+CREATE TABLE groupex.evenements (
+       `eid` int(8) unsigned NOT NULL auto_increment,
+       `asso_id` int(8) unsigned NOT NULL default '0',
+       `organisateur_uid` int(8) unsigned NOT NULL default '0',
+       `intitule` varchar(100) NOT NULL default '',
+       `short_name` varchar(30) NOT NULL default '',
+       `paiement_id` int(8) unsigned default NULL,
+       `descriptif` text NOT NULL,
+       `debut` datetime NOT NULL default '0000-00-00 00:00:00',
+       `fin` datetime default NULL,
+       `membres_only` tinyint(1) NOT NULL default '0',
+       `advertise` tinyint(1) NOT NULL default '0',
+       `show_participants` tinyint(1) NOT NULL default '0',
+       PRIMARY KEY  (`eid`)
+) TYPE=MyISAM;
+INSERT INTO virtual_domains VALUES ('evts.polytechnique.org');