Had to work out the API parent class a bit. Also closing #8 as the API docs are about done. Time to knock out the rest of the API calls so I can start using this shit.
43 lines
900 B
PHP
43 lines
900 B
PHP
<?php
|
|
|
|
class leaderboards extends UserModule
|
|
{
|
|
public function __default()
|
|
{
|
|
// Grabs the user's leaderboards
|
|
$leaderboards = $this->redis->zrevrange('user:' . $this->uid . ':leaderboards:updated', 0, -1, 'WITHSCORES');
|
|
|
|
if ($leaderboards)
|
|
{
|
|
$this->redis->multi();
|
|
|
|
// Grabs the additional fields
|
|
foreach ($leaderboards as $uid => $updated_at)
|
|
{
|
|
unset($leaderboards[$uid]);
|
|
$leaderboards[(int)$uid] = $updated_at;
|
|
|
|
$this->redis->hmget('leaderboard:' . $uid, array('name', 'created_at'));
|
|
}
|
|
|
|
$fields = $this->redis->exec();
|
|
|
|
foreach ($leaderboards as $uid => $updated_at)
|
|
{
|
|
$data = current($fields);
|
|
|
|
$leaderboards[$uid] = array(
|
|
'name' => $data['name'],
|
|
'created_at' => (int)$data['created_at'],
|
|
'updated_at' => (int)$updated_at,
|
|
);
|
|
|
|
next($fields);
|
|
}
|
|
}
|
|
|
|
return array('leaderboards' => $leaderboards);
|
|
}
|
|
}
|
|
|
|
?>
|