Fix 'young promo' for binets and PSC aliases display in list creation
authorPascal Corpet <pascal.corpet@m4x.org>
Sat, 29 May 2010 13:23:24 +0000 (15:23 +0200)
committerPascal Corpet <pascal.corpet@m4x.org>
Sat, 29 May 2010 13:23:24 +0000 (15:23 +0200)
modules/lists.php

index 3e85e72..954ecdd 100644 (file)
@@ -169,14 +169,20 @@ class ListsModule extends PLModule
 
         $page->changeTpl('lists/create.tpl');
 
-        $user_promo  = S::i('promo');
+        $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;
-        if ((($year > $user_promo) && ($month > 3)) && ($year < $user_promo + 5)) {
+        // 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;
         }
-        if ((($year > $user_promo) && ($month > 7)) && (($year < $user_promo + 1) && ($month < 8))) {
+        // 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);