case 'Bookmark':
include_once $dir.'/'.$cls.'.php';
return false;
+ case 'BookmarkListItem':
case 'BookmarkForm':
case 'InitialBookmarkForm':
case 'DeliciousBackupImporter':
function onStartOpenNoticeListItemElement($nli)
{
+ if (!$this->isMyNotice($nli->notice)) {
+ return true;
+ }
+
$nb = Bookmark::getByNotice($nli->notice);
- if (!empty($nb)) {
- $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id;
- $class = 'hentry notice bookmark';
- if ($nli->notice->scope != 0 && $nli->notice->scope != 1) {
- $class .= ' limited-scope';
- }
- $nli->out->elementStart('li', array('class' => $class,
- 'id' => 'notice-' . $id));
- Event::handle('EndOpenNoticeListItemElement', array($nli));
- return false;
+
+ if (empty($nb)) {
+ $this->log(LOG_INFO, "Notice {$nli->notice->id} has bookmark class but no matching Bookmark record.");
+ return true;
}
- return true;
+
+ $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id;
+ $class = 'hentry notice bookmark';
+ if ($nli->notice->scope != 0 && $nli->notice->scope != 1) {
+ $class .= ' limited-scope';
+ }
+ $nli->out->elementStart('li', array('class' => $class,
+ 'id' => 'notice-' . $id));
+
+ Event::handle('EndOpenNoticeListItemElement', array($nli));
+ return false;
}
/**
$options = array('uri' => $bookmark->id,
'url' => $bookmark->link,
- 'is_local' => Notice::REMOTE_OMB,
+ 'is_local' => Notice::REMOTE,
'source' => 'ostatus');
return self::_postBookmark($author->localProfile(), $activity, $options);
*/
function deleteRelated($notice)
{
- $nb = Bookmark::getByNotice($notice);
-
- if (!empty($nb)) {
- $nb->delete();
- }
-
+ if ($this->isMyNotice($notice)) {
+
+ $nb = Bookmark::getByNotice($notice);
+
+ if (!empty($nb)) {
+ $nb->delete();
+ }
+ }
+
return true;
}
*/
function adaptNoticeListItem($nli)
{
- return new BookmarkNoticeListItemAdapter($nli);
+ return new BookmarkListItem($nli);
}
function entryForm($out)
// TRANS: Application title.
return _m('TITLE','Bookmark');
}
+
+ function onEndUpgrade()
+ {
+ // Version 0.9.x of the plugin didn't stamp notices
+ // with verb and object-type (for obvious reasons). Update
+ // those notices here.
+
+ $notice = new Notice();
+
+ $notice->whereAdd('exists (select uri from bookmark where bookmark.uri = notice.uri)');
+ $notice->whereAdd('((object_type is null) or (object_type = "' .ActivityObject::NOTE.'"))');
+
+ $notice->find();
+
+ while ($notice->fetch()) {
+ $original = clone($notice);
+ $notice->verb = ActivityVerb::POST;
+ $notice->object_type = ActivityObject::BOOKMARK;
+ $notice->update($original);
+ }
+ }
+
+ public function activityObjectOutputJson(ActivityObject $obj, array &$out)
+ {
+ assert($obj->type == ActivityObject::BOOKMARK);
+
+ $bm = Bookmark::staticGet('uri', $obj->id);
+
+ if (empty($bm)) {
+ throw new ServerException("Unknown bookmark: " . $obj->id);
+ }
+
+ $out['displayName'] = $bm->title;
+ $out['targetUrl'] = $bm->url;
+
+ return true;
+ }
}