function handler_create($page) { global $globals; $page->changeTpl('lists/create.tpl'); $user_promo = S::user()->profile()->yearPromo(); $year = date('Y'); $month = date('m'); // scolar year starts in september $scolarmonth = ($year - $user_promo) * 12 + ($month - 8); $young_promo = $very_young_promo = 0; // binet are accessible only in april in the first year and until // march of the 5th year if ($scolarmonth >= 8 && $scolarmonth < 56) { $young_promo = 1; } // PSC aliases are accesible only between september and june of the second // year of scolarity if ($scolarmonth >= 12 && $scolarmonth < 22) { $very_young_promo = 1; } $page->assign('young_promo', $young_promo); $page->assign('very_young_promo', $very_young_promo); $owners = preg_split("/[\\s]+/", Post::v('owners'), -1, PREG_SPLIT_NO_EMPTY); $members = preg_split("/[\\s]+/", Post::v('members'), -1, PREG_SPLIT_NO_EMPTY); // click on validate button 'add_owner_sub' or type <enter> if (Post::has('add_owner_sub') && Post::has('add_owner')) { // if we want to add an owner and then type <enter>, then both // add_owner_sub and add_owner are filled. $oforlifes = User::getBulkForlifeEmailsFromEmail(Post::v('add_owner')); $mforlifes = User::getBulkForlifeEmailsFromEmail(Post::v('add_member')); if (!is_null($oforlifes)) { $owners = array_merge($owners, $oforlifes); } // if we want to add a member and then type <enter>, then // add_owner_sub is filled, whereas add_owner is empty. if (!is_null($mforlifes)) { $members = array_merge($members, $mforlifes); } } // click on validate button 'add_member_sub' if (Post::has('add_member_sub') && Post::has('add_member')) { $forlifes = User::getBulkForlifeEmailsFromEmail(Post::v('add_member')); if (!is_null($forlifes)) { $members = array_merge($members, $forlifes); } } if (Post::has('add_member_sub') && isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) { $upload =& PlUpload::get($_FILES['add_member_file'], S::user()->login(), 'list.addmember', true); if (!$upload) { $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier'); } else { $forlifes = User::getBulkForlifeEmailsFromEmail($upload->getContents()); if (!is_null($forlifes)) { $members = array_merge($members, $forlifes); } } } ksort($owners); $owners = array_unique($owners); ksort($members); $members = array_unique($members); $page->assign('owners', join("\n", $owners)); $page->assign('members', join("\n", $members)); if (!Post::has('submit')) { return; } else { S::assert_xsrf_token(); } $asso = Post::t('asso'); $list = strtolower(Post::t('liste')); if (empty($list)) { $page->trigError('Le champ « adresse souhaitée » est vide.'); } if (!preg_match("/^[a-zA-Z0-9\\-]*\$/", $list)) { $page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.'); } if ($asso == 'binet' || $asso == 'alias') { $promo = Post::i('promo'); $domain = $promo . '.' . $globals->mail->domain; if ($promo < 1921 || $promo > date('Y')) { $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.'); } } elseif ($asso == 'groupex') { $domain = XDB::fetchOneCell('SELECT mail_domain FROM groups WHERE nom = {?}', Post::t('groupex_name')); if (!$domain) { $page->trigError('Il n\'y a aucun groupe de ce nom sur Polytechnique.net.'); } } else { $domain = $globals->mail->domain; } require_once 'emails.inc.php'; if (list_exist($list, $domain)) { $page->trigError("L'« adresse souhaitée » est déjà prise."); } if (!Post::t('desc')) { $page->trigError('Le sujet est vide.'); } if (!count($owners)) { $page->trigError('Il n\'y a pas de gestionnaire.'); } if (count($members) < 4) { $page->trigError('Il n\'y a pas assez de membres.'); } if (!$page->nb_errs()) { $page->trigSuccess('Demande de création envoyée !'); $page->assign('created', true); $req = new ListeReq(S::user(), $asso, $list, $domain, Post::t('desc'), Post::i('advertise'), Post::i('modlevel'), Post::i('inslevel'), $owners, $members); $req->submit(); } }
function handler_acreate($page) { if (!$this->get_lists_domain()) { return PL_NOT_FOUND; } $page->changeTpl('xnetlists/alias-create.tpl'); if (!Post::has('submit')) { return; } else { S::assert_xsrf_token(); } if (!Post::has('liste')) { $page->trigError('Le champs « adresse souhaitée » est vide.'); return; } $list = Post::v('liste'); if (!preg_match("/^[a-zA-Z0-9\\-\\.]*\$/", $list)) { $page->trigError('Le nom de l\'alias ne doit contenir que des lettres,' . ' chiffres, tirets et points.'); return; } require_once 'emails.inc.php'; $lists_domain = $this->get_lists_domain(); if (list_exist($list, $lists_domain)) { $page->trigError('Cet alias est déjà pris.'); return; } add_to_list_alias(S::i('uid'), $list, $lists_domain); pl_redirect('alias/admin/' . $list . '@' . $lists_domain); }