X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp.php;h=b894d6491d24643b37a8df9e1b373338da268f4e;hb=d101a069d4d197e27fafac9f773e623eee140849;hp=b4bc9f471e9b11e88cf5bfdbebd8037947f2ad97;hpb=f41e70e9a234a24a4da648a2860d518d4e9934c2;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index b4bc9f4..b894d64 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -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(); @@ -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; @@ -674,25 +671,34 @@ class XnetGrpModule extends PLModule } } else { // User is of type xnet. - list($firstname, $lastname) = explode('@', $email); - $hruid = User::makeHrid($firstname, $lastname, 'ext'); + list($mbox, $domain) = explode('@', strtolower($email)); + $hruid = User::makeHrid($mbox, $domain, 'ext'); // User might already have an account (in another group for example). $user = User::get($hruid); // If the user has no account yet, creates new account: build names from email address. if (empty($user)) { - $display_name = ucwords(strtolower(substr($hruid, strpos('.', $hruid)))); - $full_name = ucwords(strtolower(str_replace('.', ' ', substr($email, strpos('@', $email))))); - XDB::execute('INSERT INTO accounts (hruid, display_name, full_name, email, type) - VALUES ({?}, {?}, {?}, {?}, \'xnet\')', - $hruid, $display_name, $full_name, $email); + $parts = explode('.', $mbox); + if (count($parts) == 1) { + $display_name = $full_name = $directory_name = ucfirst($mbox); + } else { + $firstname = ucfirst($parts[0]); + $lastname = ucwords(implode(' ', array_slice($parts, 1))); + $display_name = $firstname; + $full_name = "$firstname $lastname"; + $directory_name = strtoupper($lastname) . " " . $firstname; + } + XDB::execute('INSERT INTO accounts (hruid, display_name, full_name, directory_name, + email, type) + VALUES ({?}, {?}, {?}, {?}, {?}, \'xnet\')', + $hruid, $display_name, $full_name, $directory_name, $email); $user = User::get($hruid); } } 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()); @@ -1139,7 +1145,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); @@ -1149,7 +1154,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(); @@ -1165,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(); } }