summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Adsense/AdsensePlugin.php160
-rw-r--r--plugins/BlankAd/BlankAdPlugin.php124
-rw-r--r--plugins/BlankAd/redpixel.pngbin0 -> 159 bytes
-rw-r--r--plugins/Facebook/facebookaction.php2
-rw-r--r--plugins/OpenX/OpenXPlugin.php165
-rw-r--r--plugins/PoweredByStatusNet/PoweredByStatusNetPlugin.php5
-rw-r--r--plugins/PoweredByStatusNet/locale/PoweredByStatusNet.po32
-rw-r--r--plugins/PubSubHubBub/PubSubHubBubPlugin.php65
-rw-r--r--plugins/Realtime/RealtimePlugin.php2
-rw-r--r--plugins/Realtime/realtimeupdate.css3
-rw-r--r--plugins/TwitterBridge/TwitterBridgePlugin.php26
-rw-r--r--plugins/TwitterBridge/twitterauthorization.php438
-rw-r--r--plugins/TwitterBridge/twitterlogin.php97
-rw-r--r--plugins/TwitterBridge/twitteroauthclient.php7
-rw-r--r--plugins/TwitterBridge/twittersettings.php33
15 files changed, 1099 insertions, 60 deletions
diff --git a/plugins/Adsense/AdsensePlugin.php b/plugins/Adsense/AdsensePlugin.php
new file mode 100644
index 000000000..ab2b9a6fb
--- /dev/null
+++ b/plugins/Adsense/AdsensePlugin.php
@@ -0,0 +1,160 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin for Google Adsense
+ *
+ * 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 Ads
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2010 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);
+}
+
+/**
+ * Plugin to add Google Adsense to StatusNet sites
+ *
+ * This plugin lets you add Adsense ad units to your StatusNet site.
+ *
+ * We support the 4 ad sizes for the Universal Ad Platform (UAP):
+ *
+ * Medium Rectangle
+ * (Small) Rectangle
+ * Leaderboard
+ * Wide Skyscraper
+ *
+ * They fit in different places on the default theme. Some themes
+ * might interact quite poorly with this plugin.
+ *
+ * To enable advertising, you must sign up with Google Adsense and
+ * get a client ID.
+ *
+ * https://www.google.com/adsense/
+ *
+ * You'll also need to create an Adsense for Content unit in one
+ * of the four sizes described above. At the end of the process,
+ * note the "google_ad_client" and "google_ad_slot" values in the
+ * resultant Javascript.
+ *
+ * Add the plugin to config.php like so:
+ *
+ * addPlugin('Adsense', array('client' => 'Your client ID',
+ * 'rectangle' => 'slot'));
+ *
+ * Here, your client ID is the value of google_ad_client and the
+ * slot is the value of google_ad_slot. Note that if you create
+ * a different size, you'll need to provide different arguments:
+ * 'mediumRectangle', 'leaderboard', or 'wideSkyscraper'.
+ *
+ * If for some reason your ad server is different from the default,
+ * use the 'adScript' parameter to set the full path to the ad script.
+ *
+ * @category Plugin
+ * @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/
+ *
+ * @seeAlso UAPPlugin
+ */
+
+class AdsensePlugin extends UAPPlugin
+{
+ public $adScript = 'http://pagead2.googlesyndication.com/pagead/show_ads.js';
+ public $client = null;
+
+ /**
+ * Show a medium rectangle 'ad'
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showMediumRectangle($action)
+ {
+ $this->showAdsenseCode($action, 300, 250, $this->mediumRectangle);
+ }
+
+ /**
+ * Show a rectangle 'ad'
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showRectangle($action)
+ {
+ $this->showAdsenseCode($action, 180, 150, $this->rectangle);
+ }
+
+ /**
+ * Show a wide skyscraper ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showWideSkyscraper($action)
+ {
+ $this->showAdsenseCode($action, 160, 600, $this->wideSkyscraper);
+ }
+
+ /**
+ * Show a leaderboard ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showLeaderboard($action)
+ {
+ $this->showAdsenseCode($action, 728, 90, $this->leaderboard);
+ }
+
+ /**
+ * Output the bits of JavaScript code to show Adsense
+ *
+ * @param Action $action Action being shown
+ * @param integer $width Width of the block
+ * @param integer $height Height of the block
+ * @param string $slot Slot identifier
+ *
+ * @return void
+ */
+
+ protected function showAdsenseCode($action, $width, $height, $slot)
+ {
+ $code = 'google_ad_client = "'.$this->client.'"; ';
+ $code .= 'google_ad_slot = "'.$slot.'"; ';
+ $code .= 'google_ad_width = '.$width.'; ';
+ $code .= 'google_ad_height = '.$height.'; ';
+
+ $action->inlineScript($code);
+
+ $action->script($this->adScript);
+ }
+} \ No newline at end of file
diff --git a/plugins/BlankAd/BlankAdPlugin.php b/plugins/BlankAd/BlankAdPlugin.php
new file mode 100644
index 000000000..0e2719aed
--- /dev/null
+++ b/plugins/BlankAd/BlankAdPlugin.php
@@ -0,0 +1,124 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin for testing ad layout
+ *
+ * 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 Ads
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2010 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);
+}
+
+/**
+ * Plugin for testing ad layout
+ *
+ * This plugin uses the UAPPlugin framework to output ad content. However,
+ * its ad content is just images with one red pixel stretched to the
+ * right size. It's mostly useful for debugging theme layout.
+ *
+ * To use this plugin, set the parameter for the ad size you want to use
+ * to true (or anything non-null). For example, to make a leaderboard:
+ *
+ * addPlugin('BlankAd', array('leaderboard' => true));
+ *
+ * @category Plugin
+ * @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/
+ *
+ * @seeAlso Location
+ */
+
+class BlankAdPlugin extends UAPPlugin
+{
+ /**
+ * Show a medium rectangle 'ad'
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showMediumRectangle($action)
+ {
+ $action->element('img',
+ array('width' => 300,
+ 'height' => 250,
+ 'src' => common_path('plugins/BlankAd/redpixel.png')),
+ '');
+ }
+
+ /**
+ * Show a rectangle 'ad'
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showRectangle($action)
+ {
+ $action->element('img',
+ array('width' => 180,
+ 'height' => 150,
+ 'src' => common_path('plugins/BlankAd/redpixel.png')),
+ '');
+ }
+
+ /**
+ * Show a wide skyscraper ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showWideSkyscraper($action)
+ {
+ $action->element('img',
+ array('width' => 160,
+ 'height' => 600,
+ 'src' => common_path('plugins/BlankAd/redpixel.png')),
+ '');
+ }
+
+ /**
+ * Show a leaderboard ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showLeaderboard($action)
+ {
+ $action->element('img',
+ array('width' => 728,
+ 'height' => 90,
+ 'src' => common_path('plugins/BlankAd/redpixel.png')),
+ '');
+ }
+} \ No newline at end of file
diff --git a/plugins/BlankAd/redpixel.png b/plugins/BlankAd/redpixel.png
new file mode 100644
index 000000000..26299a552
--- /dev/null
+++ b/plugins/BlankAd/redpixel.png
Binary files differ
diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php
index 815fee094..389e1ea81 100644
--- a/plugins/Facebook/facebookaction.php
+++ b/plugins/Facebook/facebookaction.php
@@ -89,7 +89,7 @@ class FacebookAction extends Action
function showScripts()
{
- $this->script('js/facebookapp.js');
+ $this->script('facebookapp.js');
}
/**
diff --git a/plugins/OpenX/OpenXPlugin.php b/plugins/OpenX/OpenXPlugin.php
new file mode 100644
index 000000000..59485f25d
--- /dev/null
+++ b/plugins/OpenX/OpenXPlugin.php
@@ -0,0 +1,165 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin for OpenX ad server
+ *
+ * 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 Ads
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2010 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);
+}
+
+/**
+ * Plugin for OpenX Ad Server
+ *
+ * This plugin supports the OpenX ad server, http://www.openx.org/
+ *
+ * We support the 4 ad sizes for the Universal Ad Platform (UAP):
+ *
+ * Medium Rectangle
+ * (Small) Rectangle
+ * Leaderboard
+ * Wide Skyscraper
+ *
+ * They fit in different places on the default theme. Some themes
+ * might interact quite poorly with this plugin.
+ *
+ * To enable advertising, you will need an OpenX server. You'll need
+ * to set up a "zone" for your StatusNet site that identifies a
+ * kind of ad you want to place (of the above 4 sizes).
+ *
+ * Add the plugin to config.php like so:
+ *
+ * addPlugin('OpenX', array('adScript' => 'full path to script',
+ * 'rectangle' => 1));
+ *
+ * Here, the 'adScript' parameter is the full path to the OpenX
+ * ad script, like 'http://example.com/www/delivery/ajs.php'. Note
+ * that we don't do any magic to swap between HTTP and HTTPS, so
+ * if you want HTTPS, say so.
+ *
+ * The 'rectangle' parameter is the zone ID for that ad space on
+ * your site. If you've configured another size, try 'mediumRectangle',
+ * 'leaderboard', or 'wideSkyscraper'.
+ *
+ * If for some reason your ad server is different from the default,
+ * use the 'adScript' parameter to set the full path to the ad script.
+ *
+ * @category Ads
+ * @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/
+ *
+ * @seeAlso UAPPlugin
+ */
+
+class OpenXPlugin extends UAPPlugin
+{
+ public $adScript = null;
+
+ /**
+ * Show a medium rectangle 'ad'
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showMediumRectangle($action)
+ {
+ $this->showAd($action, $this->mediumRectangle);
+ }
+
+ /**
+ * Show a rectangle 'ad'
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showRectangle($action)
+ {
+ $this->showAd($action, $this->rectangle);
+ }
+
+ /**
+ * Show a wide skyscraper ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showWideSkyscraper($action)
+ {
+ $this->showAd($action, $this->wideSkyscraper);
+ }
+
+ /**
+ * Show a leaderboard ad
+ *
+ * @param Action $action Action being shown
+ *
+ * @return void
+ */
+
+ protected function showLeaderboard($action)
+ {
+ $this->showAd($action, $this->leaderboard);
+ }
+
+ /**
+ * Show an ad using OpenX
+ *
+ * @param Action $action Action being shown
+ * @param integer $zone Zone to show
+ *
+ * @return void
+ */
+
+ protected function showAd($action, $zone)
+ {
+$scr = <<<ENDOFSCRIPT
+var m3_u = '%s';
+var m3_r = Math.floor(Math.random()*99999999999);
+if (!document.MAX_used) document.MAX_used = ',';
+document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
+document.write ("?zoneid=%d");
+document.write ('&amp;cb=' + m3_r);
+if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
+document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
+document.write ("&amp;loc=" + escape(window.location));
+if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
+if (document.context) document.write ("&context=" + escape(document.context));
+if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
+document.write ("'><\/scr"+"ipt>");
+ENDOFSCRIPT;
+
+ $action->inlineScript(sprintf($scr, $this->adScript, $zone));
+ return true;
+ }
+} \ No newline at end of file
diff --git a/plugins/PoweredByStatusNet/PoweredByStatusNetPlugin.php b/plugins/PoweredByStatusNet/PoweredByStatusNetPlugin.php
index c59fcca89..14d1608d3 100644
--- a/plugins/PoweredByStatusNet/PoweredByStatusNetPlugin.php
+++ b/plugins/PoweredByStatusNet/PoweredByStatusNetPlugin.php
@@ -46,8 +46,9 @@ class PoweredByStatusNetPlugin extends Plugin
function onEndAddressData($action)
{
$action->elementStart('span', 'poweredby');
- $action->text(_('powered by'));
- $action->element('a', array('href' => 'http://status.net/'), 'StatusNet');
+ $action->raw(sprintf(_m('powered by %s'),
+ sprintf('<a href="http://status.net/">%s</a>',
+ _m('StatusNet'))));
$action->elementEnd('span');
return true;
diff --git a/plugins/PoweredByStatusNet/locale/PoweredByStatusNet.po b/plugins/PoweredByStatusNet/locale/PoweredByStatusNet.po
new file mode 100644
index 000000000..bd39124ef
--- /dev/null
+++ b/plugins/PoweredByStatusNet/locale/PoweredByStatusNet.po
@@ -0,0 +1,32 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-01-22 15:03-0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: PoweredByStatusNetPlugin.php:49
+#, php-format
+msgid "powered by %s"
+msgstr ""
+
+#: PoweredByStatusNetPlugin.php:51
+msgid "StatusNet"
+msgstr ""
+
+#: PoweredByStatusNetPlugin.php:64
+msgid ""
+"Outputs powered by <a href=\"http://status.net/\">StatusNet</a> after site "
+"name."
+msgstr ""
diff --git a/plugins/PubSubHubBub/PubSubHubBubPlugin.php b/plugins/PubSubHubBub/PubSubHubBubPlugin.php
index 8286cd548..a880dc866 100644
--- a/plugins/PubSubHubBub/PubSubHubBubPlugin.php
+++ b/plugins/PubSubHubBub/PubSubHubBubPlugin.php
@@ -80,6 +80,21 @@ class PubSubHubBubPlugin extends Plugin
}
/**
+ * Check if plugin should be active; may be mass-enabled.
+ * @return boolean
+ */
+
+ function enabled()
+ {
+ if (common_config('site', 'private')) {
+ // PuSH relies on public feeds
+ return false;
+ }
+ // @fixme check for being on a private network?
+ return true;
+ }
+
+ /**
* Hooks the StartApiAtom event
*
* Adds the necessary bits to advertise PubSubHubBub
@@ -92,8 +107,9 @@ class PubSubHubBubPlugin extends Plugin
function onStartApiAtom($action)
{
- $action->element('link', array('rel' => 'hub', 'href' => $this->hub), null);
-
+ if ($this->enabled()) {
+ $action->element('link', array('rel' => 'hub', 'href' => $this->hub), null);
+ }
return true;
}
@@ -110,9 +126,11 @@ class PubSubHubBubPlugin extends Plugin
function onStartApiRss($action)
{
- $action->element('atom:link', array('rel' => 'hub',
- 'href' => $this->hub),
- null);
+ if ($this->enabled()) {
+ $action->element('atom:link', array('rel' => 'hub',
+ 'href' => $this->hub),
+ null);
+ }
return true;
}
@@ -130,6 +148,9 @@ class PubSubHubBubPlugin extends Plugin
function onHandleQueuedNotice($notice)
{
+ if (!$this->enabled()) {
+ return false;
+ }
$publisher = new Publisher($this->hub);
$feeds = array();
@@ -211,13 +232,20 @@ class PubSubHubBubPlugin extends Plugin
'format' => 'atom'));
}
}
-
- foreach (array_unique($feeds) as $feed) {
- if (!$publisher->publish_update($feed)) {
- common_log_line(LOG_WARNING,
- $feed.' was not published to hub at '.
- $this->hub.':'.$publisher->last_response());
- }
+ $feeds = array_unique($feeds);
+
+ ob_start();
+ $ok = $publisher->publish_update($feeds);
+ $push_last_response = ob_get_clean();
+
+ if (!$ok) {
+ common_log(LOG_WARNING,
+ 'Failure publishing ' . count($feeds) . ' feeds to hub at '.
+ $this->hub.': '.$push_last_response);
+ } else {
+ common_log(LOG_INFO,
+ 'Published ' . count($feeds) . ' feeds to hub at '.
+ $this->hub.': '.$push_last_response);
}
return true;
@@ -236,16 +264,21 @@ class PubSubHubBubPlugin extends Plugin
function onPluginVersion(&$versions)
{
+ $about = _m('The PubSubHubBub plugin pushes RSS/Atom updates '.
+ 'to a <a href = "'.
+ 'http://pubsubhubbub.googlecode.com/'.
+ '">PubSubHubBub</a> hub.');
+ if (!$this->enabled()) {
+ $about = '<span class="disabled" style="color:gray">' . $about . '</span> ' .
+ _m('(inactive on private site)');
+ }
$versions[] = array('name' => 'PubSubHubBub',
'version' => STATUSNET_VERSION,
'author' => 'Craig Andrews',
'homepage' =>
'http://status.net/wiki/Plugin:PubSubHubBub',
'rawdescription' =>
- _m('The PubSubHubBub plugin pushes RSS/Atom updates '.
- 'to a <a href = "'.
- 'http://pubsubhubbub.googlecode.com/'.
- '">PubSubHubBub</a> hub.'));
+ $about);
return true;
}
diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php
index 89640f5be..16e28e94d 100644
--- a/plugins/Realtime/RealtimePlugin.php
+++ b/plugins/Realtime/RealtimePlugin.php
@@ -87,7 +87,7 @@ class RealtimePlugin extends Plugin
$scripts = $this->_getScripts();
foreach ($scripts as $script) {
- $action->script($script);
+ $action->script(common_path($script));
}
$user = common_current_user();
diff --git a/plugins/Realtime/realtimeupdate.css b/plugins/Realtime/realtimeupdate.css
index 56f869354..31e7c2ae6 100644
--- a/plugins/Realtime/realtimeupdate.css
+++ b/plugins/Realtime/realtimeupdate.css
@@ -18,7 +18,8 @@ display:none;
}
.realtime-popup #form_notice label[for=notice_data-attach],
-.realtime-popup #form_notice #notice_data-attach {
+.realtime-popup #form_notice #notice_data-attach,
+.realtime-popup #form_notice label[for=notice_data-geo] {
top:0;
}
diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php
index 57b3c1c99..c7f57ffc7 100644
--- a/plugins/TwitterBridge/TwitterBridgePlugin.php
+++ b/plugins/TwitterBridge/TwitterBridgePlugin.php
@@ -20,7 +20,8 @@
* @category Plugin
* @package StatusNet
* @author Zach Copley <zach@status.net>
- * @copyright 2009 Control Yourself, Inc.
+ * @author Julien C <chaumond@gmail.com>
+ * @copyright 2009-2010 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
*/
@@ -41,6 +42,7 @@ define('TWITTERBRIDGEPLUGIN_VERSION', '0.9');
* @category Plugin
* @package StatusNet
* @author Zach Copley <zach@status.net>
+ * @author Julien C <chaumond@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
* @link http://twitter.com/
@@ -72,6 +74,27 @@ class TwitterBridgePlugin extends Plugin
$m->connect('twitter/authorization',
array('action' => 'twitterauthorization'));
$m->connect('settings/twitter', array('action' => 'twittersettings'));
+ $m->connect('main/twitterlogin', array('action' => 'twitterlogin'));
+
+ return true;
+ }
+
+ /*
+ * Add a login tab for 'Sign in with Twitter'
+ *
+ * @param Action &action the current action
+ *
+ * @return void
+ */
+ function onEndLoginGroupNav(&$action)
+ {
+
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('twitterlogin'),
+ _('Twitter'),
+ _('Login or register using Twitter'),
+ 'twitterlogin' === $action_name);
return true;
}
@@ -108,6 +131,7 @@ class TwitterBridgePlugin extends Plugin
switch ($cls) {
case 'TwittersettingsAction':
case 'TwitterauthorizationAction':
+ case 'TwitterloginAction':
include_once INSTALLDIR . '/plugins/TwitterBridge/' .
strtolower(mb_substr($cls, 0, -6)) . '.php';
return false;
diff --git a/plugins/TwitterBridge/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php
index 4af2f0394..b2657ff61 100644
--- a/plugins/TwitterBridge/twitterauthorization.php
+++ b/plugins/TwitterBridge/twitterauthorization.php
@@ -19,10 +19,11 @@
* 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 TwitterauthorizationAction
+ * @category Plugin
* @package StatusNet
- * @author Zach Copely <zach@status.net>
- * @copyright 2009 StatusNet, Inc.
+ * @author Zach Copley <zach@status.net>
+ * @author Julien C <chaumond@gmail.com>
+ * @copyright 2009-2010 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/
*/
@@ -41,15 +42,21 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
* (Foreign_link) between the StatusNet user and Twitter user and stores the
* access token and secret in the link.
*
- * @category Twitter
+ * @category Plugin
* @package StatusNet
* @author Zach Copley <zach@status.net>
+ * @author Julien C <chaumond@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
*
*/
class TwitterauthorizationAction extends Action
{
+ var $twuid = null;
+ var $tw_fields = null;
+ var $access_token = null;
+ var $signin = null;
+
/**
* Initialize class members. Looks for 'oauth_token' parameter.
*
@@ -61,6 +68,7 @@ class TwitterauthorizationAction extends Action
{
parent::prepare($args);
+ $this->signin = $this->boolean('signin');
$this->oauth_token = $this->arg('oauth_token');
return true;
@@ -77,28 +85,61 @@ class TwitterauthorizationAction extends Action
{
parent::handle($args);
- if (!common_logged_in()) {
- $this->clientError(_m('Not logged in.'), 403);
+ if (common_logged_in()) {
+ $user = common_current_user();
+ $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
+
+ // If there's already a foreign link record, it means we already
+ // have an access token, and this is unecessary. So go back.
+
+ if (isset($flink)) {
+ common_redirect(common_local_url('twittersettings'));
+ }
}
- $user = common_current_user();
- $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- // If there's already a foreign link record, it means we already
- // have an access token, and this is unecessary. So go back.
+ // User was not logged in to StatusNet before
- if (isset($flink)) {
- common_redirect(common_local_url('twittersettings'));
- }
+ $this->twuid = $this->trimmed('twuid');
+
+ $this->tw_fields = array('screen_name' => $this->trimmed('tw_fields_screen_name'),
+ 'fullname' => $this->trimmed('tw_fields_fullname'));
+
+ $this->access_token = new OAuthToken($this->trimmed('access_token_key'), $this->trimmed('access_token_secret'));
+
+ $token = $this->trimmed('token');
- // $this->oauth_token is only populated once Twitter authorizes our
- // request token. If it's empty we're at the beginning of the auth
- // process
+ if (!$token || $token != common_session_token()) {
+ $this->showForm(_('There was a problem with your session token. Try again, please.'));
+ return;
+ }
- if (empty($this->oauth_token)) {
- $this->authorizeRequestToken();
+ if ($this->arg('create')) {
+ if (!$this->boolean('license')) {
+ $this->showForm(_('You can\'t register if you don\'t agree to the license.'),
+ $this->trimmed('newname'));
+ return;
+ }
+ $this->createNewUser();
+ } else if ($this->arg('connect')) {
+ $this->connectNewUser();
+ } else {
+ common_debug('Twitter Connect Plugin - ' .
+ print_r($this->args, true));
+ $this->showForm(_('Something weird happened.'),
+ $this->trimmed('newname'));
+ }
} else {
- $this->saveAccessToken();
+ // $this->oauth_token is only populated once Twitter authorizes our
+ // request token. If it's empty we're at the beginning of the auth
+ // process
+
+ if (empty($this->oauth_token)) {
+ $this->authorizeRequestToken();
+ } else {
+ $this->saveAccessToken();
+ }
}
}
@@ -123,7 +164,7 @@ class TwitterauthorizationAction extends Action
$_SESSION['twitter_request_token'] = $req_tok->key;
$_SESSION['twitter_request_token_secret'] = $req_tok->secret;
- $auth_link = $client->getAuthorizeLink($req_tok);
+ $auth_link = $client->getAuthorizeLink($req_tok, $this->signin);
} catch (OAuthClientException $e) {
$msg = sprintf('OAuth client cURL error - code: %1s, msg: %2s',
@@ -150,6 +191,8 @@ class TwitterauthorizationAction extends Action
$this->serverError(_m('Couldn\'t link your Twitter account.'));
}
+ $twitter_user = null;
+
try {
$client = new TwitterOAuthClient($_SESSION['twitter_request_token'],
@@ -165,40 +208,54 @@ class TwitterauthorizationAction extends Action
$twitter_user = $client->verifyCredentials();
} catch (OAuthClientException $e) {
- $msg = sprintf('OAuth client cURL error - code: %1$s, msg: %2$s',
+ $msg = sprintf('OAuth client error - code: %1$s, msg: %2$s',
$e->getCode(), $e->getMessage());
$this->serverError(_m('Couldn\'t link your Twitter account.'));
}
- // Save the access token and Twitter user info
+ if (common_logged_in()) {
+
+ // Save the access token and Twitter user info
+
+ $user = common_current_user();
+ $this->saveForeignLink($user->id, $twitter_user->id, $atok);
+ save_twitter_user($twitter_user->id, $twitter_user->name);
+
+ } else {
- $this->saveForeignLink($atok, $twitter_user);
+ $this->twuid = $twitter_user->id;
+ $this->tw_fields = array("screen_name" => $twitter_user->screen_name,
+ "name" => $twitter_user->name);
+ $this->access_token = $atok;
+ $this->tryLogin();
+ }
// Clean up the the mess we made in the session
unset($_SESSION['twitter_request_token']);
unset($_SESSION['twitter_request_token_secret']);
- common_redirect(common_local_url('twittersettings'));
+ if (common_logged_in()) {
+ common_redirect(common_local_url('twittersettings'));
+ }
}
/**
* Saves a Foreign_link between Twitter user and local user,
* which includes the access token and secret.
*
- * @param OAuthToken $access_token the access token to save
- * @param mixed $twitter_user twitter API user object
+ * @param int $user_id StatusNet user ID
+ * @param int $twuid Twitter user ID
+ * @param OAuthToken $token the access token to save
*
* @return nothing
*/
- function saveForeignLink($access_token, $twitter_user)
+ function saveForeignLink($user_id, $twuid, $access_token)
{
- $user = common_current_user();
-
$flink = new Foreign_link();
- $flink->user_id = $user->id;
- $flink->foreign_id = $twitter_user->id;
+ $flink->user_id = $user_id;
+ $flink->foreign_id = $twuid;
$flink->service = TWITTER_SERVICE;
$creds = TwitterOAuthClient::packToken($access_token);
@@ -214,10 +271,325 @@ class TwitterauthorizationAction extends Action
if (empty($flink_id)) {
common_log_db_error($flink, 'INSERT', __FILE__);
- $this->serverError(_m('Couldn\'t link your Twitter account.'));
+ $this->serverError(_('Couldn\'t link your Twitter account.'));
+ }
+
+ return $flink_id;
+ }
+
+ function showPageNotice()
+ {
+ if ($this->error) {
+ $this->element('div', array('class' => 'error'), $this->error);
+ } else {
+ $this->element('div', 'instructions',
+ sprintf(_('This is the first time you\'ve logged into %s so we must connect your Twitter account to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name')));
+ }
+ }
+
+ function title()
+ {
+ return _('Twitter Account Setup');
+ }
+
+ function showForm($error=null, $username=null)
+ {
+ $this->error = $error;
+ $this->username = $username;
+
+ $this->showPage();
+ }
+
+ function showPage()
+ {
+ parent::showPage();
+ }
+
+ function showContent()
+ {
+ if (!empty($this->message_text)) {
+ $this->element('p', null, $this->message);
+ return;
+ }
+
+ $this->elementStart('form', array('method' => 'post',
+ 'id' => 'form_settings_twitter_connect',
+ 'class' => 'form_settings',
+ 'action' => common_local_url('twitterauthorization')));
+ $this->elementStart('fieldset', array('id' => 'settings_twitter_connect_options'));
+ $this->element('legend', null, _('Connection options'));
+ $this->elementStart('ul', 'form_data');
+ $this->elementStart('li');
+ $this->element('input', array('type' => 'checkbox',
+ 'id' => 'license',
+ 'class' => 'checkbox',
+ 'name' => 'license',
+ 'value' => 'true'));
+ $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
+ $this->text(_('My text and files are available under '));
+ $this->element('a', array('href' => common_config('license', 'url')),
+ common_config('license', 'title'));
+ $this->text(_(' except this private data: password, email address, IM address, phone number.'));
+ $this->elementEnd('label');
+ $this->elementEnd('li');
+ $this->elementEnd('ul');
+ $this->hidden('access_token_key', $this->access_token->key);
+ $this->hidden('access_token_secret', $this->access_token->secret);
+ $this->hidden('twuid', $this->twuid);
+ $this->hidden('tw_fields_screen_name', $this->tw_fields['screen_name']);
+ $this->hidden('tw_fields_name', $this->tw_fields['name']);
+
+ $this->elementStart('fieldset');
+ $this->hidden('token', common_session_token());
+ $this->element('legend', null,
+ _('Create new account'));
+ $this->element('p', null,
+ _('Create a new user with this nickname.'));
+ $this->elementStart('ul', 'form_data');
+ $this->elementStart('li');
+ $this->input('newname', _('New nickname'),
+ ($this->username) ? $this->username : '',
+ _('1-64 lowercase letters or numbers, no punctuation or spaces'));
+ $this->elementEnd('li');
+ $this->elementEnd('ul');
+ $this->submit('create', _('Create'));
+ $this->elementEnd('fieldset');
+
+ $this->elementStart('fieldset');
+ $this->element('legend', null,
+ _('Connect existing account'));
+ $this->element('p', null,
+ _('If you already have an account, login with your username and password to connect it to your Twitter account.'));
+ $this->elementStart('ul', 'form_data');
+ $this->elementStart('li');
+ $this->input('nickname', _('Existing nickname'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->password('password', _('Password'));
+ $this->elementEnd('li');
+ $this->elementEnd('ul');
+ $this->submit('connect', _('Connect'));
+ $this->elementEnd('fieldset');
+
+ $this->elementEnd('fieldset');
+ $this->elementEnd('form');
+ }
+
+ function message($msg)
+ {
+ $this->message_text = $msg;
+ $this->showPage();
+ }
+
+ function createNewUser()
+ {
+ if (common_config('site', 'closed')) {
+ $this->clientError(_('Registration not allowed.'));
+ return;
+ }
+
+ $invite = null;
+
+ if (common_config('site', 'inviteonly')) {
+ $code = $_SESSION['invitecode'];
+ if (empty($code)) {
+ $this->clientError(_('Registration not allowed.'));
+ return;
+ }
+
+ $invite = Invitation::staticGet($code);
+
+ if (empty($invite)) {
+ $this->clientError(_('Not a valid invitation code.'));
+ return;
+ }
+ }
+
+ $nickname = $this->trimmed('newname');
+
+ if (!Validate::string($nickname, array('min_length' => 1,
+ 'max_length' => 64,
+ 'format' => NICKNAME_FMT))) {
+ $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
+ return;
+ }
+
+ if (!User::allowed_nickname($nickname)) {
+ $this->showForm(_('Nickname not allowed.'));
+ return;
+ }
+
+ if (User::staticGet('nickname', $nickname)) {
+ $this->showForm(_('Nickname already in use. Try another one.'));
+ return;
+ }
+
+ $fullname = trim($this->tw_fields['name']);
+
+ $args = array('nickname' => $nickname, 'fullname' => $fullname);
+
+ if (!empty($invite)) {
+ $args['code'] = $invite->code;
+ }
+
+ $user = User::register($args);
+
+ $result = $this->saveForeignLink($user->id,
+ $this->twuid,
+ $this->access_token);
+
+ save_twitter_user($this->twuid, $this->tw_fields['screen_name']);
+
+ if (!$result) {
+ $this->serverError(_('Error connecting user to Twitter.'));
+ return;
+ }
+
+ common_set_user($user);
+ common_real_login(true);
+
+ common_debug('TwitterBridge Plugin - ' .
+ "Registered new user $user->id from Twitter user $this->twuid");
+
+ common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
+ 303);
+ }
+
+ function connectNewUser()
+ {
+ $nickname = $this->trimmed('nickname');
+ $password = $this->trimmed('password');
+
+ if (!common_check_user($nickname, $password)) {
+ $this->showForm(_('Invalid username or password.'));
+ return;
+ }
+
+ $user = User::staticGet('nickname', $nickname);
+
+ if (!empty($user)) {
+ common_debug('TwitterBridge Plugin - ' .
+ "Legit user to connect to Twitter: $nickname");
+ }
+
+ $result = $this->saveForeignLink($user->id,
+ $this->twuid,
+ $this->access_token);
+
+ save_twitter_user($this->twuid, $this->tw_fields['screen_name']);
+
+ if (!$result) {
+ $this->serverError(_('Error connecting user to Twitter.'));
+ return;
+ }
+
+ common_debug('TwitterBridge Plugin - ' .
+ "Connected Twitter user $this->twuid to local user $user->id");
+
+ common_set_user($user);
+ common_real_login(true);
+
+ $this->goHome($user->nickname);
+ }
+
+ function connectUser()
+ {
+ $user = common_current_user();
+
+ $result = $this->flinkUser($user->id, $this->twuid);
+
+ if (empty($result)) {
+ $this->serverError(_('Error connecting user to Twitter.'));
+ return;
}
- save_twitter_user($twitter_user->id, $twitter_user->screen_name);
+ common_debug('TwitterBridge Plugin - ' .
+ "Connected Twitter user $this->twuid to local user $user->id");
+
+ // Return to Twitter connection settings tab
+ common_redirect(common_local_url('twittersettings'), 303);
+ }
+
+ function tryLogin()
+ {
+ common_debug('TwitterBridge Plugin - ' .
+ "Trying login for Twitter user $this->twuid.");
+
+ $flink = Foreign_link::getByForeignID($this->twuid,
+ TWITTER_SERVICE);
+
+ if (!empty($flink)) {
+ $user = $flink->getUser();
+
+ if (!empty($user)) {
+
+ common_debug('TwitterBridge Plugin - ' .
+ "Logged in Twitter user $flink->foreign_id as user $user->id ($user->nickname)");
+
+ common_set_user($user);
+ common_real_login(true);
+ $this->goHome($user->nickname);
+ }
+
+ } else {
+
+ common_debug('TwitterBridge Plugin - ' .
+ "No flink found for twuid: $this->twuid - new user");
+
+ $this->showForm(null, $this->bestNewNickname());
+ }
+ }
+
+ function goHome($nickname)
+ {
+ $url = common_get_returnto();
+ if ($url) {
+ // We don't have to return to it again
+ common_set_returnto(null);
+ } else {
+ $url = common_local_url('all',
+ array('nickname' =>
+ $nickname));
+ }
+
+ common_redirect($url, 303);
+ }
+
+ function bestNewNickname()
+ {
+ if (!empty($this->tw_fields['name'])) {
+ $nickname = $this->nicknamize($this->tw_fields['name']);
+ if ($this->isNewNickname($nickname)) {
+ return $nickname;
+ }
+ }
+
+ return null;
+ }
+
+ // Given a string, try to make it work as a nickname
+
+ function nicknamize($str)
+ {
+ $str = preg_replace('/\W/', '', $str);
+ $str = str_replace(array('-', '_'), '', $str);
+ return strtolower($str);
+ }
+
+ function isNewNickname($str)
+ {
+ if (!Validate::string($str, array('min_length' => 1,
+ 'max_length' => 64,
+ 'format' => NICKNAME_FMT))) {
+ return false;
+ }
+ if (!User::allowed_nickname($str)) {
+ return false;
+ }
+ if (User::staticGet('nickname', $str)) {
+ return false;
+ }
+ return true;
}
}
diff --git a/plugins/TwitterBridge/twitterlogin.php b/plugins/TwitterBridge/twitterlogin.php
new file mode 100644
index 000000000..79421fb27
--- /dev/null
+++ b/plugins/TwitterBridge/twitterlogin.php
@@ -0,0 +1,97 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * 'Sign in with Twitter' login page
+ *
+ * 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 Login
+ * @package StatusNet
+ * @author Julien Chaumond <chaumond@gmail.com>
+ * @author Zach Copley <zach@status.net>
+ * @copyright 2010 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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+
+/**
+ * Page for logging in with Twitter
+ *
+ * @category Login
+ * @package StatusNet
+ * @author Julien Chaumond <chaumond@gmail.com>
+ * @author Zach Copley <zach@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/
+ *
+ * @see SettingsAction
+ */
+
+class TwitterloginAction extends Action
+{
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (common_is_real_login()) {
+ $this->clientError(_('Already logged in.'));
+ }
+
+ $this->showPage();
+ }
+
+ function title()
+ {
+ return _('Twitter Login');
+ }
+
+ function getInstructions()
+ {
+ return _('Login with your Twitter account');
+ }
+
+ function showPageNotice()
+ {
+ $instr = $this->getInstructions();
+ $output = common_markup_to_html($instr);
+ $this->elementStart('div', 'instructions');
+ $this->raw($output);
+ $this->elementEnd('div');
+ }
+
+ function showContent()
+ {
+ $this->elementStart('a', array('href' => common_local_url('twitterauthorization',
+ null,
+ array('signin' => true))));
+ $this->element('img', array('src' => common_path('plugins/TwitterBridge/Sign-in-with-Twitter-lighter.png'),
+ 'alt' => 'Sign in with Twitter'));
+ $this->elementEnd('a');
+ }
+
+ function showLocalNav()
+ {
+ $nav = new LoginGroupNav($this);
+ $nav->show();
+ }
+}
diff --git a/plugins/TwitterBridge/twitteroauthclient.php b/plugins/TwitterBridge/twitteroauthclient.php
index bad2b74ca..277e7ab40 100644
--- a/plugins/TwitterBridge/twitteroauthclient.php
+++ b/plugins/TwitterBridge/twitteroauthclient.php
@@ -45,6 +45,7 @@ class TwitterOAuthClient extends OAuthClient
{
public static $requestTokenURL = 'https://twitter.com/oauth/request_token';
public static $authorizeURL = 'https://twitter.com/oauth/authorize';
+ public static $signinUrl = 'https://twitter.com/oauth/authenticate';
public static $accessTokenURL = 'https://twitter.com/oauth/access_token';
/**
@@ -97,9 +98,11 @@ class TwitterOAuthClient extends OAuthClient
*
* @return the link
*/
- function getAuthorizeLink($request_token)
+ function getAuthorizeLink($request_token, $signin = false)
{
- return parent::getAuthorizeLink(self::$authorizeURL,
+ $url = ($signin) ? self::$signinUrl : self::$authorizeURL;
+
+ return parent::getAuthorizeLink($url,
$request_token,
common_local_url('twitterauthorization'));
}
diff --git a/plugins/TwitterBridge/twittersettings.php b/plugins/TwitterBridge/twittersettings.php
index bc9a636a1..0137060e9 100644
--- a/plugins/TwitterBridge/twittersettings.php
+++ b/plugins/TwitterBridge/twittersettings.php
@@ -121,8 +121,35 @@ class TwittersettingsAction extends ConnectSettingsAction
$this->elementEnd('p');
$this->element('p', 'form_note',
_m('Connected Twitter account'));
+ $this->elementEnd('fieldset');
+
+ $this->elementStart('fieldset');
+
+ $this->element('legend', null, _m('Disconnect my account from Twitter'));
- $this->submit('remove', _m('Remove'));
+ if (!$user->password) {
+
+ $this->elementStart('p', array('class' => 'form_guide'));
+ $this->text(_m('Disconnecting your Twitter ' .
+ 'could make it impossible to log in! Please '));
+ $this->element('a',
+ array('href' => common_local_url('passwordsettings')),
+ _m('set a password'));
+
+ $this->text(_m(' first.'));
+ $this->elementEnd('p');
+ } else {
+
+ $note = _m('Keep your %1$s account but disconnect from Twitter. ' .
+ 'You can use your %1$s password to log in.');
+
+ $site = common_config('site', 'name');
+
+ $this->element('p', 'instructions',
+ sprintf($note, $site));
+
+ $this->submit('disconnect', _m('Disconnect'));
+ }
$this->elementEnd('fieldset');
@@ -205,7 +232,7 @@ class TwittersettingsAction extends ConnectSettingsAction
if ($this->arg('save')) {
$this->savePreferences();
- } else if ($this->arg('remove')) {
+ } else if ($this->arg('disconnect')) {
$this->removeTwitterAccount();
} else {
$this->showForm(_m('Unexpected form submission.'));
@@ -231,7 +258,7 @@ class TwittersettingsAction extends ConnectSettingsAction
return;
}
- $this->showForm(_m('Twitter account removed.'), true);
+ $this->showForm(_m('Twitter account disconnected.'), true);
}
/**