}
}
+class UFC_Profile implements UserFilterCondition
+{
+ public function buildCondition(UserFilter &$uf)
+ {
+ return '$PID IS NOT NULL';
+ }
+}
+
class UFC_Promo implements UserFilterCondition
{
if (count($uids) == 0) {
return UserFilterCondition::COND_FALSE;
} else {
- return '$UID IN (' . implode(', ', $uids) . ')';
+ return '$UID IN ' . XDB::formatArray($uids);
}
}
}
} 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);
}
}
}
$where = $this->root->buildCondition($this);
$joins = $this->buildJoins();
$this->query = 'FROM accounts AS a
- INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', ap.perms))
- INNER JOIN profiles AS p ON (p.pid = ap.pid)
+ LEFT JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', ap.perms))
+ LEFT JOIN profiles AS p ON (p.pid = ap.pid)
' . $joins . '
WHERE (' . $where . ')';
}
$limit = '';
if (!is_null($count)) {
if (!is_null($offset)) {
- $limit = XDB::format('LIMIT {?}, {?}', $offset, $count);
+ $limit = XDB::format('LIMIT {?}, {?}', (int)$offset, (int)$count);
} else {
- $limit = XDB::format('LIMIT {?}', $count);
+ $limit = XDB::format('LIMIT {?}', (int)$count);
}
}
$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 . '
$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();
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);