Integration of the new BPLC payment system.
[platal.git] / modules / survey.php
index 199d96d..6fadc20 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -403,7 +403,19 @@ class SurveyModule extends PLModule
             if (!S::logged()) {
                 return false;
             }
-            if (!$survey->checkPromo(S::v('promo'))) { // checks promotion
+            $profile = S::user()->profile();
+            if (!$profile) {
+                return false;
+            }
+            // checks promotion
+            $allowed = false;
+            foreach ($profile->yearspromo() as $p) {
+                if ($survey->checkPromo($p)) {
+                    $allowed = true;
+                    break;
+                }
+            }
+            if (!$allowed) {
                 $page->kill("Tu n'as pas accès à ce sondage car il est réservé à d'autres promotions.");
             }
         }