X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FBookmark%2FBookmarkPlugin.php;h=ff68917bcca36a683f5651f47eed337b3461e13c;hb=59043dca7fb6f974b11797c4d0f20e5b78b0611d;hp=f8db77e2b701d9ca0274704e0b9ba5b5726c046d;hpb=c97048d01bea468e0cf8865b60c3c250b4515c39;p=quix0rs-gnu-social.git diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index f8db77e2b7..ff68917bcc 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -292,19 +292,27 @@ class BookmarkPlugin extends MicroAppPlugin 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; } /** @@ -322,7 +330,7 @@ class BookmarkPlugin extends MicroAppPlugin $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); @@ -355,12 +363,15 @@ class BookmarkPlugin extends MicroAppPlugin */ 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; } @@ -540,4 +551,25 @@ class BookmarkPlugin extends MicroAppPlugin // 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); + } + } }