/**
  * Constructor
  *
  * @param Group   $group   the group for the feed
  * @param User    $cur     the current authenticated user, if any
  * @param boolean $indent  flag to turn indenting on or off
  *
  * @return void
  */
 function __construct($group, $cur = null, $indent = true)
 {
     parent::__construct($cur, $indent);
     $this->group = $group;
     // TRANS: Title in atom group notice feed. %s is a group name.
     $title = sprintf(_("%s timeline"), $group->nickname);
     $this->setTitle($title);
     $sitename = common_config('site', 'name');
     $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $group->nickname, $sitename);
     $this->setSubtitle($subtitle);
     $avatar = $group->homepage_logo;
     $logo = $avatar ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
     $this->setLogo($logo);
     $this->setUpdated('now');
     $self = common_local_url('ApiTimelineGroup', array('id' => $group->id, 'format' => 'atom'));
     $this->setId($self);
     $this->setSelfLink($self);
     // For groups, we generate an author _AND_ an <activity:subject>
     // Versions of StatusNet under 0.9.7 treat <author> as a person
     // XXX: remove this workaround in future versions
     $ao = ActivityObject::fromGroup($group);
     $this->addAuthorRaw($ao->asString('author'));
     $depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.';
     $this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject'));
     $this->addLink($group->homeUrl());
 }
 /**
  * Constructor
  *
  * @param Group   $group   the group for the feed
  * @param User    $cur     the current authenticated user, if any
  * @param boolean $indent  flag to turn indenting on or off
  *
  * @return void
  */
 function __construct($group, $cur = null, $indent = true)
 {
     parent::__construct($cur, $indent);
     $this->group = $group;
     // TRANS: Title in atom group notice feed. %s is a group name.
     $title = sprintf(_("%s timeline"), $group->nickname);
     $this->setTitle($title);
     $sitename = common_config('site', 'name');
     $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $group->nickname, $sitename);
     $this->setSubtitle($subtitle);
     $avatar = $group->homepage_logo;
     $logo = $avatar ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
     $this->setLogo($logo);
     $this->setUpdated('now');
     $self = common_local_url('ApiTimelineGroup', array('id' => $group->id, 'format' => 'atom'));
     $this->setId($self);
     $this->setSelfLink($self);
     $ao = ActivityObject::fromGroup($group);
     $this->addAuthorRaw($ao->asString('author'));
     $this->addLink($group->homeUrl());
 }
Пример #3
0
 /**
  * Returns an XML string fragment with group information as an
  * Activity Streams noun object with the given element type.
  *
  * Assumes that 'activity', 'georss', and 'poco' namespace has been
  * previously defined.
  *
  * @param string $element one of 'actor', 'subject', 'object', 'target'
  *
  * @return string
  */
 function asActivityNoun($element)
 {
     $noun = ActivityObject::fromGroup($this);
     return $noun->asString('activity:' . $element);
 }
Пример #4
0
 /**
  * Returns an XML string fragment with profile information as an
  * Activity Streams noun object with the given element type.
  *
  * Assumes that 'activity' namespace has been previously defined.
  *
  * @todo FIXME: Replace with wrappers on asActivityObject when it's got everything.
  *
  * @param string $element one of 'actor', 'subject', 'object', 'target'
  * @return string
  */
 function asActivityNoun($element)
 {
     if ($this->isGroup()) {
         $noun = ActivityObject::fromGroup($this->localGroup());
         return $noun->asString('activity:' . $element);
     } else {
         if ($this->isPeopletag()) {
             $noun = ActivityObject::fromPeopletag($this->localPeopletag());
             return $noun->asString('activity:' . $element);
         } else {
             $noun = $this->localProfile()->asActivityObject();
             return $noun->asString('activity:' . $element);
         }
     }
 }
Пример #5
0
 function asActivity()
 {
     $member = $this->getMember();
     if (!$member) {
         throw new Exception("No such member: " . $this->profile_id);
     }
     $group = $this->getGroup();
     if (!$group) {
         throw new Exception("No such group: " . $this->group_id);
     }
     $act = new Activity();
     $act->id = $this->getURI();
     $act->actor = $member->asActivityObject();
     $act->verb = ActivityVerb::JOIN;
     $act->objects[] = ActivityObject::fromGroup($group);
     $act->time = strtotime($this->created);
     // TRANS: Activity title.
     $act->title = _("Join");
     // TRANS: Success message for subscribe to group attempt through OStatus.
     // TRANS: %1$s is the member name, %2$s is the subscribed group's name.
     $act->content = sprintf(_('%1$s has joined group %2$s.'), $member->getBestName(), $group->getBestName());
     $url = common_local_url('AtomPubShowMembership', array('profile' => $member->id, 'group' => $group->id));
     $act->selfLink = $url;
     $act->editLink = $url;
     return $act;
 }
Пример #6
0
 public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped = null)
 {
     switch ($stored->verb) {
         case ActivityVerb::UNFAVORITE:
             // FIXME: do something here
             break;
         case ActivityVerb::JOIN:
             $mem = Group_member::getKV('uri', $stored->getUri());
             if ($mem instanceof Group_member) {
                 $group = $mem->getGroup();
                 $act->title = $stored->getTitle();
                 $act->objects = array(ActivityObject::fromGroup($group));
             }
             break;
         case ActivityVerb::LEAVE:
             // FIXME: ????
             break;
         case ActivityVerb::FOLLOW:
             $sub = Subscription::getKV('uri', $stored->uri);
             if ($sub instanceof Subscription) {
                 $profile = Profile::getKV('id', $sub->subscribed);
                 if ($profile instanceof Profile) {
                     $act->title = $stored->getTitle();
                     $act->objects = array($profile->asActivityObject());
                 }
             }
             break;
         case ActivityVerb::UNFOLLOW:
             // FIXME: ????
             break;
     }
     return true;
 }
Пример #7
0
 function asActivity()
 {
     $member = $this->getMember();
     $group = $this->getGroup();
     $act = new Activity();
     $act->id = TagURI::mint('join:%d:%d:%s', $member->id, $group->id, common_date_iso8601($this->created));
     $act->actor = ActivityObject::fromProfile($member);
     $act->verb = ActivityVerb::JOIN;
     $act->objects[] = ActivityObject::fromGroup($group);
     $act->time = strtotime($this->created);
     // TRANS: Activity title.
     $act->title = _("Join");
     // TRANS: Success message for subscribe to group attempt through OStatus.
     // TRANS: %1$s is the member name, %2$s is the subscribed group's name.
     $act->content = sprintf(_('%1$s has joined group %2$s.'), $member->getBestName(), $group->getBestName());
     return $act;
 }
 function onEndNoticeAsActivity($notice, &$activity)
 {
     switch ($notice->verb) {
         case ActivityVerb::FAVORITE:
             $fave = Fave::staticGet('uri', $notice->uri);
             if (!empty($fave)) {
                 $notice = Notice::staticGet('id', $fave->notice_id);
                 if (!empty($notice)) {
                     $cur = common_current_user();
                     $target = $notice->asActivity($cur);
                     if ($target->verb == ActivityVerb::POST) {
                         // "I like the thing you posted"
                         $activity->objects = $target->objects;
                     } else {
                         // "I like that you did whatever you did"
                         $activity->objects = array($target);
                     }
                 }
             }
             break;
         case ActivityVerb::UNFAVORITE:
             // FIXME: do something here
             break;
         case ActivityVerb::JOIN:
             $mem = Group_member::staticGet('uri', $notice->uri);
             if (!empty($mem)) {
                 $group = $mem->getGroup();
                 $activity->objects = array(ActivityObject::fromGroup($group));
             }
             break;
         case ActivityVerb::LEAVE:
             // FIXME: ????
             break;
         case ActivityVerb::FOLLOW:
             $sub = Subscription::staticGet('uri', $notice->uri);
             if (!empty($sub)) {
                 $profile = Profile::staticGet('id', $sub->subscribed);
                 if (!empty($profile)) {
                     $activity->objects = array(ActivityObject::fromProfile($profile));
                 }
             }
             break;
         case ActivityVerb::UNFOLLOW:
             // FIXME: ????
             break;
     }
     return true;
 }