public function buildCondition(PlFilter &$uf)
{
$uf->requireProfiles();
- return 'p.pid IS NOT NULL';
+ return '$PID IS NOT NULL';
}
}
// }}}
UserFilter::assertGrade($this->grade);
}
if ($this->grade == UserFilter::DISPLAY && $this->comparison != '=') {
- Platal::page()->killError('Comparison ' . $this->comparison . ' not allowed on displaid promo');
+ // XXX: we might try to guess the grade from the first char of the promo and forbid only '<= 2004', but allow '<= X2004'
+ Platal::page()->killError("Il n'est pas possible d'appliquer la comparaison '" . $this->comparison . "' aux promotions sans spécifier de formation (X/M/D)");
}
}
{
$uf->requireAccounts();
if ($this->active) {
- $date = 'a.uid IS NOT NULL AND a.state = \'active\'';
+ $date = '$UID IS NOT NULL AND a.state = \'active\'';
} else {
- $date = 'a.uid IS NOT NULL AND a.state != \'pending\'';
+ $date = '$UID IS NOT NULL AND a.state != \'pending\'';
}
if (!is_null($this->comparison)) {
$date .= ' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date ' . $this->comparison . ' ' . XDB::format('{?}', $this->date->format('Y-m-d'));
$conds = array();
$conds[] = $sub . '.address ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->value);
if ($this->type != -1) {
- $conds[] = $sub . '.network_type = ' . XDB::format('{?}', $this->type);
+ $conds[] = $sub . '.nwid = ' . XDB::format('{?}', $this->type);
}
return implode(' AND ', $conds);
}
if (count($uids) == 0) {
return PlFilterCondition::COND_FALSE;
} else {
- return XDB::format('a.uid IN {?}', $uids);
+ return XDB::format('$UID IN {?}', $uids);
}
}
}
{
$toks = $uf->getNameTokens();
$scores = array();
+
+ // If there weren't any sort tokens, we shouldn't sort by score, sort by NULL instead
+ if (count($toks) == 0) {
+ return 'NULL';
+ }
+
foreach ($toks as $sub => $token) {
$scores[] = XDB::format('SUM(' . $sub . '.score + IF (' . $sub . '.token = {?}, 5, 0) )', $token);
}
protected function getSortTokens(PlFilter &$uf)
{
$uf->requireAccounts();
- return 'a.uid';
+ return '$UID';
}
}
// }}}
protected function getSortTokens(PlFilter &$uf)
{
$uf->requireProfiles();
- return 'p.pid';
+ return '$PID';
}
}
// }}}
$this->buildQuery();
$lim = $limit->getSql();
$cond = '';
- if (!is_null($uids)) {
+ if (!empty($uids)) {
$cond = XDB::format(' AND a.uid IN {?}', $uids);
}
$fetched = XDB::fetchColumn('SELECT SQL_CALC_FOUND_ROWS a.uid
public function getUID($pos = 0)
{
- $uids =$this->getUIDList(null, new PlFilter(1, $pos));
+ $uids =$this->getUIDList(null, new PlLimit(1, $pos));
if (count($uids) == 0) {
return null;
} else {
public function getPID($pos = 0)
{
- $pids =$this->getPIDList(null, new PlFilter(1, $pos));
+ $pids =$this->getPIDList(null, new PlLimit(1, $pos));
if (count($pids) == 0) {
return null;
} else {
$key = array($key);
}
$joins['e' . $sub] = PlSqlJoin::left('emails', '$ME.uid = $UID AND $ME.flags != \'filter\'
- AND $ME.email IN {?}' . $key);
+ AND $ME.email IN {?}', $key);
}
}
foreach ($this->al as $sub=>$key) {