Happy New Year!
[platal.git] / modules / xnetgrp.php
index 9187c47..9274953 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -193,7 +193,7 @@ class XnetGrpModule extends PLModule
                              flags={?}
                       WHERE  id={?}",
                       Post::v('nom'), Post::v('diminutif'),
-                      Post::v('cat'), Post::i('dom'),
+                      Post::v('cat'), (Post::i('dom') == 0) ? null : Post::i('dom'),
                       Post::v('descr'), $site,
                       Post::v('mail'), Post::v('resp'),
                       Post::v('forum'), Post::v('mail_domain'),
@@ -249,11 +249,9 @@ class XnetGrpModule extends PLModule
         global $globals;
 
         $page->changeTpl('xnetgrp/mail.tpl');
-        $mmlist = new MMList(S::v('uid'), S::v('password'),
-                           $globals->asso('mail_domain'));
+        $mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
         $page->assign('listes', $mmlist->get_lists());
         $page->assign('user', S::user());
-        $page->addJsLink('ajax.js');
 
         if (Post::has('send')) {
             S::assert_xsrf_token();
@@ -374,7 +372,7 @@ class XnetGrpModule extends PLModule
             $filename = $globals->asso('diminutif') . '.csv';
         }
         $users = $globals->asso()->getMembersFilter(null, new UFO_Name('directory_name'))->getUsers();
-        pl_content_headers("text/x-csv");
+        pl_cached_content_headers('text/x-csv', 1);
         $page->changeTpl('xnetgrp/annuaire-csv.tpl', NO_SKIN);
         $page->assign('users', $users);
     }
@@ -628,7 +626,6 @@ class XnetGrpModule extends PLModule
         global $globals;
 
         $page->changeTpl('xnetgrp/membres-add.tpl');
-        $page->addJsLink('ajax.js');
 
         if (is_null($email)) {
             return;
@@ -700,8 +697,8 @@ class XnetGrpModule extends PLModule
         }
 
         if ($user) {
-            XDB::execute('REPLACE INTO  group_members (uid, asso_id)
-                                VALUES  ({?}, {?})',
+            XDB::execute('INSERT IGNORE INTO  group_members (uid, asso_id)
+                                      VALUES  ({?}, {?})',
                          $user->id(), $globals->asso('id'));
             $this->removeSubscriptionRequest($user->id());
             pl_redirect('member/' . $user->login());
@@ -1172,9 +1169,10 @@ class XnetGrpModule extends PLModule
                            $art['id'], $globals->asso('id'));
                 if ($art['photo'] && $upload->exists()) {
                     list($imgx, $imgy, $imgtype) = $upload->imageInfo();
-                    XDB::execute("REPLACE INTO  group_announces_photo
-                                           SET  eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}",
-                                 $aid, $imgtype, $imgx, $imgy, $upload->getContents());
+                    XDB::execute('INSERT INTO  group_announces_photo (eid, attachmime, attach, x, y)
+                                       VALUES  ({?}, {?}, {?}, {?}, {?})
+                      ON DUPLICATE KEY UPDATE  attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)',
+                                 $aid, $imgtype, $upload->getContents(), $imgx, $imgy);
                     $upload->rm();
                 }
             }