X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FBookmark%2FBookmarkPlugin.php;h=ff68917bcca36a683f5651f47eed337b3461e13c;hb=59043dca7fb6f974b11797c4d0f20e5b78b0611d;hp=05252862296877661da0f659c0881606da302d49;hpb=f880e6498de6d2a0e47a4b9d3079bf1ab92aeec1;p=quix0rs-gnu-social.git diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index 0525286229..ff68917bcc 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -159,11 +159,11 @@ class BookmarkPlugin extends MicroAppPlugin case 'Bookmark': include_once $dir.'/'.$cls.'.php'; return false; + case 'BookmarkListItem': case 'BookmarkForm': case 'InitialBookmarkForm': case 'DeliciousBackupImporter': case 'DeliciousBookmarkImporter': - case 'BookmarkNoticeListItemAdapter': include_once $dir.'/'.strtolower($cls).'.php'; return false; default: @@ -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; } @@ -522,7 +533,7 @@ class BookmarkPlugin extends MicroAppPlugin */ function adaptNoticeListItem($nli) { - return new BookmarkNoticeListItemAdapter($nli); + return new BookmarkListItem($nli); } function entryForm($out) @@ -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); + } + } }