X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fuserfilter%2Forders.inc.php;h=8a872bda3b85793a7084a5a3d86efdc080b455f8;hb=57fc676c5dfbf964c21a6b1a1f6e5abcb08e0b42;hp=0075d1d216d7fe0c0d6ffda19d65c99828c3cc82;hpb=e312c7f33360c594e4088483ebd9342ed11c6340;p=platal.git diff --git a/classes/userfilter/orders.inc.php b/classes/userfilter/orders.inc.php index 0075d1d..8a872bd 100644 --- a/classes/userfilter/orders.inc.php +++ b/classes/userfilter/orders.inc.php @@ -1,6 +1,6 @@ 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); + return new UFO_Name($desc); case 'score': case 'registration': @@ -53,6 +48,7 @@ abstract class UserFilterOrders case 'hruid': case 'pid': case 'hrpid': + case 'is_admin': $class = 'UFO_' . str_replace('_', '', $type); return new $class($desc); @@ -88,6 +84,11 @@ class UFO_Promo extends PlFilterGroupableOrder } } + public function getCondition($promo) + { + return new UFC_Promo(UserFilterCondition::OP_EQUALS, $this->grade, $promo); + } + public function export() { $export = $this->buildExport('promo'); @@ -100,55 +101,35 @@ class UFO_Promo extends PlFilterGroupableOrder // }}} // {{{ class UFO_Name /** Sorts users by name - * @param $type Type of name on which to sort (firstname...) - * @param $variant Variant of that name to use (marital, ordinary...) - * @param $particle Set to true if particles should be included in the sorting order * @param $desc If sort order should be descending */ -class UFO_Name extends PlFilterOrder +class UFO_Name extends PlFilterGroupableOrder { - private $type; - private $variant; - private $particle; + protected function getSortTokens(PlFilter $uf) + { + $sub = $uf->addDisplayFilter(); + $token = 'pd.sort_name'; + if ($uf->accountsRequired()) { + $account_token = Profile::getAccountEquivalentName('sort_name'); + return 'IFNULL(' . $token . ', a.' . $account_token . ')'; + } else { + return $token; + } + } - public function __construct($type, $variant = null, $particle = false, $desc = false) + public function getGroupToken(PlFilter $pf) { - parent::__construct($desc); - $this->type = $type; - $this->variant = $variant; - $this->particle = $particle; + return 'SUBSTRING(' . $this->_tokens . ', 1, 1)'; } - protected function getSortTokens(PlFilter $uf) + public function getCondition($initial) { - if (Profile::isDisplayName($this->type)) { - $sub = $uf->addDisplayFilter(); - $token = 'pd' . $sub . '.' . $this->type; - if ($uf->accountsRequired()) { - $account_token = Profile::getAccountEquivalentName($this->type); - return 'IFNULL(' . $token . ', a.' . $account_token . ')'; - } else { - return $token; - } - } else { - $sub = $uf->addNameFilter($this->type, $this->variant); - if ($this->particle) { - return 'CONCAT(pn' . $sub . '.particle, \' \', pn' . $sub . '.name)'; - } else { - return 'pn' . $sub . '.name'; - } - } + return new UFC_NameInitial($initial); } public function export() { - $export = $this->buildExport($this->type); - if (!is_null($this->variant)) { - $export['variant'] = $this->variant; - } - if ($this->particle) { - $export['particle'] = true; - } + $export = $this->buildExport(); return $export; } } @@ -314,6 +295,23 @@ class UFO_Hrpid extends PlFilterOrder } } // }}} +// {{{ class UFO_IsAdmin +/** Sorts users, putting admins first + */ +class UFO_IsAdmin extends PlFilterOrder +{ + protected function getSortTokens(PlFilter $uf) + { + $uf->requireAccounts(); + return 'a.is_admin'; + } + + public function export() + { + return $this->buildExport('is_admin'); + } +} +// }}} // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>