本文整理汇总了PHP中Streams::requestedPublisherId方法的典型用法代码示例。如果您正苦于以下问题:PHP Streams::requestedPublisherId方法的具体用法?PHP Streams::requestedPublisherId怎么用?PHP Streams::requestedPublisherId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Streams
的用法示例。
在下文中一共展示了Streams::requestedPublisherId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Streams_message_post
/**
* Used to post messages to EXISTING stream
* $_REQUEST shall contain the content of the message. Also may include 'streamNames'
* field which is an array of additional names of the streams to post message to.
*
* @param string $params
* publisher id and stream name of existing stream shall be supplied
* @return {void}
*/
function Streams_message_post()
{
$user = Users::loggedInUser(true);
$publisherId = Streams::requestedPublisherId(true);
$streamName = Streams::requestedName(true);
// check if type is allowed
$streams = Streams::fetch($user->id, $publisherId, $streamName);
if (empty($streams)) {
throw new Streams_Exception_NoSuchStream();
}
$stream = reset($streams);
if (empty($_REQUEST['type'])) {
throw new Q_Exception_RequiredField(array('field' => 'type'), 'type');
}
$type = $_REQUEST['type'];
if (!Q_Config::get("Streams", "types", $stream->type, "messages", $type, 'post', false)) {
throw new Q_Exception("This app doesn't support directly posting messages of type '{$type}' for streams of type '{$stream->type}'");
}
$result = Streams_Message::post($user->id, $publisherId, $streamName, $_REQUEST);
if (is_array($result)) {
Streams::$cache['messages'] = $result;
} else {
Streams::$cache['message'] = $result;
}
}
示例2: Streams_stream_response_data
function Streams_stream_response_data()
{
// happens only during non-GET requests
if (isset(Streams::$cache['removed_count'])) {
return array('removed_count' => Streams::$cache['removed_count']);
}
if (isset(Streams::$cache['result'])) {
return Streams::$cache['result'];
}
if (isset(Streams::$cache['stream'])) {
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
return Streams::$cache['stream']->exportArray(array('asUserId' => $userId));
}
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$user = Users::loggedInUser();
$userId = $user ? $user->id : 0;
$streams = array();
foreach (Streams::fetch($userId, $publisherId, $name, $fields) as $key => $stream) {
$streams[$key] = $stream->exportArray(array('asUserId' => $userId));
if ($userId && !empty($_REQUEST['join'])) {
$stream->join();
// NOTE: one of the rare times we may change state in a response handler
}
}
return Streams::$cache['result'] = array('stream' => empty($streams) ? null : reset($streams));
}
示例3: Streams_category_response_player
/**
* Provide player content to view the members of category listing
* Uses Streams/$type/category.php view (Streams/$streamType/category/get.php can be used for viewing the category
* stream itself if type of category is $streamType/category)
* and Streams::related to retrieve streams data
*
**/
function Streams_category_response_player()
{
$user = Users::loggedInUser();
$userId = $user ? $user->id : 0;
// These are PK of the category!
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
// need to know publisher and type of the streams to list
$streamType = Streams::requestedType();
if ($streamType) {
$prefix = "{$streamType}/";
}
$stream_publisherId = Q::expect('Streams', $streamType, 'publisher');
if (substr($name, -1) === '/') {
throw new Q_Exception("Player cannot show listing for multiple categories", compact('publisherId', 'name'));
}
/*
* Get shall return only streams which user is authorized to see.
*/
$categories = Streams::fetch($userId, $publisherId, $name);
if (empty($categories)) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => compact('publisherId', 'name')));
}
$category = reset($categories);
// Are you authorized to see category content?
if (!$category->testReadLevel('content')) {
throw new Users_Exception_NotAuthorized();
}
// get all the streams which are members of this category
// as Streams::get verifies access rights, it's safe to show all streams' content
list($relations, $streams) = Streams::related($userId, $publisherId, $name, true, array('prefix' => $prefix, 'skipAccess' => true));
Q::view("Stream/{$type}/category.php", compact('relations', 'streams', 'userId'));
}
示例4: Streams_chat_tool
/**
* Renders chat tool.
* @class Streams chat
* @constructor
* @param {array} $options Options for the tool
* @param {string} $options.publisherId Publisher id of the stream to get messsages from.
* @param {string} $options.streamName Required. Name of the stream to get messsages from.
* @param {string} [$options.loadMore] May have one these values: 'scroll', 'click' or 'pull' which indicates what kind of algorithm will be used for loading new messages. 'scroll' means that new messages will be loaded when scrollbar of the chat cointainer reaches the top (for desktop) or whole document scrollbar reaches the top (for android). 'click' will show label with 'Click to see earlier messages' and when user clicks it, new messages will be loaded. Finally, 'pull' implements 'pull-to-refresh' behavior used in many modern applications today when new messages loaded by rubber-scrolling the container by more amount than it actually begins. Defaults to 'scroll' for desktop and Android devices and 'pull' for iOS devices.
*/
function Streams_chat_tool($options)
{
$user = Users::loggedInUser();
$userId = $user ? $user->id : '';
/*
$defaults = array(
'loadMore' => (Q_Request::isTouchscreen() && Q_Request::platform() != 'android') ? 'click' : 'scroll',
'messagesToLoad' => 5,
'messageMaxHeight' => 200
);
$options = array_merge($defaults, $options);
*/
extract($options);
if (!isset($publisherId)) {
$publisherId = Streams::requestedPublisherId(true);
}
if (!isset($streamName)) {
$streamName = Streams::requestedName();
}
$stream = Streams::fetchOne($userId, $publisherId, $streamName);
if (!$stream) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => compact('publisherId', 'streamName')));
}
$options['userId'] = $userId;
if (!isset($options['notLoggedIn'])) {
$options['notLoggedIn'] = 'You are not logged in';
}
if (!isset($options['notAuthorized'])) {
$options['notAuthorized'] = 'You are not authorized';
}
Q_Response::setToolOptions($options);
}
示例5: Streams_message_response_messages
function Streams_message_response_messages()
{
if (isset(Streams::$cache['message'])) {
$message = Streams::$cache['message'];
return Db::exportArray(array($message->ordinal => $message));
}
if (isset(Streams::$cache['messages'])) {
return Db::exportArray(Streams::$cache['messages']);
}
$publisherId = Streams::requestedPublisherId(true);
$streamName = Streams::requestedName(true);
$type = Streams::requestedMessageType();
$stream = Q::ifset(Streams::$cache, 'stream', Streams::fetchOne(null, $publisherId, $streamName, true));
$maxLimit = Streams_Stream::getConfigField($type, 'getMessagesLimit', 100);
$limit = min($maxLimit, Q::ifset($_REQUEST, 'limit', $maxLimit));
if (isset($_REQUEST['ordinal'])) {
$min = $_REQUEST['ordinal'];
$limit = 1;
}
if (isset($_REQUEST['min'])) {
$min = $_REQUEST['min'];
}
$max = isset($_REQUEST['max']) ? $_REQUEST['max'] : -1;
if (isset($_REQUEST['ascending'])) {
$ascending = $_REQUEST['ascending'];
}
if (!$stream->testReadLevel('messages')) {
throw new Users_Exception_NotAuthorized();
}
$messages = $stream->getMessages(compact('type', 'min', 'max', 'limit', 'ascending'));
return Db::exportArray($messages);
}
示例6: Streams_participant_response_participant
function Streams_participant_response_participant()
{
if (isset(Streams::$cache['participant'])) {
return Streams::$cache['participant'];
}
$publisherId = Streams::requestedPublisherId(true);
$streamName = Streams::requestedName(true);
if (empty($_REQUEST['userId'])) {
throw new Q_Exception_RequiredField(array('field' => 'userId'));
}
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
$stream = Streams::fetch($userId, $publisherId, $streamName);
if (empty($stream)) {
throw new Q_Exception_MissingRow(array('table' => 'Stream', 'criteria' => "{publisherId: '{$publisherId}', name: '{$streamName}'}"));
}
$stream = reset($stream);
if (!$stream->testReadLevel('participants')) {
throw new Users_Exception_NotAuthorized();
}
$p = new Streams_Participant();
$p->publisherId = $publisherId;
$p->streamName = $streamName;
$p->userId = $_REQUEST['userId'];
if ($p->retrieve()) {
return $p->exportArray();
}
return null;
}
示例7: Streams_invite_response_data
function Streams_invite_response_data()
{
if (isset(Streams::$cache['invited'])) {
return Streams::$cache['invited'];
}
$user = Users::loggedInUser(true);
$publisherId = Streams::requestedPublisherId();
$streamType = Streams::requestedType();
$invitingUserId = Streams::requestedField('invitingUserId');
$limit = Q::ifset($_REQUEST, 'limit', Q_Config::get('Streams', 'invites', 'limit', 100));
$invited = Streams_Invited::select('*')->where(array('userId' => $user->id, 'state' => 'pending', 'expireTime <' => new Db_Expression('CURRENT_TIMESTAMP')))->limit($limit)->fetchDbRows(null, null, 'token');
$query = Streams_Invite::select('*')->where(array('token' => array_keys($invited)));
if (isset($publisherId)) {
$query = $query->where(array('publisherId' => $publisherId));
}
if (isset($streamType)) {
$query = $query->where(array('streamName' => new Db_Range($streamType . '/', true, false, true)));
}
if (isset($invitingUserId)) {
$query = $query->where(array('invitingUserId' => $invitingUserId));
}
$invites = $query->fetchDbRows();
$streams = array();
foreach ($invites as $invite) {
$stream = new Streams_Stream();
$stream->publisherId = $invite->publisherId;
$stream->name = $invite->streamName;
if ($stream->retrieve()) {
$streams[$invite->token] = $stream->exportArray();
$streams[$invite->token]['displayName'] = $invite->displayName;
}
}
return compact('streams', 'invites');
}
示例8: Streams_publisher_get
/**
* 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);
}
示例9: Streams_access_response_data
function Streams_access_response_data()
{
$user = Users::loggedInUser(true);
$publisherId = Streams::requestedPublisherId(true);
$streamName = Streams::requestedName(true);
$stream = Streams::fetchOne($user->id, $publisherId, $streamName);
if (!$stream->testAdminLevel('own')) {
throw new Users_Exception_NotAuthorized();
}
return array('access' => Q::ifset(Streams::$cache, 'access', null));
}
示例10: Streams_stream_response_streams
function Streams_stream_response_streams()
{
// happens only during non-GET requests
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : null;
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
$streams = Streams::fetch($userId, $publisherId, $name, $fields ? $fields : '*', $limit ? compact('limit') : array());
return Streams::$cache['streams'] = Db::exportArray($streams);
}
示例11: Streams_message_tool
function Streams_message_tool($options)
{
extract($options);
$user = Users::loggedInUser();
if (!$user) {
throw new Users_Exception_NotLoggedIn();
}
if (empty($publisherId)) {
$publisherId = Streams::requestedPublisherId();
}
if (empty($publisherId)) {
$publisherId = $_REQUEST['publisherId'] = $user->id;
}
if (empty($name)) {
$name = Streams::requestedName(true);
}
$stream = Streams::fetch($user->id, $publisherId, $name);
$stream = !empty($stream) ? reset($stream) : null;
if (!$stream) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => 'with that name'), 'streamName');
}
if (!$stream->testReadLevel('messages') || !$stream->testWriteLevel('post')) {
throw new Users_Exception_NotAuthorized();
}
$hidden = array('publisherId' => $publisherId, 'streamName' => $name);
$fields = array('stream' => array('label' => 'Stream', 'type' => 'static', 'value' => $stream->title));
$type = Streams::requestedType();
// check if stream has messages
$types = Q_Config::get('Streams', 'messages', $stream->type, array());
if (count($types) === 0) {
throw new Q_Exception("Stream of type '{$stream->type}' does not support messages");
}
if (!empty($type) && !in_array($type, $types)) {
throw new Q_Exception("Requested message type '{$type}' is not alowed for streams of type '{$stream->type}'");
}
if (!empty($type)) {
$hidden['type'] = $type;
$fields['type'] = array('label' => 'Message type', 'type' => 'static', 'value' => $type);
} else {
$fields['type'] = array('label' => 'Message type', 'type' => 'select', 'options' => array_merge(array('' => 'Select type'), array_combine($types, $types)), 'value' => '');
}
$fields['content'] = array('label' => 'Content', 'type' => 'textarea');
$fields['submit'] = array('label' => '', 'type' => 'submit_buttons', 'options' => array('submit' => 'Post'));
return Q_Html::tag('h3', array(), 'Post a message') . Q_Html::form(Q_Request::baseUrl() . '/action.php/Streams/message', 'post', array(), Q_Html::hidden($hidden) . Q::tool('Q/form', array('fields' => $fields, 'onSuccess' => 'function (data) {
if (data.errors) alert(data.errors);
else {
alert("Message posted");
var message = Q.getObject(["slots", "form", "fields"], data);
Q.handle(Q.info.baseUrl+"/plugins/Streams/message?publisherId="+message.publisherId+"&name="+message.streamName);
}
}')));
}
示例12: Streams_leave_post
function Streams_leave_post()
{
$user = Users::loggedInUser(true);
$publisherId = Streams::requestedPublisherId();
$streamName = Streams::requestedName(true);
$streams = Streams::fetch($user->id, $publisherId, $streamName);
if (empty($streams)) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => "{publisherId: '{$publisherId}', name: '{$streamName}'}"));
}
$stream = reset($streams);
$stream->leave(array(), $participant);
Q_Response::setSlot('participant', $participant->exportArray());
}
示例13: Streams_category_tool
/**
* This tool generates a category selector.
*
* @param {array} $options An associative array of parameters, containing:
* @param {string} [$options.publisherId=Streams::requestedPublisherId()] The publisherId of the stream to present. If "stream" parameter is empty
* @param {string} [$options.streamName=Streams::requestedName()] The streamName of the stream to present. If "stream" parameter is empty
* @param {string} [options.relationType=null] Filter the relation type.
*/
function Streams_category_tool($options)
{
extract($options);
if (!$publisherId) {
$options['publisherId'] = $publisherId = Streams::requestedPublisherId(true);
}
if (!$streamName) {
$options['streamName'] = $streamName = Streams::requestedName(true);
}
Q_Response::setToolOptions($options);
$stream = Streams::fetchOne(null, $publisherId, $streamName, true);
$userId = Users::loggedInUser(true)->id;
return Q::tool('Streams/related', $options);
}
示例14: Streams_stream_response_stream
function Streams_stream_response_stream()
{
// happens only during non-GET requests
if (isset(Streams::$cache['stream'])) {
return Streams::$cache['stream']->exportArray();
}
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
Streams::$cache['stream'] = $stream = Streams::fetchOne($userId, $publisherId, $name, $fields, array('withParticipant' => true));
return $stream ? $stream->exportArray() : null;
}
示例15: Streams_stream_delete
/**
* Used to close an existing stream. A cron job may delete this stream later.
*
* @module Streams
* @class Streams_stream
* @method delete
* @static
* @param {array} $_REQUEST
* @param {string} $_REQUEST.publisherId The id of the stream publisher
* @param {string} $_REQUEST.streamName The name of the stream the user will be invited to
*/
function Streams_stream_delete()
{
$user = Users::loggedInUser(true);
$publisherId = Streams::requestedPublisherId(true);
$streamName = Streams::requestedName(true);
Streams::$cache['result'] = Streams::close($user->id, $publisherId, $streamName);
// NOTE: we did not delete the stream. That will have to be done in a cron job like this:
// // Clean up access
// $stream->delete();
// Streams_Access::delete()->where(array(
// 'publisherId' => $stream->publisherId,
// 'streamName' => $stream->name
// ))->execute();
Q_Response::setSlot('result', Streams::$cache['result']);
}