/** * Call this function to relate a stream to category streams for things happening * around the given location, about a certain interest. * @method relateTo * @static * @param {string} $publisherId The publisherId of the category streams * @param {double} $latitude The latitude of the coordinates near which to relate * @param {double} $longitude The longitude of the coordinates near which to relate * @param {double} $title The title of the interest, which will be normalized * @param {array} $options The options to pass to the Streams::relate and Streams::create functions. Also can contain the following options: * @param {array} [$options.miles] Override the default set of distances found in the config under Places/nearby/miles * @param {callable} [$options.create] If set, this callback will be used to create streams when they don't already exist. It receives the $options array and should return a Streams_Stream object. If this option is set to null, new streams won't be created. * @param {callable} [$options.transform="array_keys"] Can be used to override the function which takes the output of Places_Nearby::forPublishers, and this $options array, and returns the array of ($originalStreamName => $newStreamName) pairs. * @param {array} [$streamNames=null] Optional reference to fill with the stream names * @return {array|boolean} Returns the array of category streams */ static function streams($publisherId, $latitude, $longitude, $title, $options = array(), &$streamNames = array()) { $options = array_merge(array('transform' => array('Places_Interest', '_transform'), 'create' => array('Places_Interest', '_create'), 'title' => $title), $options); return Places_Nearby::streams($publisherId, $latitude, $longitude, $options, $streamNames); }
/** * Call this function to unsubscribe from streams you previously subscribed to * using Places_Nearby::subscribe. * @method unsubscribe * @static * @param {double} $latitude The latitude of the coordinates to subscribe around * @param {double} $longitude The longitude of the coordinates to subscribe around * @param {double} $miles The radius, in miles, around this location. * Should be one of the array values in the Places/nearby/miles config. * @param {string} $publisherId The id of the publisher publishing these streams. * Defaults to the app name in Q/app config. * @param {array} $options The options to pass to the unsubscribe function * @return {Array} Returns an array of up to four arrays of ($publisherId, $streamName) * of streams that were subscribed to. */ static function unsubscribe($latitude, $longitude, $miles, $publisherId = null, $options = array()) { $user = Users::loggedInUser(true); if (!isset($publisherId)) { $publisherId = Users::communityId(); } $options['forSubscribers'] = true; $options['miles'] = $miles; $streams = Places_Nearby::streams($publisherId, $latitude, $longitude, $options); return Streams::unsubscribe($user->id, $publisherId, $streams, $options); }