]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/BookmarkPlugin.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / plugins / Bookmark / BookmarkPlugin.php
index 3166b9ee30c6a7d0868499fb9b379f6b2f1b74d7..77b8a8483cfc6f244bdd3d041c6f61a0ff650139 100644 (file)
@@ -159,6 +159,7 @@ class BookmarkPlugin extends MicroAppPlugin
         case 'Bookmark':
             include_once $dir.'/'.$cls.'.php';
             return false;
+        case 'BookmarkListItem':
         case 'BookmarkForm':
         case 'InitialBookmarkForm':
         case 'DeliciousBackupImporter':
@@ -291,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;
     }
 
     /**
@@ -321,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);
@@ -354,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;
     }
 
@@ -521,7 +533,7 @@ class BookmarkPlugin extends MicroAppPlugin
      */
     function adaptNoticeListItem($nli)
     {
-        return new BookmarkNoticeListItemAdapter($nli);
+        return new BookmarkListItem($nli);
     }
 
     function entryForm($out)