本文整理汇总了PHP中Notice::isLocal方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::isLocal方法的具体用法?PHP Notice::isLocal怎么用?PHP Notice::isLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::isLocal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onStartEnqueueNotice
/**
* Add a Twitter queue item for each notice
*
* @param Notice $notice the notice
* @param array &$transports the list of transports (queues)
*
* @return boolean hook return
*/
function onStartEnqueueNotice($notice, &$transports)
{
if (self::hasKeys() && $notice->isLocal() && $notice->inScope(null)) {
// Avoid a possible loop
if ($notice->source != 'twitter') {
array_push($transports, 'twitter');
}
}
return true;
}
示例2: saveActivity
static function saveActivity(Activity $act, Profile $actor, array $options = array())
{
// First check if we're going to let this Activity through from the specific actor
if (!$actor->hasRight(Right::NEWNOTICE)) {
common_log(LOG_WARNING, "Attempted post from user disallowed to post: " . $actor->getNickname());
// TRANS: Client exception thrown when a user tries to post while being banned.
throw new ClientException(_m('You are banned from posting notices on this site.'), 403);
}
if (common_config('throttle', 'enabled') && !self::checkEditThrottle($actor->id)) {
common_log(LOG_WARNING, 'Excessive posting by profile #' . $actor->id . '; throttled.');
// TRANS: Client exception thrown when a user tries to post too many notices in a given time frame.
throw new ClientException(_m('Too many notices too fast; take a breather ' . 'and post again in a few minutes.'));
}
// Get ActivityObject properties
$actobj = null;
if (!empty($act->id)) {
// implied object
$options['uri'] = $act->id;
$options['url'] = $act->link;
} else {
$actobj = count($act->objects) == 1 ? $act->objects[0] : null;
if (!is_null($actobj) && !empty($actobj->id)) {
$options['uri'] = $actobj->id;
if ($actobj->link) {
$options['url'] = $actobj->link;
} elseif (preg_match('!^https?://!', $actobj->id)) {
$options['url'] = $actobj->id;
}
}
}
$defaults = array('groups' => array(), 'is_local' => $actor->isLocal() ? self::LOCAL_PUBLIC : self::REMOTE, 'mentions' => array(), 'reply_to' => null, 'repeat_of' => null, 'scope' => null, 'source' => 'unknown', 'tags' => array(), 'uri' => null, 'url' => null, 'urls' => array(), 'distribute' => true);
// options will have default values when nothing has been supplied
$options = array_merge($defaults, $options);
foreach (array_keys($defaults) as $key) {
// Only convert the keynames we specify ourselves from 'defaults' array into variables
${$key} = $options[$key];
}
extract($options, EXTR_SKIP);
// dupe check
$stored = new Notice();
if (!empty($uri) && !ActivityUtils::compareVerbs($act->verb, array(ActivityVerb::DELETE))) {
$stored->uri = $uri;
if ($stored->find()) {
common_debug('cannot create duplicate Notice URI: ' . $stored->uri);
// I _assume_ saving a Notice with a colliding URI means we're really trying to
// save the same notice again...
throw new AlreadyFulfilledException('Notice URI already exists');
}
}
$autosource = common_config('public', 'autosource');
// Sandboxed are non-false, but not 1, either
if (!$actor->hasRight(Right::PUBLICNOTICE) || $source && $autosource && in_array($source, $autosource)) {
// FIXME: ...what about remote nonpublic? Hmmm. That is, if we sandbox remote profiles...
$stored->is_local = Notice::LOCAL_NONPUBLIC;
} else {
$stored->is_local = intval($is_local);
}
if (!$stored->isLocal()) {
// Only do these checks for non-local notices. Local notices will generate these values later.
if (!common_valid_http_url($url)) {
common_debug('Bad notice URL: [' . $url . '], URI: [' . $uri . ']. Cannot link back to original! This is normal for shared notices etc.');
}
if (empty($uri)) {
throw new ServerException('No URI for remote notice. Cannot accept that.');
}
}
$stored->profile_id = $actor->id;
$stored->source = $source;
$stored->uri = $uri;
$stored->url = $url;
$stored->verb = $act->verb;
// Notice content. We trust local users to provide HTML we like, but of course not remote users.
// FIXME: What about local users importing feeds? Mirror functions must filter out bad HTML first...
$content = $act->content ?: $act->summary;
if (is_null($content) && !is_null($actobj)) {
$content = $actobj->content ?: $actobj->summary;
}
$stored->rendered = $actor->isLocal() ? $content : common_purify($content);
// yeah, just don't use getRendered() here since it's not inserted yet ;)
$stored->content = common_strip_html($stored->rendered);
// Maybe a missing act-time should be fatal if the actor is not local?
if (!empty($act->time)) {
$stored->created = common_sql_date($act->time);
} else {
$stored->created = common_sql_now();
}
$reply = null;
if ($act->context instanceof ActivityContext && !empty($act->context->replyToID)) {
$reply = self::getKV('uri', $act->context->replyToID);
}
if (!$reply instanceof Notice && $act->target instanceof ActivityObject) {
$reply = self::getKV('uri', $act->target->id);
}
if ($reply instanceof Notice) {
if (!$reply->inScope($actor)) {
// TRANS: Client error displayed when trying to reply to a notice a the target has no access to.
// TRANS: %1$s is a user nickname, %2$d is a notice ID (number).
throw new ClientException(sprintf(_m('%1$s has no right to reply to notice %2$d.'), $actor->getNickname(), $reply->id), 403);
}
$stored->reply_to = $reply->id;
//.........这里部分代码省略.........
示例3: onStartEnqueueNotice
/**
* Add a Facebook queue item for each notice
*
* @param Notice $notice the notice
* @param array &$transports the list of transports (queues)
*
* @return boolean hook return
*/
function onStartEnqueueNotice($notice, &$transports)
{
if (self::hasApplication() && $notice->isLocal()) {
array_push($transports, 'facebook');
}
return true;
}
示例4: onStartEnqueueNotice
/**
* Add an RSSCloud queue item for each notice
*
* @param Notice $notice the notice
* @param array &$transports the list of transports (queues)
*
* @return boolean hook return
*/
function onStartEnqueueNotice($notice, &$transports)
{
if ($notice->isLocal()) {
array_push($transports, 'rsscloud');
}
return true;
}
示例5: onStartEnqueueNotice
/**
* Put saved notices into the queue for OMB distribution
*
* @param Notice $notice the notice to broadcast
* @param array $transports queuehandler's list of transports
* @return boolean true if queing was successful
*/
function onStartEnqueueNotice($notice, &$transports)
{
if ($notice->isLocal()) {
if ($notice->inScope(null)) {
array_unshift($transports, 'omb');
common_log(LOG_INFO, "Notice {$notice->id} queued for OMB processing");
} else {
// Note: We don't do privacy-controlled OMB updates.
common_log(LOG_NOTICE, "Not queueing notice {$notice->id} for OMB because of " . "privacy; scope = {$notice->scope}", __FILE__);
}
} else {
common_log(LOG_NOTICE, "Not queueing notice {$notice->id} for OMB because it's not " . "local.", __FILE__);
}
return true;
}
示例6: saveNew
//.........这里部分代码省略.........
if (Notice::contentTooLong($final)) {
// TRANS: Client exception thrown if a notice contains too many characters.
throw new ClientException(_('Problem saving notice. Too long.'));
}
if (common_config('throttle', 'enabled') && !Notice::checkEditThrottle($profile_id)) {
common_log(LOG_WARNING, 'Excessive posting by profile #' . $profile_id . '; throttled.');
// TRANS: Client exception thrown when a user tries to post too many notices in a given time frame.
throw new ClientException(_('Too many notices too fast; take a breather ' . 'and post again in a few minutes.'));
}
if (common_config('site', 'dupelimit') > 0 && !Notice::checkDupes($profile_id, $final)) {
common_log(LOG_WARNING, 'Dupe posting by profile #' . $profile_id . '; throttled.');
// TRANS: Client exception thrown when a user tries to post too many duplicate notices in a given time frame.
throw new ClientException(_('Too many duplicate messages too quickly;' . ' take a breather and post again in a few minutes.'));
}
if (!$profile->hasRight(Right::NEWNOTICE)) {
common_log(LOG_WARNING, "Attempted post from user disallowed to post: " . $profile->nickname);
// TRANS: Client exception thrown when a user tries to post while being banned.
throw new ClientException(_('You are banned from posting notices on this site.'), 403);
}
$notice = new Notice();
$notice->profile_id = $profile_id;
$autosource = common_config('public', 'autosource');
// Sandboxed are non-false, but not 1, either
if (!$profile->hasRight(Right::PUBLICNOTICE) || $source && $autosource && in_array($source, $autosource)) {
$notice->is_local = Notice::LOCAL_NONPUBLIC;
} else {
$notice->is_local = $is_local;
}
if (!empty($created)) {
$notice->created = $created;
} else {
$notice->created = common_sql_now();
}
if (!$notice->isLocal()) {
// Only do these checks for non-local notices. Local notices will generate these values later.
if (!common_valid_http_url($url)) {
common_debug('Bad notice URL: [' . $url . '], URI: [' . $uri . ']. Cannot link back to original! This is normal for shared notices etc.');
}
if (empty($uri)) {
throw new ServerException('No URI for remote notice. Cannot accept that.');
}
}
$notice->content = $final;
$notice->source = $source;
$notice->uri = $uri;
$notice->url = $url;
// Get the groups here so we can figure out replies and such
if (!isset($groups)) {
$groups = User_group::idsFromText($notice->content, $profile);
}
$reply = null;
// Handle repeat case
if (isset($repeat_of)) {
// Check for a private one
$repeat = Notice::getKV('id', $repeat_of);
if (!$repeat instanceof Notice) {
// TRANS: Client exception thrown in notice when trying to repeat a missing or deleted notice.
throw new ClientException(_('Cannot repeat; original notice is missing or deleted.'));
}
if ($profile->id == $repeat->profile_id) {
// TRANS: Client error displayed when trying to repeat an own notice.
throw new ClientException(_('You cannot repeat your own notice.'));
}
if ($repeat->scope != Notice::SITE_SCOPE && $repeat->scope != Notice::PUBLIC_SCOPE) {
// TRANS: Client error displayed when trying to repeat a non-public notice.
throw new ClientException(_('Cannot repeat a private notice.'), 403);