本文整理汇总了PHP中Users::communityId方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::communityId方法的具体用法?PHP Users::communityId怎么用?PHP Users::communityId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::communityId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Streams_0_8_8_Streams_mysql
function Streams_0_8_8_Streams_mysql()
{
$communityId = Users::communityId();
$user = Users_User::fetch($communityId, true);
Streams::create($communityId, $communityId, 'Streams/resource', array('name' => 'Streams/invitations', 'readLevel' => 0, 'writeLevel' => 0, 'adminLevel' => 0));
Streams_Access::insert(array('publisherId' => $communityId, 'streamName' => "Streams/invitations", 'ofUserId' => '', 'grantedByUserId' => null, 'ofContactLabel' => "{$app}/admins", 'readLevel' => Streams::$READ_LEVEL['messages'], 'writeLevel' => Streams::$WRITE_LEVEL['close'], 'adminLevel' => Streams::$ADMIN_LEVEL['invite']))->execute();
}
示例2: Streams_0_8_6_Streams_mysql
function Streams_0_8_6_Streams_mysql()
{
$app = Q_Config::expect('Q', 'app');
$communityId = Users::communityId();
// access for managing communities
$access = new Streams_Access();
$access->publisherId = $communityId;
$access->streamName = 'Streams/community*';
$access->ofUserId = '';
$access->ofContactLabel = "{$app}/admins";
$access->readLevel = Streams::$READ_LEVEL['messages'];
$access->writeLevel = Streams::$WRITE_LEVEL['edit'];
$access->adminLevel = Streams::$ADMIN_LEVEL['manage'];
$access->save();
// access for managing categories
$access = new Streams_Access();
$access->publisherId = $communityId;
$access->streamName = 'Streams/category/';
$access->ofUserId = '';
$access->ofContactLabel = "{$app}/admins";
$access->readLevel = Streams::$READ_LEVEL['messages'];
$access->writeLevel = Streams::$WRITE_LEVEL['close'];
$access->adminLevel = Streams::$ADMIN_LEVEL['manage'];
$access->save();
// template to help users relate things to Streams/category streams
Streams_Stream::insert(array('publisherId' => '', 'name' => 'Streams/category/', 'type' => 'Streams/template', 'title' => 'Untitled Category', 'icon' => 'Streams/category', 'content' => '', 'attributes' => null, 'readLevel' => Streams::$READ_LEVEL['messages'], 'writeLevel' => Streams::$WRITE_LEVEL['relate'], 'adminLevel' => Streams::$ADMIN_LEVEL['invite']))->execute();
// template to help users create subcategories for things
Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Streams/category/', 'type' => 'subcategories', 'fromPublisherId' => '', 'fromStreamName' => 'Streams/category/'))->execute();
}
示例3: Users_0_9_2_Users_mysql
function Users_0_9_2_Users_mysql()
{
$app = Q_Config::expect('Q', 'app');
$communityId = Users::communityId();
$rows = Users_Session::select('COUNT(1)')->where($criteria)->fetchAll(PDO::FETCH_NUM);
$count = $rows[0][0];
$limit = 100;
$offset = 0;
$sessions = Users_Session::select('*')->orderBy('id')->limit($limit, $offset)->caching(false)->fetchDbRows();
echo "Adding userId to sessions...";
while ($sessions) {
foreach ($sessions as $s) {
$parsed = Q::json_decode($s->content, true);
if (empty($parsed['Users']['loggedInUser']['id'])) {
continue;
}
$s->userId = $parsed['Users']['loggedInUser']['id'];
}
Users_Session::insertManyAndExecute($sessions, array('onDuplicateKeyUpdate' => array('userId' => new Db_Expression("VALUES(userId)"))));
$min = min($offset + $limit, $count);
echo "[100D";
echo "Updated {$min} of {$count} sessions";
$offset += $limit;
if ($offset > $count) {
break;
}
$sessions = Users_Session::select('*')->orderBy('id')->limit($limit, $offset)->caching(false)->fetchDbRows();
}
echo "\n";
}
示例4: Shipping_scheduled_response_content
function Shipping_scheduled_response_content($params)
{
// redirect to home page if not logged in
if (!Users::loggedInUser()) {
header("Location: " . Q_Request::baseUrl());
exit;
}
// get "Shipping/shipments" stream
$publisherId = Users::communityId();
$streamName = 'Shipping/shipment/' . Q_Request::uri()->shipmentStreamName;
$stream = Streams::fetchOne($publisherId, $publisherId, $streamName);
//$xml = simplexml_load_file(APP_DIR.'/classes/dhl/response.xml');
//$xml = simplexml_load_string(str_replace('req:', '', file_get_contents(APP_DIR.'/classes/dhl/response.xml')));
//print_r($xml); exit;
// test pickup
//$carrier = new Shipping_Carrier_DHL();
//$carrier->createAWBBarCode($stream, 'iVBORw0KGgoAAAANSUhEUgAAAYwAAABeAQMAAAAKdrGZAAAABlBMVEX///8AAABVwtN+AAAAaklEQVR42mNkYGBIyL8wZcutG2wTzVMZfG99eep7y1tp5oIokaMMOtabG6PuTflrnnHqVfI013vzlRYwMDAxkAxGtYxqGdUyqmVUy6iWUS2jWka1jGoZ1TKqZVTLqJZRLaNaRrWMaiEVAABqDRe8DYfcJgAAAABJRU5ErkJggg==', "AWBBarCode");
// -----------
//echo Shipping::getShipmentRelation($stream, true);
//unlink("/tmp/dhl-api-autoload.php");
if (!$stream || !$stream->testReadLevel('see')) {
throw new Users_Exception_NotAuthorized();
}
return Q::view('Shipping/content/scheduled.php', compact('streamName'));
}
示例5: Websites_seo_tool
/**
* Tool for admins to edit the url, title, keywords, description of the current page
* @class Websites seo
* @constructor
* @param {Object} [$options] Options for the tool
* @param {String} [$options.skipIfNotAuthorized=true] Whether to skip rendering the contents of the tool if the logged-in user is not authorized to edit the SEO information for this page.
*/
function Websites_seo_tool($options)
{
$skipIfNotAuthorized = Q::ifset($options, 'skipIfNotAuthorized', true);
if ($skipIfNotAuthorized) {
$websitesUserId = Users::communityId();
$sha1 = sha1(Q_Dispatcher::uri());
$seoStreamName = "Websites/seo/{$sha1}";
$stream = Streams::fetchOne(null, $websitesUserId, $seoStreamName);
$user = Users::loggedInUser();
if (!$user or $stream and !$stream->testWriteLevel('suggest')) {
$options['skip'] = true;
}
if (!$stream and !Streams::isAuthorizedToCreate($user->id, $websitesUserId, 'Websites/seo')) {
$options['skip'] = true;
}
}
unset($options['skipIfNotAuthorized']);
Q_Response::addStylesheet('plugins/Websites/css/Websites.css');
Q_Response::addScript("plugins/Websites/js/Websites.js");
Q_Response::setToolOptions($options);
$user = Users::loggedInUser(false, false);
$userId = $user ? $user->id : "";
$communityId = Users::communityId();
$sha1 = sha1(Q_Dispatcher::uri());
$seoStreamName = "Websites/seo/{$sha1}";
$streams = Streams::fetch($userId, $communityId, array("Websites/header", "Websites/title", "Websites/slogan", $seoStreamName));
foreach ($streams as $name => $s) {
if ($s) {
$s->addPreloaded($userId);
}
}
}
示例6: 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());
}
示例7: Websites_0_9_1_Streams_mysql
function Websites_0_9_1_Streams_mysql()
{
$userId = Users::communityId();
$ofUserId = '';
$ofContactLabel = 'Websites/admins';
$grantedByUserId = null;
$streams = array("Websites/presentation/" => array('type' => "Streams/template", "title" => "Untitled Presentation", "icon" => "{{baseUrl}}/plugins/Websites/img/icons/Websites/presentation", "content" => "", "deletable" => true), "Websites/slide/" => array('type' => "Streams/template", "title" => "Untitled Slide", "icon" => "{{baseUrl}}/plugins/Websites/img/icons/Websites/presentation", "content" => "", "deletable" => true));
$readLevel = Streams::$READ_LEVEL['messages'];
$adminLevel = Streams::$ADMIN_LEVEL['own'];
$rows = array();
foreach ($streams as $streamName => $stream) {
$publisherId = substr($streamName, -1) == '/' ? '' : $userId;
$level = !empty($stream['deletable']) ? 'close' : 'edit';
$writeLevel = Streams::$WRITE_LEVEL[!empty($stream['deletable']) ? 'close' : 'edit'];
$rows[] = compact('publisherId', 'streamName', 'ofUserId', 'ofContactLabel', 'grantedByUserId', 'readLevel', 'writeLevel', 'adminLevel');
}
Streams_Access::insertManyAndExecute($rows);
$attributes = null;
$closedTime = null;
$readLevel = Streams::$READ_LEVEL['messages'];
$writeLevel = Streams::$WRITE_LEVEL['join'];
$adminLevel = Streams::$ADMIN_LEVEL['invite'];
$inheritAccess = null;
$rows = array();
foreach ($streams as $name => $s) {
extract($s);
$publisherId = substr($name, -1) == '/' ? '' : $userId;
$rows[] = compact('publisherId', 'name', 'type', 'title', 'icon', 'content', 'attributes', 'readLevel', 'writeLevel', 'adminLevel', 'inheritAccess');
}
Streams_Stream::insertManyAndExecute($rows);
Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Websites/presentation/', 'type' => 'slides', 'fromPublisherId' => '', 'fromStreamName' => 'Websites/slide/'))->execute();
}
示例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'));
}
示例9: Streams_interest_delete
/**
* Used to create a new stream
*
* @param {array} $_REQUEST
* @param {string} [$_REQUEST.title] Required. The title of the interest.
* @param {string} [$_REQUEST.publisherId] Optional. Defaults to the app name.
* @return {void}
*/
function Streams_interest_delete()
{
$user = Users::loggedInUser(true);
$title = Q::ifset($_REQUEST, 'title', null);
if (!isset($title)) {
throw new Q_Exception_RequiredField(array('field' => 'title'));
}
$publisherId = Q::ifset($_REQUEST, 'publisherId', Users::communityId());
$name = 'Streams/interest/' . Q_Utils::normalize($title);
$stream = Streams::fetchOne(null, $publisherId, $name);
if (!$stream) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => Q::json_encode(compact('publisherId', 'name'))));
}
$miPublisherId = $user->id;
$miName = 'Streams/user/interests';
$myInterests = Streams::fetchOne($user->id, $miPublisherId, $miName);
if (!$myInterests) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => Q::json_encode(array('publisherId' => $miPublisherId, 'name' => $miName))));
}
$stream->leave();
Streams::unrelate($user->id, $user->id, 'Streams/user/interests', 'Streams/interests', $publisherId, $name, array('adjustWeights' => true));
Q_Response::setSlot('publisherId', $publisherId);
Q_Response::setSlot('streamName', $name);
/**
* Occurs when the logged-in user has successfully removed an interest via HTTP
* @event Streams/interest/delete {after}
* @param {string} publisherId The publisher of the interest stream
* @param {string} title The title of the interest
* @param {Users_User} user The logged-in user
* @param {Streams_Stream} stream The interest stream
* @param {Streams_Stream} myInterests The user's "Streams/user/interests" stream
*/
Q::event("Streams/interest/remove", compact('publisherId', 'title', 'subscribe', 'user', 'stream', 'myInterests'), 'after');
}
示例10: Websites_0_8_Users_mysql
function Websites_0_8_Users_mysql()
{
$userId = Users::communityId();
Users_Label::addLabel('Websites/admins', $userId, 'Website Admins', 'labels/Websites/admins', false);
if (!file_exists(USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'icons' . DS . 'Websites')) {
Q_Utils::symlink(WEBSITES_PLUGIN_FILES_DIR . DS . 'Websites' . DS . 'icons' . DS . 'labels' . DS . 'Websites', USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'icons' . DS . 'labels' . DS . 'Websites');
}
}
示例11: Trump_about_response_content
function Trump_about_response_content()
{
$publisherId = Users::communityId();
$streamName = 'Communities/about';
Q_Response::addStylesheet('plugins/Websites/css/Websites.css');
Q_Response::addScript("plugins/Websites/js/Websites.js");
return Q::view("Communities/content/article.php", compact('publisherId', 'streamName'));
}
示例12: Streams_0_8_4_Streams_mysql
function Streams_0_8_4_Streams_mysql()
{
$app = Q_Config::expect('Q', 'app');
$communityId = Users::communityId();
$user = Users_User::fetch($communityId);
// avatar for the App user
$avatar = new Streams_Avatar();
$avatar->toUserId = $communityId;
$avatar->publisherId = $communityId;
$avatar->username = $user->username;
$avatar->firstName = Users::communityName();
$avatar->lastName = Users::communitySuffix();
$avatar->icon = $user->icon;
$avatar->save();
$avatar2 = new Streams_Avatar();
$avatar2->copyFrom($avatar, null, false, true);
$avatar->toUserId = '';
$avatar->save();
// access stream for managing app roles
$stream = new Streams_Stream();
$stream->publisherId = Users::communityId();
$stream->name = 'Streams/contacts';
$stream->type = 'Streams/resource';
$stream->title = "Contacts";
$stream->setAttribute('prefixes', array("Users/", "{$app}/"));
$stream->save();
// access stream for managing app roles
$stream = new Streams_Stream();
$stream->publisherId = $app;
$stream->name = 'Streams/labels';
$stream->type = 'Streams/resource';
$stream->title = "Labels";
$stream->setAttribute('prefixes', array("Users/", "{$app}/"));
$stream->save();
// access for managing app contacts
$access = new Streams_Access();
$access->publisherId = $communityId;
$access->streamName = 'Streams/contacts';
$access->ofUserId = '';
$access->ofContactLabel = "{$app}/admins";
$access->readLevel = Streams::$READ_LEVEL['messages'];
$access->writeLevel = Streams::$WRITE_LEVEL['edit'];
$access->adminLevel = Streams::$ADMIN_LEVEL['manage'];
$access->save();
// access for managing app roles
$access = new Streams_Access();
$access->publisherId = $communityId;
$access->streamName = 'Streams/labels';
$access->ofUserId = '';
$access->ofContactLabel = "{$app}/admins";
$access->readLevel = Streams::$READ_LEVEL['messages'];
$access->writeLevel = Streams::$WRITE_LEVEL['edit'];
$access->adminLevel = Streams::$ADMIN_LEVEL['manage'];
$access->save();
}
示例13: Streams_relate_tool
/**
* Lets the user search for streams they can relate a given stream to, and relate it
* @class Streams relate
* @constructor
* @param {array} [$options] Override various options for this tool
* @param {string} $publisherId publisher id of the stream to relate
* @param {string} $streamName name of stream to relate
* @param {string} [$communityId=Users::communityId()] id of the user publishing the streams to relate to
* @param {array} [$types=Q_Config::expect('Streams','relate','types')] the types of streams the user can select
* @param {array} [$typeNames] pairs of array($type => $typeName) to override names of the types, which would otherwise be taken from the types
* @param {Boolean} [options.multiple=true] whether the user can select multiple types for the lookup
* @param {boolean} [$relateFrom=false] if true, will relate FROM the user-selected stream TO the streamName instead
* @param {string} [$types=Q_Config::expect('Streams','relate','types')] the types of streams the user can select
* @param {Q.Event} [$options.onRelate] This event handler occurs when a stream is successfully related
*/
function Streams_relate_tool($options)
{
Q_Valid::requireFields(array('publisherId', 'streamName'), $options, true);
if (!isset($options['communityId'])) {
$options['communityId'] = Users::communityId();
}
if (!isset($options['types'])) {
$options['types'] = Q_Config::get('Streams', 'relate', 'types', array());
}
Q_Response::setToolOptions($options);
return '';
}
示例14: Assets_subscription_post
/**
* Used by HTTP clients to start a subscription
* @class HTTP Assets subscription
* @method post
* @param {array} $_REQUEST
* @param {string} $_REQUEST.payments Required. Should be either "authnet" or "stripe"
* @param {String} $_REQUEST.planStreamName the name of the subscription plan's stream
* @param {String} [$_REQUEST.planPublisherId=Users::communityId()] the publisher of the subscription plan's stream
* @param {String} [$_REQUEST.token=null] if using stripe, pass the token here
*/
function Assets_subscription_post($params = array())
{
$req = array_merge($_REQUEST, $params);
Q_Valid::requireFields(array('payments'), $req, true);
// to be safe, we only start subscriptions from existing plans
$planPublisherId = Q::ifset($req, 'planPublisherId', Users::communityId());
$plan = Streams::fetchOne($planPublisherId, $planPublisherId, $req['planStreamName'], true);
// the currency will always be assumed to be "USD" for now
// and the amount will always be assumed to be in dollars, for now
$token = Q::ifset($req, 'token', null);
$subscription = Assets::startSubscription($plan, $req['payments'], compact('token'));
Q_Response::setSlot('subscription', $subscription);
}
示例15: Websites_0_8_4_Streams_mysql
function Websites_0_8_4_Streams_mysql()
{
$app = Q_Config::expect('Q', 'app');
$communityId = Users::communityId();
// allow inserting images in articles
$r = new Streams_RelatedTo();
$r->toPublisherId = $communityId;
$r->toStreamName = 'Websites/article/';
$r->type = 'images';
$r->fromPublisherId = $communityId;
$r->fromStreamName = 'Streams/image/';
$r->save();
}