function cleanupChannels() { $rc = new Realtime_channel(); $rc->selectAdd(); $rc->selectAdd('channel_key'); $rc->whereAdd('modified < "' . common_sql_date(time() - Realtime_channel::TIMEOUT) . '"'); if ($rc->find()) { $keys = $rc->fetchAll(); foreach ($keys as $key) { $rc = Realtime_channel::staticGet('channel_key', $key); if (!empty($rc)) { printfv("Deleting realtime channel '{$key}'\n"); $rc->delete(); } } } }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); if (!$this->isPost()) { // TRANS: Client exception. Do not translate POST. throw new ClientException(_m('You have to POST it.')); } $this->channelKey = $this->trimmed('channelkey'); if (empty($this->channelKey)) { // TRANS: Client exception thrown when the channel key argument is missing. throw new ClientException(_m('No channel key argument.')); } $this->channel = Realtime_channel::staticGet('channel_key', $this->channelKey); if (empty($this->channel)) { // TRANS: Client exception thrown when referring to a non-existing channel. throw new ClientException(_m('No such channel.')); } return true; }