$this->make_hook('index', AUTH_COOKIE, 'user'), 'deltaten' => $this->make_hook('index', AUTH_COOKIE, 'user'), ); } /** Check whether a given user is in a "DeltaTen" promo. * This is based on "has a profile, is an X, and is in a young enough promo". */ protected function isDeltaTenEnabled(User $user, $role) { if (!$user->hasProfile()) { return false; } return $user->profile()->isDeltaTenEnabled($role); } function handler_index($page, $action='', $subaction='') { global $globals; if (!$this->isDeltaTenEnabled(S::user(), Profile::DELTATEN_YOUNG)) { $page->killError("Ta promotion ne participe pas à l'opération N N-10."); } if ($this->isDeltaTenEnabled(S::user(), Profile::DELTATEN_OLD)) { $profile = S::user()->profile(); if ($profile->getDeltatenMessage()) { $page->trigSuccess("Tu participes bien à l'opération N N-10 en tant qu'ancien."); } else { $page->trigWarning("Tu ne participes pas encore à l'opération N N-10 en tant qu'ancien."); } } $page->setTitle("Opération N N-10"); $page->assign('deltaten_promo_old', S::user()->profile()->yearpromo() - 10); $wp = new PlWikiPage('Docs.Deltaten'); $wp->buildCache(); require_once 'ufbuilder.inc.php'; $ufb = new UFB_DeltaTenSearch(); $page->addJsLink('search.js'); if (!$ufb->isEmpty()) { require_once 'userset.inc.php'; $ufc = $ufb->getUFC(); if (!$ufc instanceof PFC_And) { $ufc = new PFC_And($ufc); } $ufc->addChild(new UFC_DeltaTen()); $ufc->addChild(new UFC_Promo('=', UserFilter::GRADE_ING, S::user()->profile()->yearpromo() - 10)); $set = new ProfileSet($ufc); $set->addMod('minifiche', 'Opération N N-10'); $set->apply('deltaten/search', $page, $action, $subaction); $nb_tot = $set->count(); if ($nb_tot > $globals->search->private_max) { $page->assign('formulaire', 1); $page->trigError('Recherche trop générale.'); $page->assign('plset_count', 0); } else if ($nb_tot == 0) { $page->assign('formulaire', 1); $page->trigError("Il n'existe personne correspondant à ces critères dans la base."); } } $page->changeTpl('deltaten/index.tpl'); } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>