X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fprofile.php;h=663f2f7a723ea33392cd3d96c6f2f5ea21b53188;hb=f6e35ff3fefafe908e1675690340ab93265192a0;hp=53d91009079eb8da4c965e4ca36959cedbd50ff8;hpb=61ee68c710d93fe2de9484ef95b6652e6ac48547;p=platal.git diff --git a/classes/profile.php b/classes/profile.php index 53d9100..663f2f7 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -195,6 +195,25 @@ class Profile return intval(substr($this->promo, 1, 4)); } + /** Check if user is an orange (associated with several promos) + */ + public function isMultiPromo() + { + return $this->grad_year != $this->entry_year + $this->mainEducationDuration(); + } + + /** Returns an array with all associated promo years. + */ + public function yearspromo() + { + $promos = array(); + $d = -$this->deltaPromoToGradYear(); + for ($g = $this->entry_year + $this->mainEducationDuration(); $g <= $this->grad_year; ++$g) { + $promos[] = $g + $d; + } + return $promos; + } + public function mainEducation() { if (empty($this->promo)) { @@ -204,6 +223,20 @@ class Profile } } + public function mainGrade() + { + switch ($this->mainEducation()) { + case 'X': + return UserFilter::GRADE_ING; + case 'M': + return UserFilter::GRADE_MST; + case 'D': + return UserFilter::GRADE_PHD; + default: + return null; + } + } + public function mainEducationDuration() { switch ($this->mainEducation()) { @@ -218,6 +251,18 @@ class Profile } } + /** Number of years between the promotion year until the + * graduation year. In standard schools it's 0, but for + * Polytechnique the promo year is the entry year. + */ + public function deltaPromoToGradYear() + { + if ($this->mainEducation() == 'X') { + return $this->mainEducationDuration(); + } + return 0; + } + /** Print a name with the given formatting: * %s = • for women * %f = firstname @@ -343,6 +388,16 @@ class Profile return property_exists($this, $name) || isset($this->data[$name]); } + public function __unset($name) + { + if (property_exists($this, $name)) { + $this->$name = null; + } else { + unset($this->data[$name]); + } + } + + /** Sets the level of visibility of the profile * Sets $this->visibility to a list of valid visibilities. * @param one of the self::VIS_* values @@ -897,7 +952,7 @@ class Profile WHERE n.pid = {?}", $pid); - foreach ($keys as $i => $key) { + while ($key = $keys->next()) { if ($key['name'] == '') { continue; }