本文整理汇总了PHP中Streams::isAuthorizedToCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP Streams::isAuthorizedToCreate方法的具体用法?PHP Streams::isAuthorizedToCreate怎么用?PHP Streams::isAuthorizedToCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Streams
的用法示例。
在下文中一共展示了Streams::isAuthorizedToCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: 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);
}
}
}
示例3: 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 = Q_Config::expect("Websites", "user", "id");
$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);
}