/** * Used to get list of streams * * @param string $params * publisher id and stream name of existing stream shall be supplied * @return {void} * array of streams indexed by names */ function Streams_publisher_get($params) { // only logged in user can get stream $user = Users::loggedInUser(true); $publisherId = Streams::requestedPublisherId(true); $name = Streams::requestedName(true); $options = array_merge($_REQUEST, $params); return Streams::get($user->id, $publisherId, $name, $options); }
/** * This tool generates a category selector. * * @param array $options * An associative array of parameters, containing: * "publisherId" => Optional. publisherId of the stream to present. If "stream" parameter is empty * defaults to Streams::requestedPublisherId() * "name" => Optional. the name of the stream to present. If "stream" parameter is empty * defaults to Streams::requestedName() * "stream" => Optional. Object. The stream objects to show categories. */ function Streams_category_tool($options) { extract($options); $user = Users::loggedInUser(true); $userId = $user->id; // PK of stream to manage categories $publisherId = Streams::requestedPublisherId(true); $name = Streams::requestedName(true); $stream = Streams::get($userId, $publisherId, $name, null, true); if (!$stream) { throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => "{publisherId: {$publisherId}, name: {$name}}")); } // activate tool frontend $default = array('publisherId' => $stream->publisherId, 'name' => $stream->name); $options = array_merge($default, $options); Q_Response::setToolOptions($options); // get the list of categories list($relations, $categories) = Streams::related($userId, $publisherId, $name, true); return Q::view("Streams/tool/category.php", compact('relations', 'categories', 'stream')); }
/** * Provide player content to view the stream content * Uses Streams/$type/get.php view and Streams::get to retrieve stream data * **/ function Streams_get_response_player() { $user = Users::loggedInUser(); $userId = $user ? $user->id : 0; $publisherId = Streams::requestedPublisherId(true); $name = Streams::requestedName(true); if (substr($name, -1) === '/') { throw new Q_Exception("Player cannot show multiple streams", compact('publisherId', 'name')); } /* * Get shall return only streams which user is authorized to see. */ if (!($stream = Streams::get($userId, $publisherId, $name, null, true))) { throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => compact('publisherId', 'name'))); } // join the stream if ($userId !== 0 && $stream->testWriteLevel('join')) { Streams_Stream::join($userId, $stream->publisherId, $stream->name); } // Let's be nice to poor Windows users $type = join(DS, explode('/', $stream->type)); return Q::view("Streams/{$type}/get.php", compact('stream', 'userId')); }