]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Share plugin now handles showing form in NoticeOptionItems
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 12 Mar 2015 15:33:34 +0000 (16:33 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 12 Mar 2015 15:33:34 +0000 (16:33 +0100)
actions/showstream.php
lib/default.php
lib/noticelistitem.php
lib/profilenoticelist.php [deleted file]
lib/profilenoticelistitem.php [deleted file]
lib/repeatform.php [deleted file]
plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php
plugins/ModPlus/actions/remoteprofile.php
plugins/Share/SharePlugin.php
plugins/Share/forms/repeat.php [new file with mode: 0644]

index eb6300fec21665947de705cc167cb5754d3d9470..8dd6c7deff0522f9410b8770bc1c6ce98061bb38 100644 (file)
@@ -225,10 +225,7 @@ class ShowstreamAction extends ProfileAction
 
     function showNotices()
     {
-        $pnl = null;
-        if (Event::handle('ShowStreamNoticeList', array($this->notice, $this, &$pnl))) {
-            $pnl = new ProfileNoticeList($this->notice, $this);
-        }
+        $pnl = new NoticeList($this->notice, $this);
         $cnt = $pnl->show();
         if (0 == $cnt) {
             $this->showEmptyListMessage();
index 8b15d57857892ecb895cadd553cf0de2e4a86b74..e9382a86bcd0900409c3d9eaa3ef21a1b945d46e 100644 (file)
@@ -302,6 +302,7 @@ $default =
                             'AuthCrypt' => array(),
                             'Cronish' => array(),
                             'Favorite' => array(),
+                            'Share' => array(),
                             'LRDD' => array(),
                             'StrictTransportSecurity' => array(),
                         ),
index 9c2f2ed4060b463c5d39241250e3e24cf63409f1..bb1eb17eb34479c032d7e050ddc8a0f9d77df1a7 100644 (file)
@@ -193,7 +193,6 @@ class NoticeListItem extends Widget
                 $this->out->elementStart('div', 'notice-options');
                 if (Event::handle('StartShowNoticeOptionItems', array($this))) {
                     $this->showReplyLink();
-                    $this->showRepeatForm();
                     $this->showDeleteLink();
                     Event::handle('EndShowNoticeOptionItems', array($this));
                 }
@@ -605,34 +604,6 @@ class NoticeListItem extends Widget
         }
     }
 
-    /**
-     * show the form to repeat a notice
-     *
-     * @return void
-     */
-    function showRepeatForm()
-    {
-        if ($this->notice->scope == Notice::PUBLIC_SCOPE ||
-            $this->notice->scope == Notice::SITE_SCOPE) {
-            $user = common_current_user();
-            if (!empty($user) &&
-                $user->id != $this->notice->profile_id) {
-                $this->out->text(' ');
-                $profile = $user->getProfile();
-                if ($profile->hasRepeated($this->notice)) {
-                    $this->out->element('span', array('class' => 'repeated',
-                                                      // TRANS: Title for repeat form status in notice list when a notice has been repeated.
-                                                      'title' => _('Notice repeated.')),
-                                        // TRANS: Repeat form status in notice list when a notice has been repeated.
-                                        _('Repeated'));
-                } else {
-                    $rf = new RepeatForm($this->out, $this->notice);
-                    $rf->show();
-                }
-            }
-        }
-    }
-
     /**
      * finish the notice
      *
diff --git a/lib/profilenoticelist.php b/lib/profilenoticelist.php
deleted file mode 100644 (file)
index d95709e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-if (!defined('GNUSOCIAL')) { exit(1); }
-
-class ProfileNoticeList extends NoticeList
-{
-    function newListItem($notice)
-    {
-        return new ProfileNoticeListItem($notice, $this->out);
-    }
-}
diff --git a/lib/profilenoticelistitem.php b/lib/profilenoticelistitem.php
deleted file mode 100644 (file)
index d7773ca..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-if (!defined('GNUSOCIAL')) { exit(1); }
-
-// We don't show the author for a profile, since we already know who it is!
-
-/**
- * Slightly modified from standard list; the author & avatar are hidden
- * in CSS. We used to remove them here too, but as it turns out that
- * confuses the inline reply code... and we hide them in CSS anyway
- * since realtime updates come through in original form.
- *
- * Remaining customization right now is for the repeat marker, where
- * it'll list who the original poster was instead of who did the repeat
- * (since the repeater is you, and the repeatee isn't shown!)
- * This will remain inconsistent if realtime updates come through,
- * since those'll get rendered as a regular NoticeListItem.
- */
-class ProfileNoticeListItem extends DoFollowListItem
-{
-    /**
-     * show a link to the author of repeat
-     *
-     * @return void
-     */
-    function showRepeat()
-    {
-        if (!empty($this->repeat)) {
-
-            // FIXME: this code is almost identical to default; need to refactor
-
-            $attrs = array('href' => $this->profile->profileurl,
-                           'class' => 'url');
-
-            if (!empty($this->profile->fullname)) {
-                $attrs['title'] = $this->profile->getFancyName();
-            }
-
-            $this->out->elementStart('span', 'repeat');
-
-            $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
-
-            // TRANS: Link to the author of a repeated notice. %s is a linked nickname.
-            $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
-
-            $this->out->elementEnd('span');
-        }
-    }
-}
diff --git a/lib/repeatform.php b/lib/repeatform.php
deleted file mode 100644 (file)
index f0ce37f..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Form for repeating a notice
- *
- * PHP version 5
- *
- * LICENCE: This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * @category  Form
- * @package   StatusNet
- * @author    Evan Prodromou <evan@status.net>
- * @copyright 2009 StatusNet, Inc.
- * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://status.net/
- */
-
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-/**
- * Form for repeating a notice
- *
- * @category Form
- * @package  StatusNet
- * @author   Evan Prodromou <evan@status.net>
- * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://status.net/
- */
-class RepeatForm extends Form
-{
-    /**
-     * Notice to repeat
-     */
-    var $notice = null;
-
-    /**
-     * Constructor
-     *
-     * @param HTMLOutputter $out    output channel
-     * @param Notice        $notice notice to repeat
-     */
-    function __construct($out=null, $notice=null)
-    {
-        parent::__construct($out);
-
-        $this->notice = $notice;
-    }
-
-    /**
-     * ID of the form
-     *
-     * @return int ID of the form
-     */
-    function id()
-    {
-        return 'repeat-' . $this->notice->id;
-    }
-
-    /**
-     * Action of the form
-     *
-     * @return string URL of the action
-     */
-    function action()
-    {
-        return common_local_url('repeat');
-    }
-
-    /**
-     * Legend of the Form
-     *
-     * @return void
-     */
-    function formLegend()
-    {
-        // TRANS: For legend for notice repeat form.
-        $this->out->element('legend', null, _('Repeat this notice?'));
-    }
-
-    /**
-     * Data elements
-     *
-     * @return void
-     */
-    function formData()
-    {
-        $this->out->hidden('notice-n'.$this->notice->id,
-                           $this->notice->id,
-                           'notice');
-    }
-
-    /**
-     * Action elements
-     *
-     * @return void
-     */
-    function formActions()
-    {
-        $this->out->submit('repeat-submit-' . $this->notice->id,
-                           // TRANS: Button text to repeat a notice on notice repeat form.
-                           _m('BUTTON','Yes'), 'submit', null,
-                           // TRANS: Button title to repeat a notice on notice repeat form.
-                           _('Repeat this notice.'));
-    }
-
-    /**
-     * Class of the form.
-     *
-     * @return string the form's class
-     */
-    function formClass()
-    {
-        return 'form_repeat';
-    }
-}
index 6b3c757b1e68845a95a80acea90e61fb1dfb0305..c4628c4ecc844041e931b71b3719782f67c1ff74 100644 (file)
@@ -137,21 +137,4 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
                            array('nickname' => $nav->action->trimmed('nickname'))), _('Bio'), 
                            _('The user\'s extended profile'), $nav->action->trimmed('action') == 'bio', 'nav_bio');
     }
-
-    //Why the heck is this shoved into this plugin!?!?  It deserves its own!
-    function onShowStreamNoticeList($notice, $action, &$pnl)
-    {
-        //TODO: This function is called after the notices in $notice are superfluously retrieved in showstream.php
-        $newnotice = new Notice();
-        $newnotice->profile_id = $action->user->id;
-        $newnotice->orderBy('modified DESC');
-        $newnotice->whereAdd('reply_to IS NULL');
-        $newnotice->limit(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
-        $newnotice->find();
-
-        $pnl = new NoticeTree($newnotice, $action);
-        return false;
-    }
-
 }
-
index 133646480c6b5fbd763eb480b2a8454b9c521baa..4203672030179b74d7b3bad0e5b8d500cfcabd24 100644 (file)
@@ -39,10 +39,7 @@ class RemoteProfileAction extends ShowstreamAction
             $this->raw(common_markup_to_html($markdown));
         }else{
 
-            $pnl = null;
-            if (Event::handle('ShowStreamNoticeList', array($this->notice, $this, &$pnl))) {
-                $pnl = new ProfileNoticeList($this->notice, $this);
-            }
+            $pnl = new NoticeList($this->notice, $this);
             $cnt = $pnl->show();
             if (0 == $cnt) {
                 $this->showEmptyListMessage();
index 18143d5a637e1aa18d3f6b39c6beea4e1dec820e..0a974701c08e60934ad3d0de584de5acd4b679f7 100644 (file)
@@ -161,22 +161,16 @@ class SharePlugin extends ActivityVerbHandlerPlugin
         // ActivityObject is instead turned into an Activity
         $object          = new Activity();
         $object->verb    = ActivityVerb::SHARE;
-        $object->type    = $notice->object_type;
-        $object->title   = sprintf(_('%1$s repeated a notice by %2$s'),
-                              $object->getProfile()->getNickname(),
-                              $target->getProfile()->getNickname());
         $object->content = $notice->rendered;
+        $this->extendActivity($stored, $act);
+
         return $object;
     }
 
     public function deleteRelated(Notice $notice)
     {
-        try {
-            $fave = Fave::fromStored($notice);
-            $fave->delete();
-        } catch (NoResultException $e) {
-            // Cool, no problem. We wanted to get rid of it anyway.
-        }
+        // No action needed as we don't have a separate table for share objects.
+        return true;
     }
 
     // API stuff
@@ -260,20 +254,26 @@ class SharePlugin extends ActivityVerbHandlerPlugin
      *
      * @return void
      */
-    public function onStartShowNoticeOptionItems($nli)
+    public function onEndShowNoticeOptionItems($nli)
     {
-        if (Event::handle('StartShowFaveForm', array($nli))) {
+        // FIXME: Use bitmasks (but be aware that PUBLIC_SCOPE is 0!)
+        if ($nli->notice->scope == Notice::PUBLIC_SCOPE ||
+                $nli->notice->scope == Notice::SITE_SCOPE) {
             $scoped = Profile::current();
-            if ($scoped instanceof Profile) {
-                if (Fave::existsForProfile($nli->notice, $scoped)) {
-                    $disfavor = new DisfavorForm($nli->out, $nli->notice);
-                    $disfavor->show();
+            if ($scoped instanceof Profile &&
+                    $scoped->getID() !== $nli->notice->getProfile()->getID()) {
+
+                if ($scoped->hasRepeated($nli->notice)) {
+                    $nli->out->element('span', array('class' => 'repeated',
+                                                      // TRANS: Title for repeat form status in notice list when a notice has been repeated.
+                                                      'title' => _('Notice repeated.')),
+                                        // TRANS: Repeat form status in notice list when a notice has been repeated.
+                                        _('Repeated'));
                 } else {
-                    $favor = new FavorForm($nli->out, $nli->notice);
-                    $favor->show();
+                    $repeat = new RepeatForm($nli->out, $nli->notice);
+                    $repeat->show();
                 }
             }
-            Event::handle('EndShowFaveForm', array($nli));
         }
     }
 
diff --git a/plugins/Share/forms/repeat.php b/plugins/Share/forms/repeat.php
new file mode 100644 (file)
index 0000000..f0ce37f
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for repeating a notice
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Form
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+    exit(1);
+}
+
+/**
+ * Form for repeating a notice
+ *
+ * @category Form
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://status.net/
+ */
+class RepeatForm extends Form
+{
+    /**
+     * Notice to repeat
+     */
+    var $notice = null;
+
+    /**
+     * Constructor
+     *
+     * @param HTMLOutputter $out    output channel
+     * @param Notice        $notice notice to repeat
+     */
+    function __construct($out=null, $notice=null)
+    {
+        parent::__construct($out);
+
+        $this->notice = $notice;
+    }
+
+    /**
+     * ID of the form
+     *
+     * @return int ID of the form
+     */
+    function id()
+    {
+        return 'repeat-' . $this->notice->id;
+    }
+
+    /**
+     * Action of the form
+     *
+     * @return string URL of the action
+     */
+    function action()
+    {
+        return common_local_url('repeat');
+    }
+
+    /**
+     * Legend of the Form
+     *
+     * @return void
+     */
+    function formLegend()
+    {
+        // TRANS: For legend for notice repeat form.
+        $this->out->element('legend', null, _('Repeat this notice?'));
+    }
+
+    /**
+     * Data elements
+     *
+     * @return void
+     */
+    function formData()
+    {
+        $this->out->hidden('notice-n'.$this->notice->id,
+                           $this->notice->id,
+                           'notice');
+    }
+
+    /**
+     * Action elements
+     *
+     * @return void
+     */
+    function formActions()
+    {
+        $this->out->submit('repeat-submit-' . $this->notice->id,
+                           // TRANS: Button text to repeat a notice on notice repeat form.
+                           _m('BUTTON','Yes'), 'submit', null,
+                           // TRANS: Button title to repeat a notice on notice repeat form.
+                           _('Repeat this notice.'));
+    }
+
+    /**
+     * Class of the form.
+     *
+     * @return string the form's class
+     */
+    function formClass()
+    {
+        return 'form_repeat';
+    }
+}