当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::loggedInUser方法代码示例

本文整理汇总了PHP中Users::loggedInUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::loggedInUser方法的具体用法?PHP Users::loggedInUser怎么用?PHP Users::loggedInUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Users的用法示例。


在下文中一共展示了Users::loggedInUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: __construct

 /**
  * @constructor
  * @param {array} $options=array() Any initial options
  * @param {string} $options.secret
  * @param {string} $options.publishableKey
  * @param {string} $options.token If provided, allows us to create a customer and charge them
  * @param {Users_User} [$options.user=Users::loggedInUser()] Allows us to set the user to charge
  */
 function __construct($options = array())
 {
     if (!isset($options['user'])) {
         $options['user'] = Users::loggedInUser(true);
     }
     $this->options = array_merge(array('secret' => Q_Config::expect('Assets', 'payments', 'stripe', 'secret'), 'publishableKey' => Q_Config::expect('Assets', 'payments', 'stripe', 'publishableKey')), $options);
 }
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:15,代码来源:Stripe.php

示例3: Q_response_dashboard

function Q_response_dashboard()
{
    $app = Q_Config::expect('Q', 'app');
    $slogan = "Powered by Q.";
    $user = Users::loggedInUser();
    return Q::view("{$app}/dashboard.php", compact('slogan', 'user'));
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:7,代码来源:dashboard.php

示例4: fetch

 /**
  * Retrieve avatars for one or more publishers as displayed to a particular user.
  * 
  * @method fetch
  * @static
  * @param $toUserId {User_User|string} The id of the user to which this would be displayed
  * @param $publisherIds {string|array} Array of various users whose avatars are being fetched
  * @param $indexField {string} Optional name of the field by which to index the resulting array
  * @return {Streams_Avatar|array}
  */
 static function fetch($toUserId, $publisherId, $indexField = null)
 {
     if (!isset($toUserIs)) {
         $toUserId = Users::loggedInUser();
         if (!$toUserId) {
             $toUserId = "";
         }
     }
     if ($toUserId instanceof Users_User) {
         $toUserId = $toUserId->id;
     }
     if ($publisherId instanceof Users_User) {
         $publisherId = $publisherId->id;
     }
     $return_one = false;
     if (!is_array($publisherId)) {
         $publisherId = array($publisherId);
         $return_one = true;
     }
     $rows = Streams_Avatar::select('*')->where(array('toUserId' => array($toUserId, ''), 'publisherId' => $publisherId))->fetchDbRows(null, '', $indexField);
     $avatars = array();
     foreach ($rows as $r) {
         if (!isset($avatars[$r->publisherId]) or $r->toUserId !== '') {
             $avatars[$r->publisherId] = $r;
         }
     }
     return $return_one ? $avatars ? reset($avatars) : null : $avatars;
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:38,代码来源:Avatar.php

示例5: MyApp_home_response_content

function MyApp_home_response_content($params)
{
    // Implement a home page for the user
    $user = Users::loggedInUser();
    // For now we will just internally forward to the welcome page
    Q_Dispatcher::forward("MyApp/welcome");
}
开发者ID:dmitriz,项目名称:Platform,代码行数:7,代码来源:content.php

示例6: users_contact_post

function users_contact_post()
{
    Pie_Session::start();
    Pie_Valid::nonce(true);
    extract($_REQUEST);
    $user = Users::loggedInUser();
    if (!$user) {
        throw new Users_Exception_NotLoggedIn();
    }
    $app = Pie_Config::expect('pie', 'app');
    $subject = "Welcome! Activate your email.";
    $view = "{$app}/email/setEmail.php";
    $fields = array();
    $p = array();
    $p['subject'] =& $subject;
    $p['view'] =& $view;
    $p['fields'] =& $fields;
    Pie::event('users/setEmail', $p, 'before');
    // may change the fields
    if (isset($first_name)) {
        $user->first_name = $first_name;
    }
    if (isset($last_name)) {
        $user->last_name = $last_name;
    }
    $user->addEmail($_REQUEST['email_address'], $subject, $view, true, $fields);
    // If no exceptions were throw, save this user row
    if (isset($first_name) or isset($last_name)) {
        $user->save();
    }
}
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:31,代码来源:post.php

示例7: Users_label_post

/**
 * Adds a label to the system. Fills the "label" (and possibly "icon") slot.
 * @param {array} $_REQUEST
 * @param {string} $_REQUEST.title The title of the label
 * @param {string} [$_REQUEST.label] You can override the label to use
 * @param {string} [$_REQUEST.icon] Optional path to an icon
 * @param {string} [$_REQUEST.userId=Users::loggedInUser(true)->id] You can override the user id, if another plugin adds a hook that allows you to do this
 */
function Users_label_post($params = array())
{
    $req = array_merge($_REQUEST, $params);
    Q_Request::requireFields(array('title'), $req, true);
    $loggedInUserId = Users::loggedInUser(true)->id;
    $userId = Q::ifset($req, 'userId', $loggedInUserId);
    $icon = Q::ifset($req, 'icon', null);
    $title = $req['title'];
    $l = Q::ifset($req, 'label', 'Users/' . Q_Utils::normalize($title));
    Users::canManageLabels($loggedInUserId, $userId, $l, true);
    $label = new Users_Label();
    $label->userId = $userId;
    $label->label = $l;
    if ($label->retrieve()) {
        throw new Users_Exception_LabelExists();
    }
    $label->title = $title;
    if (is_array($icon)) {
        // Process any icon that was posted
        $icon['path'] = 'uploads/Users';
        $icon['subpath'] = "{$userId}/label/{$label}/icon";
        $data = Q::event("Q/image/post", $icon);
        Q_Response::setSlot('icon', $data);
        $label->icon = Q_Request::baseUrl() . '/' . $data[''];
    } else {
        $label->icon = 'default';
    }
    $label->save();
    Q_Response::setSlot('label', $label->exportArray());
}
开发者ID:atirjavid,项目名称:Platform,代码行数:38,代码来源:post.php

示例8: Shipping_shipment_response_content

function Shipping_shipment_response_content($params)
{
    $user = Users::loggedInUser(true);
    // copy from shipment
    $useTemplate = Q_Request::uri()->template ? "Shipping/shipment/" . Q_Request::uri()->template : false;
    // Check if stream "Shipping/shipments" exists for current user. If no -> create one.
    Shipping::shipments();
    // Check if stream "Shipping/templates" exists for current user. If no -> create one.
    Shipping::createTemplatesStream();
    // Collect streams for shipments. Relations: "describing", "scheduled", "confirmed", "shipping", "canceled", "returned"
    $shipment = Shipping::shipment();
    //$shipment->addPreloaded($userId);
    // test for UPS pickup
    //$stream = Streams::fetchOne("Shipping", "Shipping", "Shipping/shipment/Qdqpcspny");
    //$carrier = new Shipping_Carrier_UPS();
    //$carrier->pickupCreate($stream);
    //-------------------------------
    // add main style
    Q_Response::addStylesheet('css/Shipment.css');
    // set communityId
    Q_Response::setScriptData("Q.info.communityId", Users::communityId());
    Q_Response::setScriptData("Q.info.useTemplate", $useTemplate);
    Q_Response::addScript('js/shipment.js');
    Q_Response::addScript('js/date.js');
    // add jquery UI
    //Q_Response::addStylesheet('//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css');
    //Q_Response::addScript('//code.jquery.com/ui/1.11.4/jquery-ui.js');
    // add pickadate as date picker
    Q_Response::addStylesheet('js/pickadate/compressed/themes/default.css');
    Q_Response::addStylesheet('js/pickadate/compressed/themes/default.date.css');
    Q_Response::addScript('js/pickadate/compressed/picker.js');
    Q_Response::addScript('js/pickadate/compressed/picker.date.js');
    return Q::view('Shipping/content/shipment.php', compact('user', 'shipment', 'useTemplate'));
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:34,代码来源:content.php

示例9: Users_after_Q_reroute

function Users_after_Q_reroute($params, &$stop_dispatch)
{
    $uri = Q_Dispatcher::uri();
    $app = Q_Config::expect('Q', 'app');
    $ma = $uri->module . '/' . $uri->action;
    $requireLogin = Q_Config::get('Users', 'requireLogin', array());
    if (!isset($requireLogin[$ma])) {
        return;
        // We don't have to require login here
    }
    $user = Users::loggedInUser();
    if ($requireLogin[$ma] === true and !$user) {
        // require login
    } else {
        if ($requireLogin[$ma] === 'facebook' and !Users::facebook($app)) {
            // require facebook
        } else {
            return;
            // We don't have to require login here
        }
    }
    $redirect_action = Q_Config::get('Users', 'uris', "{$app}/login", "{$app}/welcome");
    if ($redirect and $ma != $redirect_action) {
        Q_Response::redirect($redirect_action);
        $stop_dispatch = true;
        return;
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:28,代码来源:Q_reroute.php

示例10: Websites_before_Streams_Stream_save_Websites_article

function Websites_before_Streams_Stream_save_Websites_article($params)
{
    $stream = $params['stream'];
    $modifiedFields = $params['modifiedFields'];
    if ($stream->wasRetrieved()) {
        return;
    }
    $user = new Users_User();
    if (empty($stream->userId) and empty($modifiedFields['userId'])) {
        if ($liu = Users::loggedInUser()) {
            $stream->userId = $liu->id;
        } else {
            throw new Q_Exception_RequiredField(array('field' => 'userId'));
        }
    }
    $user->id = $stream->userId;
    if (!$user->retrieve()) {
        throw new Users_Exception_NoSuchUser();
    }
    $title = Streams::displayName($user, array('fullAccess' => true));
    if (isset($title)) {
        $stream->title = $title;
    }
    $stream->icon = $user->iconUrl();
    $s = Streams::fetchOne($user->id, $user->id, "Streams/user/icon");
    if (!$s or !($sizes = $s->getAttribute('sizes', null))) {
        $sizes = Q_Config::expect('Users', 'icon', 'sizes');
        sort($sizes);
    }
    $stream->setAttribute('sizes', $sizes);
}
开发者ID:dmitriz,项目名称:Platform,代码行数:31,代码来源:Streams_Stream_save_Websites_article.php

示例11: Streams_after_Q_objects

function Streams_after_Q_objects()
{
    $user = Users::loggedInUser();
    if (!$user) {
        return;
    }
    $invite = Streams::$followedInvite;
    if (!$invite) {
        return;
    }
    $displayName = $user->displayName();
    if ($displayName) {
        return;
    }
    $stream = new Streams_Stream();
    $stream->publisherId = $invite->publisherId;
    $stream->name = $invite->streamName;
    if (!$stream->retrieve()) {
        throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => 'with that name'), 'streamName');
    }
    // Prepare the complete invite dialog
    $invitingUser = Users_User::fetch($invite->invitingUserId);
    list($relations, $related) = Streams::related($user->id, $stream->publisherId, $stream->name, false);
    $params = array('displayName' => null, 'action' => 'Streams/basic', 'icon' => $user->iconUrl(), 'token' => $invite->token, 'user' => array('icon' => $invitingUser->iconUrl(), 'displayName' => $invitingUser->displayName(array('fullAccess' => true))), 'stream' => $stream->exportArray(), 'relations' => Db::exportArray($relations), 'related' => Db::exportArray($related));
    $config = Streams_Stream::getConfigField($stream->type, 'invite', array());
    $defaults = Q::ifset($config, 'dialog', array());
    $tree = new Q_Tree($defaults);
    if ($tree->merge($params)) {
        $dialogData = $tree->getAll();
        if ($dialogData) {
            Q_Response::setScriptData('Q.plugins.Streams.invite.dialog', $dialogData);
            Q_Response::addTemplate('Streams/invite/complete');
        }
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:35,代码来源:Q_objects.php

示例12: Streams_after_Q_file_save

function Streams_after_Q_file_save($params)
{
    $user = Users::loggedInUser(true);
    $path = $subpath = $name = $writePath = $data = $tailUrl = null;
    extract($params, EXTR_OVERWRITE);
    if (!empty(Streams::$cache['canWriteToStream'])) {
        // some stream's associated file was being changed
        $stream = Streams::$cache['canWriteToStream'];
    }
    if (empty($stream)) {
        return;
    }
    $filesize = filesize($writePath . DS . $name);
    $url = $tailUrl;
    $url = Q_Valid::url($url) ? $url : Q_Request::baseUrl() . '/' . $url;
    $prevUrl = $stream->getAttribute('file.url');
    $stream->setAttribute('file.url', $url);
    $stream->setAttribute('file.size', $filesize);
    // set the title and icon every time a new file is uploaded
    $stream->title = $name;
    $parts = explode('.', $name);
    $urlPrefix = Q_Request::baseUrl() . '/plugins/Streams/img/icons/files';
    $dirname = STREAMS_PLUGIN_FILES_DIR . DS . 'Streams' . DS . 'icons' . DS . 'files';
    $extension = end($parts);
    $stream->icon = file_exists($dirname . DS . $extension) ? "{$urlPrefix}/{$extension}" : "{$urlPrefix}/_blank";
    if (empty(Streams::$beingSavedQuery)) {
        $stream->changed($user->id);
    } else {
        $stream->save();
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:31,代码来源:Q_file_save.php

示例13: 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

示例14: Streams_stream_response_Q_inplace

function Streams_stream_response_Q_inplace()
{
    $user = Users::loggedInUser();
    $stream = isset(Streams::$cache['stream']) ? Streams::$cache['stream'] : null;
    if (!$stream) {
        throw new Exception("No stream");
    }
    if (isset($_REQUEST['title'])) {
        $result = $stream->title;
    } else {
        if (isset($_REQUEST['attributes'])) {
            if (is_array($_REQUEST['attributes'])) {
                reset($_REQUEST['attributes']);
                $result = $stream->getAttribute(key($_REQUEST['attributes']));
            } else {
                $result = $stream->attributes;
            }
        } else {
            $fieldNames = array_diff(Streams::getExtendFieldNames($stream->type), array('insertedTime', 'updatedTime'));
            $field = 'content';
            foreach ($fieldNames as $f) {
                if (isset($_REQUEST[$f])) {
                    $field = $f;
                    break;
                }
            }
            $result = $stream->{$field};
        }
    }
    $convert = Q::ifset($_REQUEST, 'convert', '["\\n"]');
    return Q_Html::text($result, json_decode($convert, true));
}
开发者ID:dmitriz,项目名称:Platform,代码行数:32,代码来源:Q_inplace.php

示例15: Websites_seo_post

function Websites_seo_post()
{
    if (empty($_REQUEST['streamName'])) {
        throw new Q_Exception_RequiredField(array('field' => 'streamName'));
    }
    $prefix = "Websites/seo/";
    if (substr($_REQUEST['streamName'], 0, strlen($prefix)) !== $prefix) {
        throw new Q_Exception_WrongValue(array('field' => 'streamName', 'range' => "string beginning with {$prefix}"));
    }
    $user = Users::loggedInUser(true);
    $publisherId = Users::communityId();
    $type = "Websites/seo";
    if (!Streams::isAuthorizedToCreate($user->id, $publisherId, $type)) {
        throw new Users_Exception_NotAuthorized();
    }
    $stream = new Streams_Stream($publisherId);
    $stream->publisherId = $publisherId;
    $stream->name = $_REQUEST['streamName'];
    $stream->type = $type;
    if (isset($_REQUEST['uri'])) {
        $stream->setAttribute('uri', $_REQUEST['uri']);
    }
    $stream->save();
    $stream->post($user->id, array('type' => 'Streams/created', 'content' => '', 'instructions' => Q::json_encode($stream->toArray())), true);
    $stream->subscribe();
    // autosubscribe to streams you yourself create, using templates
    Q_Response::setSlot('stream', $stream->exportArray());
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:28,代码来源:post.php


注:本文中的Users::loggedInUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。