summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/apiblockcreate.php11
-rw-r--r--classes/User.php24
-rw-r--r--lib/api.php10
-rw-r--r--lib/htmloutputter.php20
-rw-r--r--lib/plugin.php10
-rw-r--r--lib/subs.php6
-rw-r--r--plugins/GeonamesPlugin.php80
-rw-r--r--plugins/Mapstraction/MapstractionPlugin.php78
-rw-r--r--plugins/Mapstraction/allmap.php68
-rw-r--r--plugins/Mapstraction/map.php167
-rw-r--r--plugins/Mapstraction/usermap.js87
-rw-r--r--plugins/Mapstraction/usermap.php68
-rw-r--r--plugins/Realtime/RealtimePlugin.php9
-rw-r--r--plugins/TwitterBridge/TwitterBridgePlugin.php7
-rwxr-xr-xplugins/TwitterBridge/daemons/twitterstatusfetcher.php20
-rw-r--r--plugins/UserFlag/UserFlagPlugin.php2
16 files changed, 382 insertions, 285 deletions
diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php
index 4f941f6c3..e79dec32d 100644
--- a/actions/apiblockcreate.php
+++ b/actions/apiblockcreate.php
@@ -98,6 +98,17 @@ class ApiBlockCreateAction extends ApiAuthAction
return;
}
+ // Don't allow blocking yourself!
+
+ if ($this->user->id == $this->other->id) {
+ $this->clientError(
+ _("You cannot block yourself!"),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
if ($this->user->hasBlocked($this->other)
|| $this->user->block($this->other)
) {
diff --git a/classes/User.php b/classes/User.php
index f905ea2b7..2a4fab7d4 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -502,6 +502,19 @@ class User extends Memcached_DataObject
{
// Add a new block record
+ // no blocking (and thus unsubbing from) yourself
+
+ if ($this->id == $other->id) {
+ common_log(LOG_WARNING,
+ sprintf(
+ "Profile ID %d (%s) tried to block his or herself.",
+ $profile->id,
+ $profile->nickname
+ )
+ );
+ return false;
+ }
+
$block = new Profile_block();
// Begin a transaction
@@ -520,16 +533,7 @@ class User extends Memcached_DataObject
// Cancel their subscription, if it exists
- $sub = Subscription::pkeyGet(array('subscriber' => $other->id,
- 'subscribed' => $this->id));
-
- if ($sub) {
- $result = $sub->delete();
- if (!$result) {
- common_log_db_error($sub, 'DELETE', __FILE__);
- return false;
- }
- }
+ subs_unsubscribe_to($other->getUser(),$this->getProfile());
$block->query('COMMIT');
diff --git a/lib/api.php b/lib/api.php
index 5a3bb5ee4..eacb80dbe 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -134,19 +134,17 @@ class ApiAction extends Action
$twitter_user['protected'] = false; # not supported by StatusNet yet
$twitter_user['followers_count'] = $profile->subscriberCount();
- $design = null;
$user = $profile->getUser();
+ $design = null;
// Note: some profiles don't have an associated user
+ $defaultDesign = Design::siteDesign();
+
if (!empty($user)) {
$design = $user->getDesign();
}
- if (empty($design)) {
- $design = Design::siteDesign();
- }
-
$color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
$twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue();
$color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor);
@@ -165,7 +163,7 @@ class ApiAction extends Action
$timezone = 'UTC';
- if ($user->timezone) {
+ if (!empty($user) && !empty($user->timezone)) {
$timezone = $user->timezone;
}
diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php
index a7c596917..a0066594f 100644
--- a/lib/htmloutputter.php
+++ b/lib/htmloutputter.php
@@ -364,6 +364,25 @@ class HTMLOutputter extends XMLOutputter
}
/**
+ * output a script (almost always javascript) tag with inline
+ * code.
+ *
+ * @param string $code relative or absolute script path
+ * @param string $type 'type' attribute value of the tag
+ *
+ * @return void
+ */
+
+ function inlineScript($code, $type='text/javascript')
+ {
+ $this->elementStart('script', array('type' => $type));
+ $this->raw('/*<![CDATA[*/ '); // XHTML compat for Safari
+ $this->raw($code);
+ $this->raw(' /*]]>*/'); // XHTML compat for Safari
+ $this->elementEnd('script');
+ }
+
+ /**
* output a css link
*
* @param string $src relative path within the theme directory, or an absolute path
@@ -420,7 +439,6 @@ class HTMLOutputter extends XMLOutputter
}
}
-
/**
* Internal script to autofocus the given element on page onload.
*
diff --git a/lib/plugin.php b/lib/plugin.php
index 87d7be5a7..2c77c3e12 100644
--- a/lib/plugin.php
+++ b/lib/plugin.php
@@ -76,4 +76,14 @@ class Plugin
{
return true;
}
+
+ protected function log($level, $msg)
+ {
+ common_log($level, get_class($this) . ': '.$msg);
+ }
+
+ protected function debug($msg)
+ {
+ $this->log(LOG_DEBUG, $msg);
+ }
}
diff --git a/lib/subs.php b/lib/subs.php
index 2fc3160de..4b6b03967 100644
--- a/lib/subs.php
+++ b/lib/subs.php
@@ -127,6 +127,12 @@ function subs_unsubscribe_to($user, $other)
if (!$user->isSubscribed($other))
return _('Not subscribed!');
+ // Don't allow deleting self subs
+
+ if ($user->id == $other->id) {
+ return _('Couldn\'t delete self-subscription.');
+ }
+
$sub = DB_DataObject::factory('subscription');
$sub->subscriber = $user->id;
diff --git a/plugins/GeonamesPlugin.php b/plugins/GeonamesPlugin.php
index 340a6f0bf..a750f1242 100644
--- a/plugins/GeonamesPlugin.php
+++ b/plugins/GeonamesPlugin.php
@@ -51,6 +51,11 @@ class GeonamesPlugin extends Plugin
{
const LOCATION_NS = 1;
+ public $host = 'ws.geonames.org';
+ public $username = null;
+ public $token = null;
+ public $expiry = 7776000; // 90-day expiry
+
/**
* convert a name into a Location object
*
@@ -75,12 +80,11 @@ class GeonamesPlugin extends Plugin
// XXX: break down a name by commas, narrow by each
- $str = http_build_query(array('maxRows' => 1,
- 'q' => $name,
- 'lang' => $language,
- 'type' => 'json'));
-
- $result = $client->get('http://ws.geonames.org/search?'.$str);
+ $result = $client->get($this->wsUrl('search',
+ array('maxRows' => 1,
+ 'q' => $name,
+ 'lang' => $language,
+ 'type' => 'json')));
if ($result->isOk()) {
$rj = json_decode($result->getBody());
@@ -135,10 +139,9 @@ class GeonamesPlugin extends Plugin
$client = HTTPClient::start();
- $str = http_build_query(array('geonameId' => $id,
- 'lang' => $language));
-
- $result = $client->get('http://ws.geonames.org/hierarchyJSON?'.$str);
+ $result = $client->get($this->wsUrl('hierarchyJSON',
+ array('geonameId' => $id,
+ 'lang' => $language)));
if ($result->isOk()) {
@@ -195,6 +198,9 @@ class GeonamesPlugin extends Plugin
function onLocationFromLatLon($lat, $lon, $language, &$location)
{
+ $lat = rtrim($lat, "0");
+ $lon = rtrim($lon, "0");
+
$loc = $this->getCache(array('lat' => $lat,
'lon' => $lon));
@@ -205,12 +211,11 @@ class GeonamesPlugin extends Plugin
$client = HTTPClient::start();
- $str = http_build_query(array('lat' => $lat,
- 'lng' => $lon,
- 'lang' => $language));
-
$result =
- $client->get('http://ws.geonames.org/findNearbyPlaceNameJSON?'.$str);
+ $client->get($this->wsUrl('findNearbyPlaceNameJSON',
+ array('lat' => $lat,
+ 'lng' => $lon,
+ 'lang' => $language)));
if ($result->isOk()) {
@@ -286,10 +291,9 @@ class GeonamesPlugin extends Plugin
$client = HTTPClient::start();
- $str = http_build_query(array('geonameId' => $location->location_id,
- 'lang' => $language));
-
- $result = $client->get('http://ws.geonames.org/hierarchyJSON?'.$str);
+ $result = $client->get($this->wsUrl('hierarchyJSON',
+ array('geonameId' => $location->location_id,
+ 'lang' => $language)));
if ($result->isOk()) {
@@ -376,33 +380,30 @@ class GeonamesPlugin extends Plugin
{
$c = common_memcache();
- if (!$c) {
+ if (empty($c)) {
return null;
}
- return $c->get($this->cacheKey($attrs));
+ $key = $this->cacheKey($attrs);
+
+ $value = $c->get($key);
+
+ return $value;
}
function setCache($attrs, $loc)
{
$c = common_memcache();
- if (!$c) {
+ if (empty($c)) {
return null;
}
- $c->set($this->cacheKey($attrs), $loc);
- }
-
- function clearCache($attrs)
- {
- $c = common_memcache();
+ $key = $this->cacheKey($attrs);
- if (!$c) {
- return null;
- }
+ $result = $c->set($key, $loc, 0, time() + $this->expiry);
- $c->delete($this->cacheKey($attrs));
+ return $result;
}
function cacheKey($attrs)
@@ -411,4 +412,19 @@ class GeonamesPlugin extends Plugin
implode(',', array_keys($attrs)) . ':'.
common_keyize(implode(',', array_values($attrs))));
}
+
+ function wsUrl($method, $params)
+ {
+ if (!empty($this->username)) {
+ $params['username'] = $this->username;
+ }
+
+ if (!empty($this->token)) {
+ $params['token'] = $this->token;
+ }
+
+ $str = http_build_query($params);
+
+ return 'http://'.$this->host.'/'.$method.'?'.$str;
+ }
}
diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php
index c0c2c5b8e..f20e81b0e 100644
--- a/plugins/Mapstraction/MapstractionPlugin.php
+++ b/plugins/Mapstraction/MapstractionPlugin.php
@@ -90,6 +90,7 @@ class MapstractionPlugin extends Plugin
{
case 'AllmapAction':
case 'UsermapAction':
+ case 'MapAction':
include_once INSTALLDIR.'/plugins/Mapstraction/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
return false;
default:
@@ -110,9 +111,9 @@ class MapstractionPlugin extends Plugin
function onEndShowScripts($action)
{
$actionName = $action->trimmed('action');
- // These are the ones that have maps on 'em
+
if (!in_array($actionName,
- array('showstream', 'all', 'allmap', 'usermap'))) {
+ array('showstream', 'all', 'usermap', 'allmap'))) {
return true;
}
@@ -147,43 +148,20 @@ class MapstractionPlugin extends Plugin
$action->script(common_path('plugins/Mapstraction/usermap.js'));
- $action->elementStart('script', array('type' => 'text/javascript'));
- $action->raw(sprintf('var _provider = "%s";', $this->provider));
- $action->elementEnd('script');
+ $action->inlineScript(sprintf('var _provider = "%s";', $this->provider));
- switch ($actionName) {
- case 'usermap':
- case 'showstream':
- $notice = empty($action->tag)
- ? $action->user->getNotices(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
- : $action->user->getTaggedNotices($action->tag, ($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
- break;
- case 'all':
- case 'allmap':
- $cur = common_current_user();
- if (!empty($cur) && $cur->id == $action->user->id) {
- $notice = $action->user->noticeInbox(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
- } else {
- $notice = $action->user->noticesWithFriends(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
- }
- break;
- }
-
- $jsonArray = array();
+ // usermap and allmap handle this themselves
- while ($notice->fetch()) {
- if (!empty($notice->lat) && !empty($notice->lon)) {
- $jsonNotice = $this->noticeAsJson($notice);
- $jsonArray[] = $jsonNotice;
- }
+ if (in_array($actionName,
+ array('showstream', 'all'))) {
+ $action->inlineScript('$(document).ready(function() { '.
+ ' var user = null; '.
+ (($actionName == 'showstream') ? ' user = scrapeUser(); ' : '') .
+ ' var notices = scrapeNotices(user); ' .
+ ' showMapstraction($("#map_canvas"), notices); '.
+ '});');
}
- $action->elementStart('script', array('type' => 'text/javascript'));
- $action->raw('/*<![CDATA[*/'); // XHTML compat for Safari
- $action->raw('var _notices = ' . json_encode($jsonArray));
- $action->raw('/*]]>*/'); // XHTML compat for Safari
- $action->elementEnd('script');
-
return true;
}
@@ -214,34 +192,4 @@ class MapstractionPlugin extends Plugin
$action->elementEnd('div');
}
-
- function noticeAsJson($notice)
- {
- // FIXME: this code should be abstracted to a neutral third
- // party, like Notice::asJson(). I'm not sure of the ethics
- // of refactoring from within a plugin, so I'm just abusing
- // the ApiAction method. Don't do this unless you're me!
-
- require_once(INSTALLDIR.'/lib/api.php');
-
- $act = new ApiAction('/dev/null');
-
- $arr = $act->twitterStatusArray($notice, true);
- $arr['url'] = $notice->bestUrl();
- $arr['html'] = $notice->rendered;
- $arr['source'] = $arr['source'];
-
- if (!empty($notice->reply_to)) {
- $reply_to = Notice::staticGet('id', $notice->reply_to);
- if (!empty($reply_to)) {
- $arr['in_reply_to_status_url'] = $reply_to->bestUrl();
- }
- $reply_to = null;
- }
-
- $profile = $notice->getProfile();
- $arr['user']['profile_url'] = $profile->profileurl;
-
- return $arr;
- }
}
diff --git a/plugins/Mapstraction/allmap.php b/plugins/Mapstraction/allmap.php
index 6a48b141f..0c4f03b31 100644
--- a/plugins/Mapstraction/allmap.php
+++ b/plugins/Mapstraction/allmap.php
@@ -37,59 +37,26 @@ if (!defined('STATUSNET')) {
* @category Mapstraction
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-class AllmapAction extends OwnerDesignAction
+class AllmapAction extends MapAction
{
- var $profile = null;
- var $page = null;
- var $notices = null;
-
- public $plugin = null;
-
function prepare($args)
{
- parent::prepare($args);
-
- $nickname_arg = $this->arg('nickname');
- $nickname = common_canonical_nickname($nickname_arg);
-
- // Permanent redirect on non-canonical nickname
-
- if ($nickname_arg != $nickname) {
- $args = array('nickname' => $nickname);
- if ($this->arg('page') && $this->arg('page') != 1) {
- $args['page'] = $this->arg['page'];
+ if(parent::prepare($args)) {
+ $cur = common_current_user();
+ if (!empty($cur) && $cur->id == $this->user->id) {
+ $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+ } else {
+ $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
}
- common_redirect(common_local_url($this->trimmed('action'), $args), 301);
- return false;
- }
-
- $this->user = User::staticGet('nickname', $nickname);
-
- if (!$this->user) {
- $this->clientError(_('No such user.'), 404);
- return false;
- }
-
- $this->profile = $this->user->getProfile();
-
- if (!$this->profile) {
- $this->serverError(_('User has no profile.'));
+ return true;
+ }else{
return false;
}
-
- $page = $this->trimmed('page');
-
- if (!empty($page) && Validate::number($page)) {
- $this->page = $page+0;
- } else {
- $this->page = 1;
- }
-
- return true;
}
function title()
@@ -109,17 +76,4 @@ class AllmapAction extends OwnerDesignAction
$this->page);
}
}
-
- function handle($args)
- {
- parent::handle($args);
- $this->showPage();
- }
-
- function showContent()
- {
- $this->element('div', array('id' => 'map_canvas',
- 'class' => 'gray smallmap',
- 'style' => "width: 100%; height: 400px"));
- }
-} \ No newline at end of file
+}
diff --git a/plugins/Mapstraction/map.php b/plugins/Mapstraction/map.php
new file mode 100644
index 000000000..734e48088
--- /dev/null
+++ b/plugins/Mapstraction/map.php
@@ -0,0 +1,167 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a map of user's notices
+ *
+ * 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 Mapstraction
+ * @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);
+}
+
+/**
+ * Show a map of notices
+ *
+ * @category Mapstraction
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class MapAction extends OwnerDesignAction
+{
+ var $profile = null;
+ var $page = null;
+ var $notices = null;
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $nickname_arg = $this->arg('nickname');
+ $nickname = common_canonical_nickname($nickname_arg);
+
+ // Permanent redirect on non-canonical nickname
+
+ if ($nickname_arg != $nickname) {
+ $args = array('nickname' => $nickname);
+ if ($this->arg('page') && $this->arg('page') != 1) {
+ $args['page'] = $this->arg['page'];
+ }
+ common_redirect(common_local_url($this->trimmed('action'), $args), 301);
+ return false;
+ }
+
+ $this->user = User::staticGet('nickname', $nickname);
+
+ if (!$this->user) {
+ $this->clientError(_('No such user.'), 404);
+ return false;
+ }
+
+ $this->profile = $this->user->getProfile();
+
+ if (!$this->profile) {
+ $this->serverError(_('User has no profile.'));
+ return false;
+ }
+
+ $page = $this->trimmed('page');
+
+ if (!empty($page) && Validate::number($page)) {
+ $this->page = $page+0;
+ } else {
+ $this->page = 1;
+ }
+
+ $this->notices = empty($this->tag)
+ ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
+ : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
+
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showPage();
+ }
+
+ function showContent()
+ {
+ $this->element('div', array('id' => 'map_canvas',
+ 'class' => 'gray smallmap',
+ 'style' => "width: 100%; height: 400px"));
+ }
+
+ /**
+ * Hook for adding extra JavaScript
+ *
+ * @param Action $action Action object for the page
+ *
+ * @return boolean event handler return
+ */
+
+ function showScripts()
+ {
+ parent::showScripts();
+ $jsonArray = array();
+
+ while ($this->notice->fetch()) {
+ if (!empty($this->notice->lat) && !empty($this->notice->lon)) {
+ $jsonNotice = $this->noticeAsJson($this->notice);
+ $jsonArray[] = $jsonNotice;
+ }
+ }
+
+ $this->inlineScript('$(document).ready(function() { '.
+ ' var _notices = ' . json_encode($jsonArray).'; ' .
+ 'showMapstraction($("#map_canvas"), _notices); });');
+
+ return true;
+ }
+
+ function noticeAsJson($notice)
+ {
+ // FIXME: this code should be abstracted to a neutral third
+ // party, like Notice::asJson(). I'm not sure of the ethics
+ // of refactoring from within a plugin, so I'm just abusing
+ // the ApiAction method. Don't do this unless you're me!
+
+ require_once(INSTALLDIR.'/lib/api.php');
+
+ $act = new ApiAction('/dev/null');
+
+ $arr = $act->twitterStatusArray($notice, true);
+ $arr['url'] = $notice->bestUrl();
+ $arr['html'] = $notice->rendered;
+ $arr['source'] = $arr['source'];
+
+ if (!empty($notice->reply_to)) {
+ $reply_to = Notice::staticGet('id', $notice->reply_to);
+ if (!empty($reply_to)) {
+ $arr['in_reply_to_status_url'] = $reply_to->bestUrl();
+ }
+ $reply_to = null;
+ }
+
+ $profile = $notice->getProfile();
+ $arr['user']['profile_url'] = $profile->profileurl;
+
+ return $arr;
+ }
+}
diff --git a/plugins/Mapstraction/usermap.js b/plugins/Mapstraction/usermap.js
index e667dd579..4b7a6c26b 100644
--- a/plugins/Mapstraction/usermap.js
+++ b/plugins/Mapstraction/usermap.js
@@ -1,40 +1,32 @@
-$(document).ready(function() {
+function scrapeNotices(user)
+{
var notices = [];
$(".notice").each(function(){
- var notice = getNoticeFromElement($(this));
- if(notice['geo'])
- notices.push(notice);
+ var notice = getNoticeFromElement($(this));
+ if (user) {
+ notice['user'] = user;
+ } else {
+ notice['user'] = getUserFromElement($(this));
+ }
+ if(notice['geo'])
+ notices.push(notice);
});
- if($("#map_canvas").length && notices.length>0)
- {
- showMapstraction($("#map_canvas"), notices);
- }
- $('.geo').click(function(){
- var noticeElement = $(this).closest(".notice");
- notice = getNoticeFromElement(noticeElement);
-
- $.fn.jOverlay.options = {
- color : '#000',
- opacity : '0.6',
- zIndex : 99,
- center : false,
- bgClickToClose : true,
- autoHide : true,
- css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'}
- };
- var html="<div id='map_canvas_popup' class='gray smallmap' style='width: 542px; height: 500px' />";
- html+="<button class='close'>&#215;</button>";
- html+=$("<div/>").append($(this).clone()).html();
- $().jOverlay({ "html": html });
- $('#jOverlayContent').show();
- $('#jOverlayContent button').click($.closeOverlay);
-
- showMapstraction($("#map_canvas_popup"), notice);
-
- return false;
- });
-});
+ return notices;
+}
+
+function scrapeUser()
+{
+ var avatarURL = $(".entity_profile .entity_depiction img.avatar").attr('src');
+ var profileURL = $(".entity_profile .entity_nickname .url").attr('href');
+ var nickname = $(".entity_profile .entity_nickname .nickname").text();
+
+ return {
+ 'profile_image_url': avatarURL,
+ 'profile_url': profileURL,
+ 'screen_name': nickname
+ };
+}
function getMicroformatValue(element)
{
@@ -48,23 +40,34 @@ function getMicroformatValue(element)
function getNoticeFromElement(noticeElement)
{
var notice = {};
- if(noticeElement.find(".geo").length){
+
+ if(noticeElement.find(".geo").length) {
var latlon = noticeElement.find(".geo").attr('title').split(";");
notice['geo']={'coordinates': [
parseFloat(latlon[0]),
parseFloat(latlon[1])] };
}
- notice['user']={
- 'profile_image_url': noticeElement.find("img.avatar").attr('src'),
- 'profile_url': noticeElement.find(".author a.url").attr('href'),
- 'screen_name': noticeElement.find(".author .nickname").text()
- };
- notice['html']=noticeElement.find(".entry-content").html();
- notice['url']=noticeElement.find("a.timestamp").attr('href');
- notice['created_at']=noticeElement.find("abbr.published").text();
+
+ notice['html'] = noticeElement.find(".entry-content").html();
+ notice['url'] = noticeElement.find("a.timestamp").attr('href');
+ notice['created_at'] = noticeElement.find("abbr.published").text();
+
return notice;
}
+function getUserFromElement(noticeElement)
+{
+ var avatarURL = noticeElement.find("img.avatar").attr('src');
+ var profileURL = noticeElement.find(".author a.url").attr('href');
+ var nickname = noticeElement.find(".author .nickname").text();
+
+ return {
+ 'profile_image_url': avatarURL,
+ 'profile_url': profileURL,
+ 'screen_name': nickname
+ };
+}
+
function showMapstraction(element, notices) {
if(element instanceof jQuery) element = element[0];
if(! $.isArray(notices)) notices = [notices];
diff --git a/plugins/Mapstraction/usermap.php b/plugins/Mapstraction/usermap.php
index fbf1469c3..3e517ee86 100644
--- a/plugins/Mapstraction/usermap.php
+++ b/plugins/Mapstraction/usermap.php
@@ -37,61 +37,24 @@ if (!defined('STATUSNET')) {
* @category Mapstraction
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-class UsermapAction extends OwnerDesignAction
+class UsermapAction extends MapAction
{
- var $profile = null;
- var $page = null;
- var $notices = null;
-
- public $plugin = null;
function prepare($args)
{
- parent::prepare($args);
-
- $nickname_arg = $this->arg('nickname');
- $nickname = common_canonical_nickname($nickname_arg);
-
- // Permanent redirect on non-canonical nickname
-
- if ($nickname_arg != $nickname) {
- $args = array('nickname' => $nickname);
- if ($this->arg('page') && $this->arg('page') != 1) {
- $args['page'] = $this->arg['page'];
- }
- common_redirect(common_local_url($this->trimmed('action'), $args), 301);
+ if(parent::prepare($args)) {
+ $this->notice = empty($this->tag)
+ ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
+ : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
+ return true;
+ }else{
return false;
}
-
- $this->user = User::staticGet('nickname', $nickname);
-
- if (!$this->user) {
- $this->clientError(_('No such user.'), 404);
- return false;
- }
-
- $this->profile = $this->user->getProfile();
-
- if (!$this->profile) {
- $this->serverError(_('User has no profile.'));
- return false;
- }
-
- $page = $this->trimmed('page');
-
- if (!empty($page) && Validate::number($page)) {
- $this->page = $page+0;
- } else {
- $this->page = 1;
- }
-
- $this->notices = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
-
- return true;
}
function title()
@@ -110,17 +73,4 @@ class UsermapAction extends OwnerDesignAction
$this->page);
}
}
-
- function handle($args)
- {
- parent::handle($args);
- $this->showPage();
- }
-
- function showContent()
- {
- $this->element('div', array('id' => 'map_canvas',
- 'class' => 'gray smallmap',
- 'style' => "width: 100%; height: 400px"));
- }
-} \ No newline at end of file
+}
diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php
index cbfa6bae0..030df405b 100644
--- a/plugins/Realtime/RealtimePlugin.php
+++ b/plugins/Realtime/RealtimePlugin.php
@@ -120,7 +120,7 @@ class RealtimePlugin extends Plugin
function onEndShowStatusNetStyles($action)
{
- $action->cssLink(common_path('plugins/Realtime/realtimeupdate.css'),
+ $action->cssLink(common_path('plugins/Realtime/realtimeupdate.css'),
null, 'screen, projection, tv');
return true;
}
@@ -293,13 +293,6 @@ class RealtimePlugin extends Plugin
return $tags;
}
- // Push this up to Plugin
-
- function log($level, $msg)
- {
- common_log($level, get_class($this) . ': '.$msg);
- }
-
function _getScripts()
{
return array('plugins/Realtime/realtimeupdate.js',
diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php
index ad3c2e551..adf9ceda3 100644
--- a/plugins/TwitterBridge/TwitterBridgePlugin.php
+++ b/plugins/TwitterBridge/TwitterBridgePlugin.php
@@ -127,7 +127,12 @@ class TwitterBridgePlugin extends Plugin
*/
function onStartEnqueueNotice($notice, &$transports)
{
- array_push($transports, 'twitter');
+ // Avoid a possible loop
+
+ if ($notice->source != 'twitter') {
+ array_push($transports, 'twitter');
+ }
+
return true;
}
diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
index eba1d563b..b4ca12be2 100755
--- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
+++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
@@ -209,7 +209,13 @@ class TwitterStatusFetcher extends ParallelizingDaemon
continue;
}
- $this->saveStatus($status, $flink);
+ $notice = null;
+
+ $notice = $this->saveStatus($status, $flink);
+
+ if (!empty($notice)) {
+ common_broadcast_notice($notice);
+ }
}
// Okay, record the time we synced with Twitter for posterity
@@ -235,12 +241,14 @@ class TwitterStatusFetcher extends ParallelizingDaemon
$uri = 'http://twitter.com/' . $status->user->screen_name .
'/status/' . $status->id;
- $notice = Notice::staticGet('uri', $uri);
-
// check to see if we've already imported the status
+ $notice = Notice::staticGet('uri', $uri);
+
if (empty($notice)) {
+ // XXX: transaction here?
+
$notice = new Notice();
$notice->profile_id = $id;
@@ -257,6 +265,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon
$id = $notice->insert();
Event::handle('EndNoticeSave', array($notice));
}
+
}
if (!Notice_inbox::pkeyGet(array('notice_id' => $notice->id,
@@ -270,7 +279,12 @@ class TwitterStatusFetcher extends ParallelizingDaemon
$inbox->source = NOTICE_INBOX_SOURCE_GATEWAY; // From a private source
$inbox->insert();
+
}
+
+ $notice->blowCaches();
+
+ return $notice;
}
function ensureProfile($user)
diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php
index 60c0c2c0a..e13c2555a 100644
--- a/plugins/UserFlag/UserFlagPlugin.php
+++ b/plugins/UserFlag/UserFlagPlugin.php
@@ -68,7 +68,7 @@ class UserFlagPlugin extends Plugin
return true;
}
- function onRouterInitialized(&$m) {
+ function onRouterInitialized($m) {
$m->connect('main/flag/profile', array('action' => 'flagprofile'));
$m->connect('admin/profile/flag', array('action' => 'adminprofileflag'));
return true;