]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/microappplugin.php
Add urlshortenerplugin2.php to solve some @todo's and adding exceptions
[quix0rs-gnu-social.git] / lib / microappplugin.php
index 11058ad1ac80300e7ebf3d26bdec8773de9b2fd0..4da3bef935a7e60c7a6c6da3e00511df18f4c2f3 100644 (file)
@@ -162,6 +162,14 @@ abstract class MicroAppPlugin extends Plugin
      */
     abstract function deleteRelated($notice);
 
+    /**
+     *
+     */
+    public function newFormAction() {
+        // such as 'newbookmark' or 'newevent' route
+        return 'new'.$this->tag();
+    }
+
     /**
      * Check if a given notice object should be handled by this micro-app
      * plugin.
@@ -353,7 +361,7 @@ abstract class MicroAppPlugin extends Plugin
 
             $actor = $oprofile->checkAuthorship($activity);
 
-            if (empty($actor)) {
+            if (!$actor instanceof Ostatus_profile) {
                 // TRANS: Client exception thrown when no author for an activity was found.
                 throw new ClientException(_('Cannot get author for activity.'));
             }
@@ -390,19 +398,19 @@ abstract class MicroAppPlugin extends Plugin
 
             if ($target instanceof User_group) {
                 $uri = $target->getUri();
-                if (!in_array($uri, $activity->context->attention)) {
+                if (!array_key_exists($uri, $activity->context->attention)) {
                     // @todo FIXME: please document (i18n).
                     // TRANS: Client exception thrown when ...
-                    throw new ClientException(_('Bookmark not posted to this group.'));
+                    throw new ClientException(_('Object not posted to this group.'));
                 }
             } else if ($target instanceof User) {
                 $uri      = $target->uri;
                 $original = null;
                 if (!empty($activity->context->replyToID)) {
-                    $original = Notice::staticGet('uri',
+                    $original = Notice::getKV('uri',
                                                   $activity->context->replyToID);
                 }
-                if (!in_array($uri, $activity->context->attention) &&
+                if (!array_key_exists($uri, $activity->context->attention) &&
                     (empty($original) ||
                      $original->profile_id != $target->id)) {
                     // @todo FIXME: Please document (i18n).
@@ -536,7 +544,9 @@ abstract class MicroAppPlugin extends Plugin
 
     function onStartShowEntryForms(&$tabs)
     {
-        $tabs[$this->tag()] = $this->appTitle();
+        $tabs[$this->tag()] = array('title' => $this->appTitle(),
+                                    'href'  => common_local_url($this->newFormAction()),
+                                   );
         return true;
     }