platform/plugins/Streams/handlers/Streams/stream/delete.php - Q Platform
Show:

File: platform/plugins/Streams/handlers/Streams/stream/delete.php

  1. <?php
  2.  
  3. /**
  4. * Used to close an existing stream. A cron job may delete this stream later.
  5. *
  6. * @module Streams
  7. * @class Streams_stream
  8. * @method delete
  9. * @static
  10. * @param {array} $_REQUEST
  11. * @param {string} $_REQUEST.publisherId The id of the stream publisher
  12. * @param {string} $_REQUEST.streamName The name of the stream the user will be invited to
  13. */
  14. function Streams_stream_delete() {
  15. $user = Users::loggedInUser(true);
  16. $publisherId = Streams::requestedPublisherId(true);
  17. $streamName = Streams::requestedName(true);
  18. $stream = Streams::fetchOne(null, $publisherId, $streamName, true);
  19. $close = Streams_Stream::getConfigField($stream->type, 'close', true);
  20. if (!$close) {
  21. throw new Q_Exception("This app doesn't let clients directly close streams of type ".$stream->type, 'type');
  22. }
  23. Streams::$cache['result'] = Streams::close($user->id, $publisherId, $streamName);
  24. // NOTE: we did not delete the stream. That will have to be done in a cron job like this:
  25. // // Clean up access
  26. // $stream->delete();
  27. // Streams_Access::delete()->where(array(
  28. // 'publisherId' => $stream->publisherId,
  29. // 'streamName' => $stream->name
  30. // ))->execute();
  31. Q_Response::setSlot('result', Streams::$cache['result']);
  32. }