summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Adsense/AdsensePlugin.php48
-rw-r--r--plugins/Adsense/adsenseadminpanel.php223
-rw-r--r--plugins/MobileProfile/mp-screen.css6
-rw-r--r--plugins/OStatus/OStatusPlugin.php15
-rw-r--r--plugins/OStatus/actions/hostmeta.php3
-rw-r--r--plugins/OStatus/actions/ostatusgroup.php2
-rw-r--r--plugins/OStatus/lib/hubprepqueuehandler.php87
-rw-r--r--plugins/OStatus/lib/magicenvelope.php28
-rw-r--r--plugins/OStatus/lib/salmon.php4
-rw-r--r--plugins/OStatus/lib/xrd.php94
-rw-r--r--plugins/OStatus/lib/xrdaction.php5
-rw-r--r--plugins/Sitemap/SitemapPlugin.php6
-rw-r--r--plugins/Sitemap/Sitemap_notice_count.php4
-rw-r--r--plugins/Sitemap/Sitemap_user_count.php4
-rw-r--r--plugins/Sitemap/scripts/updatecounts.php36
-rw-r--r--plugins/TwitterBridge/TwitterBridgePlugin.php13
-rw-r--r--plugins/TwitterBridge/twitter.php21
-rw-r--r--plugins/TwitterBridge/twitteradminpanel.php29
18 files changed, 527 insertions, 101 deletions
diff --git a/plugins/Adsense/AdsensePlugin.php b/plugins/Adsense/AdsensePlugin.php
index ab2b9a6fb..cd6fc3503 100644
--- a/plugins/Adsense/AdsensePlugin.php
+++ b/plugins/Adsense/AdsensePlugin.php
@@ -83,6 +83,21 @@ class AdsensePlugin extends UAPPlugin
public $adScript = 'http://pagead2.googlesyndication.com/pagead/show_ads.js';
public $client = null;
+ function initialize()
+ {
+ parent::initialize();
+
+ // A little bit of chicanery so we avoid overwriting values that
+ // are passed in with the constructor
+
+ foreach (array('mediumRectangle', 'rectangle', 'leaderboard', 'wideSkyscraper', 'adScript', 'client') as $setting) {
+ $value = common_config('adsense', strtolower($setting));
+ if (!empty($value)) { // not found
+ $this->$setting = $value;
+ }
+ }
+ }
+
/**
* Show a medium rectangle 'ad'
*
@@ -157,4 +172,37 @@ class AdsensePlugin extends UAPPlugin
$action->script($this->adScript);
}
+
+ function onRouterInitialized($m)
+ {
+ $m->connect('admin/adsense',
+ array('action' => 'adsenseadminpanel'));
+
+ return true;
+ }
+
+ function onAutoload($cls)
+ {
+ $dir = dirname(__FILE__);
+
+ switch ($cls)
+ {
+ case 'AdsenseadminpanelAction':
+ require_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onEndAdminPanelNav($menu) {
+ if (AdminPanelAction::canAdmin('adsense')) {
+ // TRANS: Menu item title/tooltip
+ $menu_title = _('Adsense configuration');
+ // TRANS: Menu item for site administration
+ $menu->out->menuItem(common_local_url('adsenseadminpanel'), _('Adsense'),
+ $menu_title, $action_name == 'adsenseadminpanel', 'nav_adsense_admin_panel');
+ }
+ return true;
+ }
} \ No newline at end of file
diff --git a/plugins/Adsense/adsenseadminpanel.php b/plugins/Adsense/adsenseadminpanel.php
new file mode 100644
index 000000000..7b99cf805
--- /dev/null
+++ b/plugins/Adsense/adsenseadminpanel.php
@@ -0,0 +1,223 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Adsense administration panel
+ *
+ * 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 Adsense
+ * @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);
+}
+
+/**
+ * Administer adsense settings
+ *
+ * @category Adsense
+ * @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 AdsenseadminpanelAction extends AdminPanelAction
+{
+ /**
+ * Returns the page title
+ *
+ * @return string page title
+ */
+
+ function title()
+ {
+ return _('Adsense');
+ }
+
+ /**
+ * Instructions for using this form.
+ *
+ * @return string instructions
+ */
+
+ function getInstructions()
+ {
+ return _('Adsense settings for this StatusNet site');
+ }
+
+ /**
+ * Show the site admin panel form
+ *
+ * @return void
+ */
+
+ function showForm()
+ {
+ $form = new AdsenseAdminPanelForm($this);
+ $form->show();
+ return;
+ }
+
+ /**
+ * Save settings from the form
+ *
+ * @return void
+ */
+
+ function saveSettings()
+ {
+ static $settings = array('adsense' => array('adScript', 'client', 'mediumRectangle', 'rectangle', 'leaderboard', 'wideSkyscraper'));
+
+ $values = array();
+
+ foreach ($settings as $section => $parts) {
+ foreach ($parts as $setting) {
+ $values[$section][$setting] = $this->trimmed($setting);
+ }
+ }
+
+ // This throws an exception on validation errors
+
+ $this->validate($values);
+
+ // assert(all values are valid);
+
+ $config = new Config();
+
+ $config->query('BEGIN');
+
+ foreach ($settings as $section => $parts) {
+ foreach ($parts as $setting) {
+ Config::save($section, $setting, $values[$section][$setting]);
+ }
+ }
+
+ $config->query('COMMIT');
+
+ return;
+ }
+
+ function validate(&$values)
+ {
+ }
+}
+
+/**
+ * Form for the adsense admin panel
+ */
+
+class AdsenseAdminPanelForm extends AdminForm
+{
+ /**
+ * ID of the form
+ *
+ * @return int ID of the form
+ */
+
+ function id()
+ {
+ return 'form_adsense_admin_panel';
+ }
+
+ /**
+ * class of the form
+ *
+ * @return string class of the form
+ */
+
+ function formClass()
+ {
+ return 'form_adsense';
+ }
+
+ /**
+ * Action of the form
+ *
+ * @return string URL of the action
+ */
+
+ function action()
+ {
+ return common_local_url('adsenseadminpanel');
+ }
+
+ /**
+ * Data elements of the form
+ *
+ * @return void
+ */
+
+ function formData()
+ {
+ $this->out->elementStart('fieldset', array('id' => 'adsense_admin'));
+ $this->out->elementStart('ul', 'form_data');
+ $this->li();
+ $this->input('client',
+ _('Client ID'),
+ _('Google client ID'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('adScript',
+ _('Ad Script URL'),
+ _('Script URL (advanced)'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('mediumRectangle',
+ _('Medium rectangle'),
+ _('Medium rectangle slot code'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('rectangle',
+ _('Rectangle'),
+ _('Rectangle slot code'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('leaderboard',
+ _('Leaderboard'),
+ _('Leaderboard slot code'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('wideSkyscraper',
+ _('Skyscraper'),
+ _('Wide skyscraper slot code'),
+ 'adsense');
+ $this->unli();
+ $this->out->elementEnd('ul');
+ }
+
+ /**
+ * Action elements
+ *
+ * @return void
+ */
+
+ function formActions()
+ {
+ $this->out->submit('submit', _('Save'), 'submit', null, _('Save AdSense settings'));
+ }
+}
diff --git a/plugins/MobileProfile/mp-screen.css b/plugins/MobileProfile/mp-screen.css
index 0fc801612..1f70b5612 100644
--- a/plugins/MobileProfile/mp-screen.css
+++ b/plugins/MobileProfile/mp-screen.css
@@ -2,7 +2,7 @@
*
* @package StatusNet
* @author Sarven Capadisli <csarven@status.net>
- * @copyright 2009 StatusNet, Inc.
+ * @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/
*/
@@ -195,10 +195,6 @@ width:43px;
margin-right:1%;
}
-.notice-options form {
-width:16px;
-height:16px;
-}
.notice-options form.processing {
background-image:none;
}
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index c61e2cc5f..70971c5b3 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -158,6 +158,9 @@ class OStatusPlugin extends Plugin
// Also, we'll add in the salmon link
$salmon = common_local_url($salmonAction, array('id' => $id));
+ $feed->addLink($salmon, array('rel' => Salmon::REL_SALMON));
+
+ // XXX: these are deprecated
$feed->addLink($salmon, array('rel' => Salmon::NS_REPLIES));
$feed->addLink($salmon, array('rel' => Salmon::NS_MENTIONS));
}
@@ -953,4 +956,16 @@ class OStatusPlugin extends Plugin
}
return false;
}
+
+ public function onStartProfileGetAtomFeed($profile, &$feed)
+ {
+ $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
+
+ if (empty($oprofile)) {
+ return true;
+ }
+
+ $feed = $oprofile->feeduri;
+ return false;
+ }
}
diff --git a/plugins/OStatus/actions/hostmeta.php b/plugins/OStatus/actions/hostmeta.php
index 6d35ada6c..8ca07f916 100644
--- a/plugins/OStatus/actions/hostmeta.php
+++ b/plugins/OStatus/actions/hostmeta.php
@@ -36,13 +36,12 @@ class HostMetaAction extends Action
$url.= '?uri={uri}';
$xrd = new XRD();
-
- $xrd = new XRD();
$xrd->host = $domain;
$xrd->links[] = array('rel' => Discovery::LRDD_REL,
'template' => $url,
'title' => array('Resource Descriptor'));
+ header('Content-type: application/xrd+xml');
print $xrd->toXML();
}
}
diff --git a/plugins/OStatus/actions/ostatusgroup.php b/plugins/OStatus/actions/ostatusgroup.php
index f325ba053..1b368de63 100644
--- a/plugins/OStatus/actions/ostatusgroup.php
+++ b/plugins/OStatus/actions/ostatusgroup.php
@@ -104,7 +104,7 @@ class OStatusGroupAction extends OStatusSubAction
}
$this->showEntity($group,
- $group->getProfileUrl(),
+ $group->homeUrl(),
$group->homepage_logo,
$group->description);
return $ok;
diff --git a/plugins/OStatus/lib/hubprepqueuehandler.php b/plugins/OStatus/lib/hubprepqueuehandler.php
new file mode 100644
index 000000000..0d585938f
--- /dev/null
+++ b/plugins/OStatus/lib/hubprepqueuehandler.php
@@ -0,0 +1,87 @@
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2010, StatusNet, Inc.
+ *
+ * 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/>.
+ */
+
+/**
+ * When we have a large batch of PuSH consumers, we break the data set
+ * into smaller chunks. Enqueue final destinations...
+ *
+ * @package Hub
+ * @author Brion Vibber <brion@status.net>
+ */
+class HubPrepQueueHandler extends QueueHandler
+{
+ // Enqueue this many low-level distributions before re-queueing the rest
+ // of the batch to be processed later. Helps to keep latency down for other
+ // things happening during a particularly long OStatus delivery session.
+ //
+ // [Could probably ditch this if we had working message delivery priorities
+ // for queueing, but this isn't supported in ActiveMQ 5.3.]
+ const ROLLING_BATCH = 20;
+
+ function transport()
+ {
+ return 'hubprep';
+ }
+
+ function handle($data)
+ {
+ $topic = $data['topic'];
+ $atom = $data['atom'];
+ $pushCallbacks = $data['pushCallbacks'];
+
+ assert(is_string($atom));
+ assert(is_string($topic));
+ assert(is_array($pushCallbacks));
+
+ // Set up distribution for the first n subscribing sites...
+ // If we encounter an uncatchable error, queue handling should
+ // automatically re-run the batch, which could lead to some dupe
+ // distributions.
+ //
+ // Worst case is if one of these hubprep entries dies too many
+ // times and gets dropped; the rest of the batch won't get processed.
+ try {
+ $n = 0;
+ while (count($pushCallbacks) && $n < self::ROLLING_BATCH) {
+ $n++;
+ $callback = array_shift($pushCallbacks);
+ $sub = HubSub::staticGet($topic, $callback);
+ if (!$sub) {
+ common_log(LOG_ERR, "Skipping PuSH delivery for deleted(?) consumer $callback on $topic");
+ continue;
+ }
+
+ $sub->distribute($atom);
+ }
+ } catch (Exception $e) {
+ common_log(LOG_ERR, "Exception during PuSH batch out: " .
+ $e->getMessage() .
+ " prepping $topic to $callback");
+ }
+
+ // And re-queue the rest of the batch!
+ if (count($pushCallbacks) > 0) {
+ $sub = new HubSub();
+ $sub->topic = $topic;
+ $sub->bulkDistribute($atom, $pushCallbacks);
+ }
+
+ return true;
+ }
+}
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php
index f39686b71..3bdf24b31 100644
--- a/plugins/OStatus/lib/magicenvelope.php
+++ b/plugins/OStatus/lib/magicenvelope.php
@@ -97,24 +97,18 @@ class MagicEnvelope
}
public function toXML($env) {
- $dom = new DOMDocument();
-
- $envelope = $dom->createElementNS(MagicEnvelope::NS, 'me:env');
- $envelope->setAttribute('xmlns:me', MagicEnvelope::NS);
- $data = $dom->createElementNS(MagicEnvelope::NS, 'me:data', $env['data']);
- $data->setAttribute('type', $env['data_type']);
- $envelope->appendChild($data);
- $enc = $dom->createElementNS(MagicEnvelope::NS, 'me:encoding', $env['encoding']);
- $envelope->appendChild($enc);
- $alg = $dom->createElementNS(MagicEnvelope::NS, 'me:alg', $env['alg']);
- $envelope->appendChild($alg);
- $sig = $dom->createElementNS(MagicEnvelope::NS, 'me:sig', $env['sig']);
- $envelope->appendChild($sig);
-
- $dom->appendChild($envelope);
+ $xs = new XMLStringer();
+ $xs->startXML();
+ $xs->elementStart('me:env', array('xmlns:me' => MagicEnvelope::NS));
+ $xs->element('me:data', array('type' => $env['data_type']), $env['data']);
+ $xs->element('me:encoding', null, $env['encoding']);
+ $xs->element('me:alg', null, $env['alg']);
+ $xs->element('me:sig', null, $env['sig']);
+ $xs->elementEnd('me:env');
-
- return $dom->saveXML();
+ $string = $xs->getString();
+ common_debug($string);
+ return $string;
}
diff --git a/plugins/OStatus/lib/salmon.php b/plugins/OStatus/lib/salmon.php
index 3d3341bc6..ef7719a40 100644
--- a/plugins/OStatus/lib/salmon.php
+++ b/plugins/OStatus/lib/salmon.php
@@ -28,9 +28,11 @@
*/
class Salmon
{
+ const REL_SALMON = 'salmon';
+ const REL_MENTIONED = 'mentioned';
+ // XXX: these are deprecated
const NS_REPLIES = "http://salmon-protocol.org/ns/salmon-replies";
-
const NS_MENTIONS = "http://salmon-protocol.org/ns/salmon-mention";
/**
diff --git a/plugins/OStatus/lib/xrd.php b/plugins/OStatus/lib/xrd.php
index 34b28790b..a10b9f427 100644
--- a/plugins/OStatus/lib/xrd.php
+++ b/plugins/OStatus/lib/xrd.php
@@ -106,44 +106,43 @@ class XRD
public function toXML()
{
- $dom = new DOMDocument('1.0', 'UTF-8');
- $dom->formatOutput = true;
-
- $xrd_dom = $dom->createElementNS(XRD::XRD_NS, 'XRD');
- $dom->appendChild($xrd_dom);
+ $xs = new XMLStringer();
+
+ $xs->startXML();
+ $xs->elementStart('XRD', array('xmlns' => XRD::XRD_NS));
if ($this->host) {
- $host_dom = $dom->createElement('hm:Host', $this->host);
- $xrd_dom->setAttributeNS(XRD::XML_NS, 'xmlns:hm', XRD::HOST_META_NS);
- $xrd_dom->appendChild($host_dom);
+ $xs->element('hm:Host', array('xmlns:hm' => XRD::HOST_META_NS), $this->host);
}
- if ($this->expires) {
- $expires_dom = $dom->createElement('Expires', $this->expires);
- $xrd_dom->appendChild($expires_dom);
- }
-
- if ($this->subject) {
- $subject_dom = $dom->createElement('Subject', $this->subject);
- $xrd_dom->appendChild($subject_dom);
- }
-
- foreach ($this->alias as $alias) {
- $alias_dom = $dom->createElement('Alias', $alias);
- $xrd_dom->appendChild($alias_dom);
- }
-
- foreach ($this->types as $type) {
- $type_dom = $dom->createElement('Type', $type);
- $xrd_dom->appendChild($type_dom);
- }
-
- foreach ($this->links as $link) {
- $link_dom = $this->saveLink($dom, $link);
- $xrd_dom->appendChild($link_dom);
- }
-
- return $dom->saveXML();
+ if ($this->expires) {
+ $xs->element('Expires', null, $this->expires);
+ }
+
+ if ($this->subject) {
+ $xs->element('Subject', null, $this->subject);
+ }
+
+ foreach ($this->alias as $alias) {
+ $xs->element('Alias', null, $alias);
+ }
+
+ foreach ($this->links as $link) {
+ $titles = array();
+ if (isset($link['title'])) {
+ $titles = $link['title'];
+ unset($link['title']);
+ }
+ $xs->elementStart('Link', $link);
+ foreach ($titles as $title) {
+ $xs->element('Title', null, $title);
+ }
+ $xs->elementEnd('Link');
+ }
+
+ $xs->elementEnd('XRD');
+
+ return $xs->getString();
}
function parseType($element)
@@ -169,32 +168,5 @@ class XRD
return $link;
}
-
- function saveLink($doc, $link)
- {
- $link_element = $doc->createElement('Link');
- if (!empty($link['rel'])) {
- $link_element->setAttribute('rel', $link['rel']);
- }
- if (!empty($link['type'])) {
- $link_element->setAttribute('type', $link['type']);
- }
- if (!empty($link['href'])) {
- $link_element->setAttribute('href', $link['href']);
- }
- if (!empty($link['template'])) {
- $link_element->setAttribute('template', $link['template']);
- }
-
- if (!empty($link['title']) && is_array($link['title'])) {
- foreach($link['title'] as $title) {
- $title = $doc->createElement('Title', $title);
- $link_element->appendChild($title);
- }
- }
-
-
- return $link_element;
- }
}
diff --git a/plugins/OStatus/lib/xrdaction.php b/plugins/OStatus/lib/xrdaction.php
index f1a56e0a8..d8cf648d6 100644
--- a/plugins/OStatus/lib/xrdaction.php
+++ b/plugins/OStatus/lib/xrdaction.php
@@ -76,6 +76,9 @@ class XrdAction extends Action
$salmon_url = common_local_url('usersalmon',
array('id' => $this->user->id));
+ $xrd->links[] = array('rel' => Salmon::REL_SALMON,
+ 'href' => $salmon_url);
+ // XXX : Deprecated - to be removed.
$xrd->links[] = array('rel' => Salmon::NS_REPLIES,
'href' => $salmon_url);
@@ -98,7 +101,7 @@ class XrdAction extends Action
$xrd->links[] = array('rel' => 'http://ostatus.org/schema/1.0/subscribe',
'template' => $url );
- header('Content-type: text/xml');
+ header('Content-type: application/xrd+xml');
print $xrd->toXML();
}
diff --git a/plugins/Sitemap/SitemapPlugin.php b/plugins/Sitemap/SitemapPlugin.php
index d4d295237..b6d3b1ad3 100644
--- a/plugins/Sitemap/SitemapPlugin.php
+++ b/plugins/Sitemap/SitemapPlugin.php
@@ -202,6 +202,12 @@ class SitemapPlugin extends Plugin
null, false),
new ColumnDef('modified', 'timestamp')));
+ $userCreated = $schema->getColumnDef('user', 'created');
+
+ if (empty($userCreated) || $userCreated->key != 'MUL') {
+ $schema->createIndex('user', 'created');
+ }
+
return true;
}
diff --git a/plugins/Sitemap/Sitemap_notice_count.php b/plugins/Sitemap/Sitemap_notice_count.php
index 2a375b3e4..6e0061e97 100644
--- a/plugins/Sitemap/Sitemap_notice_count.php
+++ b/plugins/Sitemap/Sitemap_notice_count.php
@@ -153,7 +153,9 @@ class Sitemap_notice_count extends Memcached_DataObject
$noticeCounts[$snc->notice_date] = $snc->notice_count;
}
- self::cacheSet('sitemap:notice:counts', $noticeCounts);
+ // Cache notice counts for 4 hours.
+
+ self::cacheSet('sitemap:notice:counts', $noticeCounts, null, time() + 4 * 60 * 60);
}
return $noticeCounts;
diff --git a/plugins/Sitemap/Sitemap_user_count.php b/plugins/Sitemap/Sitemap_user_count.php
index 64b4c3442..98dd05bfe 100644
--- a/plugins/Sitemap/Sitemap_user_count.php
+++ b/plugins/Sitemap/Sitemap_user_count.php
@@ -154,7 +154,9 @@ class Sitemap_user_count extends Memcached_DataObject
$userCounts[$suc->registration_date] = $suc->user_count;
}
- self::cacheSet('sitemap:user:counts', $userCounts);
+ // Cache user counts for 4 hours.
+
+ self::cacheSet('sitemap:user:counts', $userCounts, null, time() + 4 * 60 * 60);
}
return $userCounts;
diff --git a/plugins/Sitemap/scripts/updatecounts.php b/plugins/Sitemap/scripts/updatecounts.php
new file mode 100644
index 000000000..91bc0ac4e
--- /dev/null
+++ b/plugins/Sitemap/scripts/updatecounts.php
@@ -0,0 +1,36 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2010, StatusNet, Inc.
+ *
+ * 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/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
+
+$helptext = <<<END_OF_UPDATECOUNTS_HELP
+updatecounts.php [options]
+Update the notice and user counts cached in the database.
+
+END_OF_UPDATECOUNTS_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+// Will fill the cache
+
+$userCounts = Sitemap_user_count::getAll();
+$noticeCounts = Sitemap_notice_count::getAll();
+
+echo "Done.\n";
diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php
index 65b3a6b38..0505a328f 100644
--- a/plugins/TwitterBridge/TwitterBridgePlugin.php
+++ b/plugins/TwitterBridge/TwitterBridgePlugin.php
@@ -50,6 +50,7 @@ class TwitterBridgePlugin extends Plugin
{
const VERSION = STATUSNET_VERSION;
+ public $adminImportControl = false; // Should the 'import' checkbox be exposed in the admin panel?
/**
* Initializer for the plugin.
@@ -322,5 +323,17 @@ class TwitterBridgePlugin extends Plugin
return true;
}
+ /**
+ * Expose the adminImportControl setting to the administration panel code.
+ * This allows us to disable the import bridge enabling checkbox for administrators,
+ * since on a bulk farm site we can't yet automate the import daemon setup.
+ *
+ * @return boolean hook value;
+ */
+ function onTwitterBridgeAdminImportControl()
+ {
+ return (bool)$this->adminImportControl;
+ }
+
}
diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php
index 896eee2da..306ba2442 100644
--- a/plugins/TwitterBridge/twitter.php
+++ b/plugins/TwitterBridge/twitter.php
@@ -75,8 +75,6 @@ function save_twitter_user($twitter_id, $screen_name)
if (!empty($fuser)) {
- $result = true;
-
// Delete old record if Twitter user changed screen name
if ($fuser->nickname != $screen_name) {
@@ -88,6 +86,25 @@ function save_twitter_user($twitter_id, $screen_name)
$screen_name,
$oldname));
}
+
+ } else {
+
+ // Kill any old, invalid records for this screen name
+
+ $fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE);
+
+ if (!empty($fuser)) {
+ $fuser->delete();
+ common_log(
+ LOG_INFO,
+ sprintf(
+ 'Twitter bridge - deteted old record for Twitter ' .
+ 'screen name "%s" belonging to Twitter ID %d.',
+ $screen_name,
+ $fuser->id
+ )
+ );
+ }
}
return add_twitter_user($twitter_id, $screen_name);
diff --git a/plugins/TwitterBridge/twitteradminpanel.php b/plugins/TwitterBridge/twitteradminpanel.php
index a78a92c66..69f8da078 100644
--- a/plugins/TwitterBridge/twitteradminpanel.php
+++ b/plugins/TwitterBridge/twitteradminpanel.php
@@ -92,9 +92,11 @@ class TwitteradminpanelAction extends AdminPanelAction
);
static $booleans = array(
- 'twitter' => array('signin'),
- 'twitterimport' => array('enabled')
+ 'twitter' => array('signin')
);
+ if (Event::handle('TwitterBridgeAdminImportControl')) {
+ $booleans['twitterimport'] = array('enabled');
+ }
$values = array();
@@ -155,6 +157,13 @@ class TwitteradminpanelAction extends AdminPanelAction
);
}
}
+
+ function isImportEnabled()
+ {
+ // Since daemon setup isn't automated yet...
+ // @todo: if merged into main queues, detect presence of daemon config
+ return true;
+ }
}
class TwitterAdminPanelForm extends AdminForm
@@ -263,13 +272,15 @@ class TwitterAdminPanelForm extends AdminForm
);
$this->unli();
- $this->li();
- $this->out->checkbox(
- 'enabled', _m('Enable Twitter import'),
- (bool) $this->value('enabled', 'twitterimport'),
- _m('Allow users to import their Twitter friends\' timelines')
- );
- $this->unli();
+ if (Event::handle('TwitterBridgeAdminImportControl')) {
+ $this->li();
+ $this->out->checkbox(
+ 'enabled', _m('Enable Twitter import'),
+ (bool) $this->value('enabled', 'twitterimport'),
+ _m('Allow users to import their Twitter friends\' timelines. Requires daemons to be manually configured.')
+ );
+ $this->unli();
+ }
$this->out->elementEnd('ul');