|
|
@ -53,77 +53,53 @@ class RoomController extends AbstractController |
|
|
|
$this->getParameter('app.kevacoin.password') |
|
|
|
$this->getParameter('app.kevacoin.password') |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Connect memcached |
|
|
|
|
|
|
|
$memcached = new \Memcached(); |
|
|
|
|
|
|
|
$memcached->addServer( |
|
|
|
|
|
|
|
$this->getParameter('app.memcached.host'), |
|
|
|
|
|
|
|
$this->getParameter('app.memcached.port') |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$memory = md5( |
|
|
|
|
|
|
|
sprintf( |
|
|
|
|
|
|
|
'%s.RoomController::list:rooms', |
|
|
|
|
|
|
|
__DIR__ |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get room list |
|
|
|
// Get room list |
|
|
|
$list = []; |
|
|
|
$list = []; |
|
|
|
|
|
|
|
|
|
|
|
if (!$list = $memcached->get($memory)) |
|
|
|
foreach ((array) $client->kevaListNamespaces() as $value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach ((array) $client->kevaListNamespaces() as $value) |
|
|
|
// Calculate room totals |
|
|
|
{ |
|
|
|
$total = 0; |
|
|
|
// Calculate room totals |
|
|
|
|
|
|
|
$total = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ((array) $client->kevaFilter($value['namespaceId']) as $post) |
|
|
|
foreach ((array) $client->kevaFilter($value['namespaceId']) as $post) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Skip values with meta keys |
|
|
|
|
|
|
|
if (false !== stripos($post['key'], '_KEVA_')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Skip values with meta keys |
|
|
|
continue; |
|
|
|
if (false !== stripos($post['key'], '_KEVA_')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Require valid kevachat meta |
|
|
|
|
|
|
|
if ($this->_post($post)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$total++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add to room list |
|
|
|
// Require valid kevachat meta |
|
|
|
$list[] = |
|
|
|
if ($this->_post($post)) |
|
|
|
[ |
|
|
|
{ |
|
|
|
'namespace' => $value['namespaceId'], |
|
|
|
$total++; |
|
|
|
'total' => $total, |
|
|
|
} |
|
|
|
'pinned' => in_array( |
|
|
|
|
|
|
|
$value['namespaceId'], |
|
|
|
|
|
|
|
(array) explode( |
|
|
|
|
|
|
|
'|', |
|
|
|
|
|
|
|
$this->getParameter('app.kevacoin.room.namespaces.pinned') |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sort by name |
|
|
|
// Add to room list |
|
|
|
array_multisort( |
|
|
|
$list[] = |
|
|
|
array_column( |
|
|
|
[ |
|
|
|
$list, |
|
|
|
'namespace' => $value['namespaceId'], |
|
|
|
'total' |
|
|
|
'total' => $total, |
|
|
|
), |
|
|
|
'pinned' => in_array( |
|
|
|
SORT_DESC, |
|
|
|
$value['namespaceId'], |
|
|
|
$list |
|
|
|
(array) explode( |
|
|
|
); |
|
|
|
'|', |
|
|
|
|
|
|
|
$this->getParameter('app.kevacoin.room.namespaces.pinned') |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Cache rooms to memcached as kevaListNamespaces hides rooms with pending posts |
|
|
|
// Sort by name |
|
|
|
$memcached->set( |
|
|
|
array_multisort( |
|
|
|
$memory, |
|
|
|
array_column( |
|
|
|
$list, |
|
|
|
$list, |
|
|
|
(int) $this->getParameter('app.memcached.timeout') |
|
|
|
'total' |
|
|
|
); |
|
|
|
), |
|
|
|
} |
|
|
|
SORT_DESC, |
|
|
|
|
|
|
|
$list |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// RSS |
|
|
|
// RSS |
|
|
|
if ('rss' === $request->get('feed')) |
|
|
|
if ('rss' === $request->get('feed')) |
|
|
|