Order educations by graduation year in the database and in the display.
authorStéphane Jacob <jacou@melix.net>
Thu, 21 Aug 2008 13:42:37 +0000 (15:42 +0200)
committerStéphane Jacob <jacou@melix.net>
Thu, 21 Aug 2008 14:38:42 +0000 (16:38 +0200)
modules/profile/general.inc.php

index 0c4191b..794f746 100644 (file)
@@ -86,6 +86,13 @@ class ProfileEdu implements ProfileSetting
     {
     }
 
+    static function sortByGradYear($line1, $line2) {
+        if ($line1['grad_year'] == $line2['grad_year']) {
+            return 0;
+        }
+        return ($line1['grad_year'] < $line2['grad_year']) ? -1 : 1;
+    }
+
     public function value(ProfilePage &$page, $field, $value, &$success)
     {
         $success = true;
@@ -113,6 +120,7 @@ class ProfileEdu implements ProfileSetting
                 }
                 $i++;
             }
+            usort($value, array("ProfileEdu", "sortByGradYear"));
         }
         return $value;
     }