X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp.php;h=71b5b75638bdc6e03d1c01a00c647d9a628d093d;hb=8c5bbd3f286135e2229be855492e00cd940c3550;hp=04242313009712571de6ab217698e5f77a6a684b;hpb=445d244cc8597f6fef76b602dbfe9ec598c84ff7;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 0424231..71b5b75 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -184,20 +184,26 @@ class XnetGrpModule extends PLModule $page->trigError('Ni le nom ni le diminutif du groupe ne peuvent être vide.'); return; } + $axDate = make_datetime(Post::v('axDate')); + if (Post::t('axDate') != '') { + $axDate = make_datetime(Post::v('axDate'))->format('Y-m-d'); + } else { + $axDate = null; + } XDB::execute( "UPDATE groups SET nom={?}, diminutif={?}, cat={?}, dom={?}, descr={?}, site={?}, mail={?}, resp={?}, - forum={?}, mail_domain={?}, ax={?}, pub={?}, + forum={?}, mail_domain={?}, ax={?}, axDate = {?}, pub={?}, sub_url={?}, inscriptible={?}, unsub_url={?}, 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'), - Post::has('ax'), Post::v('pub'), + Post::has('ax'), $axDate, Post::v('pub'), Post::v('sub_url'), Post::v('inscriptible'), Post::v('unsub_url'), $flags, $globals->asso('id')); if (Post::v('mail_domain')) { @@ -249,11 +255,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(); @@ -628,7 +632,6 @@ class XnetGrpModule extends PLModule global $globals; $page->changeTpl('xnetgrp/membres-add.tpl'); - $page->addJsLink('ajax.js'); if (is_null($email)) { return; @@ -700,8 +703,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()); @@ -916,11 +919,12 @@ class XnetGrpModule extends PLModule // Update group params for user $perms = Post::v('group_perms'); $comm = Post::t('comm'); - if ($user->group_perms != $perms || $user->group_comm != $comm) { + $position = (Post::t('group_position') == '') ? null : Post::v('group_position'); + if ($user->group_perms != $perms || $user->group_comm != $comm || $user->group_position != $position) { XDB::query('UPDATE group_members - SET perms = {?}, comm = {?} + SET perms = {?}, comm = {?}, position = {?} WHERE uid = {?} AND asso_id = {?}', - ($perms == 'admin') ? 'admin' : 'membre', $comm, + ($perms == 'admin') ? 'admin' : 'membre', $comm, $position, $user->id(), $globals->asso('id')); if (XDB::affectedRows()) { if ($perms != $user->group_perms) { @@ -929,6 +933,9 @@ class XnetGrpModule extends PLModule if ($comm != $user->group_comm) { $page->trigSuccess('Commentaire mis à jour.'); } + if ($position != $user->group_position) { + $page->trigSuccess('Poste mis à jour.'); + } } } @@ -989,9 +996,13 @@ class XnetGrpModule extends PLModule } } + $res = XDB::rawFetchAllAssoc('SHOW COLUMNS FROM group_members LIKE \'position\''); + $positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']); + $page->assign('user', $user); $page->assign('listes', $mmlist->get_lists($user->forlifeEmail())); $page->assign('alias', $user->emailAliases($globals->asso('mail_domain'), 'user', true)); + $page->assign('positions', explode(',', $positions)); } function handler_rss(&$page, $user = null, $hash = null) @@ -1148,7 +1159,6 @@ class XnetGrpModule extends PLModule $aid, $imgtype, $imgx, $imgy, $upload->getContents()); } if ($art['xorg']) { - require_once('validations.inc.php'); $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext, $art['promo_min'], $art['promo_max'], $art['expiration'], "", S::user(), $upload); @@ -1158,7 +1168,6 @@ class XnetGrpModule extends PLModule $upload->rm(); } if ($art['nl']) { - require_once('validations.inc.php'); $article = new NLReq(S::user(), $globals->asso('nom') . " : " .$art['titre'], $art['texte'], $art['contact_html']); $article->submit(); @@ -1174,9 +1183,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(); } }