if ($this->grade != UserFilter::DISPLAY) {
UserFilter::assertGrade($this->grade);
}
+ if ($this->grade == UserFilter::DISPLAY && $this->comparison != '=') {
+ Platal::page()->killError('Comparison ' . $this->comparison . ' not allowed on displaid promo');
+ }
}
public function buildCondition(PlFilter &$uf)
{
protected function getSortTokens(PlFilter &$uf)
{
+ $uf->requireAccounts();
return 'a.registration_date';
}
}
{
protected function getSortTokens(PlFilter &$uf)
{
+ $uf->requireProfiles();
return 'p.next_birthday';
}
}
{
protected function getSortTokens(PlFilter &$uf)
{
+ $uf->requireProfiles();
return 'p.last_change';
}
}
{
protected function getSortTokens(PlFilter &$uf)
{
+ $uf->requireProfiles();
return 'p.deathdate';
}
}
// }}}
+// {{{ class UFO_Uid
+/** Sorts users based on their uid
+ */
+class UFO_Uid extends UserFilterOrder
+{
+ protected function getSortTokens(PlFilter &$uf)
+ {
+ $uf->requireAccounts();
+ return 'a.uid';
+ }
+}
+// }}
+
+// {{{ class UFO_Hruid
+/** Sorts users based on their hruid
+ */
+class UFO_Hruid extends UserFilterOrder
+{
+ protected function getSortTokens(PlFilter &$uf)
+ {
+ $uf->requireAccounts();
+ return 'a.hruid';
+ }
+}
+// }}}
+
+// {{{ class UFO_Pid
+/** Sorts users based on their pid
+ */
+class UFO_Pid extends UserFilterOrder
+{
+ protected function getSortTokens(PlFilter &$uf)
+ {
+ $uf->requireProfiles();
+ return 'p.pid';
+ }
+}
+// }}
+
+// {{{ class UFO_Hrpid
+/** Sorts users based on their hrpid
+ */
+class UFO_Hrpid extends UserFilterOrder
+{
+ protected function getSortTokens(PlFilter &$uf)
+ {
+ $uf->requireProfiles();
+ return 'p.hrpid';
+ }
+}
+// }}}
+
/***********************************
*********************************
array(self::buildProfileQuery('INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
WHERE pd.promo = {?}', 'X2004'),
new UFC_Promo('=', UserFilter::DISPLAY, 'X2004'), -1),
- array(self::buildProfileQuery('INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
- WHERE pd.promo < {?}', 'X2004'),
- new UFC_Promo('<', UserFilter::DISPLAY, 'X2004'), -1),
- array(self::buildProfileQuery('INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
- WHERE pd.promo > {?}', 'X2004'),
- new UFC_Promo('>', UserFilter::DISPLAY, 'X2004'), -1),
- array(self::buildProfileQuery('INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
- WHERE pd.promo < {?}', 'X1900'),
- new UFC_Promo('<', UserFilter::DISPLAY, 'X1900'), 0),
array(self::buildProfileQuery('INNER JOIN profile_education AS pe ON (pe.pid = p.pid)
LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id)
$this->assertEquals($count, $uf->getTotalProfileCount());
}
+
+ public static function sortProvider()
+ {
+ return array(
+ array(self::buildAccountQuery('ORDER BY a.uid'), new UFO_Uid()),
+ array(self::buildAccountQuery('ORDER BY a.hruid'), new UFO_Hruid()),
+ array(self::buildAccountQuery('ORDER BY a.uid DESC'), new UFO_Uid(true)),
+ array(self::buildAccountQuery('ORDER BY a.hruid DESC'), new UFO_Hruid(true)),
+ array(self::buildProfileQuery('ORDER BY p.pid'), new UFO_Pid()),
+ array(self::buildProfileQuery('ORDER BY p.hrpid'), new UFO_Hrpid()),
+ array(self::buildProfileQuery('ORDER BY p.pid DESC'), new UFO_Pid(true)),
+ array(self::buildProfileQuery('ORDER BY p.hrpid DESC'), new UFO_Hrpid(true)),
+ array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL
+ ORDER BY p.deathdate, p.pid'),
+ array(new UFO_Death(), new UFO_Pid()), new UFC_Dead()),
+ array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL
+ ORDER BY p.deathdate DESC, p.pid'),
+ array(new UFO_Death(true), new UFO_Pid()), new UFC_Dead()),
+ );
+ }
+
+ /**
+ * @dataProvider sortProvider
+ */
+ public function testUserSortAndLimits($query, $sort, $cond = null)
+ {
+ self::checkPlatal();
+
+ $query = XDB::query($query[0]);
+ $count = $query->numRows();
+ $ids = $query->fetchColumn();
+ $this->assertSame($count, count($ids));
+
+ if ($cond == null ) {
+ $cond = new PFC_True();
+ }
+ $uf = new UserFilter($cond, $sort);
+ for ($i = 0 ; $i < $count ; $i += 7987) {
+ $got = $uf->getUIDs(new PlLimit(100, $i));
+ $this->assertSame($count, $uf->getTotalUserCount());
+ $part = array_slice($ids, $i, 100);
+ $this->assertSame($part, $got);
+ }
+ }
+
+ /**
+ * @dataProvider sortProvider
+ */
+ public function testProfileSortAndLimits($query, $sort, $cond = null)
+ {
+ self::checkPlatal();
+
+ $query = XDB::query($query[1]);
+ $count = $query->numRows();
+ $ids = $query->fetchColumn();
+ $this->assertSame($count, count($ids));
+
+ if ($cond == null ) {
+ $cond = new PFC_True();
+ }
+ $uf = new UserFilter($cond, $sort);
+ for ($i = 0 ; $i < $count ; $i += 7987) {
+ $got = $uf->getPIDs(new PlLimit(100, $i));
+ $this->assertSame($count, $uf->getTotalProfileCount());
+ $part = array_slice($ids, $i, 100);
+ $this->assertSame($part, $got);
+ }
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: