From: Stephen Paul Weber Date: Sun, 18 Oct 2015 21:28:55 +0000 (+0000) Subject: Allow users to opt out of sending linkbacks X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=677f0ac479d9c450257822e41f01d33e70f95503;p=quix0rs-gnu-social.git Allow users to opt out of sending linkbacks --- diff --git a/plugins/Linkback/LinkbackPlugin.php b/plugins/Linkback/LinkbackPlugin.php index 4e49de670f..4af67baba4 100644 --- a/plugins/Linkback/LinkbackPlugin.php +++ b/plugins/Linkback/LinkbackPlugin.php @@ -65,9 +65,14 @@ class LinkbackPlugin extends Plugin // notice content $c = $notice->content; $this->notice = $notice; - // Ignoring results - common_replace_urls_callback($c, - array($this, 'linkbackUrl')); + + if(!$notice->getProfile()-> + getPref("linkbackplugin", "disable_linkbacks") + ) { + // Ignoring results + common_replace_urls_callback($c, + array($this, 'linkbackUrl')); + } if($notice->isRepeat()) { $repeat = Notice::getByID($notice->repeat_of); @@ -315,4 +320,23 @@ class LinkbackPlugin extends Plugin 'or Trackback protocols.')); return true; } + + public function onStartInitializeRouter(URLMapper $m) + { + $m->connect('settings/linkback', array('action' => 'linkbacksettings')); + return true; + } + + function onEndAccountSettingsNav($action) + { + $action_name = $action->trimmed('action'); + + $action->menuItem(common_local_url('linkbacksettings'), + // TRANS: OpenID plugin menu item on user settings page. + _m('MENU', 'Send Linkbacks'), + // TRANS: OpenID plugin tooltip for user settings menu item. + _m('Opt-out of sending linkbacks.'), + $action_name === 'linkbacksettings'); + return true; + } } diff --git a/plugins/Linkback/actions/linkbacksettings.php b/plugins/Linkback/actions/linkbacksettings.php new file mode 100644 index 0000000000..261e2979dc --- /dev/null +++ b/plugins/Linkback/actions/linkbacksettings.php @@ -0,0 +1,91 @@ +. + * + * @category Settings + * @package StatusNet + * @author Stephen Paul Weber + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + */ + +if (!defined('GNUSOCIAL')) { exit(1); } + +/** + * Settings for Linkback + * + * Lets users opt out of sending linkbacks + * + * @category Settings + * @author Stephen Paul Weber + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + */ +class LinkbacksettingsAction extends SettingsAction +{ + /** + * Title of the page + * + * @return string Page title + */ + function title() + { + // TRANS: Title of Linkback settings page for a user. + return _m('TITLE','Linkback settings'); + } + + /** + * Instructions for use + * + * @return string Instructions for use + */ + function getInstructions() + { + // TRANS: Form instructions for Linkback settings. + return _m('Linkbacks inform post authors when you link to them. ' . + 'You can disable this feature here.'); + } + + function showContent() + { + $this->elementStart('form', array('method' => 'post', + 'class' => 'form_settings', + 'action' => + common_local_url('linkbacksettings'))); + $this->hidden('token', common_session_token()); + + $this->elementStart('fieldset'); + $this->element('legend', null, _m('LEGEND','Preferences')); + $this->checkbox('disable_linkbacks', "Opt out of sending linkbacks for URLs you post", $this->scoped->getPref("linkbackplugin", "disable_linkbacks")); + // TRANS: Button text to save OpenID prefs + $this->submit('settings_linkback_prefs_save', _m('BUTTON','Save'), 'submit', 'save_prefs'); + $this->elementEnd('fieldset'); + + $this->elementEnd('form'); + } + + /** + * Handle a POST request + * + * @return void + */ + protected function doPost() + { + $x = $this->scoped->setPref("linkbackplugin", "disable_linkbacks", $this->boolean('disable_linkbacks')); + + return _m('Linkback preferences saved.'); + } +}