+// {{{ abstract class UserFilterOrder
+/** Class providing factories for the UserFilterOrders.
+ */
+abstract class UserFilterOrders
+{
+ public static function fromExport(array $export)
+ {
+ $export = new PlDict($export);
+ if (!$export->has('type')) {
+ throw new Exception("Missing type in export");
+ }
+ $type = $export->s('type');
+ $desc = ($export->s('order') == 'desc');
+ switch ($type) {
+ case 'promo':
+ return new UFO_Promo($export->v('grade'), $desc);
+
+ case 'lastname':
+ case 'name':
+ case 'firstname':
+ case 'nickname':
+ case 'pseudonym':
+ return new UFO_Name($type, $export->v('variant'),
+ $export->b('particle'), $desc);
+
+ case 'score':
+ case 'registration':
+ case 'birthday':
+ case 'profile_update':
+ case 'death':
+ case 'uid':
+ case 'hruid':
+ case 'pid':
+ case 'hrpid':
+ $class = 'UFO_' . str_replace('_', '', $type);
+ return new $class($desc);
+
+ default:
+ throw new Exception("Unknown order field: $type");
+ }
+ }
+}
+// }}}