diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/GeonamesPlugin.php | 80 | ||||
-rw-r--r-- | plugins/Mapstraction/MapstractionPlugin.php | 78 | ||||
-rw-r--r-- | plugins/Mapstraction/allmap.php | 68 | ||||
-rw-r--r-- | plugins/Mapstraction/map.php | 167 | ||||
-rw-r--r-- | plugins/Mapstraction/usermap.js | 87 | ||||
-rw-r--r-- | plugins/Mapstraction/usermap.php | 68 | ||||
-rw-r--r-- | plugins/Realtime/RealtimePlugin.php | 9 | ||||
-rw-r--r-- | plugins/TwitterBridge/TwitterBridgePlugin.php | 7 | ||||
-rwxr-xr-x | plugins/TwitterBridge/daemons/twitterstatusfetcher.php | 20 | ||||
-rw-r--r-- | plugins/UserFlag/UserFlagPlugin.php | 2 |
10 files changed, 318 insertions, 268 deletions
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'>×</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; |