當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Streams::requestedName方法代碼示例

本文整理匯總了PHP中Streams::requestedName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Streams::requestedName方法的具體用法?PHP Streams::requestedName怎麽用?PHP Streams::requestedName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Streams的用法示例。


在下文中一共展示了Streams::requestedName方法的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;
    }
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:34,代碼來源:post.php

示例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));
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:29,代碼來源:data.php

示例3: 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);
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:41,代碼來源:tool.php

示例4: 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'));
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:40,代碼來源:player.php

示例5: 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;
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:29,代碼來源:participant.php

示例6: 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);
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:32,代碼來源:messages.php

示例7: 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);
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:17,代碼來源:get.php

示例8: 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));
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:11,代碼來源:data.php

示例9: 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);
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:12,代碼來源:streams.php

示例10: 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);
					}
				}')));
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:52,代碼來源:tool.php

示例11: 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());
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:13,代碼來源:post.php

示例12: 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);
}
開發者ID:AndreyTepaykin,項目名稱:Platform,代碼行數:22,代碼來源:tool.php

示例13: 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;
}
開發者ID:AndreyTepaykin,項目名稱:Platform,代碼行數:14,代碼來源:stream.php

示例14: 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']);
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:26,代碼來源:delete.php

示例15: Streams_invite_response_content

function Streams_invite_response_content()
{
    $user = Users::loggedInUser(true);
    $publisherId = Streams::requestedPublisherId();
    if (empty($publisherId)) {
        $publisherId = $user->id;
    }
    $streamName = Streams::requestedName(true);
    $stream = new Streams_Stream();
    $stream->publisherId = $publisherId;
    $stream->name = $streamName;
    if (!$stream->retrieve()) {
        throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => "{publisherId: '{$publisherId}', name: '{$streamName}'}"));
    }
    return Q::tool('Streams/invite', compact('stream'));
}
開發者ID:dmitriz,項目名稱:Platform,代碼行數:16,代碼來源:content.php


注:本文中的Streams::requestedName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。