X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fuserfilter.php;h=30a7029cac9f3cd4300b13cad621605b548f9554;hb=c52d86d1d876e6def108e1d458604cc9714c252d;hp=a2e616e45afdc9c0ee40e71f2b631b3f6ab5bfd1;hpb=009b8ab7a296ce9ad4ee41c5e6716ae451a7ddd7;p=platal.git diff --git a/classes/userfilter.php b/classes/userfilter.php index a2e616e..30a7029 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -460,7 +460,7 @@ class UFC_WatchRegistration extends UFC_UserRelated if (count($uids) == 0) { return UserFilterCondition::COND_FALSE; } else { - return '$UID IN (' . implode(', ', $uids) . ')'; + return '$UID IN ' . XDB::formatArray($uids); } } } @@ -482,7 +482,7 @@ class UFC_WatchPromo extends UFC_UserRelated } else { $sube = $uf->addEducationFilter(true, $this->grade); $field = 'pe' . $sube . '.' . UserFilter::promoYear($this->grade); - return $field . ' IN (' . implode(', ', $promos) . ')'; + return $field . ' IN ' . XDB::formatArray($promos); } } } @@ -725,7 +725,7 @@ class UserFilter } $cond = ''; if (!is_null($uids)) { - $cond = ' AND a.uid IN (' . implode(', ', $uids) . ')'; + $cond = ' AND a.uid IN ' . XDB::formatArray($uids); } $fetched = XDB::fetchColumn('SELECT SQL_CALC_FOUND_ROWS a.uid ' . $this->query . $cond . ' @@ -754,8 +754,13 @@ class UserFilter $table = array(); $uids = array(); foreach ($users as $user) { - $uids[] = $user->id(); - $table[$user->id()] = $user; + if ($user instanceof PlUser) { + $uid = $user->id(); + } else { + $uid = $user; + } + $uids[] = $uid; + $table[$uid] = $user; } $fetched = $this->getUIDList($uids, $count, $offset); $output = array(); @@ -813,6 +818,16 @@ class UserFilter return new UserFilter(new UFC_And($min, $max)); } + static public function sortByName() + { + return array(new UFO_Name(self::LASTNAME), new UFO_Name(self::FIRSTNAME)); + } + + static public function sortByPromo() + { + return array(new UFO_Promo(), new UFO_Name(self::LASTNAME), new UFO_Name(self::FIRSTNAME)); + } + static private function getDBSuffix($string) { return preg_replace('/[^a-z0-9]/i', '', $string);