コード例 #1
0
ファイル: Fave.php プロジェクト: Grasia/bolotweet
 function asActivity()
 {
     $notice = Notice::staticGet('id', $this->notice_id);
     if (!$notice) {
         throw new Exception("Fave for non-existent notice: " . $this->notice_id);
     }
     $profile = Profile::staticGet('id', $this->user_id);
     if (!$profile) {
         throw new Exception("Fave by non-existent profile: " . $this->user_id);
     }
     $act = new Activity();
     $act->verb = ActivityVerb::FAVORITE;
     // FIXME: rationalize this with URL below
     $act->id = $this->getURI();
     $act->time = strtotime($this->modified);
     // TRANS: Activity title when marking a notice as favorite.
     $act->title = _("Favor");
     // TRANS: Ntofication given when a user marks a notice as favorite.
     // TRANS: %1$s is a user nickname or full name, %2$s is a notice URI.
     $act->content = sprintf(_('%1$s marked notice %2$s as a favorite.'), $profile->getBestName(), $notice->uri);
     $act->actor = ActivityObject::fromProfile($profile);
     $act->objects[] = ActivityObject::fromNotice($notice);
     $url = common_local_url('AtomPubShowFavorite', array('profile' => $this->user_id, 'notice' => $this->notice_id));
     $act->selfLink = $url;
     $act->editLink = $url;
     return $act;
 }
コード例 #2
0
 /**
  * Notify remote users when their notices get de-favorited.
  *
  * @param Profile $profile Profile person doing the de-faving
  * @param Notice  $notice  Notice being favored
  *
  * @return hook return value
  */
 function onEndDisfavorNotice(Profile $profile, Notice $notice)
 {
     $user = User::staticGet('id', $profile->id);
     if (empty($user)) {
         return true;
     }
     $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
     if (empty($oprofile)) {
         return true;
     }
     $act = new Activity();
     $act->verb = ActivityVerb::UNFAVORITE;
     $act->id = TagURI::mint('disfavor:%d:%d:%s', $profile->id, $notice->id, common_date_iso8601(time()));
     $act->time = time();
     // TRANS: Title for unliking a remote notice.
     $act->title = _m('Unlike');
     // TRANS: Success message for remove a favorite notice through OStatus.
     // TRANS: %1$s is the unfavoring user's name, %2$s is URI to the no longer favored notice.
     $act->content = sprintf(_m('%1$s no longer likes %2$s.'), $profile->getBestName(), $notice->uri);
     $act->actor = ActivityObject::fromProfile($profile);
     $act->object = ActivityObject::fromNotice($notice);
     $oprofile->notifyActivity($act, $profile);
     return true;
 }
コード例 #3
0
ファイル: Notice.php プロジェクト: Br3nda/statusnet-debian
 /**
  * Returns an XML string fragment with a reference to a notice as an
  * Activity Streams noun object with the given element type.
  *
  * Assumes that 'activity' namespace has been previously defined.
  *
  * @param string $element one of 'subject', 'object', 'target'
  * @return string
  */
 function asActivityNoun($element)
 {
     $noun = ActivityObject::fromNotice($this);
     return $noun->asString('activity:' . $element);
 }
コード例 #4
0
 /**
  * Notify remote users when their notices get de-favorited.
  *
  * @param Profile $profile Profile person doing the de-faving
  * @param Notice  $notice  Notice being favored
  *
  * @return hook return value
  */
 function onEndDisfavorNotice(Profile $profile, Notice $notice)
 {
     $user = User::staticGet('id', $profile->id);
     if (empty($user)) {
         return true;
     }
     $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
     if (empty($oprofile)) {
         return true;
     }
     $act = new Activity();
     $act->verb = ActivityVerb::UNFAVORITE;
     $act->id = TagURI::mint('disfavor:%d:%d:%s', $profile->id, $notice->id, common_date_iso8601(time()));
     $act->time = time();
     $act->title = _("Disfavor");
     $act->content = sprintf(_("%s marked notice %s as no longer a favorite."), $profile->getBestName(), $notice->uri);
     $act->actor = ActivityObject::fromProfile($profile);
     $act->object = ActivityObject::fromNotice($notice);
     $oprofile->notifyActivity($act, $profile);
     return true;
 }
コード例 #5
0
ファイル: Fave.php プロジェクト: stevertiqo/StatusNet
 function asActivity()
 {
     $notice = Notice::staticGet('id', $this->notice_id);
     $profile = Profile::staticGet('id', $this->user_id);
     $act = new Activity();
     $act->verb = ActivityVerb::FAVORITE;
     $act->id = TagURI::mint('favor:%d:%d:%s', $profile->id, $notice->id, common_date_iso8601($this->modified));
     $act->time = strtotime($this->modified);
     // TRANS: Activity title when marking a notice as favorite.
     $act->title = _("Favor");
     // TRANS: Ntofication given when a user marks a notice as favorite.
     // TRANS: %1$s is a user nickname or full name, %2$s is a notice URI.
     $act->content = sprintf(_('%1$s marked notice %2$s as a favorite.'), $profile->getBestName(), $notice->uri);
     $act->actor = ActivityObject::fromProfile($profile);
     $act->objects[] = ActivityObject::fromNotice($notice);
     return $act;
 }