本文整理汇总了PHP中Notice::getProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::getProfile方法的具体用法?PHP Notice::getProfile怎么用?PHP Notice::getProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::getProfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addNew
public static function addNew(Notice $notice, Profile $actor = null)
{
if (is_null($actor)) {
$actor = $notice->getProfile();
}
if ($notice->getProfile()->hasRole(Profile_role::DELETED)) {
// Don't emit notices if the notice author is (being) deleted
return false;
}
$act = new Activity();
$act->verb = ActivityVerb::DELETE;
$act->time = time();
$act->id = $notice->getUri();
$act->content = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'), htmlspecialchars($actor->getUrl()), htmlspecialchars($actor->getBestName()), htmlspecialchars($notice->getUrl()), htmlspecialchars($notice->getUri()));
$act->actor = $actor->asActivityObject();
$act->target = new ActivityObject();
// We don't save the notice object, as it's supposed to be removed!
$act->target->id = $notice->getUri();
$act->target->type = $notice->getObjectType();
$act->objects = array(clone $act->target);
$url = $notice->getUrl();
$act->selfLink = $url;
$act->editLink = $url;
// This will make ActivityModeration run saveObjectFromActivity which adds
// a new Deleted_notice entry in the database as well as deletes the notice
// if the actor has permission to do so.
$stored = Notice::saveActivity($act, $actor);
return $stored;
}
示例2: onStartNoticeDistribute
/**
* If poster is in one of the forced groups, make sure their notice
* gets saved into that group even if not explicitly mentioned.
*
* @param Notice $notice
* @return boolean event hook return
*/
function onStartNoticeDistribute($notice)
{
$profile = $notice->getProfile();
$isRemote = !User::getKV('id', $profile->id);
if ($isRemote) {
/*
* Notices from remote users on other sites
* will normally not end up here unless they're
* specifically directed here, e.g.: via explicit
* post to a remote (to them) group. But remote
* notices can also be `pulled in' as a result of
* local users subscribing to the remote user;
* from the remote user's perspective, this results
* in group-forcing appearing effectively random.
* So let's be consistent, and just never force
* incoming remote notices into a ForceGroup:
*/
return true;
}
foreach ($this->post as $nickname) {
$group = User_group::getForNickname($nickname);
if ($group && $profile->isMember($group)) {
$notice->addToGroupInbox($group);
}
}
return true;
}
示例3: onStartNoticeDistribute
/**
* If poster is in one of the forced groups, make sure their notice
* gets saved into that group even if not explicitly mentioned.
*
* @param Notice $notice
* @return boolean event hook return
*/
function onStartNoticeDistribute($notice)
{
$profile = $notice->getProfile();
foreach ($this->post as $nickname) {
$group = User_group::getForNickname($nickname);
if ($group && $profile->isMember($group)) {
$notice->addToGroupInbox($group);
}
}
return true;
}
示例4: activityObjectFromNotice
public function activityObjectFromNotice(Notice $notice)
{
$object = new ActivityObject();
$object->type = $notice->object_type ?: ActivityObject::NOTE;
$object->id = $notice->getUri();
$object->title = sprintf('New %1$s by %2$s', ActivityObject::canonicalType($object->type), $notice->getProfile()->getNickname());
$object->content = $notice->getRendered();
$object->link = $notice->getUrl();
$object->extra[] = array('status_net', array('notice_id' => $notice->getID()));
return $object;
}
示例5: format_entry
/**
* extra information for XMPP messages, as defined by Twitter
*
* @param Profile $profile Profile of the sending user
* @param Notice $notice Notice being sent
*
* @return string Extra information (Atom, HTML, addresses) in string format
*/
protected function format_entry(Notice $notice)
{
$profile = $notice->getProfile();
$entry = $notice->asAtomEntry(true, true);
$xs = new XMLStringer();
$xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
$xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
$xs->element('a', array('href' => $profile->profileurl), $profile->nickname);
try {
$parent = $notice->getParent();
$orig_profile = $parent->getProfile();
$orig_profurl = $orig_profile->getUrl();
$xs->text(" => ");
$xs->element('a', array('href' => $orig_profurl), $orig_profile->nickname);
$xs->text(": ");
} catch (InvalidUrlException $e) {
$xs->text(sprintf(' => %s', $orig_profile->nickname));
} catch (NoParentNoticeException $e) {
$xs->text(": ");
}
if (!empty($notice->rendered)) {
$notice->rendered = str_replace("\t", "", $notice->rendered);
$xs->raw($notice->rendered);
} else {
$xs->raw(common_render_content($notice->content, $notice));
}
$xs->text(" ");
$xs->element('a', array('href' => common_local_url('conversation', array('id' => $notice->conversation)) . '#notice-' . $notice->id), sprintf(_m('[%u]'), $notice->id));
$xs->elementEnd('body');
$xs->elementEnd('html');
$html = $xs->getString();
return $html . ' ' . $entry;
}
示例6: onStartNoticeSave
/**
* When saving a notice, check its groups. If any of them has
* privacy == always, force a group private message to all mentioned groups.
* If any of the groups disallows private messages, skip it.
*
* @param
*/
function onStartNoticeSave(Notice &$notice)
{
// Look for group tags
// FIXME: won't work for remote groups
// @fixme if Notice::saveNew is refactored so we can just pull its list
// of groups between processing and saving, make use of it
$count = preg_match_all('/(?:^|\\s)!(' . Nickname::DISPLAY_FMT . ')/', strtolower($notice->content), $match);
$groups = array();
$ignored = array();
$forcePrivate = false;
$profile = $notice->getProfile();
if ($count > 0) {
/* Add them to the database */
foreach (array_unique($match[1]) as $nickname) {
$group = User_group::getForNickname($nickname, $profile);
if (empty($group)) {
continue;
}
$gps = Group_privacy_settings::forGroup($group);
switch ($gps->allow_privacy) {
case Group_privacy_settings::ALWAYS:
$forcePrivate = true;
// fall through
// fall through
case Group_privacy_settings::SOMETIMES:
$groups[] = $group;
break;
case Group_privacy_settings::NEVER:
$ignored[] = $group;
break;
}
}
if ($forcePrivate) {
foreach ($ignored as $group) {
common_log(LOG_NOTICE, "Notice forced to group direct message " . "but group " . $group->nickname . " does not allow them.");
}
$user = User::getKV('id', $notice->profile_id);
if (empty($user)) {
common_log(LOG_WARNING, "Notice forced to group direct message " . "but profile " . $notice->profile_id . " is not a local user.");
} else {
foreach ($groups as $group) {
Group_message::send($user, $group, $notice->content);
}
}
// Don't save the notice!
// FIXME: this is probably cheating.
// TRANS: Client exception thrown when a private group message has to be forced.
throw new ClientException(sprintf(_m('Forced notice to private group message.')), 200);
}
}
return true;
}
示例7: onEndFavorNotice
public function onEndFavorNotice(Profile $actor, Notice $target)
{
try {
$notice_author = $target->getProfile();
// Don't notify ourselves of our own favorite on our own notice,
// or if it's a remote user (since we don't know their email addresses etc.)
if ($notice_author->id == $actor->id || !$notice_author->isLocal()) {
return true;
}
$local_user = $notice_author->getUser();
mail_notify_fave($local_user, $actor, $target);
} catch (Exception $e) {
// Mm'kay, probably not a local user. Let's skip this favor notification.
}
}
示例8: formatNotice
/**
* makes a plain-text formatted version of a notice, suitable for IM distribution
*
* @param Notice $notice notice being sent
*
* @return string plain-text version of the notice, with user nickname prefixed
*/
protected function formatNotice(Notice $notice)
{
$profile = $notice->getProfile();
try {
$parent = $notice->getParent();
$orig_profile = $parent->getProfile();
$nicknames = sprintf('%1$s => %2$s', $profile->nickname, $orig_profile->nickname);
} catch (NoParentNoticeException $e) {
$nicknames = $profile->nickname;
}
return sprintf('%1$s: %2$s [%3$u]', $nicknames, $notice->content, $notice->id);
}
示例9: showEvent
protected function showEvent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
{
$profile = $stored->getProfile();
$event = Happening::fromNotice($stored);
if (!$event instanceof Happening) {
// TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond").
$out->element('p', null, _m('Deleted.'));
return;
}
$out->elementStart('div', 'h-event');
$out->elementStart('h3', 'p-summary p-name');
try {
$out->element('a', array('href' => $event->getUrl()), $event->title);
} catch (InvalidUrlException $e) {
$out->text($event->title);
}
$out->elementEnd('h3');
$now = new DateTime();
$startDate = new DateTime($event->start_time);
$endDate = new DateTime($event->end_time);
$userTz = new DateTimeZone(common_timezone());
// Localize the time for the observer
$now->setTimeZone($userTz);
$startDate->setTimezone($userTz);
$endDate->setTimezone($userTz);
$thisYear = $now->format('Y');
$startYear = $startDate->format('Y');
$endYear = $endDate->format('Y');
$dateFmt = 'D, F j, ';
// e.g.: Mon, Aug 31
if ($startYear != $thisYear || $endYear != $thisYear) {
$dateFmt .= 'Y,';
// append year if we need to think about years
}
$startDateStr = $startDate->format($dateFmt);
$endDateStr = $endDate->format($dateFmt);
$timeFmt = 'g:ia';
$startTimeStr = $startDate->format($timeFmt);
$endTimeStr = $endDate->format("{$timeFmt} (T)");
$out->elementStart('div', 'event-times');
// VEVENT/EVENT-TIMES IN
// TRANS: Field label for event description.
$out->element('strong', null, _m('Time:'));
$out->element('time', array('class' => 'dt-start', 'datetime' => common_date_iso8601($event->start_time)), $startDateStr . ' ' . $startTimeStr);
$out->text(' – ');
$out->element('time', array('class' => 'dt-end', 'datetime' => common_date_iso8601($event->end_time)), $startDateStr != $endDateStr ? "{$endDateStr} {$endTimeStr}" : $endTimeStr);
$out->elementEnd('div');
// VEVENT/EVENT-TIMES OUT
if (!empty($event->location)) {
$out->elementStart('div', 'event-location');
// TRANS: Field label for event description.
$out->element('strong', null, _m('Location:'));
$out->element('span', 'p-location', $event->location);
$out->elementEnd('div');
}
if (!empty($event->description)) {
$out->elementStart('div', 'event-description');
// TRANS: Field label for event description.
$out->element('strong', null, _m('Description:'));
$out->element('div', 'p-description', $event->description);
$out->elementEnd('div');
}
$rsvps = $event->getRSVPs();
$out->elementStart('div', 'event-rsvps');
// TRANS: Field label for event description.
$out->element('strong', null, _m('Attending:'));
$out->elementStart('ul', 'attending-list');
foreach ($rsvps as $verb => $responses) {
$out->elementStart('li', 'rsvp-list');
switch ($verb) {
case RSVP::POSITIVE:
$out->text(_('Yes:'));
break;
case RSVP::NEGATIVE:
$out->text(_('No:'));
break;
case RSVP::POSSIBLE:
$out->text(_('Maybe:'));
break;
}
$ids = array();
foreach ($responses as $response) {
$ids[] = $response->profile_id;
}
$ids = array_slice($ids, 0, ProfileMiniList::MAX_PROFILES + 1);
$minilist = new ProfileMiniList(Profile::multiGet('id', $ids), $out);
$minilist->show();
$out->elementEnd('li');
}
$out->elementEnd('ul');
$out->elementEnd('div');
if ($scoped instanceof Profile) {
$rsvp = $event->getRSVP($scoped);
if (empty($rsvp)) {
$form = new RSVPForm($event, $out);
} else {
$form = new CancelRSVPForm($rsvp, $out);
}
$form->show();
}
//.........这里部分代码省略.........
示例10: saveNew
//.........这里部分代码省略.........
// 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 (!empty($options['repeat_of'])) {
// Check for a private one
$repeat = Notice::getByID($options['repeat_of']);
if ($profile->sameAs($repeat->getProfile())) {
// 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);
}
if (!$repeat->inScope($profile)) {
// The generic checks above should cover this, but let's be sure!
// TRANS: Client error displayed when trying to repeat a notice you cannot access.
throw new ClientException(_('Cannot repeat a notice you cannot read.'), 403);
}
if ($profile->hasRepeated($repeat)) {
// TRANS: Client error displayed when trying to repeat an already repeated notice.
throw new ClientException(_('You already repeated that notice.'));
}
$notice->repeat_of = $repeat->id;
$notice->conversation = $repeat->conversation;
} else {
$reply = null;
// If $reply_to is specified, we check that it exists, and then
// return it if it does
if (!empty($reply_to)) {
$reply = Notice::getKV('id', $reply_to);
} elseif (in_array($source, array('xmpp', 'mail', 'sms'))) {
// If the source lacks capability of sending the "reply_to"
// metadata, let's try to find an inline replyto-reference.
$reply = self::getInlineReplyTo($profile, $final);
}
if ($reply instanceof Notice) {
if (!$reply->inScope($profile)) {
// TRANS: Client error displayed when trying to reply to a notice a the target has no access to.
示例11: mail_notify_attn
/**
* Notify a user that they have received an "attn:" message AKA "@-reply"
*
* @param User $user The user who recevied the notice
* @param Notice $notice The notice that was sent
*
* @return void
*/
function mail_notify_attn($user, $notice)
{
if (!$user->receivesEmailNotifications()) {
return;
}
$sender = $notice->getProfile();
if ($sender->id == $user->id) {
return;
}
// See if the notice's author who mentions this user is sandboxed
if (!$sender->hasRight(Right::EMAILONREPLY)) {
return;
}
// If the author has blocked the author, don't spam them with a notification.
if ($user->hasBlocked($sender)) {
return;
}
$bestname = $sender->getBestName();
common_switch_locale($user->language);
if ($notice->hasConversation()) {
$conversationUrl = common_local_url('conversation', array('id' => $notice->conversation)) . '#notice-' . $notice->id;
// TRANS: Line in @-reply notification e-mail. %s is conversation URL.
$conversationEmailText = sprintf(_("The full conversation can be read here:\n\n" . "\t%s"), $conversationUrl) . "\n\n";
} else {
$conversationEmailText = '';
}
// TRANS: E-mail subject for notice notification.
// TRANS: %1$s is the sending user's long name, %2$s is the adding user's nickname.
$subject = sprintf(_('%1$s (@%2$s) sent a notice to your attention'), $bestname, $sender->nickname);
// TRANS: Body of @-reply notification e-mail.
// TRANS: %1$s is the sending user's name, $2$s is the StatusNet sitename,
// TRANS: %3$s is a URL to the notice, %4$s is the notice text,
// TRANS: %5$s is the text "The full conversation can be read here:" and a URL to the full conversion if it exists (otherwise empty),
// TRANS: %6$s is a URL to reply to the notice, %7$s is a URL to all @-replies for the addressed user,
$body = sprintf(_("%1\$s just sent a notice to your attention (an '@-reply') on %2\$s.\n\n" . "The notice is here:\n\n" . "\t%3\$s\n\n" . "It reads:\n\n" . "\t%4\$s\n\n" . "%5\$s" . "You can reply back here:\n\n" . "\t%6\$s\n\n" . "The list of all @-replies for you here:\n\n" . "%7\$s"), $sender->getFancyName(), common_config('site', 'name'), common_local_url('shownotice', array('notice' => $notice->id)), $notice->content, $conversationEmailText, common_local_url('newnotice', array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)), common_local_url('replies', array('nickname' => $user->nickname))) . mail_footer_block();
$headers = _mail_prepare_headers('mention', $user->nickname, $sender->nickname);
common_switch_locale();
mail_to_user($user, $subject, $body, $headers);
}
示例12: extendActivity
public function extendActivity(Notice $stored, Activity $act, Profile $scoped = null)
{
// TODO: How to handle repeats of deleted notices?
$target = Notice::getByID($stored->repeat_of);
// TRANS: A repeat activity's title. %1$s is repeater's nickname
// and %2$s is the repeated user's nickname.
$act->title = sprintf(_('%1$s repeated a notice by %2$s'), $stored->getProfile()->getNickname(), $target->getProfile()->getNickname());
$act->objects[] = $target->asActivity($scoped);
}
示例13: activityObjectFromNotice
public function activityObjectFromNotice(Notice $stored)
{
// Repeat is a little bit special. As it's an activity, our
// ActivityObject is instead turned into an Activity
$object = new Activity();
$object->actor = $stored->getProfile()->asActivityObject();
$object->verb = ActivityVerb::SHARE;
$object->content = $stored->getRendered();
$this->extendActivity($stored, $object);
return $object;
}
示例14: canRead
function canRead(Notice $notice)
{
if ($notice->scope & Notice::SITE_SCOPE) {
$user = $this->getUser();
if (empty($user)) {
return false;
}
}
if ($notice->scope & Notice::ADDRESSEE_SCOPE) {
$replies = $notice->getReplies();
if (!in_array($this->id, $replies)) {
$groups = $notice->getGroups();
$foundOne = false;
foreach ($groups as $group) {
if ($this->isMember($group)) {
$foundOne = true;
break;
}
}
if (!$foundOne) {
return false;
}
}
}
if ($notice->scope & Notice::FOLLOWER_SCOPE) {
$author = $notice->getProfile();
if (!Subscription::exists($this, $author)) {
return false;
}
}
return true;
}
示例15: XMLStringer
/**
* extra information for XMPP messages, as defined by Twitter
*
* @param Profile $profile Profile of the sending user
* @param Notice $notice Notice being sent
*
* @return string Extra information (Atom, HTML, addresses) in string format
*/
function format_entry($notice)
{
$profile = $notice->getProfile();
$entry = $notice->asAtomEntry(true, true);
$xs = new XMLStringer();
$xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
$xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
$xs->element('a', array('href' => $profile->profileurl), $profile->nickname);
$xs->text(": ");
if (!empty($notice->rendered)) {
$xs->raw($notice->rendered);
} else {
$xs->raw(common_render_content($notice->content, $notice));
}
$xs->text(" ");
$xs->element('a', array('href' => common_local_url('conversation', array('id' => $notice->conversation)) . '#notice-' . $notice->id), sprintf(_m('[%s]'), $notice->id));
$xs->elementEnd('body');
$xs->elementEnd('html');
$html = $xs->getString();
return $html . ' ' . $entry;
}