X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp.php;h=9187c47d7e99d0bddb0a4bcf90ee0e46c0ece224;hb=916b4ee3e800729a93cfb4e3da0c56818baf7c3f;hp=4fded5fe68419e527a911fee28da27b4f5c467c5;hpb=4abb0fe4bcefc73a18891e9768640d8811a09acc;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 4fded5f..9187c47 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -401,13 +401,13 @@ class XnetGrpModule extends PLModule $mailer->setSubject('[' . $globals->asso('nom') . '] Demande d\'inscription'); $message = ($user->isFemale() ? 'Chère' : 'Cher') . " Camarade,\n" . "\n" - . " Suite à ta demande d'adhésion à " . $globals->asso('nom') . ",\n" - . "j'ai le plaisir de t'annoncer que ton inscription a été validée !\n" + . " Suite à ta demande d'adhésion à " . $globals->asso('nom') + . ", j'ai le plaisir de t'annoncer que ton inscription a été validée !\n" . "\n" . "Bien cordialement,\n" . "-- \n" . S::user()->fullName() . '.'; - $mailer->setTxtBody($message); + $mailer->setTxtBody(wordwrap($message, 72)); $mailer->send(); } } @@ -674,18 +674,27 @@ 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); } } @@ -1139,7 +1148,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 +1157,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();