]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/microappplugin.php
Remove missing twittersettings page from subscriptions helper
[quix0rs-gnu-social.git] / lib / microappplugin.php
index 5df76a074f2e35b5f520072c2c1ecd21b06cb972..11058ad1ac80300e7ebf3d26bdec8773de9b2fd0 100644 (file)
@@ -137,21 +137,6 @@ abstract class MicroAppPlugin extends Plugin
      */
     abstract function activityObjectFromNotice($notice);
 
-    /**
-     * Custom HTML output for your special notice; called when a
-     * matching notice turns up in a NoticeListItem.
-     *
-     * All micro-app classes must override this method.
-     *
-     * @param Notice $notice
-     * @param HTMLOutputter $out
-     *
-     * @fixme WARNING WARNING WARNING base plugin stuff below tries to close
-     * a div that this function opens in the BookmarkPlugin child class.
-     * This is probably wrong.
-     */
-    abstract function showNotice($notice, $out);
-
     /**
      * When building the primary notice form, we'll fetch also some
      * alternate forms for specialized types -- that's you!
@@ -190,7 +175,7 @@ abstract class MicroAppPlugin extends Plugin
      */
     function isMyNotice($notice) {
         $types = $this->types();
-        return in_array($notice->object_type, $types);
+        return ($notice->verb == ActivityVerb::POST) && in_array($notice->object_type, $types);
     }
 
     /**
@@ -208,6 +193,8 @@ abstract class MicroAppPlugin extends Plugin
     function isMyActivity($activity) {
         $types = $this->types();
         return (count($activity->objects) == 1 &&
+                ($activity->objects[0] instanceof ActivityObject) &&
+                ($activity->verb == ActivityVerb::POST) &&
                 in_array($activity->objects[0]->type, $types));
     }
 
@@ -284,7 +271,10 @@ abstract class MicroAppPlugin extends Plugin
         $adapter = $this->adaptNoticeListItem($nli);
 
         if (!empty($adapter)) {
-            $adapter->show();
+            $adapter->showNotice();
+            $adapter->showNoticeAttachments();
+            $adapter->showNoticeInfo();
+            $adapter->showNoticeOptions();
         } else {
             $this->oldShowNotice($nli);
         }
@@ -357,7 +347,7 @@ abstract class MicroAppPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onStartHandleFeedEntryWithProfile($activity, $oprofile)
+    function onStartHandleFeedEntryWithProfile($activity, $oprofile, &$notice)
     {
         if ($this->isMyActivity($activity)) {
 
@@ -372,11 +362,11 @@ abstract class MicroAppPlugin extends Plugin
 
             $options = array('uri' => $object->id,
                              'url' => $object->link,
-                             'is_local' => Notice::REMOTE_OMB,
+                             'is_local' => Notice::REMOTE,
                              'source' => 'ostatus');
 
             // $actor is an ostatus_profile
-            $this->saveNoticeFromActivity($activity, $actor->localProfile(), $options);
+            $notice = $this->saveNoticeFromActivity($activity, $actor->localProfile(), $options);
 
             return false;
         }
@@ -402,7 +392,7 @@ abstract class MicroAppPlugin extends Plugin
                 $uri = $target->getUri();
                 if (!in_array($uri, $activity->context->attention)) {
                     // @todo FIXME: please document (i18n).
-                    // TRANS: Client exception.
+                    // TRANS: Client exception thrown when ...
                     throw new ClientException(_('Bookmark not posted to this group.'));
                 }
             } else if ($target instanceof User) {
@@ -416,7 +406,7 @@ abstract class MicroAppPlugin extends Plugin
                     (empty($original) ||
                      $original->profile_id != $target->id)) {
                     // @todo FIXME: Please document (i18n).
-                    // TRANS: Client exception.
+                    // TRANS: Client exception when ...
                     throw new ClientException(_('Object not posted to this user.'));
                 }
             } else {
@@ -430,7 +420,7 @@ abstract class MicroAppPlugin extends Plugin
 
             $options = array('uri' => $object->id,
                              'url' => $object->link,
-                             'is_local' => Notice::REMOTE_OMB,
+                             'is_local' => Notice::REMOTE,
                              'source' => 'ostatus');
 
             // $actor is an ostatus_profile
@@ -458,9 +448,9 @@ abstract class MicroAppPlugin extends Plugin
             $options = array('source' => 'atompub');
 
             // $user->getProfile() is a Profile
-            $this->saveNoticeFromActivity($activity,
-                                          $user->getProfile(),
-                                          $options);
+            $notice = $this->saveNoticeFromActivity($activity,
+                                                    $user->getProfile(),
+                                                    $options);
 
             return false;
         }
@@ -560,20 +550,9 @@ abstract class MicroAppPlugin extends Plugin
         return true;
     }
 
-    /**
-     * Custom HTML output for your special notice; called when a
-     * matching notice turns up in a NoticeListItem.
-     *
-     * All micro-app classes must override this method.
-     *
-     * @param Notice $notice
-     * @param HTMLOutputter $out
-     *
-     * @fixme WARNING WARNING WARNING base plugin stuff below tries to close
-     * a div that this function opens in the BookmarkPlugin child class.
-     * This is probably wrong.
-     */
-    abstract function showNotice($notice, $out);
-
-
+    function showNotice($notice, $out)
+    {
+        // TRANS: Server exception thrown when a micro app plugin developer has not done his job too well.
+        throw new ServerException(_('You must implement either adaptNoticeListItem() or showNotice().'));
+    }
 }