]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/TwitterBridgePlugin.php
[ROUTES] Allow accept-header specification during router creation
[quix0rs-gnu-social.git] / plugins / TwitterBridge / TwitterBridgePlugin.php
index 623e2b51d8471250b90c0d6c74b1c7836d0f3fdd..79d705c2555cffc1cc9cff82a3881f4d812886b8 100644 (file)
@@ -47,7 +47,7 @@ require_once __DIR__ . '/twitter.php';
  */
 class TwitterBridgePlugin extends Plugin
 {
-    const VERSION = GNUSOCIAL_VERSION;
+    const PLUGIN_VERSION = '2.0.0';
     public $adminImportControl = false; // Should the 'import' checkbox be exposed in the admin panel?
 
     /**
@@ -111,23 +111,17 @@ class TwitterBridgePlugin extends Plugin
      */
     public function onRouterInitialized(URLMapper $m)
     {
-        $m->connect('panel/twitter', array('action' => 'twitteradminpanel'));
+        $m->connect('panel/twitter', ['action' => 'twitteradminpanel']);
 
         if (self::hasKeys()) {
-            $m->connect(
-                'twitter/authorization',
-                array('action' => 'twitterauthorization')
-            );
-            $m->connect(
-                'settings/twitter', array(
-                    'action' => 'twittersettings'
-                    )
-                );
+            $m->connect('twitter/authorization',
+                        ['action' => 'twitterauthorization']);
+            $m->connect('settings/twitter',
+                        ['action' => 'twittersettings']);
+
             if (common_config('twitter', 'signin')) {
-                $m->connect(
-                    'main/twitterlogin',
-                    array('action' => 'twitterlogin')
-                );
+                $m->connect('main/twitterlogin',
+                            ['action' => 'twitterlogin']);
             }
         }
 
@@ -299,9 +293,9 @@ class TwitterBridgePlugin extends Plugin
     {
         $versions[] = array(
             'name' => 'TwitterBridge',
-            'version' => self::VERSION,
+            'version' => self::PLUGIN_VERSION,
             'author' => 'Zach Copley, Julien C, Jean Baptiste Favre',
-            'homepage' => 'http://status.net/wiki/Plugin:TwitterBridge',
+            'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/TwitterBridge',
             // TRANS: Plugin description.
             'rawdescription' => _m('The Twitter "bridge" plugin allows integration ' .
                 'of a StatusNet instance with ' .
@@ -570,4 +564,28 @@ class TwitterBridgePlugin extends Plugin
 
         return true;
     }
+    
+    /**
+     * Set the object_type field of previously imported Twitter notices to
+     * ActivityObject::NOTE if they are unset. Null object_type caused a notice
+     * not to show on the timeline.
+     */
+    public function onEndUpgrade()
+    {
+       printfnq("Ensuring all Twitter notices have an object_type...");
+       
+       $notice = new Notice();
+       $notice->whereAdd("source='twitter'");
+       $notice->whereAdd('object_type IS NULL');
+       
+       if ($notice->find()) {
+               while ($notice->fetch()) {
+                       $orig = Notice::getKV('id', $notice->id);
+                       $notice->object_type = ActivityObject::NOTE;
+                       $notice->update($orig);
+               }
+       }
+       
+       printfnq("DONE.\n");
+    }
 }