summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--EVENTS.txt328
-rw-r--r--README206
-rw-r--r--actions/accesstoken.php28
-rw-r--r--actions/all.php82
-rw-r--r--actions/allrss.php1
-rw-r--r--actions/api.php293
-rw-r--r--actions/apiaccountratelimitstatus.php112
-rw-r--r--actions/apiaccountverifycredentials.php85
-rw-r--r--actions/apiblockcreate.php114
-rw-r--r--actions/apiblockdestroy.php113
-rw-r--r--actions/apidirectmessage.php375
-rw-r--r--actions/apidirectmessagenew.php188
-rw-r--r--actions/apifavoritecreate.php168
-rw-r--r--actions/apifavoritedestroy.php150
-rw-r--r--actions/apifriendshipscreate.php137
-rw-r--r--actions/apifriendshipsdestroy.php139
-rw-r--r--actions/apifriendshipsexists.php128
-rw-r--r--actions/apifriendshipsshow.php168
-rw-r--r--actions/apigroupcreate.php372
-rw-r--r--actions/apigroupismember.php122
-rw-r--r--actions/apigroupjoin.php163
-rw-r--r--actions/apigroupleave.php149
-rw-r--r--actions/apigrouplist.php223
-rw-r--r--actions/apigrouplistall.php208
-rw-r--r--actions/apigroupmembership.php192
-rw-r--r--actions/apigroupshow.php152
-rw-r--r--actions/apihelptest.php96
-rw-r--r--actions/apistatusesdestroy.php154
-rw-r--r--actions/apistatusesshow.php206
-rw-r--r--actions/apistatusesupdate.php271
-rw-r--r--actions/apistatusnetconfig.php142
-rw-r--r--actions/apistatusnetversion.php102
-rw-r--r--actions/apisubscriptions.php266
-rw-r--r--actions/apitimelinefavorites.php237
-rw-r--r--actions/apitimelinefriends.php247
-rw-r--r--actions/apitimelinegroup.php231
-rw-r--r--actions/apitimelinementions.php233
-rw-r--r--actions/apitimelinepublic.php213
-rw-r--r--actions/apitimelinetag.php224
-rw-r--r--actions/apitimelineuser.php248
-rw-r--r--actions/apiuserfollowers.php89
-rw-r--r--actions/apiuserfriends.php89
-rw-r--r--actions/apiusershow.php126
-rw-r--r--actions/bookmarklet.php75
-rw-r--r--actions/confirmaddress.php6
-rw-r--r--actions/deletenotice.php38
-rw-r--r--actions/doc.php26
-rw-r--r--actions/editgroup.php9
-rw-r--r--actions/emailsettings.php2
-rw-r--r--actions/favorited.php3
-rw-r--r--actions/favoritesrss.php11
-rw-r--r--actions/finishremotesubscribe.php313
-rw-r--r--actions/foafgroup.php173
-rw-r--r--actions/groupbyid.php5
-rw-r--r--actions/groupdesignsettings.php5
-rw-r--r--actions/grouplogo.php5
-rw-r--r--actions/groupmembers.php9
-rw-r--r--actions/grouprss.php6
-rw-r--r--actions/groupsearch.php3
-rw-r--r--actions/invite.php4
-rw-r--r--actions/joingroup.php5
-rw-r--r--actions/leavegroup.php5
-rw-r--r--actions/login.php11
-rw-r--r--actions/logout.php2
-rw-r--r--actions/newgroup.php9
-rw-r--r--actions/newmessage.php7
-rw-r--r--actions/newnotice.php210
-rw-r--r--actions/noticesearch.php4
-rw-r--r--actions/othersettings.php27
-rw-r--r--actions/postnotice.php109
-rw-r--r--actions/profilesettings.php24
-rw-r--r--actions/public.php30
-rw-r--r--actions/publicrss.php18
-rw-r--r--actions/publictagcloud.php3
-rw-r--r--actions/register.php42
-rw-r--r--actions/remotesubscribe.php336
-rw-r--r--actions/replies.php4
-rw-r--r--actions/repliesrss.php1
-rw-r--r--actions/requesttoken.php21
-rw-r--r--actions/showfavorites.php4
-rw-r--r--actions/showgroup.php17
-rw-r--r--actions/shownotice.php8
-rw-r--r--actions/showstream.php374
-rw-r--r--actions/subscribers.php4
-rw-r--r--actions/twitapiaccount.php127
-rw-r--r--actions/twitapiblocks.php74
-rw-r--r--actions/twitapidirect_messages.php304
-rw-r--r--actions/twitapifavorites.php216
-rw-r--r--actions/twitapifriendships.php250
-rw-r--r--actions/twitapigroups.php329
-rw-r--r--actions/twitapihelp.php57
-rw-r--r--actions/twitapisearchatom.php8
-rw-r--r--actions/twitapisearchjson.php10
-rw-r--r--actions/twitapistatuses.php601
-rw-r--r--actions/twitapistatusnet.php175
-rw-r--r--actions/twitapitags.php113
-rw-r--r--actions/twitapitrends.php6
-rw-r--r--actions/twitapiusers.php80
-rw-r--r--actions/updateprofile.php202
-rw-r--r--actions/userauthorization.php421
-rw-r--r--actions/userrss.php5
-rw-r--r--actions/xrds.php108
-rw-r--r--classes/Avatar.php2
-rw-r--r--classes/Config.php131
-rw-r--r--classes/Deleted_notice.php46
-rw-r--r--classes/File.php55
-rw-r--r--classes/File_oembed.php21
-rw-r--r--classes/File_redirection.php3
-rw-r--r--classes/Location_namespace.php46
-rw-r--r--classes/Message.php51
-rw-r--r--classes/Notice.php260
-rw-r--r--classes/Profile.php57
-rw-r--r--classes/User.php161
-rw-r--r--classes/User_group.php18
-rw-r--r--classes/User_role.php48
-rw-r--r--classes/statusnet.ini55
-rw-r--r--config.php.sample9
-rw-r--r--db/08to09.sql34
-rw-r--r--db/08to09_pg.sql40
-rw-r--r--db/location_namespace.sql5
-rw-r--r--db/statusnet.sql74
-rw-r--r--db/statusnet_pg.sql32
-rw-r--r--doc-src/bookmarklet2
-rw-r--r--doc-src/help1
-rw-r--r--extlib/DB/DataObject.php2
-rw-r--r--extlib/DB/DataObject/Cast.php8
-rw-r--r--extlib/DB/DataObject/Error.php8
-rwxr-xr-xextlib/libomb/base_url_xrds_mapper.php51
-rw-r--r--extlib/libomb/constants.php58
-rwxr-xr-xextlib/libomb/datastore.php200
-rw-r--r--extlib/libomb/helper.php99
-rwxr-xr-xextlib/libomb/invalidparameterexception.php32
-rwxr-xr-xextlib/libomb/invalidyadisexception.php31
-rwxr-xr-xextlib/libomb/notice.php272
-rwxr-xr-xextlib/libomb/omb_yadis_xrds.php196
-rwxr-xr-xextlib/libomb/plain_xrds_writer.php124
-rwxr-xr-xextlib/libomb/profile.php317
-rwxr-xr-xextlib/libomb/remoteserviceexception.php42
-rwxr-xr-xextlib/libomb/service_consumer.php430
-rwxr-xr-xextlib/libomb/service_provider.php425
-rwxr-xr-xextlib/libomb/unsupportedserviceexception.php31
-rwxr-xr-xextlib/libomb/xrds_mapper.php33
-rwxr-xr-xextlib/libomb/xrds_writer.php33
-rw-r--r--extlib/php-gettext/gettext.inc2
-rw-r--r--index.php121
-rw-r--r--install.php448
-rw-r--r--js/util.js31
-rw-r--r--lib/Shorturl_api.php66
-rw-r--r--lib/accountsettingsaction.php61
-rw-r--r--lib/action.php39
-rw-r--r--lib/api.php (renamed from lib/twitterapi.php)632
-rw-r--r--lib/apiauth.php203
-rw-r--r--lib/apibareauth.php109
-rw-r--r--lib/command.php140
-rw-r--r--lib/commandinterpreter.php53
-rw-r--r--lib/common.php253
-rw-r--r--lib/connectsettingsaction.php49
-rw-r--r--lib/curlclient.php179
-rw-r--r--lib/default.php235
-rw-r--r--lib/deleteaction.php74
-rw-r--r--lib/groupeditform.php24
-rw-r--r--lib/htmloutputter.php2
-rw-r--r--lib/httpclient.php122
-rw-r--r--lib/jabber.php6
-rw-r--r--lib/language.php47
-rw-r--r--lib/location.php188
-rw-r--r--lib/logingroupnav.php35
-rw-r--r--lib/mail.php72
-rw-r--r--lib/mediafile.php284
-rw-r--r--lib/messageform.php17
-rw-r--r--lib/noticeform.php65
-rw-r--r--lib/noticelist.php53
-rw-r--r--lib/oauthstore.php348
-rw-r--r--lib/omb.php329
-rw-r--r--lib/plugin.php14
-rw-r--r--lib/profilelist.php62
-rw-r--r--lib/queuehandler.php77
-rw-r--r--lib/right.php50
-rw-r--r--lib/router.php868
-rw-r--r--lib/rssaction.php59
-rw-r--r--lib/schema.php680
-rw-r--r--lib/settingsaction.php4
-rw-r--r--lib/unqueuemanager.php20
-rw-r--r--lib/util.php152
-rw-r--r--locale/bg/LC_MESSAGES/statusnet.mobin0 -> 97732 bytes
-rw-r--r--locale/bg/LC_MESSAGES/statusnet.po (renamed from locale/bg_BG/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/bg_BG/LC_MESSAGES/statusnet.mobin89338 -> 0 bytes
-rw-r--r--locale/ca/LC_MESSAGES/statusnet.mo (renamed from locale/ca_ES/LC_MESSAGES/statusnet.mo)bin84543 -> 84543 bytes
-rw-r--r--locale/ca/LC_MESSAGES/statusnet.po (renamed from locale/ca_ES/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/cs/LC_MESSAGES/statusnet.mobin0 -> 38703 bytes
-rw-r--r--locale/cs/LC_MESSAGES/statusnet.po (renamed from locale/cs_CZ/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/cs_CZ/LC_MESSAGES/statusnet.mobin28419 -> 0 bytes
-rw-r--r--locale/de/LC_MESSAGES/statusnet.mobin0 -> 84579 bytes
-rw-r--r--locale/de/LC_MESSAGES/statusnet.po (renamed from locale/de_DE/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/de_DE/LC_MESSAGES/statusnet.mobin59656 -> 0 bytes
-rw-r--r--locale/el/LC_MESSAGES/statusnet.mo (renamed from locale/el_GR/LC_MESSAGES/statusnet.mo)bin27725 -> 27725 bytes
-rw-r--r--locale/el/LC_MESSAGES/statusnet.po (renamed from locale/el_GR/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/en_GB/LC_MESSAGES/statusnet.mobin77405 -> 78521 bytes
-rw-r--r--locale/es/LC_MESSAGES/statusnet.mobin71978 -> 83472 bytes
-rw-r--r--locale/fr/LC_MESSAGES/statusnet.mobin0 -> 86462 bytes
-rw-r--r--locale/fr/LC_MESSAGES/statusnet.po (renamed from locale/fr_FR/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/fr_FR/LC_MESSAGES/statusnet.mobin83964 -> 0 bytes
-rw-r--r--locale/ga/LC_MESSAGES/statusnet.mobin0 -> 73858 bytes
-rw-r--r--locale/ga/LC_MESSAGES/statusnet.po4713
-rw-r--r--locale/he/LC_MESSAGES/statusnet.mo (renamed from locale/he_IL/LC_MESSAGES/statusnet.mo)bin42235 -> 42235 bytes
-rw-r--r--locale/he/LC_MESSAGES/statusnet.po (renamed from locale/he_IL/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/is/LC_MESSAGES/statusnet.mobin0 -> 85990 bytes
-rw-r--r--locale/is/LC_MESSAGES/statusnet.po (renamed from locale/is_IS/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/it/LC_MESSAGES/statusnet.mobin0 -> 83401 bytes
-rw-r--r--locale/it/LC_MESSAGES/statusnet.po (renamed from locale/it_IT/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/it_IT/LC_MESSAGES/statusnet.mobin80186 -> 0 bytes
-rw-r--r--locale/ja/LC_MESSAGES/statusnet.mobin0 -> 46648 bytes
-rw-r--r--locale/ja/LC_MESSAGES/statusnet.po (renamed from locale/ja_JP/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/ja_JP/LC_MESSAGES/statusnet.mobin37594 -> 0 bytes
-rw-r--r--locale/ko/LC_MESSAGES/statusnet.mo (renamed from locale/ko_KR/LC_MESSAGES/statusnet.mo)bin88929 -> 88929 bytes
-rw-r--r--locale/ko/LC_MESSAGES/statusnet.po (renamed from locale/ko_KR/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/mk/LC_MESSAGES/statusnet.mobin0 -> 50541 bytes
-rw-r--r--locale/mk/LC_MESSAGES/statusnet.po (renamed from locale/mk_MK/LC_MESSAGES/statusnet.po)4
-rw-r--r--locale/mk_MK/LC_MESSAGES/statusnet.mobin37731 -> 0 bytes
-rw-r--r--locale/nb/LC_MESSAGES/statusnet.mo (renamed from locale/nb_NO/LC_MESSAGES/statusnet.mo)bin22230 -> 22230 bytes
-rw-r--r--locale/nb/LC_MESSAGES/statusnet.po (renamed from locale/nb_NO/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/nl/LC_MESSAGES/statusnet.mobin0 -> 63579 bytes
-rw-r--r--locale/nl/LC_MESSAGES/statusnet.po (renamed from locale/nl_NL/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/nl_NL/LC_MESSAGES/statusnet.mobin56796 -> 0 bytes
-rw-r--r--locale/nn/LC_MESSAGES/statusnet.mo (renamed from locale/nn_NO/LC_MESSAGES/statusnet.mo)bin80329 -> 80329 bytes
-rw-r--r--locale/nn/LC_MESSAGES/statusnet.po (renamed from locale/nn_NO/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/pl/LC_MESSAGES/statusnet.mo (renamed from locale/pl_PL/LC_MESSAGES/statusnet.mo)bin124708 -> 124708 bytes
-rw-r--r--locale/pl/LC_MESSAGES/statusnet.po (renamed from locale/pl_PL/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/pt/LC_MESSAGES/statusnet.mobin22701 -> 25415 bytes
-rw-r--r--locale/pt_BR/LC_MESSAGES/statusnet.mobin76797 -> 83652 bytes
-rw-r--r--locale/ru/LC_MESSAGES/statusnet.mo (renamed from locale/ru_RU/LC_MESSAGES/statusnet.mo)bin109421 -> 109421 bytes
-rw-r--r--locale/ru/LC_MESSAGES/statusnet.po (renamed from locale/ru_RU/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/sv/LC_MESSAGES/statusnet.mobin0 -> 69744 bytes
-rw-r--r--locale/sv/LC_MESSAGES/statusnet.po (renamed from locale/sv_SE/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/sv_SE/LC_MESSAGES/statusnet.mobin54299 -> 0 bytes
-rw-r--r--locale/te/LC_MESSAGES/statusnet.mobin0 -> 43726 bytes
-rw-r--r--locale/te/LC_MESSAGES/statusnet.po (renamed from locale/te_IN/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/te_IN/LC_MESSAGES/statusnet.mobin29270 -> 0 bytes
-rw-r--r--locale/tr/LC_MESSAGES/statusnet.mobin0 -> 37703 bytes
-rw-r--r--locale/tr/LC_MESSAGES/statusnet.po (renamed from locale/tr_TR/LC_MESSAGES/statusnet.po)4
-rw-r--r--locale/tr_TR/LC_MESSAGES/statusnet.mobin27598 -> 0 bytes
-rw-r--r--locale/uk/LC_MESSAGES/statusnet.mo (renamed from locale/uk_UA/LC_MESSAGES/statusnet.mo)bin109628 -> 109628 bytes
-rw-r--r--locale/uk/LC_MESSAGES/statusnet.po (renamed from locale/uk_UA/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/vi/LC_MESSAGES/statusnet.mobin0 -> 78725 bytes
-rw-r--r--locale/vi/LC_MESSAGES/statusnet.po (renamed from locale/vi_VN/LC_MESSAGES/statusnet.po)0
-rw-r--r--locale/vi_VN/LC_MESSAGES/statusnet.mobin50650 -> 0 bytes
-rw-r--r--locale/zh_TW/LC_MESSAGES/statusnet.mobin11931 -> 17868 bytes
-rw-r--r--locale/zh_TW/LC_MESSAGES/statusnet.po4
-rw-r--r--plugins/FBConnect/README76
-rw-r--r--plugins/Facebook/FBCLoginGroupNav.php (renamed from plugins/FBConnect/FBCLoginGroupNav.php)0
-rw-r--r--plugins/Facebook/FBCSettingsNav.php (renamed from plugins/FBConnect/FBCSettingsNav.php)0
-rw-r--r--plugins/Facebook/FBC_XDReceiver.php (renamed from plugins/FBConnect/FBC_XDReceiver.php)0
-rw-r--r--plugins/Facebook/FBConnect.css (renamed from plugins/FBConnect/FBConnectPlugin.css)0
-rw-r--r--plugins/Facebook/FBConnectAuth.php (renamed from plugins/FBConnect/FBConnectAuth.php)2
-rw-r--r--plugins/Facebook/FBConnectLogin.php (renamed from plugins/FBConnect/FBConnectLogin.php)3
-rw-r--r--plugins/Facebook/FBConnectSettings.php (renamed from plugins/FBConnect/FBConnectSettings.php)0
-rw-r--r--plugins/Facebook/FacebookPlugin.php (renamed from plugins/FBConnect/FBConnectPlugin.php)378
-rw-r--r--plugins/Facebook/README129
-rw-r--r--plugins/Facebook/facebook/facebook.php (renamed from extlib/facebook/facebook.php)0
-rw-r--r--plugins/Facebook/facebook/facebook_desktop.php (renamed from extlib/facebook/facebook_desktop.php)0
-rwxr-xr-xplugins/Facebook/facebook/facebookapi_php5_restlib.php (renamed from extlib/facebook/facebookapi_php5_restlib.php)0
-rw-r--r--plugins/Facebook/facebook/jsonwrapper/JSON/JSON.php (renamed from extlib/facebook/jsonwrapper/JSON/JSON.php)0
-rw-r--r--plugins/Facebook/facebook/jsonwrapper/JSON/LICENSE (renamed from extlib/facebook/jsonwrapper/JSON/LICENSE)0
-rw-r--r--plugins/Facebook/facebook/jsonwrapper/jsonwrapper.php (renamed from extlib/facebook/jsonwrapper/jsonwrapper.php)0
-rw-r--r--plugins/Facebook/facebook/jsonwrapper/jsonwrapper_inner.php (renamed from extlib/facebook/jsonwrapper/jsonwrapper_inner.php)0
-rw-r--r--plugins/Facebook/facebookaction.php (renamed from lib/facebookaction.php)78
-rw-r--r--plugins/Facebook/facebookapp.css (renamed from theme/base/css/facebookapp.css)24
-rw-r--r--plugins/Facebook/facebookhome.php (renamed from actions/facebookhome.php)6
-rw-r--r--plugins/Facebook/facebookinvite.php (renamed from actions/facebookinvite.php)3
-rw-r--r--plugins/Facebook/facebooklogin.php (renamed from actions/facebooklogin.php)34
-rwxr-xr-xplugins/Facebook/facebookqueuehandler.php (renamed from scripts/facebookqueuehandler.php)7
-rw-r--r--plugins/Facebook/facebookremove.php (renamed from actions/facebookremove.php)6
-rw-r--r--plugins/Facebook/facebooksettings.php (renamed from actions/facebooksettings.php)24
-rw-r--r--plugins/Facebook/facebookutil.php (renamed from lib/facebookutil.php)48
-rw-r--r--plugins/Facebook/fbfavicon.ico (renamed from plugins/FBConnect/fbfavicon.ico)bin1150 -> 1150 bytes
-rw-r--r--plugins/GeonamesPlugin.php305
-rw-r--r--plugins/LilUrl/LilUrlPlugin.php64
-rw-r--r--plugins/OpenID/OpenIDPlugin.php244
-rw-r--r--plugins/OpenID/User_openid.php (renamed from classes/User_openid.php)13
-rw-r--r--plugins/OpenID/doc-src/openid (renamed from doc-src/openid)0
-rw-r--r--plugins/OpenID/finishaddopenid.php (renamed from actions/finishaddopenid.php)2
-rw-r--r--plugins/OpenID/finishopenidlogin.php (renamed from actions/finishopenidlogin.php)8
-rw-r--r--plugins/OpenID/openid.php (renamed from lib/openid.php)4
-rw-r--r--plugins/OpenID/openidlogin.php (renamed from actions/openidlogin.php)6
-rw-r--r--plugins/OpenID/openidsettings.php (renamed from actions/openidsettings.php)8
-rw-r--r--plugins/OpenID/publicxrds.php (renamed from actions/publicxrds.php)2
-rw-r--r--plugins/Orbited/OrbitedPlugin.php154
-rw-r--r--plugins/Orbited/orbitedextra.js2
-rw-r--r--plugins/Orbited/orbitedupdater.js24
-rw-r--r--plugins/PtitUrl/PtitUrlPlugin.php62
-rw-r--r--plugins/PubSubHubBub/PubSubHubBubPlugin.php122
-rw-r--r--plugins/PubSubHubBub/publisher.php86
-rw-r--r--plugins/Realtime/RealtimePlugin.php9
-rw-r--r--plugins/Realtime/jquery.getUrlParam.js72
-rw-r--r--plugins/Realtime/realtimeupdate.js47
-rw-r--r--plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php52
-rw-r--r--plugins/SimpleUrl/SimpleUrlPlugin.php79
-rw-r--r--plugins/TemplatePlugin.php2
-rw-r--r--plugins/TightUrl/TightUrlPlugin.php62
-rw-r--r--plugins/TwitterBridge/README85
-rw-r--r--plugins/TwitterBridge/TwitterBridgePlugin.php187
-rwxr-xr-xplugins/TwitterBridge/daemons/synctwitterfriends.php (renamed from scripts/synctwitterfriends.php)13
-rwxr-xr-xplugins/TwitterBridge/daemons/twitterqueuehandler.php (renamed from scripts/twitterqueuehandler.php)7
-rwxr-xr-xplugins/TwitterBridge/daemons/twitterstatusfetcher.php (renamed from scripts/twitterstatusfetcher.php)14
-rw-r--r--plugins/TwitterBridge/twitter.php (renamed from lib/twitter.php)51
-rw-r--r--plugins/TwitterBridge/twitterauthorization.php (renamed from actions/twitterauthorization.php)25
-rw-r--r--plugins/TwitterBridge/twitterbasicauthclient.php (renamed from lib/twitterbasicauthclient.php)10
-rw-r--r--plugins/TwitterBridge/twitteroauthclient.php (renamed from lib/twitteroauthclient.php)0
-rw-r--r--plugins/TwitterBridge/twittersettings.php (renamed from actions/twittersettings.php)11
-rw-r--r--scripts/checkschema.php30
-rw-r--r--scripts/createsim.php2
-rwxr-xr-xscripts/getvaliddaemons.php32
-rwxr-xr-xscripts/maildaemon.php155
-rwxr-xr-xscripts/ombqueuehandler.php2
-rwxr-xr-xscripts/pluginqueuehandler.php58
-rw-r--r--scripts/showtable.php (renamed from actions/twitapinotifications.php)35
-rwxr-xr-xscripts/startdaemons.sh2
-rwxr-xr-xscripts/xmppdaemon.php17
-rw-r--r--tests/HashTagDetectionTests.php1
-rw-r--r--tests/LocationTest.php87
-rw-r--r--tests/URLDetectionTest.php225
-rw-r--r--tests/UserRightsTest.php59
-rw-r--r--theme/base/css/display.css15
-rw-r--r--theme/base/images/icons/icons-01.pngbin0 -> 3260 bytes
-rw-r--r--theme/default/css/display.css50
-rw-r--r--theme/identica/css/display.css48
-rw-r--r--theme/identica/css/ie.css8
-rw-r--r--theme/iphone/bg-body.gifbin136 -> 0 bytes
-rw-r--r--theme/iphone/bg-header.gifbin2469 -> 0 bytes
-rw-r--r--theme/iphone/default-avatar-mini.pngbin646 -> 0 bytes
-rw-r--r--theme/iphone/default-avatar-profile.pngbin2853 -> 0 bytes
-rw-r--r--theme/iphone/default-avatar-stream.pngbin1487 -> 0 bytes
-rw-r--r--theme/iphone/display.css698
-rw-r--r--theme/iphone/display.css.dist686
-rw-r--r--theme/iphone/ie6.css.dist63
-rw-r--r--theme/iphone/ie7.css.dist20
-rw-r--r--theme/iphone/login-bg.gifbin328 -> 0 bytes
-rw-r--r--theme/iphone/logo.pngbin818 -> 0 bytes
-rw-r--r--theme/readme.txt2
340 files changed, 23289 insertions, 8823 deletions
diff --git a/.gitignore b/.gitignore
index 1cde3a625..217622c84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,4 +24,4 @@ config-*.php
good-config.php
lac08.log
php.log
-
+.DS_Store
diff --git a/EVENTS.txt b/EVENTS.txt
index 68cb28603..d989557e6 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -32,10 +32,10 @@ StartShowLaconicaStyles: backwards compatibility; deprecated
EndShowLaconicaStyles: backwards compatibility; deprecated
- $action: the current action
-StartShowUAStyles: Showing custom UA Style links
+StartShowUAStyles: Showing custom User-Agent style links
- $action: the current action
-EndShowUAStyles: End showing custom UA Style links; good place to add user-agent (e.g., filter, -webkit, -moz) specific styles
+EndShowUAStyles: End showing custom User-Agent links; good place to add user-agent (e.g., filter, -webkit, -moz) specific styles
- $action: the current action
StartShowScripts: Showing JavaScript links
@@ -87,6 +87,18 @@ StartShowContentBlock: Showing before the content container
EndShowContentBlock: Showing after the content container
- $action: the current action
+StartShowAside: Showing before the Aside container
+- $action: the current action
+
+EndShowAside: Showing after the Aside container
+- $action: the current action
+
+StartShowNoticeFormData: Showing before the notice form data
+- $action: the current action
+
+EndShowNoticeFormData: Showing after the notice form data
+- $action: the current action
+
StartNoticeSave: before inserting a notice (good place for content filters)
- $notice: notice being saved (no ID or URI)
@@ -117,6 +129,9 @@ StartSubGroupNav: Showing the subscriptions group nav menu
EndSubGroupNav: At the end of the subscriptions group nav menu
- $action: the current action
+StartInitializeRouter: Before the router instance has been initialized; good place to add routes
+- $m: the Net_URL_Mapper that has just been set up
+
RouterInitialized: After the router instance has been initialized
- $m: the Net_URL_Mapper that has just been set up
@@ -134,3 +149,312 @@ StartAddressData: Allows the site owner to provide additional information about
EndAddressData: At the end of <address>
- $action: the current action
+
+StartLoginGroupNav: Before showing the login and register navigation menu
+- $action: the current action
+
+EndLoginGroupNav: After showing the login and register navigation menu
+- $action: the current action
+
+StartAccountSettingsNav: Before showing the account settings menu
+- $action: the current action
+
+EndAccountSettingsNav: After showing the account settings menu
+- $action: the current action
+
+Autoload: When trying to autoload a class
+- $cls: the class being sought. A plugin might require_once the file for the class.
+
+SensitiveAction: determines if an action is 'sensitive' and should use SSL
+- $action: name of the action, like 'login'
+- $sensitive: flag for whether this is a sensitive action
+
+LoginAction: determines if an action is a 'login' action (OK for public view in private mode)
+- $action: name of the action, like 'register'
+- $login: flag for whether this is a login action
+
+StartShowHead: called before showing the <head> element and children
+- $action: action object being show
+
+EndShowHead: called after showing the <head> element (and </head>)
+- $action: action object being shown
+
+StartShowBody: called before showing the <body> element and children
+- $action: action object being shown
+
+EndShowBody: called after showing the <body> element (and </body>)
+- $action: action object being shown
+
+StartPersonalGroupNav: beginning of personal group nav menu
+- $action: action object being shown
+
+EndPersonalGroupNav: end of personal group nav menu (good place to add a menu item)
+- $action: action object being shown
+
+StartEndHTML: just before the </html> tag
+- $action: action object being shown
+
+EndEndHTML: just after the </html> tag
+- $action: action object being shown
+
+StartShowDesign: just before showing a site, user, or group design
+- $action: action object being shown
+
+EndShowDesign: just after showing a site, user, or group design
+- $action: action object being shown
+
+StartShowExportData: just before showing the <div> with export data (feeds)
+- $action: action object being shown
+
+EndShowExportData: just after showing the <div> with export data (feeds)
+- $action: action object being shown
+
+StartShowNoticeItem: just before showing the notice item
+- $action: action object being shown
+
+EndShowNoticeItem: just after showing the notice item
+- $action: action object being shown
+
+StartShowPageNotice: just before showing the page notice (instructions or error)
+- $action: action object being shown
+
+EndShowPageNotice: just after showing the page notice (instructions or error)
+- $action: action object being shown
+
+StartShowPageTitle: just before showing the main h1 title of a page (only for registration)
+- $action: action object being shown
+
+StartProfileFormData: just before showing text entry fields on profile settings page
+- $action: action object being shown
+
+EndProfileFormData: just after showing text entry fields on profile settings page
+- $action: action object being shown
+
+StartProfileSaveForm: before starting to save a profile settings form
+- $action: action object being shown
+
+EndProfileSaveForm: after saving a profile settings form (after commit, no profile or user object!)
+- $action: action object being shown
+
+StartRegistrationFormData: just before showing text entry fields on registration page
+- $action: action object being shown
+
+EndRegistrationFormData: just after showing text entry fields on registration page
+- $action: action object being shown
+
+StartRegistrationTry: before validating and saving a new user
+- $action: action object being shown
+
+EndRegistrationTry: after saving a new user (note: no profile or user object!)
+- $action: action object being shown
+
+StartNewQueueManager: before trying to start a new queue manager; good for plugins implementing new queue manager classes
+- $qm: empty queue manager to set
+
+RedirectToLogin: event when we force a redirect to login (like when going to a settings page on a remembered login)
+- $action: action object being shown
+- $user: current user
+
+StartLoadDoc: before loading a help doc (hook this to show your own documentation)
+- $title: title of the document
+- $output: HTML output to show
+
+EndLoadDoc: after loading a help doc (hook this to modify other documentation)
+- $title: title of the document
+- $output: HTML output to show
+
+StartApiRss: after the rss <channel> element is started
+- $action: action object being shown
+
+StartApiAtom: after the <feed> element is started
+- $action: action object being shown
+
+StartEnqueueNotice: about to add a notice to the queues (good place to add a new transport)
+- $notice: the notice being added
+- &$transports: modifiable list of transports (as strings) to queue for
+
+EndEnqueueNotice: after adding a notice to the queues
+- $notice: the notice being added
+- $transports: modifiable list of transports to use
+
+UnqueueHandleNotice: Handle a notice when no queue manager is available
+- $notice: the notice to handle
+- $queue: the "queue" that is being executed
+
+GetValidDaemons: Just before determining which daemons to run
+- &$daemons: modifiable list of daemon scripts to run, filenames relative to scripts/
+
+HandleQueuedNotice: Handle a queued notice at queue time (or immediately if no queue)
+- &$notice: notice to handle
+
+StartShowHeadElements: Right after the <head> tag
+- $action: the current action
+
+EndShowHeadElements: Right before the </head> tag; put <script>s here if you need them in <head>
+- $action: the current action
+
+CheckSchema: chance to check the schema
+
+StartProfilePageProfileSection: Starting to show the section of the
+ profile page with the actual profile data;
+ hook to prevent showing the profile (e.g.)
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageProfileElements: inside the section, before the first
+ element; prepend elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageProfileElements: inside the section, after the last element;
+ append elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageProfileSection: After showing the section of the profile
+ page with the profile elements
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageActionsSection: Starting to show the section of the
+ profile page with action links; hook
+ to hide them (for example)
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageActionsElements: inside the list, before the first
+ element; prepend elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageActionsElements: inside the list, after the last element;
+ append elements here
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageActionsSection: After showing the section of the profile
+ page with the entity actions
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageAvatar: before showing the avatar on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageAvatar: after showing the avatar on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageNickname: before showing the nickname on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageNickname: after showing the nickname on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageFullName: before showing the fullname on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageFullName: after showing the fullname on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageLocation: before showing the location on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageLocation: after showing the location on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageHomepage: before showing the homepage link on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageHomepage: after showing the homepage on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageBio: before showing the bio on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageBio: after showing the bio on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfilePageProfileTags: before showing the tags on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+EndProfilePageProfileTags: after showing the tags on the profile page
+- $action: the current action
+- &$profile: the profile being shown
+
+StartProfileList: when starting a list of profiles (before <ul>)
+- $profilelist: ProfileList widget, with $profile, $action, and $out
+
+EndProfileList: when ending a list of profiles (after </ul>)
+- $profilelist: ProfileList widget
+
+StartProfileListItem: when starting to show a profile list item
+- $item: ProfileListItem widget
+
+EndProfileListItem: after showing a profile list item
+- $item: ProfileListItem widget
+
+StartProfileListItemProfile: the profile data part of the item
+- $item: ProfileListItem widget
+
+EndProfileListItemProfile: the profile data part of the item
+- $item: ProfileListItem widget
+
+StartProfileListItemActions: the actions (buttons) for an item
+- $item: ProfileListItem widget
+
+EndProfileListItemActions: the actions (buttons) for an item
+- $item: ProfileListItem widget
+
+StartProfileListItemProfileElements: inside the <div>
+- $item: ProfileListItem widget
+
+EndProfileListItemProfileElements: inside the <div>
+- $item: ProfileListItem widget
+
+StartProfileListItemAvatar: Showing a profile list avatar
+- $item: ProfileListItem widget
+
+EndProfileListItemAvatar: Showing a profile list avatar
+- $item: ProfileListItem widget
+
+StartProfileListItemFullName: Showing the profile list full name
+- $item: ProfileListItem widget
+
+EndProfileListItemFullName: Showing the profile list full name
+- $item: ProfileListItem widget
+
+StartProfileListItemLocation: Showing the profile list location
+- $item: ProfileListItem widget
+
+EndProfileListItemLocation: Showing the profile list location
+- $item: ProfileListItem widget
+
+StartProfileListItemHomepage: Showing the profile list homepage
+- $item: ProfileListItem widget
+
+EndProfileListItemHomepage: Showing the profile list homepage
+- $item: ProfileListItem widget
+
+StartProfileListItemBio: Showing the profile list bio
+- $item: ProfileListItem widget
+
+EndProfileListItemBio: Showing the profile list bio
+- $item: ProfileListItem widget
+
+StartProfileListItemActionElements: Showing the profile list actions (prepend a button here, or replace all buttons)
+- $item: ProfileListItem widget
+
+EndProfileListItemActionElements: Showing profile list actions (append a button here)
+- $item: ProfileListItem widget
diff --git a/README b/README
index b4c37e3ab..852b48667 100644
--- a/README
+++ b/README
@@ -556,10 +556,6 @@ This will run eight (for now) queue handlers:
of registered users.
* xmppconfirmhandler.php - sends confirmation messages to registered
users.
-* twitterqueuehandler.php - sends queued notices to Twitter for user
- who have opted to set up Twitter bridging.
-* facebookqueuehandler.php - sends queued notices to Facebook for users
- of the built-in Facebook application.
Note that these queue daemons are pretty raw, and need your care. In
particular, they leak memory, and you may want to restart them on a
@@ -577,101 +573,6 @@ our kind of hacky home-grown DB-based queue solution. See the "queues"
config section below for how to configure to use STOMP. As of this
writing, the software has been tested with ActiveMQ (
-Twitter Bridge
---------------
-
-* OAuth
-
-As of 0.8.1, OAuth is used to to access protected resources on Twitter
-instead of HTTP Basic Auth. To use Twitter bridging you will need
-to register your instance of StatusNet as an application on Twitter
-(http://twitter.com/apps), and update the following variables in your
-config.php with the consumer key and secret Twitter generates for you:
-
- $config['twitter']['consumer_key'] = 'YOURKEY';
- $config['twitter']['consumer_secret'] = 'YOURSECRET';
-
-When registering your application with Twitter set the type to "Browser"
-and your Callback URL to:
-
- http://example.org/mublog/twitter/authorization
-
-The default access type should be, "Read & Write".
-
-* Importing statuses from Twitter
-
-To allow your users to import their friends' Twitter statuses, you will
-need to enable the bidirectional Twitter bridge in config.php:
-
- $config['twitterbridge']['enabled'] = true;
-
-and run the TwitterStatusFetcher daemon (scripts/twitterstatusfetcher.php).
-Additionally, you will want to set the integration source variable,
-which will keep notices posted to Twitter via StatusNet from looping
-back. The integration source should be set to the name of your
-application, exactly as you specified it on the settings page for your
-StatusNet application on Twitter, e.g.:
-
- $config['integration']['source'] = 'YourApp';
-
-* Twitter Friends Syncing
-
-Users may set a flag in their settings ("Subscribe to my Twitter friends
-here" under the Twitter tab) to have StatusNet attempt to locate and
-subscribe to "friends" (people they "follow") on Twitter who also have
-accounts on your StatusNet system, and who have previously set up a link
-for automatically posting notices to Twitter.
-
-As of 0.8.0, this is no longer accomplished via a cron job. Instead you
-must run the SyncTwitterFriends daemon (scripts/synctwitterfreinds.php).
-
-Built-in Facebook Application
------------------------------
-
-StatusNet's Facebook application allows your users to automatically
-update their Facebook statuses with their latest notices, invite
-their friends to use the app (and thus your site), view their notice
-timelines, and post notices -- all from within Facebook. The application
-is built into StatusNet and runs on your host. For automatic Facebook
-status updating to work you will need to enable queuing and run the
-facebookqueuehandler.php daemon (see the "Queues and daemons" section
-above).
-
-Quick setup instructions*:
-
-Install the Facebook Developer application on Facebook:
-
- http://www.facebook.com/developers/
-
-Use it to create a new application and generate an API key and secret.
-Uncomment the Facebook app section of your config.php and copy in the
-key and secret, e.g.:
-
- # Config section for the built-in Facebook application
- $config['facebook']['apikey'] = 'APIKEY';
- $config['facebook']['secret'] = 'SECRET';
-
-In Facebook's application editor, specify the following URLs for your app:
-
-- Canvas Callback URL: http://example.net/mublog/facebook/
-- Post-Remove Callback URL: http://example.net/mublog/facebook/remove
-- Post-Add Redirect URL: http://apps.facebook.com/yourapp/
-- Canvas Page URL: http://apps.facebook.com/yourapp/
-
-(Replace 'example.net' with your host's URL, 'mublog' with the path
-to your StatusNet installation, and 'yourapp' with the name of the
-Facebook application you created.)
-
-Additionally, Choose "Web" for Application type in the Advanced tab.
-In the "Canvas setting" section, choose the "FBML" for Render Method,
-"Smart Size" for IFrame size, and "Full width (760px)" for Canvas Width.
-Everything else can be left with default values.
-
-*For more detailed instructions please see the installation guide on the
-StatusNet wiki:
-
- http://status.net/trac/wiki/FacebookApplication
-
Sitemaps
--------
@@ -869,40 +770,8 @@ to update it.
Notice inboxes
--------------
-Before version 0.6.2, the page showing all notices from people the
-user is subscribed to ("so-and-so with friends") was calculated at run
-time. Starting with 0.6.2, we have a new data structure for holding a
-user's "notice inbox". (Note: distinct from the "message inbox", which
-is the "inbox" tab in the UI. The notice inbox appears under the
-"Personal" tab.)
-
-Notices are added to the inbox when they're created. This speeds up
-the query considerably, and also allows us the opportunity, in the
-future, to add different kind of notices to an inbox -- like @-replies
-or subscriptions to search terms or hashtags.
-
-Notice inboxes are enabled by default for new installations. If you
-are upgrading an existing site, this means that your users will see
-empty "Personal" pages. The following steps will help you fix the
-problem.
-
-0. $config['inboxes']['enabled'] can be set to one of three values. If
- you set it to 'false', the site will work as before. Support for this
- will probably be dropped in future versions.
-1. Setting the flag to 'transitional' means that you're in transition.
- In this mode, the code will run the "new query" or the "old query"
- based on whether the user's inbox has been updated.
-2. After setting the flag to "transitional", you can run the
- fixup_inboxes.php script to create the inboxes. You may want to set
- the memory limit high. You can re-run it without ill effect.
-3. When fixup_inboxes is finished, you can set the enabled flag to
- 'true'.
-
-NOTE: As of version 0.8.1 notice inboxes are automatically trimmed back
- to ~1000 notices every once in a while.
-
-NOTE: we will drop support for non-inboxed sites in the 0.9.x version
-of StatusNet. It's time to switch now!
+Notice inboxes are now required. If you don't have inboxes enabled,
+StatusNet will no longer run.
UTF-8 Database
--------------
@@ -998,8 +867,6 @@ closed: If set to 'true', will disallow registration on your site.
the service, *then* set this variable to 'true'.
inviteonly: If set to 'true', will only allow registration if the user
was invited by an existing user.
-openidonly: If set to 'true', will only allow registrations and logins
- through OpenID.
private: If set to 'true', anonymous users will be redirected to the
'login' page. Also, API methods that normally require no
authentication will require it. Note that this does not turn
@@ -1027,6 +894,9 @@ shorturllength: Length of URL at which URLs in a message exceeding 140
dupelimit: minimum time allowed for one person to say the same thing
twice. Default 60s. Anything lower is considered a user
or UI error.
+textlimit: default max size for texts in the site. Defaults to 140.
+ 0 means no limit. Can be fine-tuned for notices, messages,
+ profile bios and group descriptions.
db
--
@@ -1066,6 +936,14 @@ utf8: whether to talk to the database in UTF-8 mode. This is the default
with new installations, but older sites may want to turn it off
until they get their databases fixed up. See "UTF-8 database"
above for details.
+schemacheck: when to let plugins check the database schema to add
+ tables or update them. Values can be 'runtime' (default)
+ or 'script'. 'runtime' can be costly (plugins check the
+ schema on every hit, adding potentially several db
+ queries, some quite long), but not everyone knows how to
+ run a script. If you can, set this to 'script' and run
+ scripts/checkschema.php whenever you install or upgrade a
+ plugin.
syslog
------
@@ -1227,14 +1105,6 @@ For configuring invites.
enabled: Whether to allow users to send invites. Default true.
-openid
-------
-
-For configuring OpenID.
-
-enabled: Whether to allow users to register and login using OpenID. Default
- true.
-
tag
---
@@ -1312,24 +1182,11 @@ For SMS integration.
enabled: Whether to enable SMS integration. Defaults to true. Queues
should also be enabled.
-twitter
--------
-
-For Twitter integration
-
-enabled: Whether to enable Twitter integration. Defaults to true.
- Queues should also be enabled.
-
integration
-----------
A catch-all for integration with other systems.
-source: The name to use for the source of posts to Twitter. Defaults
- to 'statusnet', but if you request your own source name from
- Twitter <http://twitter.com/help/request_source>, you can use
- that here instead. Status updates on Twitter will then have
- links to your site.
taguri: base for tag:// URIs. Defaults to site-server + ',2009'.
inboxes
@@ -1337,9 +1194,8 @@ inboxes
For notice inboxes.
-enabled: A three-valued flag for whether to use notice inboxes (see
- upgrading info above for notes about this change). Can be
- 'false', 'true', or '"transitional"'.
+enabled: No longer used. If you set this to something other than true,
+ StatusNet will no longer run.
throttle
--------
@@ -1361,6 +1217,8 @@ banned: an array of usernames and/or profile IDs of 'banned' profiles.
The site will reject any notices by these users -- they will
not be accepted at all. (Compare with blacklisted users above,
whose posts just won't show up in the public stream.)
+biolimit: max character length of bio; 0 means no limit; null means to use
+ the site text limit default.
newuser
-------
@@ -1457,6 +1315,9 @@ Options for group functionality.
maxaliases: maximum number of aliases a group can have. Default 3. Set
to 0 or less to prevent aliases in a group.
+desclimit: maximum number of characters to allow in group descriptions.
+ null (default) means to use the site-wide text limits. 0
+ means no limit.
oohembed
--------
@@ -1503,15 +1364,6 @@ dir: directory to write backgrounds too. Default is '/background/'
path: path to backgrounds. Default is sub-path of install path; note
that you may need to change this if you change site-path too.
-twitterbridge
--------------
-
-A bi-direction bridge to Twitter (http://twitter.com/).
-
-enabled: default false. If true, will show user's Twitter friends'
- notices in their inbox and faves pages, only to the user. You
- must also run the twitterstatusfetcher.php script.
-
ping
----
@@ -1535,6 +1387,24 @@ linkcolor: Hex color of all links.
backgroundimage: Image to use for the background.
disposition: Flags for whether or not to tile the background image.
+notice
+------
+
+Configuration options specific to notices.
+
+contentlimit: max length of the plain-text content of a notice.
+ Default is null, meaning to use the site-wide text limit.
+ 0 means no limit.
+
+message
+-------
+
+Configuration options specific to messages.
+
+contentlimit: max length of the plain-text content of a message.
+ Default is null, meaning to use the site-wide text limit.
+ 0 means no limit.
+
Plugins
=======
diff --git a/actions/accesstoken.php b/actions/accesstoken.php
index c99aaeded..76bd40473 100644
--- a/actions/accesstoken.php
+++ b/actions/accesstoken.php
@@ -1,6 +1,6 @@
<?php
/**
- * Access token class.
+ * Access token class
*
* PHP version 5
*
@@ -32,10 +32,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
+require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
require_once INSTALLDIR.'/lib/omb.php';
/**
- * Access token class.
+ * Access token class
*
* @category Action
* @package StatusNet
@@ -47,28 +48,23 @@ require_once INSTALLDIR.'/lib/omb.php';
class AccesstokenAction extends Action
{
/**
- * Class handler.
+ * Class handler
*
* @param array $args query arguments
*
- * @return boolean false if user doesn't exist
- */
+ * @return nothing
+ *
+ **/
function handle($args)
{
parent::handle($args);
try {
- common_debug('getting request from env variables', __FILE__);
- common_remove_magic_from_request();
- $req = OAuthRequest::from_request('POST', common_local_url('accesstoken'));
- common_debug('getting a server', __FILE__);
- $server = omb_oauth_server();
- common_debug('fetching the access token', __FILE__);
- $token = $server->fetch_access_token($req);
- common_debug('got this token: "'.print_r($token, true).'"', __FILE__);
- common_debug('printing the access token', __FILE__);
- print $token;
- } catch (OAuthException $e) {
+ $srv = new OMB_Service_Provider(null, omb_oauth_datastore(),
+ omb_oauth_server());
+ $srv->writeAccessToken();
+ } catch (Exception $e) {
$this->serverError($e->getMessage());
}
}
}
+?>
diff --git a/actions/all.php b/actions/all.php
index bfde3a7e4..f1786462e 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -1,5 +1,5 @@
<?php
-/*
+/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
@@ -15,9 +15,25 @@
*
* 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 Actions
+ * @package Actions
+ * @author Evan Prodromou <evan@status.net>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <millette@controlyourself.ca>
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Meitar Moscovitz <meitarm@gmail.com>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@controlyourself.ca>
+ * @license GNU Affero General Public License http://www.gnu.org/licenses/
+ * @link http://status.net
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
require_once INSTALLDIR.'/lib/personalgroupnav.php';
require_once INSTALLDIR.'/lib/noticelist.php';
@@ -43,8 +59,8 @@ class AllAction extends ProfileAction
$this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
}
- if($this->page > 1 && $this->notice->N == 0){
- $this->serverError(_('No such page'),$code=404);
+ if ($this->page > 1 && $this->notice->N == 0) {
+ $this->serverError(_('No such page'), $code = 404);
}
return true;
@@ -73,20 +89,33 @@ class AllAction extends ProfileAction
function getFeeds()
{
- return array(new Feed(Feed::RSS1,
- common_local_url('allrss', array('nickname' =>
- $this->user->nickname)),
- sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
- new Feed(Feed::RSS2,
- common_local_url('api', array('apiaction' => 'statuses',
- 'method' => 'friends_timeline',
- 'argument' => $this->user->nickname.'.rss')),
- sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
- new Feed(Feed::ATOM,
- common_local_url('api', array('apiaction' => 'statuses',
- 'method' => 'friends_timeline',
- 'argument' => $this->user->nickname.'.atom')),
- sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
+ return array(
+ new Feed(Feed::RSS1,
+ common_local_url(
+ 'allrss', array(
+ 'nickname' =>
+ $this->user->nickname)
+ ),
+ sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
+ new Feed(Feed::RSS2,
+ common_local_url(
+ 'api', array(
+ 'apiaction' => 'statuses',
+ 'method' => 'friends_timeline',
+ 'argument' => $this->user->nickname.'.rss'
+ )
+ ),
+ sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
+ new Feed(Feed::ATOM,
+ common_local_url(
+ 'api', array(
+ 'apiaction' => 'statuses',
+ 'method' => 'friends_timeline',
+ 'argument' => $this->user->nickname.'.atom'
+ )
+ ),
+ sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))
+ );
}
function showLocalNav()
@@ -106,11 +135,8 @@ class AllAction extends ProfileAction
} else {
$message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
}
- }
- else {
- $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and then nudge %s or post a notice to his or her attention.'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
- $this->user->nickname);
+ } else {
+ $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
}
$this->elementStart('div', 'guide');
@@ -128,17 +154,19 @@ class AllAction extends ProfileAction
$this->showEmptyListMessage();
}
- $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
- $this->page, 'all', array('nickname' => $this->user->nickname));
+ $this->pagination(
+ $this->page > 1, $cnt > NOTICES_PER_PAGE,
+ $this->page, 'all', array('nickname' => $this->user->nickname)
+ );
}
function showPageTitle()
{
$user =& common_current_user();
if ($user && ($user->id == $this->user->id)) {
- $this->element('h1', NULL, _("You and friends"));
+ $this->element('h1', null, _("You and friends"));
} else {
- $this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname));
+ $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname));
}
}
diff --git a/actions/allrss.php b/actions/allrss.php
index 57efb73f0..28b1be27d 100644
--- a/actions/allrss.php
+++ b/actions/allrss.php
@@ -68,6 +68,7 @@ class AllrssAction extends Rss10Action
$this->clientError(_('No such user.'));
return false;
} else {
+ $this->notices = $this->getNotices($this->limit);
return true;
}
}
diff --git a/actions/api.php b/actions/api.php
deleted file mode 100644
index 3705d035c..000000000
--- a/actions/api.php
+++ /dev/null
@@ -1,293 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-
-class ApiAction extends Action
-{
-
- var $user;
- var $content_type;
- var $api_arg;
- var $api_method;
- var $api_action;
- var $auth_user;
- var $auth_pw;
-
- function handle($args)
- {
- parent::handle($args);
-
- $this->api_action = $this->arg('apiaction');
- $method = $this->arg('method');
- $argument = $this->arg('argument');
- $this->basic_auth_process_header();
-
- if (isset($argument)) {
- $cmdext = explode('.', $argument);
- $this->api_arg = $cmdext[0];
- $this->api_method = $method;
- $this->content_type = strtolower($cmdext[1]);
- } else {
-
- # Requested format / content-type will be an extension on the method
- $cmdext = explode('.', $method);
- $this->api_method = $cmdext[0];
- $this->content_type = strtolower($cmdext[1]);
- }
-
- if ($this->requires_auth()) {
- if (!isset($this->auth_user)) {
-
- # This header makes basic auth go
- header('WWW-Authenticate: Basic realm="StatusNet API"');
-
- # If the user hits cancel -- bam!
- $this->show_basic_auth_error();
- } else {
- $nickname = $this->auth_user;
- $password = $this->auth_pw;
- $user = common_check_user($nickname, $password);
-
- if ($user) {
- $this->user = $user;
- $this->process_command();
- } else {
- # basic authentication failed
- list($proxy, $ip) = common_client_ip();
-
- common_log(LOG_WARNING, "Failed API auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
- $this->show_basic_auth_error();
- }
- }
- } else {
-
- // Caller might give us a username even if not required
- if (isset($this->auth_user)) {
- $user = User::staticGet('nickname', $this->auth_user);
- if ($user) {
- $this->user = $user;
- }
- # Twitter doesn't throw an error if the user isn't found
- }
-
- $this->process_command();
- }
- }
-
- function process_command()
- {
- $action = "twitapi$this->api_action";
- $actionfile = INSTALLDIR."/actions/$action.php";
-
- if (file_exists($actionfile)) {
- require_once($actionfile);
- $action_class = ucfirst($action)."Action";
- $action_obj = new $action_class();
-
- if (!$action_obj->prepare($this->args)) {
- return;
- }
-
- if (method_exists($action_obj, $this->api_method)) {
- $apidata = array( 'content-type' => $this->content_type,
- 'api_method' => $this->api_method,
- 'api_arg' => $this->api_arg,
- 'user' => $this->user);
-
- call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata);
- } else {
- $this->clientError("API method not found!", $code=404);
- }
- } else {
- $this->clientError("API method not found!", $code=404);
- }
- }
-
- // Whitelist of API methods that don't need authentication
- function requires_auth()
- {
- static $noauth = array( 'statuses/public_timeline',
- 'statuses/show',
- 'users/show',
- 'help/test',
- 'help/downtime_schedule',
- 'statusnet/version',
- 'statusnet/config',
- 'statusnet/wadl',
- 'tags/timeline',
- 'oembed/oembed',
- 'groups/show',
- 'groups/timeline',
- 'groups/list_all',
- 'groups/membership',
- 'groups/is_member',
- 'groups/timeline');
-
- static $bareauth = array('statuses/user_timeline',
- 'statuses/friends_timeline',
- 'statuses/home_timeline',
- 'statuses/friends',
- 'statuses/replies',
- 'statuses/mentions',
- 'statuses/followers',
- 'favorites/favorites',
- 'friendships/show',
- 'groups/list_groups');
-
- $fullname = "$this->api_action/$this->api_method";
-
- // If the site is "private", all API methods except statusnet/config
- // need authentication
-
- if (common_config('site', 'private')) {
- return $fullname != 'statusnet/config' || false;
- }
-
- // bareauth: only needs auth if without an argument or query param specifying user
-
- if (in_array($fullname, $bareauth)) {
-
- // Special case: friendships/show only needs auth if source_id or
- // source_screen_name is not specified as a param
-
- if ($fullname == 'friendships/show') {
-
- $source_id = $this->arg('source_id');
- $source_screen_name = $this->arg('source_screen_name');
-
- if (empty($source_id) && empty($source_screen_name)) {
- return true;
- }
-
- return false;
- }
-
- // if all of these are empty, auth is required
-
- $id = $this->arg('id');
- $user_id = $this->arg('user_id');
- $screen_name = $this->arg('screen_name');
-
- if (empty($this->api_arg) &&
- empty($id) &&
- empty($user_id) &&
- empty($screen_name)) {
- return true;
- } else {
- return false;
- }
-
- } else if (in_array($fullname, $noauth)) {
-
- // noauth: never needs auth
-
- return false;
- } else {
-
- // everybody else needs auth
-
- return true;
- }
- }
-
- function basic_auth_process_header()
- {
- if(isset($_SERVER['AUTHORIZATION']) || isset($_SERVER['HTTP_AUTHORIZATION']))
- {
- $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])?$_SERVER['HTTP_AUTHORIZATION']:$_SERVER['AUTHORIZATION'];
- }
-
- if(isset($_SERVER['PHP_AUTH_USER']))
- {
- $this->auth_user = $_SERVER['PHP_AUTH_USER'];
- $this->auth_pw = $_SERVER['PHP_AUTH_PW'];
- }
- elseif ( isset($authorization_header) && strstr(substr($authorization_header, 0,5),'Basic') )
- {
- // decode the HTTP_AUTHORIZATION header on php-cgi server self
- // on fcgid server the header name is AUTHORIZATION
-
- $auth_hash = base64_decode( substr($authorization_header, 6) );
- list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash);
-
- // set all to NULL on a empty basic auth request
- if($this->auth_user == "") {
- $this->auth_user = NULL;
- $this->auth_pw = NULL;
- }
- }
- else
- {
- $this->auth_user = NULL;
- $this->auth_pw = NULL;
- }
- }
-
- function show_basic_auth_error()
- {
- header('HTTP/1.1 401 Unauthorized');
- $msg = 'Could not authenticate you.';
-
- if ($this->content_type == 'xml') {
- header('Content-Type: application/xml; charset=utf-8');
- $this->startXML();
- $this->elementStart('hash');
- $this->element('error', null, $msg);
- $this->element('request', null, $_SERVER['REQUEST_URI']);
- $this->elementEnd('hash');
- $this->endXML();
- } else if ($this->content_type == 'json') {
- header('Content-Type: application/json; charset=utf-8');
- $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
- print(json_encode($error_array));
- } else {
- header('Content-type: text/plain');
- print "$msg\n";
- }
- }
-
- function isReadOnly($args)
- {
- $apiaction = $args['apiaction'];
- $method = $args['method'];
-
- list($cmdtext, $fmt) = explode('.', $method);
-
- static $write_methods = array(
- 'account' => array('update_location', 'update_delivery_device', 'end_session'),
- 'blocks' => array('create', 'destroy'),
- 'direct_messages' => array('create', 'destroy'),
- 'favorites' => array('create', 'destroy'),
- 'friendships' => array('create', 'destroy'),
- 'help' => array(),
- 'notifications' => array('follow', 'leave'),
- 'statuses' => array('update', 'destroy'),
- 'users' => array()
- );
-
- if (array_key_exists($apiaction, $write_methods)) {
- if (!in_array($cmdtext, $write_methods[$apiaction])) {
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/actions/apiaccountratelimitstatus.php b/actions/apiaccountratelimitstatus.php
new file mode 100644
index 000000000..96179f175
--- /dev/null
+++ b/actions/apiaccountratelimitstatus.php
@@ -0,0 +1,112 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Dummy action that emulates Twitter's rate limit status API resource
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * We don't have a rate limit, but some clients check this method.
+ * It always returns the same thing: 150 hits left.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiAccountRateLimitStatusAction extends ApiBareAuthAction
+{
+
+ /**
+ * Handle the request
+ *
+ * Return some Twitter-ish data about API limits
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ $reset = new DateTime();
+ $reset->modify('+1 hour');
+
+ $this->initDocument($this->format);
+
+ if ($this->format == 'xml') {
+ $this->elementStart('hash');
+ $this->element('remaining-hits', array('type' => 'integer'), 150);
+ $this->element('hourly-limit', array('type' => 'integer'), 150);
+ $this->element(
+ 'reset-time', array('type' => 'datetime'),
+ common_date_iso8601($reset->format('r'))
+ );
+ $this->element(
+ 'reset_time_in_seconds',
+ array('type' => 'integer'),
+ strtotime('+1 hour')
+ );
+ $this->elementEnd('hash');
+ } elseif ($this->format == 'json') {
+ $out = array(
+ 'reset_time_in_seconds' => strtotime('+1 hour'),
+ 'remaining_hits' => 150,
+ 'hourly_limit' => 150,
+ 'reset_time' => common_date_rfc2822(
+ $reset->format('r')
+ )
+ );
+ print json_encode($out);
+ }
+
+ $this->endDocument($this->format);
+ }
+
+}
+
diff --git a/actions/apiaccountverifycredentials.php b/actions/apiaccountverifycredentials.php
new file mode 100644
index 000000000..08b201dbf
--- /dev/null
+++ b/actions/apiaccountverifycredentials.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Test if supplied user credentials are valid.
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Check a user's credentials. Returns an HTTP 200 OK response code and a
+ * representation of the requesting user if authentication was successful;
+ * returns a 401 status code and an error message if not.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiAccountVerifyCredentialsAction extends ApiAuthAction
+{
+
+ /**
+ * Handle the request
+ *
+ * Check whether the credentials are valid and output the result
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ switch ($this->format) {
+ case 'xml':
+ case 'json':
+ $args['id'] = $this->auth_user->id;
+ $action_obj = new ApiUserShowAction();
+ if ($action_obj->prepare($args)) {
+ $action_obj->handle($args);
+ }
+ break;
+ default:
+ header('Content-Type: text/html; charset=utf-8');
+ print 'Authorized';
+ }
+
+ }
+
+}
diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php
new file mode 100644
index 000000000..1cab2df5d
--- /dev/null
+++ b/actions/apiblockcreate.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Block a user via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Blocks the user specified in the ID parameter as the authenticating user.
+ * Destroys a friendship to the blocked user if it exists. Returns the
+ * blocked user in the requested format when successful.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiBlockCreateAction extends ApiAuthAction
+{
+ var $other = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->other = $this->getTargetUser($this->arg('id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Save the new message
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->user) || empty($this->other)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ if ($this->user->hasBlocked($this->other)
+ || $this->user->block($this->other)
+ ) {
+ $this->initDocument($this->format);
+ $this->showProfile($this->other, $this->format);
+ $this->endDocument($this->format);
+ } else {
+ $this->serverError(_('Block user failed.'), 500, $this->format);
+ }
+
+ }
+
+}
+
diff --git a/actions/apiblockdestroy.php b/actions/apiblockdestroy.php
new file mode 100644
index 000000000..16dbf94ca
--- /dev/null
+++ b/actions/apiblockdestroy.php
@@ -0,0 +1,113 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Un-block a user via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Un-blocks the user specified in the ID parameter for the authenticating user.
+ * Returns the un-blocked user in the requested format when successful.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiBlockDestroyAction extends ApiAuthAction
+{
+ var $other = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->other = $this->getTargetUser($this->arg('id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Save the new message
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->user) || empty($this->other)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ if (!$this->user->hasBlocked($this->other)
+ || $this->user->unblock($this->other)
+ ) {
+ $this->initDocument($this->format);
+ $this->showProfile($this->other, $this->format);
+ $this->endDocument($this->format);
+ } else {
+ $this->serverError(_('Unblock user failed.'));
+ }
+
+ }
+
+}
+
diff --git a/actions/apidirectmessage.php b/actions/apidirectmessage.php
new file mode 100644
index 000000000..a21fe86d2
--- /dev/null
+++ b/actions/apidirectmessage.php
@@ -0,0 +1,375 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a the direct messages from or to a user
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Show a list of direct messages from or to the authenticating user
+ *
+ * @category API
+ * @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiDirectMessageAction extends ApiAuthAction
+{
+ var $messages = null;
+ var $title = null;
+ var $subtitle = null;
+ var $link = null;
+ var $selfuri_base = null;
+ var $id = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ $server = common_root_url();
+ $taguribase = common_config('integration', 'taguri');
+
+ if ($this->arg('sent')) {
+
+ // Action was called by /api/direct_messages/sent.format
+
+ $this->title = sprintf(
+ _("Direct messages from %s"),
+ $this->user->nickname
+ );
+ $this->subtitle = sprintf(
+ _("All the direct messages sent from %s"),
+ $this->user->nickname
+ );
+ $this->link = $server . $this->user->nickname . '/outbox';
+ $this->selfuri_base = common_root_url() . 'api/direct_messages/sent';
+ $this->id = "tag:$taguribase:SentDirectMessages:" . $this->user->id;
+ } else {
+ $this->title = sprintf(
+ _("Direct messages to %s"),
+ $this->user->nickname
+ );
+ $this->subtitle = sprintf(
+ _("All the direct messages sent to %s"),
+ $this->user->nickname
+ );
+ $this->link = $server . $this->user->nickname . '/inbox';
+ $this->selfuri_base = common_root_url() . 'api/direct_messages';
+ $this->id = "tag:$taguribase:DirectMessages:" . $this->user->id;
+ }
+
+ $this->messages = $this->getMessages();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Show the messages
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showMessages();
+ }
+
+ /**
+ * Show the messages
+ *
+ * @return void
+ */
+
+ function showMessages()
+ {
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlDirectMessages();
+ break;
+ case 'rss':
+ $this->showRssDirectMessages();
+ break;
+ case 'atom':
+ $this->showAtomDirectMessages();
+ break;
+ case 'json':
+ $this->showJsonDirectMessages();
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getMessages()
+ {
+ $message = new Message();
+
+ if ($this->arg('sent')) {
+ $message->from_profile = $this->user->id;
+ } else {
+ $message->to_profile = $this->user->id;
+ }
+
+ if (!empty($this->max_id)) {
+ $message->whereAdd('id <= ' . $this->max_id);
+ }
+
+ if (!empty($this->since_id)) {
+ $message->whereAdd('id > ' . $this->since_id);
+ }
+
+ if (!empty($since)) {
+ $d = date('Y-m-d H:i:s', $this->since);
+ $message->whereAdd("created > '$d'");
+ }
+
+ $message->orderBy('created DESC, id DESC');
+ $message->limit((($this->page - 1) * $this->count), $this->count);
+ $message->find();
+
+ $messages = array();
+
+ while ($message->fetch()) {
+ $messages[] = clone($message);
+ }
+
+ return $messages;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this notice last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->messages)) {
+ return strtotime($this->messages[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * Shows a list of direct messages as Twitter-style XML array
+ *
+ * @return void
+ */
+
+ function showXmlDirectMessages()
+ {
+ $this->initDocument('xml');
+ $this->elementStart('direct-messages', array('type' => 'array'));
+
+ foreach ($this->messages as $m) {
+ $dm_array = $this->directMessageArray($m);
+ $this->showXmlDirectMessage($dm_array);
+ }
+
+ $this->elementEnd('direct-messages');
+ $this->endDocument('xml');
+ }
+
+ /**
+ * Shows a list of direct messages as a JSON encoded array
+ *
+ * @return void
+ */
+
+ function showJsonDirectMessages()
+ {
+ $this->initDocument('json');
+
+ $dmsgs = array();
+
+ foreach ($this->messages as $m) {
+ $dm_array = $this->directMessageArray($m);
+ array_push($dmsgs, $dm_array);
+ }
+
+ $this->showJsonObjects($dmsgs);
+ $this->endDocument('json');
+ }
+
+ /**
+ * Shows a list of direct messages as RSS items
+ *
+ * @return void
+ */
+
+ function showRssDirectMessages()
+ {
+ $this->initDocument('rss');
+
+ $this->element('title', null, $this->title);
+
+ $this->element('link', null, $this->link);
+ $this->element('description', null, $this->subtitle);
+ $this->element('language', null, 'en-us');
+
+ $this->element(
+ 'atom:link',
+ array(
+ 'type' => 'application/rss+xml',
+ 'href' => $this->selfuri_base . '.rss',
+ 'rel' => self
+ ),
+ null
+ );
+ $this->element('ttl', null, '40');
+
+ foreach ($this->messages as $m) {
+ $entry = $this->rssDirectMessageArray($m);
+ $this->showTwitterRssItem($entry);
+ }
+
+ $this->endTwitterRss();
+ }
+
+ /**
+ * Shows a list of direct messages as Atom entries
+ *
+ * @return void
+ */
+
+ function showAtomDirectMessages()
+ {
+ $this->initDocument('atom');
+
+ $this->element('title', null, $this->title);
+ $this->element('id', null, $this->id);
+
+ $selfuri = common_root_url() . 'api/direct_messages.atom';
+
+ $this->element(
+ 'link', array(
+ 'href' => $this->link,
+ 'rel' => 'alternate',
+ 'type' => 'text/html'),
+ null
+ );
+ $this->element(
+ 'link', array(
+ 'href' => $this->selfuri_base . '.atom', 'rel' => 'self',
+ 'type' => 'application/atom+xml'),
+ null
+ );
+ $this->element('updated', null, common_date_iso8601('now'));
+ $this->element('subtitle', null, $this->subtitle);
+
+ foreach ($this->messages as $m) {
+ $entry = $this->rssDirectMessageArray($m);
+ $this->showTwitterAtomEntry($entry);
+ }
+
+ $this->endDocument('atom');
+ }
+
+ /**
+ * An entity tag for this notice
+ *
+ * Returns an Etag based on the action name, language, and
+ * timestamps of the notice
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->messages)) {
+
+ $last = count($this->messages) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ strtotime($this->messages[0]->created),
+ strtotime($this->messages[$last]->created)
+ )
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apidirectmessagenew.php b/actions/apidirectmessagenew.php
new file mode 100644
index 000000000..ca1ee70dd
--- /dev/null
+++ b/actions/apidirectmessagenew.php
@@ -0,0 +1,188 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Send a direct message via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Creates a new direct message from the authenticating user to
+ * the user specified by id.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiDirectMessageNewAction extends ApiAuthAction
+{
+ var $source = null;
+ var $other = null;
+ var $content = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ $this->source = $this->trimmed('source'); // Not supported by Twitter.
+
+ $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
+ if (empty($thtis->source) || in_array($this->source, $reserved_sources)) {
+ $source = 'api';
+ }
+
+ $this->content = $this->trimmed('text');
+
+ $this->user = $this->auth_user;
+
+ $user_param = $this->trimmed('user');
+ $user_id = $this->arg('user_id');
+ $screen_name = $this->trimmed('screen_name');
+
+ if (isset($user_param) || isset($user_id) || isset($screen_name)) {
+ $this->other = $this->getTargetUser($user_param);
+ }
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Save the new message
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->content)) {
+ $this->clientError(
+ _('No message text!'),
+ 406,
+ $this->format
+ );
+ } else {
+ $content_shortened = common_shorten_links($this->content);
+ if (Message::contentTooLong($content_shortened)) {
+ $this->clientError(
+ sprintf(
+ _('That\'s too long. Max message size is %d chars.'),
+ Message::maxContent()
+ ),
+ 406,
+ $this->format
+ );
+ return;
+ }
+ }
+
+ if (empty($this->other)) {
+ $this->clientError(_('Recipient user not found.'), 403, $this->format);
+ return;
+ } else if (!$this->user->mutuallySubscribed($this->other)) {
+ $this->clientError(
+ _('Can\'t send direct messages to users who aren\'t your friend.'),
+ 403,
+ $this->format
+ );
+ return;
+ } else if ($this->user->id == $this->other->id) {
+
+ // Note: sending msgs to yourself is allowed by Twitter
+
+ $errmsg = 'Don\'t send a message to yourself; ' .
+ 'just say it to yourself quietly instead.';
+
+ $this->clientError(_($errmsg), 403, $this->format);
+ return;
+ }
+
+ $message = Message::saveNew(
+ $this->user->id,
+ $this->other->id,
+ html_entity_decode($this->content, ENT_NOQUOTES, 'UTF-8'),
+ $this->source
+ );
+
+ if (is_string($message)) {
+ $this->serverError($message);
+ return;
+ }
+
+ mail_notify_message($message, $this->user, $this->other);
+
+ if ($this->format == 'xml') {
+ $this->showSingleXmlDirectMessage($message);
+ } elseif ($this->format == 'json') {
+ $this->showSingleJsondirectMessage($message);
+ }
+ }
+
+}
+
diff --git a/actions/apifavoritecreate.php b/actions/apifavoritecreate.php
new file mode 100644
index 000000000..436739770
--- /dev/null
+++ b/actions/apifavoritecreate.php
@@ -0,0 +1,168 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Add a notice to a user's list of favorite notices via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Favorites the status specified in the ID parameter as the authenticating user.
+ * Returns the favorite status when successful.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiFavoriteCreateAction extends ApiAuthAction
+{
+ var $notice = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->notice = Notice::staticGet($this->arg('id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->notice)) {
+ $this->clientError(
+ _('No status found with that ID.'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ // Note: Twitter lets you fave things repeatedly via API.
+
+ if ($this->user->hasFave($this->notice)) {
+ $this->clientError(
+ _('This status is already a favorite!'),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
+ $fave = Fave::addNew($this->user, $this->notice);
+
+ if (empty($fave)) {
+ $this->clientError(
+ _('Could not create favorite.'),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
+ $this->notify($fave, $this->notice, $this->user);
+ $this->user->blowFavesCache();
+
+ if ($this->format == 'xml') {
+ $this->showSingleXmlStatus($this->notice);
+ } elseif ($this->format == 'json') {
+ $this->show_single_json_status($this->notice);
+ }
+ }
+
+ /**
+ * Notify the author of the favorite that the user likes their notice
+ *
+ * @param Favorite $fave the favorite in question
+ * @param Notice $notice the notice that's been faved
+ * @param User $user the user doing the favoriting
+ *
+ * @return void
+ */
+ function notify($fave, $notice, $user)
+ {
+ $other = User::staticGet('id', $notice->profile_id);
+ if ($other && $other->id != $user->id) {
+ if ($other->email && $other->emailnotifyfav) {
+ mail_notify_fave($other, $user, $notice);
+ }
+ // XXX: notify by IM
+ // XXX: notify by SMS
+ }
+ }
+
+}
diff --git a/actions/apifavoritedestroy.php b/actions/apifavoritedestroy.php
new file mode 100644
index 000000000..f131d1c7f
--- /dev/null
+++ b/actions/apifavoritedestroy.php
@@ -0,0 +1,150 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Remote a notice from a user's list of favorite notices via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Un-favorites the status specified in the ID parameter as the authenticating user.
+ * Returns the un-favorited status in the requested format when successful.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiFavoriteDestroyAction extends ApiAuthAction
+{
+
+ var $notice = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->notice = Notice::staticGet($this->arg('id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->notice)) {
+ $this->clientError(
+ _('No status found with that ID.'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ $fave = new Fave();
+ $fave->user_id = $this->user->id;
+ $fave->notice_id = $this->notice->id;
+
+ if (!$fave->find(true)) {
+ $this->clientError(
+ _('That status is not a favorite!'),
+ 403,
+ $this->favorite
+ );
+ return;
+ }
+
+ $result = $fave->delete();
+
+ if (!$result) {
+ common_log_db_error($fave, 'DELETE', __FILE__);
+ $this->clientError(
+ _('Could not delete favorite.'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ $this->user->blowFavesCache();
+
+ if ($this->format == 'xml') {
+ $this->showSingleXmlStatus($this->notice);
+ } elseif ($this->format == 'json') {
+ $this->show_single_json_status($this->notice);
+ }
+ }
+
+}
diff --git a/actions/apifriendshipscreate.php b/actions/apifriendshipscreate.php
new file mode 100644
index 000000000..a824e734b
--- /dev/null
+++ b/actions/apifriendshipscreate.php
@@ -0,0 +1,137 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Subscribe to a user via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Allows the authenticating users to follow (subscribe) the user specified in
+ * the ID parameter. Returns the befriended user in the requested format when
+ * successful. Returns a string describing the failure condition when unsuccessful.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiFriendshipsCreateAction extends ApiAuthAction
+{
+ var $other = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->other = $this->getTargetUser($id);
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->other)) {
+ $this->clientError(
+ _('Could not follow user: User not found.'),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
+ if ($this->user->isSubscribed($this->other)) {
+ $errmsg = sprintf(
+ _('Could not follow user: %s is already on your list.'),
+ $this->other->nickname
+ );
+ $this->clientError($errmsg, 403, $this->format);
+ return;
+ }
+
+ $result = subs_subscribe_to($this->user, $this->other);
+
+ if (is_string($result)) {
+ $this->clientError($result, 403, $this->format);
+ return;
+ }
+
+ $this->initDocument($this->format);
+ $this->showProfile($this->other, $this->format);
+ $this->endDocument($this->format);
+ }
+
+}
diff --git a/actions/apifriendshipsdestroy.php b/actions/apifriendshipsdestroy.php
new file mode 100644
index 000000000..3d9b7e001
--- /dev/null
+++ b/actions/apifriendshipsdestroy.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Unsubscribe to a user via API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Allows the authenticating users to unfollow (unsubscribe) the user specified in
+ * the ID parameter. Returns the unfollowed user in the requested format when
+ * successful. Returns a string describing the failure condition when unsuccessful.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiFriendshipsDestroyAction extends ApiAuthAction
+{
+ var $other = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->other = $this->getTargetUser($id);
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->other)) {
+ $this->clientError(
+ _('Could not unfollow user: User not found.'),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
+ // Don't allow unsubscribing from yourself!
+
+ if ($this->user->id == $this->other->id) {
+ $this->clientError(
+ _("You cannot unfollow yourself!"),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
+ $result = subs_unsubscribe_user($this->user, $this->other->nickname);
+
+ if (is_string($result)) {
+ $this->clientError($result, 403, $this->format);
+ return;
+ }
+
+ $this->initDocument($this->format);
+ $this->showProfile($this->other, $this->format);
+ $this->endDocument($this->format);
+ }
+
+}
diff --git a/actions/apifriendshipsexists.php b/actions/apifriendshipsexists.php
new file mode 100644
index 000000000..ae50c512c
--- /dev/null
+++ b/actions/apifriendshipsexists.php
@@ -0,0 +1,128 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show whether there is a friendship between two users
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Tests for the existence of friendship between two users. Will return true if
+ * user_a follows user_b, otherwise will return false.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiFriendshipsExistsAction extends ApiAction
+{
+ var $user_a = null;
+ var $user_b = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $user_a_id = $this->trimmed('user_a');
+ $user_b_id = $this->trimmed('user_b');
+
+ common_debug("user_a = " . $user_a_id);
+ common_debug("user_b = " . $user_b_id);
+
+
+ $this->user_a = $this->getTargetUser($user_a_id);
+
+ if (empty($this->user_a)) {
+ common_debug('gargargra');
+ }
+
+ $this->user_b = $this->getTargetUser($user_b_id);
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (empty($this->user_a) || empty($this->user_b)) {
+ $this->clientError(
+ _('Two user ids or screen_names must be supplied.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ $result = $this->user_a->isSubscribed($this->user_b);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->initDocument('xml');
+ $this->element('friends', null, $result);
+ $this->endDocument('xml');
+ break;
+ case 'json':
+ $this->initDocument('json');
+ print json_encode($result);
+ $this->endDocument('json');
+ break;
+ default:
+ break;
+ }
+ }
+
+}
diff --git a/actions/apifriendshipsshow.php b/actions/apifriendshipsshow.php
new file mode 100644
index 000000000..8fc436738
--- /dev/null
+++ b/actions/apifriendshipsshow.php
@@ -0,0 +1,168 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show information about the relationship between two users
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Outputs detailed information about the relationship between two users
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiFriendshipsShowAction extends ApiBareAuthAction
+{
+ var $source = null;
+ var $target = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $source_id = (int)$this->trimmed('source_id');
+ $source_screen_name = $this->trimmed('source_screen_name');
+ $target_id = (int)$this->trimmed('target_id');
+ $target_screen_name = $this->trimmed('target_screen_name');
+
+ if (!empty($source_id)) {
+ $this->source = User::staticGet($source_id);
+ } elseif (!empty($source_screen_name)) {
+ $this->source = User::staticGet('nickname', $source_screen_name);
+ } else {
+ $this->source = $this->auth_user;
+ }
+
+ if (!empty($target_id)) {
+ $this->target = User::staticGet($target_id);
+ } elseif (!empty($target_screen_name)) {
+ $this->target = User::staticGet('nickname', $target_screen_name);
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Determines whether this API resource requires auth. Overloaded to look
+ * return true in case source_id and source_screen_name are both empty
+ *
+ * @return boolean true or false
+ */
+
+ function requiresAuth()
+ {
+ if (common_config('site', 'private')) {
+ return true;
+ }
+
+ $source_id = $this->trimmed('source_id');
+ $source_screen_name = $this->trimmed('source_screen_name');
+
+ if (empty($source_id) && empty($source_screen_name)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(_('API method not found!'), 404);
+ return;
+ }
+
+ if (empty($this->source)) {
+ $this->clientError(
+ _('Could not determine source user.'),
+ 404
+ );
+ return;
+ }
+
+ if (empty($this->target)) {
+ $this->clientError(
+ _('Could not find target user.'),
+ 404
+ );
+ return;
+ }
+
+ $result = $this->twitterRelationshipArray($this->source, $this->target);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->initDocument('xml');
+ $this->showTwitterXmlRelationship($result[relationship]);
+ $this->endDocument('xml');
+ break;
+ case 'json':
+ $this->initDocument('json');
+ print json_encode($result);
+ $this->endDocument('json');
+ break;
+ default:
+ break;
+ }
+
+ }
+
+}
diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php
new file mode 100644
index 000000000..f66e83073
--- /dev/null
+++ b/actions/apigroupcreate.php
@@ -0,0 +1,372 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Create a group via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Make a new group. Sets the authenticated user as the administrator of the group.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupCreateAction extends ApiAuthAction
+{
+ var $group = null;
+ var $nickname = null;
+ var $fullname = null;
+ var $homepage = null;
+ var $description = null;
+ var $location = null;
+ var $aliasstring = null;
+ var $aliases = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+
+ $this->nickname = $this->arg('nickname');
+ $this->fullname = $this->arg('full_name');
+ $this->homepage = $this->arg('homepage');
+ $this->description = $this->arg('description');
+ $this->location = $this->arg('location');
+ $this->aliasstring = $this->arg('aliases');
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Save the new group
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ if ($this->validateParams() == false) {
+ return;
+ }
+
+ $group = new User_group();
+
+ $group->query('BEGIN');
+
+ $group->nickname = $this->nickname;
+ $group->fullname = $this->fullname;
+ $group->homepage = $this->homepage;
+ $group->description = $this->description;
+ $group->location = $this->location;
+ $group->created = common_sql_now();
+
+ $result = $group->insert();
+
+ if (!$result) {
+ common_log_db_error($group, 'INSERT', __FILE__);
+ $this->serverError(
+ _('Could not create group.'),
+ 500,
+ $this->format
+ );
+ return;
+ }
+
+ $result = $group->setAliases($this->aliases);
+
+ if (!$result) {
+ $this->serverError(
+ _('Could not create aliases.'),
+ 500,
+ $this->format
+ );
+ return;
+ }
+
+ $member = new Group_member();
+
+ $member->group_id = $group->id;
+ $member->profile_id = $this->user->id;
+ $member->is_admin = 1;
+ $member->created = $group->created;
+
+ $result = $member->insert();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ $this->serverError(
+ _('Could not set group membership.'),
+ 500,
+ $this->format
+ );
+ return;
+ }
+
+ $group->query('COMMIT');
+
+ switch($this->format) {
+ case 'xml':
+ $this->showSingleXmlGroup($group);
+ break;
+ case 'json':
+ $this->showSingleJsonGroup($group);
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+
+ }
+
+ /**
+ * Validate params for the new group
+ *
+ * @return void
+ */
+
+ function validateParams()
+ {
+ $valid = Validate::string(
+ $this->nickname, array(
+ 'min_length' => 1,
+ 'max_length' => 64,
+ 'format' => NICKNAME_FMT
+ )
+ );
+
+ if (!$valid) {
+ $this->clientError(
+ _(
+ 'Nickname must have only lowercase letters ' .
+ 'and numbers and no spaces.'
+ ),
+ 403,
+ $this->format
+ );
+ return false;
+ } elseif ($this->groupNicknameExists($this->nickname)) {
+ $this->clientError(
+ _('Nickname already in use. Try another one.'),
+ 403,
+ $this->format
+ );
+ return false;
+ } else if (!User_group::allowedNickname($this->nickname)) {
+ $this->clientError(
+ _('Not a valid nickname.'),
+ 403,
+ $this->format
+ );
+ return false;
+
+ } elseif (
+ !is_null($this->homepage)
+ && strlen($this->homepage) > 0
+ && !Validate::uri(
+ $this->homepage, array(
+ 'allowed_schemes' =>
+ array('http', 'https')
+ )
+ )) {
+ $this->clientError(
+ _('Homepage is not a valid URL.'),
+ 403,
+ $this->format
+ );
+ return false;
+ } elseif (
+ !is_null($this->fullname)
+ && mb_strlen($this->fullname) > 255) {
+ $this->clientError(
+ _('Full name is too long (max 255 chars).'),
+ 403,
+ $this->format
+ );
+ return false;
+ } elseif (User_group::descriptionTooLong($this->description)) {
+ $this->clientError(
+ sprintf(
+ _('Description is too long (max %d chars).'),
+ User_group::maxDescription()
+ ),
+ 403,
+ $this->format
+ );
+ return false;
+ } elseif (
+ !is_null($this->location)
+ && mb_strlen($this->location) > 255) {
+ $this->clientError(
+ _('Location is too long (max 255 chars).'),
+ 403,
+ $this->format
+ );
+ return false;
+ }
+
+ if (!empty($this->aliasstring)) {
+ $this->aliases = array_map(
+ 'common_canonical_nickname',
+ array_unique(preg_split('/[\s,]+/', $this->aliasstring))
+ );
+ } else {
+ $this->aliases = array();
+ }
+
+ if (count($this->aliases) > common_config('group', 'maxaliases')) {
+ $this->clientError(
+ sprintf(
+ _('Too many aliases! Maximum %d.'),
+ common_config('group', 'maxaliases')
+ ),
+ 403,
+ $this->format
+ );
+ return false;
+ }
+
+ foreach ($this->aliases as $alias) {
+
+ $valid = Validate::string(
+ $alias, array(
+ 'min_length' => 1,
+ 'max_length' => 64,
+ 'format' => NICKNAME_FMT
+ )
+ );
+
+ if (!$valid) {
+ $this->clientError(
+ sprintf(_('Invalid alias: "%s"'), $alias),
+ 403,
+ $this->format
+ );
+ return false;
+ }
+ if ($this->groupNicknameExists($alias)) {
+ $this->clientError(
+ sprintf(
+ _('Alias "%s" already in use. Try another one.'),
+ $alias
+ ),
+ 403,
+ $this->format
+ );
+ return false;
+ }
+
+ // XXX assumes alphanum nicknames
+
+ if (strcmp($alias, $this->nickname) == 0) {
+ $this->clientError(
+ _('Alias can\'t be the same as nickname.'),
+ 403,
+ $this->format
+ );
+ return false;
+ }
+ }
+
+ // Evarything looks OK
+
+ return true;
+ }
+
+ /**
+ * Check to see whether a nickname is already in use by a group
+ *
+ * @param String $nickname The nickname in question
+ *
+ * @return boolean true or false
+ */
+
+ function groupNicknameExists($nickname)
+ {
+ $group = User_group::staticGet('nickname', $nickname);
+
+ if (!empty($group)) {
+ return true;
+ }
+
+ $alias = Group_alias::staticGet('alias', $nickname);
+
+ if (!empty($alias)) {
+ return true;
+ }
+
+ return false;
+ }
+
+}
diff --git a/actions/apigroupismember.php b/actions/apigroupismember.php
new file mode 100644
index 000000000..a8a40a6b3
--- /dev/null
+++ b/actions/apigroupismember.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Check to see whether a user a member of a group
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Returns whether a user is a member of a specified group.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupIsMemberAction extends ApiBareAuthAction
+{
+ var $group = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->getTargetUser(null);
+ $this->group = $this->getTargetGroup(null);
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Save the new message
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ if (empty($this->group)) {
+ $this->clientError('Group not found!', 404, $this->format);
+ return false;
+ }
+
+ $is_member = $this->user->isMember($this->group);
+
+ switch($this->format) {
+ case 'xml':
+ $this->initDocument('xml');
+ $this->element('is_member', null, $is_member);
+ $this->endDocument('xml');
+ break;
+ case 'json':
+ $this->initDocument('json');
+ $this->showJsonObjects(array('is_member' => $is_member));
+ $this->endDocument('json');
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 400,
+ $this->format
+ );
+ break;
+ }
+ }
+
+}
diff --git a/actions/apigroupjoin.php b/actions/apigroupjoin.php
new file mode 100644
index 000000000..071cd9290
--- /dev/null
+++ b/actions/apigroupjoin.php
@@ -0,0 +1,163 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Join a group via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Joins the authenticated user to the group speicified by ID
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupJoinAction extends ApiAuthAction
+{
+ var $group = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->group = $this->getTargetGroup($this->arg('id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Save the new message
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ if (empty($this->group)) {
+ $this->clientError('Group not found!', 404, $this->format);
+ return false;
+ }
+
+ if ($this->user->isMember($this->group)) {
+ $this->clientError(
+ _('You are already a member of that group.'),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
+ if (Group_block::isBlocked($this->group, $this->user->getProfile())) {
+ $this->clientError(
+ _('You have been blocked from that group by the admin.'),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
+ $member = new Group_member();
+
+ $member->group_id = $this->group->id;
+ $member->profile_id = $this->user->id;
+ $member->created = common_sql_now();
+
+ $result = $member->insert();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ $this->serverError(
+ sprintf(
+ _('Could not join user %s to group %s.'),
+ $this->user->nickname,
+ $this->group->nickname
+ )
+ );
+ return;
+ }
+
+ switch($this->format) {
+ case 'xml':
+ $this->show_single_xml_group($this->group);
+ break;
+ case 'json':
+ $this->showSingleJsonGroup($this->group);
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+ }
+
+}
diff --git a/actions/apigroupleave.php b/actions/apigroupleave.php
new file mode 100644
index 000000000..0d4bb9e4d
--- /dev/null
+++ b/actions/apigroupleave.php
@@ -0,0 +1,149 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Leave a group via the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Removes the authenticated user from the group specified by ID
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupLeaveAction extends ApiAuthAction
+{
+ var $group = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->group = $this->getTargetGroup($this->arg('id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Save the new message
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ if (empty($this->group)) {
+ $this->clientError('Group not found!', 404, $this->format);
+ return false;
+ }
+
+ $member = new Group_member();
+
+ $member->group_id = $this->group->id;
+ $member->profile_id = $this->auth->id;
+
+ if (!$member->find(true)) {
+ $this->serverError(_('You are not a member of this group.'));
+ return;
+ }
+
+ $result = $member->delete();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ $this->serverError(
+ sprintf(
+ _('Could not remove user %s to group %s.'),
+ $this->user->nickname,
+ $this->$group->nickname
+ )
+ );
+ return;
+ }
+
+ switch($this->format) {
+ case 'xml':
+ $this->show_single_xml_group($this->group);
+ break;
+ case 'json':
+ $this->showSingleJsonGroup($this->group);
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+ }
+
+}
diff --git a/actions/apigrouplist.php b/actions/apigrouplist.php
new file mode 100644
index 000000000..c529c1e40
--- /dev/null
+++ b/actions/apigrouplist.php
@@ -0,0 +1,223 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Check to see whether a user a member of a group
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Returns whether a user is a member of a specified group.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupListAction extends ApiBareAuthAction
+{
+ var $groups = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->getTargetUser($id);
+ $this->groups = $this->getGroups();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Show the user's groups
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s's groups"), $this->user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Groups";
+ $link = common_local_url(
+ 'usergroups',
+ array('nickname' => $this->user->nickname)
+ );
+ $subtitle = sprintf(
+ _("Groups %s is a member of on %s."),
+ $this->user->nickname,
+ $sitename
+ );
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlGroups($this->groups);
+ break;
+ case 'rss':
+ $this->showRssGroups($this->groups, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() . 'api/statusnet/groups/list/' .
+ $this->user->id . '.atom';
+ $this->showAtomGroups(
+ $this->groups,
+ $title,
+ $id,
+ $link,
+ $subtitle,
+ $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonGroups($this->groups);
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+
+ }
+
+ /**
+ * Get groups
+ *
+ * @return array groups
+ */
+
+ function getGroups()
+ {
+ $groups = array();
+
+ $group = $this->user->getGroups(
+ ($this->page - 1) * $this->count,
+ $this->count,
+ $this->since_id,
+ $this->max_id,
+ $this->since
+ );
+
+ while ($group->fetch()) {
+ $groups[] = clone($group);
+ }
+
+ return $groups;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest group the user has joined
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->groups) && (count($this->groups) > 0)) {
+ return strtotime($this->groups[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this list of groups
+ *
+ * Returns an Etag based on the action name, language, user ID and
+ * timestamps of the first and last group the user has joined
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->groups) && (count($this->groups) > 0)) {
+
+ $last = count($this->groups) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ strtotime($this->groups[0]->created),
+ strtotime($this->groups[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php
new file mode 100644
index 000000000..89469f36f
--- /dev/null
+++ b/actions/apigrouplistall.php
@@ -0,0 +1,208 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show the newest groups
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Returns of the lastest 20 groups for the site
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupListAllAction extends ApiAction
+{
+ var $groups = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->getTargetUser($id);
+ $this->groups = $this->getGroups();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Show the user's groups
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s groups"), $sitename);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Groups";
+ $link = common_local_url('groups');
+ $subtitle = sprintf(_("groups on %s"), $sitename);
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlGroups($this->groups);
+ break;
+ case 'rss':
+ $this->showRssGroups($this->groups, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() .
+ 'api/statusnet/groups/list_all.atom';
+ $this->showAtomGroups(
+ $this->groups,
+ $title,
+ $id,
+ $link,
+ $subtitle,
+ $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonGroups($this->groups);
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+
+ }
+
+ /**
+ * Get groups
+ *
+ * @return array groups
+ */
+
+ function getGroups()
+ {
+ $groups = array();
+
+ // XXX: Use the $page, $count, $max_id, $since_id, and $since parameters
+
+ $group = new User_group();
+ $group->orderBy('created DESC');
+ $group->find();
+
+ while ($group->fetch()) {
+ $groups[] = clone($group);
+ }
+
+ return $groups;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the site's latest group
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->groups) && (count($this->groups) > 0)) {
+ return strtotime($this->groups[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this list of groups
+ *
+ * Returns an Etag based on the action name, language, and
+ * timestamps of the first and last group the user has joined
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->groups) && (count($this->groups) > 0)) {
+
+ $last = count($this->groups) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ strtotime($this->groups[0]->created),
+ strtotime($this->groups[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php
new file mode 100644
index 000000000..b31e47b39
--- /dev/null
+++ b/actions/apigroupmembership.php
@@ -0,0 +1,192 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * List a group's members
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * List 20 newest members of the group specified by name or ID.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupMembershipAction extends ApiAction
+{
+ var $group = null;
+ var $profiles = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->group = $this->getTargetGroup($this->arg('id'));
+ $this->profiles = $this->getProfiles();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Show the members of the group
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ // XXX: RSS and Atom
+
+ switch($this->format) {
+ case 'xml':
+ $this->showTwitterXmlUsers($this->profiles);
+ break;
+ case 'json':
+ $this->showJsonUsers($this->profiles);
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+ }
+
+ /**
+ * Fetch the members of a group
+ *
+ * @return array $profiles list of profiles
+ */
+
+ function getProfiles()
+ {
+ $profiles = array();
+
+ $profile = $this->group->getMembers(
+ ($this->page - 1) * $this->count,
+ $this->count,
+ $this->since_id,
+ $this->max_id,
+ $this->since
+ );
+
+ while ($profile->fetch()) {
+ $profiles[] = clone($profile);
+ }
+
+ return $profiles;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this list of profiles last modified?
+ *
+ * @return string datestamp of the lastest profile in the group
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->profiles) && (count($this->profiles) > 0)) {
+ return strtotime($this->profiles[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this list of groups
+ *
+ * Returns an Etag based on the action name, language
+ * the group id, and timestamps of the first and last
+ * user who has joined the group
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->profiles) && (count($this->profiles) > 0)) {
+
+ $last = count($this->profiles) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->group->id,
+ strtotime($this->profiles[0]->created),
+ strtotime($this->profiles[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apigroupshow.php b/actions/apigroupshow.php
new file mode 100644
index 000000000..2bdb22bc4
--- /dev/null
+++ b/actions/apigroupshow.php
@@ -0,0 +1,152 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show information about a group
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Outputs detailed information about the group specified by ID
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiGroupShowAction extends ApiAction
+{
+ var $group = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->group = $this->getTargetGroup($this->arg('id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (empty($this->group)) {
+ $this->clientError(
+ 'Group not found!',
+ 404,
+ $this->format
+ );
+ return;
+ }
+
+ switch($this->format) {
+ case 'xml':
+ $this->show_single_xml_group($this->group);
+ break;
+ case 'json':
+ $this->showSingleJsonGroup($this->group);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), 404, $this->format);
+ break;
+ }
+
+ }
+
+ /**
+ * When was this group last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->group)) {
+ return strtotime($this->group->modified);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this group
+ *
+ * Returns an Etag based on the action name, language, and
+ * timestamps of the notice
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->group)) {
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->group->id,
+ strtotime($this->group->modified))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apihelptest.php b/actions/apihelptest.php
new file mode 100644
index 000000000..e4ef55f2e
--- /dev/null
+++ b/actions/apihelptest.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Test that you can connect to the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Returns the string "ok" in the requested format with a 200 OK HTTP status code.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiHelpTestAction extends ApiAction
+{
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($this->format == 'xml') {
+ $this->initDocument('xml');
+ $this->element('ok', null, 'true');
+ $this->endDocument('xml');
+ } elseif ($this->format == 'json') {
+ $this->initDocument('json');
+ print '"ok"';
+ $this->endDocument('json');
+ } else {
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ }
+ }
+
+}
+
diff --git a/actions/apistatusesdestroy.php b/actions/apistatusesdestroy.php
new file mode 100644
index 000000000..8dc8793b5
--- /dev/null
+++ b/actions/apistatusesdestroy.php
@@ -0,0 +1,154 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Destroy a notice through the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Tom Blankenship <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Deletes one of the authenticating user's statuses (notices).
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Tom Blankenship <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiStatusesDestroyAction extends ApiAuthAction
+{
+ var $status = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->notice_id = (int)$this->trimmed('id');
+
+ if (empty($notice_id)) {
+ $this->notice_id = (int)$this->arg('id');
+ }
+
+ $this->notice = Notice::staticGet((int)$this->notice_id);
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Delete the notice and all related replies
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(_('API method not found!'), $code = 404);
+ return;
+ }
+
+ if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
+ $this->clientError(_('This method requires a POST or DELETE.'),
+ 400, $this->format);
+ return;
+ }
+
+ if (empty($this->notice)) {
+ $this->clientError(_('No status found with that ID.'),
+ 404, $this->format);
+ return;
+ }
+
+ if ($this->user->id == $this->notice->profile_id) {
+ $replies = new Reply;
+ $replies->get('notice_id', $this->notice_id);
+ $replies->delete();
+ $this->notice->delete();
+
+ if ($this->format == 'xml') {
+ $this->showSingleXmlStatus($this->notice);
+ } elseif ($this->format == 'json') {
+ $this->show_single_json_status($this->notice);
+ }
+ } else {
+ $this->clientError(_('You may not delete another user\'s status.'),
+ 403, $this->format);
+ }
+
+ $this->showNotice();
+ }
+
+ /**
+ * Show the deleted notice
+ *
+ * @return void
+ */
+
+ function showNotice()
+ {
+ if (!empty($this->notice)) {
+ if ($this->format == 'xml') {
+ $this->showSingleXmlStatus($this->notice);
+ } elseif ($this->format == 'json') {
+ $this->show_single_json_status($this->notice);
+ }
+ }
+ }
+
+}
diff --git a/actions/apistatusesshow.php b/actions/apistatusesshow.php
new file mode 100644
index 000000000..3be22ca59
--- /dev/null
+++ b/actions/apistatusesshow.php
@@ -0,0 +1,206 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a notice (as a Twitter-style status)
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Tom Blankenship <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Returns the notice specified by id as a Twitter-style status and inline user
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Tom Blankenship <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiStatusesShowAction extends ApiAction
+{
+
+ var $notice_id = null;
+ var $notice = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ // 'id' is an undocumented parameter in Twitter's API. Several
+ // clients make use of it, so we support it too.
+
+ // show.json?id=12345 takes precedence over /show/12345.json
+
+ $this->notice_id = (int)$this->trimmed('id');
+
+ if (empty($notice_id)) {
+ $this->notice_id = (int)$this->arg('id');
+ }
+
+ $this->notice = Notice::staticGet((int)$this->notice_id);
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the notice
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(_('API method not found!'), $code = 404);
+ return;
+ }
+
+ $this->showNotice();
+ }
+
+ /**
+ * Show the notice
+ *
+ * @return void
+ */
+
+ function showNotice()
+ {
+ if (!empty($this->notice)) {
+ if ($this->format == 'xml') {
+ $this->showSingleXmlStatus($this->notice);
+ } elseif ($this->format == 'json') {
+ $this->show_single_json_status($this->notice);
+ }
+ } else {
+
+ // XXX: Twitter just sets a 404 header and doens't bother
+ // to return an err msg
+
+ $deleted = Deleted_notice::staticGet($this->notice_id);
+
+ if (!empty($deleted)) {
+ $this->clientError(
+ _('Status deleted.'),
+ 410,
+ $this->format
+ );
+ } else {
+ $this->clientError(
+ _('No status with that ID found.'),
+ 404,
+ $this->format
+ );
+ }
+ }
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this notice last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notice)) {
+ return strtotime($this->notice->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this notice
+ *
+ * Returns an Etag based on the action name, language, and
+ * timestamps of the notice
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notice)) {
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->notice->id,
+ strtotime($this->notice->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php
new file mode 100644
index 000000000..898a4bd72
--- /dev/null
+++ b/actions/apistatusesupdate.php
@@ -0,0 +1,271 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Post a notice (update your status) through the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Tom Blankenship <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
+
+/**
+ * Updates the authenticating user's status (posts a notice).
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Tom Blankenship <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiStatusesUpdateAction extends ApiAuthAction
+{
+ var $source = null;
+ var $status = null;
+ var $in_reply_to_status_id = null;
+ static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->auth_user;
+ $this->status = $this->trimmed('status');
+ $this->source = $this->trimmed('source');
+
+ if (empty($this->source) || in_array($source, $this->reserved_sources)) {
+ $this->source = 'api';
+ }
+
+ $this->in_reply_to_status_id
+ = intval($this->trimmed('in_reply_to_status_id'));
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Make a new notice for the update, save it, and show it
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(
+ _('This method requires a POST.'),
+ 400, $this->format
+ );
+ return;
+ }
+
+ if (empty($this->status)) {
+ $this->clientError(
+ 'Client must provide a \'status\' parameter with a value.',
+ 400,
+ $this->format
+ );
+ return;
+ }
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ // Workaround for PHP returning empty $_FILES when POST length > PHP settings
+
+ if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) {
+ $this->clientError(_('Unable to handle that much POST data!'));
+ return;
+ }
+
+ $status_shortened = common_shorten_links($this->status);
+
+ if (Notice::contentTooLong($status_shortened)) {
+
+ // Note: Twitter truncates anything over 140, flags the status
+ // as "truncated."
+
+ $this->clientError(
+ sprintf(
+ _('That\'s too long. Max notice size is %d chars.'),
+ Notice::maxContent()
+ ),
+ 406,
+ $this->format
+ );
+
+ return;
+ }
+
+ // Check for commands
+
+ $inter = new CommandInterpreter();
+ $cmd = $inter->handle_command($this->user, $status_shortened);
+
+ if ($cmd) {
+
+ if ($this->supported($cmd)) {
+ $cmd->execute(new Channel());
+ }
+
+ // Cmd not supported? Twitter just returns your latest status.
+ // And, it returns your last status whether the cmd was successful
+ // or not!
+
+ $this->notice = $this->user->getCurrentNotice();
+
+ } else {
+
+ $reply_to = null;
+
+ if (!empty($this->in_reply_to_status_id)) {
+
+ // Check whether notice actually exists
+
+ $reply = Notice::staticGet($this->in_reply_to_status_id);
+
+ if ($reply) {
+ $reply_to = $this->in_reply_to_status_id;
+ } else {
+ $this->clientError(
+ _('Not found'),
+ $code = 404,
+ $this->format
+ );
+ return;
+ }
+ }
+
+ $upload = null;
+
+ try {
+ $upload = MediaFile::fromUpload('media', $this->user);
+ } catch (ClientException $ce) {
+ $this->clientError($ce->getMessage());
+ return;
+ }
+
+ if (isset($upload)) {
+ $status_shortened .= ' ' . $upload->shortUrl();
+
+ if (Notice::contentTooLong($status_shortened)) {
+ $upload->delete();
+ $msg = _(
+ 'Max notice size is %d chars, ' .
+ 'including attachment URL.'
+ );
+ $this->clientError(sprintf($msg, Notice::maxContent()));
+ }
+ }
+
+ $this->notice = Notice::saveNew(
+ $this->user->id,
+ html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'),
+ $this->source,
+ 1,
+ $reply_to
+ );
+
+ if (isset($upload)) {
+ $upload->attachToNotice($this->notice);
+ }
+
+ common_broadcast_notice($this->notice);
+ }
+
+ $this->showNotice();
+ }
+
+ /**
+ * Show the resulting notice
+ *
+ * @return void
+ */
+
+ function showNotice()
+ {
+ if (!empty($this->notice)) {
+ if ($this->format == 'xml') {
+ $this->showSingleXmlStatus($this->notice);
+ } elseif ($this->format == 'json') {
+ $this->show_single_json_status($this->notice);
+ }
+ }
+ }
+
+ /**
+ * Is this command supported when doing an update from the API?
+ *
+ * @param string $cmd the command to check for
+ *
+ * @return boolean true or false
+ */
+
+ function supported($cmd)
+ {
+ static $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand',
+ 'FavCommand', 'OnCommand', 'OffCommand');
+
+ if (in_array(get_class($cmd), $cmdlist)) {
+ return true;
+ }
+
+ return false;
+ }
+
+}
diff --git a/actions/apistatusnetconfig.php b/actions/apistatusnetconfig.php
new file mode 100644
index 000000000..ed1d151bf
--- /dev/null
+++ b/actions/apistatusnetconfig.php
@@ -0,0 +1,142 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Dump of configuration variables
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Gives a full dump of configuration variables for this instance
+ * of StatusNet, minus variables that may be security-sensitive (like
+ * passwords).
+ * URL: http://identi.ca/api/statusnet/config.(xml|json)
+ * Formats: xml, json
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiStatusnetConfigAction extends ApiAction
+{
+ var $keys = array(
+ 'site' => array('name', 'server', 'theme', 'path', 'fancy', 'language',
+ 'email', 'broughtby', 'broughtbyurl', 'closed',
+ 'inviteonly', 'private'),
+ 'license' => array('url', 'title', 'image'),
+ 'nickname' => array('featured'),
+ 'throttle' => array('enabled', 'count', 'timespan'),
+ 'xmpp' => array('enabled', 'server', 'user')
+ );
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->initDocument('xml');
+ $this->elementStart('config');
+
+ // XXX: check that all sections and settings are legal XML elements
+
+ common_debug(var_export($this->keys, true));
+
+ foreach ($this->keys as $section => $settings) {
+ $this->elementStart($section);
+ foreach ($settings as $setting) {
+ $value = common_config($section, $setting);
+ if (is_array($value)) {
+ $value = implode(',', $value);
+ } else if ($value === false) {
+ $value = 'false';
+ } else if ($value === true) {
+ $value = 'true';
+ }
+ $this->element($setting, null, $value);
+ }
+ $this->elementEnd($section);
+ }
+ $this->elementEnd('config');
+ $this->endDocument('xml');
+ break;
+ case 'json':
+ $result = array();
+ foreach ($this->keys as $section => $settings) {
+ $result[$section] = array();
+ foreach ($settings as $setting) {
+ $result[$section][$setting]
+ = common_config($section, $setting);
+ }
+ }
+ $this->initDocument('json');
+ $this->showJsonObjects($result);
+ $this->endDocument('json');
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+ }
+
+}
+
diff --git a/actions/apistatusnetversion.php b/actions/apistatusnetversion.php
new file mode 100644
index 000000000..e73ab983b
--- /dev/null
+++ b/actions/apistatusnetversion.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * A version stamp for the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Returns a version number for this version of StatusNet, which
+ * should make things a bit easier for upgrades.
+ * URL: http://identi.ca/api/statusnet/version.(xml|json)
+ * Formats: xml, js
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiStatusnetVersionAction extends ApiAction
+{
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->initDocument('xml');
+ $this->element('version', null, STATUSNET_VERSION);
+ $this->endDocument('xml');
+ break;
+ case 'json':
+ $this->initDocument('json');
+ print '"'.STATUSNET_VERSION.'"';
+ $this->endDocument('json');
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+ }
+
+}
+
diff --git a/actions/apisubscriptions.php b/actions/apisubscriptions.php
new file mode 100644
index 000000000..bc68dd192
--- /dev/null
+++ b/actions/apisubscriptions.php
@@ -0,0 +1,266 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Base class for showing subscription information in the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * This class outputs a list of profiles as Twitter-style user and status objects.
+ * It is used by the API methods /api/statuses/(friends|followers). To support the
+ * social graph methods it also can output a simple list of IDs.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiSubscriptionsAction extends ApiBareAuthAction
+{
+ var $profiles = null;
+ var $tag = null;
+ var $lite = null;
+ var $ids_only = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->tag = $this->arg('tag');
+
+ // Note: Twitter no longer supports 'lite'
+ $this->lite = $this->arg('lite');
+
+ $this->ids_only = $this->arg('ids_only');
+
+ // If called as a social graph method, show 5000 per page, otherwise 100
+
+ $this->count = isset($this->ids_only) ?
+ 5000 : (int)$this->arg('count', 100);
+
+ $this->user = $this->getTargetUser($this->arg('id'));
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return false;
+ }
+
+ $this->profiles = $this->getProfiles();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Show the profiles
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(_('API method not found!'), $code = 404);
+ return;
+ }
+
+ $this->initDocument($this->format);
+
+ if (isset($this->ids_only)) {
+ $this->showIds();
+ } else {
+ $this->showProfiles(isset($this->lite) ? false : true);
+ }
+
+ $this->endDocument($this->format);
+ }
+
+ /**
+ * Get profiles - should get overrrided
+ *
+ * @return array Profiles
+ */
+
+ function getProfiles()
+ {
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest profile in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->profiles) && (count($this->profiles) > 0)) {
+ return strtotime($this->profiles[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this action
+ *
+ * Returns an Etag based on the action name, language, user ID, and
+ * timestamps of the first and last profiles in the subscriptions list
+ * There's also an indicator to show whether this action is being called
+ * as /api/statuses/(friends|followers) or /api/(friends|followers)/ids
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->profiles) && (count($this->profiles) > 0)) {
+
+ $last = count($this->profiles) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ isset($this->ids_only) ? 'IDs' : 'Profiles',
+ strtotime($this->profiles[0]->created),
+ strtotime($this->profiles[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+ /**
+ * Show the profiles as Twitter-style useres and statuses
+ *
+ * @param boolean $include_statuses Whether to include the latest status
+ * with each user. Default true.
+ *
+ * @return void
+ */
+
+ function showProfiles($include_statuses = true)
+ {
+ switch ($this->format) {
+ case 'xml':
+ $this->elementStart('users', array('type' => 'array'));
+ foreach ($this->profiles as $profile) {
+ $this->showProfile(
+ $profile,
+ $this->format,
+ null,
+ $include_statuses
+ );
+ }
+ $this->elementEnd('users');
+ break;
+ case 'json':
+ $arrays = array();
+ foreach ($this->profiles as $profile) {
+ $arrays[] = $this->twitterUserArray(
+ $profile,
+ $include_statuses
+ );
+ }
+ print json_encode($arrays);
+ break;
+ default:
+ $this->clientError(_('Unsupported format.'));
+ break;
+ }
+ }
+
+ /**
+ * Show the IDs of the profiles only. 5000 per page. To support
+ * the 'social graph' methods: /api/(friends|followers)/ids
+ *
+ * @return void
+ */
+
+ function showIds()
+ {
+ switch ($this->format) {
+ case 'xml':
+ $this->elementStart('ids');
+ foreach ($this->profiles as $profile) {
+ $this->element('id', null, $profile->id);
+ }
+ $this->elementEnd('ids');
+ break;
+ case 'json':
+ $ids = array();
+ foreach ($this->profiles as $profile) {
+ $ids[] = (int)$profile->id;
+ }
+ print json_encode($ids);
+ break;
+ default:
+ $this->clientError(_('Unsupported format.'));
+ break;
+ }
+ }
+
+}
diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php
new file mode 100644
index 000000000..b8ae74f13
--- /dev/null
+++ b/actions/apitimelinefavorites.php
@@ -0,0 +1,237 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a user's favorite 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR.'/lib/apibareauth.php';
+
+/**
+ * Returns the 20 most recent favorite notices for the authenticating user or user
+ * specified by the ID parameter in the requested format.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiTimelineFavoritesAction extends ApiBareAuthAction
+{
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->getTargetUser($this->arg('id'));
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $profile = $this->user->getProfile();
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(
+ _('%s / Favorites from %s'),
+ $sitename,
+ $this->user->nickname
+ );
+
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Favorites:" . $this->user->id;
+ $link = common_local_url(
+ 'favorites',
+ array('nickname' => $this->user->nickname)
+ );
+ $subtitle = sprintf(
+ _('%s updates favorited by %s / %s.'),
+ $sitename,
+ $profile->getBestName(),
+ $this->user->nickname
+ );
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() .
+ ltrim($_SERVER['QUERY_STRING'], 'p=');
+ $this->showAtomTimeline(
+ $this->notices, $title, $id, $link, $subtitle,
+ null, $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
+ $notice = $this->user->favoriteNotices(
+ ($this->page-1) * $this->count,
+ $this->count,
+ true
+ );
+ } else {
+ $notice = $this->user->favoriteNotices(
+ ($this->page-1) * $this->count,
+ $this->count,
+ false
+ );
+ }
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, user ID, and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php
new file mode 100644
index 000000000..1ea35866e
--- /dev/null
+++ b/actions/apitimelinefriends.php
@@ -0,0 +1,247 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show the friends timeline
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Returns the most recent notices (default 20) posted by the target user.
+ * This is the equivalent of 'You and friends' page accessed via Web.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiTimelineFriendsAction extends ApiBareAuthAction
+{
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->getTargetUser($this->arg('id'));
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $profile = $this->user->getProfile();
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s and friends"), $this->user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:FriendsTimeline:" . $this->user->id;
+ $link = common_local_url(
+ 'all', array('nickname' => $this->user->nickname)
+ );
+ $subtitle = sprintf(
+ _('Updates from %1$s and friends on %2$s!'),
+ $this->user->nickname, $sitename
+ );
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ break;
+ case 'atom':
+
+ $target_id = $this->arg('id');
+
+ if (isset($target_id)) {
+ $selfuri = common_root_url() .
+ 'api/statuses/friends_timeline/' .
+ $target_id . '.atom';
+ } else {
+ $selfuri = common_root_url() .
+ 'api/statuses/friends_timeline.atom';
+ }
+
+ $this->showAtomTimeline(
+ $this->notices, $title, $id, $link,
+ $subtitle, null, $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
+ $notice = $this->user->noticeInbox(
+ ($this->page-1) * $this->count,
+ $this->count, $this->since_id,
+ $this->max_id, $this->since
+ );
+ } else {
+ $notice = $this->user->noticesWithFriends(
+ ($this->page-1) * $this->count,
+ $this->count, $this->since_id,
+ $this->max_id, $this->since
+ );
+ }
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, user ID, and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php
new file mode 100644
index 000000000..5d0542918
--- /dev/null
+++ b/actions/apitimelinegroup.php
@@ -0,0 +1,231 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a group'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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Returns the most recent notices (default 20) posted to the group specified by ID
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiTimelineGroupAction extends ApiAction
+{
+
+ var $group = null;
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->group = $this->getTargetGroup($this->arg('id'));
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s timeline"), $this->group->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
+ $link = common_local_url(
+ 'showgroup',
+ array('nickname' => $this->group->nickname)
+ );
+ $subtitle = sprintf(
+ _('Updates from %1$s on %2$s!'),
+ $this->group->nickname,
+ $sitename
+ );
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() .
+ 'api/statusnet/groups/timeline/' .
+ $this->group->nickname . '.atom';
+ $this->showAtomTimeline(
+ $this->notices,
+ $title,
+ $id,
+ $link,
+ $subtitle,
+ null,
+ $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(
+ _('API method not found!'),
+ 404,
+ $this->format
+ );
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ $notice = $this->group->getNotices(
+ ($this->page-1) * $this->count,
+ $this->count,
+ $this->since_id,
+ $this->max_id,
+ $this->since
+ );
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, group ID and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->group->id,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php
new file mode 100644
index 000000000..fe5ff0f28
--- /dev/null
+++ b/actions/apitimelinementions.php
@@ -0,0 +1,233 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show notices mentioning a user (@nickname)
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Returns the most recent (default 20) mentions (status containing @nickname)
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiTimelineMentionsAction extends ApiBareAuthAction
+{
+
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->getTargetUser($this->arg('id'));
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $profile = $this->user->getProfile();
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(
+ _('%1$s / Updates mentioning %2$s'),
+ $sitename, $this->user->nickname
+ );
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Mentions:" . $this->user->id;
+ $link = common_local_url(
+ 'replies',
+ array('nickname' => $this->user->nickname)
+ );
+ $subtitle = sprintf(
+ _('%1$s updates that reply to updates from %2$s / %3$s.'),
+ $sitename, $this->user->nickname, $profile->getBestName()
+ );
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() .
+ ltrim($_SERVER['QUERY_STRING'], 'p=');
+ $this->showAtomTimeline(
+ $this->notices, $title, $id, $link, $subtitle,
+ null, $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ $notice = $this->user->getReplies(
+ ($this->page - 1) * $this->count, $this->count,
+ $this->since_id, $this->max_id, $this->since
+ );
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, user ID, and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php
new file mode 100644
index 000000000..58e267734
--- /dev/null
+++ b/actions/apitimelinepublic.php
@@ -0,0 +1,213 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show the public timeline
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Returns the most recent notices (default 20) posted by everybody
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiTimelinePublicAction extends ApiAction
+{
+
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s public timeline"), $sitename);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:PublicTimeline";
+ $link = common_root_url();
+ $subtitle = sprintf(_("%s updates from everyone!"), $sitename);
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
+ $this->showAtomTimeline(
+ $this->notices, $title, $id, $link,
+ $subtitle, null, $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ $notice = Notice::publicStream(
+ ($this->page - 1) * $this->count, $this->count, $this->since_id,
+ $this->max_id, $this->since
+ );
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php
new file mode 100644
index 000000000..a274daac0
--- /dev/null
+++ b/actions/apitimelinetag.php
@@ -0,0 +1,224 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show the latest notices for a given tag
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Returns the 20 most recent notices tagged by a given tag
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@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/
+ */
+
+class ApiTimelineTagAction extends ApiAction
+{
+
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->tag = $this->arg('tag');
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("Notices tagged with %s"), $this->tag);
+ $link = common_local_url(
+ 'tag',
+ array('tag' => $this->tag)
+ );
+ $subtitle = sprintf(
+ _('Updates tagged with %1$s on %2$s!'),
+ $this->tag,
+ $sitename
+ );
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:TagTimeline:".$tag;
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() .
+ 'api/statusnet/tags/timeline/' .
+ $this->tag . '.atom';
+ $this->showAtomTimeline(
+ $this->notices,
+ $title,
+ $id,
+ $link,
+ $subtitle,
+ null,
+ $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ $notice = Notice_tag::getStream(
+ $this->tag,
+ ($this->page - 1) * $this->count,
+ $this->count + 1
+ );
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->tag,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php
new file mode 100644
index 000000000..285735fd1
--- /dev/null
+++ b/actions/apitimelineuser.php
@@ -0,0 +1,248 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a user's timeline
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Returns the most recent notices (default 20) posted by the authenticating
+ * user. Another user's timeline can be requested via the id parameter. This
+ * is the API equivalent of the user profile web page.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @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/
+ */
+
+class ApiTimelineUserAction extends ApiBareAuthAction
+{
+
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = $this->getTargetUser($this->arg('id'));
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user!'), 404, $this->format);
+ return;
+ }
+
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $profile = $this->user->getProfile();
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s timeline"), $this->user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:UserTimeline:" . $this->user->id;
+ $link = common_local_url(
+ 'showstream',
+ array('nickname' => $this->user->nickname)
+ );
+ $subtitle = sprintf(
+ _('Updates from %1$s on %2$s!'),
+ $this->user->nickname, $sitename
+ );
+
+ // FriendFeed's SUP protocol
+ // Also added RSS and Atom feeds
+
+ $suplink = common_local_url('sup', null, null, $this->user->id);
+ header('X-SUP-ID: ' . $suplink);
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline(
+ $this->notices, $title, $link,
+ $subtitle, $suplink
+ );
+ break;
+ case 'atom':
+ if (isset($apidata['api_arg'])) {
+ $selfuri = common_root_url() .
+ 'api/statuses/user_timeline/' .
+ $apidata['api_arg'] . '.atom';
+ } else {
+ $selfuri = common_root_url() .
+ 'api/statuses/user_timeline.atom';
+ }
+ $this->showAtomTimeline(
+ $this->notices, $title, $id, $link,
+ $subtitle, $suplink, $selfuri
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ $notice = $this->user->getNotices(
+ ($this->page-1) * $this->count, $this->count,
+ $this->since_id, $this->max_id, $this->since
+ );
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, user ID, and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apiuserfollowers.php b/actions/apiuserfollowers.php
new file mode 100644
index 000000000..e8d92a773
--- /dev/null
+++ b/actions/apiuserfollowers.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a user's followers (subscribers)
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Ouputs the authenticating user's followers (subscribers), each with
+ * current Twitter-style status inline. They are ordered by the order
+ * in which they subscribed to the user, 100 at a time.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiUserFollowersAction extends ApiSubscriptionsAction
+{
+ /**
+ * Get the user's subscribers (followers) as an array of profiles
+ *
+ * @return array Profiles
+ */
+
+ function getProfiles()
+ {
+ $offset = ($this->page - 1) * $this->count;
+ $limit = $this->count + 1;
+
+ $subs = null;
+
+ if (isset($this->tag)) {
+ $subs = $this->user->getTaggedSubscribers(
+ $this->tag, $offset, $limit
+ );
+ } else {
+ $subs = $this->user->getSubscribers(
+ $offset,
+ $limit
+ );
+ }
+
+ $profiles = array();
+
+ if (!empty($subs)) {
+ while ($subs->fetch()) {
+ $profiles[] = clone($subs);
+ }
+ }
+
+ return $profiles;
+ }
+
+}
diff --git a/actions/apiuserfriends.php b/actions/apiuserfriends.php
new file mode 100644
index 000000000..741a26e58
--- /dev/null
+++ b/actions/apiuserfriends.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a user's friends (subscriptions)
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Ouputs the authenticating user's friends (subscriptions), each with
+ * current Twitter-style status inline. They are ordered by the date
+ * in which the user subscribed to them, 100 at a time.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @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/
+ */
+
+class ApiUserFriendsAction extends ApiSubscriptionsAction
+{
+ /**
+ * Get the user's subscriptions (friends) as an array of profiles
+ *
+ * @return array Profiles
+ */
+
+ function getProfiles()
+ {
+ $offset = ($this->page - 1) * $this->count;
+ $limit = $this->count + 1;
+
+ $subs = null;
+
+ if (isset($this->tag)) {
+ $subs = $this->user->getTaggedSubscriptions(
+ $this->tag, $offset, $limit
+ );
+ } else {
+ $subs = $this->user->getSubscriptions(
+ $offset,
+ $limit
+ );
+ }
+
+ $profiles = array();
+
+ if (!empty($subs)) {
+ while ($subs->fetch()) {
+ $profiles[] = clone($subs);
+ }
+ }
+
+ return $profiles;
+ }
+
+}
diff --git a/actions/apiusershow.php b/actions/apiusershow.php
new file mode 100644
index 000000000..b3a939b43
--- /dev/null
+++ b/actions/apiusershow.php
@@ -0,0 +1,126 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show a user's profile information
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author mac65 <mac65@mac65.com>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Ouputs information for a user, specified by ID or screen name.
+ * The user's most recent status will be returned inline.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author mac65 <mac65@mac65.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/
+ */
+
+class ApiUserShowAction extends ApiAction
+{
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $email = $this->arg('email');
+
+ // XXX: email field deprecated in Twitter's API
+
+ if (!empty($email)) {
+ $this->user = User::staticGet('email', $email);
+ } else {
+ $this->user = $this->getTargetUser($this->arg('id'));
+ }
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Check the format and show the user info
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if (empty($this->user)) {
+ $this->clientError(_('Not found.'), 404, $this->format);
+ return;
+ }
+
+ if (!in_array($this->format, array('xml', 'json'))) {
+ $this->clientError(_('API method not found!'), $code = 404);
+ return;
+ }
+
+ $profile = $this->user->getProfile();
+
+ if (empty($profile)) {
+ $this->clientError(_('User has no profile.'));
+ return;
+ }
+
+ $twitter_user = $this->twitterUserArray($this->user->getProfile(), true);
+
+ if ($this->format == 'xml') {
+ $this->initDocument('xml');
+ $this->showTwitterXmlUser($twitter_user);
+ $this->endDocument('xml');
+ } elseif ($this->format == 'json') {
+ $this->initDocument('json');
+ $this->showJsonObjects($twitter_user);
+ $this->endDocument('json');
+ }
+
+ }
+
+}
diff --git a/actions/bookmarklet.php b/actions/bookmarklet.php
new file mode 100644
index 000000000..0603a7456
--- /dev/null
+++ b/actions/bookmarklet.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Handler for posting new 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 Bookmarklet
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@status.net>
+ * @copyright 2008-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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/actions/newnotice.php';
+
+/**
+ * Action for posting a notice
+ *
+ * @category Bookmarklet
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@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 BookmarkletAction extends NewnoticeAction
+{
+ function showTitle()
+ {
+ $this->element('title', null, _('Post to ').common_config('site', 'name'));
+ }
+
+ function showHeader()
+ {
+ $this->elementStart('div', array('id' => 'header'));
+ $this->elementStart('address');
+ $this->element('a', array('class' => 'url',
+ 'href' => common_local_url('public')),
+ '');
+ $this->elementEnd('address');
+ if (common_logged_in()) {
+ $this->showNoticeForm();
+ }
+ $this->elementEnd('div');
+ }
+
+ function showCore()
+ {
+ }
+
+ function showFooter()
+ {
+ }
+}
+
diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php
index 201694286..6fd74f3ff 100644
--- a/actions/confirmaddress.php
+++ b/actions/confirmaddress.php
@@ -67,11 +67,7 @@ class ConfirmaddressAction extends Action
parent::handle($args);
if (!common_logged_in()) {
common_set_returnto($this->selfUrl());
- if (!common_config('site', 'openidonly')) {
- common_redirect(common_local_url('login'));
- } else {
- common_redirect(common_local_url('openidlogin'));
- }
+ common_redirect(common_local_url('login'));
return;
}
$code = $this->trimmed('code');
diff --git a/actions/deletenotice.php b/actions/deletenotice.php
index 3d040f2fa..4a48a9c34 100644
--- a/actions/deletenotice.php
+++ b/actions/deletenotice.php
@@ -32,15 +32,45 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/deleteaction.php';
-
-class DeletenoticeAction extends DeleteAction
+class DeletenoticeAction extends Action
{
- var $error = null;
+ var $error = null;
+ var $user = null;
+ var $notice = null;
+ var $profile = null;
+ var $user_profile = null;
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = common_current_user();
+ $notice_id = $this->trimmed('notice');
+ $this->notice = Notice::staticGet($notice_id);
+
+ if (!$this->notice) {
+ common_user_error(_('No such notice.'));
+ exit;
+ }
+
+ $this->profile = $this->notice->getProfile();
+ $this->user_profile = $this->user->getProfile();
+
+ return true;
+ }
function handle($args)
{
parent::handle($args);
+
+ if (!common_logged_in()) {
+ common_user_error(_('Not logged in.'));
+ exit;
+ } else if ($this->notice->profile_id != $this->user_profile->id &&
+ !$this->user->hasRight(Right::deleteOthersNotice)) {
+ common_user_error(_('Can\'t delete this notice.'));
+ exit;
+ }
// XXX: Ajax!
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
diff --git a/actions/doc.php b/actions/doc.php
index 68295234c..836f039d3 100644
--- a/actions/doc.php
+++ b/actions/doc.php
@@ -58,12 +58,24 @@ class DocAction extends Action
function handle($args)
{
parent::handle($args);
- $this->title = $this->trimmed('title');
- $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
- if (!file_exists($this->filename)) {
- $this->clientError(_('No such document.'));
- return;
+
+ $this->title = $this->trimmed('title');
+ $this->output = null;
+
+ if (Event::handle('StartLoadDoc', array(&$this->title, &$this->output))) {
+
+ $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
+ if (!file_exists($this->filename)) {
+ $this->clientError(_('No such document.'));
+ return;
+ }
+
+ $c = file_get_contents($this->filename);
+ $this->output = common_markup_to_html($c);
+
+ Event::handle('EndLoadDoc', array($this->title, &$this->output));
}
+
$this->showPage();
}
@@ -93,9 +105,7 @@ class DocAction extends Action
*/
function showContent()
{
- $c = file_get_contents($this->filename);
- $output = common_markup_to_html($c);
- $this->raw($output);
+ $this->raw($this->output);
}
/**
diff --git a/actions/editgroup.php b/actions/editgroup.php
index b8dac31cb..cf1608035 100644
--- a/actions/editgroup.php
+++ b/actions/editgroup.php
@@ -64,11 +64,6 @@ class EditgroupAction extends GroupDesignAction
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to create a group.'));
return false;
@@ -202,8 +197,8 @@ class EditgroupAction extends GroupDesignAction
} else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
$this->showForm(_('Full name is too long (max 255 chars).'));
return;
- } else if (!is_null($description) && mb_strlen($description) > 140) {
- $this->showForm(_('description is too long (max 140 chars).'));
+ } else if (User_group::descriptionTooLong($description)) {
+ $this->showForm(sprintf(_('description is too long (max %d chars).'), User_group::maxDescription()));
return;
} else if (!is_null($location) && mb_strlen($location) > 255) {
$this->showForm(_('Location is too long (max 255 chars).'));
diff --git a/actions/emailsettings.php b/actions/emailsettings.php
index 6eff06c0d..67b991cdc 100644
--- a/actions/emailsettings.php
+++ b/actions/emailsettings.php
@@ -326,7 +326,7 @@ class EmailsettingsAction extends AccountSettingsAction
$this->showForm(_('Cannot normalize that email address'));
return;
}
- if (!Validate::email($email, true)) {
+ if (!Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(_('Not a valid email address'));
return;
} else if ($user->email == $email) {
diff --git a/actions/favorited.php b/actions/favorited.php
index 5ba508cdf..150b67b0b 100644
--- a/actions/favorited.php
+++ b/actions/favorited.php
@@ -153,8 +153,7 @@ class FavoritedAction extends Action
$message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
}
else {
- $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to add a notice to your favorites!'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
}
$this->elementStart('div', 'guide');
diff --git a/actions/favoritesrss.php b/actions/favoritesrss.php
index 2d5ce9854..62f06e841 100644
--- a/actions/favoritesrss.php
+++ b/actions/favoritesrss.php
@@ -50,11 +50,11 @@ require_once INSTALLDIR.'/lib/rssaction.php';
*/
class FavoritesrssAction extends Rss10Action
{
-
+
/** The user whose favorites to display */
-
+
var $user = null;
-
+
/**
* Find the user to display by supplied nickname
*
@@ -66,7 +66,7 @@ class FavoritesrssAction extends Rss10Action
function prepare($args)
{
parent::prepare($args);
-
+
$nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname);
@@ -74,10 +74,11 @@ class FavoritesrssAction extends Rss10Action
$this->clientError(_('No such user.'));
return false;
} else {
+ $this->notices = $this->getNotices($this->limit);
return true;
}
}
-
+
/**
* Get notices
*
diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php
index 871bc3d2d..b1cec66f4 100644
--- a/actions/finishremotesubscribe.php
+++ b/actions/finishremotesubscribe.php
@@ -1,5 +1,16 @@
<?php
-/*
+/**
+ * Handler for remote subscription finish callback
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
@@ -15,285 +26,121 @@
*
* 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/>.
- */
+ **/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/omb.php');
+require_once INSTALLDIR.'/extlib/libomb/service_consumer.php';
+require_once INSTALLDIR.'/lib/omb.php';
+/**
+ * Handler for remote subscription finish callback
+ *
+ * When a remote user subscribes a local user, a redirect to this action is
+ * issued after the remote user authorized his service to subscribe.
+ *
+ * @category Action
+ * @package Laconica
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://laconi.ca/
+ */
class FinishremotesubscribeAction extends Action
{
+ /**
+ * Class handler.
+ *
+ * @param array $args query arguments
+ *
+ * @return nothing
+ *
+ **/
function handle($args)
{
-
parent::handle($args);
- if (common_logged_in()) {
- $this->clientError(_('You can use the local subscription!'));
- return;
- }
-
- $omb = $_SESSION['oauth_authorization_request'];
+ /* Restore session data. RemotesubscribeAction should have stored
+ this entry. */
+ $service = unserialize($_SESSION['oauth_authorization_request']);
- if (!$omb) {
+ if (!$service) {
$this->clientError(_('Not expecting this response!'));
return;
}
- common_debug('stored request: '.print_r($omb,true), __FILE__);
-
- common_remove_magic_from_request();
- $req = OAuthRequest::from_request('POST', common_local_url('finishuserauthorization'));
-
- $token = $req->get_parameter('oauth_token');
-
- # I think this is the success metric
-
- if ($token != $omb['token']) {
- $this->clientError(_('Not authorized.'));
- return;
- }
-
- $version = $req->get_parameter('omb_version');
-
- if ($version != OMB_VERSION_01) {
- $this->clientError(_('Unknown version of OMB protocol.'));
- return;
- }
-
- $nickname = $req->get_parameter('omb_listener_nickname');
-
- if (!$nickname) {
- $this->clientError(_('No nickname provided by remote server.'));
- return;
- }
-
- $profile_url = $req->get_parameter('omb_listener_profile');
+ common_debug('stored request: '. print_r($service, true), __FILE__);
- if (!$profile_url) {
- $this->clientError(_('No profile URL returned by server.'));
- return;
- }
-
- if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) {
- $this->clientError(_('Invalid profile URL returned by server.'));
- return;
- }
-
- if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) {
- $this->clientError(_('You can use the local subscription!'));
- return;
- }
-
- common_debug('listenee: "'.$omb['listenee'].'"', __FILE__);
-
- $user = User::staticGet('nickname', $omb['listenee']);
+ /* Create user objects for both users. Do it early for request
+ validation. */
+ $user = User::staticGet('uri', $service->getListeneeURI());
if (!$user) {
- $this->clientError(_('User being listened to doesn\'t exist.'));
+ $this->clientError(_('User being listened to does not exist.'));
return;
}
- $other = User::staticGet('uri', $omb['listener']);
+ $other = User::staticGet('uri', $service->getListenerURI());
if ($other) {
$this->clientError(_('You can use the local subscription!'));
return;
}
- $fullname = $req->get_parameter('omb_listener_fullname');
- $homepage = $req->get_parameter('omb_listener_homepage');
- $bio = $req->get_parameter('omb_listener_bio');
- $location = $req->get_parameter('omb_listener_location');
- $avatar_url = $req->get_parameter('omb_listener_avatar');
+ $remote = Remote_profile::staticGet('uri', $service->getListenerURI());
- list($newtok, $newsecret) = $this->access_token($omb);
+ $profile = Profile::staticGet($remote->id);
- if (!$newtok || !$newsecret) {
- $this->clientError(_('Couldn\'t convert request tokens to access tokens.'));
+ if ($user->hasBlocked($profile)) {
+ $this->clientError(_('That user has blocked you from subscribing.'));
return;
}
- # XXX: possible attack point; subscribe and return someone else's profile URI
-
- $remote = Remote_profile::staticGet('uri', $omb['listener']);
-
- if ($remote) {
- $exists = true;
- $profile = Profile::staticGet($remote->id);
- $orig_remote = clone($remote);
- $orig_profile = clone($profile);
- # XXX: compare current postNotice and updateProfile URLs to the ones
- # stored in the DB to avoid (possibly...) above attack
- } else {
- $exists = false;
- $remote = new Remote_profile();
- $remote->uri = $omb['listener'];
- $profile = new Profile();
- }
-
- $profile->nickname = $nickname;
- $profile->profileurl = $profile_url;
-
- if (!is_null($fullname)) {
- $profile->fullname = $fullname;
- }
- if (!is_null($homepage)) {
- $profile->homepage = $homepage;
- }
- if (!is_null($bio)) {
- $profile->bio = $bio;
- }
- if (!is_null($location)) {
- $profile->location = $location;
- }
-
- if ($exists) {
- $profile->update($orig_profile);
- } else {
- $profile->created = DB_DataObject_Cast::dateTime(); # current time
- $id = $profile->insert();
- if (!$id) {
- $this->serverError(_('Error inserting new profile'));
+ /* Perform the handling itself via libomb. */
+ try {
+ $service->finishAuthorization();
+ } catch (OAuthException $e) {
+ if ($e->getMessage() == 'The authorized token does not equal the ' .
+ 'submitted token.') {
+ $this->clientError(_('You are not authorized.'));
return;
- }
- $remote->id = $id;
- }
-
- if ($avatar_url) {
- if (!$this->add_avatar($profile, $avatar_url)) {
- $this->serverError(_('Error inserting avatar'));
- return;
- }
- }
-
- $remote->postnoticeurl = $omb['post_notice_url'];
- $remote->updateprofileurl = $omb['update_profile_url'];
-
- if ($exists) {
- if (!$remote->update($orig_remote)) {
- $this->serverError(_('Error updating remote profile'));
+ } else {
+ $this->clientError(_('Could not convert request token to ' .
+ 'access token.'));
return;
}
- } else {
- $remote->created = DB_DataObject_Cast::dateTime(); # current time
- if (!$remote->insert()) {
- $this->serverError(_('Error inserting remote profile'));
- return;
- }
- }
-
- if ($user->hasBlocked($profile)) {
- $this->clientError(_('That user has blocked you from subscribing.'));
+ } catch (OMB_RemoteServiceException $e) {
+ $this->clientError(_('Remote service uses unknown version of ' .
+ 'OMB protocol.'));
+ return;
+ } catch (Exception $e) {
+ common_debug('Got exception ' . print_r($e, true), __FILE__);
+ $this->clientError($e->getMessage());
return;
}
- $sub = new Subscription();
-
- $sub->subscriber = $remote->id;
- $sub->subscribed = $user->id;
-
- $sub_exists = false;
-
- if ($sub->find(true)) {
- $sub_exists = true;
- $orig_sub = clone($sub);
- } else {
- $sub_exists = false;
- $sub->created = DB_DataObject_Cast::dateTime(); # current time
- }
-
- $sub->token = $newtok;
- $sub->secret = $newsecret;
+ /* The service URLs are not accessible from datastore, so setting them
+ after insertion of the profile. */
+ $orig_remote = clone($remote);
- if ($sub_exists) {
- $result = $sub->update($orig_sub);
- } else {
- $result = $sub->insert();
- }
+ $remote->postnoticeurl =
+ $service->getServiceURI(OMB_ENDPOINT_POSTNOTICE);
+ $remote->updateprofileurl =
+ $service->getServiceURI(OMB_ENDPOINT_UPDATEPROFILE);
- if (!$result) {
- common_log_db_error($sub, ($sub_exists) ? 'UPDATE' : 'INSERT', __FILE__);
- $this->clientError(_('Couldn\'t insert new subscription.'));
- return;
+ if (!$remote->update($orig_remote)) {
+ $this->serverError(_('Error updating remote profile'));
+ return;
}
- # Notify user, if necessary
-
- mail_subscribe_notify_profile($user, $profile);
-
- # Clear the data
+ /* Clear the session data. */
unset($_SESSION['oauth_authorization_request']);
- # If we show subscriptions in reverse chron order, this should
- # show up close to the top of the page
-
+ /* If we show subscriptions in reverse chronological order, the new one
+ should show up close to the top of the page. */
common_redirect(common_local_url('subscribers', array('nickname' =>
$user->nickname)),
303);
}
-
- function add_avatar($profile, $url)
- {
- $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
- copy($url, $temp_filename);
- $imagefile = new ImageFile($profile->id, $temp_filename);
- $filename = Avatar::filename($profile->id,
- image_type_to_extension($imagefile->type),
- null,
- common_timestamp());
- rename($temp_filename, Avatar::path($filename));
- return $profile->setOriginal($filename);
- }
-
- function access_token($omb)
- {
-
- common_debug('starting request for access token', __FILE__);
-
- $con = omb_oauth_consumer();
- $tok = new OAuthToken($omb['token'], $omb['secret']);
-
- common_debug('using request token "'.$tok.'"', __FILE__);
-
- $url = $omb['access_token_url'];
-
- common_debug('using access token url "'.$url.'"', __FILE__);
-
- # XXX: Is this the right thing to do? Strip off GET params and make them
- # POST params? Seems wrong to me.
-
- $parsed = parse_url($url);
- $params = array();
- parse_str($parsed['query'], $params);
-
- $req = OAuthRequest::from_consumer_and_token($con, $tok, "POST", $url, $params);
-
- $req->set_parameter('omb_version', OMB_VERSION_01);
-
- # XXX: test to see if endpoint accepts this signature method
-
- $req->sign_request(omb_hmac_sha1(), $con, $tok);
-
- # We re-use this tool's fetcher, since it's pretty good
-
- common_debug('posting to access token url "'.$req->get_normalized_http_url().'"', __FILE__);
- common_debug('posting request data "'.$req->to_postdata().'"', __FILE__);
-
- $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
- $result = $fetcher->post($req->get_normalized_http_url(),
- $req->to_postdata(),
- array('User-Agent: StatusNet/' . STATUSNET_VERSION));
-
- common_debug('got result: "'.print_r($result,true).'"', __FILE__);
-
- if ($result->status != 200) {
- return null;
- }
-
- parse_str($result->body, $return);
-
- return array($return['oauth_token'], $return['oauth_token_secret']);
- }
}
diff --git a/actions/foafgroup.php b/actions/foafgroup.php
new file mode 100644
index 000000000..f5fd7fe88
--- /dev/null
+++ b/actions/foafgroup.php
@@ -0,0 +1,173 @@
+<?php
+/*
+ * StatusNet the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, 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/>.
+ *
+ * @category Mail
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Toby Inkster <mail@tobyinkster.co.uk>
+ * @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') && !defined('LACONICA')) { exit(1); }
+
+class FoafGroupAction extends Action
+{
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $nickname_arg = $this->arg('nickname');
+
+ if (empty($nickname_arg)) {
+ $this->clientError(_('No such group.'), 404);
+ return false;
+ }
+
+ $this->nickname = common_canonical_nickname($nickname_arg);
+
+ // Permanent redirect on non-canonical nickname
+
+ if ($nickname_arg != $this->nickname) {
+ common_redirect(common_local_url('foafgroup',
+ array('nickname' => $this->nickname)),
+ 301);
+ return false;
+ }
+
+ $this->group = User_group::staticGet('nickname', $this->nickname);
+
+ if (!$this->group) {
+ $this->clientError(_('No such group.'), 404);
+ return false;
+ }
+
+ common_set_returnto($this->selfUrl());
+
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ header('Content-Type: application/rdf+xml');
+
+ $this->startXML();
+ $this->elementStart('rdf:RDF', array('xmlns:rdf' =>
+ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+ 'xmlns:dcterms' =>
+ 'http://purl.org/dc/terms/',
+ 'xmlns:sioc' =>
+ 'http://rdfs.org/sioc/ns#',
+ 'xmlns:foaf' =>
+ 'http://xmlns.com/foaf/0.1/',
+ 'xmlns:statusnet' =>
+ 'http://status.net/ont/',
+ 'xmlns' => 'http://xmlns.com/foaf/0.1/'));
+
+ $this->showPpd(common_local_url('foafgroup', array('nickname' => $this->nickname)), $this->group->permalink());
+
+ $this->elementStart('Group', array('rdf:about' =>
+ $this->group->permalink()));
+ if ($this->group->fullname) {
+ $this->element('name', null, $this->group->fullname);
+ }
+ if ($this->group->description) {
+ $this->element('dcterms:description', null, $this->group->description);
+ }
+ if ($this->group->nickname) {
+ $this->element('dcterms:identifier', null, $this->group->nickname);
+ $this->element('nick', null, $this->group->nickname);
+ }
+ foreach ($this->group->getAliases() as $alias) {
+ $this->element('nick', null, $alias);
+ }
+ if ($this->group->homeUrl()) {
+ $this->element('weblog', array('rdf:resource' => $this->group->homeUrl()));
+ }
+ if ($this->group->homepage) {
+ $this->element('page', array('rdf:resource' => $this->group->homepage));
+ }
+ if ($this->group->homepage_logo) {
+ $this->element('depiction', array('rdf:resource' => $this->group->homepage_logo));
+ }
+
+ $members = $this->group->getMembers();
+ $member_details = array();
+ while ($members->fetch()) {
+ $member_uri = common_local_url('userbyid', array('id'=>$members->id));
+ $member_details[$member_uri] = array(
+ 'nickname' => $members->nickname
+ );
+ $this->element('member', array('rdf:resource' => $member_uri));
+ }
+
+ $admins = $this->group->getAdmins();
+ while ($admins->fetch()) {
+ $admin_uri = common_local_url('userbyid', array('id'=>$admins->id));
+ $member_details[$admin_uri]['is_admin'] = true;
+ $this->element('statusnet:groupAdmin', array('rdf:resource' => $admin_uri));
+ }
+
+ $this->elementEnd('Group');
+
+ ksort($member_details);
+ foreach ($member_details as $uri => $details) {
+ if ($details['is_admin'])
+ {
+ $this->elementStart('Agent', array('rdf:about' => $uri));
+ $this->element('nick', null, $details['nickname']);
+ $this->elementStart('holdsAccount');
+ $this->elementStart('sioc:User', array('rdf:about'=>$uri.'#acct'));
+ $this->elementStart('sioc:has_function');
+ $this->elementStart('statusnet:GroupAdminRole');
+ $this->element('sioc:scope', array('rdf:resource' => $this->group->permalink()));
+ $this->elementEnd('statusnet:GroupAdminRole');
+ $this->elementEnd('sioc:has_function');
+ $this->elementEnd('sioc:User');
+ $this->elementEnd('holdsAccount');
+ $this->elementEnd('Agent');
+ }
+ else
+ {
+ $this->element('Agent', array(
+ 'foaf:nick' => $details['nickname'],
+ 'rdf:about' => $uri,
+ ));
+ }
+ }
+
+ $this->elementEnd('rdf:RDF');
+ $this->endXML();
+ }
+
+ function showPpd($foaf_url, $person_uri)
+ {
+ $this->elementStart('Document', array('rdf:about' => $foaf_url));
+ $this->element('primaryTopic', array('rdf:resource' => $person_uri));
+ $this->elementEnd('Document');
+ }
+
+} \ No newline at end of file
diff --git a/actions/groupbyid.php b/actions/groupbyid.php
index 52cfaddfc..f65bf511a 100644
--- a/actions/groupbyid.php
+++ b/actions/groupbyid.php
@@ -68,11 +68,6 @@ class GroupbyidAction extends Action
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
$id = $this->arg('id');
if (!$id) {
diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php
index cd86e3b05..b87b7d156 100644
--- a/actions/groupdesignsettings.php
+++ b/actions/groupdesignsettings.php
@@ -64,11 +64,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
{
parent::prepare($args);
- if (!common_config('inboxes', 'enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to edit a group.'));
return false;
diff --git a/actions/grouplogo.php b/actions/grouplogo.php
index 63ba769c7..a9dc7eb1d 100644
--- a/actions/grouplogo.php
+++ b/actions/grouplogo.php
@@ -66,11 +66,6 @@ class GrouplogoAction extends GroupDesignAction
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to create a group.'));
return false;
diff --git a/actions/groupmembers.php b/actions/groupmembers.php
index dcbdd3759..b326a0df7 100644
--- a/actions/groupmembers.php
+++ b/actions/groupmembers.php
@@ -179,9 +179,12 @@ class GroupMemberListItem extends ProfileListItem
function showActions()
{
$this->startActions();
- $this->showSubscribeButton();
- $this->showMakeAdminForm();
- $this->showGroupBlockForm();
+ if (Event::handle('StartProfileListItemActionElements', array($this))) {
+ $this->showSubscribeButton();
+ $this->showMakeAdminForm();
+ $this->showGroupBlockForm();
+ Event::handle('EndProfileListItemActionElements', array($this));
+ }
$this->endActions();
}
diff --git a/actions/grouprss.php b/actions/grouprss.php
index 70c1ded48..50e48a67e 100644
--- a/actions/grouprss.php
+++ b/actions/grouprss.php
@@ -76,11 +76,6 @@ class groupRssAction extends Rss10Action
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
$nickname_arg = $this->arg('nickname');
$nickname = common_canonical_nickname($nickname_arg);
@@ -104,6 +99,7 @@ class groupRssAction extends Rss10Action
return false;
}
+ $this->notices = $this->getNotices($this->limit);
return true;
}
diff --git a/actions/groupsearch.php b/actions/groupsearch.php
index 517f12789..55f4cee62 100644
--- a/actions/groupsearch.php
+++ b/actions/groupsearch.php
@@ -82,8 +82,7 @@ class GroupsearchAction extends SearchAction
$message = _('If you can\'t find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
}
else {
- $message = sprintf(_('Why not [register an account](%%%%action.%s%%%%) and [create the group](%%%%action.newgroup%%%%) yourself!'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $message = _('Why not [register an account](%%action.register%%) and [create the group](%%action.newgroup%%) yourself!');
}
$this->elementStart('div', 'guide');
$this->raw(common_markup_to_html($message));
diff --git a/actions/invite.php b/actions/invite.php
index 9fa6a76f6..3015202e9 100644
--- a/actions/invite.php
+++ b/actions/invite.php
@@ -68,7 +68,7 @@ class InviteAction extends CurrentUserDesignAction
foreach ($addresses as $email) {
$email = trim($email);
- if (!Validate::email($email, true)) {
+ if (!Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(sprintf(_('Invalid email address: %s'), $email));
return;
}
@@ -241,7 +241,7 @@ class InviteAction extends CurrentUserDesignAction
common_root_url(),
$personal,
common_local_url('showstream', array('nickname' => $user->nickname)),
- common_local_url((!common_config('site', 'openidonly')) ? 'register' : 'openidlogin', array('code' => $invite->code)));
+ common_local_url('register', array('code' => $invite->code)));
mail_send($recipients, $headers, $body);
}
diff --git a/actions/joingroup.php b/actions/joingroup.php
index 0209dd43f..bf69b2ad1 100644
--- a/actions/joingroup.php
+++ b/actions/joingroup.php
@@ -56,11 +56,6 @@ class JoingroupAction extends Action
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to join a group.'));
return false;
diff --git a/actions/leavegroup.php b/actions/leavegroup.php
index 60b22e147..08fce1509 100644
--- a/actions/leavegroup.php
+++ b/actions/leavegroup.php
@@ -56,11 +56,6 @@ class LeavegroupAction extends Action
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work.'));
- return false;
- }
-
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to leave a group.'));
return false;
diff --git a/actions/login.php b/actions/login.php
index ac8c40c3e..f6d016310 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -67,8 +67,6 @@ class LoginAction extends Action
*
* Switches on request method; either shows the form or handles its input.
*
- * Checks if only OpenID is allowed and redirects to openidlogin if so.
- *
* @param array $args $_REQUEST data
*
* @return void
@@ -77,9 +75,7 @@ class LoginAction extends Action
function handle($args)
{
parent::handle($args);
- if (common_config('site', 'openidonly')) {
- common_redirect(common_local_url('openidlogin'));
- } else if (common_is_real_login()) {
+ if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkLogin();
@@ -259,11 +255,6 @@ class LoginAction extends Action
return _('For security reasons, please re-enter your ' .
'user name and password ' .
'before changing your settings.');
- } else if (common_config('openid', 'enabled')) {
- return _('Login with your username and password. ' .
- 'Don\'t have a username yet? ' .
- '[Register](%%action.register%%) a new account, or ' .
- 'try [OpenID](%%action.openidlogin%%). ');
} else {
return _('Login with your username and password. ' .
'Don\'t have a username yet? ' .
diff --git a/actions/logout.php b/actions/logout.php
index 298b2a484..1e0adae57 100644
--- a/actions/logout.php
+++ b/actions/logout.php
@@ -32,8 +32,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/openid.php';
-
/**
* Logout action class.
*
diff --git a/actions/newgroup.php b/actions/newgroup.php
index 01cb636aa..80da9861a 100644
--- a/actions/newgroup.php
+++ b/actions/newgroup.php
@@ -61,11 +61,6 @@ class NewgroupAction extends Action
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to create a group.'));
return false;
@@ -146,8 +141,8 @@ class NewgroupAction extends Action
} else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
$this->showForm(_('Full name is too long (max 255 chars).'));
return;
- } else if (!is_null($description) && mb_strlen($description) > 140) {
- $this->showForm(_('description is too long (max 140 chars).'));
+ } else if (User_group::descriptionTooLong($description)) {
+ $this->showForm(sprintf(_('description is too long (max %d chars).'), User_group::maxDescription()));
return;
} else if (!is_null($location) && mb_strlen($location) > 255) {
$this->showForm(_('Location is too long (max 255 chars).'));
diff --git a/actions/newmessage.php b/actions/newmessage.php
index 828a339cf..a0b17fc18 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -144,9 +144,10 @@ class NewmessageAction extends Action
} else {
$content_shortened = common_shorten_links($this->content);
- if (mb_strlen($content_shortened) > 140) {
- $this->showForm(_('That\'s too long. ' .
- 'Max message size is 140 chars.'));
+ if (Message::contentTooLong($content_shortened)) {
+ $this->showForm(sprintf(_('That\'s too long. ' .
+ 'Max message size is %d chars.'),
+ Message::maxContent()));
return;
}
}
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 548832eca..fbd7ab6bc 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -33,7 +33,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/noticelist.php';
+require_once INSTALLDIR . '/lib/noticelist.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
/**
* Action for posting new notices
@@ -113,33 +114,6 @@ class NewnoticeAction extends Action
}
}
- function getUploadedFileType() {
- require_once 'MIME/Type.php';
-
- $cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
- $cmd = common_config('attachments', 'filecommand');
-
- $filetype = MIME_Type::autoDetect($_FILES['attach']['tmp_name']);
- if (in_array($filetype, common_config('attachments', 'supported'))) {
- return $filetype;
- }
- $media = MIME_Type::getMedia($filetype);
- if ('application' !== $media) {
- $hint = sprintf(_(' Try using another %s format.'), $media);
- } else {
- $hint = '';
- }
- $this->clientError(sprintf(
- _('%s is not a supported filetype on this server.'), $filetype) . $hint);
- }
-
- function isRespectsQuota($user) {
- $file = new File;
- $ret = $file->isRespectsQuota($user,$_FILES['attach']['size']);
- if (true === $ret) return true;
- $this->clientError($ret);
- }
-
/**
* Save a new notice, based on arguments
*
@@ -160,17 +134,12 @@ class NewnoticeAction extends Action
if (!$content) {
$this->clientError(_('No content!'));
- } else {
- $content_shortened = common_shorten_links($content);
- if (mb_strlen($content_shortened) > 140) {
- $this->clientError(_('That\'s too long. '.
- 'Max notice size is 140 chars.'));
- }
+ return;
}
$inter = new CommandInterpreter();
- $cmd = $inter->handle_command($user, $content_shortened);
+ $cmd = $inter->handle_command($user, $content);
if ($cmd) {
if ($this->boolean('ajax')) {
@@ -181,6 +150,13 @@ class NewnoticeAction extends Action
return;
}
+ $content_shortened = common_shorten_links($content);
+ if (Notice::contentTooLong($content_shortened)) {
+ $this->clientError(sprintf(_('That\'s too long. '.
+ 'Max notice size is %d chars.'),
+ Notice::maxContent()));
+ }
+
$replyto = $this->trimmed('inreplyto');
#If an ID of 0 is wrongly passed here, it will cause a database error,
#so override it...
@@ -188,84 +164,29 @@ class NewnoticeAction extends Action
$replyto = 'false';
}
- if (isset($_FILES['attach']['error'])) {
- switch ($_FILES['attach']['error']) {
- case UPLOAD_ERR_NO_FILE:
- // no file uploaded, nothing to do
- break;
-
- case UPLOAD_ERR_OK:
- $mimetype = $this->getUploadedFileType();
- if (!$this->isRespectsQuota($user)) {
- die('clientError() should trigger an exception before reaching here.');
- }
- break;
-
- case UPLOAD_ERR_INI_SIZE:
- $this->clientError(_('The uploaded file exceeds the upload_max_filesize directive in php.ini.'));
-
- case UPLOAD_ERR_FORM_SIZE:
- $this->clientError(_('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'));
-
- case UPLOAD_ERR_PARTIAL:
- $this->clientError(_('The uploaded file was only partially uploaded.'));
-
- case UPLOAD_ERR_NO_TMP_DIR:
- $this->clientError(_('Missing a temporary folder.'));
-
- case UPLOAD_ERR_CANT_WRITE:
- $this->clientError(_('Failed to write file to disk.'));
-
- case UPLOAD_ERR_EXTENSION:
- $this->clientError(_('File upload stopped by extension.'));
-
- default:
- die('Should never reach here.');
- }
- }
-
- if (isset($mimetype)) {
- $filename = $this->saveFile($mimetype);
- if (empty($filename)) {
- $this->clientError(_('Couldn\'t save file.'));
- }
-
- $fileRecord = $this->storeFile($filename, $mimetype);
+ $upload = null;
+ $upload = MediaFile::fromUpload('attach');
- $fileurl = common_local_url('attachment',
- array('attachment' => $fileRecord->id));
+ if (isset($upload)) {
- // not sure this is necessary -- Zach
- $this->maybeAddRedir($fileRecord->id, $fileurl);
+ $content_shortened .= ' ' . $upload->shortUrl();
- $short_fileurl = common_shorten_url($fileurl);
- if (!$short_fileurl) {
- // todo -- Consider forcing default shortener if none selected?
- $short_fileurl = $fileurl;
+ if (Notice::contentTooLong($content_shortened)) {
+ $upload->delete();
+ $this->clientError(
+ sprintf(
+ _('Max notice size is %d chars, including attachment URL.'),
+ Notice::maxContent()
+ )
+ );
}
- $content_shortened .= ' ' . $short_fileurl;
-
- if (mb_strlen($content_shortened) > 140) {
- $this->deleteFile($filename);
- $this->clientError(_('Max notice size is 140 chars, including attachment URL.'));
- }
-
- // Also, not sure this is necessary -- Zach
- $this->maybeAddRedir($fileRecord->id, $short_fileurl);
}
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
($replyto == 'false') ? null : $replyto);
- if (is_string($notice)) {
- if (isset($filename)) {
- $this->deleteFile($filename);
- }
- $this->clientError($notice);
- }
-
- if (isset($mimetype)) {
- $this->attachFile($notice, $fileRecord);
+ if (isset($upload)) {
+ $upload->attachToNotice($notice);
}
common_broadcast_notice($notice);
@@ -295,87 +216,6 @@ class NewnoticeAction extends Action
}
}
- function saveFile($mimetype) {
-
- $cur = common_current_user();
-
- if (empty($cur)) {
- $this->serverError(_('Somehow lost the login in saveFile'));
- }
-
- $basename = basename($_FILES['attach']['name']);
-
- $filename = File::filename($cur->getProfile(), $basename, $mimetype);
-
- $filepath = File::path($filename);
-
- if (move_uploaded_file($_FILES['attach']['tmp_name'], $filepath)) {
- return $filename;
- } else {
- $this->clientError(_('File could not be moved to destination directory.'));
- }
- }
-
- function deleteFile($filename)
- {
- $filepath = File::path($filename);
- @unlink($filepath);
- }
-
- function storeFile($filename, $mimetype) {
-
- $file = new File;
- $file->filename = $filename;
-
- $file->url = File::url($filename);
-
- $filepath = File::path($filename);
-
- $file->size = filesize($filepath);
- $file->date = time();
- $file->mimetype = $mimetype;
-
- $file_id = $file->insert();
-
- if (!$file_id) {
- common_log_db_error($file, "INSERT", __FILE__);
- $this->clientError(_('There was a database error while saving your file. Please try again.'));
- }
-
- return $file;
- }
-
- function rememberFile($file, $short)
- {
- $this->maybeAddRedir($file->id, $short);
- }
-
- function maybeAddRedir($file_id, $url)
- {
- $file_redir = File_redirection::staticGet('url', $url);
-
- if (empty($file_redir)) {
- $file_redir = new File_redirection;
- $file_redir->url = $url;
- $file_redir->file_id = $file_id;
-
- $result = $file_redir->insert();
-
- if (!$result) {
- common_log_db_error($file_redir, "INSERT", __FILE__);
- $this->clientError(_('There was a database error while saving your file. Please try again.'));
- }
- }
- }
-
- function attachFile($notice, $filerec)
- {
- File_to_post::processNew($filerec->id, $notice->id);
-
- $this->maybeAddRedir($filerec->id,
- common_local_url('file', array('notice' => $notice->id)));
- }
-
/**
* Show an Ajax-y error message
*
diff --git a/actions/noticesearch.php b/actions/noticesearch.php
index 69dcd1a46..79cf572cc 100644
--- a/actions/noticesearch.php
+++ b/actions/noticesearch.php
@@ -121,9 +121,7 @@ class NoticesearchAction extends SearchAction
$message = sprintf(_('Be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q));
}
else {
- $message = sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
- urlencode($q));
+ $message = sprintf(_('Why not [register an account](%%%%action.register%%%%) and be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q));
}
$this->elementStart('div', 'guide');
diff --git a/actions/othersettings.php b/actions/othersettings.php
index f898e2207..d32a2d651 100644
--- a/actions/othersettings.php
+++ b/actions/othersettings.php
@@ -97,19 +97,20 @@ class OthersettingsAction extends AccountSettingsAction
$this->elementStart('fieldset');
$this->hidden('token', common_session_token());
- // I18N
-
- $services = array(
- '' => 'None',
- 'ur1.ca' => 'ur1.ca (free service)',
- '2tu.us' => '2tu.us (free service)',
- 'ptiturl.com' => 'ptiturl.com',
- 'bit.ly' => 'bit.ly',
- 'tinyurl.com' => 'tinyurl.com',
- 'is.gd' => 'is.gd',
- 'snipr.com' => 'snipr.com',
- 'metamark.net' => 'metamark.net'
- );
+ $services=array();
+ global $_shorteners;
+ if($_shorteners){
+ foreach($_shorteners as $name=>$value)
+ {
+ $services[$name]=$name;
+ if(!empty($value['info']['freeService'])){
+ // I18N
+ $services[$name].=' (free service)';
+ }
+ }
+ }
+ asort($services);
+ $services['']='None';
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
diff --git a/actions/postnotice.php b/actions/postnotice.php
index e775ca17e..c2e1c44ca 100644
--- a/actions/postnotice.php
+++ b/actions/postnotice.php
@@ -1,5 +1,16 @@
<?php
-/*
+/**
+ * Handle postnotice action
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
@@ -19,73 +30,67 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/omb.php');
+require_once INSTALLDIR.'/lib/omb.php';
+require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
+/**
+ * Handler for postnotice action
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ */
class PostnoticeAction extends Action
{
+ /**
+ * For initializing members of the class.
+ *
+ * @param array $argarray misc. arguments
+ *
+ * @return boolean true
+ */
+ function prepare($argarray)
+ {
+ parent::prepare($argarray);
+ try {
+ $this->checkNotice();
+ } catch (Exception $e) {
+ $this->clientError($e->getMessage());
+ return false;
+ }
+ return true;
+ }
+
function handle($args)
{
parent::handle($args);
try {
- common_remove_magic_from_request();
- $req = OAuthRequest::from_request('POST', common_local_url('postnotice'));
- # Note: server-to-server function!
- $server = omb_oauth_server();
- list($consumer, $token) = $server->verify_request($req);
- if ($this->save_notice($req, $consumer, $token)) {
- print "omb_version=".OMB_VERSION_01;
- }
- } catch (OAuthException $e) {
+ $srv = new OMB_Service_Provider(null, omb_oauth_datastore(),
+ omb_oauth_server());
+ $srv->handlePostNotice();
+ } catch (Exception $e) {
$this->serverError($e->getMessage());
return;
}
}
- function save_notice(&$req, &$consumer, &$token)
+ function checkNotice()
{
- $version = $req->get_parameter('omb_version');
- if ($version != OMB_VERSION_01) {
- $this->clientError(_('Unsupported OMB version'), 400);
- return false;
- }
- # First, check to see
- $listenee = $req->get_parameter('omb_listenee');
- $remote_profile = Remote_profile::staticGet('uri', $listenee);
- if (!$remote_profile) {
- $this->clientError(_('Profile unknown'), 403);
- return false;
- }
- $sub = Subscription::staticGet('token', $token->key);
- if (!$sub) {
- $this->clientError(_('No such subscription'), 403);
- return false;
- }
- $content = $req->get_parameter('omb_notice_content');
- $content_shortened = common_shorten_links($content);
- if (mb_strlen($content_shortened) > 140) {
+ $content = common_shorten_links($_POST['omb_notice_content']);
+ if (Notice::contentTooLong($content)) {
$this->clientError(_('Invalid notice content'), 400);
return false;
}
- $notice_uri = $req->get_parameter('omb_notice');
- if (!Validate::uri($notice_uri) &&
- !common_valid_tag($notice_uri)) {
- $this->clientError(_('Invalid notice uri'), 400);
- return false;
- }
- $notice_url = $req->get_parameter('omb_notice_url');
- if ($notice_url && !common_valid_http_url($notice_url)) {
- $this->clientError(_('Invalid notice url'), 400);
- return false;
+ $license = $_POST['omb_notice_license'];
+ $site_license = common_config('license', 'url');
+ if ($license && !common_compatible_license($license, $site_license)) {
+ throw new Exception(sprintf(_('Notice license ‘%s’ is not ' .
+ 'compatible with site license ‘%s’.'),
+ $license, $site_license));
}
- $notice = Notice::staticGet('uri', $notice_uri);
- if (!$notice) {
- $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, null, $notice_uri);
- if (is_string($notice)) {
- common_server_serror($notice, 500);
- return false;
- }
- common_broadcast_notice($notice, true);
- }
- return true;
}
}
+?> \ No newline at end of file
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 2d66e9946..0a0cc5997 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -117,9 +117,16 @@ class ProfilesettingsAction extends AccountSettingsAction
_('URL of your homepage, blog, or profile on another site'));
$this->elementEnd('li');
$this->elementStart('li');
+ $maxBio = Profile::maxBio();
+ if ($maxBio > 0) {
+ $bioInstr = sprintf(_('Describe yourself and your interests in %d chars'),
+ $maxBio);
+ } else {
+ $bioInstr = _('Describe yourself and your interests');
+ }
$this->textarea('bio', _('Bio'),
($this->arg('bio')) ? $this->arg('bio') : $profile->bio,
- _('Describe yourself and your interests in 140 chars'));
+ $bioInstr);
$this->elementEnd('li');
$this->elementStart('li');
$this->input('location', _('Location'),
@@ -210,8 +217,9 @@ class ProfilesettingsAction extends AccountSettingsAction
} else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
$this->showForm(_('Full name is too long (max 255 chars).'));
return;
- } else if (!is_null($bio) && mb_strlen($bio) > 140) {
- $this->showForm(_('Bio is too long (max 140 chars).'));
+ } else if (Profile::bioTooLong($bio)) {
+ $this->showForm(sprintf(_('Bio is too long (max %d chars).'),
+ Profile::maxBio()));
return;
} else if (!is_null($location) && mb_strlen($location) > 255) {
$this->showForm(_('Location is too long (max 255 chars).'));
@@ -298,6 +306,16 @@ class ProfilesettingsAction extends AccountSettingsAction
$profile->homepage = $homepage;
$profile->bio = $bio;
$profile->location = $location;
+
+ $loc = Location::fromName($location);
+
+ if (!empty($loc)) {
+ $profile->lat = $loc->lat;
+ $profile->lon = $loc->lon;
+ $profile->location_id = $loc->location_id;
+ $profile->location_ns = $loc->location_ns;
+ }
+
$profile->profileurl = common_profile_url($nickname);
common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__);
diff --git a/actions/public.php b/actions/public.php
index d426648f3..73fad182a 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -114,8 +114,6 @@ class PublicAction extends Action
{
parent::handle($args);
- header('X-XRDS-Location: '. common_local_url('publicxrds'));
-
$this->showPage();
}
@@ -157,22 +155,6 @@ class PublicAction extends Action
}
/**
- * Extra head elements
- *
- * We include a <meta> element linking to the publicxrds page, for OpenID
- * client-side authentication.
- *
- * @return void
- */
-
- function extraHead()
- {
- // for client side of OpenID authentication
- $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
- 'content' => common_local_url('publicxrds')));
- }
-
- /**
* Show tabset for this page
*
* Uses the PublicGroupNav widget
@@ -196,8 +178,7 @@ class PublicAction extends Action
}
else {
if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
- $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to post!'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
}
}
@@ -244,11 +225,10 @@ class PublicAction extends Action
function showAnonymousMessage()
{
if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
- $m = sprintf(_('This is %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
- '[Join now](%%%%action.%s%%%%) to share notices about yourself with friends, family, and colleagues! ' .
- '([Read more](%%%%doc.help%%%%))'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
+ 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
+ '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ' .
+ '([Read more](%%doc.help%%))');
} else {
$m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
'based on the Free Software [StatusNet](http://status.net/) tool.');
diff --git a/actions/publicrss.php b/actions/publicrss.php
index 593888b9f..0c5d061cb 100644
--- a/actions/publicrss.php
+++ b/actions/publicrss.php
@@ -50,8 +50,22 @@ require_once INSTALLDIR.'/lib/rssaction.php';
class PublicrssAction extends Rss10Action
{
/**
+ * Read arguments and initialize members
+ *
+ * @param array $args Arguments from $_REQUEST
+ * @return boolean success
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ $this->notices = $this->getNotices($this->limit);
+ return true;
+ }
+
+ /**
* Initialization.
- *
+ *
* @return boolean true
*/
function init()
@@ -73,7 +87,7 @@ class PublicrssAction extends Rss10Action
while ($notice->fetch()) {
$notices[] = clone($notice);
}
-
+
return $notices;
}
diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php
index 60bb53e27..e7f6ee36c 100644
--- a/actions/publictagcloud.php
+++ b/actions/publictagcloud.php
@@ -72,8 +72,7 @@ class PublictagcloudAction extends Action
$message .= _('Be the first to post one!');
}
else {
- $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to post one!'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $message .= _('Why not [register an account](%%action.register%%) and be the first to post one!');
}
$this->elementStart('div', 'guide');
diff --git a/actions/register.php b/actions/register.php
index eefbc340a..a6c1a903a 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -116,8 +116,6 @@ class RegisterAction extends Action
*
* Checks if registration is closed and shows an error if so.
*
- * Checks if only OpenID is allowed and redirects to openidlogin if so.
- *
* @param array $args $_REQUEST data
*
* @return void
@@ -129,8 +127,6 @@ class RegisterAction extends Action
if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
- } else if (common_config('site', 'openidonly')) {
- common_redirect(common_local_url('openidlogin'));
} else if (common_logged_in()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -195,7 +191,7 @@ class RegisterAction extends Action
if (!$this->boolean('license')) {
$this->showForm(_('You can\'t register if you don\'t '.
'agree to the license.'));
- } else if ($email && !Validate::email($email, true)) {
+ } else if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(_('Not a valid email address.'));
} else if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
@@ -217,8 +213,9 @@ class RegisterAction extends Action
} else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
$this->showForm(_('Full name is too long (max 255 chars).'));
return;
- } else if (!is_null($bio) && mb_strlen($bio) > 140) {
- $this->showForm(_('Bio is too long (max 140 chars).'));
+ } else if (Profile::bioTooLong($bio)) {
+ $this->showForm(sprintf(_('Bio is too long (max %d chars).'),
+ Profile::maxBio()));
return;
} else if (!is_null($location) && mb_strlen($location) > 255) {
$this->showForm(_('Location is too long (max 255 chars).'));
@@ -335,22 +332,11 @@ class RegisterAction extends Action
} else if ($this->error) {
$this->element('p', 'error', $this->error);
} else {
- if (common_config('openid', 'enabled')) {
- $instr =
- common_markup_to_html(_('With this form you can create '.
- ' a new account. ' .
- 'You can then post notices and '.
- 'link up to friends and colleagues. '.
- '(Have an [OpenID](http://openid.net/)? ' .
- 'Try our [OpenID registration]'.
- '(%%action.openidlogin%%)!)'));
- } else {
- $instr =
- common_markup_to_html(_('With this form you can create '.
- ' a new account. ' .
- 'You can then post notices and '.
- 'link up to friends and colleagues.'));
- }
+ $instr =
+ common_markup_to_html(_('With this form you can create '.
+ ' a new account. ' .
+ 'You can then post notices and '.
+ 'link up to friends and colleagues. '));
$this->elementStart('div', 'instructions');
$this->raw($instr);
@@ -463,10 +449,16 @@ class RegisterAction extends Action
'or profile on another site'));
$this->elementEnd('li');
$this->elementStart('li');
+ $maxBio = Profile::maxBio();
+ if ($maxBio > 0) {
+ $bioInstr = sprintf(_('Describe yourself and your interests in %d chars'),
+ $maxBio);
+ } else {
+ $bioInstr = _('Describe yourself and your interests');
+ }
$this->textarea('bio', _('Bio'),
$this->trimmed('bio'),
- _('Describe yourself and your '.
- 'interests in 140 chars'));
+ $bioInstr);
$this->elementEnd('li');
$this->elementStart('li');
$this->input('location', _('Location'),
diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php
index 374392d4a..aee2a5d8e 100644
--- a/actions/remotesubscribe.php
+++ b/actions/remotesubscribe.php
@@ -1,5 +1,16 @@
<?php
-/*
+/**
+ * Handler for remote subscription
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
@@ -15,11 +26,24 @@
*
* 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/>.
- */
+ **/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/omb.php');
+require_once INSTALLDIR.'/lib/omb.php';
+require_once INSTALLDIR.'/extlib/libomb/service_consumer.php';
+require_once INSTALLDIR.'/extlib/libomb/profile.php';
+
+/**
+ * Handler for remote subscription
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ */
class RemotesubscribeAction extends Action
{
@@ -36,7 +60,7 @@ class RemotesubscribeAction extends Action
return false;
}
- $this->nickname = $this->trimmed('nickname');
+ $this->nickname = $this->trimmed('nickname');
$this->profile_url = $this->trimmed('profile_url');
return true;
@@ -47,7 +71,7 @@ class RemotesubscribeAction extends Action
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- # CSRF protection
+ /* Use a session token for CSRF protection. */
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->showForm(_('There was a problem with your session token. '.
@@ -71,13 +95,11 @@ class RemotesubscribeAction extends Action
if ($this->err) {
$this->element('div', 'error', $this->err);
} else {
- $inst = sprintf(_('To subscribe, you can [login](%%%%action.%s%%%%),' .
- ' or [register](%%%%action.%s%%%%) a new ' .
- ' account. If you already have an account ' .
- ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
- ' enter your profile URL below.'),
- (!common_config('site','openidonly')) ? 'login' : 'openidlogin',
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $inst = _('To subscribe, you can [login](%%action.login%%),' .
+ ' or [register](%%action.register%%) a new ' .
+ ' account. If you already have an account ' .
+ ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
+ ' enter your profile URL below.');
$output = common_markup_to_html($inst);
$this->elementStart('div', 'instructions');
$this->raw($output);
@@ -92,8 +114,8 @@ class RemotesubscribeAction extends Action
function showContent()
{
- # id = remotesubscribe conflicts with the
- # button on profile page
+ /* The id 'remotesubscribe' conflicts with the
+ button on profile page. */
$this->elementStart('form', array('id' => 'form_remote_subscribe',
'method' => 'post',
'class' => 'form_settings',
@@ -119,247 +141,50 @@ class RemotesubscribeAction extends Action
function remoteSubscription()
{
- $user = $this->getUser();
-
- if (!$user) {
+ if (!$this->nickname) {
$this->showForm(_('No such user.'));
return;
}
+ $user = User::staticGet('nickname', $this->nickname);
+
$this->profile_url = $this->trimmed('profile_url');
if (!$this->profile_url) {
- $this->showForm(_('No such user.'));
+ $this->showForm(_('No such user'));
return;
}
- if (!Validate::uri($this->profile_url, array('allowed_schemes' => array('http', 'https')))) {
+ if (!common_valid_http_url($this->profile_url)) {
$this->showForm(_('Invalid profile URL (bad format)'));
return;
}
- $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
- $yadis = Auth_Yadis_Yadis::discover($this->profile_url, $fetcher);
-
- if (!$yadis || $yadis->failed) {
- $this->showForm(_('Not a valid profile URL (no YADIS document).'));
- return;
- }
-
- # XXX: a little liberal for sites that accidentally put whitespace before the xml declaration
-
- $xrds =& Auth_Yadis_XRDS::parseXRDS(trim($yadis->response_text));
-
- if (!$xrds) {
- $this->showForm(_('Not a valid profile URL (no XRDS defined).'));
- return;
- }
-
- $omb = $this->getOmb($xrds);
-
- if (!$omb) {
- $this->showForm(_('Not a valid profile URL (incorrect services).'));
- return;
- }
-
- if (omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]) ==
- common_local_url('requesttoken'))
- {
- $this->showForm(_('That\'s a local profile! Login to subscribe.'));
+ try {
+ $service = new OMB_Service_Consumer($this->profile_url,
+ common_root_url(),
+ omb_oauth_datastore());
+ } catch (OMB_InvalidYadisException $e) {
+ $this->showForm(_('Not a valid profile URL (no YADIS document or ' .
+ 'no or invalid XRDS defined).'));
return;
}
- if (User::staticGet('uri', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]))) {
- $this->showForm(_('That\'s a local profile! Login to subscribe.'));
+ if ($service->getServiceURI(OAUTH_ENDPOINT_REQUEST) ==
+ common_local_url('requesttoken') ||
+ User::staticGet('uri', $service->getRemoteUserURI())) {
+ $this->showForm(_('That’s a local profile! Login to subscribe.'));
return;
}
- list($token, $secret) = $this->requestToken($omb);
-
- if (!$token || !$secret) {
- $this->showForm(_('Couldn\'t get a request token.'));
+ try {
+ $service->requestToken();
+ } catch (OMB_RemoteServiceException $e) {
+ $this->showForm(_('Couldn’t get a request token.'));
return;
}
- $this->requestAuthorization($user, $omb, $token, $secret);
- }
-
- function getUser()
- {
- $user = null;
- if ($this->nickname) {
- $user = User::staticGet('nickname', $this->nickname);
- }
- return $user;
- }
-
- function getOmb($xrds)
- {
- static $omb_endpoints = array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE);
- static $oauth_endpoints = array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE,
- OAUTH_ENDPOINT_ACCESS);
- $omb = array();
-
- # XXX: the following code could probably be refactored to eliminate dupes
-
- $oauth_services = omb_get_services($xrds, OAUTH_DISCOVERY);
-
- if (!$oauth_services) {
- return null;
- }
-
- $oauth_service = $oauth_services[0];
-
- $oauth_xrd = $this->getXRD($oauth_service, $xrds);
-
- if (!$oauth_xrd) {
- return null;
- }
-
- if (!$this->addServices($oauth_xrd, $oauth_endpoints, $omb)) {
- return null;
- }
-
- $omb_services = omb_get_services($xrds, OMB_NAMESPACE);
-
- if (!$omb_services) {
- return null;
- }
-
- $omb_service = $omb_services[0];
-
- $omb_xrd = $this->getXRD($omb_service, $xrds);
-
- if (!$omb_xrd) {
- return null;
- }
-
- if (!$this->addServices($omb_xrd, $omb_endpoints, $omb)) {
- return null;
- }
-
- # XXX: check that we got all the services we needed
-
- foreach (array_merge($omb_endpoints, $oauth_endpoints) as $type) {
- if (!array_key_exists($type, $omb) || !$omb[$type]) {
- return null;
- }
- }
-
- if (!omb_local_id($omb[OAUTH_ENDPOINT_REQUEST])) {
- return null;
- }
-
- return $omb;
- }
-
- function getXRD($main_service, $main_xrds)
- {
- $uri = omb_service_uri($main_service);
- if (strpos($uri, "#") !== 0) {
- # FIXME: more rigorous handling of external service definitions
- return null;
- }
- $id = substr($uri, 1);
- $nodes = $main_xrds->allXrdNodes;
- $parser = $main_xrds->parser;
- foreach ($nodes as $node) {
- $attrs = $parser->attributes($node);
- if (array_key_exists('xml:id', $attrs) &&
- $attrs['xml:id'] == $id) {
- # XXX: trick the constructor into thinking this is the only node
- $bogus_nodes = array($node);
- return new Auth_Yadis_XRDS($parser, $bogus_nodes);
- }
- }
- return null;
- }
-
- function addServices($xrd, $types, &$omb)
- {
- foreach ($types as $type) {
- $matches = omb_get_services($xrd, $type);
- if ($matches) {
- $omb[$type] = $matches[0];
- } else {
- # no match for type
- return false;
- }
- }
- return true;
- }
-
- function requestToken($omb)
- {
- $con = omb_oauth_consumer();
-
- $url = omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]);
-
- # XXX: Is this the right thing to do? Strip off GET params and make them
- # POST params? Seems wrong to me.
-
- $parsed = parse_url($url);
- $params = array();
- parse_str($parsed['query'], $params);
-
- $req = OAuthRequest::from_consumer_and_token($con, null, "POST", $url, $params);
-
- $listener = omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]);
-
- if (!$listener) {
- return null;
- }
-
- $req->set_parameter('omb_listener', $listener);
- $req->set_parameter('omb_version', OMB_VERSION_01);
-
- # XXX: test to see if endpoint accepts this signature method
-
- $req->sign_request(omb_hmac_sha1(), $con, null);
-
- # We re-use this tool's fetcher, since it's pretty good
-
- $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
-
- $result = $fetcher->post($req->get_normalized_http_url(),
- $req->to_postdata(),
- array('User-Agent: StatusNet/' . STATUSNET_VERSION));
- if ($result->status != 200) {
- return null;
- }
-
- parse_str($result->body, $return);
-
- return array($return['oauth_token'], $return['oauth_token_secret']);
- }
-
- function requestAuthorization($user, $omb, $token, $secret)
- {
- $con = omb_oauth_consumer();
- $tok = new OAuthToken($token, $secret);
-
- $url = omb_service_uri($omb[OAUTH_ENDPOINT_AUTHORIZE]);
-
- # XXX: Is this the right thing to do? Strip off GET params and make them
- # POST params? Seems wrong to me.
-
- $parsed = parse_url($url);
- $params = array();
- parse_str($parsed['query'], $params);
-
- $req = OAuthRequest::from_consumer_and_token($con, $tok, 'GET', $url, $params);
-
- # We send over a ton of information. This lets the other
- # server store info about our user, and it lets the current
- # user decide if they really want to authorize the subscription.
-
- $req->set_parameter('omb_version', OMB_VERSION_01);
- $req->set_parameter('omb_listener', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]));
- $req->set_parameter('omb_listenee', $user->uri);
- $req->set_parameter('omb_listenee_profile', common_profile_url($user->nickname));
- $req->set_parameter('omb_listenee_nickname', $user->nickname);
- $req->set_parameter('omb_listenee_license', common_config('license', 'url'));
-
+ /* Create an OMB_Profile from $user. */
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
@@ -367,49 +192,16 @@ class RemotesubscribeAction extends Action
return;
}
- if (!is_null($profile->fullname)) {
- $req->set_parameter('omb_listenee_fullname', $profile->fullname);
- }
- if (!is_null($profile->homepage)) {
- $req->set_parameter('omb_listenee_homepage', $profile->homepage);
- }
- if (!is_null($profile->bio)) {
- $req->set_parameter('omb_listenee_bio', $profile->bio);
- }
- if (!is_null($profile->location)) {
- $req->set_parameter('omb_listenee_location', $profile->location);
- }
- $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
- if ($avatar) {
- $req->set_parameter('omb_listenee_avatar', $avatar->url);
- }
-
- # XXX: add a nonce to prevent replay attacks
-
- $req->set_parameter('oauth_callback', common_local_url('finishremotesubscribe'));
-
- # XXX: test to see if endpoint accepts this signature method
-
- $req->sign_request(omb_hmac_sha1(), $con, $tok);
-
- # store all our info here
-
- $omb['listenee'] = $user->nickname;
- $omb['listener'] = omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]);
- $omb['token'] = $token;
- $omb['secret'] = $secret;
- # call doesn't work after bounce back so we cache; maybe serialization issue...?
- $omb['access_token_url'] = omb_service_uri($omb[OAUTH_ENDPOINT_ACCESS]);
- $omb['post_notice_url'] = omb_service_uri($omb[OMB_ENDPOINT_POSTNOTICE]);
- $omb['update_profile_url'] = omb_service_uri($omb[OMB_ENDPOINT_UPDATEPROFILE]);
+ $target_url = $service->requestAuthorization(
+ profile_to_omb_profile($user->uri, $profile),
+ common_local_url('finishremotesubscribe'));
common_ensure_session();
- $_SESSION['oauth_authorization_request'] = $omb;
-
- # Redirect to authorization service
+ $_SESSION['oauth_authorization_request'] = serialize($service);
- common_redirect($req->to_url(), 303);
- return;
+ /* Redirect to the remote service for authorization. */
+ common_redirect($target_url, 303);
}
}
+?>
diff --git a/actions/replies.php b/actions/replies.php
index cca430230..6003ad30b 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -192,9 +192,7 @@ class RepliesAction extends OwnerDesignAction
}
}
else {
- $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and then nudge %s or post a notice to his or her attention.'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
- $this->user->nickname);
+ $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
}
$this->elementStart('div', 'guide');
diff --git a/actions/repliesrss.php b/actions/repliesrss.php
index c71c9226f..76aae21ad 100644
--- a/actions/repliesrss.php
+++ b/actions/repliesrss.php
@@ -38,6 +38,7 @@ class RepliesrssAction extends Rss10Action
$this->clientError(_('No such user.'));
return false;
} else {
+ $this->notices = $this->getNotices($this->limit);
return true;
}
}
diff --git a/actions/requesttoken.php b/actions/requesttoken.php
index a17efcdd5..e095161a7 100644
--- a/actions/requesttoken.php
+++ b/actions/requesttoken.php
@@ -34,6 +34,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
}
require_once INSTALLDIR.'/lib/omb.php';
+require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
/**
* Request token action class.
@@ -49,17 +50,17 @@ class RequesttokenAction extends Action
{
/**
* Is read only?
- *
+ *
* @return boolean false
*/
- function isReadOnly($args)
+ function isReadOnly()
{
return false;
}
-
+
/**
* Class handler.
- *
+ *
* @param array $args array of arguments
*
* @return void
@@ -68,14 +69,12 @@ class RequesttokenAction extends Action
{
parent::handle($args);
try {
- common_remove_magic_from_request();
- $req = OAuthRequest::from_request('POST', common_local_url('requesttoken'));
- $server = omb_oauth_server();
- $token = $server->fetch_request_token($req);
- print $token.'&omb_version='.OMB_VERSION_01;
- } catch (OAuthException $e) {
+ $srv = new OMB_Service_Provider(null, omb_oauth_datastore(),
+ omb_oauth_server());
+ $srv->writeRequestToken();
+ } catch (Exception $e) {
$this->serverError($e->getMessage());
}
}
}
-
+?>
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index 0f7a66330..b96d2af37 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -196,9 +196,7 @@ class ShowfavoritesAction extends OwnerDesignAction
}
}
else {
- $message = sprintf(_('%s hasn\'t added any notices to his favorites yet. Why not [register an account](%%%%action.%s%%%%) and then post something interesting they would add to their favorites :)'),
- $this->user->nickname,
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $message = sprintf(_('%s hasn\'t added any notices to his favorites yet. Why not [register an account](%%%%action.register%%%%) and then post something interesting they would add to their favorites :)'), $this->user->nickname);
}
$this->elementStart('div', 'guide');
diff --git a/actions/showgroup.php b/actions/showgroup.php
index 8157ee3c8..bfe45ddad 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -101,11 +101,6 @@ class ShowgroupAction extends GroupDesignAction
{
parent::prepare($args);
- if (!common_config('inboxes','enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
$nickname_arg = $this->arg('nickname');
@@ -345,7 +340,12 @@ class ShowgroupAction extends GroupDesignAction
'method' => 'timeline',
'argument' => $this->group->nickname.'.atom')),
sprintf(_('Notice feed for %s group (Atom)'),
- $this->group->nickname)));
+ $this->group->nickname)),
+ new Feed(Feed::FOAF,
+ common_local_url('foafgroup',
+ array('nickname' => $this->group->nickname)),
+ sprintf(_('FOAF for %s group'),
+ $this->group->nickname)));
}
/**
@@ -450,9 +450,8 @@ class ShowgroupAction extends GroupDesignAction
$m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
'short messages about their life and interests. '.
- '[Join now](%%%%action.%s%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
- $this->group->nickname,
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
+ $this->group->nickname);
} else {
$m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
diff --git a/actions/shownotice.php b/actions/shownotice.php
index 3bc52b2db..41408c23c 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -84,7 +84,13 @@ class ShownoticeAction extends OwnerDesignAction
$this->notice = Notice::staticGet($id);
if (empty($this->notice)) {
- $this->clientError(_('No such notice.'), 404);
+ // Did we used to have it, and it got deleted?
+ $deleted = Deleted_notice::staticGet($id);
+ if (!empty($deleted)) {
+ $this->clientError(_('Notice deleted.'), 410);
+ } else {
+ $this->clientError(_('No such notice.'), 404);
+ }
return false;
}
diff --git a/actions/showstream.php b/actions/showstream.php
index 89285b13c..de7100b1d 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -115,11 +115,11 @@ class ShowstreamAction extends ProfileAction
{
if (!empty($this->tag)) {
return array(new Feed(Feed::RSS1,
- common_local_url('userrss',
- array('nickname' => $this->user->nickname,
- 'tag' => $this->tag)),
- sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
- $this->user->nickname, $this->tag)));
+ common_local_url('userrss',
+ array('nickname' => $this->user->nickname,
+ 'tag' => $this->tag)),
+ sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
+ $this->user->nickname, $this->tag)));
}
return array(new Feed(Feed::RSS1,
@@ -181,159 +181,253 @@ class ShowstreamAction extends ProfileAction
function showProfile()
{
- $this->elementStart('div', 'entity_profile vcard author');
- $this->element('h2', null, _('User profile'));
-
- $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
- $this->elementStart('dl', 'entity_depiction');
- $this->element('dt', null, _('Photo'));
- $this->elementStart('dd');
- $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
- 'class' => 'photo avatar',
- 'width' => AVATAR_PROFILE_SIZE,
- 'height' => AVATAR_PROFILE_SIZE,
- 'alt' => $this->profile->nickname));
- $this->elementEnd('dd');
-
- $user = User::staticGet('id', $this->profile->id);
- $cur = common_current_user();
- if ($cur && $cur->id == $user->id) {
- $this->elementStart('dd');
- $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
- $this->elementEnd('dd');
+ $this->showProfileData();
+ $this->showEntityActions();
+ }
+
+ function showProfileData()
+ {
+ if (Event::handle('StartProfilePageProfileSection', array(&$this, $this->profile))) {
+
+ $this->elementStart('div', 'entity_profile vcard author');
+ $this->element('h2', null, _('User profile'));
+
+ if (Event::handle('StartProfilePageProfileElements', array(&$this, $this->profile))) {
+
+ $this->showAvatar();
+ $this->showNickname();
+ $this->showFullName();
+ $this->showLocation();
+ $this->showHomepage();
+ $this->showBio();
+ $this->showProfileTags();
+
+ Event::handle('EndProfilePageProfileElements', array(&$this, $this->profile));
+ }
+
+ $this->elementEnd('div');
+ Event::handle('EndProfilePageProfileSection', array(&$this, $this->profile));
}
+ }
+
+ function showAvatar()
+ {
+ if (Event::handle('StartProfilePageAvatar', array($this, $this->profile))) {
+
+ $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
- $this->elementEnd('dl');
-
- $this->elementStart('dl', 'entity_nickname');
- $this->element('dt', null, _('Nickname'));
- $this->elementStart('dd');
- $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
- $this->element('a', array('href' => $this->profile->profileurl,
- 'rel' => 'me', 'class' => $hasFN),
- $this->profile->nickname);
- $this->elementEnd('dd');
- $this->elementEnd('dl');
-
- if ($this->profile->fullname) {
- $this->elementStart('dl', 'entity_fn');
- $this->element('dt', null, _('Full name'));
+ $this->elementStart('dl', 'entity_depiction');
+ $this->element('dt', null, _('Photo'));
$this->elementStart('dd');
- $this->element('span', 'fn', $this->profile->fullname);
+ $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
+ 'class' => 'photo avatar',
+ 'width' => AVATAR_PROFILE_SIZE,
+ 'height' => AVATAR_PROFILE_SIZE,
+ 'alt' => $this->profile->nickname));
$this->elementEnd('dd');
- $this->elementEnd('dl');
- }
- if ($this->profile->location) {
- $this->elementStart('dl', 'entity_location');
- $this->element('dt', null, _('Location'));
- $this->element('dd', 'label', $this->profile->location);
+ $user = User::staticGet('id', $this->profile->id);
+
+ $cur = common_current_user();
+ if ($cur && $cur->id == $user->id) {
+ $this->elementStart('dd');
+ $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
+ $this->elementEnd('dd');
+ }
+
$this->elementEnd('dl');
+
+ Event::handle('EndProfilePageAvatar', array($this, $this->profile));
}
+ }
+
+ function showNickname()
+ {
+ if (Event::handle('StartProfilePageNickname', array($this, $this->profile))) {
- if ($this->profile->homepage) {
- $this->elementStart('dl', 'entity_url');
- $this->element('dt', null, _('URL'));
+ $this->elementStart('dl', 'entity_nickname');
+ $this->element('dt', null, _('Nickname'));
$this->elementStart('dd');
- $this->element('a', array('href' => $this->profile->homepage,
- 'rel' => 'me', 'class' => 'url'),
- $this->profile->homepage);
+ $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
+ $this->element('a', array('href' => $this->profile->profileurl,
+ 'rel' => 'me', 'class' => $hasFN),
+ $this->profile->nickname);
$this->elementEnd('dd');
$this->elementEnd('dl');
+
+ Event::handle('EndProfilePageNickname', array($this, $this->profile));
}
+ }
- if ($this->profile->bio) {
- $this->elementStart('dl', 'entity_note');
- $this->element('dt', null, _('Note'));
- $this->element('dd', 'note', $this->profile->bio);
- $this->elementEnd('dl');
+ function showFullName()
+ {
+ if (Event::handle('StartProfilePageFullName', array($this, $this->profile))) {
+ if ($this->profile->fullname) {
+ $this->elementStart('dl', 'entity_fn');
+ $this->element('dt', null, _('Full name'));
+ $this->elementStart('dd');
+ $this->element('span', 'fn', $this->profile->fullname);
+ $this->elementEnd('dd');
+ $this->elementEnd('dl');
+ }
+ Event::handle('EndProfilePageFullName', array($this, $this->profile));
}
+ }
- $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
- if (count($tags) > 0) {
- $this->elementStart('dl', 'entity_tags');
- $this->element('dt', null, _('Tags'));
- $this->elementStart('dd');
- $this->elementStart('ul', 'tags xoxo');
- foreach ($tags as $tag) {
- $this->elementStart('li');
- // Avoid space by using raw output.
- $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
- common_local_url('peopletag', array('tag' => $tag)) .
- '">' . $tag . '</a>';
- $this->raw($pt);
- $this->elementEnd('li');
+ function showLocation()
+ {
+ if (Event::handle('StartProfilePageLocation', array($this, $this->profile))) {
+ if ($this->profile->location) {
+ $this->elementStart('dl', 'entity_location');
+ $this->element('dt', null, _('Location'));
+ $this->element('dd', 'label', $this->profile->location);
+ $this->elementEnd('dl');
}
- $this->elementEnd('ul');
- $this->elementEnd('dd');
- $this->elementEnd('dl');
+ Event::handle('EndProfilePageLocation', array($this, $this->profile));
}
- $this->elementEnd('div');
+ }
- $this->elementStart('div', 'entity_actions');
- $this->element('h2', null, _('User actions'));
- $this->elementStart('ul');
- $cur = common_current_user();
-
- if ($cur && $cur->id == $this->profile->id) {
- $this->elementStart('li', 'entity_edit');
- $this->element('a', array('href' => common_local_url('profilesettings'),
- 'title' => _('Edit profile settings')),
- _('Edit'));
- $this->elementEnd('li');
+ function showHomepage()
+ {
+ if (Event::handle('StartProfilePageHomepage', array($this, $this->profile))) {
+ if ($this->profile->homepage) {
+ $this->elementStart('dl', 'entity_url');
+ $this->element('dt', null, _('URL'));
+ $this->elementStart('dd');
+ $this->element('a', array('href' => $this->profile->homepage,
+ 'rel' => 'me', 'class' => 'url'),
+ $this->profile->homepage);
+ $this->elementEnd('dd');
+ $this->elementEnd('dl');
+ }
+ Event::handle('EndProfilePageHomepage', array($this, $this->profile));
}
+ }
- if ($cur) {
- if ($cur->id != $this->profile->id) {
- $this->elementStart('li', 'entity_subscribe');
- if ($cur->isSubscribed($this->profile)) {
- $usf = new UnsubscribeForm($this, $this->profile);
- $usf->show();
- } else {
- $sf = new SubscribeForm($this, $this->profile);
- $sf->show();
- }
- $this->elementEnd('li');
+ function showBio()
+ {
+ if (Event::handle('StartProfilePageBio', array($this, $this->profile))) {
+ if ($this->profile->bio) {
+ $this->elementStart('dl', 'entity_note');
+ $this->element('dt', null, _('Note'));
+ $this->element('dd', 'note', $this->profile->bio);
+ $this->elementEnd('dl');
}
- } else {
- $this->elementStart('li', 'entity_subscribe');
- $this->showRemoteSubscribeLink();
- $this->elementEnd('li');
+ Event::handle('EndProfilePageBio', array($this, $this->profile));
}
+ }
- if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) {
- $this->elementStart('li', 'entity_send-a-message');
- $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
- 'title' => _('Send a direct message to this user')),
- _('Message'));
- $this->elementEnd('li');
-
- if ($user->email && $user->emailnotifynudge) {
- $this->elementStart('li', 'entity_nudge');
- $nf = new NudgeForm($this, $user);
- $nf->show();
- $this->elementEnd('li');
+ function showProfileTags()
+ {
+ if (Event::handle('StartProfilePageProfileTags', array($this, $this->profile))) {
+ $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
+
+ if (count($tags) > 0) {
+ $this->elementStart('dl', 'entity_tags');
+ $this->element('dt', null, _('Tags'));
+ $this->elementStart('dd');
+ $this->elementStart('ul', 'tags xoxo');
+ foreach ($tags as $tag) {
+ $this->elementStart('li');
+ // Avoid space by using raw output.
+ $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
+ common_local_url('peopletag', array('tag' => $tag)) .
+ '">' . $tag . '</a>';
+ $this->raw($pt);
+ $this->elementEnd('li');
+ }
+ $this->elementEnd('ul');
+ $this->elementEnd('dd');
+ $this->elementEnd('dl');
}
+ Event::handle('EndProfilePageProfileTags', array($this, $this->profile));
}
+ }
- if ($cur && $cur->id != $this->profile->id) {
- $blocked = $cur->hasBlocked($this->profile);
- $this->elementStart('li', 'entity_block');
- if ($blocked) {
- $ubf = new UnblockForm($this, $this->profile,
- array('action' => 'showstream',
- 'nickname' => $this->profile->nickname));
- $ubf->show();
- } else {
- $bf = new BlockForm($this, $this->profile,
- array('action' => 'showstream',
- 'nickname' => $this->profile->nickname));
- $bf->show();
+ function showEntityActions()
+ {
+ if (Event::handle('StartProfilePageActionsSection', array(&$this, $this->profile))) {
+
+ $cur = common_current_user();
+
+ $this->elementStart('div', 'entity_actions');
+ $this->element('h2', null, _('User actions'));
+ $this->elementStart('ul');
+
+ if (Event::handle('StartProfilePageActionsElements', array(&$this, $this->profile))) {
+ if (empty($cur)) { // not logged in
+ $this->elementStart('li', 'entity_subscribe');
+ $this->showRemoteSubscribeLink();
+ $this->elementEnd('li');
+ } else {
+ if ($cur->id == $this->profile->id) { // your own page
+ $this->elementStart('li', 'entity_edit');
+ $this->element('a', array('href' => common_local_url('profilesettings'),
+ 'title' => _('Edit profile settings')),
+ _('Edit'));
+ $this->elementEnd('li');
+ } else { // someone else's page
+
+ // subscribe/unsubscribe button
+
+ $this->elementStart('li', 'entity_subscribe');
+
+ if ($cur->isSubscribed($this->profile)) {
+ $usf = new UnsubscribeForm($this, $this->profile);
+ $usf->show();
+ } else {
+ $sf = new SubscribeForm($this, $this->profile);
+ $sf->show();
+ }
+ $this->elementEnd('li');
+
+ if ($cur->mutuallySubscribed($this->user)) {
+
+ // message
+
+ $this->elementStart('li', 'entity_send-a-message');
+ $this->element('a', array('href' => common_local_url('newmessage', array('to' => $this->user->id)),
+ 'title' => _('Send a direct message to this user')),
+ _('Message'));
+ $this->elementEnd('li');
+
+ // nudge
+
+ if ($this->user->email && $this->user->emailnotifynudge) {
+ $this->elementStart('li', 'entity_nudge');
+ $nf = new NudgeForm($this, $this->user);
+ $nf->show();
+ $this->elementEnd('li');
+ }
+ }
+
+ // block/unblock
+
+ $blocked = $cur->hasBlocked($this->profile);
+ $this->elementStart('li', 'entity_block');
+ if ($blocked) {
+ $ubf = new UnblockForm($this, $this->profile,
+ array('action' => 'showstream',
+ 'nickname' => $this->profile->nickname));
+ $ubf->show();
+ } else {
+ $bf = new BlockForm($this, $this->profile,
+ array('action' => 'showstream',
+ 'nickname' => $this->profile->nickname));
+ $bf->show();
+ }
+ $this->elementEnd('li');
+ }
+ }
+
+ Event::handle('EndProfilePageActionsElements', array(&$this, $this->profile));
}
- $this->elementEnd('li');
+
+ $this->elementEnd('ul');
+ $this->elementEnd('div');
+
+ Event::handle('EndProfilePageActionsSection', array(&$this, $this->profile));
}
- $this->elementEnd('ul');
- $this->elementEnd('div');
}
function showRemoteSubscribeLink()
@@ -358,9 +452,7 @@ class ShowstreamAction extends ProfileAction
}
}
else {
- $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and then nudge %s or post a notice to his or her attention.'),
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
- $this->user->nickname);
+ $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
}
$this->elementStart('div', 'guide');
@@ -371,7 +463,7 @@ class ShowstreamAction extends ProfileAction
function showNotices()
{
$notice = empty($this->tag)
- ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
+ ? $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);
$pnl = new ProfileNoticeList($notice, $this);
@@ -393,16 +485,14 @@ class ShowstreamAction extends ProfileAction
{
if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
- '[Join now](%%%%action.%s%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
- $this->user->nickname,
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
- $this->user->nickname);
+ 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
+ '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
+ $this->user->nickname, $this->user->nickname);
} else {
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [StatusNet](http://status.net/) tool. '),
- $this->user->nickname, $this->user->nickname);
- }
+ 'based on the Free Software [StatusNet](http://status.net/) tool. '),
+ $this->user->nickname, $this->user->nickname);
+ }
$this->elementStart('div', array('id' => 'anon_notice'));
$this->raw(common_markup_to_html($m));
$this->elementEnd('div');
diff --git a/actions/subscribers.php b/actions/subscribers.php
index f7d08d9d0..df9ec9961 100644
--- a/actions/subscribers.php
+++ b/actions/subscribers.php
@@ -111,9 +111,7 @@ class SubscribersAction extends GalleryAction
}
}
else {
- $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.%s%%%%) and be the first?'),
- $this->user->nickname,
- (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+ $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->user->nickname);
}
$this->elementStart('div', 'guide');
diff --git a/actions/twitapiaccount.php b/actions/twitapiaccount.php
deleted file mode 100644
index 93c8443c9..000000000
--- a/actions/twitapiaccount.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class TwitapiaccountAction extends TwitterapiAction
-{
- function verify_credentials($args, $apidata)
- {
- parent::handle($args);
-
- switch ($apidata['content-type']) {
- case 'xml':
- case 'json':
- $action_obj = new TwitapiusersAction();
- $action_obj->prepare($args);
- call_user_func(array($action_obj, 'show'), $args, $apidata);
- break;
- default:
- header('Content-Type: text/html; charset=utf-8');
- print 'Authorized';
- }
- }
-
- function end_session($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
- }
-
- function update_location($args, $apidata)
- {
- parent::handle($args);
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->clientError(_('This method requires a POST.'),
- 400, $apidata['content-type']);
- return;
- }
-
- $location = trim($this->arg('location'));
-
- if (!is_null($location) && mb_strlen($location) > 255) {
-
- // XXX: But Twitter just truncates and runs with it. -- Zach
- $this->clientError(_('That\'s too long. Max notice size is 255 chars.'),
- 406, $apidate['content-type']);
- return;
- }
-
- $user = $apidata['user']; // Always the auth user
- $profile = $user->getProfile();
-
- $orig_profile = clone($profile);
- $profile->location = $location;
-
- $result = $profile->update($orig_profile);
-
- if (empty($result)) {
- common_log_db_error($profile, 'UPDATE', __FILE__);
- $this->serverError(_('Couldn\'t save profile.'));
- return;
- }
-
- common_broadcast_profile($profile);
- $type = $apidata['content-type'];
-
- $this->init_document($type);
- $this->show_profile($profile, $type);
- $this->end_document($type);
- }
-
-
- function update_delivery_device($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
- }
-
- // We don't have a rate limit, but some clients check this method.
- // It always returns the same thing: 100 hit left.
- function rate_limit_status($args, $apidata)
- {
- parent::handle($args);
-
- $type = $apidata['content-type'];
- $this->init_document($type);
-
- if ($apidata['content-type'] == 'xml') {
- $this->elementStart('hash');
- $this->element('remaining-hits', array('type' => 'integer'), 100);
- $this->element('hourly-limit', array('type' => 'integer'), 100);
- $this->element('reset-time', array('type' => 'datetime'), null);
- $this->element('reset_time_in_seconds', array('type' => 'integer'), 0);
- $this->elementEnd('hash');
- } elseif ($apidata['content-type'] == 'json') {
-
- $out = array('reset_time_in_seconds' => 0,
- 'remaining_hits' => 100,
- 'hourly_limit' => 100,
- 'reset_time' => '');
- print json_encode($out);
- }
-
- $this->end_document($type);
- }
-}
diff --git a/actions/twitapiblocks.php b/actions/twitapiblocks.php
deleted file mode 100644
index ed17946ae..000000000
--- a/actions/twitapiblocks.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class TwitapiblocksAction extends TwitterapiAction
-{
-
- function create($args, $apidata)
- {
-
- parent::handle($args);
-
- $blockee = $this->get_user($apidata['api_arg'], $apidata);
-
- if (empty($blockee)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $user = $apidata['user']; // Always the auth user
-
- if ($user->hasBlocked($blockee) || $user->block($blockee)) {
- $type = $apidata['content-type'];
- $this->init_document($type);
- $this->show_profile($blockee, $type);
- $this->end_document($type);
- } else {
- $this->serverError(_('Block user failed.'));
- }
- }
-
- function destroy($args, $apidata)
- {
- parent::handle($args);
- $blockee = $this->get_user($apidata['api_arg'], $apidata);
-
- if (empty($blockee)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $user = $apidata['user'];
-
- if (!$user->hasBlocked($blockee) || $user->unblock($blockee)) {
- $type = $apidata['content-type'];
- $this->init_document($type);
- $this->show_profile($blockee, $type);
- $this->end_document($type);
- } else {
- $this->serverError(_('Unblock user failed.'));
- }
- }
-} \ No newline at end of file
diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php
deleted file mode 100644
index dbe55804b..000000000
--- a/actions/twitapidirect_messages.php
+++ /dev/null
@@ -1,304 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class Twitapidirect_messagesAction extends TwitterapiAction
-{
-
- function direct_messages($args, $apidata)
- {
- parent::handle($args);
- return $this->show_messages($args, $apidata, 'received');
- }
-
- function sent($args, $apidata)
- {
- parent::handle($args);
- return $this->show_messages($args, $apidata, 'sent');
- }
-
- function show_messages($args, $apidata, $type)
- {
- $user = $apidata['user']; // Always the auth user
-
- $message = new Message();
- $title = null;
- $subtitle = null;
- $link = null;
- $server = common_root_url();
-
- if ($type == 'received') {
- $message->to_profile = $user->id;
- $title = sprintf(_("Direct messages to %s"), $user->nickname);
- $subtitle = sprintf(_("All the direct messages sent to %s"),
- $user->nickname);
- $link = $server . $user->nickname . '/inbox';
- } else {
- $message->from_profile = $user->id;
- $title = _('Direct Messages You\'ve Sent');
- $subtitle = sprintf(_("All the direct messages sent from %s"),
- $user->nickname);
- $link = $server . $user->nickname . '/outbox';
- }
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- if ($max_id) {
- $message->whereAdd("id <= $max_id");
- }
-
- if ($since_id) {
- $message->whereAdd("id > $since_id");
- }
-
- if ($since) {
- $d = date('Y-m-d H:i:s', $since);
- $message->whereAdd("created > '$d'");
- }
-
- $message->orderBy('created DESC, id DESC');
- $message->limit((($page-1)*$count), $count);
- $message->find();
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_dmsgs($message);
- break;
- case 'rss':
- $this->show_rss_dmsgs($message, $title, $link, $subtitle);
- break;
- case 'atom':
- $selfuri = common_root_url() . 'api/direct_messages';
- $selfuri .= ($type == 'received') ? '.atom' : '/sent.atom';
- $taguribase = common_config('integration', 'taguri');
-
- if ($type == 'sent') {
- $id = "tag:$taguribase:SentDirectMessages:" . $user->id;
- } else {
- $id = "tag:$taguribase:DirectMessages:" . $user->id;
- }
-
- $this->show_atom_dmsgs($message, $title, $link, $subtitle,
- $selfuri, $id);
- break;
- case 'json':
- $this->show_json_dmsgs($message);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
-
- }
-
- // had to change this from "new" to "create" to avoid PHP reserved word
- function create($args, $apidata)
- {
- parent::handle($args);
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->clientError(_('This method requires a POST.'),
- 400, $apidata['content-type']);
- return;
- }
-
- $user = $apidata['user'];
- $source = $this->trimmed('source'); // Not supported by Twitter.
-
- $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
- if (empty($source) || in_array($source, $reserved_sources)) {
- $source = 'api';
- }
-
- $content = $this->trimmed('text');
-
- if (empty($content)) {
- $this->clientError(_('No message text!'),
- $code = 406, $apidata['content-type']);
- } else {
- $content_shortened = common_shorten_links($content);
- if (mb_strlen($content_shortened) > 140) {
- $this->clientError(_('That\'s too long. Max message size is 140 chars.'),
- $code = 406, $apidata['content-type']);
- return;
- }
- }
-
- $other = $this->get_user($this->trimmed('user'));
-
- if (empty($other)) {
- $this->clientError(_('Recipient user not found.'),
- $code = 403, $apidata['content-type']);
- return;
- } else if (!$user->mutuallySubscribed($other)) {
- $this->clientError(_('Can\'t send direct messages to users who aren\'t your friend.'),
- $code = 403, $apidata['content-type']);
- return;
- } else if ($user->id == $other->id) {
- // Sending msgs to yourself is allowed by Twitter
- $this->clientError(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'),
- $code = 403, $apidata['content-type']);
- return;
- }
-
- $message = Message::saveNew($user->id, $other->id,
- html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source);
-
- if (is_string($message)) {
- $this->serverError($message);
- return;
- }
-
- $this->notify($user, $other, $message);
-
- if ($apidata['content-type'] == 'xml') {
- $this->show_single_xml_dmsg($message);
- } elseif ($apidata['content-type'] == 'json') {
- $this->show_single_json_dmsg($message);
- }
-
- }
-
- function destroy($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
- }
-
- function show_xml_dmsgs($message)
- {
-
- $this->init_document('xml');
- $this->elementStart('direct-messages', array('type' => 'array'));
-
- if (is_array($message)) {
- foreach ($message as $m) {
- $twitter_dm = $this->twitter_dmsg_array($m);
- $this->show_twitter_xml_dmsg($twitter_dm);
- }
- } else {
- while ($message->fetch()) {
- $twitter_dm = $this->twitter_dmsg_array($message);
- $this->show_twitter_xml_dmsg($twitter_dm);
- }
- }
-
- $this->elementEnd('direct-messages');
- $this->end_document('xml');
-
- }
-
- function show_json_dmsgs($message)
- {
-
- $this->init_document('json');
-
- $dmsgs = array();
-
- if (is_array($message)) {
- foreach ($message as $m) {
- $twitter_dm = $this->twitter_dmsg_array($m);
- array_push($dmsgs, $twitter_dm);
- }
- } else {
- while ($message->fetch()) {
- $twitter_dm = $this->twitter_dmsg_array($message);
- array_push($dmsgs, $twitter_dm);
- }
- }
-
- $this->show_json_objects($dmsgs);
- $this->end_document('json');
-
- }
-
- function show_rss_dmsgs($message, $title, $link, $subtitle)
- {
-
- $this->init_document('rss');
-
- $this->elementStart('channel');
- $this->element('title', null, $title);
-
- $this->element('link', null, $link);
- $this->element('description', null, $subtitle);
- $this->element('language', null, 'en-us');
- $this->element('ttl', null, '40');
-
- if (is_array($message)) {
- foreach ($message as $m) {
- $entry = $this->twitter_rss_dmsg_array($m);
- $this->show_twitter_rss_item($entry);
- }
- } else {
- while ($message->fetch()) {
- $entry = $this->twitter_rss_dmsg_array($message);
- $this->show_twitter_rss_item($entry);
- }
- }
-
- $this->elementEnd('channel');
- $this->end_twitter_rss();
-
- }
-
- function show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id)
- {
-
- $this->init_document('atom');
-
- $this->element('title', null, $title);
- $this->element('id', null, $id);
- $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
- $this->element('link', array('href' => $selfuri, 'rel' => 'self',
- 'type' => 'application/atom+xml'), null);
- $this->element('updated', null, common_date_iso8601('now'));
- $this->element('subtitle', null, $subtitle);
-
- if (is_array($message)) {
- foreach ($message as $m) {
- $entry = $this->twitter_rss_dmsg_array($m);
- $this->show_twitter_atom_entry($entry);
- }
- } else {
- while ($message->fetch()) {
- $entry = $this->twitter_rss_dmsg_array($message);
- $this->show_twitter_atom_entry($entry);
- }
- }
-
- $this->end_document('atom');
- }
-
- // swiped from MessageAction. Should it be place in util.php?
- function notify($from, $to, $message)
- {
- mail_notify_message($message, $from, $to);
- # XXX: Jabber, SMS notifications... probably queued
- }
-
-}
diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php
deleted file mode 100644
index f8943fe2d..000000000
--- a/actions/twitapifavorites.php
+++ /dev/null
@@ -1,216 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class TwitapifavoritesAction extends TwitterapiAction
-{
-
- function favorites($args, $apidata)
- {
- parent::handle($args);
-
- $this->auth_user = $apidata['user'];
- $user = $this->get_user($apidata['api_arg'], $apidata);
-
- if (empty($user)) {
- if ($apidata['content-type'] == 'xml') {
- $this->show_single_xml_status($notice);
- } elseif ($apidata['content-type'] == 'json') {
- $this->show_single_json_status($notice);
- }
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $profile = $user->getProfile();
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_('%s / Favorites from %s'), $sitename,
- $user->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:Favorites:".$user->id;
- $link = common_local_url('favorites',
- array('nickname' => $user->nickname));
- $subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename,
- $profile->getBestName(), $user->nickname);
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- if (!empty($this->auth_user) && $this->auth_user->id == $user->id) {
- $notice = $user->favoriteNotices(($page-1)*$count, $count, true);
- } else {
- $notice = $user->favoriteNotices(($page-1)*$count, $count, false);
- }
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_timeline($notice);
- break;
- case 'rss':
- $this->show_rss_timeline($notice, $title, $link, $subtitle);
- break;
- case 'atom':
- if (isset($apidata['api_arg'])) {
- $selfuri = $selfuri = common_root_url() .
- 'api/favorites/' . $apidata['api_arg'] . '.atom';
- } else {
- $selfuri = $selfuri = common_root_url() .
- 'api/favorites.atom';
- }
- $this->show_atom_timeline($notice, $title, $id, $link,
- $subtitle, null, $selfuri);
- break;
- case 'json':
- $this->show_json_timeline($notice);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
-
- }
-
- function create($args, $apidata)
- {
- parent::handle($args);
-
- // Check for RESTfulness
- if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
- $this->clientError(_('This method requires a POST or DELETE.'),
- 400, $apidata['content-type']);
- return;
- }
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- $user = $apidata['user']; // Always the auth user
- $notice_id = $apidata['api_arg'];
- $notice = Notice::staticGet($notice_id);
-
- if (empty($notice)) {
- $this->clientError(_('No status found with that ID.'),
- 404, $apidata['content-type']);
- return;
- }
-
- // XXX: Twitter lets you fave things repeatedly via api.
- if ($user->hasFave($notice)) {
- $this->clientError(_('This status is already a favorite!'),
- 403, $apidata['content-type']);
- return;
- }
-
- $fave = Fave::addNew($user, $notice);
-
- if (empty($fave)) {
- $this->clientError(_('Could not create favorite.'));
- return;
- }
-
- $this->notify($fave, $notice, $user);
- $user->blowFavesCache();
-
- if ($apidata['content-type'] == 'xml') {
- $this->show_single_xml_status($notice);
- } elseif ($apidata['content-type'] == 'json') {
- $this->show_single_json_status($notice);
- }
-
- }
-
- function destroy($args, $apidata)
- {
- parent::handle($args);
-
- // Check for RESTfulness
- if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
- $this->clientError(_('This method requires a POST or DELETE.'),
- 400, $apidata['content-type']);
- return;
- }
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- $user = $apidata['user']; // Always the auth user
- $notice_id = $apidata['api_arg'];
- $notice = Notice::staticGet($notice_id);
-
- if (empty($notice)) {
- $this->clientError(_('No status found with that ID.'),
- 404, $apidata['content-type']);
- return;
- }
-
- $fave = new Fave();
- $fave->user_id = $this->id;
- $fave->notice_id = $notice->id;
-
- if (!$fave->find(true)) {
- $this->clientError(_('That status is not a favorite!'),
- 403, $apidata['content-type']);
- return;
- }
-
- $result = $fave->delete();
-
- if (!$result) {
- common_log_db_error($fave, 'DELETE', __FILE__);
- $this->clientError(_('Could not delete favorite.'), 404);
- return;
- }
-
- $user->blowFavesCache();
-
- if ($apidata['content-type'] == 'xml') {
- $this->show_single_xml_status($notice);
- } elseif ($apidata['content-type'] == 'json') {
- $this->show_single_json_status($notice);
- }
-
- }
-
- // XXX: these two funcs swiped from faves.
- // Maybe put in util.php, or some common base class?
-
- function notify($fave, $notice, $user)
- {
- $other = User::staticGet('id', $notice->profile_id);
- if ($other && $other->id != $user->id) {
- if ($other->email && $other->emailnotifyfav) {
- mail_notify_fave($other, $user, $notice);
- }
- # XXX: notify by IM
- # XXX: notify by SMS
- }
- }
-}
diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php
deleted file mode 100644
index eea8945c3..000000000
--- a/actions/twitapifriendships.php
+++ /dev/null
@@ -1,250 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class TwitapifriendshipsAction extends TwitterapiAction
-{
-
- function create($args, $apidata)
- {
- parent::handle($args);
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->clientError(_('This method requires a POST.'),
- 400, $apidata['content-type']);
- return;
- }
-
- $id = $apidata['api_arg'];
- $other = $this->get_user($id);
-
- if (empty($other)) {
- $this->clientError(_('Could not follow user: User not found.'),
- 403, $apidata['content-type']);
- return;
- }
-
- $user = $apidata['user'];
-
- if ($user->isSubscribed($other)) {
- $errmsg = sprintf(_('Could not follow user: %s is already on your list.'),
- $other->nickname);
- $this->clientError($errmsg, 403, $apidata['content-type']);
- return;
- }
-
- $sub = new Subscription();
-
- $sub->query('BEGIN');
-
- $sub->subscriber = $user->id;
- $sub->subscribed = $other->id;
- $sub->created = DB_DataObject_Cast::dateTime(); # current time
-
- $result = $sub->insert();
-
- if (empty($result)) {
- $errmsg = sprintf(_('Could not follow user: %s is already on your list.'),
- $other->nickname);
- $this->clientError($errmsg, 400, $apidata['content-type']);
- return;
- }
-
- $sub->query('COMMIT');
-
- mail_subscribe_notify($other, $user);
-
- $type = $apidata['content-type'];
- $this->init_document($type);
- $this->show_profile($other, $type);
- $this->end_document($type);
-
- }
-
- function destroy($args, $apidata)
- {
- parent::handle($args);
-
- if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
- $this->clientError(_('This method requires a POST or DELETE.'),
- 400, $apidata['content-type']);
- return;
- }
-
- $id = $apidata['api_arg'];
-
- # We can't subscribe to a remote person, but we can unsub
-
- $other = $this->get_profile($id);
- $user = $apidata['user']; // Alwyas the auth user
-
- if ($user->id == $other->id) {
- $this->clientError(_("You cannot unfollow yourself!"),
- 403, $apidata['content-type']);
- return;
- }
-
- $sub = new Subscription();
- $sub->subscriber = $user->id;
- $sub->subscribed = $other->id;
-
- if ($sub->find(true)) {
- $sub->query('BEGIN');
- $sub->delete();
- $sub->query('COMMIT');
- } else {
- $this->clientError(_('You are not friends with the specified user.'),
- 403, $apidata['content-type']);
- return;
- }
-
- $type = $apidata['content-type'];
- $this->init_document($type);
- $this->show_profile($other, $type);
- $this->end_document($type);
-
- }
-
- function exists($args, $apidata)
- {
- parent::handle($args);
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- $user_a_id = $this->trimmed('user_a');
- $user_b_id = $this->trimmed('user_b');
-
- $user_a = $this->get_user($user_a_id);
- $user_b = $this->get_user($user_b_id);
-
- if (empty($user_a) || empty($user_b)) {
- $this->clientError(_('Two user ids or screen_names must be supplied.'),
- 400, $apidata['content-type']);
- return;
- }
-
- $result = $user_a->isSubscribed($user_b);
-
- switch ($apidata['content-type']) {
- case 'xml':
- $this->init_document('xml');
- $this->element('friends', null, $result);
- $this->end_document('xml');
- break;
- case 'json':
- $this->init_document('json');
- print json_encode($result);
- $this->end_document('json');
- break;
- default:
- break;
- }
-
- }
-
- function show($args, $apidata)
- {
- parent::handle($args);
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- $source_id = (int)$this->trimmed('source_id');
- $source_screen_name = $this->trimmed('source_screen_name');
-
- // If the source is not specified for an unauthenticated request,
- // the method will return an HTTP 403.
-
- if (empty($source_id) && empty($source_screen_name)) {
- if (empty($apidata['user'])) {
- $this->clientError(_('Could not determine source user.'),
- $code = 403);
- return;
- }
- }
-
- $source = null;
-
- if (!empty($source_id)) {
- $source = User::staticGet($source_id);
- } elseif (!empty($source_screen_name)) {
- $source = User::staticGet('nickname', $source_screen_name);
- } else {
- $source = $apidata['user'];
- }
-
- // If a source or target is specified but does not exist,
- // the method will return an HTTP 404.
-
- if (empty($source)) {
- $this->clientError(_('Could not determine source user.'),
- $code = 404);
- return;
- }
-
- $target_id = (int)$this->trimmed('target_id');
- $target_screen_name = $this->trimmed('target_screen_name');
-
- $target = null;
-
- if (!empty($target_id)) {
- $target = User::staticGet($target_id);
- } elseif (!empty($target_screen_name)) {
- $target = User::staticGet('nickname', $target_screen_name);
- } else {
- $this->clientError(_('Target user not specified.'),
- $code = 403);
- return;
- }
-
- if (empty($target)) {
- $this->clientError(_('Could not find target user.'),
- $code = 404);
- return;
- }
-
- $result = $this->twitter_relationship_array($source, $target);
-
- switch ($apidata['content-type']) {
- case 'xml':
- $this->init_document('xml');
- $this->show_twitter_xml_relationship($result[relationship]);
- $this->end_document('xml');
- break;
- case 'json':
- $this->init_document('json');
- print json_encode($result);
- $this->end_document('json');
- break;
- default:
- break;
- }
- }
-
-}
diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php
deleted file mode 100644
index 4deb1b764..000000000
--- a/actions/twitapigroups.php
+++ /dev/null
@@ -1,329 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * StatusNet extensions to the Twitter-like API for groups
- *
- * 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 Twitter
- * @package StatusNet
- * @author Craig Andrews <candrews@integralblue.com>
- * @author Zach Copley <zach@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') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once INSTALLDIR.'/lib/twitterapi.php';
-
-/**
- * Group-specific API methods
- *
- * This class handles StatusNet group API methods.
- *
- * @category Twitter
- * @package StatusNet
- * @author Craig Andrews <candrews@integralblue.com>
- * @author Zach Copley <zach@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/
- */
-
- class TwitapigroupsAction extends TwitterapiAction
- {
-
- function list_groups($args, $apidata)
- {
- parent::handle($args);
-
- common_debug("in groups api action");
-
- $this->auth_user = $apidata['user'];
- $user = $this->get_user($apidata['api_arg'], $apidata);
-
- if (empty($user)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
- $group = $user->getGroups(($page-1)*$count,
- $count, $since_id, $max_id, $since);
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_("%s's groups"), $user->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:Groups";
- $link = common_root_url();
- $subtitle = sprintf(_("groups %s is a member of on %s"), $user->nickname, $sitename);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_groups($group);
- break;
- case 'rss':
- $this->show_rss_groups($group, $title, $link, $subtitle);
- break;
- case 'atom':
- $selfuri = common_root_url() . 'api/statusnet/groups/list/' . $user->id . '.atom';
- $this->show_atom_groups($group, $title, $id, $link,
- $subtitle, $selfuri);
- break;
- case 'json':
- $this->show_json_groups($group);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- break;
- }
- }
-
- function list_all($args, $apidata)
- {
- parent::handle($args);
-
- common_debug("in groups api action");
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- /* TODO:
- Use the $page, $count, $max_id, $since_id, and $since parameters
- */
- $group = new User_group();
- $group->orderBy('created DESC');
- $group->find();
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_("%s groups"), $sitename);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:Groups";
- $link = common_root_url();
- $subtitle = sprintf(_("groups on %s"), $sitename);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_groups($group);
- break;
- case 'rss':
- $this->show_rss_groups($group, $title, $link, $subtitle);
- break;
- case 'atom':
- $selfuri = common_root_url() . 'api/statusnet/groups/list_all.atom';
- $this->show_atom_groups($group, $title, $id, $link,
- $subtitle, $selfuri);
- break;
- case 'json':
- $this->show_json_groups($group);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- break;
- }
- }
-
- function show($args, $apidata)
- {
- parent::handle($args);
-
- common_debug("in groups api action");
-
- $this->auth_user = $apidata['user'];
- $group = $this->get_group($apidata['api_arg'], $apidata);
-
- if (empty($group)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_single_xml_group($group);
- break;
- case 'json':
- $this->show_single_json_group($group);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
- }
-
- function timeline($args, $apidata)
- {
- parent::handle($args);
-
- common_debug("in groups api action");
-
- $this->auth_user = $apidata['user'];
- $group = $this->get_group($apidata['api_arg'], $apidata);
-
- if (empty($group)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_("%s timeline"), $group->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:GroupTimeline:".$group->id;
- $link = common_local_url('showgroup',
- array('nickname' => $group->nickname));
- $subtitle = sprintf(_('Updates from %1$s on %2$s!'),
- $group->nickname, $sitename);
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- $notice = $group->getNotices(($page-1)*$count,
- $count, $since_id, $max_id, $since);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_timeline($notice);
- break;
- case 'rss':
- $this->show_rss_timeline($notice, $title, $link, $subtitle);
- break;
- case 'atom':
- if (isset($apidata['api_arg'])) {
- $selfuri = common_root_url() .
- 'api/statusnet/groups/timeline/' .
- $apidata['api_arg'] . '.atom';
- } else {
- $selfuri = common_root_url() .
- 'api/statusnet/groups/timeline.atom';
- }
- $this->show_atom_timeline($notice, $title, $id, $link,
- $subtitle, null, $selfuri);
- break;
- case 'json':
- $this->show_json_timeline($notice);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
- }
-
- function membership($args, $apidata)
- {
- parent::handle($args);
-
- common_debug("in groups api action");
-
- $this->auth_user = $apidata['user'];
- $group = $this->get_group($apidata['api_arg'], $apidata);
-
- if (empty($group)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_("Members of %s group"), $group->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:GroupMembership:".$group->id;
- $link = common_local_url('showgroup',
- array('nickname' => $group->nickname));
- $subtitle = sprintf(_('Members of %1$s on %2$s'),
- $group->nickname, $sitename);
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- $member = $group->getMembers(($page-1)*$count,
- $count, $since_id, $max_id, $since);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_twitter_xml_users($member);
- break;
- //TODO implement the RSS and ATOM content types
- /*case 'rss':
- $this->show_rss_users($member, $title, $link, $subtitle);
- break;*/
- /*case 'atom':
- if (isset($apidata['api_arg'])) {
- $selfuri = common_root_url() .
- 'api/statusnet/groups/membership/' .
- $apidata['api_arg'] . '.atom';
- } else {
- $selfuri = common_root_url() .
- 'api/statusnet/groups/membership.atom';
- }
- $this->show_atom_users($member, $title, $id, $link,
- $subtitle, null, $selfuri);
- break;*/
- case 'json':
- $this->show_json_users($member);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
- }
-
- function is_member($args, $apidata)
- {
- parent::handle($args);
-
- common_debug("in groups api action");
-
- $this->auth_user = $apidata['user'];
- $group = User_group::staticGet($args['group_id']);
- if(! $group){
- $this->clientError(_('Group not found'), $code = 500);
- }
- $user = User::staticGet('id', $args['user_id']);
- if(! $user){
- $this->clientError(_('User not found'), $code = 500);
- }
-
- $is_member=$user->isMember($group);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->init_document('xml');
- $this->element('is_member', null, $is_member);
- $this->end_document('xml');
- break;
- case 'json':
- $this->init_document('json');
- $this->show_json_objects(array('is_member'=>$is_member));
- $this->end_document('json');
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
- }
-}
diff --git a/actions/twitapihelp.php b/actions/twitapihelp.php
deleted file mode 100644
index 81381620e..000000000
--- a/actions/twitapihelp.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class TwitapihelpAction extends TwitterapiAction
-{
-
- /* Returns the string "ok" in the requested format with a 200 OK HTTP status code.
- * URL:http://identi.ca/api/help/test.format
- * Formats: xml, json
- */
- function test($args, $apidata)
- {
- parent::handle($args);
-
- if ($apidata['content-type'] == 'xml') {
- $this->init_document('xml');
- $this->element('ok', null, 'true');
- $this->end_document('xml');
- } elseif ($apidata['content-type'] == 'json') {
- $this->init_document('json');
- print '"ok"';
- $this->end_document('json');
- } else {
- $this->clientError(_('API method not found!'), $code=404);
- }
-
- }
-
- function downtime_schedule($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
- }
-
-} \ No newline at end of file
diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php
index 2f587d604..7d618c471 100644
--- a/actions/twitapisearchatom.php
+++ b/actions/twitapisearchatom.php
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/twitterapi.php';
+require_once INSTALLDIR.'/lib/api.php';
/**
* Action for outputting search results in Twitter compatible Atom
@@ -46,10 +46,10 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*
- * @see TwitterapiAction
+ * @see ApiAction
*/
-class TwitapisearchatomAction extends TwitterapiAction
+class TwitapisearchatomAction extends ApiAction
{
var $cnt;
@@ -340,7 +340,7 @@ class TwitapisearchatomAction extends TwitterapiAction
// TODO: Here is where we'd put in a link to an atom feed for threads
$this->element("twitter:source", null,
- htmlentities($this->source_link($notice->source)));
+ htmlentities($this->sourceLink($notice->source)));
$this->elementStart('author');
diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php
index c628ee624..c7fa741a0 100644
--- a/actions/twitapisearchjson.php
+++ b/actions/twitapisearchjson.php
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/twitterapi.php';
+require_once INSTALLDIR.'/lib/api.php';
require_once INSTALLDIR.'/lib/jsonsearchresultslist.php';
/**
@@ -42,10 +42,10 @@ require_once INSTALLDIR.'/lib/jsonsearchresultslist.php';
* @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 TwitterapiAction
+ * @see ApiAction
*/
-class TwitapisearchjsonAction extends TwitterapiAction
+class TwitapisearchjsonAction extends ApiAction
{
var $query;
var $lang;
@@ -134,9 +134,9 @@ class TwitapisearchjsonAction extends TwitterapiAction
$results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page);
- $this->init_document('json');
+ $this->initDocument('json');
$results->show();
- $this->end_document('json');
+ $this->endDocument('json');
}
/**
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
deleted file mode 100644
index b0d3e584b..000000000
--- a/actions/twitapistatuses.php
+++ /dev/null
@@ -1,601 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class TwitapistatusesAction extends TwitterapiAction
-{
-
- function public_timeline($args, $apidata)
- {
- // XXX: To really live up to the spec we need to build a list
- // of notices by users who have custom avatars, so fix this SQL -- Zach
-
- parent::handle($args);
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_("%s public timeline"), $sitename);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:PublicTimeline";
- $link = common_root_url();
- $subtitle = sprintf(_("%s updates from everyone!"), $sitename);
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- $notice = Notice::publicStream(($page-1)*$count, $count, $since_id,
- $max_id, $since);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_timeline($notice);
- break;
- case 'rss':
- $this->show_rss_timeline($notice, $title, $link, $subtitle);
- break;
- case 'atom':
- $selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
- $this->show_atom_timeline($notice, $title, $id, $link,
- $subtitle, null, $selfuri);
- break;
- case 'json':
- $this->show_json_timeline($notice);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- break;
- }
-
- }
-
- function friends_timeline($args, $apidata)
- {
- parent::handle($args);
-
- $this->auth_user = $apidata['user'];
- $user = $this->get_user($apidata['api_arg'], $apidata);
-
- if (empty($user)) {
- $this->clientError(_('No such user!'), 404,
- $apidata['content-type']);
- return;
- }
-
- $profile = $user->getProfile();
- $sitename = common_config('site', 'name');
- $title = sprintf(_("%s and friends"), $user->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:FriendsTimeline:" . $user->id;
- $link = common_local_url('all',
- array('nickname' => $user->nickname));
- $subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'),
- $user->nickname, $sitename);
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- if (!empty($this->auth_user) && $this->auth_user->id == $user->id) {
- $notice = $user->noticeInbox(($page-1)*$count,
- $count, $since_id, $max_id, $since);
- } else {
- $notice = $user->noticesWithFriends(($page-1)*$count,
- $count, $since_id, $max_id, $since);
- }
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_timeline($notice);
- break;
- case 'rss':
- $this->show_rss_timeline($notice, $title, $link, $subtitle);
- break;
- case 'atom':
- if (isset($apidata['api_arg'])) {
- $selfuri = common_root_url() .
- 'api/statuses/friends_timeline/' .
- $apidata['api_arg'] . '.atom';
- } else {
- $selfuri = common_root_url() .
- 'api/statuses/friends_timeline.atom';
- }
- $this->show_atom_timeline($notice, $title, $id, $link,
- $subtitle, null, $selfuri);
- break;
- case 'json':
- $this->show_json_timeline($notice);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
-
- }
-
- function home_timeline($args, $apidata)
- {
- call_user_func(array($this, 'friends_timeline'), $args, $apidata);
- }
-
- function user_timeline($args, $apidata)
- {
- parent::handle($args);
-
- $this->auth_user = $apidata['user'];
- $user = $this->get_user($apidata['api_arg'], $apidata);
-
- if (empty($user)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $profile = $user->getProfile();
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_("%s timeline"), $user->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:UserTimeline:".$user->id;
- $link = common_local_url('showstream',
- array('nickname' => $user->nickname));
- $subtitle = sprintf(_('Updates from %1$s on %2$s!'),
- $user->nickname, $sitename);
-
- # FriendFeed's SUP protocol
- # Also added RSS and Atom feeds
-
- $suplink = common_local_url('sup', null, null, $user->id);
- header('X-SUP-ID: '.$suplink);
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- $notice = $user->getNotices(($page-1)*$count,
- $count, $since_id, $max_id, $since);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_timeline($notice);
- break;
- case 'rss':
- $this->show_rss_timeline($notice, $title, $link,
- $subtitle, $suplink);
- break;
- case 'atom':
- if (isset($apidata['api_arg'])) {
- $selfuri = common_root_url() .
- 'api/statuses/user_timeline/' .
- $apidata['api_arg'] . '.atom';
- } else {
- $selfuri = common_root_url() .
- 'api/statuses/user_timeline.atom';
- }
- $this->show_atom_timeline($notice, $title, $id, $link,
- $subtitle, $suplink, $selfuri);
- break;
- case 'json':
- $this->show_json_timeline($notice);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
-
- }
-
- function update($args, $apidata)
- {
- parent::handle($args);
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->clientError(_('This method requires a POST.'),
- 400, $apidata['content-type']);
- return;
- }
-
- $user = $apidata['user']; // Always the auth user
-
- $status = $this->trimmed('status');
- $source = $this->trimmed('source');
- $in_reply_to_status_id =
- intval($this->trimmed('in_reply_to_status_id'));
- $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
-
- if (empty($source) || in_array($source, $reserved_sources)) {
- $source = 'api';
- }
-
- if (empty($status)) {
- $this->clientError(_('Client must provide a \'status\' parameter with a value.'),
- $code = 403, $apidata['content-type']);
- return;
-
- } else {
-
- $status_shortened = common_shorten_links($status);
-
- if (mb_strlen($status_shortened) > 140) {
-
- // XXX: Twitter truncates anything over 140, flags the status
- // as "truncated." Sending this error may screw up some clients
- // that assume Twitter will truncate for them. Should we just
- // truncate too? -- Zach
- $this->clientError(_('That\'s too long. Max notice size is 140 chars.'),
- $code = 406, $apidata['content-type']);
- return;
- }
- }
-
- // Check for commands
- $inter = new CommandInterpreter();
- $cmd = $inter->handle_command($user, $status_shortened);
-
- if ($cmd) {
-
- if ($this->supported($cmd)) {
- $cmd->execute(new Channel());
- }
-
- // cmd not supported? Twitter just returns your latest status.
- // And, it returns your last status whether the cmd was successful
- // or not!
- $n = $user->getCurrentNotice();
- $apidata['api_arg'] = $n->id;
- } else {
-
- $reply_to = null;
-
- if ($in_reply_to_status_id) {
-
- // check whether notice actually exists
- $reply = Notice::staticGet($in_reply_to_status_id);
-
- if ($reply) {
- $reply_to = $in_reply_to_status_id;
- } else {
- $this->clientError(_('Not found'), $code = 404,
- $apidata['content-type']);
- return;
- }
- }
-
- $notice = Notice::saveNew($user->id,
- html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'),
- $source, 1, $reply_to);
-
- if (is_string($notice)) {
- $this->serverError($notice, 500, $apidata['content-type']);
- return;
- }
-
- common_broadcast_notice($notice);
- $apidata['api_arg'] = $notice->id;
- }
-
- $this->show($args, $apidata);
- }
-
- function mentions($args, $apidata)
- {
- parent::handle($args);
-
- $user = $this->get_user($apidata['api_arg'], $apidata);
- $this->auth_user = $apidata['user'];
-
- if (empty($user)) {
- $this->clientError(_('No such user!'), 404,
- $apidata['content-type']);
- return;
- }
-
- $profile = $user->getProfile();
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_('%1$s / Updates mentioning %2$s'),
- $sitename, $user->nickname);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:Mentions:".$user->id;
- $link = common_local_url('replies',
- array('nickname' => $user->nickname));
- $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'),
- $sitename, $user->nickname, $profile->getBestName());
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- $notice = $user->getReplies(($page-1)*$count,
- $count, $since_id, $max_id, $since);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_timeline($notice);
- break;
- case 'rss':
- $this->show_rss_timeline($notice, $title, $link, $subtitle);
- break;
- case 'atom':
- $selfuri = common_root_url() .
- ltrim($_SERVER['QUERY_STRING'], 'p=');
- $this->show_atom_timeline($notice, $title, $id, $link, $subtitle,
- null, $selfuri);
- break;
- case 'json':
- $this->show_json_timeline($notice);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
-
- }
-
- function replies($args, $apidata)
- {
- call_user_func(array($this, 'mentions'), $args, $apidata);
- }
-
- function show($args, $apidata)
- {
- parent::handle($args);
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- // 'id' is an undocumented parameter in Twitter's API. Several
- // clients make use of it, so we support it too.
-
- // show.json?id=12345 takes precedence over /show/12345.json
-
- $this->auth_user = $apidata['user'];
- $notice_id = $this->trimmed('id');
-
- if (empty($notice_id)) {
- $notice_id = $apidata['api_arg'];
- }
-
- $notice = Notice::staticGet((int)$notice_id);
-
- if ($notice) {
- if ($apidata['content-type'] == 'xml') {
- $this->show_single_xml_status($notice);
- } elseif ($apidata['content-type'] == 'json') {
- $this->show_single_json_status($notice);
- }
- } else {
- // XXX: Twitter just sets a 404 header and doens't bother
- // to return an err msg
- $this->clientError(_('No status with that ID found.'),
- 404, $apidata['content-type']);
- }
- }
-
- function destroy($args, $apidata)
- {
- parent::handle($args);
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- // Check for RESTfulness
- if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
- // XXX: Twitter just prints the err msg, no XML / JSON.
- $this->clientError(_('This method requires a POST or DELETE.'),
- 400, $apidata['content-type']);
- return;
- }
-
- $user = $apidata['user']; // Always the auth user
- $notice_id = $apidata['api_arg'];
- $notice = Notice::staticGet($notice_id);
-
- if (empty($notice)) {
- $this->clientError(_('No status found with that ID.'),
- 404, $apidata['content-type']);
- return;
- }
-
- if ($user->id == $notice->profile_id) {
- $replies = new Reply;
- $replies->get('notice_id', $notice_id);
- $replies->delete();
- $notice->delete();
-
- if ($apidata['content-type'] == 'xml') {
- $this->show_single_xml_status($notice);
- } elseif ($apidata['content-type'] == 'json') {
- $this->show_single_json_status($notice);
- }
- } else {
- $this->clientError(_('You may not delete another user\'s status.'),
- 403, $apidata['content-type']);
- }
-
- }
-
- function friends($args, $apidata)
- {
- parent::handle($args);
- $includeStatuses= !(array_key_exists('lite', $args) and $args['lite']);
- return $this->subscriptions($apidata, 'subscribed', 'subscriber', false, $includeStatuses);
- }
-
- function friendsIDs($args, $apidata)
- {
- parent::handle($args);
- return $this->subscriptions($apidata, 'subscribed', 'subscriber', true);
- }
-
- function followers($args, $apidata)
- {
- parent::handle($args);
- $includeStatuses= !(array_key_exists('lite', $args) and $args['lite']);
- return $this->subscriptions($apidata, 'subscriber', 'subscribed', false, $includeStatuses);
- }
-
- function followersIDs($args, $apidata)
- {
- parent::handle($args);
- return $this->subscriptions($apidata, 'subscriber', 'subscribed', true);
- }
-
- function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false, $includeStatuses=true)
- {
- $this->auth_user = $apidata['user'];
- $user = $this->get_user($apidata['api_arg'], $apidata);
-
- if (empty($user)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $profile = $user->getProfile();
-
- $sub = new Subscription();
- $sub->$user_attr = $profile->id;
-
- $sub->orderBy('created DESC');
-
- // Normally, page 100 friends at a time
-
- if (!$onlyIDs) {
- $page = $this->arg('page', 1);
- $count = $this->arg('count', 100);
- $sub->limit(($page-1)*$count, $count);
- } else {
-
- // If we're just looking at IDs, return
- // ALL of them, unless the user specifies a page,
- // in which case, return 500 per page.
-
- $page = $this->arg('page');
- if (!empty($page)) {
- if ($page < 1) {
- $page = 1;
- }
- $count = 500;
- $sub->limit(($page-1)*$count, $count);
- }
- }
-
- $others = array();
-
- if ($sub->find()) {
- while ($sub->fetch()) {
- $others[] = Profile::staticGet($sub->$other_attr);
- }
- } else {
- // user has no followers
- }
-
- $type = $apidata['content-type'];
-
- $this->init_document($type);
-
- if ($onlyIDs) {
- $this->showIDs($others, $type);
- } else {
- $this->show_profiles($others, $type, $includeStatuses);
- }
-
- $this->end_document($type);
- }
-
- function show_profiles($profiles, $type, $includeStatuses)
- {
- switch ($type) {
- case 'xml':
- $this->elementStart('users', array('type' => 'array'));
- foreach ($profiles as $profile) {
- $this->show_profile($profile,$type,null,$includeStatuses);
- }
- $this->elementEnd('users');
- break;
- case 'json':
- $arrays = array();
- foreach ($profiles as $profile) {
- $arrays[] = $this->twitter_user_array($profile, $includeStatuses);
- }
- print json_encode($arrays);
- break;
- default:
- $this->clientError(_('unsupported file type'));
- }
- }
-
- function showIDs($profiles, $type)
- {
- switch ($type) {
- case 'xml':
- $this->elementStart('ids');
- foreach ($profiles as $profile) {
- $this->element('id', null, $profile->id);
- }
- $this->elementEnd('ids');
- break;
- case 'json':
- $ids = array();
- foreach ($profiles as $profile) {
- $ids[] = (int)$profile->id;
- }
- print json_encode($ids);
- break;
- default:
- $this->clientError(_('unsupported file type'));
- }
- }
-
- function featured($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
- }
-
- function supported($cmd)
- {
- $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand',
- 'FavCommand', 'OnCommand', 'OffCommand');
-
- if (in_array(get_class($cmd), $cmdlist)) {
- return true;
- }
-
- return false;
- }
-
-}
diff --git a/actions/twitapistatusnet.php b/actions/twitapistatusnet.php
deleted file mode 100644
index 490f11dce..000000000
--- a/actions/twitapistatusnet.php
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * StatusNet-only extensions to the Twitter-like API
- *
- * 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 Twitter
- * @package StatusNet
- * @author Evan Prodromou <evan@status.net>
- * @copyright 2008 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.'/lib/twitterapi.php';
-
-/**
- * StatusNet-specific API methods
- *
- * This class handles all /statusnet/ API methods.
- *
- * @category Twitter
- * @package StatusNet
- * @author Evan Prodromou <evan@status.net>
- * @copyright 2008 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/
- */
-
-class TwitapistatusnetAction extends TwitterapiAction
-{
- /**
- * A version stamp for the API
- *
- * Returns a version number for this version of StatusNet, which
- * should make things a bit easier for upgrades.
- * URL: http://identi.ca/api/statusnet/version.(xml|json)
- * Formats: xml, json
- *
- * @param array $args Web arguments
- * @param array $apidata Twitter API data
- *
- * @return void
- *
- * @see ApiAction::process_command()
- */
-
- function version($args, $apidata)
- {
- parent::handle($args);
- switch ($apidata['content-type']) {
- case 'xml':
- $this->init_document('xml');
- $this->element('version', null, STATUSNET_VERSION);
- $this->end_document('xml');
- break;
- case 'json':
- $this->init_document('json');
- print '"'.STATUSNET_VERSION.'"';
- $this->end_document('json');
- break;
- default:
- $this->clientError(_('API method not found!'), $code=404);
- }
- }
-
- /**
- * Dump of configuration variables
- *
- * Gives a full dump of configuration variables for this instance
- * of StatusNet, minus variables that may be security-sensitive (like
- * passwords).
- * URL: http://identi.ca/api/statusnet/config.(xml|json)
- * Formats: xml, json
- *
- * @param array $args Web arguments
- * @param array $apidata Twitter API data
- *
- * @return void
- *
- * @see ApiAction::process_command()
- */
-
- function config($args, $apidata)
- {
- static $keys = array('site' => array('name', 'server', 'theme', 'path', 'fancy', 'language',
- 'email', 'broughtby', 'broughtbyurl', 'closed',
- 'inviteonly', 'private'),
- 'license' => array('url', 'title', 'image'),
- 'nickname' => array('featured'),
- 'throttle' => array('enabled', 'count', 'timespan'),
- 'xmpp' => array('enabled', 'server', 'user'));
-
- parent::handle($args);
-
- switch ($apidata['content-type']) {
- case 'xml':
- $this->init_document('xml');
- $this->elementStart('config');
- // XXX: check that all sections and settings are legal XML elements
- foreach ($keys as $section => $settings) {
- $this->elementStart($section);
- foreach ($settings as $setting) {
- $value = common_config($section, $setting);
- if (is_array($value)) {
- $value = implode(',', $value);
- } else if ($value === false) {
- $value = 'false';
- } else if ($value === true) {
- $value = 'true';
- }
- $this->element($setting, null, $value);
- }
- $this->elementEnd($section);
- }
- $this->elementEnd('config');
- $this->end_document('xml');
- break;
- case 'json':
- $result = array();
- foreach ($keys as $section => $settings) {
- $result[$section] = array();
- foreach ($settings as $setting) {
- $result[$section][$setting] = common_config($section, $setting);
- }
- }
- $this->init_document('json');
- $this->show_json_objects($result);
- $this->end_document('json');
- break;
- default:
- $this->clientError(_('API method not found!'), $code=404);
- }
- }
-
- /**
- * WADL description of the API
- *
- * Gives a WADL description of the API provided by this version of the
- * software.
- *
- * @param array $args Web arguments
- * @param array $apidata Twitter API data
- *
- * @return void
- *
- * @see ApiAction::process_command()
- */
-
- function wadl($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), 501);
- }
-
-}
diff --git a/actions/twitapitags.php b/actions/twitapitags.php
deleted file mode 100644
index 0bcc55d37..000000000
--- a/actions/twitapitags.php
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * StatusNet extensions to the Twitter-like API for groups
- *
- * 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 Twitter
- * @package StatusNet
- * @author Craig Andrews <candrews@integralblue.com>
- * @author Zach Copley <zach@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') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once INSTALLDIR.'/lib/twitterapi.php';
-
-/**
- * Group-specific API methods
- *
- * This class handles StatusNet group API methods.
- *
- * @category Twitter
- * @package StatusNet
- * @author Craig Andrews <candrews@integralblue.com>
- * @author Zach Copley <zach@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/
- */
-
- class TwitapitagsAction extends TwitterapiAction
- {
-
- function timeline($args, $apidata)
- {
- parent::handle($args);
-
- common_debug("in tags api action");
-
- $this->auth_user = $apidata['user'];
- $tag = $apidata['api_arg'];
-
- if (empty($tag)) {
- $this->clientError('Not Found', 404, $apidata['content-type']);
- return;
- }
-
- $sitename = common_config('site', 'name');
- $title = sprintf(_("Notices tagged with %s"), $tag);
- $taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:TagTimeline:".$tag;
- $link = common_local_url('tag',
- array('tag' => $tag));
- $subtitle = sprintf(_('Updates tagged with %1$s on %2$s!'),
- $tag, $sitename);
-
- $page = (int)$this->arg('page', 1);
- $count = (int)$this->arg('count', 20);
- $max_id = (int)$this->arg('max_id', 0);
- $since_id = (int)$this->arg('since_id', 0);
- $since = $this->arg('since');
-
- # XXX: support max_id, since_id, and since arguments
- $notice = Notice_tag::getStream($tag, ($page-1)*$count, $count + 1);
-
- switch($apidata['content-type']) {
- case 'xml':
- $this->show_xml_timeline($notice);
- break;
- case 'rss':
- $this->show_rss_timeline($notice, $title, $link, $subtitle);
- break;
- case 'atom':
- if (isset($apidata['api_arg'])) {
- $selfuri = common_root_url() .
- 'api/statusnet/tags/timeline/' .
- $apidata['api_arg'] . '.atom';
- } else {
- $selfuri = common_root_url() .
- 'api/statusnet/tags/timeline.atom';
- }
- $this->show_atom_timeline($notice, $title, $id, $link,
- $subtitle, null, $selfuri);
- break;
- case 'json':
- $this->show_json_timeline($notice);
- break;
- default:
- $this->clientError(_('API method not found!'), $code = 404);
- }
- }
-
-}
diff --git a/actions/twitapitrends.php b/actions/twitapitrends.php
index 83ab28f35..779405e6d 100644
--- a/actions/twitapitrends.php
+++ b/actions/twitapitrends.php
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/twitterapi.php';
+require_once INSTALLDIR.'/lib/api.php';
/**
* Returns the top ten queries that are currently trending
@@ -42,10 +42,10 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*
- * @see TwitterapiAction
+ * @see ApiAction
*/
-class TwitapitrendsAction extends TwitterapiAction
+class TwitapitrendsAction extends ApiAction
{
var $callback;
diff --git a/actions/twitapiusers.php b/actions/twitapiusers.php
deleted file mode 100644
index 703fa6754..000000000
--- a/actions/twitapiusers.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, 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/>.
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/twitterapi.php');
-
-class TwitapiusersAction extends TwitterapiAction
-{
-
- function show($args, $apidata)
- {
- parent::handle($args);
-
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- $this->clientError(_('API method not found!'), $code = 404);
- return;
- }
-
- $user = null;
- $email = $this->arg('email');
-
- // XXX: email field deprecated in Twitter's API
-
- if ($email) {
- $user = User::staticGet('email', $email);
- } else {
- $user = $this->get_user($apidata['api_arg'], $apidata);
- }
-
- if (empty($user)) {
- $this->clientError(_('Not found.'), 404, $apidata['content-type']);
- return;
- }
-
- $profile = $user->getProfile();
-
- if (!$profile) {
- common_server_error(_('User has no profile.'));
- return;
- }
-
- $twitter_user = $this->twitter_user_array($user->getProfile(), true);
-
- if ($apidata['content-type'] == 'xml') {
- $this->init_document('xml');
- $this->show_twitter_xml_user($twitter_user);
- $this->end_document('xml');
- } elseif ($apidata['content-type'] == 'json') {
- $this->init_document('json');
- $this->show_json_objects($twitter_user);
- $this->end_document('json');
- } else {
-
- // This is in case 'show' was called via /account/verify_credentials
- // without a format (xml or json).
- header('Content-Type: text/html; charset=utf-8');
- print 'Authorized';
- }
-
- }
-}
diff --git a/actions/updateprofile.php b/actions/updateprofile.php
index 9a4cf8e46..3cec9523c 100644
--- a/actions/updateprofile.php
+++ b/actions/updateprofile.php
@@ -1,5 +1,16 @@
<?php
-/*
+/**
+ * Handle an updateprofile action
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
@@ -19,165 +30,54 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/omb.php');
+require_once INSTALLDIR.'/lib/omb.php';
+require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
+/**
+ * Handle an updateprofile action
+ *
+ * @category Action
+ * @package Laconica
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://laconi.ca/
+ */
class UpdateprofileAction extends Action
{
-
- function handle($args)
- {
- parent::handle($args);
- try {
- common_remove_magic_from_request();
- $req = OAuthRequest::from_request('POST', common_local_url('updateprofile'));
- # Note: server-to-server function!
- $server = omb_oauth_server();
- list($consumer, $token) = $server->verify_request($req);
- if ($this->update_profile($req, $consumer, $token)) {
- header('HTTP/1.1 200 OK');
- header('Content-type: text/plain');
- print "omb_version=".OMB_VERSION_01;
- }
- } catch (OAuthException $e) {
- $this->serverError($e->getMessage());
- return;
- }
- }
- function update_profile($req, $consumer, $token)
+ /**
+ * For initializing members of the class.
+ *
+ * @param array $argarray misc. arguments
+ *
+ * @return boolean true
+ */
+ function prepare($argarray)
{
- $version = $req->get_parameter('omb_version');
- if ($version != OMB_VERSION_01) {
- $this->clientError(_('Unsupported OMB version'), 400);
+ parent::prepare($argarray);
+ $license = $_POST['omb_listenee_license'];
+ $site_license = common_config('license', 'url');
+ if (!common_compatible_license($license, $site_license)) {
+ $this->clientError(sprintf(_('Listenee stream license ‘%s’ is not '.
+ 'compatible with site license ‘%s’.'),
+ $license, $site_license));
return false;
}
- # First, check to see if listenee exists
- $listenee = $req->get_parameter('omb_listenee');
- $remote = Remote_profile::staticGet('uri', $listenee);
- if (!$remote) {
- $this->clientError(_('Profile unknown'), 404);
- return false;
- }
- # Second, check to see if they should be able to post updates!
- # We see if there are any subscriptions to that remote user with
- # the given token.
-
- $sub = new Subscription();
- $sub->subscribed = $remote->id;
- $sub->token = $token->key;
- if (!$sub->find(true)) {
- $this->clientError(_('You did not send us that profile'), 403);
- return false;
- }
-
- $profile = Profile::staticGet('id', $remote->id);
- if (!$profile) {
- # This one is our fault
- $this->serverError(_('Remote profile with no matching profile'), 500);
- return false;
- }
- $nickname = $req->get_parameter('omb_listenee_nickname');
- if ($nickname && !Validate::string($nickname, array('min_length' => 1,
- 'max_length' => 64,
- 'format' => NICKNAME_FMT))) {
- $this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.'));
- return false;
- }
- $license = $req->get_parameter('omb_listenee_license');
- if ($license && !common_valid_http_url($license)) {
- $this->clientError(sprintf(_("Invalid license URL '%s'"), $license));
- return false;
- }
- $profile_url = $req->get_parameter('omb_listenee_profile');
- if ($profile_url && !common_valid_http_url($profile_url)) {
- $this->clientError(sprintf(_("Invalid profile URL '%s'."), $profile_url));
- return false;
- }
- # optional stuff
- $fullname = $req->get_parameter('omb_listenee_fullname');
- if ($fullname && mb_strlen($fullname) > 255) {
- $this->clientError(_("Full name is too long (max 255 chars)."));
- return false;
- }
- $homepage = $req->get_parameter('omb_listenee_homepage');
- if ($homepage && (!common_valid_http_url($homepage) || mb_strlen($homepage) > 255)) {
- $this->clientError(sprintf(_("Invalid homepage '%s'"), $homepage));
- return false;
- }
- $bio = $req->get_parameter('omb_listenee_bio');
- if ($bio && mb_strlen($bio) > 140) {
- $this->clientError(_("Bio is too long (max 140 chars)."));
- return false;
- }
- $location = $req->get_parameter('omb_listenee_location');
- if ($location && mb_strlen($location) > 255) {
- $this->clientError(_("Location is too long (max 255 chars)."));
- return false;
- }
- $avatar = $req->get_parameter('omb_listenee_avatar');
- if ($avatar) {
- if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
- $this->clientError(sprintf(_("Invalid avatar URL '%s'"), $avatar));
- return false;
- }
- $size = @getimagesize($avatar);
- if (!$size) {
- $this->clientError(sprintf(_("Can't read avatar URL '%s'"), $avatar));
- return false;
- }
- if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
- $this->clientError(sprintf(_("Wrong size image at '%s'"), $avatar));
- return false;
- }
- if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
- IMAGETYPE_PNG))) {
- $this->clientError(sprintf(_("Wrong image type for '%s'"), $avatar));
- return false;
- }
- }
-
- $orig_profile = clone($profile);
+ return true;
+ }
- /* Use values even if they are an empty string. Parsing an empty string in
- updateProfile is the specified way of clearing a parameter in OMB. */
- if (!is_null($nickname)) {
- $profile->nickname = $nickname;
- }
- if (!is_null($profile_url)) {
- $profile->profileurl = $profile_url;
- }
- if (!is_null($fullname)) {
- $profile->fullname = $fullname;
- }
- if (!is_null($homepage)) {
- $profile->homepage = $homepage;
- }
- if (!is_null($bio)) {
- $profile->bio = $bio;
- }
- if (!is_null($location)) {
- $profile->location = $location;
- }
+ function handle($args)
+ {
+ parent::handle($args);
- if (!$profile->update($orig_profile)) {
- $this->serverError(_('Could not save new profile info'), 500);
- return false;
- } else {
- if ($avatar) {
- $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
- copy($avatar, $temp_filename);
- $imagefile = new ImageFile($profile->id, $temp_filename);
- $filename = Avatar::filename($profile->id,
- image_type_to_extension($imagefile->type),
- null,
- common_timestamp());
- rename($temp_filename, Avatar::path($filename));
- if (!$profile->setOriginal($filename)) {
- $this->serverError(_('Could not save avatar info'), 500);
- return false;
- }
- }
- return true;
+ try {
+ $srv = new OMB_Service_Provider(null, omb_oauth_datastore(),
+ omb_oauth_server());
+ $srv->handleUpdateProfile();
+ } catch (Exception $e) {
+ $this->serverError($e->getMessage());
+ return;
}
}
}
diff --git a/actions/userauthorization.php b/actions/userauthorization.php
index a9ac1f256..dc59e6c94 100644
--- a/actions/userauthorization.php
+++ b/actions/userauthorization.php
@@ -1,5 +1,16 @@
<?php
-/*
+/**
+ * Let the user authorize a remote subscription request
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
@@ -19,7 +30,9 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/omb.php');
+require_once INSTALLDIR.'/lib/omb.php';
+require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
+require_once INSTALLDIR.'/extlib/libomb/profile.php';
define('TIMESTAMP_THRESHOLD', 300);
class UserauthorizationAction extends Action
@@ -32,46 +45,58 @@ class UserauthorizationAction extends Action
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- # CSRF protection
+ /* Use a session token for CSRF protection. */
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $params = $this->getStoredParams();
- $this->showForm($params, _('There was a problem with your session token. '.
- 'Try again, please.'));
+ $srv = $this->getStoredParams();
+ $this->showForm($srv->getRemoteUser(), _('There was a problem ' .
+ 'with your session token. Try again, ' .
+ 'please.'));
return;
}
- # We've shown the form, now post user's choice
+ /* We've shown the form, now post user's choice. */
$this->sendAuthorization();
} else {
if (!common_logged_in()) {
- # Go log in, and then come back
+ /* Go log in, and then come back. */
common_set_returnto($_SERVER['REQUEST_URI']);
- if (!common_config('site', 'openidonly')) {
- common_redirect(common_local_url('login'));
- } else {
- common_redirect(common_local_url('openidlogin'));
- }
+ common_redirect(common_local_url('login'));
+ return;
+ }
+
+ $user = common_current_user();
+ $profile = $user->getProfile();
+ if (!$profile) {
+ common_log_db_error($user, 'SELECT', __FILE__);
+ $this->serverError(_('User without matching profile'));
return;
}
+ /* TODO: If no token is passed the user should get a prompt to enter
+ it according to OAuth Core 1.0. */
try {
- $this->validateRequest();
- $this->storeParams($_GET);
- $this->showForm($_GET);
- } catch (OAuthException $e) {
+ $this->validateOmb();
+ $srv = new OMB_Service_Provider(
+ profile_to_omb_profile($user->uri, $profile),
+ omb_oauth_datastore());
+
+ $remote_user = $srv->handleUserAuth();
+ } catch (Exception $e) {
$this->clearParams();
$this->clientError($e->getMessage());
return;
}
+ $this->storeParams($srv);
+ $this->showForm($remote_user);
}
}
function showForm($params, $error=null)
{
$this->params = $params;
- $this->error = $error;
+ $this->error = $error;
$this->showPage();
}
@@ -83,23 +108,24 @@ class UserauthorizationAction extends Action
function showPageNotice()
{
$this->element('p', null, _('Please check these details to make sure '.
- 'that you want to subscribe to this user\'s notices. '.
- 'If you didn\'t just ask to subscribe to someone\'s notices, '.
- 'click "Reject".'));
+ 'that you want to subscribe to this ' .
+ 'user’s notices. If you didn’t just ask ' .
+ 'to subscribe to someone’s notices, '.
+ 'click “Reject”.'));
}
function showContent()
{
$params = $this->params;
- $nickname = $params['omb_listenee_nickname'];
- $profile = $params['omb_listenee_profile'];
- $license = $params['omb_listenee_license'];
- $fullname = $params['omb_listenee_fullname'];
- $homepage = $params['omb_listenee_homepage'];
- $bio = $params['omb_listenee_bio'];
- $location = $params['omb_listenee_location'];
- $avatar = $params['omb_listenee_avatar'];
+ $nickname = $params->getNickname();
+ $profile = $params->getProfileURL();
+ $license = $params->getLicenseURL();
+ $fullname = $params->getFullname();
+ $homepage = $params->getHomepage();
+ $bio = $params->getBio();
+ $location = $params->getLocation();
+ $avatar = $params->getAvatarURL();
$this->elementStart('div', array('class' => 'profile'));
$this->elementStart('div', 'entity_profile vcard');
@@ -176,11 +202,14 @@ class UserauthorizationAction extends Action
'id' => 'userauthorization',
'class' => 'form_user_authorization',
'name' => 'userauthorization',
- 'action' => common_local_url('userauthorization')));
+ 'action' => common_local_url(
+ 'userauthorization')));
$this->hidden('token', common_session_token());
- $this->submit('accept', _('Accept'), 'submit accept', null, _('Subscribe to this user'));
- $this->submit('reject', _('Reject'), 'submit reject', null, _('Reject this subscription'));
+ $this->submit('accept', _('Accept'), 'submit accept', null,
+ _('Subscribe to this user'));
+ $this->submit('reject', _('Reject'), 'submit reject', null,
+ _('Reject this subscription'));
$this->elementEnd('form');
$this->elementEnd('li');
$this->elementEnd('ul');
@@ -190,191 +219,27 @@ class UserauthorizationAction extends Action
function sendAuthorization()
{
- $params = $this->getStoredParams();
+ $srv = $this->getStoredParams();
- if (!$params) {
+ if (is_null($srv)) {
$this->clientError(_('No authorization request!'));
return;
}
- $callback = $params['oauth_callback'];
-
- if ($this->arg('accept')) {
- if (!$this->authorizeToken($params)) {
- $this->clientError(_('Error authorizing token'));
- }
- if (!$this->saveRemoteProfile($params)) {
- $this->clientError(_('Error saving remote profile'));
- }
- if (!$callback) {
- $this->showAcceptMessage($params['oauth_token']);
- } else {
- $newparams = array();
- $newparams['oauth_token'] = $params['oauth_token'];
- $newparams['omb_version'] = OMB_VERSION_01;
- $user = User::staticGet('uri', $params['omb_listener']);
- $profile = $user->getProfile();
- if (!$profile) {
- common_log_db_error($user, 'SELECT', __FILE__);
- $this->serverError(_('User without matching profile'));
- return;
- }
- $newparams['omb_listener_nickname'] = $user->nickname;
- $newparams['omb_listener_profile'] = common_local_url('showstream',
- array('nickname' => $user->nickname));
- if (!is_null($profile->fullname)) {
- $newparams['omb_listener_fullname'] = $profile->fullname;
- }
- if (!is_null($profile->homepage)) {
- $newparams['omb_listener_homepage'] = $profile->homepage;
- }
- if (!is_null($profile->bio)) {
- $newparams['omb_listener_bio'] = $profile->bio;
- }
- if (!is_null($profile->location)) {
- $newparams['omb_listener_location'] = $profile->location;
- }
- $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
- if ($avatar) {
- $newparams['omb_listener_avatar'] = $avatar->url;
- }
- $parts = array();
- foreach ($newparams as $k => $v) {
- $parts[] = $k . '=' . OAuthUtil::urlencode_rfc3986($v);
- }
- $query_string = implode('&', $parts);
- $parsed = parse_url($callback);
- $url = $callback . (($parsed['query']) ? '&' : '?') . $query_string;
- common_redirect($url, 303);
- }
- } else {
- if (!$callback) {
- $this->showRejectMessage();
- } else {
- # XXX: not 100% sure how to signal failure... just redirect without token?
- common_redirect($callback, 303);
- }
- }
- }
-
- function authorizeToken(&$params)
- {
- $token_field = $params['oauth_token'];
- $rt = new Token();
- $rt->tok = $token_field;
- $rt->type = 0;
- $rt->state = 0;
- if ($rt->find(true)) {
- $orig_rt = clone($rt);
- $rt->state = 1; # Authorized but not used
- if ($rt->update($orig_rt)) {
- return true;
- }
- }
- return false;
- }
-
- # XXX: refactor with similar code in finishremotesubscribe.php
-
- function saveRemoteProfile(&$params)
- {
- # FIXME: we should really do this when the consumer comes
- # back for an access token. If they never do, we've got stuff in a
- # weird state.
-
- $nickname = $params['omb_listenee_nickname'];
- $fullname = $params['omb_listenee_fullname'];
- $profile_url = $params['omb_listenee_profile'];
- $homepage = $params['omb_listenee_homepage'];
- $bio = $params['omb_listenee_bio'];
- $location = $params['omb_listenee_location'];
- $avatar_url = $params['omb_listenee_avatar'];
-
- $listenee = $params['omb_listenee'];
- $remote = Remote_profile::staticGet('uri', $listenee);
-
- if ($remote) {
- $exists = true;
- $profile = Profile::staticGet($remote->id);
- $orig_remote = clone($remote);
- $orig_profile = clone($profile);
- } else {
- $exists = false;
- $remote = new Remote_profile();
- $remote->uri = $listenee;
- $profile = new Profile();
- }
-
- $profile->nickname = $nickname;
- $profile->profileurl = $profile_url;
-
- if (!is_null($fullname)) {
- $profile->fullname = $fullname;
- }
- if (!is_null($homepage)) {
- $profile->homepage = $homepage;
- }
- if (!is_null($bio)) {
- $profile->bio = $bio;
- }
- if (!is_null($location)) {
- $profile->location = $location;
+ $accepted = $this->arg('accept');
+ try {
+ list($val, $token) = $srv->continueUserAuth($accepted);
+ } catch (Exception $e) {
+ $this->clientError($e->getMessage());
+ return;
}
-
- if ($exists) {
- $profile->update($orig_profile);
+ if ($val !== false) {
+ common_redirect($val, 303);
+ } elseif ($accepted) {
+ $this->showAcceptMessage($token);
} else {
- $profile->created = DB_DataObject_Cast::dateTime(); # current time
- $id = $profile->insert();
- if (!$id) {
- return false;
- }
- $remote->id = $id;
+ $this->showRejectMessage();
}
-
- if ($exists) {
- if (!$remote->update($orig_remote)) {
- return false;
- }
- } else {
- $remote->created = DB_DataObject_Cast::dateTime(); # current time
- if (!$remote->insert()) {
- return false;
- }
- }
-
- if ($avatar_url) {
- if (!$this->addAvatar($profile, $avatar_url)) {
- return false;
- }
- }
-
- $user = common_current_user();
-
- $sub = new Subscription();
- $sub->subscriber = $user->id;
- $sub->subscribed = $remote->id;
- $sub->token = $params['oauth_token']; # NOTE: request token, not valid for use!
- $sub->created = DB_DataObject_Cast::dateTime(); # current time
-
- if (!$sub->insert()) {
- return false;
- }
-
- return true;
- }
-
- function addAvatar($profile, $url)
- {
- $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
- copy($url, $temp_filename);
- $imagefile = new ImageFile($profile->id, $temp_filename);
- $filename = Avatar::filename($profile->id,
- image_type_to_extension($imagefile->type),
- null,
- common_timestamp());
- rename($temp_filename, Avatar::path($filename));
- return $profile->setOriginal($filename);
}
function showAcceptMessage($tok)
@@ -382,26 +247,28 @@ class UserauthorizationAction extends Action
common_show_header(_('Subscription authorized'));
$this->element('p', null,
_('The subscription has been authorized, but no '.
- 'callback URL was passed. Check with the site\'s instructions for '.
- 'details on how to authorize the subscription. Your subscription token is:'));
+ 'callback URL was passed. Check with the site’s ' .
+ 'instructions for details on how to authorize the ' .
+ 'subscription. Your subscription token is:'));
$this->element('blockquote', 'token', $tok);
common_show_footer();
}
- function showRejectMessage($tok)
+ function showRejectMessage()
{
common_show_header(_('Subscription rejected'));
$this->element('p', null,
_('The subscription has been rejected, but no '.
- 'callback URL was passed. Check with the site\'s instructions for '.
- 'details on how to fully reject the subscription.'));
+ 'callback URL was passed. Check with the site’s ' .
+ 'instructions for details on how to fully reject ' .
+ 'the subscription.'));
common_show_footer();
}
function storeParams($params)
{
common_ensure_session();
- $_SESSION['userauthorizationparams'] = $params;
+ $_SESSION['userauthorizationparams'] = serialize($params);
}
function clearParams()
@@ -413,138 +280,74 @@ class UserauthorizationAction extends Action
function getStoredParams()
{
common_ensure_session();
- $params = $_SESSION['userauthorizationparams'];
+ $params = unserialize($_SESSION['userauthorizationparams']);
return $params;
}
- # Throws an OAuthException if anything goes wrong
-
- function validateRequest()
- {
- /* Find token.
- TODO: If no token is passed the user should get a prompt to enter it
- according to OAuth Core 1.0 */
- $t = new Token();
- $t->tok = $_GET['oauth_token'];
- $t->type = 0;
- if (!$t->find(true)) {
- throw new OAuthException("Invalid request token: " . $_GET['oauth_token']);
- }
-
- $this->validateOmb();
- return true;
- }
-
function validateOmb()
{
- foreach (array('omb_version', 'omb_listener', 'omb_listenee',
- 'omb_listenee_profile', 'omb_listenee_nickname',
- 'omb_listenee_license') as $param)
- {
- if (!isset($_GET[$param]) || is_null($_GET[$param])) {
- throw new OAuthException("Required parameter '$param' not found");
- }
- }
- # Now, OMB stuff
- $version = $_GET['omb_version'];
- if ($version != OMB_VERSION_01) {
- throw new OAuthException("OpenMicroBlogging version '$version' not supported");
- }
$listener = $_GET['omb_listener'];
+ $listenee = $_GET['omb_listenee'];
+ $nickname = $_GET['omb_listenee_nickname'];
+ $profile = $_GET['omb_listenee_profile'];
+
$user = User::staticGet('uri', $listener);
if (!$user) {
- throw new OAuthException("Listener URI '$listener' not found here");
- }
- $cur = common_current_user();
- if ($cur->id != $user->id) {
- throw new OAuthException("Can't add for another user!");
- }
- $listenee = $_GET['omb_listenee'];
- if (!Validate::uri($listenee) &&
- !common_valid_tag($listenee)) {
- throw new OAuthException("Listenee URI '$listenee' not a recognizable URI");
+ throw new Exception(sprintf(_('Listener URI ‘%s’ not found here'),
+ $listener));
}
+
if (strlen($listenee) > 255) {
- throw new OAuthException("Listenee URI '$listenee' too long");
+ throw new Exception(sprintf(_('Listenee URI ‘%s’ is too long.'),
+ $listenee));
}
$other = User::staticGet('uri', $listenee);
if ($other) {
- throw new OAuthException("Listenee URI '$listenee' is local user");
+ throw new Exception(sprintf(_('Listenee URI ‘%s’ is a local user.'),
+ $listenee));
}
$remote = Remote_profile::staticGet('uri', $listenee);
if ($remote) {
- $sub = new Subscription();
+ $sub = new Subscription();
$sub->subscriber = $user->id;
$sub->subscribed = $remote->id;
if ($sub->find(true)) {
- throw new OAuthException("Already subscribed to user!");
+ throw new Exception('You are already subscribed to this user.');
}
}
- $nickname = $_GET['omb_listenee_nickname'];
- if (!Validate::string($nickname, array('min_length' => 1,
- 'max_length' => 64,
- 'format' => NICKNAME_FMT))) {
- throw new OAuthException('Nickname must have only letters and numbers and no spaces.');
- }
- $profile = $_GET['omb_listenee_profile'];
- if (!common_valid_http_url($profile)) {
- throw new OAuthException("Invalid profile URL '$profile'.");
- }
- if ($profile == common_local_url('showstream', array('nickname' => $nickname))) {
- throw new OAuthException("Profile URL '$profile' is for a local user.");
- }
+ if ($profile == common_profile_url($nickname)) {
+ throw new Exception(sprintf(_('Profile URL ‘%s’ is for a local user.'),
+ $profile));
- $license = $_GET['omb_listenee_license'];
- if (!common_valid_http_url($license)) {
- throw new OAuthException("Invalid license URL '$license'.");
}
+
+ $license = $_GET['omb_listenee_license'];
$site_license = common_config('license', 'url');
if (!common_compatible_license($license, $site_license)) {
- throw new OAuthException("Listenee stream license '$license' not compatible with site license '$site_license'.");
- }
- # optional stuff
- $fullname = $_GET['omb_listenee_fullname'];
- if ($fullname && mb_strlen($fullname) > 255) {
- throw new OAuthException("Full name '$fullname' too long.");
- }
- $homepage = $_GET['omb_listenee_homepage'];
- if ($homepage && (!common_valid_http_url($homepage) || mb_strlen($homepage) > 255)) {
- throw new OAuthException("Invalid homepage '$homepage'");
- }
- $bio = $_GET['omb_listenee_bio'];
- if ($bio && mb_strlen($bio) > 140) {
- throw new OAuthException("Bio too long '$bio'");
- }
- $location = $_GET['omb_listenee_location'];
- if ($location && mb_strlen($location) > 255) {
- throw new OAuthException("Location too long '$location'");
+ throw new Exception(sprintf(_('Listenee stream license ‘%s’ is not ' .
+ 'compatible with site license ‘%s’.'),
+ $license, $site_license));
}
+
$avatar = $_GET['omb_listenee_avatar'];
if ($avatar) {
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
- throw new OAuthException("Invalid avatar URL '$avatar'");
+ throw new Exception(sprintf(_('Avatar URL ‘%s’ is not valid.'),
+ $avatar));
}
$size = @getimagesize($avatar);
if (!$size) {
- throw new OAuthException("Can't read avatar URL '$avatar'");
- }
- if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
- throw new OAuthException("Wrong size image at '$avatar'");
+ throw new Exception(sprintf(_('Can’t read avatar URL ‘%s’.'),
+ $avatar));
}
if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
IMAGETYPE_PNG))) {
- throw new OAuthException("Wrong image type for '$avatar'");
+ throw new Exception(sprintf(_('Wrong image type for avatar URL '.
+ '‘%s’.'), $avatar));
}
}
- $callback = $_GET['oauth_callback'];
- if ($callback && !common_valid_http_url($callback)) {
- throw new OAuthException("Invalid callback URL '$callback'");
- }
- if ($callback && $callback == common_local_url('finishremotesubscribe')) {
- throw new OAuthException("Callback URL '$callback' is for local site.");
- }
}
-}
+} \ No newline at end of file
diff --git a/actions/userrss.php b/actions/userrss.php
index fa6d588cd..19e610551 100644
--- a/actions/userrss.php
+++ b/actions/userrss.php
@@ -25,7 +25,6 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
class UserrssAction extends Rss10Action
{
- var $user = null;
var $tag = null;
function prepare($args)
@@ -39,6 +38,7 @@ class UserrssAction extends Rss10Action
$this->clientError(_('No such user.'));
return false;
} else {
+ $this->notices = $this->getNotices($this->limit);
return true;
}
}
@@ -64,9 +64,8 @@ class UserrssAction extends Rss10Action
function getNotices($limit=0)
{
-
$user = $this->user;
-
+
if (is_null($user)) {
return null;
}
diff --git a/actions/xrds.php b/actions/xrds.php
index def10e4cf..8ba89fec0 100644
--- a/actions/xrds.php
+++ b/actions/xrds.php
@@ -1,7 +1,7 @@
<?php
/**
- * XRDS for OpenID
+ * XRDS for OpenMicroBlogging
*
* PHP version 5
*
@@ -34,9 +34,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
}
require_once INSTALLDIR.'/lib/omb.php';
+require_once INSTALLDIR.'/extlib/libomb/service_provider.php';
+require_once INSTALLDIR.'/extlib/libomb/xrds_mapper.php';
/**
- * XRDS for OpenID
+ * XRDS for OpenMicroBlogging
*
* @category Action
* @package StatusNet
@@ -52,7 +54,7 @@ class XrdsAction extends Action
*
* @return boolean true
*/
- function isReadOnly($args)
+ function isReadOnly()
{
return true;
}
@@ -85,89 +87,31 @@ class XrdsAction extends Action
*/
function showXrds($user)
{
- header('Content-Type: application/xrds+xml');
- $this->startXML();
- $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
+ $srv = new OMB_Service_Provider(profile_to_omb_profile($user->uri,
+ $user->getProfile()));
+ /* Use libomb’s default XRDS Writer. */
+ $xrds_writer = null;
+ $srv->writeXRDS(new Laconica_XRDS_Mapper(), $xrds_writer);
+ }
+}
- $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
- 'xml:id' => 'oauth',
- 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
- 'version' => '2.0'));
- $this->element('Type', null, 'xri://$xrds*simple');
- $this->showService(OAUTH_ENDPOINT_REQUEST,
- common_local_url('requesttoken'),
- array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
- array(OAUTH_HMAC_SHA1),
- $user->uri);
- $this->showService(OAUTH_ENDPOINT_AUTHORIZE,
- common_local_url('userauthorization'),
- array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
- array(OAUTH_HMAC_SHA1));
- $this->showService(OAUTH_ENDPOINT_ACCESS,
- common_local_url('accesstoken'),
- array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
- array(OAUTH_HMAC_SHA1));
- $this->showService(OAUTH_ENDPOINT_RESOURCE,
- null,
- array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
- array(OAUTH_HMAC_SHA1));
- $this->elementEnd('XRD');
+class Laconica_XRDS_Mapper implements OMB_XRDS_Mapper
+{
+ protected $urls;
- // XXX: decide whether to include user's ID/nickname in postNotice URL
- $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
- 'xml:id' => 'omb',
- 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
- 'version' => '2.0'));
- $this->element('Type', null, 'xri://$xrds*simple');
- $this->showService(OMB_ENDPOINT_POSTNOTICE,
- common_local_url('postnotice'));
- $this->showService(OMB_ENDPOINT_UPDATEPROFILE,
- common_local_url('updateprofile'));
- $this->elementEnd('XRD');
- $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
- 'version' => '2.0'));
- $this->element('Type', null, 'xri://$xrds*simple');
- $this->showService(OAUTH_DISCOVERY,
- '#oauth');
- $this->showService(OMB_NAMESPACE,
- '#omb');
- $this->elementEnd('XRD');
- $this->elementEnd('XRDS');
- $this->endXML();
+ public function __construct()
+ {
+ $this->urls = array(
+ OAUTH_ENDPOINT_REQUEST => 'requesttoken',
+ OAUTH_ENDPOINT_AUTHORIZE => 'userauthorization',
+ OAUTH_ENDPOINT_ACCESS => 'accesstoken',
+ OMB_ENDPOINT_POSTNOTICE => 'postnotice',
+ OMB_ENDPOINT_UPDATEPROFILE => 'updateprofile');
}
- /**
- * Show service.
- *
- * @param string $type XRDS type
- * @param string $uri URI
- * @param array $params type parameters, null by default
- * @param array $sigs type signatures, null by default
- * @param string $localId local ID, null by default
- *
- * @return void
- */
- function showService($type, $uri, $params=null, $sigs=null, $localId=null)
+ public function getURL($action)
{
- $this->elementStart('Service');
- if ($uri) {
- $this->element('URI', null, $uri);
- }
- $this->element('Type', null, $type);
- if ($params) {
- foreach ($params as $param) {
- $this->element('Type', null, $param);
- }
- }
- if ($sigs) {
- foreach ($sigs as $sig) {
- $this->element('Type', null, $sig);
- }
- }
- if ($localId) {
- $this->element('LocalID', null, $localId);
- }
- $this->elementEnd('Service');
+ return common_local_url($this->urls[$action]);
}
}
-
+?>
diff --git a/classes/Avatar.php b/classes/Avatar.php
index 5e8b315fe..64f105179 100644
--- a/classes/Avatar.php
+++ b/classes/Avatar.php
@@ -81,7 +81,7 @@ class Avatar extends Memcached_DataObject
if (empty($server)) {
$server = common_config('site', 'server');
}
-
+ common_debug('path = ' . $path);
// XXX: protocol
return 'http://'.$server.$path.$filename;
diff --git a/classes/Config.php b/classes/Config.php
new file mode 100644
index 000000000..92f237d7f
--- /dev/null
+++ b/classes/Config.php
@@ -0,0 +1,131 @@
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, Control Yourself, 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/>.
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+/**
+ * Table Definition for config
+ */
+
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class Config extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'config'; // table name
+ public $section; // varchar(32) primary_key not_null
+ public $setting; // varchar(32) primary_key not_null
+ public $value; // varchar(255)
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Config',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+
+ const settingsKey = 'config:settings';
+
+ static function loadSettings()
+ {
+ $settings = self::_getSettings();
+ if (!empty($settings)) {
+ self::_applySettings($settings);
+ }
+ }
+
+ static function _getSettings()
+ {
+ $c = self::memcache();
+
+ if (!empty($c)) {
+ $settings = $c->get(common_cache_key(self::settingsKey));
+ if (!empty($settings)) {
+ return $settings;
+ }
+ }
+
+ $settings = array();
+
+ $config = new Config();
+
+ $config->find();
+
+ while ($config->fetch()) {
+ $settings[] = array($config->section, $config->setting, $config->value);
+ }
+
+ $config->free();
+
+ if (!empty($c)) {
+ $c->set(common_cache_key(self::settingsKey), $settings);
+ }
+
+ return $settings;
+ }
+
+ static function _applySettings($settings)
+ {
+ global $config;
+
+ foreach ($settings as $s) {
+ list($section, $setting, $value) = $s;
+ $config[$section][$setting] = $value;
+ }
+ }
+
+ function insert()
+ {
+ $result = parent::insert();
+ if ($result) {
+ Config::_blowSettingsCache();
+ }
+ return $result;
+ }
+
+ function delete()
+ {
+ $result = parent::delete();
+ if ($result) {
+ Config::_blowSettingsCache();
+ }
+ return $result;
+ }
+
+ function update($orig=null)
+ {
+ $result = parent::update($orig);
+ if ($result) {
+ Config::_blowSettingsCache();
+ }
+ return $result;
+ }
+
+ function _blowSettingsCache()
+ {
+ $c = self::memcache();
+
+ if (!empty($c)) {
+ $c->delete(common_cache_key(self::settingsKey));
+ }
+ }
+}
diff --git a/classes/Deleted_notice.php b/classes/Deleted_notice.php
new file mode 100644
index 000000000..64dc85da6
--- /dev/null
+++ b/classes/Deleted_notice.php
@@ -0,0 +1,46 @@
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, Control Yourself, 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/>.
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+/**
+ * Table Definition for notice
+ */
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class Deleted_notice extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'deleted_notice'; // table name
+ public $id; // int(4) primary_key not_null
+ public $profile_id; // int(4) not_null
+ public $uri; // varchar(255) unique_key
+ public $created; // datetime() not_null
+ public $deleted; // datetime() not_null
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Deleted_notice',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+}
diff --git a/classes/File.php b/classes/File.php
index 308d0a771..e04a9d525 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -94,7 +94,13 @@ class File extends Memcached_DataObject
$file_redir = File_redirection::staticGet('url', $given_url);
if (empty($file_redir)) {
$redir_data = File_redirection::where($given_url);
- $redir_url = $redir_data['url'];
+ if (is_array($redir_data)) {
+ $redir_url = $redir_data['url'];
+ } elseif (is_string($redir_data)) {
+ $redir_url = $redir_data;
+ } else {
+ throw new ServerException("Can't process url '$given_url'");
+ }
// TODO: max field length
if ($redir_url === $given_url || strlen($redir_url) > 255) {
$x = File::saveNew($redir_data, $given_url);
@@ -197,17 +203,44 @@ class File extends Memcached_DataObject
return 'http://'.$server.$path.$filename;
}
- function isEnclosure(){
- if(isset($this->filename)){
- return true;
- }
- $notEnclosureMimeTypes = array('text/html','application/xhtml+xml',null);
- $mimetype = strtolower($this->mimetype);
- $semicolon = strpos($mimetype,';');
- if($semicolon){
- $mimetype = substr($mimetype,0,$semicolon);
+ function getEnclosure(){
+ $enclosure = (object) array();
+ $enclosure->title=$this->title;
+ $enclosure->url=$this->url;
+ $enclosure->title=$this->title;
+ $enclosure->date=$this->date;
+ $enclosure->modified=$this->modified;
+ $enclosure->size=$this->size;
+ $enclosure->mimetype=$this->mimetype;
+
+ if(! isset($this->filename)){
+ $notEnclosureMimeTypes = array('text/html','application/xhtml+xml');
+ $mimetype = strtolower($this->mimetype);
+ $semicolon = strpos($mimetype,';');
+ if($semicolon){
+ $mimetype = substr($mimetype,0,$semicolon);
+ }
+ if(in_array($mimetype,$notEnclosureMimeTypes)){
+ $oembed = File_oembed::staticGet('file_id',$this->id);
+ if($oembed){
+ $mimetype = strtolower($oembed->mimetype);
+ $semicolon = strpos($mimetype,';');
+ if($semicolon){
+ $mimetype = substr($mimetype,0,$semicolon);
+ }
+ if(in_array($mimetype,$notEnclosureMimeTypes)){
+ return false;
+ }else{
+ if($oembed->mimetype) $enclosure->mimetype=$oembed->mimetype;
+ if($oembed->url) $enclosure->url=$oembed->url;
+ if($oembed->title) $enclosure->title=$oembed->title;
+ if($oembed->modified) $enclosure->modified=$oembed->modified;
+ unset($oembed->size);
+ }
+ }
+ }
}
- return(! in_array($mimetype,$notEnclosureMimeTypes));
+ return $enclosure;
}
}
diff --git a/classes/File_oembed.php b/classes/File_oembed.php
index 6be651815..e41ccfd09 100644
--- a/classes/File_oembed.php
+++ b/classes/File_oembed.php
@@ -20,6 +20,7 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+require_once INSTALLDIR.'/classes/File_redirection.php';
/**
* Table Definition for file_oembed
@@ -34,6 +35,7 @@ class File_oembed extends Memcached_DataObject
public $file_id; // int(4) primary_key not_null
public $version; // varchar(20)
public $type; // varchar(20)
+ public $mimetype; // varchar(50)
public $provider; // varchar(50)
public $provider_url; // varchar(255)
public $width; // int(4)
@@ -93,7 +95,24 @@ class File_oembed extends Memcached_DataObject
if (!empty($data->title)) $file_oembed->title = $data->title;
if (!empty($data->author_name)) $file_oembed->author_name = $data->author_name;
if (!empty($data->author_url)) $file_oembed->author_url = $data->author_url;
- if (!empty($data->url)) $file_oembed->url = $data->url;
+ if (!empty($data->url)){
+ $file_oembed->url = $data->url;
+ $given_url = File_redirection::_canonUrl($file_oembed->url);
+ if (! empty($given_url)){
+ $file = File::staticGet('url', $given_url);
+ if (empty($file)) {
+ $file_redir = File_redirection::staticGet('url', $given_url);
+ if (empty($file_redir)) {
+ $redir_data = File_redirection::where($given_url);
+ $file_oembed->mimetype = $redir_data['type'];
+ } else {
+ $file_id = $file_redir->file_id;
+ }
+ } else {
+ $file_oembed->mimetype=$file->mimetype;
+ }
+ }
+ }
$file_oembed->insert();
if (!empty($data->thumbnail_url)) {
File_thumbnail::saveNew($data, $file_id);
diff --git a/classes/File_redirection.php b/classes/File_redirection.php
index 76b18f672..79052bf7d 100644
--- a/classes/File_redirection.php
+++ b/classes/File_redirection.php
@@ -79,6 +79,9 @@ class File_redirection extends Memcached_DataObject
}
}
+ if(strpos($short_url,'://') === false){
+ return $short_url;
+ }
$curlh = File_redirection::_commonCurl($short_url, $redirs);
// Don't include body in output
curl_setopt($curlh, CURLOPT_NOBODY, true);
diff --git a/classes/Location_namespace.php b/classes/Location_namespace.php
new file mode 100644
index 000000000..5ab95d9ef
--- /dev/null
+++ b/classes/Location_namespace.php
@@ -0,0 +1,46 @@
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, 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/>.
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+
+/**
+ * Table Definition for location_namespace
+ */
+
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class Location_namespace extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'location_namespace'; // table name
+ public $id; // int(4) primary_key not_null
+ public $description; // varchar(255)
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
+
+ /* Static get */
+ function staticGet($k,$v=NULL) {
+ return Memcached_DataObject::staticGet('Location_namespace',$k,$v);
+ }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+}
diff --git a/classes/Message.php b/classes/Message.php
index 4806057b4..979e6e87c 100644
--- a/classes/Message.php
+++ b/classes/Message.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Message extends Memcached_DataObject
+class Message extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -14,58 +14,73 @@ class Message extends Memcached_DataObject
public $uri; // varchar(255) unique_key
public $from_profile; // int(4) not_null
public $to_profile; // int(4) not_null
- public $content; // varchar(140)
- public $rendered; // text()
- public $url; // varchar(255)
+ public $content; // text()
+ public $rendered; // text()
+ public $url; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- public $source; // varchar(32)
+ public $source; // varchar(32)
/* Static get */
- function staticGet($k,$v=null)
- { return Memcached_DataObject::staticGet('Message',$k,$v); }
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Message',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
-
+
function getFrom()
{
return Profile::staticGet('id', $this->from_profile);
}
-
+
function getTo()
{
return Profile::staticGet('id', $this->to_profile);
}
-
+
static function saveNew($from, $to, $content, $source) {
-
+
$msg = new Message();
-
+
$msg->from_profile = $from;
$msg->to_profile = $to;
$msg->content = common_shorten_links($content);
$msg->rendered = common_render_text($content);
$msg->created = common_sql_now();
$msg->source = $source;
-
+
$result = $msg->insert();
-
+
if (!$result) {
common_log_db_error($msg, 'INSERT', __FILE__);
return _('Could not insert message.');
}
-
+
$orig = clone($msg);
$msg->uri = common_local_url('showmessage', array('message' => $msg->id));
-
+
$result = $msg->update($orig);
-
+
if (!$result) {
common_log_db_error($msg, 'UPDATE', __FILE__);
return _('Could not update message with new URI.');
}
-
+
return $msg;
}
+
+ static function maxContent()
+ {
+ $desclimit = common_config('message', 'contentlimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($desclimit)) {
+ $desclimit = common_config('site', 'textlimit');
+ }
+ return $desclimit;
+ }
+
+ static function contentTooLong($content)
+ {
+ $contentlimit = self::maxContent();
+ return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit));
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 7d0502626..c08a66790 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1,5 +1,5 @@
<?php
-/*
+/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
@@ -15,9 +15,26 @@
*
* 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 Notices
+ * @package StatusNet
+ * @author Brenda Wallace <shiny@cpan.org>
+ * @author Christopher Vollick <psycotica0@gmail.com>
+ * @author CiaranG <ciaran@ciarang.com>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@controlezvous.ca>
+ * @author Gina Haeussge <osd@foosel.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <millette@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @author Tom Adams <tom@holizz.com>
+ * @license GNU Affero General Public License http://www.gnu.org/licenses/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
/**
* Table Definition for notice
@@ -40,7 +57,7 @@ class Notice extends Memcached_DataObject
public $id; // int(4) primary_key not_null
public $profile_id; // int(4) not_null
public $uri; // varchar(255) unique_key
- public $content; // varchar(140)
+ public $content; // text()
public $rendered; // text()
public $url; // varchar(255)
public $created; // datetime() not_null
@@ -49,6 +66,10 @@ class Notice extends Memcached_DataObject
public $is_local; // tinyint(1)
public $source; // varchar(32)
public $conversation; // int(4)
+ public $lat; // decimal(10,7)
+ public $lon; // decimal(10,7)
+ public $location_id; // int(4)
+ public $location_ns; // int(4)
/* Static get */
function staticGet($k,$v=NULL) {
@@ -75,17 +96,30 @@ class Notice extends Memcached_DataObject
$this->blowFavesCache(true);
$this->blowSubsCache(true);
+ // For auditing purposes, save a record that the notice
+ // was deleted.
+
+ $deleted = new Deleted_notice();
+
+ $deleted->id = $this->id;
+ $deleted->profile_id = $this->profile_id;
+ $deleted->uri = $this->uri;
+ $deleted->created = $this->created;
+ $deleted->deleted = common_sql_now();
+
$this->query('BEGIN');
+
+ $deleted->insert();
+
//Null any notices that are replies to this notice
$this->query(sprintf("UPDATE notice set reply_to = null WHERE reply_to = %d", $this->id));
$related = array('Reply',
'Fave',
'Notice_tag',
'Group_inbox',
- 'Queue_item');
- if (common_config('inboxes', 'enabled')) {
- $related[] = 'Notice_inbox';
- }
+ 'Queue_item',
+ 'Notice_inbox');
+
foreach ($related as $cls) {
$inst = new $cls();
$inst->notice_id = $this->id;
@@ -134,37 +168,38 @@ class Notice extends Memcached_DataObject
}
static function saveNew($profile_id, $content, $source=null,
- $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null) {
+ $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null,
+ $lat=null, $lon=null, $location_id=null, $location_ns=null) {
$profile = Profile::staticGet($profile_id);
$final = common_shorten_links($content);
- if (mb_strlen($final) > 140) {
- common_log(LOG_INFO, 'Rejecting notice that is too long.');
- return _('Problem saving notice. Too long.');
+ if (Notice::contentTooLong($final)) {
+ throw new ClientException(_('Problem saving notice. Too long.'));
}
- if (!$profile) {
- common_log(LOG_ERR, 'Problem saving notice. Unknown user.');
- return _('Problem saving notice. Unknown user.');
+ if (empty($profile)) {
+ throw new ClientException(_('Problem saving notice. Unknown user.'));
}
if (common_config('throttle', 'enabled') && !Notice::checkEditThrottle($profile_id)) {
common_log(LOG_WARNING, 'Excessive posting by profile #' . $profile_id . '; throttled.');
- return _('Too many notices too fast; take a breather and post again in a few minutes.');
+ throw new ClientException(_('Too many notices too fast; take a breather '.
+ 'and post again in a few minutes.'));
}
if (common_config('site', 'dupelimit') > 0 && !Notice::checkDupes($profile_id, $final)) {
common_log(LOG_WARNING, 'Dupe posting by profile #' . $profile_id . '; throttled.');
- return _('Too many duplicate messages too quickly; take a breather and post again in a few minutes.');
+ throw new ClientException(_('Too many duplicate messages too quickly;'.
+ ' take a breather and post again in a few minutes.'));
}
- $banned = common_config('profile', 'banned');
+ $banned = common_config('profile', 'banned');
if ( in_array($profile_id, $banned) || in_array($profile->nickname, $banned)) {
common_log(LOG_WARNING, "Attempted post from banned user: $profile->nickname (user id = $profile_id).");
- return _('You are banned from posting notices on this site.');
+ throw new ClientException(_('You are banned from posting notices on this site.'));
}
$notice = new Notice();
@@ -188,18 +223,38 @@ class Notice extends Memcached_DataObject
$notice->created = common_sql_now();
}
- $notice->content = $final;
- $notice->rendered = common_render_content($final, $notice);
- $notice->source = $source;
- $notice->uri = $uri;
+ $notice->content = $final;
+ $notice->rendered = common_render_content($final, $notice);
+ $notice->source = $source;
+ $notice->uri = $uri;
- $notice->reply_to = self::getReplyTo($reply_to, $profile_id, $source, $final);
+ $notice->reply_to = self::getReplyTo($reply_to, $profile_id, $source, $final);
if (!empty($notice->reply_to)) {
$reply = Notice::staticGet('id', $notice->reply_to);
$notice->conversation = $reply->conversation;
}
+ if (!empty($lat) && !empty($lon)) {
+ $notice->lat = $lat;
+ $notice->lon = $lon;
+ $notice->location_id = $location_id;
+ $notice->location_ns = $location_ns;
+ } else if (!empty($location_ns) && !empty($location_id)) {
+ $location = Location::fromId($location_id, $location_ns);
+ if (!empty($location)) {
+ $notice->lat = $location->lat;
+ $notice->lon = $location->lon;
+ $notice->location_id = $location_id;
+ $notice->location_ns = $location_ns;
+ }
+ } else {
+ $notice->lat = $profile->lat;
+ $notice->lon = $profile->lon;
+ $notice->location_id = $profile->location_id;
+ $notice->location_ns = $profile->location_ns;
+ }
+
if (Event::handle('StartNoticeSave', array(&$notice))) {
// XXX: some of these functions write to the DB
@@ -210,7 +265,7 @@ class Notice extends Memcached_DataObject
if (!$id) {
common_log_db_error($notice, 'INSERT', __FILE__);
- return _('Problem saving notice.');
+ throw new ServerException(_('Problem saving notice.'));
}
// Update ID-dependent columns: URI, conversation
@@ -235,13 +290,12 @@ class Notice extends Memcached_DataObject
if ($changed) {
if (!$notice->update($orig)) {
common_log_db_error($notice, 'UPDATE', __FILE__);
- return _('Problem saving notice.');
+ throw new ServerException(_('Problem saving notice.'));
}
}
// XXX: do we need to change this for remote users?
- $notice->saveReplies();
$notice->saveTags();
$notice->addToInboxes();
@@ -279,11 +333,11 @@ class Notice extends Memcached_DataObject
static function checkDupes($profile_id, $content) {
$profile = Profile::staticGet($profile_id);
- if (!$profile) {
+ if (empty($profile)) {
return false;
}
$notice = $profile->getNotices(0, NOTICE_CACHE_WINDOW);
- if ($notice) {
+ if (!empty($notice)) {
$last = 0;
while ($notice->fetch()) {
if (time() - strtotime($notice->created) >= common_config('site', 'dupelimit')) {
@@ -309,7 +363,7 @@ class Notice extends Memcached_DataObject
static function checkEditThrottle($profile_id) {
$profile = Profile::staticGet($profile_id);
- if (!$profile) {
+ if (empty($profile)) {
return false;
}
# Get the Nth notice
@@ -630,7 +684,7 @@ class Notice extends Memcached_DataObject
$cache = common_memcache();
- if (!$cache) {
+ if (empty($cache)) {
return Notice::getStreamDirect($qry, $offset, $limit, null, null, $order, null);
}
@@ -691,7 +745,7 @@ class Notice extends Memcached_DataObject
# If there are no hits, just return the value
- if (!$notice) {
+ if (empty($notice)) {
return $notice;
}
@@ -854,66 +908,73 @@ class Notice extends Memcached_DataObject
function addToInboxes()
{
- $enabled = common_config('inboxes', 'enabled');
+ // XXX: loads constants
- if ($enabled === true || $enabled === 'transitional') {
+ $inbox = new Notice_inbox();
- // XXX: loads constants
+ $users = $this->getSubscribedUsers();
- $inbox = new Notice_inbox();
+ // FIXME: kind of ignoring 'transitional'...
+ // we'll probably stop supporting inboxless mode
+ // in 0.9.x
- $users = $this->getSubscribedUsers();
+ $ni = array();
- // FIXME: kind of ignoring 'transitional'...
- // we'll probably stop supporting inboxless mode
- // in 0.9.x
+ foreach ($users as $id) {
+ $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
+ }
- $ni = array();
+ $groups = $this->saveGroups();
+ foreach ($groups as $group) {
+ $users = $group->getUserMembers();
foreach ($users as $id) {
- $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
- }
-
- $groups = $this->saveGroups();
-
- foreach ($groups as $group) {
- $users = $group->getUserMembers();
- foreach ($users as $id) {
- if (!array_key_exists($id, $ni)) {
- $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
- }
+ if (!array_key_exists($id, $ni)) {
+ $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
}
}
+ }
- $cnt = 0;
+ $recipients = $this->saveReplies();
- $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
- $qry = $qryhdr;
+ foreach ($recipients as $recipient) {
- foreach ($ni as $id => $source) {
- if ($cnt > 0) {
- $qry .= ', ';
- }
- $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
- $cnt++;
- if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
- // FIXME: Causes lag in replicated servers
- // Notice_inbox::gc($id);
- }
- if ($cnt >= MAX_BOXCARS) {
- $inbox = new Notice_inbox();
- $inbox->query($qry);
- $qry = $qryhdr;
- $cnt = 0;
+ if (!array_key_exists($recipient, $ni)) {
+ $recipientUser = User::staticGet('id', $recipient);
+ if (!empty($recipientUser)) {
+ $ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
}
}
+ }
+
+ $cnt = 0;
+
+ $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
+ $qry = $qryhdr;
+ foreach ($ni as $id => $source) {
if ($cnt > 0) {
+ $qry .= ', ';
+ }
+ $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
+ $cnt++;
+ if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
+ // FIXME: Causes lag in replicated servers
+ // Notice_inbox::gc($id);
+ }
+ if ($cnt >= MAX_BOXCARS) {
$inbox = new Notice_inbox();
$inbox->query($qry);
+ $qry = $qryhdr;
+ $cnt = 0;
}
}
+ if ($cnt > 0) {
+ $inbox = new Notice_inbox();
+ $inbox->query($qry);
+ }
+
return;
}
@@ -948,11 +1009,6 @@ class Notice extends Memcached_DataObject
{
$groups = array();
- $enabled = common_config('inboxes', 'enabled');
- if ($enabled !== true && $enabled !== 'transitional') {
- return $groups;
- }
-
/* extract all !group */
$count = preg_match_all('/(?:^|\s)!([A-Za-z0-9]{1,64})/',
strtolower($this->content),
@@ -1043,12 +1099,12 @@ class Notice extends Memcached_DataObject
for ($i=0; $i<count($names); $i++) {
$nickname = $names[$i];
$recipient = common_relative_profile($sender, $nickname, $this->created);
- if (!$recipient) {
+ if (empty($recipient)) {
continue;
}
// Don't save replies from blocked profile to local user
$recipient_user = User::staticGet('id', $recipient->id);
- if ($recipient_user && $recipient_user->hasBlocked($sender)) {
+ if (!empty($recipient_user) && $recipient_user->hasBlocked($sender)) {
continue;
}
$reply = new Reply();
@@ -1059,7 +1115,7 @@ class Notice extends Memcached_DataObject
$last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
common_log(LOG_ERR, 'DB error inserting reply: ' . $last_error->message);
common_server_error(sprintf(_('DB error inserting reply: %s'), $last_error->message));
- return;
+ return array();
} else {
$replied[$recipient->id] = 1;
}
@@ -1083,7 +1139,7 @@ class Notice extends Memcached_DataObject
$id = $reply->insert();
if (!$id) {
common_log_db_error($reply, 'INSERT', __FILE__);
- return;
+ return array();
} else {
$replied[$recipient->id] = 1;
}
@@ -1092,12 +1148,16 @@ class Notice extends Memcached_DataObject
}
}
- foreach (array_keys($replied) as $recipient) {
+ $recipientIds = array_keys($replied);
+
+ foreach ($recipientIds as $recipient) {
$user = User::staticGet('id', $recipient);
if ($user) {
mail_notify_attn($user, $this);
}
}
+
+ return $recipientIds;
}
function asAtomEntry($namespace=false, $source=false)
@@ -1181,10 +1241,11 @@ class Notice extends Memcached_DataObject
$attachments = $this->attachments();
if($attachments){
foreach($attachments as $attachment){
- if ($attachment->isEnclosure()) {
- $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
- if($attachment->title){
- $attributes['title']=$attachment->title;
+ $enclosure=$attachment->getEnclosure();
+ if ($enclosure) {
+ $attributes = array('rel'=>'enclosure','href'=>$enclosure->url,'type'=>$enclosure->mimetype,'length'=>$enclosure->size);
+ if($enclosure->title){
+ $attributes['title']=$enclosure->title;
}
$xs->element('link', $attributes, null);
}
@@ -1335,4 +1396,37 @@ class Notice extends Memcached_DataObject
return $last->id;
}
}
+
+ static function maxContent()
+ {
+ $contentlimit = common_config('notice', 'contentlimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($contentlimit)) {
+ $contentlimit = common_config('site', 'textlimit');
+ }
+ return $contentlimit;
+ }
+
+ static function contentTooLong($content)
+ {
+ $contentlimit = self::maxContent();
+ return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit));
+ }
+
+ function getLocation()
+ {
+ $location = null;
+
+ if (!empty($this->location_id) && !empty($this->location_ns)) {
+ $location = Location::fromId($this->location_id, $this->location_ns);
+ }
+
+ if (is_null($location)) { // no ID, or Location::fromId() failed
+ if (!empty($this->lat) && !empty($this->lon)) {
+ $location = Location::fromLatLon($this->lat, $this->lon);
+ }
+ }
+
+ return $location;
+ }
}
diff --git a/classes/Profile.php b/classes/Profile.php
index 8385ebf88..7c1e9db33 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -35,18 +35,28 @@ class Profile extends Memcached_DataObject
public $fullname; // varchar(255) multiple_key
public $profileurl; // varchar(255)
public $homepage; // varchar(255) multiple_key
- public $bio; // varchar(140) multiple_key
+ public $bio; // text() multiple_key
public $location; // varchar(255) multiple_key
+ public $lat; // decimal(10,7)
+ public $lon; // decimal(10,7)
+ public $location_id; // int(4)
+ public $location_ns; // int(4)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */
- function staticGet($k,$v=null)
- { return Memcached_DataObject::staticGet('Profile',$k,$v); }
+ function staticGet($k,$v=NULL) {
+ return Memcached_DataObject::staticGet('Profile',$k,$v);
+ }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+ function getUser()
+ {
+ return User::staticGet('id', $this->id);
+ }
+
function getAvatar($width, $height=null)
{
if (is_null($height)) {
@@ -462,6 +472,22 @@ class Profile extends Memcached_DataObject
}
}
+ static function maxBio()
+ {
+ $biolimit = common_config('profile', 'biolimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($biolimit)) {
+ $biolimit = common_config('site', 'textlimit');
+ }
+ return $biolimit;
+ }
+
+ static function bioTooLong($bio)
+ {
+ $biolimit = self::maxBio();
+ return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
+ }
+
function delete()
{
$this->_deleteNotices();
@@ -536,4 +562,29 @@ class Profile extends Memcached_DataObject
$block->blocked = $this->id;
$block->delete();
}
+
+ // XXX: identical to Notice::getLocation.
+
+ function getLocation()
+ {
+ $location = null;
+
+ if (!empty($this->location_id) && !empty($this->location_ns)) {
+ $location = Location::fromId($this->location_id, $this->location_ns);
+ }
+
+ if (is_null($location)) { // no ID, or Location::fromId() failed
+ if (!empty($this->lat) && !empty($this->lon)) {
+ $location = Location::fromLatLon($this->lat, $this->lon);
+ }
+ }
+
+ if (is_null($location)) { // still haven't found it!
+ if (!empty($this->location)) {
+ $location = Location::fromName($this->location);
+ }
+ }
+
+ return $location;
+ }
}
diff --git a/classes/User.php b/classes/User.php
index 007662131..3fa9cc152 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -103,10 +103,7 @@ class User extends Memcached_DataObject
}
$toupdate = implode(', ', $parts);
- $table = $this->tableName();
- if(common_config('db','quote_identifiers')) {
- $table = '"' . $table . '"';
- }
+ $table = common_database_tablename($this->tableName());
$qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
' WHERE id = ' . $this->id;
$orig->decache();
@@ -201,6 +198,15 @@ class User extends Memcached_DataObject
}
if (!empty($location)) {
$profile->location = $location;
+
+ $loc = Location::fromName($location);
+
+ if (!empty($loc)) {
+ $profile->lat = $loc->lat;
+ $profile->lon = $loc->lon;
+ $profile->location_id = $loc->location_id;
+ $profile->location_ns = $loc->location_ns;
+ }
}
$profile->created = common_sql_now();
@@ -230,11 +236,9 @@ class User extends Memcached_DataObject
}
}
- $inboxes = common_config('inboxes', 'enabled');
+ // This flag is ignored but still set to 1
- if ($inboxes === true || $inboxes == 'transitional') {
- $user->inboxed = 1;
- }
+ $user->inboxed = 1;
$user->created = common_sql_now();
$user->uri = common_user_uri($user);
@@ -324,6 +328,7 @@ class User extends Memcached_DataObject
common_config('site', 'name'),
$user->nickname),
'system');
+ common_broadcast_notice($notice);
}
}
@@ -436,55 +441,16 @@ class User extends Memcached_DataObject
function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
{
- $enabled = common_config('inboxes', 'enabled');
-
- // Complicated code, depending on whether we support inboxes yet
- // XXX: make this go away when inboxes become mandatory
-
- if ($enabled === false ||
- ($enabled == 'transitional' && $this->inboxed == 0)) {
- $qry =
- 'SELECT notice.* ' .
- 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
- 'WHERE subscription.subscriber = %d ' .
- 'AND notice.is_local != ' . Notice::GATEWAY;
- return Notice::getStream(sprintf($qry, $this->id),
- 'user:notices_with_friends:' . $this->id,
- $offset, $limit, $since_id, $before_id,
- $order, $since);
- } else if ($enabled === true ||
- ($enabled == 'transitional' && $this->inboxed == 1)) {
+ $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
- $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
-
- return Notice::getStreamByIds($ids);
- }
+ return Notice::getStreamByIds($ids);
}
function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
{
- $enabled = common_config('inboxes', 'enabled');
-
- // Complicated code, depending on whether we support inboxes yet
- // XXX: make this go away when inboxes become mandatory
+ $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
- if ($enabled === false ||
- ($enabled == 'transitional' && $this->inboxed == 0)) {
- $qry =
- 'SELECT notice.* ' .
- 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
- 'WHERE subscription.subscriber = %d ';
- return Notice::getStream(sprintf($qry, $this->id),
- 'user:notices_with_friends:' . $this->id,
- $offset, $limit, $since_id, $before_id,
- $order, $since);
- } else if ($enabled === true ||
- ($enabled == 'transitional' && $this->inboxed == 1)) {
-
- $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
-
- return Notice::getStreamByIds($ids);
- }
+ return Notice::getStreamByIds($ids);
}
function blowFavesCache()
@@ -634,11 +600,7 @@ class User extends Memcached_DataObject
'ORDER BY subscription.created DESC ';
if ($offset) {
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
}
$profile = new Profile();
@@ -661,11 +623,7 @@ class User extends Memcached_DataObject
'AND subscription.subscribed != subscription.subscriber ' .
'ORDER BY subscription.created DESC ';
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
$profile = new Profile();
@@ -674,20 +632,82 @@ class User extends Memcached_DataObject
return $profile;
}
- function hasOpenID()
+ function getDesign()
+ {
+ return Design::staticGet('id', $this->design_id);
+ }
+
+ function hasRole($name)
{
- $oid = new User_openid();
+ $role = User_role::pkeyGet(array('user_id' => $this->id,
+ 'role' => $name));
+ return (!empty($role));
+ }
- $oid->user_id = $this->id;
+ function grantRole($name)
+ {
+ $role = new User_role();
- $cnt = $oid->find();
+ $role->user_id = $this->id;
+ $role->role = $name;
+ $role->created = common_sql_now();
+
+ $result = $role->insert();
+
+ if (!$result) {
+ common_log_db_error($role, 'INSERT', __FILE__);
+ return false;
+ }
- return ($cnt > 0);
+ return true;
}
- function getDesign()
+ function revokeRole($name)
{
- return Design::staticGet('id', $this->design_id);
+ $role = User_role::pkeyGet(array('user_id' => $this->id,
+ 'role' => $name));
+
+ if (empty($role)) {
+ throw new Exception('Cannot revoke role "'.$name.'" for user #'.$this->id.'; does not exist.');
+ }
+
+ $result = $role->delete();
+
+ if (!$result) {
+ common_log_db_error($role, 'DELETE', __FILE__);
+ throw new Exception('Cannot revoke role "'.$name.'" for user #'.$this->id.'; database error.');
+ }
+
+ return true;
+ }
+
+ /**
+ * Does this user have the right to do X?
+ *
+ * With our role-based authorization, this is merely a lookup for whether the user
+ * has a particular role. The implementation currently uses a switch statement
+ * to determine if the user has the pre-defined role to exercise the right. Future
+ * implementations may allow per-site roles, and different mappings of roles to rights.
+ *
+ * @param $right string Name of the right, usually a constant in class Right
+ * @return boolean whether the user has the right in question
+ */
+
+ function hasRight($right)
+ {
+ $result = false;
+ if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
+ switch ($right)
+ {
+ case Right::deleteOthersNotice:
+ $result = $this->hasRole('moderator');
+ break;
+ default:
+ $result = false;
+ break;
+ }
+ }
+ return $result;
}
function delete()
@@ -701,12 +721,9 @@ class User extends Memcached_DataObject
'Remember_me',
'Foreign_link',
'Invitation',
+ 'Notice_inbox',
);
- if (common_config('inboxes', 'enabled')) {
- $related[] = 'Notice_inbox';
- }
-
foreach ($related as $cls) {
$inst = new $cls();
$inst->user_id = $this->id;
diff --git a/classes/User_group.php b/classes/User_group.php
index ea19cbb97..310ecff1e 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -13,7 +13,7 @@ class User_group extends Memcached_DataObject
public $nickname; // varchar(64) unique_key
public $fullname; // varchar(255)
public $homepage; // varchar(255)
- public $description; // varchar(140)
+ public $description; // text()
public $location; // varchar(255)
public $original_logo; // varchar(255)
public $homepage_logo; // varchar(255)
@@ -298,6 +298,22 @@ class User_group extends Memcached_DataObject
return $ids;
}
+ static function maxDescription()
+ {
+ $desclimit = common_config('group', 'desclimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($desclimit)) {
+ $desclimit = common_config('site', 'textlimit');
+ }
+ return $desclimit;
+ }
+
+ static function descriptionTooLong($desc)
+ {
+ $desclimit = self::maxDescription();
+ return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit));
+ }
+
function asAtomEntry($namespace=false, $source=false)
{
$xs = new XMLStringer(true);
diff --git a/classes/User_role.php b/classes/User_role.php
new file mode 100644
index 000000000..85ecfb422
--- /dev/null
+++ b/classes/User_role.php
@@ -0,0 +1,48 @@
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, 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/>.
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+
+/**
+ * Table Definition for user_role
+ */
+
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class User_role extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'user_role'; // table name
+ public $user_id; // int(4) primary_key not_null
+ public $role; // varchar(32) primary_key not_null
+ public $created; // datetime() not_null
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_role',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+
+ function &pkeyGet($kv)
+ {
+ return Memcached_DataObject::pkeyGet('User_role', $kv);
+ }
+}
diff --git a/classes/statusnet.ini b/classes/statusnet.ini
index 766bed75d..7931c7bcd 100644
--- a/classes/statusnet.ini
+++ b/classes/statusnet.ini
@@ -16,6 +16,15 @@ width = K
height = K
url = U
+[config]
+section = 130
+setting = 130
+value = 2
+
+[config__keys]
+section = K
+setting = K
+
[confirm_address]
code = 130
user_id = 129
@@ -38,6 +47,17 @@ modified = 384
[consumer__keys]
consumer_key = K
+[deleted_notice]
+id = 129
+profile_id = 129
+uri = 2
+created = 142
+deleted = 142
+
+[deleted_notice__keys]
+id = K
+uri = U
+
[design]
id = 129
backgroundcolor = 1
@@ -78,6 +98,7 @@ id = N
file_id = 129
version = 2
type = 2
+mimetype = 2
provider = 2
provider_url = 2
width = 1
@@ -223,12 +244,21 @@ created = 142
[invitation__keys]
code = K
+[location_namespace]
+id = 129
+description = 2
+created = 142
+modified = 384
+
+[location_namespace__keys]
+id = K
+
[message]
id = 129
uri = 2
from_profile = 129
to_profile = 129
-content = 2
+content = 34
rendered = 34
url = 2
created = 142
@@ -255,7 +285,7 @@ ts = K
id = 129
profile_id = 129
uri = 2
-content = 2
+content = 34
rendered = 34
url = 2
created = 142
@@ -264,6 +294,10 @@ reply_to = 1
is_local = 17
source = 2
conversation = 1
+lat = 1
+lon = 1
+location_id = 1
+location_ns = 1
[notice__keys]
id = N
@@ -303,8 +337,12 @@ nickname = 130
fullname = 2
profileurl = 2
homepage = 2
-bio = 2
+bio = 34
location = 2
+lat = 1
+lon = 1
+location_id = 1
+location_ns = 1
created = 142
modified = 384
@@ -475,7 +513,7 @@ id = 129
nickname = 2
fullname = 2
homepage = 2
-description = 2
+description = 34
location = 2
original_logo = 2
homepage_logo = 2
@@ -498,3 +536,12 @@ modified = 384
[user_openid__keys]
canonical = K
display = U
+
+[user_role]
+user_id = 129
+role = 130
+created = 142
+
+[user_role__keys]
+user_id = K
+role = K
diff --git a/config.php.sample b/config.php.sample
index bd3776a47..9fccb84f3 100644
--- a/config.php.sample
+++ b/config.php.sample
@@ -38,8 +38,6 @@ $config['site']['path'] = 'statusnet';
// $config['site']['closed'] = true;
// Only allow registration for people invited by another user
// $config['site']['inviteonly'] = true;
-// Only allow registrations and logins through OpenID
-// $config['site']['openidonly'] = true;
// Make the site invisible to non-logged-in users
// $config['site']['private'] = true;
@@ -99,9 +97,6 @@ $config['sphinx']['port'] = 3312;
// $config['xmpp']['public'][] = 'someindexer@example.net';
// $config['xmpp']['debug'] = false;
-// Disable OpenID
-// $config['openid']['enabled'] = false;
-
// Turn off invites
// $config['invite']['enabled'] = false;
@@ -109,6 +104,10 @@ $config['sphinx']['port'] = 3312;
// $config['site']['timezone'] = 'Pacific/Auckland';
// $config['site']['language'] = 'en_NZ';
+// When validating user supplied email addresses, validate if the domain
+// is running an SMTP server.
+// $config['mail']['check_domain'] = true;
+
// Email info, used for all outbound email
// $config['mail']['notifyfrom'] = 'microblog@example.net';
// $config['mail']['domain'] = 'microblog.example.net';
diff --git a/db/08to09.sql b/db/08to09.sql
new file mode 100644
index 000000000..953e0e5f4
--- /dev/null
+++ b/db/08to09.sql
@@ -0,0 +1,34 @@
+alter table notice
+ modify column content text comment 'update content';
+
+alter table message
+ modify column content text comment 'message content';
+
+alter table profile
+ modify column bio text comment 'descriptive biography';
+
+alter table user_group
+ modify column description text comment 'group description';
+
+alter table file_oembed
+ add column mimetype varchar(50) comment 'mime type of resource';
+
+create table config (
+
+ section varchar(32) comment 'configuration section',
+ setting varchar(32) comment 'configuration setting',
+ value varchar(255) comment 'configuration value',
+
+ constraint primary key (section, setting)
+
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
+
+create table user_role (
+
+ user_id integer not null comment 'user having the role' references user (id),
+ role varchar(32) not null comment 'string representing the role',
+ created datetime not null comment 'date the role was granted',
+
+ constraint primary key (user_id, role)
+
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql
new file mode 100644
index 000000000..9e37314aa
--- /dev/null
+++ b/db/08to09_pg.sql
@@ -0,0 +1,40 @@
+-- SQL commands to update an 0.8.x version of Laconica
+-- to 0.9.x.
+
+--these are just comments
+/*
+alter table notice
+ modify column content text comment 'update content';
+
+alter table message
+ modify column content text comment 'message content';
+
+alter table profile
+ modify column bio text comment 'descriptive biography';
+
+alter table user_group
+ modify column description text comment 'group description';
+*/
+
+alter table file_oembed
+ add column mimetype varchar(50) /*comment 'mime type of resource'*/;
+
+create table config (
+
+ section varchar(32) /* comment 'configuration section'*/,
+ setting varchar(32) /* comment 'configuration setting'*/,
+ value varchar(255) /* comment 'configuration value'*/,
+
+ primary key (section, setting)
+
+);
+
+create table user_role (
+
+ user_id integer not null /* comment 'user having the role'*/ references "user" (id),
+ role varchar(32) not null /* comment 'string representing the role'*/,
+ created timestamp /* not null comment 'date the role was granted'*/,
+
+ primary key (user_id, role)
+
+);
diff --git a/db/location_namespace.sql b/db/location_namespace.sql
new file mode 100644
index 000000000..59b2ce67c
--- /dev/null
+++ b/db/location_namespace.sql
@@ -0,0 +1,5 @@
+insert into location_namespace
+ (id, description, created)
+values
+ (1, 'Geonames', now()),
+ (2, 'Where on Earth', now());
diff --git a/db/statusnet.sql b/db/statusnet.sql
index 2c04f680a..1524d8395 100644
--- a/db/statusnet.sql
+++ b/db/statusnet.sql
@@ -1,13 +1,19 @@
/* local and remote users have profiles */
create table profile (
+
id integer auto_increment primary key comment 'unique identifier',
nickname varchar(64) not null comment 'nickname or username',
fullname varchar(255) comment 'display name',
profileurl varchar(255) comment 'URL, cached so we dont regenerate',
homepage varchar(255) comment 'identifying URL',
- bio varchar(140) comment 'descriptive biography',
+ bio text comment 'descriptive biography',
location varchar(255) comment 'physical location',
+ lat decimal(10,7) comment 'latitude',
+ lon decimal(10,7) comment 'longitude',
+ location_id integer comment 'location id if possible',
+ location_ns integer comment 'namespace for location',
+
created datetime not null comment 'date this record was created',
modified timestamp comment 'date this record was modified',
@@ -110,7 +116,7 @@ create table notice (
id integer auto_increment primary key comment 'unique identifier',
profile_id integer not null comment 'who made the update' references profile (id),
uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
- content varchar(140) comment 'update content',
+ content text comment 'update content',
rendered text comment 'HTML version of the content',
url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',
created datetime not null comment 'date this record was created',
@@ -119,6 +125,10 @@ create table notice (
is_local tinyint default 0 comment 'notice was generated by a user',
source varchar(32) comment 'source of comment, like "web", "im", or "clientname"',
conversation integer comment 'id of root notice in this conversation' references notice (id),
+ lat decimal(10,7) comment 'latitude',
+ lon decimal(10,7) comment 'longitude',
+ location_id integer comment 'location id if possible',
+ location_ns integer comment 'namespace for location',
index notice_profile_id_idx (profile_id),
index notice_conversation_idx (conversation),
@@ -195,18 +205,6 @@ create table nonce (
constraint primary key (consumer_key, ts, nonce)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
-/* One-to-many relationship of user to openid_url */
-
-create table user_openid (
- canonical varchar(255) primary key comment 'Canonical true URL',
- display varchar(255) not null unique key comment 'URL for viewing, may be different from canonical',
- user_id integer not null comment 'user owning this URL' references user (id),
- created datetime not null comment 'date this record was created',
- modified timestamp comment 'date this record was modified',
-
- index user_openid_user_id_idx (user_id)
-) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
-
/* These are used by JanRain OpenID library */
create table oid_associations (
@@ -331,7 +329,7 @@ create table message (
uri varchar(255) unique key comment 'universally unique identifier',
from_profile integer not null comment 'who the message is from' references profile (id),
to_profile integer not null comment 'who the message is to' references profile (id),
- content varchar(140) comment 'message content',
+ content text comment 'message content',
rendered text comment 'HTML version of the content',
url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',
created datetime not null comment 'date this record was created',
@@ -380,7 +378,7 @@ create table user_group (
nickname varchar(64) unique key comment 'nickname for addressing',
fullname varchar(255) comment 'display name',
homepage varchar(255) comment 'URL, cached so we dont regenerate',
- description varchar(140) comment 'descriptive biography',
+ description text comment 'group description',
location varchar(255) comment 'related physical location, if any',
original_logo varchar(255) comment 'original size logo',
@@ -450,6 +448,7 @@ create table file_oembed (
file_id integer primary key comment 'oEmbed for that URL/file' references file (id),
version varchar(20) comment 'oEmbed spec. version',
type varchar(20) comment 'oEmbed type: photo, video, link, rich',
+ mimetype varchar(50) comment 'mime type of resource',
provider varchar(50) comment 'name of this oEmbed provider',
provider_url varchar(255) comment 'URL of this oEmbed provider',
width integer comment 'width of oEmbed resource when available',
@@ -534,4 +533,45 @@ create table session (
index session_modified_idx (modified)
-) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; \ No newline at end of file
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
+
+create table deleted_notice (
+
+ id integer primary key comment 'identity of notice',
+ profile_id integer not null comment 'author of the notice',
+ uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
+ created datetime not null comment 'date the notice record was created',
+ deleted datetime not null comment 'date the notice record was created',
+
+ index deleted_notice_profile_id_idx (profile_id)
+
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
+
+create table config (
+
+ section varchar(32) comment 'configuration section',
+ setting varchar(32) comment 'configuration setting',
+ value varchar(255) comment 'configuration value',
+
+ constraint primary key (section, setting)
+
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
+
+create table user_role (
+
+ user_id integer not null comment 'user having the role' references user (id),
+ role varchar(32) not null comment 'string representing the role',
+ created datetime not null comment 'date the role was granted',
+
+ constraint primary key (user_id, role)
+
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
+
+create table location_namespace (
+
+ id integer primary key comment 'identity for this namespace',
+ description varchar(255) comment 'description of the namespace',
+ created datetime not null comment 'date the record was created',
+ modified timestamp comment 'date this record was modified'
+
+) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql
index ad34720a2..672877ddf 100644
--- a/db/statusnet_pg.sql
+++ b/db/statusnet_pg.sql
@@ -465,6 +465,7 @@ create table file_oembed (
file_id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */,
version varchar(20),
type varchar(20),
+ mimetype varchar(50),
provider varchar(50),
provider_url varchar(255),
width integer,
@@ -529,6 +530,17 @@ create table session (
create index session_modified_idx on session (modified);
+create table deleted_notice (
+
+ id integer primary key /* comment 'identity of notice'*/ ,
+ profile_id integer /* not null comment 'author of the notice'*/,
+ uri varchar(255) unique /* comment 'universally unique identifier, usually a tag URI'*/,
+ created timestamp not null /* comment 'date the notice record was created'*/ ,
+ deleted timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date the notice record was created'*/
+);
+
+CREATE index deleted_notice_profile_id_idx on deleted_notice (profile_id);
+
/* Textsearch stuff */
@@ -537,3 +549,23 @@ create index noticecontent_idx on notice using gist(to_tsvector('english',conten
create trigger textsearchupdate before insert or update on profile for each row
execute procedure tsvector_update_trigger(textsearch, 'pg_catalog.english', nickname, fullname, location, bio, homepage);
+
+create table config (
+
+ section varchar(32) /* comment 'configuration section'*/,
+ setting varchar(32) /* comment 'configuration setting'*/,
+ value varchar(255) /* comment 'configuration value'*/,
+
+ primary key (section, setting)
+
+);
+
+create table user_role (
+
+ user_id integer not null /* comment 'user having the role'*/ references "user" (id),
+ role varchar(32) not null /* comment 'string representing the role'*/,
+ created timestamp /* not null comment 'date the role was granted'*/,
+
+ primary key (user_id, role)
+
+);
diff --git a/doc-src/bookmarklet b/doc-src/bookmarklet
index e5ded7702..6ce23bd0b 100644
--- a/doc-src/bookmarklet
+++ b/doc-src/bookmarklet
@@ -2,4 +2,4 @@ A bookmarklet is a small piece of javascript code used as a bookmark. This one w
Drag-and-drop the following link to your bookmarks bar or right-click it and add it to your browser favorites to keep it handy.
-<a href="javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=newnotice',l=d.location,e=encodeURIComponent,g=f+'&amp;status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22 from '+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=800,height=570')){l.href=g;}}a();void(0);">Post to %%site.name%%</a>
+<a href="javascript:(function(){var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=bookmarklet',l=d.location,e=encodeURIComponent,g=f+'&status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22%20%E2%80%94%20'+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=450,height=200')){l.href=g;}}a();})()">Post to %%site.name%%</a>
diff --git a/doc-src/help b/doc-src/help
index 8d7acf63b..93300ab24 100644
--- a/doc-src/help
+++ b/doc-src/help
@@ -26,7 +26,6 @@ Here are some documents that you might find helpful in understanding
* [SMS](%%doc.sms%%) - tying your cellphone to %%site.name%%
* [tags](%%doc.tags%%) - different ways to use tagging
* [Groups](%%doc.groups%%) - joining together in groups
-* [OpenID](%%doc.openid%%) - what OpenID is and how to use it with this service
* [OpenMicroBlogging](%%doc.openmublog%%) - subscribing to remote users
* [Privacy](%%doc.privacy%%) - %%site.name%%'s privacy policy
* [Source](%%doc.source%%) - How to get the StatusNet source code
diff --git a/extlib/DB/DataObject.php b/extlib/DB/DataObject.php
index 8e226b8fa..60ff1441b 100644
--- a/extlib/DB/DataObject.php
+++ b/extlib/DB/DataObject.php
@@ -235,7 +235,7 @@ class DB_DataObject extends DB_DataObject_Overload
* @access private
* @var string
*/
- var $_DB_DataObject_version = "1.8.11";
+ var $_DB_DataObject_version = "1.8.12";
/**
* The Database table (used by table extends)
diff --git a/extlib/DB/DataObject/Cast.php b/extlib/DB/DataObject/Cast.php
index 095d2a4d2..2049beb58 100644
--- a/extlib/DB/DataObject/Cast.php
+++ b/extlib/DB/DataObject/Cast.php
@@ -6,9 +6,9 @@
*
* PHP versions 4 and 5
*
- * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
@@ -16,8 +16,8 @@
* @package DB_DataObject
* @author Alan Knowles <alan@akbkhome.com>
* @copyright 1997-2008 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Cast.php 264148 2008-08-04 03:44:59Z alan_k $
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version CVS: $Id: Cast.php 287158 2009-08-12 13:58:31Z alan_k $
* @link http://pear.php.net/package/DB_DataObject
*/
diff --git a/extlib/DB/DataObject/Error.php b/extlib/DB/DataObject/Error.php
index 382115453..cdb863d83 100644
--- a/extlib/DB/DataObject/Error.php
+++ b/extlib/DB/DataObject/Error.php
@@ -7,9 +7,9 @@
*
* PHP versions 4 and 5
*
- * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
@@ -17,8 +17,8 @@
* @package DB_DataObject
* @author Alan Knowles <alan@akbkhome.com>
* @copyright 1997-2006 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Error.php 277015 2009-03-12 05:51:03Z alan_k $
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version CVS: $Id: Error.php 287158 2009-08-12 13:58:31Z alan_k $
* @link http://pear.php.net/package/DB_DataObject
*/
diff --git a/extlib/libomb/base_url_xrds_mapper.php b/extlib/libomb/base_url_xrds_mapper.php
new file mode 100755
index 000000000..645459583
--- /dev/null
+++ b/extlib/libomb/base_url_xrds_mapper.php
@@ -0,0 +1,51 @@
+<?php
+
+require_once 'xrds_mapper.php';
+require_once 'constants.php';
+
+/**
+ * Map XRDS actions to URLs using base URLs.
+ *
+ * This interface specifies classes which write the XRDS file announcing
+ * the OMB server. An instance of an implementing class should be passed to
+ * OMB_Service_Provider->writeXRDS.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Base_URL_XRDS_Mapper implements OMB_XRDS_Mapper {
+
+ protected $urls;
+
+ public function __construct($oauth_base, $omb_base) {
+ $this->urls = array(
+ OAUTH_ENDPOINT_REQUEST => $oauth_base . 'requesttoken',
+ OAUTH_ENDPOINT_AUTHORIZE => $oauth_base . 'userauthorization',
+ OAUTH_ENDPOINT_ACCESS => $oauth_base . 'accesstoken',
+ OMB_ENDPOINT_POSTNOTICE => $omb_base . 'postnotice',
+ OMB_ENDPOINT_UPDATEPROFILE => $omb_base . 'updateprofile');
+ }
+
+ public function getURL($action) {
+ return $this->urls[$action];
+ }
+}
+?>
diff --git a/extlib/libomb/constants.php b/extlib/libomb/constants.php
new file mode 100644
index 000000000..a097443ac
--- /dev/null
+++ b/extlib/libomb/constants.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Constants for libomb
+ *
+ * This file contains constant definitions for libomb. The defined constants
+ * are service and namespace URIs for OAuth and OMB as used in XRDS.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+/**
+ * The OMB constants.
+ **/
+
+define('OMB_VERSION_01', 'http://openmicroblogging.org/protocol/0.1');
+
+/* The OMB version supported by this libomb version. */
+define('OMB_VERSION', OMB_VERSION_01);
+
+define('OMB_ENDPOINT_UPDATEPROFILE', OMB_VERSION . '/updateProfile');
+define('OMB_ENDPOINT_POSTNOTICE', OMB_VERSION . '/postNotice');
+
+/**
+ * The OAuth constants.
+ **/
+
+define('OAUTH_NAMESPACE', 'http://oauth.net/core/1.0/');
+
+define('OAUTH_ENDPOINT_REQUEST', OAUTH_NAMESPACE.'endpoint/request');
+define('OAUTH_ENDPOINT_AUTHORIZE', OAUTH_NAMESPACE.'endpoint/authorize');
+define('OAUTH_ENDPOINT_ACCESS', OAUTH_NAMESPACE.'endpoint/access');
+define('OAUTH_ENDPOINT_RESOURCE', OAUTH_NAMESPACE.'endpoint/resource');
+
+define('OAUTH_AUTH_HEADER', OAUTH_NAMESPACE.'parameters/auth-header');
+define('OAUTH_POST_BODY', OAUTH_NAMESPACE.'parameters/post-body');
+
+define('OAUTH_HMAC_SHA1', OAUTH_NAMESPACE.'signature/HMAC-SHA1');
+
+define('OAUTH_DISCOVERY', 'http://oauth.net/discovery/1.0');
+?>
diff --git a/extlib/libomb/datastore.php b/extlib/libomb/datastore.php
new file mode 100755
index 000000000..ab52de547
--- /dev/null
+++ b/extlib/libomb/datastore.php
@@ -0,0 +1,200 @@
+<?php
+
+require_once 'OAuth.php';
+
+/**
+ * Data access interface
+ *
+ * This interface specifies data access methods libomb needs. It should be
+ * implemented by libomb users. OMB_Datastore is libomb’s main interface to the
+ * application’s data. Objects corresponding to this interface are used in
+ * OMB_Service_Provider and OMB_Service_Consumer.
+ *
+ * Note that it’s implemented as a class since OAuthDataStore is as well a
+ * class, though only declaring methods.
+ *
+ * OMB_Datastore extends OAuthDataStore with two OAuth-related methods for token
+ * revoking and authorizing and all OMB-related methods.
+ * Refer to OAuth.php for a complete specification of OAuth-related methods.
+ *
+ * It is the user’s duty to signal and handle errors. libomb does not check
+ * return values nor handle exceptions. It is suggested to use exceptions.
+ * Note that lookup_token and getProfile return null if the requested object
+ * is not available. This is NOT an error and should not raise an exception.
+ * Same applies for lookup_nonce which returns a boolean value. These methods
+ * may nevertheless throw an exception, for example in case of a storage errors.
+ *
+ * Most of the parameters passed to these methods are unescaped and unverified
+ * user input. Therefore they should be handled with extra care to avoid
+ * security problems like SQL injections.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Datastore extends OAuthDataStore {
+
+ /*********
+ * OAUTH *
+ *********/
+
+ /**
+ * Revoke specified OAuth token
+ *
+ * Revokes the authorization token specified by $token_key.
+ * Throws exceptions in case of error.
+ *
+ * @param string $token_key The key of the token to be revoked
+ *
+ * @access public
+ **/
+ public function revoke_token($token_key) {
+ throw new Exception();
+ }
+
+ /**
+ * Authorize specified OAuth token
+ *
+ * Authorizes the authorization token specified by $token_key.
+ * Throws exceptions in case of error.
+ *
+ * @param string $token_key The key of the token to be authorized
+ *
+ * @access public
+ **/
+ public function authorize_token($token_key) {
+ throw new Exception();
+ }
+
+ /*********
+ * OMB *
+ *********/
+
+ /**
+ * Get profile by identifying URI
+ *
+ * Returns an OMB_Profile object representing the OMB profile identified by
+ * $identifier_uri.
+ * Returns null if there is no such OMB profile.
+ * Throws exceptions in case of other error.
+ *
+ * @param string $identifier_uri The OMB identifier URI specifying the
+ * requested profile
+ *
+ * @access public
+ *
+ * @return OMB_Profile The corresponding profile
+ **/
+ public function getProfile($identifier_uri) {
+ throw new Exception();
+ }
+
+ /**
+ * Save passed profile
+ *
+ * Stores the OMB profile $profile. Overwrites an existing entry.
+ * Throws exceptions in case of error.
+ *
+ * @param OMB_Profile $profile The OMB profile which should be saved
+ *
+ * @access public
+ **/
+ public function saveProfile($profile) {
+ throw new Exception();
+ }
+
+ /**
+ * Save passed notice
+ *
+ * Stores the OMB notice $notice. The datastore may change the passed notice.
+ * This might by neccessary for URIs depending on a database key. Note that
+ * it is the user’s duty to present a mechanism for his OMB_Datastore to
+ * appropriately change his OMB_Notice. TODO: Ugly.
+ * Throws exceptions in case of error.
+ *
+ * @param OMB_Notice $notice The OMB notice which should be saved
+ *
+ * @access public
+ **/
+ public function saveNotice(&$notice) {
+ throw new Exception();
+ }
+
+ /**
+ * Get subscriptions of a given profile
+ *
+ * Returns an array containing subscription informations for the specified
+ * profile. Every array entry should in turn be an array with keys
+ * 'uri´: The identifier URI of the subscriber
+ * 'token´: The subscribe token
+ * 'secret´: The secret token
+ * Throws exceptions in case of error.
+ *
+ * @param string $subscribed_user_uri The OMB identifier URI specifying the
+ * subscribed profile
+ *
+ * @access public
+ *
+ * @return mixed An array containing the subscriptions or 0 if no
+ * subscription has been found.
+ **/
+ public function getSubscriptions($subscribed_user_uri) {
+ throw new Exception();
+ }
+
+ /**
+ * Delete a subscription
+ *
+ * Deletes the subscription from $subscriber_uri to $subscribed_user_uri.
+ * Throws exceptions in case of error.
+ *
+ * @param string $subscriber_uri The OMB identifier URI specifying the
+ * subscribing profile
+ *
+ * @param string $subscribed_user_uri The OMB identifier URI specifying the
+ * subscribed profile
+ *
+ * @access public
+ **/
+ public function deleteSubscription($subscriber_uri, $subscribed_user_uri) {
+ throw new Exception();
+ }
+
+ /**
+ * Save a subscription
+ *
+ * Saves the subscription from $subscriber_uri to $subscribed_user_uri.
+ * Throws exceptions in case of error.
+ *
+ * @param string $subscriber_uri The OMB identifier URI specifying
+ * the subscribing profile
+ *
+ * @param string $subscribed_user_uri The OMB identifier URI specifying
+ * the subscribed profile
+ * @param OAuthToken $token The access token
+ *
+ * @access public
+ **/
+ public function saveSubscription($subscriber_uri, $subscribed_user_uri,
+ $token) {
+ throw new Exception();
+ }
+}
+?>
diff --git a/extlib/libomb/helper.php b/extlib/libomb/helper.php
new file mode 100644
index 000000000..a1f21f268
--- /dev/null
+++ b/extlib/libomb/helper.php
@@ -0,0 +1,99 @@
+<?php
+
+require_once 'Validate.php';
+
+/**
+ * Helper functions for libomb
+ *
+ * This file contains helper functions for libomb.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Helper {
+
+ /**
+ * Non-scalar constants
+ *
+ * The set of OMB and OAuth Services an OMB Server has to implement.
+ */
+
+ public static $OMB_SERVICES =
+ array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE);
+ public static $OAUTH_SERVICES =
+ array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE, OAUTH_ENDPOINT_ACCESS);
+
+ /**
+ * Validate URL
+ *
+ * Basic URL validation. Currently http, https, ftp and gopher are supported
+ * schemes.
+ *
+ * @param string $url The URL which is to be validated.
+ *
+ * @return bool Whether URL is valid.
+ *
+ * @access public
+ */
+ public static function validateURL($url) {
+ return Validate::uri($url, array('allowed_schemes' => array('http', 'https',
+ 'gopher', 'ftp')));
+ }
+
+ /**
+ * Validate Media type
+ *
+ * Basic Media type validation. Checks for valid maintype and correct format.
+ *
+ * @param string $mediatype The Media type which is to be validated.
+ *
+ * @return bool Whether media type is valid.
+ *
+ * @access public
+ */
+ public static function validateMediaType($mediatype) {
+ if (0 === preg_match('/^(\w+)\/([\w\d-+.]+)$/', $mediatype, $subtypes)) {
+ return false;
+ }
+ if (!in_array(strtolower($subtypes[1]), array('application', 'audio', 'image',
+ 'message', 'model', 'multipart', 'text', 'video'))) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Remove escaping from request parameters
+ *
+ * Neutralise the evil effects of magic_quotes_gpc in the current request.
+ * This is used before handing a request off to OAuthRequest::from_request.
+ * Many thanks to Ciaran Gultnieks for this fix.
+ *
+ * @access public
+ */
+ public static function removeMagicQuotesFromRequest() {
+ if(get_magic_quotes_gpc() == 1) {
+ $_POST = array_map('stripslashes', $_POST);
+ $_GET = array_map('stripslashes', $_GET);
+ }
+ }
+}
+?>
diff --git a/extlib/libomb/invalidparameterexception.php b/extlib/libomb/invalidparameterexception.php
new file mode 100755
index 000000000..163e1dd4c
--- /dev/null
+++ b/extlib/libomb/invalidparameterexception.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Exception stating that a passed parameter is invalid
+ *
+ * This exception is raised when a parameter does not obey the OMB standard.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+class OMB_InvalidParameterException extends Exception {
+ public function __construct($value, $type, $parameter) {
+ parent::__construct("Invalid value $value for parameter $parameter in $type");
+ }
+}
+?>
diff --git a/extlib/libomb/invalidyadisexception.php b/extlib/libomb/invalidyadisexception.php
new file mode 100755
index 000000000..797b7b95b
--- /dev/null
+++ b/extlib/libomb/invalidyadisexception.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Exception stating that a requested url does not resolve to a valid yadis
+ *
+ * This exception is raised when OMB_Service is not able to discover a valid
+ * yadis location with XRDS.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+class OMB_InvalidYadisException extends Exception {
+
+}
+?>
diff --git a/extlib/libomb/notice.php b/extlib/libomb/notice.php
new file mode 100755
index 000000000..9ac36640a
--- /dev/null
+++ b/extlib/libomb/notice.php
@@ -0,0 +1,272 @@
+<?php
+require_once 'invalidparameterexception.php';
+require_once 'Validate.php';
+require_once 'helper.php';
+
+/**
+ * OMB Notice representation
+ *
+ * This class represents an OMB notice.
+ *
+ * Do not call the setters with null values. Instead, if you want to delete a
+ * field, pass an empty string. The getters will return null for empty fields.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Notice {
+ protected $author;
+ protected $uri;
+ protected $content;
+ protected $url;
+ protected $license_url; /* url is an own addition for clarification. */
+ protected $seealso_url; /* url is an own addition for clarification. */
+ protected $seealso_disposition;
+ protected $seealso_mediatype;
+ protected $seealso_license_url; /* url is an addition for clarification. */
+
+ /* The notice as OMB param array. Cached and rebuild on usage.
+ false while outdated. */
+ protected $param_array;
+
+ /**
+ * Constructor for OMB_Notice
+ *
+ * Initializes the OMB_Notice object with author, uri and content.
+ * These parameters are mandatory for postNotice.
+ *
+ * @param object $author An OMB_Profile object representing the author of the
+ * notice.
+ * @param string $uri The notice URI as defined by the OMB. A unique and
+ * unchanging identifier for a notice.
+ * @param string $content The content of the notice. 140 chars recommended,
+ * but there is no limit.
+ *
+ * @access public
+ */
+ public function __construct($author, $uri, $content) {
+ $this->content = $content;
+ if (is_null($author)) {
+ throw new OMB_InvalidParameterException('', 'notice', 'omb_listenee');
+ }
+ $this->author = $author;
+
+ if (!Validate::uri($uri)) {
+ throw new OMB_InvalidParameterException($uri, 'notice', 'omb_notice');
+ }
+ $this->uri = $uri;
+
+ $this->param_array = false;
+ }
+
+ /**
+ * Returns the notice as array
+ *
+ * The method returns an array which contains the whole notice as array. The
+ * array is cached and only rebuilt on changes of the notice.
+ * Empty optional values are not passed.
+ *
+ * @access public
+ * @returns array The notice as parameter array
+ */
+ public function asParameters() {
+ if ($this->param_array !== false) {
+ return $this->param_array;
+ }
+
+ $this->param_array = array(
+ 'omb_notice' => $this->uri,
+ 'omb_notice_content' => $this->content);
+
+ if (!is_null($this->url))
+ $this->param_array['omb_notice_url'] = $this->url;
+
+ if (!is_null($this->license_url))
+ $this->param_array['omb_notice_license'] = $this->license_url;
+
+ if (!is_null($this->seealso_url)) {
+ $this->param_array['omb_seealso'] = $this->seealso_url;
+
+ /* This is actually a free interpretation of the OMB standard. We assume
+ that additional seealso parameters are not of any use if seealso itself
+ is not set. */
+ if (!is_null($this->seealso_disposition))
+ $this->param_array['omb_seealso_disposition'] =
+ $this->seealso_disposition;
+
+ if (!is_null($this->seealso_mediatype))
+ $this->param_array['omb_seealso_mediatype'] = $this->seealso_mediatype;
+
+ if (!is_null($this->seealso_license_url))
+ $this->param_array['omb_seealso_license'] = $this->seealso_license_url;
+ }
+ return $this->param_array;
+ }
+
+ /**
+ * Builds an OMB_Notice object from array
+ *
+ * The method builds an OMB_Notice object from the passed parameters array.
+ * The array MUST provide a notice URI and content. The array fields HAVE TO
+ * be named according to the OMB standard, i. e. omb_notice_* and
+ * omb_seealso_*. Values are handled as not passed if the corresponding array
+ * fields are not set or the empty string.
+ *
+ * @param object $author An OMB_Profile object representing the author of
+ * the notice.
+ * @param string $parameters An array containing the notice parameters.
+ *
+ * @access public
+ *
+ * @returns OMB_Notice The built OMB_Notice.
+ */
+ public static function fromParameters($author, $parameters) {
+ $notice = new OMB_Notice($author, $parameters['omb_notice'],
+ $parameters['omb_notice_content']);
+
+ if (isset($parameters['omb_notice_url'])) {
+ $notice->setURL($parameters['omb_notice_url']);
+ }
+
+ if (isset($parameters['omb_notice_license'])) {
+ $notice->setLicenseURL($parameters['omb_notice_license']);
+ }
+
+ if (isset($parameters['omb_seealso'])) {
+ $notice->setSeealsoURL($parameters['omb_seealso']);
+ }
+
+ if (isset($parameters['omb_seealso_disposition'])) {
+ $notice->setSeealsoDisposition($parameters['omb_seealso_disposition']);
+ }
+
+ if (isset($parameters['omb_seealso_mediatype'])) {
+ $notice->setSeealsoMediatype($parameters['omb_seealso_mediatype']);
+ }
+
+ if (isset($parameters['omb_seealso_license'])) {
+ $notice->setSeealsoLicenseURL($parameters['omb_seealso_license']);
+ }
+ return $notice;
+ }
+
+ public function getAuthor() {
+ return $this->author;
+ }
+
+ public function getIdentifierURI() {
+ return $this->uri;
+ }
+
+ public function getContent() {
+ return $this->content;
+ }
+
+ public function getURL() {
+ return $this->url;
+ }
+
+ public function getLicenseURL() {
+ return $this->license_url;
+ }
+
+ public function getSeealsoURL() {
+ return $this->seealso_url;
+ }
+
+ public function getSeealsoDisposition() {
+ return $this->seealso_disposition;
+ }
+
+ public function getSeealsoMediatype() {
+ return $this->seealso_mediatype;
+ }
+
+ public function getSeealsoLicenseURL() {
+ return $this->seealso_license_url;
+ }
+
+ public function setURL($url) {
+ if ($url === '') {
+ $url = null;
+ } elseif (!OMB_Helper::validateURL($url)) {
+ throw new OMB_InvalidParameterException($url, 'notice', 'omb_notice_url');
+ }
+ $this->url = $url;
+ $this->param_array = false;
+ }
+
+ public function setLicenseURL($license_url) {
+ if ($license_url === '') {
+ $license_url = null;
+ } elseif (!OMB_Helper::validateURL($license_url)) {
+ throw new OMB_InvalidParameterException($license_url, 'notice',
+ 'omb_notice_license');
+ }
+ $this->license_url = $license_url;
+ $this->param_array = false;
+ }
+
+ public function setSeealsoURL($seealso_url) {
+ if ($seealso_url === '') {
+ $seealso_url = null;
+ } elseif (!OMB_Helper::validateURL($seealso_url)) {
+ throw new OMB_InvalidParameterException($seealso_url, 'notice',
+ 'omb_seealso');
+ }
+ $this->seealso_url = $seealso_url;
+ $this->param_array = false;
+ }
+
+ public function setSeealsoDisposition($seealso_disposition) {
+ if ($seealso_disposition === '') {
+ $seealso_disposition = null;
+ } elseif ($seealso_disposition !== 'link' && $seealso_disposition !== 'inline') {
+ throw new OMB_InvalidParameterException($seealso_disposition, 'notice',
+ 'omb_seealso_disposition');
+ }
+ $this->seealso_disposition = $seealso_disposition;
+ $this->param_array = false;
+ }
+
+ public function setSeealsoMediatype($seealso_mediatype) {
+ if ($seealso_mediatype === '') {
+ $seealso_mediatype = null;
+ } elseif (!OMB_Helper::validateMediaType($seealso_mediatype)) {
+ throw new OMB_InvalidParameterException($seealso_mediatype, 'notice',
+ 'omb_seealso_mediatype');
+ }
+ $this->seealso_mediatype = $seealso_mediatype;
+ $this->param_array = false;
+ }
+
+ public function setSeealsoLicenseURL($seealso_license_url) {
+ if ($seealso_license_url === '') {
+ $seealso_license_url = null;
+ } elseif (!OMB_Helper::validateURL($seealso_license_url)) {
+ throw new OMB_InvalidParameterException($seealso_license_url, 'notice',
+ 'omb_seealso_license');
+ }
+ $this->seealso_license_url = $seealso_license_url;
+ $this->param_array = false;
+ }
+}
+?>
diff --git a/extlib/libomb/omb_yadis_xrds.php b/extlib/libomb/omb_yadis_xrds.php
new file mode 100755
index 000000000..89921203b
--- /dev/null
+++ b/extlib/libomb/omb_yadis_xrds.php
@@ -0,0 +1,196 @@
+<?php
+
+require_once 'Auth/Yadis/Yadis.php';
+require_once 'unsupportedserviceexception.php';
+require_once 'invalidyadisexception.php';
+
+/**
+ * OMB XRDS representation
+ *
+ * This class represents a Yadis XRDS file for OMB. It adds some useful methods to
+ * Auth_Yadis_XRDS.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Yadis_XRDS extends Auth_Yadis_XRDS {
+
+ protected $fetcher;
+
+ /**
+ * Create an instance from URL
+ *
+ * Constructs an OMB_Yadis_XRDS object from a given URL. A full Yadis
+ * discovery is performed on the URL and the XRDS is parsed.
+ * Throws an OMB_InvalidYadisException when no Yadis is discovered or the
+ * detected XRDS file is broken.
+ *
+ * @param string $url The URL on which Yadis discovery
+ * should be performed on
+ * @param Auth_Yadis_HTTPFetcher $fetcher A fetcher used to get HTTP
+ * resources
+ *
+ * @access public
+ *
+ * @return OMB_Yadis_XRDS The initialized object representing the given
+ * resource
+ **/
+ public static function fromYadisURL($url, $fetcher) {
+ /* Perform a Yadis discovery. */
+ $yadis = Auth_Yadis_Yadis::discover($url, $fetcher);
+ if ($yadis->failed) {
+ throw new OMB_InvalidYadisException($url);
+ }
+
+ /* Parse the XRDS file. */
+ $xrds = OMB_Yadis_XRDS::parseXRDS($yadis->response_text);
+ if ($xrds === null) {
+ throw new OMB_InvalidYadisException($url);
+ }
+ $xrds->fetcher = $fetcher;
+ return $xrds;
+ }
+
+ /**
+ * Get a specific service
+ *
+ * Returns the Auth_Yadis_Service object corresponding to the given service
+ * URI.
+ * Throws an OMB_UnsupportedServiceException if the service is not available.
+ *
+ * @param string $service URI specifier of the requested service
+ *
+ * @access public
+ *
+ * @return Auth_Yadis_Service The object representing the requested service
+ **/
+ public function getService($service) {
+ $match = $this->services(array( create_function('$s',
+ "return in_array('$service', \$s->getTypes());")));
+ if ($match === array()) {
+ throw new OMB_UnsupportedServiceException($service);
+ }
+ return $match[0];
+ }
+
+ /**
+ * Get a specific XRD
+ *
+ * Returns the OMB_Yadis_XRDS object corresponding to the given URI.
+ * Throws an OMB_UnsupportedServiceException if the XRD is not available.
+ * Note that getXRD tries to resolve external XRD parts as well.
+ *
+ * @param string $uri URI specifier of the requested XRD
+ *
+ * @access public
+ *
+ * @return OMB_Yadis_XRDS The object representing the requested XRD
+ **/
+ public function getXRD($uri) {
+ $nexthash = strpos($uri, '#');
+ if ($nexthash !== 0) {
+ if ($nexthash !== false) {
+ $cururi = substr($uri, 0, $nexthash);
+ $nexturi = substr($uri, $nexthash);
+ }
+ return
+ OMB_Yadis_XRDS::fromYadisURL($cururi, $this->fetcher)->getXRD($nexturi);
+ }
+
+ $id = substr($uri, 1);
+ foreach ($this->allXrdNodes as $node) {
+ $attrs = $this->parser->attributes($node);
+ if (array_key_exists('xml:id', $attrs) && $attrs['xml:id'] == $id) {
+ /* Trick the constructor into thinking this is the only node. */
+ $bogus_nodes = array($node);
+ return new OMB_Yadis_XRDS($this->parser, $bogus_nodes);
+ }
+ }
+ throw new OMB_UnsupportedServiceException($uri);
+ }
+
+ /**
+ * Parse an XML string containing a XRDS document
+ *
+ * Parse an XML string (XRDS document) and return either a
+ * Auth_Yadis_XRDS object or null, depending on whether the
+ * XRDS XML is valid.
+ * Copy and paste from parent to select correct constructor.
+ *
+ * @param string $xml_string An XRDS XML string.
+ *
+ * @access public
+ *
+ * @return mixed An instance of OMB_Yadis_XRDS or null,
+ * depending on the validity of $xml_string
+ **/
+
+ public function &parseXRDS($xml_string, $extra_ns_map = null) {
+ $_null = null;
+
+ if (!$xml_string) {
+ return $_null;
+ }
+
+ $parser = Auth_Yadis_getXMLParser();
+
+ $ns_map = Auth_Yadis_getNSMap();
+
+ if ($extra_ns_map && is_array($extra_ns_map)) {
+ $ns_map = array_merge($ns_map, $extra_ns_map);
+ }
+
+ if (!($parser && $parser->init($xml_string, $ns_map))) {
+ return $_null;
+ }
+
+ // Try to get root element.
+ $root = $parser->evalXPath('/xrds:XRDS[1]');
+ if (!$root) {
+ return $_null;
+ }
+
+ if (is_array($root)) {
+ $root = $root[0];
+ }
+
+ $attrs = $parser->attributes($root);
+
+ if (array_key_exists('xmlns:xrd', $attrs) &&
+ $attrs['xmlns:xrd'] != Auth_Yadis_XMLNS_XRDS) {
+ return $_null;
+ } else if (array_key_exists('xmlns', $attrs) &&
+ preg_match('/xri/', $attrs['xmlns']) &&
+ $attrs['xmlns'] != Auth_Yadis_XMLNS_XRD_2_0) {
+ return $_null;
+ }
+
+ // Get the last XRD node.
+ $xrd_nodes = $parser->evalXPath('/xrds:XRDS[1]/xrd:XRD');
+
+ if (!$xrd_nodes) {
+ return $_null;
+ }
+
+ $xrds = new OMB_Yadis_XRDS($parser, $xrd_nodes);
+ return $xrds;
+ }
+}
diff --git a/extlib/libomb/plain_xrds_writer.php b/extlib/libomb/plain_xrds_writer.php
new file mode 100755
index 000000000..b4a6e990b
--- /dev/null
+++ b/extlib/libomb/plain_xrds_writer.php
@@ -0,0 +1,124 @@
+<?php
+
+require_once 'xrds_writer.php';
+
+/**
+ * Write OMB-specific XRDS using XMLWriter.
+ *
+ * This class writes the XRDS file announcing the OMB server. It uses
+ * OMB_XMLWriter, which is a subclass of XMLWriter. An instance of
+ * OMB_Plain_XRDS_Writer should be passed to OMB_Service_Provider->writeXRDS.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Plain_XRDS_Writer implements OMB_XRDS_Writer {
+ public function writeXRDS($user, $mapper) {
+ header('Content-Type: application/xrds+xml');
+ $xw = new XMLWriter();
+ $xw->openURI('php://output');
+ $xw->setIndent(true);
+
+ $xw->startDocument('1.0', 'UTF-8');
+ $this->writeFullElement($xw, 'XRDS', array('xmlns' => 'xri://$xrds'), array(
+ array('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'oauth',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'), array(
+ array('Type', null, 'xri://$xrds*simple'),
+ array('Service', null, array(
+ array('Type', null, OAUTH_ENDPOINT_REQUEST),
+ array('URI', null, $mapper->getURL(OAUTH_ENDPOINT_REQUEST)),
+ array('Type', null, OAUTH_AUTH_HEADER),
+ array('Type', null, OAUTH_POST_BODY),
+ array('Type', null, OAUTH_HMAC_SHA1),
+ array('LocalID', null, $user->getIdentifierURI())
+ )),
+ array('Service', null, array(
+ array('Type', null, OAUTH_ENDPOINT_AUTHORIZE),
+ array('URI', null, $mapper->getURL(OAUTH_ENDPOINT_AUTHORIZE)),
+ array('Type', null, OAUTH_AUTH_HEADER),
+ array('Type', null, OAUTH_POST_BODY),
+ array('Type', null, OAUTH_HMAC_SHA1)
+ )),
+ array('Service', null, array(
+ array('Type', null, OAUTH_ENDPOINT_ACCESS),
+ array('URI', null, $mapper->getURL(OAUTH_ENDPOINT_ACCESS)),
+ array('Type', null, OAUTH_AUTH_HEADER),
+ array('Type', null, OAUTH_POST_BODY),
+ array('Type', null, OAUTH_HMAC_SHA1)
+ )),
+ array('Service', null, array(
+ array('Type', null, OAUTH_ENDPOINT_RESOURCE),
+ array('Type', null, OAUTH_AUTH_HEADER),
+ array('Type', null, OAUTH_POST_BODY),
+ array('Type', null, OAUTH_HMAC_SHA1)
+ ))
+ )),
+ array('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'xml:id' => 'omb',
+ 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
+ 'version' => '2.0'), array(
+ array('Type', null, 'xri://$xrds*simple'),
+ array('Service', null, array(
+ array('Type', null, OMB_ENDPOINT_POSTNOTICE),
+ array('URI', null, $mapper->getURL(OMB_ENDPOINT_POSTNOTICE))
+ )),
+ array('Service', null, array(
+ array('Type', null, OMB_ENDPOINT_UPDATEPROFILE),
+ array('URI', null, $mapper->getURL(OMB_ENDPOINT_UPDATEPROFILE))
+ ))
+ )),
+ array('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
+ 'version' => '2.0'), array(
+ array('Type', null, 'xri://$xrds*simple'),
+ array('Service', null, array(
+ array('Type', null, OAUTH_DISCOVERY),
+ array('URI', null, '#oauth')
+ )),
+ array('Service', null, array(
+ array('Type', null, OMB_VERSION),
+ array('URI', null, '#omb')
+ ))
+ ))
+ ));
+ $xw->endDocument();
+ $xw->flush();
+ }
+
+ public static function writeFullElement($xw, $tag, $attributes, $content) {
+ $xw->startElement($tag);
+ if (!is_null($attributes)) {
+ foreach ($attributes as $name => $value) {
+ $xw->writeAttribute($name, $value);
+ }
+ }
+ if (is_array($content)) {
+ foreach ($content as $values) {
+ OMB_Plain_XRDS_Writer::writeFullElement($xw, $values[0], $values[1], $values[2]);
+ }
+ } else {
+ $xw->text($content);
+ }
+ $xw->fullEndElement();
+ }
+}
+?>
diff --git a/extlib/libomb/profile.php b/extlib/libomb/profile.php
new file mode 100755
index 000000000..13314d3e8
--- /dev/null
+++ b/extlib/libomb/profile.php
@@ -0,0 +1,317 @@
+<?php
+require_once 'invalidparameterexception.php';
+require_once 'Validate.php';
+require_once 'helper.php';
+
+/**
+ * OMB profile representation
+ *
+ * This class represents an OMB profile.
+ *
+ * Do not call the setters with null values. Instead, if you want to delete a
+ * field, pass an empty string. The getters will return null for empty fields.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Profile {
+ protected $identifier_uri;
+ protected $profile_url;
+ protected $nickname;
+ protected $license_url;
+ protected $fullname;
+ protected $homepage;
+ protected $bio;
+ protected $location;
+ protected $avatar_url;
+
+ /* The profile as OMB param array. Cached and rebuild on usage.
+ false while outdated. */
+ protected $param_array;
+
+ /**
+ * Constructor for OMB_Profile
+ *
+ * Initializes the OMB_Profile object with an identifier uri.
+ *
+ * @param string $identifier_uri The profile URI as defined by the OMB. A unique
+ * and unchanging identifier for a profile.
+ *
+ * @access public
+ */
+ public function __construct($identifier_uri) {
+ if (!Validate::uri($identifier_uri)) {
+ throw new OMB_InvalidParameterException($identifier_uri, 'profile',
+ 'omb_listenee or omb_listener');
+ }
+ $this->identifier_uri = $identifier_uri;
+ $this->param_array = false;
+ }
+
+ /**
+ * Returns the profile as array
+ *
+ * The method returns an array which contains the whole profile as array. The
+ * array is cached and only rebuilt on changes of the profile.
+ *
+ * @param bool $force_all Specifies whether empty fields should be added to
+ * the array as well. This is neccessary to clear
+ * fields via updateProfile.
+ *
+ * @param string $prefix The common prefix to the key for all parameters.
+ *
+ * @access public
+ *
+ * @return array The profile as parameter array
+ */
+ public function asParameters($prefix, $force_all = false) {
+ if ($this->param_array === false) {
+ $this->param_array = array('' => $this->identifier_uri);
+
+ if ($force_all || !is_null($this->profile_url)) {
+ $this->param_array['_profile'] = $this->profile_url;
+ }
+
+ if ($force_all || !is_null($this->homepage)) {
+ $this->param_array['_homepage'] = $this->homepage;
+ }
+
+ if ($force_all || !is_null($this->nickname)) {
+ $this->param_array['_nickname'] = $this->nickname;
+ }
+
+ if ($force_all || !is_null($this->license_url)) {
+ $this->param_array['_license'] = $this->license_url;
+ }
+
+ if ($force_all || !is_null($this->fullname)) {
+ $this->param_array['_fullname'] = $this->fullname;
+ }
+
+ if ($force_all || !is_null($this->bio)) {
+ $this->param_array['_bio'] = $this->bio;
+ }
+
+ if ($force_all || !is_null($this->location)) {
+ $this->param_array['_location'] = $this->location;
+ }
+
+ if ($force_all || !is_null($this->avatar_url)) {
+ $this->param_array['_avatar'] = $this->avatar_url;
+ }
+
+ }
+ $ret = array();
+ foreach ($this->param_array as $k => $v) {
+ $ret[$prefix . $k] = $v;
+ }
+ return $ret;
+ }
+
+ /**
+ * Builds an OMB_Profile object from array
+ *
+ * The method builds an OMB_Profile object from the passed parameters array. The
+ * array MUST provide a profile URI. The array fields HAVE TO be named according
+ * to the OMB standard. The prefix (omb_listener or omb_listenee) is passed as a
+ * parameter.
+ *
+ * @param string $parameters An array containing the profile parameters.
+ * @param string $prefix The common prefix of the profile parameter keys.
+ *
+ * @access public
+ *
+ * @returns OMB_Profile The built OMB_Profile.
+ */
+ public static function fromParameters($parameters, $prefix) {
+ if (!isset($parameters[$prefix])) {
+ throw new OMB_InvalidParameterException('', 'profile', $prefix);
+ }
+
+ $profile = new OMB_Profile($parameters[$prefix]);
+ $profile->updateFromParameters($parameters, $prefix);
+ return $profile;
+ }
+
+ /**
+ * Update from array
+ *
+ * Updates from the passed parameters array. The array does not have to
+ * provide a profile URI. The array fields HAVE TO be named according to the
+ * OMB standard. The prefix (omb_listener or omb_listenee) is passed as a
+ * parameter.
+ *
+ * @param string $parameters An array containing the profile parameters.
+ * @param string $prefix The common prefix of the profile parameter keys.
+ *
+ * @access public
+ */
+ public function updateFromParameters($parameters, $prefix) {
+ if (isset($parameters[$prefix.'_profile'])) {
+ $this->setProfileURL($parameters[$prefix.'_profile']);
+ }
+
+ if (isset($parameters[$prefix.'_license'])) {
+ $this->setLicenseURL($parameters[$prefix.'_license']);
+ }
+
+ if (isset($parameters[$prefix.'_nickname'])) {
+ $this->setNickname($parameters[$prefix.'_nickname']);
+ }
+
+ if (isset($parameters[$prefix.'_fullname'])) {
+ $this->setFullname($parameters[$prefix.'_fullname']);
+ }
+
+ if (isset($parameters[$prefix.'_homepage'])) {
+ $this->setHomepage($parameters[$prefix.'_homepage']);
+ }
+
+ if (isset($parameters[$prefix.'_bio'])) {
+ $this->setBio($parameters[$prefix.'_bio']);
+ }
+
+ if (isset($parameters[$prefix.'_location'])) {
+ $this->setLocation($parameters[$prefix.'_location']);
+ }
+
+ if (isset($parameters[$prefix.'_avatar'])) {
+ $this->setAvatarURL($parameters[$prefix.'_avatar']);
+ }
+ }
+
+ public function getIdentifierURI() {
+ return $this->identifier_uri;
+ }
+
+ public function getProfileURL() {
+ return $this->profile_url;
+ }
+
+ public function getHomepage() {
+ return $this->homepage;
+ }
+
+ public function getNickname() {
+ return $this->nickname;
+ }
+
+ public function getLicenseURL() {
+ return $this->license_url;
+ }
+
+ public function getFullname() {
+ return $this->fullname;
+ }
+
+ public function getBio() {
+ return $this->bio;
+ }
+
+ public function getLocation() {
+ return $this->location;
+ }
+
+ public function getAvatarURL() {
+ return $this->avatar_url;
+ }
+
+ public function setProfileURL($profile_url) {
+ if (!OMB_Helper::validateURL($profile_url)) {
+ throw new OMB_InvalidParameterException($profile_url, 'profile',
+ 'omb_listenee_profile or omb_listener_profile');
+ }
+ $this->profile_url = $profile_url;
+ $this->param_array = false;
+ }
+
+ public function setNickname($nickname) {
+ if (!Validate::string($nickname,
+ array('min_length' => 1,
+ 'max_length' => 64,
+ 'format' => VALIDATE_NUM . VALIDATE_ALPHA))) {
+ throw new OMB_InvalidParameterException($nickname, 'profile', 'nickname');
+ }
+
+ $this->nickname = $nickname;
+ $this->param_array = false;
+ }
+
+ public function setLicenseURL($license_url) {
+ if (!OMB_Helper::validateURL($license_url)) {
+ throw new OMB_InvalidParameterException($license_url, 'profile',
+ 'omb_listenee_license or omb_listener_license');
+ }
+ $this->license_url = $license_url;
+ $this->param_array = false;
+ }
+
+ public function setFullname($fullname) {
+ if ($fullname === '') {
+ $fullname = null;
+ } elseif (!Validate::string($fullname, array('max_length' => 255))) {
+ throw new OMB_InvalidParameterException($fullname, 'profile', 'fullname');
+ }
+ $this->fullname = $fullname;
+ $this->param_array = false;
+ }
+
+ public function setHomepage($homepage) {
+ if ($homepage === '') {
+ $homepage = null;
+ }
+ $this->homepage = $homepage;
+ $this->param_array = false;
+ }
+
+ public function setBio($bio) {
+ if ($bio === '') {
+ $bio = null;
+ } elseif (!Validate::string($bio, array('max_length' => 140))) {
+ throw new OMB_InvalidParameterException($bio, 'profile', 'fullname');
+ }
+ $this->bio = $bio;
+ $this->param_array = false;
+ }
+
+ public function setLocation($location) {
+ if ($location === '') {
+ $location = null;
+ } elseif (!Validate::string($location, array('max_length' => 255))) {
+ throw new OMB_InvalidParameterException($location, 'profile', 'fullname');
+ }
+ $this->location = $location;
+ $this->param_array = false;
+ }
+
+ public function setAvatarURL($avatar_url) {
+ if ($avatar_url === '') {
+ $avatar_url = null;
+ } elseif (!OMB_Helper::validateURL($avatar_url)) {
+ throw new OMB_InvalidParameterException($avatar_url, 'profile',
+ 'omb_listenee_avatar or omb_listener_avatar');
+ }
+ $this->avatar_url = $avatar_url;
+ $this->param_array = false;
+ }
+
+}
+?>
diff --git a/extlib/libomb/remoteserviceexception.php b/extlib/libomb/remoteserviceexception.php
new file mode 100755
index 000000000..374d15973
--- /dev/null
+++ b/extlib/libomb/remoteserviceexception.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Exception stating that the remote service had a failure
+ *
+ * This exception is raised when a remote service failed to return a valid
+ * response to a request or send a valid request.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+class OMB_RemoteServiceException extends Exception {
+ public static function fromYadis($request_uri, $result) {
+ if ($result->status == 200) {
+ $err = 'Got wrong response ' . $result->body;
+ } else {
+ $err = 'Got error code ' . $result->status . ' with response ' . $result->body;
+ }
+ return new OMB_RemoteServiceException($request_uri . ': ' . $err);
+ }
+
+ public static function forRequest($action_uri, $failure) {
+ return new OMB_RemoteServiceException("Handler for $action_uri: " . $failure);
+ }
+}
+?>
diff --git a/extlib/libomb/service_consumer.php b/extlib/libomb/service_consumer.php
new file mode 100755
index 000000000..273fd052e
--- /dev/null
+++ b/extlib/libomb/service_consumer.php
@@ -0,0 +1,430 @@
+<?php
+
+require_once 'constants.php';
+require_once 'Validate.php';
+require_once 'Auth/Yadis/Yadis.php';
+require_once 'OAuth.php';
+require_once 'unsupportedserviceexception.php';
+require_once 'remoteserviceexception.php';
+require_once 'omb_yadis_xrds.php';
+require_once 'helper.php';
+
+/**
+ * OMB service representation
+ *
+ * This class represents a complete remote OMB service. It provides discovery
+ * and execution of the service’s methods.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Service_Consumer {
+ protected $url; /* The service URL */
+ protected $services; /* An array of strings mapping service URI to
+ service URL */
+
+ protected $token; /* An OAuthToken */
+
+ protected $listener_uri; /* The URI identifying the listener, i. e. the
+ remote user. */
+
+ protected $listenee_uri; /* The URI identifying the listenee, i. e. the
+ local user during an auth request. */
+
+ /**
+ * According to OAuth Core 1.0, an user authorization request is no full-blown
+ * OAuth request. nonce, timestamp, consumer_key and signature are not needed
+ * in this step. See http://laconi.ca/trac/ticket/827 for more informations.
+ *
+ * Since Laconica up to version 0.7.2 performs a full OAuth request check, a
+ * correct request would fail.
+ **/
+ public $performLegacyAuthRequest = true;
+
+ /* Helper stuff we are going to need. */
+ protected $fetcher;
+ protected $oauth_consumer;
+ protected $datastore;
+
+ /**
+ * Constructor for OMB_Service_Consumer
+ *
+ * Initializes an OMB_Service_Consumer object representing the OMB service
+ * specified by $service_url. Performs a complete service discovery using
+ * Yadis.
+ * Throws OMB_UnsupportedServiceException if XRDS file does not specify a
+ * complete OMB service.
+ *
+ * @param string $service_url The URL of the service
+ * @param string $consumer_url An URL representing the consumer
+ * @param OMB_Datastore $datastore An instance of a class implementing
+ * OMB_Datastore
+ *
+ * @access public
+ **/
+ public function __construct ($service_url, $consumer_url, $datastore) {
+ $this->url = $service_url;
+ $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
+ $this->datastore = $datastore;
+ $this->oauth_consumer = new OAuthConsumer($consumer_url, '');
+
+ $xrds = OMB_Yadis_XRDS::fromYadisURL($service_url, $this->fetcher);
+
+ /* Detect our services. This performs a validation as well, since
+ getService und getXRD throw exceptions on failure. */
+ $this->services = array();
+
+ foreach (array(OAUTH_DISCOVERY => OMB_Helper::$OAUTH_SERVICES,
+ OMB_VERSION => OMB_Helper::$OMB_SERVICES)
+ as $service_root => $targetservices) {
+ $uris = $xrds->getService($service_root)->getURIs();
+ $xrd = $xrds->getXRD($uris[0]);
+ foreach ($targetservices as $targetservice) {
+ $yadis_service = $xrd->getService($targetservice);
+ if ($targetservice == OAUTH_ENDPOINT_REQUEST) {
+ $localid = $yadis_service->getElements('xrd:LocalID');
+ $this->listener_uri = $yadis_service->parser->content($localid[0]);
+ }
+ $uris = $yadis_service->getURIs();
+ $this->services[$targetservice] = $uris[0];
+ }
+ }
+ }
+
+ /**
+ * Get the handler URI for a service
+ *
+ * Returns the URI the remote web service has specified for the given
+ * service.
+ *
+ * @param string $service The URI identifying the service
+ *
+ * @access public
+ *
+ * @return string The service handler URI
+ **/
+ public function getServiceURI($service) {
+ return $this->services[$service];
+ }
+
+ /**
+ * Get the remote user’s URI
+ *
+ * Returns the URI of the remote user, i. e. the listener.
+ *
+ * @access public
+ *
+ * @return string The remote user’s URI
+ **/
+ public function getRemoteUserURI() {
+ return $this->listener_uri;
+ }
+
+ /**
+ * Get the listenee’s URI
+ *
+ * Returns the URI of the user being subscribed to, i. e. the local user.
+ *
+ * @access public
+ *
+ * @return string The local user’s URI
+ **/
+ public function getListeneeURI() {
+ return $this->listenee_uri;
+ }
+
+ /**
+ * Request a request token
+ *
+ * Performs a token request on the service. Returns an OAuthToken on success.
+ * Throws an exception if the request fails.
+ *
+ * @access public
+ *
+ * @return OAuthToken An unauthorized request token
+ **/
+ public function requestToken() {
+ /* Set the token to null just in case the user called setToken. */
+ $this->token = null;
+
+ $result = $this->performAction(OAUTH_ENDPOINT_REQUEST,
+ array('omb_listener' => $this->listener_uri));
+ if ($result->status != 200) {
+ throw OMB_RemoteServiceException::fromYadis(OAUTH_ENDPOINT_REQUEST,
+ $result);
+ }
+ parse_str($result->body, $return);
+ if (!isset($return['oauth_token']) || !isset($return['oauth_token_secret'])) {
+ throw OMB_RemoteServiceException::fromYadis(OAUTH_ENDPOINT_REQUEST,
+ $result);
+ }
+ $this->setToken($return['oauth_token'], $return['oauth_token_secret']);
+ return $this->token;
+ }
+
+ /**
+ *
+ * Request authorization
+ *
+ * Returns an URL which equals to an authorization request. The end user
+ * should be redirected to this location to perform authorization.
+ * The $finish_url should be a local resource which invokes
+ * OMB_Consumer::finishAuthorization on request.
+ *
+ * @param OMB_Profile $profile An OMB_Profile object representing the
+ * soon-to-be subscribed (i. e. local) user
+ * @param string $finish_url Target location after successful
+ * authorization
+ *
+ * @access public
+ *
+ * @return string An URL representing an authorization request
+ **/
+ public function requestAuthorization($profile, $finish_url) {
+ if ($this->performLegacyAuthRequest) {
+ $params = $profile->asParameters('omb_listenee', false);
+ $params['omb_listener'] = $this->listener_uri;
+ $params['oauth_callback'] = $finish_url;
+
+ $url = $this->prepareAction(OAUTH_ENDPOINT_AUTHORIZE, $params, 'GET')->to_url();
+ } else {
+
+ $params = array(
+ 'oauth_callback' => $finish_url,
+ 'oauth_token' => $this->token->key,
+ 'omb_version' => OMB_VERSION,
+ 'omb_listener' => $this->listener_uri);
+
+ $params = array_merge($profile->asParameters('omb_listenee', false). $params);
+
+ /* Build result URL. */
+ $url = $this->services[OAUTH_ENDPOINT_AUTHORIZE];
+ $url .= (strrpos($url, '?') === false ? '?' : '&');
+ foreach ($params as $k => $v) {
+ $url .= OAuthUtil::urlencode_rfc3986($k) . '=' . OAuthUtil::urlencode_rfc3986($v) . '&';
+ }
+ }
+
+ $this->listenee_uri = $profile->getIdentifierURI();
+
+ return $url;
+ }
+
+ /**
+ * Finish authorization
+ *
+ * Finish the subscription process by converting the received and authorized
+ * request token into an access token. After that, the subscriber’s profile
+ * and the subscription are stored in the database.
+ * Expects an OAuthRequest in query parameters.
+ * Throws exceptions on failure.
+ *
+ * @access public
+ **/
+ public function finishAuthorization() {
+ OMB_Helper::removeMagicQuotesFromRequest();
+ $req = OAuthRequest::from_request();
+ if ($req->get_parameter('oauth_token') !=
+ $this->token->key) {
+ /* That’s not the token I wanted to get authorized. */
+ throw new OAuthException('The authorized token does not equal the ' .
+ 'submitted token.');
+ }
+
+ if ($req->get_parameter('omb_version') != OMB_VERSION) {
+ throw new OMB_RemoteServiceException('The remote service uses an ' .
+ 'unsupported OMB version');
+ }
+
+ /* Construct the profile to validate it. */
+
+ /* Fix OMB bug. Listener URI is not passed. */
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ $params = $_POST;
+ } else {
+ $params = $_GET;
+ }
+ $params['omb_listener'] = $this->listener_uri;
+
+ require_once 'profile.php';
+ $listener = OMB_Profile::fromParameters($params, 'omb_listener');
+
+ /* Ask the remote service to convert the authorized request token into an
+ access token. */
+
+ $result = $this->performAction(OAUTH_ENDPOINT_ACCESS, array());
+ if ($result->status != 200) {
+ throw new OAuthException('Could not get access token');
+ }
+
+ parse_str($result->body, $return);
+ if (!isset($return['oauth_token']) || !isset($return['oauth_token_secret'])) {
+ throw new OAuthException('Could not get access token');
+ }
+ $this->setToken($return['oauth_token'], $return['oauth_token_secret']);
+
+ /* Subscription is finished and valid. Now store the new subscriber and the
+ subscription in the database. */
+
+ $this->datastore->saveProfile($listener);
+ $this->datastore->saveSubscription($this->listener_uri,
+ $this->listenee_uri,
+ $this->token);
+ }
+
+ /**
+ * Return the URI identifying the listener
+ *
+ * Returns the URI for the OMB user who tries to subscribe or already has
+ * subscribed our user. This method is a workaround for a serious OMB flaw:
+ * The Listener URI is not passed in the finishauthorization call.
+ *
+ * @access public
+ *
+ * @return string the listener’s URI
+ **/
+ public function getListenerURI() {
+ return $this->listener_uri;
+ }
+
+ /**
+ * Inform the service about a profile update
+ *
+ * Sends an updated profile to the service.
+ *
+ * @param OMB_Profile $profile The profile that has changed
+ *
+ * @access public
+ **/
+ public function updateProfile($profile) {
+ $params = $profile->asParameters('omb_listenee', true);
+ $this->performOMBAction(OMB_ENDPOINT_UPDATEPROFILE, $params, $profile->getIdentifierURI());
+ }
+
+ /**
+ * Inform the service about a new notice
+ *
+ * Sends a notice to the service.
+ *
+ * @param OMB_Notice $notice The notice
+ *
+ * @access public
+ **/
+ public function postNotice($notice) {
+ $params = $notice->asParameters();
+ $params['omb_listenee'] = $notice->getAuthor()->getIdentifierURI();
+ $this->performOMBAction(OMB_ENDPOINT_POSTNOTICE, $params, $params['omb_listenee']);
+ }
+
+ /**
+ * Set the token member variable
+ *
+ * Initializes the token based on given token and secret token.
+ *
+ * @param string $token The token
+ * @param string $secret The secret token
+ *
+ * @access public
+ **/
+ public function setToken($token, $secret) {
+ $this->token = new OAuthToken($token, $secret);
+ }
+
+ /**
+ * Prepare an OAuthRequest object
+ *
+ * Creates an OAuthRequest object mapping the request specified by the
+ * parameters.
+ *
+ * @param string $action_uri The URI specifying the target service
+ * @param array $params Additional parameters for the service call
+ * @param string $method The HTTP method used to call the service
+ * ('POST' or 'GET', usually)
+ *
+ * @access protected
+ *
+ * @return OAuthRequest the prepared request
+ **/
+ protected function prepareAction($action_uri, $params, $method) {
+ $url = $this->services[$action_uri];
+
+ $url_params = array();
+ parse_str(parse_url($url, PHP_URL_QUERY), $url_params);
+
+ /* Add OMB version. */
+ $url_params['omb_version'] = OMB_VERSION;
+
+ /* Add user-defined parameters. */
+ $url_params = array_merge($url_params, $params);
+
+ $req = OAuthRequest::from_consumer_and_token($this->oauth_consumer,
+ $this->token, $method, $url, $url_params);
+
+ /* Sign the request. */
+ $req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(),
+ $this->oauth_consumer, $this->token);
+
+ return $req;
+ }
+
+ /**
+ * Perform a service call
+ *
+ * Creates an OAuthRequest object and execute the mapped call as POST request.
+ *
+ * @param string $action_uri The URI specifying the target service
+ * @param array $params Additional parameters for the service call
+ *
+ * @access protected
+ *
+ * @return Auth_Yadis_HTTPResponse The POST request response
+ **/
+ protected function performAction($action_uri, $params) {
+ $req = $this->prepareAction($action_uri, $params, 'POST');
+
+ /* Return result page. */
+ return $this->fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), array());
+ }
+
+ /**
+ * Perform an OMB action
+ *
+ * Executes an OMB action – to date, it’s one of updateProfile or postNotice.
+ *
+ * @param string $action_uri The URI specifying the target service
+ * @param array $params Additional parameters for the service call
+ * @param string $listenee_uri The URI identifying the local user for whom
+ * the action is performed
+ *
+ * @access protected
+ **/
+ protected function performOMBAction($action_uri, $params, $listenee_uri) {
+ $result = $this->performAction($action_uri, $params);
+ if ($result->status == 403) {
+ /* The remote user unsubscribed us. */
+ $this->datastore->deleteSubscription($this->listener_uri, $listenee_uri);
+ } else if ($result->status != 200 ||
+ strpos($result->body, 'omb_version=' . OMB_VERSION) === false) {
+ /* The server signaled an error or sent an incorrect response. */
+ throw OMB_RemoteServiceException::fromYadis($action_uri, $result);
+ }
+ }
+}
diff --git a/extlib/libomb/service_provider.php b/extlib/libomb/service_provider.php
new file mode 100755
index 000000000..753152713
--- /dev/null
+++ b/extlib/libomb/service_provider.php
@@ -0,0 +1,425 @@
+<?php
+
+require_once 'constants.php';
+require_once 'remoteserviceexception.php';
+require_once 'helper.php';
+
+/**
+ * OMB service realization
+ *
+ * This class realizes a complete, simple OMB service.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+class OMB_Service_Provider {
+ protected $user; /* An OMB_Profile representing the user */
+ protected $datastore; /* AN OMB_Datastore */
+
+ protected $remote_user; /* An OMB_Profile representing the remote user during
+ the authorization process */
+
+ protected $oauth_server; /* An OAuthServer; should only be accessed via
+ getOAuthServer. */
+
+ /**
+ * Initialize an OMB_Service_Provider object
+ *
+ * Constructs an OMB_Service_Provider instance that provides OMB services
+ * referring to a particular user.
+ *
+ * @param OMB_Profile $user An OMB_Profile; mandatory for XRDS
+ * output, user auth handling and OMB
+ * action performing
+ * @param OMB_Datastore $datastore An OMB_Datastore; mandatory for
+ * everything but XRDS output
+ * @param OAuthServer $oauth_server An OAuthServer; used for token writing
+ * and OMB action handling; will use
+ * default value if not set
+ *
+ * @access public
+ **/
+ public function __construct ($user = null, $datastore = null, $oauth_server = null) {
+ $this->user = $user;
+ $this->datastore = $datastore;
+ $this->oauth_server = $oauth_server;
+ }
+
+ public function getRemoteUser() {
+ return $this->remote_user;
+ }
+
+ /**
+ * Write a XRDS document
+ *
+ * Writes a XRDS document specifying the OMB service. Optionally uses a
+ * given object of a class implementing OMB_XRDS_Writer for output. Else
+ * OMB_Plain_XRDS_Writer is used.
+ *
+ * @param OMB_XRDS_Mapper $xrds_mapper An object mapping actions to URLs
+ * @param OMB_XRDS_Writer $xrds_writer Optional; The OMB_XRDS_Writer used to
+ * write the XRDS document
+ *
+ * @access public
+ *
+ * @return mixed Depends on the used OMB_XRDS_Writer; OMB_Plain_XRDS_Writer
+ * returns nothing.
+ **/
+ public function writeXRDS($xrds_mapper, $xrds_writer = null) {
+ if ($xrds_writer == null) {
+ require_once 'plain_xrds_writer.php';
+ $xrds_writer = new OMB_Plain_XRDS_Writer();
+ }
+ return $xrds_writer->writeXRDS($this->user, $xrds_mapper);
+ }
+
+ /**
+ * Echo a request token
+ *
+ * Outputs an unauthorized request token for the query found in $_GET or
+ * $_POST.
+ *
+ * @access public
+ **/
+ public function writeRequestToken() {
+ OMB_Helper::removeMagicQuotesFromRequest();
+ echo $this->getOAuthServer()->fetch_request_token(OAuthRequest::from_request());
+ }
+
+ /**
+ * Handle an user authorization request.
+ *
+ * Parses an authorization request. This includes OAuth and OMB verification.
+ * Throws exceptions on failures. Returns an OMB_Profile object representing
+ * the remote user.
+ *
+ * The OMB_Profile passed to the constructor of OMB_Service_Provider should
+ * not represent the user specified in the authorization request, but the one
+ * currently logged in to the service. This condition being satisfied,
+ * handleUserAuth will check whether the listener specified in the request is
+ * identical to the logged in user.
+ *
+ * @access public
+ *
+ * @return OMB_Profile The profile of the soon-to-be subscribed, i. e. remote
+ * user
+ **/
+ public function handleUserAuth() {
+ OMB_Helper::removeMagicQuotesFromRequest();
+
+ /* Verify the request token. */
+
+ $this->token = $this->datastore->lookup_token(null, "request", $_GET['oauth_token']);
+ if (is_null($this->token)) {
+ throw new OAuthException('The given request token has not been issued ' .
+ 'by this service.');
+ }
+
+ /* Verify the OMB part. */
+
+ if ($_GET['omb_version'] !== OMB_VERSION) {
+ throw OMB_RemoteServiceException::forRequest(OAUTH_ENDPOINT_AUTHORIZE,
+ 'Wrong OMB version ' . $_GET['omb_version']);
+ }
+
+ if ($_GET['omb_listener'] !== $this->user->getIdentifierURI()) {
+ throw OMB_RemoteServiceException::forRequest(OAUTH_ENDPOINT_AUTHORIZE,
+ 'Wrong OMB listener ' . $_GET['omb_listener']);
+ }
+
+ foreach (array('omb_listenee', 'omb_listenee_profile',
+ 'omb_listenee_nickname', 'omb_listenee_license') as $param) {
+ if (!isset($_GET[$param]) || is_null($_GET[$param])) {
+ throw OMB_RemoteServiceException::forRequest(OAUTH_ENDPOINT_AUTHORIZE,
+ "Required parameter '$param' not found");
+ }
+ }
+
+ /* Store given callback for later use. */
+ if (isset($_GET['oauth_callback']) && $_GET['oauth_callback'] !== '') {
+ $this->callback = $_GET['oauth_callback'];
+ if (!OMB_Helper::validateURL($this->callback)) {
+ throw OMB_RemoteServiceException::forRequest(OAUTH_ENDPOINT_AUTHORIZE,
+ 'Invalid callback URL specified');
+ }
+ }
+ $this->remote_user = OMB_Profile::fromParameters($_GET, 'omb_listenee');
+
+ return $this->remote_user;
+ }
+
+ /**
+ * Continue the OAuth dance after user authorization
+ *
+ * Performs the appropriate actions after user answered the authorization
+ * request.
+ *
+ * @param bool $accepted Whether the user granted authorization
+ *
+ * @access public
+ *
+ * @return array A two-component array with the values:
+ * - callback The callback URL or null if none given
+ * - token The authorized request token or null if not
+ * authorized.
+ **/
+ public function continueUserAuth($accepted) {
+ $callback = $this->callback;
+ if (!$accepted) {
+ $this->datastore->revoke_token($this->token->key);
+ $this->token = null;
+ /* TODO: The handling is probably wrong in terms of OAuth 1.0 but the way
+ laconica works. Moreover I don’t know the right way either. */
+
+ } else {
+ $this->datastore->authorize_token($this->token->key);
+ $this->datastore->saveProfile($this->remote_user);
+ $this->datastore->saveSubscription($this->user->getIdentifierURI(),
+ $this->remote_user->getIdentifierURI(), $this->token);
+
+ if (!is_null($this->callback)) {
+ /* Callback wants to get some informations as well. */
+ $params = $this->user->asParameters('omb_listener', false);
+
+ $params['oauth_token'] = $this->token->key;
+ $params['omb_version'] = OMB_VERSION;
+
+ $callback .= (parse_url($this->callback, PHP_URL_QUERY) ? '&' : '?');
+ foreach ($params as $k => $v) {
+ $callback .= OAuthUtil::urlencode_rfc3986($k) . '=' .
+ OAuthUtil::urlencode_rfc3986($v) . '&';
+ }
+ }
+ }
+ return array($callback, $this->token);
+ }
+
+ /**
+ * Echo an access token
+ *
+ * Outputs an access token for the query found in $_POST. OMB 0.1 specifies
+ * that the access token request has to be a POST even if OAuth allows GET as
+ * well.
+ *
+ * @access public
+ **/
+ public function writeAccessToken() {
+ OMB_Helper::removeMagicQuotesFromRequest();
+ echo $this->getOAuthServer()->fetch_access_token(
+ OAuthRequest::from_request('POST'));
+ }
+
+ /**
+ * Handle an updateprofile request
+ *
+ * Handles an updateprofile request posted to this service. Updates the
+ * profile through the OMB_Datastore.
+ *
+ * @access public
+ *
+ * @return OMB_Profile The updated profile
+ **/
+ public function handleUpdateProfile() {
+ list($req, $profile) = $this->handleOMBRequest(OMB_ENDPOINT_UPDATEPROFILE);
+ $profile->updateFromParameters($req->get_parameters(), 'omb_listenee');
+ $this->datastore->saveProfile($profile);
+ $this->finishOMBRequest();
+ return $profile;
+ }
+
+ /**
+ * Handle a postnotice request
+ *
+ * Handles a postnotice request posted to this service. Saves the notice
+ * through the OMB_Datastore.
+ *
+ * @access public
+ *
+ * @return OMB_Notice The received notice
+ **/
+ public function handlePostNotice() {
+ list($req, $profile) = $this->handleOMBRequest(OMB_ENDPOINT_POSTNOTICE);
+ require_once 'notice.php';
+ $notice = OMB_Notice::fromParameters($profile, $req->get_parameters());
+ $this->datastore->saveNotice($notice);
+ $this->finishOMBRequest();
+ return $notice;
+ }
+
+ /**
+ * Handle an OMB request
+ *
+ * Performs common OMB request handling.
+ *
+ * @param string $uri The URI defining the OMB endpoint being served
+ *
+ * @access protected
+ *
+ * @return array(OAuthRequest, OMB_Profile)
+ **/
+ protected function handleOMBRequest($uri) {
+
+ OMB_Helper::removeMagicQuotesFromRequest();
+ $req = OAuthRequest::from_request('POST');
+ $listenee = $req->get_parameter('omb_listenee');
+
+ try {
+ list($consumer, $token) = $this->getOAuthServer()->verify_request($req);
+ } catch (OAuthException $e) {
+ header('HTTP/1.1 403 Forbidden');
+ throw OMB_RemoteServiceException::forRequest($uri,
+ 'Revoked accesstoken for ' . $listenee);
+ }
+
+ $version = $req->get_parameter('omb_version');
+ if ($version !== OMB_VERSION) {
+ header('HTTP/1.1 400 Bad Request');
+ throw OMB_RemoteServiceException::forRequest($uri,
+ 'Wrong OMB version ' . $version);
+ }
+
+ $profile = $this->datastore->getProfile($listenee);
+ if (is_null($profile)) {
+ header('HTTP/1.1 400 Bad Request');
+ throw OMB_RemoteServiceException::forRequest($uri,
+ 'Unknown remote profile ' . $listenee);
+ }
+
+ $subscribers = $this->datastore->getSubscriptions($listenee);
+ if (count($subscribers) === 0) {
+ header('HTTP/1.1 403 Forbidden');
+ throw OMB_RemoteServiceException::forRequest($uri,
+ 'No subscriber for ' . $listenee);
+ }
+
+ return array($req, $profile);
+ }
+
+ /**
+ * Finishes an OMB request handling
+ *
+ * Performs common OMB request handling finishing.
+ *
+ * @access protected
+ **/
+ protected function finishOMBRequest() {
+ header('HTTP/1.1 200 OK');
+ header('Content-type: text/plain');
+ /* There should be no clutter but the version. */
+ echo "omb_version=" . OMB_VERSION;
+ }
+
+ /**
+ * Return an OAuthServer
+ *
+ * Checks whether the OAuthServer is null. If so, initializes it with a
+ * default value. Returns the OAuth server.
+ *
+ * @access protected
+ **/
+ protected function getOAuthServer() {
+ if (is_null($this->oauth_server)) {
+ $this->oauth_server = new OAuthServer($this->datastore);
+ $this->oauth_server->add_signature_method(
+ new OAuthSignatureMethod_HMAC_SHA1());
+ }
+ return $this->oauth_server;
+ }
+
+ /**
+ * Publish a notice
+ *
+ * Posts an OMB notice. This includes storing the notice and posting it to
+ * subscribed users.
+ *
+ * @param OMB_Notice $notice The new notice
+ *
+ * @access public
+ *
+ * @return array An array mapping subscriber URIs to the exception posting to
+ * them has raised; Empty array if no exception occured
+ **/
+ public function postNotice($notice) {
+ $uri = $this->user->getIdentifierURI();
+
+ /* $notice is passed by reference and may change. */
+ $this->datastore->saveNotice($notice);
+ $subscribers = $this->datastore->getSubscriptions($uri);
+
+ /* No one to post to. */
+ if (is_null($subscribers)) {
+ return array();
+ }
+
+ require_once 'service_consumer.php';
+
+ $err = array();
+ foreach($subscribers as $subscriber) {
+ try {
+ $service = new OMB_Service_Consumer($subscriber['uri'], $uri, $this->datastore);
+ $service->setToken($subscriber['token'], $subscriber['secret']);
+ $service->postNotice($notice);
+ } catch (Exception $e) {
+ $err[$subscriber['uri']] = $e;
+ continue;
+ }
+ }
+ return $err;
+ }
+
+ /**
+ * Publish a profile update
+ *
+ * Posts the current profile as an OMB profile update. This includes updating
+ * the stored profile and posting it to subscribed users.
+ *
+ * @access public
+ *
+ * @return array An array mapping subscriber URIs to the exception posting to
+ * them has raised; Empty array if no exception occured
+ **/
+ public function updateProfile() {
+ $uri = $this->user->getIdentifierURI();
+
+ $this->datastore->saveProfile($this->user);
+ $subscribers = $this->datastore->getSubscriptions($uri);
+
+ /* No one to post to. */
+ if (is_null($subscribers)) {
+ return array();
+ }
+
+ require_once 'service_consumer.php';
+
+ $err = array();
+ foreach($subscribers as $subscriber) {
+ try {
+ $service = new OMB_Service_Consumer($subscriber['uri'], $uri, $this->datastore);
+ $service->setToken($subscriber['token'], $subscriber['secret']);
+ $service->updateProfile($this->user);
+ } catch (Exception $e) {
+ $err[$subscriber['uri']] = $e;
+ continue;
+ }
+ }
+ return $err;
+ }
+}
diff --git a/extlib/libomb/unsupportedserviceexception.php b/extlib/libomb/unsupportedserviceexception.php
new file mode 100755
index 000000000..4dab63ebe
--- /dev/null
+++ b/extlib/libomb/unsupportedserviceexception.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Exception stating that a requested service is not available
+ *
+ * This exception is raised when OMB_Service is asked to call a service the remote
+ * server does not provide.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+class OMB_UnsupportedServiceException extends Exception {
+
+}
+?>
diff --git a/extlib/libomb/xrds_mapper.php b/extlib/libomb/xrds_mapper.php
new file mode 100755
index 000000000..7552154e5
--- /dev/null
+++ b/extlib/libomb/xrds_mapper.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Map XRDS actions to URLs
+ *
+ * This interface specifies classes which write the XRDS file announcing
+ * the OMB server. An instance of an implementing class should be passed to
+ * OMB_Service_Provider->writeXRDS.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+interface OMB_XRDS_Mapper {
+ public function getURL($action);
+}
+?>
diff --git a/extlib/libomb/xrds_writer.php b/extlib/libomb/xrds_writer.php
new file mode 100755
index 000000000..31b451b9c
--- /dev/null
+++ b/extlib/libomb/xrds_writer.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Write OMB-specific XRDS
+ *
+ * This interface specifies classes which write the XRDS file announcing
+ * the OMB server. An instance of an implementing class should be passed to
+ * OMB_Service_Provider->writeXRDS.
+ *
+ * PHP version 5
+ *
+ * LICENSE: 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/>.
+ *
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @copyright 2009 Adrian Lang
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ **/
+
+interface OMB_XRDS_Writer {
+ public function writeXRDS($user, $mapper);
+}
+?>
diff --git a/extlib/php-gettext/gettext.inc b/extlib/php-gettext/gettext.inc
index fcaafe7c9..7c95e40ec 100644
--- a/extlib/php-gettext/gettext.inc
+++ b/extlib/php-gettext/gettext.inc
@@ -129,7 +129,7 @@ function _setlocale($category, $locale) {
$ret = 0;
if (function_exists('setlocale')) // I don't know if this ever happens ;)
$ret = setlocale($category, $locale);
- if (($ret and $locale == '') or ($ret == $locale)) {
+ if ($ret and ($locale == '' or $ret == $locale)) {
$EMULATEGETTEXT = 0;
$CURRENTLOCALE = $ret;
} else {
diff --git a/index.php b/index.php
index 362ab3cd3..644812bd5 100644
--- a/index.php
+++ b/index.php
@@ -15,6 +15,22 @@
*
* 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 StatusNet
+ * @package StatusNet
+ * @author Brenda Wallace <shiny@cpan.org>
+ * @author Christopher Vollick <psycotica0@gmail.com>
+ * @author CiaranG <ciaran@ciarang.com>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@controlezvous.ca>
+ * @author Gina Haeussge <osd@foosel.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <millette@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @author Tom Adams <tom@holizz.com>
+ *
+ * @license GNU Affero General Public License http://www.gnu.org/licenses/
*/
define('INSTALLDIR', dirname(__FILE__));
@@ -29,7 +45,8 @@ $action = null;
function getPath($req)
{
if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER))
- && array_key_exists('p', $req)) {
+ && array_key_exists('p', $req)
+ ) {
return $req['p'];
} else if (array_key_exists('PATH_INFO', $_SERVER)) {
$path = $_SERVER['PATH_INFO'];
@@ -44,6 +61,11 @@ function getPath($req)
}
}
+/**
+ * logs and then displays error messages
+ *
+ * @return void
+ */
function handleError($error)
{
if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
@@ -51,28 +73,35 @@ function handleError($error)
}
$logmsg = "PEAR error: " . $error->getMessage();
- if(common_config('site', 'logdebug')) {
+ if (common_config('site', 'logdebug')) {
$logmsg .= " : ". $error->getDebugInfo();
}
common_log(LOG_ERR, $logmsg);
- if(common_config('site', 'logdebug')) {
+ if (common_config('site', 'logdebug')) {
$bt = $error->getBacktrace();
foreach ($bt as $line) {
common_log(LOG_ERR, $line);
}
}
- if ($error instanceof DB_DataObject_Error ||
- $error instanceof DB_Error) {
- $msg = sprintf(_('The database for %s isn\'t responding correctly, '.
- 'so the site won\'t work properly. '.
- 'The site admins probably know about the problem, '.
- 'but you can contact them at %s to make sure. '.
- 'Otherwise, wait a few minutes and try again.'),
- common_config('site', 'name'),
- common_config('site', 'email'));
+ if ($error instanceof DB_DataObject_Error
+ || $error instanceof DB_Error
+ ) {
+ $msg = sprintf(
+ _(
+ 'The database for %s isn\'t responding correctly, '.
+ 'so the site won\'t work properly. '.
+ 'The site admins probably know about the problem, '.
+ 'but you can contact them at %s to make sure. '.
+ 'Otherwise, wait a few minutes and try again.'
+ ),
+ common_config('site', 'name'),
+ common_config('site', 'email')
+ );
} else {
- $msg = _('An important error occured, probably related to email setup. '.
- 'Check logfiles for more info..');
+ $msg = _(
+ 'An important error occured, probably related to email setup. '.
+ 'Check logfiles for more info..'
+ );
}
$dac = new DBErrorAction($msg, 500);
@@ -112,6 +141,19 @@ function checkMirror($action_obj, $args)
}
}
+function isLoginAction($action)
+{
+ static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register');
+
+ $login = null;
+
+ if (Event::handle('LoginAction', array($action, &$login))) {
+ $login = in_array($action, $loginActions);
+ }
+
+ return $login;
+}
+
function main()
{
// fake HTTP redirects using lighttpd's 404 redirects
@@ -120,10 +162,11 @@ function main()
$_lighty_url = @parse_url($_lighty_url);
if ($_lighty_url['path'] != '/index.php' && $_lighty_url['path'] != '/') {
- $_lighty_path = preg_replace('/^'.preg_quote(common_config('site','path')).'\//', '', substr($_lighty_url['path'], 1));
+ $_lighty_path = preg_replace('/^'.preg_quote(common_config('site', 'path')).'\//', '', substr($_lighty_url['path'], 1));
$_SERVER['QUERY_STRING'] = 'p='.$_lighty_path;
- if ($_lighty_url['query'])
+ if ($_lighty_url['query']) {
$_SERVER['QUERY_STRING'] .= '&'.$_lighty_url['query'];
+ }
parse_str($_lighty_url['query'], $_lighty_query);
foreach ($_lighty_query as $key => $val) {
$_GET[$key] = $_REQUEST[$key] = $val;
@@ -134,7 +177,7 @@ function main()
$_SERVER['REDIRECT_URL'] = preg_replace("/\?.+$/", "", $_SERVER['REQUEST_URI']);
// quick check for fancy URL auto-detection support in installer.
- if (isset($_SERVER['REDIRECT_URL']) && (preg_replace("/^\/$/","",(dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') === $_SERVER['REDIRECT_URL']) {
+ if (isset($_SERVER['REDIRECT_URL']) && (preg_replace("/^\/$/", "", (dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') === $_SERVER['REDIRECT_URL']) {
die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs.");
}
global $user, $action;
@@ -142,8 +185,12 @@ function main()
Snapshot::check();
if (!_have_config()) {
- $msg = sprintf(_("No configuration file found. Try running ".
- "the installation program first."));
+ $msg = sprintf(
+ _(
+ "No configuration file found. Try running ".
+ "the installation program first."
+ )
+ );
$sac = new ServerErrorAction($msg);
$sac->showPage();
return;
@@ -189,36 +236,12 @@ function main()
// If the site is private, and they're not on one of the "public"
// parts of the site, redirect to login
- if (!$user && common_config('site', 'private')) {
- $public_actions = array('openidlogin', 'finishopenidlogin',
- 'recoverpassword', 'api', 'doc',
- 'opensearch');
- $login_action = 'openidlogin';
- if (!common_config('site', 'openidonly')) {
- $public_actions[] = 'login';
- $public_actions[] = 'register';
- $login_action = 'login';
- }
- if (!in_array($action, $public_actions) &&
- !preg_match('/rss$/', $action)) {
-
- // set returnto
- $rargs =& common_copy_args($args);
- unset($rargs['action']);
- if (common_config('site', 'fancy')) {
- unset($rargs['p']);
- }
- if (array_key_exists('submit', $rargs)) {
- unset($rargs['submit']);
- }
- foreach (array_keys($_COOKIE) as $cookie) {
- unset($rargs[$cookie]);
- }
- common_set_returnto(common_local_url($action, $rargs));
-
- common_redirect(common_local_url($login_action));
- return;
- }
+ if (!$user && common_config('site', 'private')
+ && !isLoginAction($action)
+ && !preg_match('/rss$/', $action)
+ ) {
+ common_redirect(common_local_url('login'));
+ return;
}
$action_class = ucfirst($action).'Action';
diff --git a/install.php b/install.php
index 425ea91ef..319c261e4 100644
--- a/install.php
+++ b/install.php
@@ -1,3 +1,4 @@
+
<?php
/**
* StatusNet - the distributed open-source microblogging tool
@@ -15,6 +16,24 @@
*
* 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 Installation
+ * @package Installation
+ *
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Brenda Wallace <shiny@cpan.org>
+ * @author Brett Taylor <brett@webfroot.co.nz>
+ * @author Brion Vibber <brion@pobox.com>
+ * @author CiaranG <ciaran@ciarang.com>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Eric Helgeson <helfire@Erics-MBP.local>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Tom Adams <tom@holizz.com>
+ * @license GNU Affero General Public License http://www.gnu.org/licenses/
+ * @version 0.9.x
+ * @link http://status.net
*/
define('INSTALLDIR', dirname(__FILE__));
@@ -181,15 +200,32 @@ $external_libraries=array(
'check_class'=>'Validate'
)
);
+$dbModules = array(
+ 'mysql' => array(
+ 'name' => 'MySQL',
+ 'check_module' => 'mysql', // mysqli?
+ 'installer' => 'mysql_db_installer',
+ ),
+ 'pgsql' => array(
+ 'name' => 'PostgreSQL',
+ 'check_module' => 'pgsql',
+ 'installer' => 'pgsql_db_installer',
+ ),
+);
+/**
+ * the actual installation.
+ * If call libraries are present, then install
+ *
+ * @return void
+ */
function main()
{
- if (!checkPrereqs())
- {
+ if (!checkPrereqs()) {
return;
}
-
- if (isset($_GET['checklibs'])) {
+
+ if (!empty($_GET['checklibs'])) {
showLibs();
} else {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -200,15 +236,22 @@ function main()
}
}
+/**
+ * checks if an external libary is present
+ *
+ * @param string $external_library Name of library
+ *
+ * @return boolean indicates if library present
+ */
function haveExternalLibrary($external_library)
{
- if(isset($external_library['include']) && ! haveIncludeFile($external_library['include'])){
+ if (isset($external_library['include']) && !haveIncludeFile($external_library['include'])) {
return false;
}
- if(isset($external_library['check_function']) && ! function_exists($external_library['check_function'])){
+ if (isset($external_library['check_function']) && ! function_exists($external_library['check_function'])) {
return false;
}
- if(isset($external_library['check_class']) && ! class_exists($external_library['check_class'])){
+ if (isset($external_library['check_class']) && ! class_exists($external_library['check_class'])) {
return false;
}
return true;
@@ -223,19 +266,23 @@ function haveIncludeFile($filename) {
return $ok;
}
+/**
+ * Check if all is ready for installation
+ *
+ * @return void
+ */
function checkPrereqs()
{
- $pass = true;
+ $pass = true;
if (file_exists(INSTALLDIR.'/config.php')) {
- ?><p class="error">Config file &quot;config.php&quot; already exists.</p>
- <?php
+ printf('<p class="error">Config file &quot;config.php&quot; already exists.</p>');
$pass = false;
}
if (version_compare(PHP_VERSION, '5.2.3', '<')) {
- ?><p class="error">Require PHP version 5.2.3 or greater.</p><?php
- $pass = false;
+ printf('<p class="error">Require PHP version 5.2.3 or greater.</p>');
+ $pass = false;
}
$reqs = array('gd', 'curl',
@@ -243,63 +290,83 @@ function checkPrereqs()
foreach ($reqs as $req) {
if (!checkExtension($req)) {
- ?><p class="error">Cannot load required extension: <code><?php echo $req; ?></code></p><?php
- $pass = false;
+ printf('<p class="error">Cannot load required extension: <code>%s</code></p>', $req);
+ $pass = false;
}
}
- if (!checkExtension('pgsql') && !checkExtension('mysql')) {
- ?><p class="error">Cannot find mysql or pgsql extension. You need one or the other: <code><?php echo $req; ?></code></p><?php
- $pass = false;
- }
-
- if (!is_writable(INSTALLDIR)) {
- ?><p class="error">Cannot write config file to: <code><?php echo INSTALLDIR; ?></code></p>
- <p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?></code>
- <?php
- $pass = false;
- }
-
- // Check the subdirs used for file uploads
- $fileSubdirs = array('avatar', 'background', 'file');
- foreach ($fileSubdirs as $fileSubdir) {
- $fileFullPath = INSTALLDIR."/$fileSubdir/";
- if (!is_writable($fileFullPath)) {
- ?><p class="error">Cannot write <?php echo $fileSubdir; ?> directory: <code><?php echo $fileFullPath; ?></code></p>
- <p>On your server, try this command: <code>chmod a+w <?php echo $fileFullPath; ?></code></p>
- <?php
- $pass = false;
- }
- }
-
- return $pass;
+ // Make sure we have at least one database module available
+ global $dbModules;
+ $missingExtensions = array();
+ foreach ($dbModules as $type => $info) {
+ if (!checkExtension($info['check_module'])) {
+ $missingExtensions[] = $info['check_module'];
+ }
+ }
+
+ if (count($missingExtensions) == count($dbModules)) {
+ $req = implode(', ', $missingExtensions);
+ printf('<p class="error">Cannot find mysql or pgsql extension. You need one or the other.');
+ $pass = false;
+ }
+
+ if (!is_writable(INSTALLDIR)) {
+ printf('<p class="error">Cannot write config file to: <code>%s</code></p>', INSTALLDIR);
+ printf('<p>On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR);
+ $pass = false;
+ }
+
+ // Check the subdirs used for file uploads
+ $fileSubdirs = array('avatar', 'background', 'file');
+ foreach ($fileSubdirs as $fileSubdir) {
+ $fileFullPath = INSTALLDIR."/$fileSubdir/";
+ if (!is_writable($fileFullPath)) {
+ printf('<p class="error">Cannot write to %s directory: <code>%s</code></p>', $fileSubdir, $fileFullPath);
+ printf('<p>On your server, try this command: <code>chmod a+w %s</code></p>', $fileFullPath);
+ $pass = false;
+ }
+ }
+
+ return $pass;
}
+/**
+ * Checks if a php extension is both installed and loaded
+ *
+ * @param string $name of extension to check
+ *
+ * @return boolean whether extension is installed and loaded
+ */
function checkExtension($name)
{
if (extension_loaded($name)) {
return true;
} elseif (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode')) {
- // dl will throw a fatal error if it's disabled or we're in safe mode.
- // More fun, it may not even exist under some SAPIs in 5.3.0 or later...
- $soname = $name . '.' . PHP_SHLIB_SUFFIX;
- if (PHP_SHLIB_SUFFIX == 'dll') {
- $soname = "php_" . $soname;
- }
- return @dl($soname);
+ // dl will throw a fatal error if it's disabled or we're in safe mode.
+ // More fun, it may not even exist under some SAPIs in 5.3.0 or later...
+ $soname = $name . '.' . PHP_SHLIB_SUFFIX;
+ if (PHP_SHLIB_SUFFIX == 'dll') {
+ $soname = "php_" . $soname;
+ }
+ return @dl($soname);
} else {
return false;
}
}
+/**
+ * Show list of libraries
+ *
+ * @return void
+ */
function showLibs()
{
global $external_libraries;
$present_libraries=array();
$absent_libraries=array();
- foreach($external_libraries as $external_library){
- if(haveExternalLibrary($external_library)){
+ foreach ($external_libraries as $external_library) {
+ if (haveExternalLibrary($external_library)) {
$present_libraries[]=$external_library;
- }else{
+ } else {
$absent_libraries[]=$external_library;
}
}
@@ -314,22 +381,21 @@ function showLibs()
<h2>Absent Libraries</h2>
<ul id="absent_libraries">
E_O_T;
- foreach($absent_libraries as $library)
- {
+ foreach ($absent_libraries as $library) {
echo '<li>';
- if(isset($library['url'])){
+ if (isset($library['url'])) {
echo '<a href="'.$library['url'].'">'.htmlentities($library['name']).'</a>';
- }else{
+ } else {
echo htmlentities($library['name']);
}
echo '<ul>';
- if(isset($library['deb'])){
+ if (isset($library['deb'])) {
echo '<li class="deb package">deb: <a href="apt:' . urlencode($library['deb']) . '">' . htmlentities($library['deb']) . '</a></li>';
}
- if(isset($library['rpm'])){
+ if (isset($library['rpm'])) {
echo '<li class="rpm package">rpm: ' . htmlentities($library['rpm']) . '</li>';
}
- if(isset($library['pear'])){
+ if (isset($library['pear'])) {
echo '<li class="pear package">pear: ' . htmlentities($library['pear']) . '</li>';
}
echo '</ul>';
@@ -339,12 +405,11 @@ E_O_T;
<h2>Installed Libraries</h2>
<ul id="present_libraries">
E_O_T;
- foreach($present_libraries as $library)
- {
+ foreach ($present_libraries as $library) {
echo '<li>';
- if(isset($library['url'])){
+ if (isset($library['url'])) {
echo '<a href="'.$library['url'].'">'.htmlentities($library['name']).'</a>';
- }else{
+ } else {
echo htmlentities($library['name']);
}
echo '</li>';
@@ -356,6 +421,15 @@ E_O_T;
function showForm()
{
+ global $dbModules;
+ $dbRadios = '';
+ $checked = 'checked="checked" '; // Check the first one which exists
+ foreach ($dbModules as $type => $info) {
+ if (checkExtension($info['check_module'])) {
+ $dbRadios .= "<input type=\"radio\" name=\"dbtype\" id=\"dbtype-$type\" value=\"$type\" $checked/> $info[name]<br />\n";
+ $checked = '';
+ }
+ }
echo<<<E_O_T
</ul>
</dd>
@@ -392,8 +466,7 @@ function showForm()
<li>
<label for="dbtype">Type</label>
- <input type="radio" name="dbtype" id="fancy-mysql" value="mysql" checked='checked' /> MySQL<br />
- <input type="radio" name="dbtype" id="dbtype-pgsql" value="pgsql" /> PostgreSQL<br />
+ $dbRadios
<p class="form_guide">Database type</p>
</li>
@@ -422,17 +495,11 @@ E_O_T;
function updateStatus($status, $error=false)
{
-?>
- <li <?php echo ($error) ? 'class="error"': ''; ?>><?php echo $status;?></li>
-
-<?php
+ echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
}
function handlePost()
{
-?>
-
-<?php
$host = $_POST['host'];
$dbtype = $_POST['dbtype'];
$database = $_POST['database'];
@@ -443,55 +510,41 @@ function handlePost()
$server = $_SERVER['HTTP_HOST'];
$path = substr(dirname($_SERVER['PHP_SELF']), 1);
-?>
+ echo <<<STR
<dl class="system_notice">
<dt>Page notice</dt>
<dd>
<ul>
-<?php
- $fail = false;
+STR;
+ $fail = false;
if (empty($host)) {
updateStatus("No hostname specified.", true);
- $fail = true;
+ $fail = true;
}
if (empty($database)) {
updateStatus("No database specified.", true);
- $fail = true;
+ $fail = true;
}
if (empty($username)) {
updateStatus("No username specified.", true);
- $fail = true;
+ $fail = true;
}
-// if (empty($password)) {
-// updateStatus("No password specified.", true);
-// $fail = true;
-// }
-
if (empty($sitename)) {
updateStatus("No sitename specified.", true);
- $fail = true;
+ $fail = true;
}
- if($fail){
- showForm();
+ if ($fail) {
+ showForm();
return;
}
- // FIXME: use PEAR::DB or PDO instead of our own switch
-
- switch($dbtype) {
- case 'mysql':
- $db = mysql_db_installer($host, $database, $username, $password);
- break;
- case 'pgsql':
- $db = pgsql_db_installer($host, $database, $username, $password);
- break;
- default:
- }
+ global $dbModules;
+ $db = call_user_func($dbModules[$dbtype]['installer'], $host, $database, $username, $password);
if (!$db) {
// database connection failed, do not move on to create config file.
@@ -514,112 +567,110 @@ function handlePost()
updateStatus("StatusNet has been installed at $link");
updateStatus("You can visit your <a href='$link'>new StatusNet site</a>.");
-?>
-
-<?php
}
-function pgsql_db_installer($host, $database, $username, $password) {
- $connstring = "dbname=$database host=$host user=$username";
-
- //No password would mean trust authentication used.
- if (!empty($password)) {
- $connstring .= " password=$password";
- }
- updateStatus("Starting installation...");
- updateStatus("Checking database...");
- $conn = pg_connect($connstring);
-
- if ($conn ===false) {
- updateStatus("Failed to connect to database: $connstring");
- showForm();
- return false;
- }
-
- //ensure database encoding is UTF8
- $record = pg_fetch_object(pg_query($conn, 'SHOW server_encoding'));
- if ($record->server_encoding != 'UTF8') {
- updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding));
- showForm();
- return false;
- }
-
- updateStatus("Running database script...");
- //wrap in transaction;
- pg_query($conn, 'BEGIN');
- $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql');
-
- if ($res === false) {
- updateStatus("Can't run database script.", true);
- showForm();
- return false;
- }
- foreach (array('sms_carrier' => 'SMS carrier',
+function Pgsql_Db_installer($host, $database, $username, $password)
+{
+ $connstring = "dbname=$database host=$host user=$username";
+
+ //No password would mean trust authentication used.
+ if (!empty($password)) {
+ $connstring .= " password=$password";
+ }
+ updateStatus("Starting installation...");
+ updateStatus("Checking database...");
+ $conn = pg_connect($connstring);
+
+ if ($conn ===false) {
+ updateStatus("Failed to connect to database: $connstring");
+ showForm();
+ return false;
+ }
+
+ //ensure database encoding is UTF8
+ $record = pg_fetch_object(pg_query($conn, 'SHOW server_encoding'));
+ if ($record->server_encoding != 'UTF8') {
+ updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding));
+ showForm();
+ return false;
+ }
+
+ updateStatus("Running database script...");
+ //wrap in transaction;
+ pg_query($conn, 'BEGIN');
+ $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql');
+
+ if ($res === false) {
+ updateStatus("Can't run database script.", true);
+ showForm();
+ return false;
+ }
+ foreach (array('sms_carrier' => 'SMS carrier',
'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
- updateStatus(sprintf("Adding %s data to database...", $name));
- $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql');
- if ($res === false) {
- updateStatus(sprintf("Can't run %d script.", $name), true);
- showForm();
- return false;
- }
- }
- pg_query($conn, 'COMMIT');
-
- if (empty($password)) {
- $sqlUrl = "pgsql://$username@$host/$database";
- }
- else {
- $sqlUrl = "pgsql://$username:$password@$host/$database";
- }
-
- $db = array('type' => 'pgsql', 'database' => $sqlUrl);
-
- return $db;
+ updateStatus(sprintf("Adding %s data to database...", $name));
+ $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql');
+ if ($res === false) {
+ updateStatus(sprintf("Can't run %d script.", $name), true);
+ showForm();
+ return false;
+ }
+ }
+ pg_query($conn, 'COMMIT');
+
+ if (empty($password)) {
+ $sqlUrl = "pgsql://$username@$host/$database";
+ } else {
+ $sqlUrl = "pgsql://$username:$password@$host/$database";
+ }
+
+ $db = array('type' => 'pgsql', 'database' => $sqlUrl);
+
+ return $db;
}
-function mysql_db_installer($host, $database, $username, $password) {
- updateStatus("Starting installation...");
- updateStatus("Checking database...");
-
- $conn = mysql_connect($host, $username, $password);
- if (!$conn) {
- updateStatus("Can't connect to server '$host' as '$username'.", true);
- showForm();
- return false;
- }
- updateStatus("Changing to database...");
- $res = mysql_select_db($database, $conn);
- if (!$res) {
- updateStatus("Can't change to database.", true);
- showForm();
- return false;
- }
- updateStatus("Running database script...");
- $res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn);
- if ($res === false) {
- updateStatus("Can't run database script.", true);
- showForm();
- return false;
- }
- foreach (array('sms_carrier' => 'SMS carrier',
+function Mysql_Db_installer($host, $database, $username, $password)
+{
+ updateStatus("Starting installation...");
+ updateStatus("Checking database...");
+
+ $conn = mysql_connect($host, $username, $password);
+ if (!$conn) {
+ updateStatus("Can't connect to server '$host' as '$username'.", true);
+ showForm();
+ return false;
+ }
+ updateStatus("Changing to database...");
+ $res = mysql_select_db($database, $conn);
+ if (!$res) {
+ updateStatus("Can't change to database.", true);
+ showForm();
+ return false;
+ }
+ updateStatus("Running database script...");
+ $res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn);
+ if ($res === false) {
+ updateStatus("Can't run database script.", true);
+ showForm();
+ return false;
+ }
+ foreach (array('sms_carrier' => 'SMS carrier',
'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
- updateStatus(sprintf("Adding %s data to database...", $name));
- $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
- if ($res === false) {
- updateStatus(sprintf("Can't run %d script.", $name), true);
- showForm();
- return false;
- }
- }
-
- $sqlUrl = "mysqli://$username:$password@$host/$database";
- $db = array('type' => 'mysql', 'database' => $sqlUrl);
- return $db;
+ updateStatus(sprintf("Adding %s data to database...", $name));
+ $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
+ if ($res === false) {
+ updateStatus(sprintf("Can't run %d script.", $name), true);
+ showForm();
+ return false;
+ }
+ }
+
+ $sqlUrl = "mysqli://$username:$password@$host/$database";
+ $db = array('type' => 'mysql', 'database' => $sqlUrl);
+ return $db;
}
function writeConf($sitename, $server, $path, $fancy, $db)
@@ -650,7 +701,16 @@ function writeConf($sitename, $server, $path, $fancy, $db)
return $res;
}
-function runDbScript($filename, $conn, $type = 'mysql')
+/**
+ * Install schema into the database
+ *
+ * @param string $filename location of database schema file
+ * @param dbconn $conn connection to database
+ * @param string $type type of database, currently mysql or pgsql
+ *
+ * @return boolean - indicating success or failure
+ */
+function runDbScript($filename, $conn, $type = 'mysqli')
{
$sql = trim(file_get_contents($filename));
$stmts = explode(';', $sql);
@@ -661,7 +721,7 @@ function runDbScript($filename, $conn, $type = 'mysql')
}
// FIXME: use PEAR::DB or PDO instead of our own switch
switch ($type) {
- case 'mysql':
+ case 'mysqli':
$res = mysql_query($stmt, $conn);
if ($res === false) {
$error = mysql_error();
@@ -686,7 +746,9 @@ function runDbScript($filename, $conn, $type = 'mysql')
?>
<?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
-<!DOCTYPE html>
+<!DOCTYPE html
+PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<title>Install StatusNet</title>
diff --git a/js/util.js b/js/util.js
index 2165957c3..b079388e4 100644
--- a/js/util.js
+++ b/js/util.js
@@ -21,7 +21,9 @@ $(document).ready(function(){
// count character on keyup
function counter(event){
- var maxLength = 140;
+ if (maxLength <= 0) {
+ return;
+ }
var currentLength = $("#notice_data-text").val().length;
var remaining = maxLength - currentLength;
var counter = $("#notice_text-count");
@@ -67,12 +69,20 @@ $(document).ready(function(){
return true;
}
+ // define maxLength if it wasn't defined already
+
+ if (typeof(maxLength) == "undefined") {
+ maxLength = 140;
+ }
+
if ($("#notice_data-text").length) {
- $("#notice_data-text").bind("keyup", counter);
- $("#notice_data-text").bind("keydown", submitonreturn);
+ if (maxLength > 0) {
+ $("#notice_data-text").bind("keyup", counter);
+ // run once in case there's something in there
+ counter();
+ }
- // run once in case there's something in there
- counter();
+ $("#notice_data-text").bind("keydown", submitonreturn);
if($('body')[0].id != 'conversation') {
$("#notice_data-text").focus();
@@ -218,7 +228,9 @@ $(document).ready(function(){
}
else {
$("#notice_data-text").val("");
- counter();
+ if (maxLength > 0) {
+ counter();
+ }
}
}
}
@@ -229,6 +241,9 @@ $(document).ready(function(){
alert(result);
}
else {
+ if($('body')[0].id == 'bookmarklet') {
+ self.close();
+ }
if ($("#command_result", xml).length > 0) {
var result = document._importNode($("p", xml).get(0), true);
result = result.textContent || result.innerHTML;
@@ -258,7 +273,9 @@ $(document).ready(function(){
$("#notice_data-attach").val("");
$("#notice_in-reply-to").val("");
$('#notice_data-attach_selected').remove();
- counter();
+ if (maxLength > 0) {
+ counter();
+ }
}
$("#form_notice").removeClass("processing");
$("#notice_action-submit").removeAttr("disabled");
diff --git a/lib/Shorturl_api.php b/lib/Shorturl_api.php
index 6402dbc09..18ae7719b 100644
--- a/lib/Shorturl_api.php
+++ b/lib/Shorturl_api.php
@@ -19,7 +19,7 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-class ShortUrlApi
+abstract class ShortUrlApi
{
protected $service_url;
protected $long_limit = 27;
@@ -35,11 +35,9 @@ class ShortUrlApi
return $url;
}
- protected function shorten_imp($url) {
- return "To Override";
- }
+ protected abstract function shorten_imp($url);
- private function is_long($url) {
+ protected function is_long($url) {
return strlen($url) >= common_config('site', 'shorturllength');
}
@@ -71,61 +69,3 @@ class ShortUrlApi
}
}
-class LilUrl extends ShortUrlApi
-{
- function __construct()
- {
- parent::__construct('http://ur1.ca/');
- }
-
- protected function shorten_imp($url) {
- $data['longurl'] = $url;
- $response = $this->http_post($data);
- if (!$response) return $url;
- $y = @simplexml_load_string($response);
- if (!isset($y->body)) return $url;
- $x = $y->body->p[0]->a->attributes();
- if (isset($x['href'])) return $x['href'];
- return $url;
- }
-}
-
-
-class PtitUrl extends ShortUrlApi
-{
- function __construct()
- {
- parent::__construct('http://ptiturl.com/?creer=oui&action=Reduire&url=');
- }
-
- protected function shorten_imp($url) {
- $response = $this->http_get($url);
- if (!$response) return $url;
- $response = $this->tidy($response);
- $y = @simplexml_load_string($response);
- if (!isset($y->body)) return $url;
- $xml = $y->body->center->table->tr->td->pre->a->attributes();
- if (isset($xml['href'])) return $xml['href'];
- return $url;
- }
-}
-
-class TightUrl extends ShortUrlApi
-{
- function __construct()
- {
- parent::__construct('http://2tu.us/?save=y&url=');
- }
-
- protected function shorten_imp($url) {
- $response = $this->http_get($url);
- if (!$response) return $url;
- $response = $this->tidy($response);
- $y = @simplexml_load_string($response);
- if (!isset($y->body)) return $url;
- $xml = $y->body->p[0]->code[0]->a->attributes();
- if (isset($xml['href'])) return $xml['href'];
- return $url;
- }
-}
-
diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php
index 798116163..a004a3ed9 100644
--- a/lib/accountsettingsaction.php
+++ b/lib/accountsettingsaction.php
@@ -98,42 +98,39 @@ class AccountSettingsNav extends Widget
function show()
{
- # action => array('prompt', 'title')
- $menu =
- array('profilesettings' =>
- array(_('Profile'),
- _('Change your profile settings')),
- 'avatarsettings' =>
- array(_('Avatar'),
- _('Upload an avatar')),
- 'passwordsettings' =>
- array(_('Password'),
- _('Change your password')),
- 'emailsettings' =>
- array(_('Email'),
- _('Change email handling')),
- 'openidsettings' =>
- array(_('OpenID'),
- _('Add or remove OpenIDs')),
- 'userdesignsettings' =>
- array(_('Design'),
- _('Design your profile')),
- 'othersettings' =>
- array(_('Other'),
- _('Other options')));
-
$action_name = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav'));
- foreach ($menu as $menuaction => $menudesc) {
- if ($menuaction == 'openidsettings' &&
- !common_config('openid', 'enabled')) {
- continue;
+ if (Event::handle('StartAccountSettingsNav', array(&$this->action))) {
+
+ $menu =
+ array('profilesettings' =>
+ array(_('Profile'),
+ _('Change your profile settings')),
+ 'avatarsettings' =>
+ array(_('Avatar'),
+ _('Upload an avatar')),
+ 'passwordsettings' =>
+ array(_('Password'),
+ _('Change your password')),
+ 'emailsettings' =>
+ array(_('Email'),
+ _('Change email handling')),
+ 'userdesignsettings' =>
+ array(_('Design'),
+ _('Design your profile')),
+ 'othersettings' =>
+ array(_('Other'),
+ _('Other options')));
+
+ foreach ($menu as $menuaction => $menudesc) {
+ $this->action->menuItem(common_local_url($menuaction),
+ $menudesc[0],
+ $menudesc[1],
+ $action_name === $menuaction);
}
- $this->action->menuItem(common_local_url($menuaction),
- $menudesc[0],
- $menudesc[1],
- $action_name === $menuaction);
+
+ Event::handle('EndAccountSettingsNav', array(&$this->action));
}
$this->action->elementEnd('ul');
diff --git a/lib/action.php b/lib/action.php
index 670eb498c..1b2f73752 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -120,14 +120,16 @@ class Action extends HTMLOutputter // lawsuit
{
// XXX: attributes (profile?)
$this->elementStart('head');
- $this->showTitle();
- $this->showShortcutIcon();
- $this->showStylesheets();
- $this->showScripts();
- $this->showOpenSearch();
- $this->showFeeds();
- $this->showDescription();
- $this->extraHead();
+ if (Event::handle('StartShowHeadElements', array($this))) {
+ $this->showTitle();
+ $this->showShortcutIcon();
+ $this->showStylesheets();
+ $this->showOpenSearch();
+ $this->showFeeds();
+ $this->showDescription();
+ $this->extraHead();
+ Event::handle('EndShowHeadElements', array($this));
+ }
$this->elementEnd('head');
}
@@ -352,6 +354,7 @@ class Action extends HTMLOutputter // lawsuit
Event::handle('EndShowFooter', array($this));
}
$this->elementEnd('div');
+ $this->showScripts();
$this->elementEnd('body');
}
@@ -442,17 +445,12 @@ class Action extends HTMLOutputter // lawsuit
_('Logout'), _('Logout from the site'), false, 'nav_logout');
}
else {
- if (!common_config('site', 'openidonly')) {
- if (!common_config('site', 'closed')) {
- $this->menuItem(common_local_url('register'),
- _('Register'), _('Create an account'), false, 'nav_register');
- }
- $this->menuItem(common_local_url('login'),
- _('Login'), _('Login to the site'), false, 'nav_login');
- } else {
- $this->menuItem(common_local_url('openidlogin'),
- _('OpenID'), _('Login with OpenID'), false, 'nav_openid');
+ if (!common_config('site', 'closed')) {
+ $this->menuItem(common_local_url('register'),
+ _('Register'), _('Create an account'), false, 'nav_register');
}
+ $this->menuItem(common_local_url('login'),
+ _('Login'), _('Login to the site'), false, 'nav_login');
}
$this->menuItem(common_local_url('doc', array('title' => 'help')),
_('Help'), _('Help me!'), false, 'nav_help');
@@ -530,7 +528,10 @@ class Action extends HTMLOutputter // lawsuit
$this->showContentBlock();
Event::handle('EndShowContentBlock', array($this));
}
- $this->showAside();
+ if (Event::handle('StartShowAside', array($this))) {
+ $this->showAside();
+ Event::handle('EndShowAside', array($this));
+ }
$this->elementEnd('div');
}
diff --git a/lib/twitterapi.php b/lib/api.php
index 3bac400e2..9bd2083de 100644
--- a/lib/twitterapi.php
+++ b/lib/api.php
@@ -1,9 +1,12 @@
<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, StatusNet, Inc.
+/**
+ * StatusNet, the distributed open-source microblogging tool
*
- * This program is free software: you can redistribute it and/or modify
+ * Base API action
+ *
+ * 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.
@@ -15,17 +18,49 @@
*
* 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Toby Inkster <mail@tobyinkster.co.uk>
+ * @author Zach Copley <zach@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') && !defined('LACONICA')) {
+if (!defined('STATUSNET')) {
exit(1);
}
-class TwitterapiAction extends Action
-{
-
- var $auth_user;
+/**
+ * Contains most of the Twitter-compatible API output functions.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author Toby Inkster <mail@tobyinkster.co.uk>
+ * @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/
+ */
+class ApiAction extends Action
+{
+ var $format = null;
+ var $user = null;
+ var $page = null;
+ var $count = null;
+ var $max_id = null;
+ var $since_id = null;
+ var $since = null;
+
/**
* Initialization.
*
@@ -37,6 +72,14 @@ class TwitterapiAction extends Action
function prepare($args)
{
parent::prepare($args);
+
+ $this->format = $this->arg('format');
+ $this->page = (int)$this->arg('page', 1);
+ $this->count = (int)$this->arg('count', 20);
+ $this->max_id = (int)$this->arg('max_id', 0);
+ $this->since_id = (int)$this->arg('since_id', 0);
+ $this->since = $this->arg('since');
+
return true;
}
@@ -73,7 +116,7 @@ class TwitterapiAction extends Action
return parent::element($tag, $attrs, $content);
}
- function twitter_user_array($profile, $get_notice=false)
+ function twitterUserArray($profile, $get_notice=false)
{
$twitter_user = array();
@@ -91,21 +134,27 @@ class TwitterapiAction extends Action
$twitter_user['protected'] = false; # not supported by StatusNet yet
$twitter_user['followers_count'] = $profile->subscriberCount();
- // To be supported soon...
- $twitter_user['profile_background_color'] = '';
- $twitter_user['profile_text_color'] = '';
- $twitter_user['profile_link_color'] = '';
- $twitter_user['profile_sidebar_fill_color'] = '';
+ // Need to pull up the user for some of this
+ $user = $profile->getUser();
+ $design = $user->getDesign();
+ $defaultDesign = Design::siteDesign();
+ if (!$design) $design = $defaultDesign;
+ $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);
+ $twitter_user['profile_text_color'] = ($color == null) ? '' : '#'.$color->hexValue();
+ $color = Design::toWebColor(empty($design->linkcolor) ? $defaultDesign->linkcolor : $design->linkcolor);
+ $twitter_user['profile_link_color'] = ($color == null) ? '' : '#'.$color->hexValue();
+ $color = Design::toWebColor(empty($design->sidebarcolor) ? $defaultDesign->sidebarcolor : $design->sidebarcolor);
+ $twitter_user['profile_sidebar_fill_color'] = ($color == null) ? '' : '#'.$color->hexValue();
$twitter_user['profile_sidebar_border_color'] = '';
$twitter_user['friends_count'] = $profile->subscriptionCount();
- $twitter_user['created_at'] = $this->date_twitter($profile->created);
+ $twitter_user['created_at'] = $this->dateTwitter($profile->created);
$twitter_user['favourites_count'] = $profile->faveCount(); // British spelling!
- // Need to pull up the user for some of this
- $user = User::staticGet($profile->id);
$timezone = 'UTC';
@@ -146,24 +195,24 @@ class TwitterapiAction extends Action
$notice = $profile->getCurrentNotice();
if ($notice) {
# don't get user!
- $twitter_user['status'] = $this->twitter_status_array($notice, false);
+ $twitter_user['status'] = $this->twitterStatusArray($notice, false);
}
}
return $twitter_user;
}
- function twitter_status_array($notice, $include_user=true)
+ function twitterStatusArray($notice, $include_user=true)
{
$profile = $notice->getProfile();
$twitter_status = array();
$twitter_status['text'] = $notice->content;
$twitter_status['truncated'] = false; # Not possible on StatusNet
- $twitter_status['created_at'] = $this->date_twitter($notice->created);
+ $twitter_status['created_at'] = $this->dateTwitter($notice->created);
$twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
intval($notice->reply_to) : null;
- $twitter_status['source'] = $this->source_link($notice->source);
+ $twitter_status['source'] = $this->sourceLink($notice->source);
$twitter_status['id'] = intval($notice->id);
$replier_profile = null;
@@ -206,14 +255,14 @@ class TwitterapiAction extends Action
if ($include_user) {
# Don't get notice (recursive!)
- $twitter_user = $this->twitter_user_array($profile, false);
+ $twitter_user = $this->twitterUserArray($profile, false);
$twitter_status['user'] = $twitter_user;
}
return $twitter_status;
}
- function twitter_group_array($group)
+ function twitterGroupArray($group)
{
$twitter_group=array();
$twitter_group['id']=$group->id;
@@ -228,12 +277,12 @@ class TwitterapiAction extends Action
$twitter_group['homepage']=$group->homepage;
$twitter_group['description']=$group->description;
$twitter_group['location']=$group->location;
- $twitter_group['created']=$this->date_twitter($group->created);
- $twitter_group['modified']=$this->date_twitter($group->modified);
+ $twitter_group['created']=$this->dateTwitter($group->created);
+ $twitter_group['modified']=$this->dateTwitter($group->modified);
return $twitter_group;
}
- function twitter_rss_group_array($group)
+ function twitterRssGroupArray($group)
{
$entry = array();
$entry['content']=$group->description;
@@ -251,7 +300,7 @@ class TwitterapiAction extends Action
return $entry;
}
- function twitter_rss_entry_array($notice)
+ function twitterRssEntryArray($notice)
{
$profile = $notice->getProfile();
$entry = array();
@@ -274,11 +323,12 @@ class TwitterapiAction extends Action
$enclosures = array();
foreach ($attachments as $attachment) {
- if ($attachment->isEnclosure()) {
+ $enclosure_o=$attachment->getEnclosure();
+ if ($enclosure_o) {
$enclosure = array();
- $enclosure['url'] = $attachment->url;
- $enclosure['mimetype'] = $attachment->mimetype;
- $enclosure['size'] = $attachment->size;
+ $enclosure['url'] = $enclosure_o->url;
+ $enclosure['mimetype'] = $enclosure_o->mimetype;
+ $enclosure['size'] = $enclosure_o->size;
$enclosures[] = $enclosure;
}
}
@@ -287,23 +337,6 @@ class TwitterapiAction extends Action
$entry['enclosures'] = $enclosures;
}
-/*
- // Enclosure
- $attachments = $notice->attachments();
- if($attachments){
- $entry['enclosures']=array();
- foreach($attachments as $attachment){
- if ($attachment->isEnclosure()) {
- $enclosure=array();
- $enclosure['url']=$attachment->url;
- $enclosure['mimetype']=$attachment->mimetype;
- $enclosure['size']=$attachment->size;
- $entry['enclosures'][]=$enclosure;
- }
- }
- }
-*/
-
// Tags/Categories
$tag = new Notice_tag();
$tag->notice_id = $notice->id;
@@ -323,65 +356,20 @@ class TwitterapiAction extends Action
return $entry;
}
- function twitter_rss_dmsg_array($message)
- {
- $entry = array();
-
- $entry['title'] = sprintf('Message from %s to %s',
- $message->getFrom()->nickname, $message->getTo()->nickname);
-
- $entry['content'] = common_xml_safe_str(trim($message->content));
- $entry['link'] = common_local_url('showmessage', array('message' => $message->id));
- $entry['published'] = common_date_iso8601($message->created);
-
- $taguribase = common_config('integration', 'taguri');
-
- $entry['id'] = "tag:$taguribase,:$entry[link]";
- $entry['updated'] = $entry['published'];
- $entry['author'] = $message->getFrom()->getBestName();
-
- # RSS Item specific
- $entry['description'] = $entry['content'];
- $entry['pubDate'] = common_date_rfc2822($message->created);
- $entry['guid'] = $entry['link'];
-
- return $entry;
- }
-
- function twitter_dmsg_array($message)
- {
- $twitter_dm = array();
-
- $from_profile = $message->getFrom();
- $to_profile = $message->getTo();
-
- $twitter_dm['id'] = $message->id;
- $twitter_dm['sender_id'] = $message->from_profile;
- $twitter_dm['text'] = trim($message->content);
- $twitter_dm['recipient_id'] = $message->to_profile;
- $twitter_dm['created_at'] = $this->date_twitter($message->created);
- $twitter_dm['sender_screen_name'] = $from_profile->nickname;
- $twitter_dm['recipient_screen_name'] = $to_profile->nickname;
- $twitter_dm['sender'] = $this->twitter_user_array($from_profile, false);
- $twitter_dm['recipient'] = $this->twitter_user_array($to_profile, false);
-
- return $twitter_dm;
- }
-
- function twitter_relationship_array($source, $target)
+ function twitterRelationshipArray($source, $target)
{
$relationship = array();
$relationship['source'] =
- $this->relationship_details_array($source, $target);
+ $this->relationshipDetailsArray($source, $target);
$relationship['target'] =
- $this->relationship_details_array($target, $source);
+ $this->relationshipDetailsArray($target, $source);
return array('relationship' => $relationship);
}
- function relationship_details_array($source, $target)
+ function relationshipDetailsArray($source, $target)
{
$details = array();
@@ -408,14 +396,14 @@ class TwitterapiAction extends Action
return $details;
}
- function show_twitter_xml_relationship($relationship)
+ function showTwitterXmlRelationship($relationship)
{
$this->elementStart('relationship');
foreach($relationship as $element => $value) {
if ($element == 'source' || $element == 'target') {
$this->elementStart($element);
- $this->show_xml_relationship_details($value);
+ $this->showXmlRelationshipDetails($value);
$this->elementEnd($element);
}
}
@@ -423,26 +411,26 @@ class TwitterapiAction extends Action
$this->elementEnd('relationship');
}
- function show_xml_relationship_details($details)
+ function showXmlRelationshipDetails($details)
{
foreach($details as $element => $value) {
$this->element($element, null, $value);
}
}
- function show_twitter_xml_status($twitter_status)
+ function showTwitterXmlStatus($twitter_status)
{
$this->elementStart('status');
foreach($twitter_status as $element => $value) {
switch ($element) {
case 'user':
- $this->show_twitter_xml_user($twitter_status['user']);
+ $this->showTwitterXmlUser($twitter_status['user']);
break;
case 'text':
$this->element($element, null, common_xml_safe_str($value));
break;
case 'attachments':
- $this->show_xml_attachments($twitter_status['attachments']);
+ $this->showXmlAttachments($twitter_status['attachments']);
break;
default:
$this->element($element, null, $value);
@@ -451,7 +439,7 @@ class TwitterapiAction extends Action
$this->elementEnd('status');
}
- function show_twitter_xml_group($twitter_group)
+ function showTwitterXmlGroup($twitter_group)
{
$this->elementStart('group');
foreach($twitter_group as $element => $value) {
@@ -460,12 +448,12 @@ class TwitterapiAction extends Action
$this->elementEnd('group');
}
- function show_twitter_xml_user($twitter_user, $role='user')
+ function showTwitterXmlUser($twitter_user, $role='user')
{
$this->elementStart($role);
foreach($twitter_user as $element => $value) {
if ($element == 'status') {
- $this->show_twitter_xml_status($twitter_user['status']);
+ $this->showTwitterXmlStatus($twitter_user['status']);
} else {
$this->element($element, null, $value);
}
@@ -473,7 +461,7 @@ class TwitterapiAction extends Action
$this->elementEnd($role);
}
- function show_xml_attachments($attachments) {
+ function showXmlAttachments($attachments) {
if (!empty($attachments)) {
$this->elementStart('attachments', array('type' => 'array'));
foreach ($attachments as $attachment) {
@@ -487,7 +475,7 @@ class TwitterapiAction extends Action
}
}
- function show_twitter_rss_item($entry)
+ function showTwitterRssItem($entry)
{
$this->elementStart('item');
$this->element('title', null, $entry['title']);
@@ -511,94 +499,59 @@ class TwitterapiAction extends Action
$this->elementEnd('item');
}
- function show_json_objects($objects)
+ function showJsonObjects($objects)
{
print(json_encode($objects));
}
- function show_single_xml_status($notice)
+ function showSingleXmlStatus($notice)
{
- $this->init_document('xml');
- $twitter_status = $this->twitter_status_array($notice);
- $this->show_twitter_xml_status($twitter_status);
- $this->end_document('xml');
+ $this->initDocument('xml');
+ $twitter_status = $this->twitterStatusArray($notice);
+ $this->showTwitterXmlStatus($twitter_status);
+ $this->endDocument('xml');
}
function show_single_json_status($notice)
{
- $this->init_document('json');
- $status = $this->twitter_status_array($notice);
- $this->show_json_objects($status);
- $this->end_document('json');
- }
-
- function show_single_xml_dmsg($message)
- {
- $this->init_document('xml');
- $dmsg = $this->twitter_dmsg_array($message);
- $this->show_twitter_xml_dmsg($dmsg);
- $this->end_document('xml');
+ $this->initDocument('json');
+ $status = $this->twitterStatusArray($notice);
+ $this->showJsonObjects($status);
+ $this->endDocument('json');
}
- function show_single_json_dmsg($message)
- {
- $this->init_document('json');
- $dmsg = $this->twitter_dmsg_array($message);
- $this->show_json_objects($dmsg);
- $this->end_document('json');
- }
-
- function show_twitter_xml_dmsg($twitter_dm)
- {
- $this->elementStart('direct_message');
- foreach($twitter_dm as $element => $value) {
- switch ($element) {
- case 'sender':
- case 'recipient':
- $this->show_twitter_xml_user($value, $element);
- break;
- case 'text':
- $this->element($element, null, common_xml_safe_str($value));
- break;
- default:
- $this->element($element, null, $value);
- }
- }
- $this->elementEnd('direct_message');
- }
- function show_xml_timeline($notice)
+ function showXmlTimeline($notice)
{
- $this->init_document('xml');
+ $this->initDocument('xml');
$this->elementStart('statuses', array('type' => 'array'));
if (is_array($notice)) {
foreach ($notice as $n) {
- $twitter_status = $this->twitter_status_array($n);
- $this->show_twitter_xml_status($twitter_status);
+ $twitter_status = $this->twitterStatusArray($n);
+ $this->showTwitterXmlStatus($twitter_status);
}
} else {
while ($notice->fetch()) {
- $twitter_status = $this->twitter_status_array($notice);
- $this->show_twitter_xml_status($twitter_status);
+ $twitter_status = $this->twitterStatusArray($notice);
+ $this->showTwitterXmlStatus($twitter_status);
}
}
$this->elementEnd('statuses');
- $this->end_document('xml');
+ $this->endDocument('xml');
}
- function show_rss_timeline($notice, $title, $link, $subtitle, $suplink=null)
+ function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null)
{
- $this->init_document('rss');
+ $this->initDocument('rss');
- $this->elementStart('channel');
$this->element('title', null, $title);
$this->element('link', null, $link);
if (!is_null($suplink)) {
- # For FriendFeed's SUP protocol
+ // For FriendFeed's SUP protocol
$this->element('link', array('xmlns' => 'http://www.w3.org/2005/Atom',
'rel' => 'http://api.friendfeed.com/2008/03#sup',
'href' => $suplink,
@@ -610,24 +563,23 @@ class TwitterapiAction extends Action
if (is_array($notice)) {
foreach ($notice as $n) {
- $entry = $this->twitter_rss_entry_array($n);
- $this->show_twitter_rss_item($entry);
+ $entry = $this->twitterRssEntryArray($n);
+ $this->showTwitterRssItem($entry);
}
} else {
while ($notice->fetch()) {
- $entry = $this->twitter_rss_entry_array($notice);
- $this->show_twitter_rss_item($entry);
+ $entry = $this->twitterRssEntryArray($notice);
+ $this->showTwitterRssItem($entry);
}
}
- $this->elementEnd('channel');
- $this->end_twitter_rss();
+ $this->endTwitterRss();
}
- function show_atom_timeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null)
+ function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null)
{
- $this->init_document('atom');
+ $this->initDocument('atom');
$this->element('title', null, $title);
$this->element('id', null, $id);
@@ -658,16 +610,15 @@ class TwitterapiAction extends Action
}
}
- $this->end_document('atom');
+ $this->endDocument('atom');
}
- function show_rss_groups($group, $title, $link, $subtitle)
+ function showRssGroups($group, $title, $link, $subtitle)
{
- $this->init_document('rss');
+ $this->initDocument('rss');
- $this->elementStart('channel');
$this->element('title', null, $title);
$this->element('link', null, $link);
$this->element('description', null, $subtitle);
@@ -676,24 +627,138 @@ class TwitterapiAction extends Action
if (is_array($group)) {
foreach ($group as $g) {
- $twitter_group = $this->twitter_rss_group_array($g);
- $this->show_twitter_rss_item($twitter_group);
+ $twitter_group = $this->twitterRssGroupArray($g);
+ $this->showTwitterRssItem($twitter_group);
}
} else {
while ($group->fetch()) {
- $twitter_group = $this->twitter_rss_group_array($group);
- $this->show_twitter_rss_item($twitter_group);
+ $twitter_group = $this->twitterRssGroupArray($group);
+ $this->showTwitterRssItem($twitter_group);
}
}
- $this->elementEnd('channel');
- $this->end_twitter_rss();
+ $this->endTwitterRss();
}
- function show_atom_groups($group, $title, $id, $link, $subtitle=null, $selfuri=null)
+
+ function showTwitterAtomEntry($entry)
{
+ $this->elementStart('entry');
+ $this->element('title', null, $entry['title']);
+ $this->element('content', array('type' => 'html'), $entry['content']);
+ $this->element('id', null, $entry['id']);
+ $this->element('published', null, $entry['published']);
+ $this->element('updated', null, $entry['updated']);
+ $this->element('link', array('type' => 'text/html',
+ 'href' => $entry['link'],
+ 'rel' => 'alternate'));
+ $this->element('link', array('type' => $entry['avatar-type'],
+ 'href' => $entry['avatar'],
+ 'rel' => 'image'));
+ $this->elementStart('author');
+
+ $this->element('name', null, $entry['author-name']);
+ $this->element('uri', null, $entry['author-uri']);
+
+ $this->elementEnd('author');
+ $this->elementEnd('entry');
+ }
- $this->init_document('atom');
+ function showXmlDirectMessage($dm)
+ {
+ $this->elementStart('direct_message');
+ foreach($dm as $element => $value) {
+ switch ($element) {
+ case 'sender':
+ case 'recipient':
+ $this->showTwitterXmlUser($value, $element);
+ break;
+ case 'text':
+ $this->element($element, null, common_xml_safe_str($value));
+ break;
+ default:
+ $this->element($element, null, $value);
+ break;
+ }
+ }
+ $this->elementEnd('direct_message');
+ }
+
+ function directMessageArray($message)
+ {
+ $dmsg = array();
+
+ $from_profile = $message->getFrom();
+ $to_profile = $message->getTo();
+
+ $dmsg['id'] = $message->id;
+ $dmsg['sender_id'] = $message->from_profile;
+ $dmsg['text'] = trim($message->content);
+ $dmsg['recipient_id'] = $message->to_profile;
+ $dmsg['created_at'] = $this->dateTwitter($message->created);
+ $dmsg['sender_screen_name'] = $from_profile->nickname;
+ $dmsg['recipient_screen_name'] = $to_profile->nickname;
+ $dmsg['sender'] = $this->twitterUserArray($from_profile, false);
+ $dmsg['recipient'] = $this->twitterUserArray($to_profile, false);
+
+ return $dmsg;
+ }
+
+ function rssDirectMessageArray($message)
+ {
+ $entry = array();
+
+ $from = $message->getFrom();
+
+ $entry['title'] = sprintf('Message from %s to %s',
+ $from->nickname, $message->getTo()->nickname);
+
+ $entry['content'] = common_xml_safe_str($message->rendered);
+ $entry['link'] = common_local_url('showmessage', array('message' => $message->id));
+ $entry['published'] = common_date_iso8601($message->created);
+
+ $taguribase = common_config('integration', 'taguri');
+
+ $entry['id'] = "tag:$taguribase:$entry[link]";
+ $entry['updated'] = $entry['published'];
+
+ $entry['author-name'] = $from->getBestName();
+ $entry['author-uri'] = $from->homepage;
+
+ $avatar = $from->getAvatar(AVATAR_STREAM_SIZE);
+
+ $entry['avatar'] = (!empty($avatar)) ? $avatar->url : Avatar::defaultImage(AVATAR_STREAM_SIZE);
+ $entry['avatar-type'] = (!empty($avatar)) ? $avatar->mediatype : 'image/png';
+
+ // RSS item specific
+
+ $entry['description'] = $entry['content'];
+ $entry['pubDate'] = common_date_rfc2822($message->created);
+ $entry['guid'] = $entry['link'];
+
+ return $entry;
+ }
+
+ function showSingleXmlDirectMessage($message)
+ {
+ $this->initDocument('xml');
+ $dmsg = $this->directMessageArray($message);
+ $this->showXmlDirectMessage($dmsg);
+ $this->endDocument('xml');
+ }
+
+ function showSingleJsonDirectMessage($message)
+ {
+ $this->initDocument('json');
+ $dmsg = $this->directMessageArray($message);
+ $this->showJsonObjects($dmsg);
+ $this->endDocument('json');
+ }
+
+ function showAtomGroups($group, $title, $id, $link, $subtitle=null, $selfuri=null)
+ {
+
+ $this->initDocument('atom');
$this->element('title', null, $title);
$this->element('id', null, $id);
@@ -717,168 +782,151 @@ class TwitterapiAction extends Action
}
}
- $this->end_document('atom');
+ $this->endDocument('atom');
}
- function show_json_timeline($notice)
+ function showJsonTimeline($notice)
{
- $this->init_document('json');
+ $this->initDocument('json');
$statuses = array();
if (is_array($notice)) {
foreach ($notice as $n) {
- $twitter_status = $this->twitter_status_array($n);
+ $twitter_status = $this->twitterStatusArray($n);
array_push($statuses, $twitter_status);
}
} else {
while ($notice->fetch()) {
- $twitter_status = $this->twitter_status_array($notice);
+ $twitter_status = $this->twitterStatusArray($notice);
array_push($statuses, $twitter_status);
}
}
- $this->show_json_objects($statuses);
+ $this->showJsonObjects($statuses);
- $this->end_document('json');
+ $this->endDocument('json');
}
- function show_json_groups($group)
+ function showJsonGroups($group)
{
- $this->init_document('json');
+ $this->initDocument('json');
$groups = array();
if (is_array($group)) {
foreach ($group as $g) {
- $twitter_group = $this->twitter_group_array($g);
+ $twitter_group = $this->twitterGroupArray($g);
array_push($groups, $twitter_group);
}
} else {
while ($group->fetch()) {
- $twitter_group = $this->twitter_group_array($group);
+ $twitter_group = $this->twitterGroupArray($group);
array_push($groups, $twitter_group);
}
}
- $this->show_json_objects($groups);
+ $this->showJsonObjects($groups);
- $this->end_document('json');
+ $this->endDocument('json');
}
- function show_xml_groups($group)
+ function showXmlGroups($group)
{
- $this->init_document('xml');
+ $this->initDocument('xml');
$this->elementStart('groups', array('type' => 'array'));
if (is_array($group)) {
foreach ($group as $g) {
- $twitter_group = $this->twitter_group_array($g);
- $this->show_twitter_xml_group($twitter_group);
+ $twitter_group = $this->twitterGroupArray($g);
+ $this->showTwitterXmlGroup($twitter_group);
}
} else {
while ($group->fetch()) {
- $twitter_group = $this->twitter_group_array($group);
- $this->show_twitter_xml_group($twitter_group);
+ $twitter_group = $this->twitterGroupArray($group);
+ $this->showTwitterXmlGroup($twitter_group);
}
}
$this->elementEnd('groups');
- $this->end_document('xml');
+ $this->endDocument('xml');
}
- function show_twitter_xml_users($user)
+ function showTwitterXmlUsers($user)
{
- $this->init_document('xml');
+ $this->initDocument('xml');
$this->elementStart('users', array('type' => 'array'));
if (is_array($user)) {
- foreach ($group as $g) {
- $twitter_user = $this->twitter_user_array($g);
- $this->show_twitter_xml_user($twitter_user,'user');
+ foreach ($user as $u) {
+ $twitter_user = $this->twitterUserArray($u);
+ $this->showTwitterXmlUser($twitter_user);
}
} else {
while ($user->fetch()) {
- $twitter_user = $this->twitter_user_array($user);
- $this->show_twitter_xml_user($twitter_user);
+ $twitter_user = $this->twitterUserArray($user);
+ $this->showTwitterXmlUser($twitter_user);
}
}
$this->elementEnd('users');
- $this->end_document('xml');
+ $this->endDocument('xml');
}
- function show_json_users($user)
+ function showJsonUsers($user)
{
- $this->init_document('json');
+ $this->initDocument('json');
$users = array();
if (is_array($user)) {
foreach ($user as $u) {
- $twitter_user = $this->twitter_user_array($u);
+ $twitter_user = $this->twitterUserArray($u);
array_push($users, $twitter_user);
}
} else {
while ($user->fetch()) {
- $twitter_user = $this->twitter_user_array($user);
+ $twitter_user = $this->twitterUserArray($user);
array_push($users, $twitter_user);
}
}
- $this->show_json_objects($users);
+ $this->showJsonObjects($users);
- $this->end_document('json');
+ $this->endDocument('json');
}
- function show_single_json_group($group)
+ function showSingleJsonGroup($group)
{
- $this->init_document('json');
- $twitter_group = $this->twitter_group_array($group);
- $this->show_json_objects($twitter_group);
- $this->end_document('json');
+ $this->initDocument('json');
+ $twitter_group = $this->twitterGroupArray($group);
+ $this->showJsonObjects($twitter_group);
+ $this->endDocument('json');
}
- function show_single_xml_group($group)
+ function showSingleXmlGroup($group)
{
- $this->init_document('xml');
- $twitter_group = $this->twitter_group_array($group);
- $this->show_twitter_xml_group($twitter_group);
- $this->end_document('xml');
+ $this->initDocument('xml');
+ $twitter_group = $this->twitterGroupArray($group);
+ $this->showTwitterXmlGroup($twitter_group);
+ $this->endDocument('xml');
}
- // Anyone know what date format this is?
- // Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach
- function date_twitter($dt)
+ function dateTwitter($dt)
{
- $t = strtotime($dt);
- return date("D M d H:i:s O Y", $t);
- }
-
- // XXX: Candidate for a general utility method somewhere?
- function count_subscriptions($profile)
- {
-
- $count = 0;
- $sub = new Subscription();
- $sub->subscribed = $profile->id;
-
- $count = $sub->find();
-
- if ($count > 0) {
- return $count - 1;
- } else {
- return 0;
- }
+ $dateStr = date('d F Y H:i:s', strtotime($dt));
+ $d = new DateTime($dateStr, new DateTimeZone('UTC'));
+ $d->setTimezone(new DateTimeZone(common_timezone()));
+ return $d->format('D M d H:i:s O Y');
}
- function init_document($type='xml')
+ function initDocument($type='xml')
{
switch ($type) {
case 'xml':
@@ -896,11 +944,11 @@ class TwitterapiAction extends Action
break;
case 'rss':
header("Content-Type: application/rss+xml; charset=utf-8");
- $this->init_twitter_rss();
+ $this->initTwitterRss();
break;
case 'atom':
header('Content-Type: application/atom+xml; charset=utf-8');
- $this->init_twitter_atom();
+ $this->initTwitterAtom();
break;
default:
$this->clientError(_('Not a supported data format.'));
@@ -910,7 +958,7 @@ class TwitterapiAction extends Action
return;
}
- function end_document($type='xml')
+ function endDocument($type='xml')
{
switch ($type) {
case 'xml':
@@ -925,10 +973,10 @@ class TwitterapiAction extends Action
}
break;
case 'rss':
- $this->end_twitter_rss();
+ $this->endTwitterRss();
break;
case 'atom':
- $this->end_twitter_rss();
+ $this->endTwitterRss();
break;
default:
$this->clientError(_('Not a supported data format.'));
@@ -937,7 +985,7 @@ class TwitterapiAction extends Action
return;
}
- function clientError($msg, $code = 400, $content_type = 'json')
+ function clientError($msg, $code = 400, $format = 'xml')
{
$action = $this->trimmed('action');
@@ -951,20 +999,23 @@ class TwitterapiAction extends Action
header('HTTP/1.1 '.$code.' '.$status_string);
- if ($content_type == 'xml') {
- $this->init_document('xml');
+ if ($format == 'xml') {
+ $this->initDocument('xml');
$this->elementStart('hash');
$this->element('error', null, $msg);
$this->element('request', null, $_SERVER['REQUEST_URI']);
$this->elementEnd('hash');
- $this->end_document('xml');
- } else {
- $this->init_document('json');
+ $this->endDocument('xml');
+ } elseif ($format == 'json'){
+ $this->initDocument('json');
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
print(json_encode($error_array));
- $this->end_document('json');
- }
+ $this->endDocument('json');
+ } else {
+ // If user didn't request a useful format, throw a regular client error
+ throw new ClientException($msg, $code);
+ }
}
function serverError($msg, $code = 500, $content_type = 'json')
@@ -982,56 +1033,60 @@ class TwitterapiAction extends Action
header('HTTP/1.1 '.$code.' '.$status_string);
if ($content_type == 'xml') {
- $this->init_document('xml');
+ $this->initDocument('xml');
$this->elementStart('hash');
$this->element('error', null, $msg);
$this->element('request', null, $_SERVER['REQUEST_URI']);
$this->elementEnd('hash');
- $this->end_document('xml');
+ $this->endDocument('xml');
} else {
- $this->init_document('json');
+ $this->initDocument('json');
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
print(json_encode($error_array));
- $this->end_document('json');
+ $this->endDocument('json');
}
}
- function init_twitter_rss()
+ function initTwitterRss()
{
$this->startXML();
- $this->elementStart('rss', array('version' => '2.0'));
+ $this->elementStart('rss', array('version' => '2.0', 'xmlns:atom'=>'http://www.w3.org/2005/Atom'));
+ $this->elementStart('channel');
+ Event::handle('StartApiRss', array($this));
}
- function end_twitter_rss()
+ function endTwitterRss()
{
+ $this->elementEnd('channel');
$this->elementEnd('rss');
$this->endXML();
}
- function init_twitter_atom()
+ function initTwitterAtom()
{
$this->startXML();
// FIXME: don't hardcode the language here!
$this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom',
'xml:lang' => 'en-US',
'xmlns:thr' => 'http://purl.org/syndication/thread/1.0'));
+ Event::handle('StartApiAtom', array($this));
}
- function end_twitter_atom()
+ function endTwitterAtom()
{
$this->elementEnd('feed');
$this->endXML();
}
- function show_profile($profile, $content_type='xml', $notice=null, $includeStatuses=true)
+ function showProfile($profile, $content_type='xml', $notice=null, $includeStatuses=true)
{
- $profile_array = $this->twitter_user_array($profile, $includeStatuses);
+ $profile_array = $this->twitterUserArray($profile, $includeStatuses);
switch ($content_type) {
case 'xml':
- $this->show_twitter_xml_user($profile_array);
+ $this->showTwitterXmlUser($profile_array);
break;
case 'json':
- $this->show_json_objects($profile_array);
+ $this->showJsonObjects($profile_array);
break;
default:
$this->clientError(_('Not a supported data format.'));
@@ -1040,7 +1095,7 @@ class TwitterapiAction extends Action
return;
}
- function get_user($id, $apidata=null)
+ function getTargetUser($id)
{
if (empty($id)) {
@@ -1061,7 +1116,7 @@ class TwitterapiAction extends Action
return User::staticGet('nickname', $nickname);
} else {
// Fall back to trying the currently authenticated user
- return $apidata['user'];
+ return $this->auth_user;
}
} else if (is_numeric($id)) {
@@ -1072,10 +1127,9 @@ class TwitterapiAction extends Action
}
}
- function get_group($id, $apidata=null)
+ function getTargetGroup($id)
{
if (empty($id)) {
-
if (is_numeric($this->arg('id'))) {
return User_group::staticGet($this->arg('id'));
} else if ($this->arg('id')) {
@@ -1100,21 +1154,7 @@ class TwitterapiAction extends Action
}
}
- function get_profile($id)
- {
- if (is_numeric($id)) {
- return Profile::staticGet($id);
- } else {
- $user = User::staticGet('nickname', $id);
- if ($user) {
- return $user->getProfile();
- } else {
- return null;
- }
- }
- }
-
- function source_link($source)
+ function sourceLink($source)
{
$source_name = _($source);
switch ($source) {
diff --git a/lib/apiauth.php b/lib/apiauth.php
new file mode 100644
index 000000000..2f2e44a26
--- /dev/null
+++ b/lib/apiauth.php
@@ -0,0 +1,203 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Base class for API actions that require authentication
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Brenda Wallace <shiny@cpan.org>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author mEDI <medi@milaro.net>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR . '/lib/api.php';
+
+/**
+ * Actions extending this class will require auth
+ *
+ * @category API
+ * @package StatusNet
+ * @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/
+ */
+
+class ApiAuthAction extends ApiAction
+{
+
+ var $auth_user = null;
+
+ /**
+ * Take arguments for running, and output basic auth header if needed
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ if ($this->requiresAuth()) {
+ $this->checkBasicAuthUser();
+ }
+
+ return true;
+ }
+
+ /**
+ * Does this API resource require authentication?
+ *
+ * @return boolean true
+ */
+
+ function requiresAuth()
+ {
+ return true;
+ }
+
+ /**
+ * Check for a user specified via HTTP basic auth. If there isn't
+ * one, try to get one by outputting the basic auth header.
+ *
+ * @return boolean true or false
+ */
+
+ function checkBasicAuthUser()
+ {
+ $this->basicAuthProcessHeader();
+
+ $realm = common_config('site', 'name') . ' API';
+
+ if (!isset($this->auth_user)) {
+ header('WWW-Authenticate: Basic realm="' . $realm . '"');
+
+ // show error if the user clicks 'cancel'
+
+ $this->showBasicAuthError();
+ exit;
+
+ } else {
+ $nickname = $this->auth_user;
+ $password = $this->auth_pw;
+ $this->auth_user = common_check_user($nickname, $password);
+
+ if (empty($this->auth_user)) {
+
+ // basic authentication failed
+
+ list($proxy, $ip) = common_client_ip();
+ common_log(
+ LOG_WARNING,
+ 'Failed API auth attempt, nickname = ' .
+ "$nickname, proxy = $proxy, ip = $ip."
+ );
+ $this->showBasicAuthError();
+ exit;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Read the HTTP headers and set the auth user. Decodes HTTP_AUTHORIZATION
+ * param to support basic auth when PHP is running in CGI mode.
+ *
+ * @return void
+ */
+
+ function basicAuthProcessHeader()
+ {
+ if (isset($_SERVER['AUTHORIZATION'])
+ || isset($_SERVER['HTTP_AUTHORIZATION'])
+ ) {
+ $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])
+ ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['AUTHORIZATION'];
+ }
+
+ if (isset($_SERVER['PHP_AUTH_USER'])) {
+ $this->auth_user = $_SERVER['PHP_AUTH_USER'];
+ $this->auth_pw = $_SERVER['PHP_AUTH_PW'];
+ } elseif (isset($authorization_header)
+ && strstr(substr($authorization_header, 0, 5), 'Basic')) {
+
+ // decode the HTTP_AUTHORIZATION header on php-cgi server self
+ // on fcgid server the header name is AUTHORIZATION
+
+ $auth_hash = base64_decode(substr($authorization_header, 6));
+ list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash);
+
+ // set all to null on a empty basic auth request
+
+ if ($this->auth_user == "") {
+ $this->auth_user = null;
+ $this->auth_pw = null;
+ }
+ } else {
+ $this->auth_user = null;
+ $this->auth_pw = null;
+ }
+ }
+
+ /**
+ * Output an authentication error message. Use XML or JSON if one
+ * of those formats is specified, otherwise output plain text
+ *
+ * @return void
+ */
+
+ function showBasicAuthError()
+ {
+ header('HTTP/1.1 401 Unauthorized');
+ $msg = 'Could not authenticate you.';
+
+ if ($this->format == 'xml') {
+ header('Content-Type: application/xml; charset=utf-8');
+ $this->startXML();
+ $this->elementStart('hash');
+ $this->element('error', null, $msg);
+ $this->element('request', null, $_SERVER['REQUEST_URI']);
+ $this->elementEnd('hash');
+ $this->endXML();
+ } elseif ($this->format == 'json') {
+ header('Content-Type: application/json; charset=utf-8');
+ $error_array = array('error' => $msg,
+ 'request' => $_SERVER['REQUEST_URI']);
+ print(json_encode($error_array));
+ } else {
+ header('Content-type: text/plain');
+ print "$msg\n";
+ }
+ }
+
+}
diff --git a/lib/apibareauth.php b/lib/apibareauth.php
new file mode 100644
index 000000000..2d29c1ddd
--- /dev/null
+++ b/lib/apibareauth.php
@@ -0,0 +1,109 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Base class for API actions that require "bare auth". Bare auth means
+ * authentication is required only if the action is called without an argument
+ * or query param specifying user id.
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Brenda Wallace <shiny@cpan.org>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author mEDI <medi@milaro.net>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Zach Copley <zach@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);
+}
+
+require_once INSTALLDIR.'/lib/apiauth.php';
+
+/**
+ * Actions extending this class will require auth unless a target
+ * user ID has been specified
+ *
+ * @category API
+ * @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Brenda Wallace <shiny@cpan.org>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author mEDI <medi@milaro.net>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @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/
+ */
+
+class ApiBareAuthAction extends ApiAuthAction
+{
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ return true;
+ }
+
+ /**
+ * Does this API resource require authentication?
+ *
+ * @return boolean true or false
+ */
+
+ function requiresAuth()
+ {
+ // If the site is "private", all API methods except statusnet/config
+ // need authentication
+
+ if (common_config('site', 'private')) {
+ return true;
+ }
+
+ // check whether a user has been specified somehow
+
+ $id = $this->arg('id');
+ $user_id = $this->arg('user_id');
+ $screen_name = $this->arg('screen_name');
+
+ if (empty($id) && empty($user_id) && empty($screen_name)) {
+ return true;
+ }
+
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/lib/command.php b/lib/command.php
index 01b14f83e..9efa40696 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -73,7 +73,7 @@ class UntrackCommand extends UnimplementedCommand
}
}
-class NudgeCommand extends UnimplementedCommand
+class NudgeCommand extends Command
{
var $other = null;
function __construct($user, $other)
@@ -81,6 +81,26 @@ class NudgeCommand extends UnimplementedCommand
parent::__construct($user);
$this->other = $other;
}
+ function execute($channel)
+ {
+ $recipient = User::staticGet('nickname', $this->other);
+ if(! $recipient){
+ $channel->error($this->user, sprintf(_('Could not find a user with nickname %s'),
+ $this->other));
+ }else{
+ if ($recipient->id == $this->user->id) {
+ $channel->error($this->user, _('It does not make a lot of sense to nudge yourself!'));
+ }else{
+ if ($recipient->email && $recipient->emailnotifynudge) {
+ mail_notify_nudge($this->user, $recipient);
+ }
+ // XXX: notify by IM
+ // XXX: notify by SMS
+ $channel->output($this->user, sprintf(_('Nudge sent to %s'),
+ $recipient->nickname));
+ }
+ }
+ }
}
class InviteCommand extends UnimplementedCommand
@@ -124,18 +144,30 @@ class FavCommand extends Command
function execute($channel)
{
+ if(substr($this->other,0,1)=='#'){
+ //favoriting a specific notice_id
- $recipient =
- common_relative_profile($this->user, common_canonical_nickname($this->other));
+ $notice = Notice::staticGet(substr($this->other,1));
+ if (!$notice) {
+ $channel->error($this->user, _('Notice with that id does not exist'));
+ return;
+ }
+ $recipient = $notice->getProfile();
+ }else{
+ //favoriting a given user's last notice
- if (!$recipient) {
- $channel->error($this->user, _('No such user.'));
- return;
- }
- $notice = $recipient->getCurrentNotice();
- if (!$notice) {
- $channel->error($this->user, _('User has no last notice'));
- return;
+ $recipient =
+ common_relative_profile($this->user, common_canonical_nickname($this->other));
+
+ if (!$recipient) {
+ $channel->error($this->user, _('No such user.'));
+ return;
+ }
+ $notice = $recipient->getCurrentNotice();
+ if (!$notice) {
+ $channel->error($this->user, _('User has no last notice'));
+ return;
+ }
}
$fave = Fave::addNew($this->user, $notice);
@@ -312,16 +344,20 @@ class MessageCommand extends Command
function execute($channel)
{
$other = User::staticGet('nickname', common_canonical_nickname($this->other));
+
$len = mb_strlen($this->text);
+
if ($len == 0) {
$channel->error($this->user, _('No content!'));
return;
- } else if ($len > 140) {
- $content = common_shorten_links($content);
- if (mb_strlen($content) > 140) {
- $channel->error($this->user, sprintf(_('Message too long - maximum is 140 characters, you sent %d'), $len));
- return;
- }
+ }
+
+ $this->text = common_shorten_links($this->text);
+
+ if (Message::contentTooLong($this->text)) {
+ $channel->error($this->user, sprintf(_('Message too long - maximum is %d characters, you sent %d'),
+ Message::maxContent(), mb_strlen($this->text)));
+ return;
}
if (!$other) {
@@ -343,6 +379,71 @@ class MessageCommand extends Command
}
}
+class ReplyCommand extends Command
+{
+ var $other = null;
+ var $text = null;
+ function __construct($user, $other, $text)
+ {
+ parent::__construct($user);
+ $this->other = $other;
+ $this->text = $text;
+ }
+
+ function execute($channel)
+ {
+ if(substr($this->other,0,1)=='#'){
+ //replying to a specific notice_id
+
+ $notice = Notice::staticGet(substr($this->other,1));
+ if (!$notice) {
+ $channel->error($this->user, _('Notice with that id does not exist'));
+ return;
+ }
+ $recipient = $notice->getProfile();
+ }else{
+ //replying to a given user's last notice
+
+ $recipient =
+ common_relative_profile($this->user, common_canonical_nickname($this->other));
+
+ if (!$recipient) {
+ $channel->error($this->user, _('No such user.'));
+ return;
+ }
+ $notice = $recipient->getCurrentNotice();
+ if (!$notice) {
+ $channel->error($this->user, _('User has no last notice'));
+ return;
+ }
+ }
+
+ $len = mb_strlen($this->text);
+
+ if ($len == 0) {
+ $channel->error($this->user, _('No content!'));
+ return;
+ }
+
+ $this->text = common_shorten_links($this->text);
+
+ if (Notice::contentTooLong($this->text)) {
+ $channel->error($this->user, sprintf(_('Notice too long - maximum is %d characters, you sent %d'),
+ Notice::maxContent(), mb_strlen($this->text)));
+ return;
+ }
+
+ $notice = Notice::saveNew($this->user->id, $this->text, $channel->source(), 1,
+ $notice->id);
+ if ($notice) {
+ $channel->output($this->user, sprintf(_('Reply to %s sent'), $recipient->nickname));
+ } else {
+ $channel->error($this->user, _('Error saving notice.'));
+ }
+ common_broadcast_notice($notice);
+ }
+}
+
class GetCommand extends Command
{
@@ -493,6 +594,9 @@ class HelpCommand extends Command
"get <nickname> - get last notice from user\n".
"whois <nickname> - get profile info on user\n".
"fav <nickname> - add user's last notice as a 'fave'\n".
+ "fav #<notice_id> - add notice with the given id as a 'fave'\n".
+ "reply #<notice_id> - reply to notice with a given id\n".
+ "reply <nickname> - reply to the last notice from user\n".
"join <group> - join group\n".
"drop <group> - leave group\n".
"stats - get your stats\n".
@@ -503,7 +607,7 @@ class HelpCommand extends Command
"last <nickname> - same as 'get'\n".
"on <nickname> - not yet implemented.\n".
"off <nickname> - not yet implemented.\n".
- "nudge <nickname> - not yet implemented.\n".
+ "nudge <nickname> - remind a user to update.\n".
"invite <phone number> - not yet implemented.\n".
"track <word> - not yet implemented.\n".
"untrack <word> - not yet implemented.\n".
diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php
index 6e4340e5d..b921a17cc 100644
--- a/lib/commandinterpreter.php
+++ b/lib/commandinterpreter.php
@@ -28,7 +28,7 @@ class CommandInterpreter
# XXX: localise
$text = preg_replace('/\s+/', ' ', trim($text));
- list($cmd, $arg) = explode(' ', $text, 2);
+ list($cmd, $arg) = $this->split_arg($text);
# We try to support all the same commands as Twitter, see
# http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
@@ -43,7 +43,7 @@ class CommandInterpreter
return new HelpCommand($user);
case 'on':
if ($arg) {
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -54,7 +54,7 @@ class CommandInterpreter
}
case 'off':
if ($arg) {
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -74,7 +74,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -84,7 +84,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -95,7 +95,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -106,7 +106,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -117,7 +117,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -128,17 +128,28 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if (!$extra) {
return null;
} else {
return new MessageCommand($user, $other, $extra);
}
+ case 'r':
+ case 'reply':
+ if (!$arg) {
+ return null;
+ }
+ list($other, $extra) = $this->split_arg($arg);
+ if (!$extra) {
+ return null;
+ } else {
+ return new ReplyCommand($user, $other, $extra);
+ }
case 'whois':
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -148,7 +159,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -158,7 +169,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -173,7 +184,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -183,7 +194,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($word, $extra) = explode(' ', $arg, 2);
+ list($word, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else if ($word == 'off') {
@@ -195,7 +206,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($word, $extra) = explode(' ', $arg, 2);
+ list($word, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else if ($word == 'all') {
@@ -213,5 +224,17 @@ class CommandInterpreter
return false;
}
}
+
+ /**
+ * Split arguments without triggering a PHP notice warning
+ */
+ function split_arg($text)
+ {
+ $pieces = explode(' ', $text, 2);
+ if (count($pieces) == 1) {
+ $pieces[] = null;
+ }
+ return $pieces;
+ }
}
diff --git a/lib/common.php b/lib/common.php
index 016b04481..e29456ed4 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -19,10 +19,10 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-define('STATUSNET_VERSION', '0.8.2rc2');
+define('STATUSNET_VERSION', '0.9.0dev');
define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility
-define('STATUSNET_CODENAME', 'Life and How to Live It');
+define('STATUSNET_CODENAME', 'Stand');
define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48);
@@ -53,6 +53,7 @@ require_once('DB/DataObject/Cast.php'); # for dates
if (!function_exists('gettext')) {
require_once("php-gettext/gettext.inc");
}
+
require_once(INSTALLDIR.'/lib/language.php');
// This gets included before the config file, so that admin code and plugins
@@ -93,206 +94,17 @@ if (isset($path)) {
null;
}
-// default configuration, overwritten in config.php
+require_once(INSTALLDIR.'/lib/default.php');
+
+// Set config values initially to default values
-$config =
- array('site' =>
- array('name' => 'Just another StatusNet microblog',
- 'server' => $_server,
- 'theme' => 'default',
- 'path' => $_path,
- 'logfile' => null,
- 'logo' => null,
- 'logdebug' => false,
- 'fancy' => false,
- 'locale_path' => INSTALLDIR.'/locale',
- 'language' => 'en_US',
- 'languages' => get_all_languages(),
- 'email' =>
- array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : null,
- 'broughtby' => null,
- 'timezone' => 'UTC',
- 'broughtbyurl' => null,
- 'closed' => false,
- 'inviteonly' => false,
- 'openidonly' => false,
- 'private' => false,
- 'ssl' => 'never',
- 'sslserver' => null,
- 'shorturllength' => 30,
- 'dupelimit' => 60), # default for same person saying the same thing
- 'syslog' =>
- array('appname' => 'statusnet', # for syslog
- 'priority' => 'debug', # XXX: currently ignored
- 'facility' => LOG_USER),
- 'queue' =>
- array('enabled' => false,
- 'subsystem' => 'db', # default to database, or 'stomp'
- 'stomp_server' => null,
- 'queue_basename' => 'statusnet',
- 'stomp_username' => null,
- 'stomp_password' => null,
- ),
- 'license' =>
- array('url' => 'http://creativecommons.org/licenses/by/3.0/',
- 'title' => 'Creative Commons Attribution 3.0',
- 'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'),
- 'mail' =>
- array('backend' => 'mail',
- 'params' => null),
- 'nickname' =>
- array('blacklist' => array(),
- 'featured' => array()),
- 'profile' =>
- array('banned' => array()),
- 'avatar' =>
- array('server' => null,
- 'dir' => INSTALLDIR . '/avatar/',
- 'path' => $_path . '/avatar/'),
- 'background' =>
- array('server' => null,
- 'dir' => INSTALLDIR . '/background/',
- 'path' => $_path . '/background/'),
- 'public' =>
- array('localonly' => true,
- 'blacklist' => array(),
- 'autosource' => array()),
- 'theme' =>
- array('server' => null,
- 'dir' => null,
- 'path'=> null),
- 'throttle' =>
- array('enabled' => false, // whether to throttle edits; false by default
- 'count' => 20, // number of allowed messages in timespan
- 'timespan' => 600), // timespan for throttling
- 'xmpp' =>
- array('enabled' => false,
- 'server' => 'INVALID SERVER',
- 'port' => 5222,
- 'user' => 'update',
- 'encryption' => true,
- 'resource' => 'uniquename',
- 'password' => 'blahblahblah',
- 'host' => null, # only set if != server
- 'debug' => false, # print extra debug info
- 'public' => array()), # JIDs of users who want to receive the public stream
- 'openid' =>
- array('enabled' => true),
- 'invite' =>
- array('enabled' => true),
- 'sphinx' =>
- array('enabled' => false,
- 'server' => 'localhost',
- 'port' => 3312),
- 'tag' =>
- array('dropoff' => 864000.0),
- 'popular' =>
- array('dropoff' => 864000.0),
- 'daemon' =>
- array('piddir' => '/var/run',
- 'user' => false,
- 'group' => false),
- 'emailpost' =>
- array('enabled' => true),
- 'sms' =>
- array('enabled' => true),
- 'twitterbridge' =>
- array('enabled' => false),
- 'integration' =>
- array('source' => 'StatusNet', # source attribute for Twitter
- 'taguri' => $_server.',2009'), # base for tag URIs
- 'twitter' =>
- array('enabled' => true,
- 'consumer_key' => null,
- 'consumer_secret' => null),
- 'memcached' =>
- array('enabled' => false,
- 'server' => 'localhost',
- 'base' => null,
- 'port' => 11211),
- 'ping' =>
- array('notify' => array()),
- 'inboxes' =>
- array('enabled' => true), # on by default for new sites
- 'newuser' =>
- array('default' => null,
- 'welcome' => null),
- 'snapshot' =>
- array('run' => 'web',
- 'frequency' => 10000,
- 'reporturl' => 'http://status.net/stats/report'),
- 'attachments' =>
- array('server' => null,
- 'dir' => INSTALLDIR . '/file/',
- 'path' => $_path . '/file/',
- 'supported' => array('image/png',
- 'image/jpeg',
- 'image/gif',
- 'image/svg+xml',
- 'audio/mpeg',
- 'audio/x-speex',
- 'application/ogg',
- 'application/pdf',
- 'application/vnd.oasis.opendocument.text',
- 'application/vnd.oasis.opendocument.text-template',
- 'application/vnd.oasis.opendocument.graphics',
- 'application/vnd.oasis.opendocument.graphics-template',
- 'application/vnd.oasis.opendocument.presentation',
- 'application/vnd.oasis.opendocument.presentation-template',
- 'application/vnd.oasis.opendocument.spreadsheet',
- 'application/vnd.oasis.opendocument.spreadsheet-template',
- 'application/vnd.oasis.opendocument.chart',
- 'application/vnd.oasis.opendocument.chart-template',
- 'application/vnd.oasis.opendocument.image',
- 'application/vnd.oasis.opendocument.image-template',
- 'application/vnd.oasis.opendocument.formula',
- 'application/vnd.oasis.opendocument.formula-template',
- 'application/vnd.oasis.opendocument.text-master',
- 'application/vnd.oasis.opendocument.text-web',
- 'application/x-zip',
- 'application/zip',
- 'text/plain',
- 'video/mpeg',
- 'video/mp4',
- 'video/quicktime',
- 'video/mpeg'),
- 'file_quota' => 5000000,
- 'user_quota' => 50000000,
- 'monthly_quota' => 15000000,
- 'uploads' => true,
- 'filecommand' => '/usr/bin/file',
- ),
- 'group' =>
- array('maxaliases' => 3),
- 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
- 'search' =>
- array('type' => 'fulltext'),
- 'sessions' =>
- array('handle' => false, // whether to handle sessions ourselves
- 'debug' => false), // debugging output for sessions
- 'design' =>
- array('backgroundcolor' => null, // null -> 'use theme default'
- 'contentcolor' => null,
- 'sidebarcolor' => null,
- 'textcolor' => null,
- 'linkcolor' => null,
- 'backgroundimage' => null,
- 'disposition' => null),
- );
+$config = $default;
+
+// default configuration, overwritten in config.php
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
-$config['db'] =
- array('database' => 'YOU HAVE TO SET THIS IN config.php',
- 'schema_location' => INSTALLDIR . '/classes',
- 'class_location' => INSTALLDIR . '/classes',
- 'require_prefix' => 'classes/',
- 'class_prefix' => '',
- 'mirror' => null,
- 'utf8' => true,
- 'db_driver' => 'DB', # XXX: JanRain libs only work with DB
- 'quote_identifiers' => false,
- 'type' => 'mysql' );
+$config['db'] = $default['db'];
// Backward compatibility
@@ -382,13 +194,25 @@ if ($_db_name != 'statusnet' && !array_key_exists('ini_'.$_db_name, $config['db'
$config['db']['ini_'.$_db_name] = INSTALLDIR.'/classes/statusnet.ini';
}
-// Ignore openidonly if OpenID is disabled
-
-if (!$config['openid']['enabled']) {
- $config['site']['openidonly'] = false;
+function __autoload($cls)
+{
+ if (file_exists(INSTALLDIR.'/classes/' . $cls . '.php')) {
+ require_once(INSTALLDIR.'/classes/' . $cls . '.php');
+ } else if (file_exists(INSTALLDIR.'/lib/' . strtolower($cls) . '.php')) {
+ require_once(INSTALLDIR.'/lib/' . strtolower($cls) . '.php');
+ } else if (mb_substr($cls, -6) == 'Action' &&
+ file_exists(INSTALLDIR.'/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php')) {
+ require_once(INSTALLDIR.'/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
+ } else if ($cls == 'OAuthRequest') {
+ require_once('OAuth.php');
+ } else {
+ Event::handle('Autoload', array(&$cls));
+ }
}
// XXX: how many of these could be auto-loaded on use?
+// XXX: note that these files should not use config options
+// at compile time since DB config options are not yet loaded.
require_once 'Validate.php';
require_once 'markdown.php';
@@ -399,29 +223,24 @@ require_once INSTALLDIR.'/lib/theme.php';
require_once INSTALLDIR.'/lib/mail.php';
require_once INSTALLDIR.'/lib/subs.php';
require_once INSTALLDIR.'/lib/Shorturl_api.php';
-require_once INSTALLDIR.'/lib/twitter.php';
require_once INSTALLDIR.'/lib/clientexception.php';
require_once INSTALLDIR.'/lib/serverexception.php';
-// XXX: other formats here
+// Load settings from database; note we need autoload for this
-define('NICKNAME_FMT', VALIDATE_NUM.VALIDATE_ALPHA_LOWER);
+Config::loadSettings();
-function __autoload($class)
-{
- if ($class == 'OAuthRequest') {
- require_once('OAuth.php');
- } else if (file_exists(INSTALLDIR.'/classes/' . $class . '.php')) {
- require_once(INSTALLDIR.'/classes/' . $class . '.php');
- } else if (file_exists(INSTALLDIR.'/lib/' . strtolower($class) . '.php')) {
- require_once(INSTALLDIR.'/lib/' . strtolower($class) . '.php');
- } else if (mb_substr($class, -6) == 'Action' &&
- file_exists(INSTALLDIR.'/actions/' . strtolower(mb_substr($class, 0, -6)) . '.php')) {
- require_once(INSTALLDIR.'/actions/' . strtolower(mb_substr($class, 0, -6)) . '.php');
- }
+// XXX: if plugins should check the schema at runtime, do that here.
+
+if ($config['db']['schemacheck'] == 'runtime') {
+ Event::handle('CheckSchema');
}
+// XXX: other formats here
+
+define('NICKNAME_FMT', VALIDATE_NUM.VALIDATE_ALPHA_LOWER);
+
// Give plugins a chance to initialize in a fully-prepared environment
Event::handle('InitializePlugin');
diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php
index 2095a7ceb..e5fb8727b 100644
--- a/lib/connectsettingsaction.php
+++ b/lib/connectsettingsaction.php
@@ -98,34 +98,37 @@ class ConnectSettingsNav extends Widget
function show()
{
- # action => array('prompt', 'title')
- $menu = array();
- if (common_config('xmpp', 'enabled')) {
- $menu['imsettings'] =
- array(_('IM'),
- _('Updates by instant messenger (IM)'));
- }
- if (common_config('sms', 'enabled')) {
- $menu['smssettings'] =
- array(_('SMS'),
- _('Updates by SMS'));
- }
- if (common_config('twitter', 'enabled')) {
- $menu['twittersettings'] =
- array(_('Twitter'),
- _('Twitter integration options'));
- }
-
$action_name = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav'));
- foreach ($menu as $menuaction => $menudesc) {
- $this->action->menuItem(common_local_url($menuaction),
- $menudesc[0],
- $menudesc[1],
- $action_name === $menuaction);
+ if (Event::handle('StartConnectSettingsNav', array(&$this->action))) {
+
+ # action => array('prompt', 'title')
+ $menu = array();
+ if (common_config('xmpp', 'enabled')) {
+ $menu['imsettings'] =
+ array(_('IM'),
+ _('Updates by instant messenger (IM)'));
+ }
+ if (common_config('sms', 'enabled')) {
+ $menu['smssettings'] =
+ array(_('SMS'),
+ _('Updates by SMS'));
+ }
+
+ foreach ($menu as $menuaction => $menudesc) {
+ $this->action->menuItem(common_local_url($menuaction),
+ $menudesc[0],
+ $menudesc[1],
+ $action_name === $menuaction);
+ }
+
+ Event::handle('EndConnectSettingsNav', array(&$this->action));
}
$this->action->elementEnd('ul');
}
+
}
+
+
diff --git a/lib/curlclient.php b/lib/curlclient.php
new file mode 100644
index 000000000..c307c2984
--- /dev/null
+++ b/lib/curlclient.php
@@ -0,0 +1,179 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Utility class for wrapping Curl
+ *
+ * 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 HTTP
+ * @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);
+}
+
+define(CURLCLIENT_VERSION, "0.1");
+
+/**
+ * Wrapper for Curl
+ *
+ * Makes Curl HTTP client calls within our HTTPClient framework
+ *
+ * @category HTTP
+ * @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 CurlClient extends HTTPClient
+{
+ function __construct()
+ {
+ }
+
+ function head($url, $headers=null)
+ {
+ $ch = curl_init($url);
+
+ $this->setup($ch);
+
+ curl_setopt_array($ch,
+ array(CURLOPT_NOBODY => true));
+
+ if (!is_null($headers)) {
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ }
+
+ $result = curl_exec($ch);
+
+ curl_close($ch);
+
+ return $this->parseResults($result);
+ }
+
+ function get($url, $headers=null)
+ {
+ $ch = curl_init($url);
+
+ $this->setup($ch);
+
+ if (!is_null($headers)) {
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ }
+
+ $result = curl_exec($ch);
+
+ curl_close($ch);
+
+ return $this->parseResults($result);
+ }
+
+ function post($url, $headers=null, $body=null)
+ {
+ $ch = curl_init($url);
+
+ $this->setup($ch);
+
+ curl_setopt($ch, CURLOPT_POST, true);
+
+ if (!is_null($body)) {
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
+ }
+
+ if (!is_null($headers)) {
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ }
+
+ $result = curl_exec($ch);
+
+ curl_close($ch);
+
+ return $this->parseResults($result);
+ }
+
+ function setup($ch)
+ {
+ curl_setopt_array($ch,
+ array(CURLOPT_USERAGENT => $this->userAgent(),
+ CURLOPT_HEADER => true,
+ CURLOPT_RETURNTRANSFER => true));
+ }
+
+ function userAgent()
+ {
+ $version = curl_version();
+ return parent::userAgent() . " CurlClient/".CURLCLIENT_VERSION . " cURL/" . $version['version'];
+ }
+
+ function parseResults($results)
+ {
+ $resp = new HTTPResponse();
+
+ $lines = explode("\r\n", $results);
+
+ if (preg_match("#^HTTP/1.[01] (\d\d\d) .+$#", $lines[0], $match)) {
+ $resp->code = $match[1];
+ } else {
+ throw Exception("Bad format: initial line is not HTTP status line");
+ }
+
+ $lastk = null;
+
+ for ($i = 1; $i < count($lines); $i++) {
+ $l =& $lines[$i];
+ if (mb_strlen($l) == 0) {
+ $resp->body = implode("\r\n", array_slice($lines, $i + 1));
+ break;
+ }
+ if (preg_match("#^(\S+):\s+(.*)$#", $l, $match)) {
+ $k = $match[1];
+ $v = $match[2];
+
+ if (array_key_exists($k, $resp->headers)) {
+ if (is_array($resp->headers[$k])) {
+ $resp->headers[$k][] = $v;
+ } else {
+ $resp->headers[$k] = array($resp->headers[$k], $v);
+ }
+ } else {
+ $resp->headers[$k] = $v;
+ }
+ $lastk = $k;
+ } else if (preg_match("#^\s+(.*)$#", $l, $match)) {
+ // continuation line
+ if (is_null($lastk)) {
+ throw Exception("Bad format: initial whitespace in headers");
+ }
+ $h =& $resp->headers[$lastk];
+ if (is_array($h)) {
+ $n = count($h);
+ $h[$n-1] .= $match[1];
+ } else {
+ $h .= $match[1];
+ }
+ }
+ }
+
+ return $resp;
+ }
+}
diff --git a/lib/default.php b/lib/default.php
new file mode 100644
index 000000000..7ec8558b0
--- /dev/null
+++ b/lib/default.php
@@ -0,0 +1,235 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Default settings for core configuration
+ *
+ * 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 Config
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2008-9 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/
+ */
+
+$default =
+ array('site' =>
+ array('name' => 'Just another StatusNet microblog',
+ 'server' => $_server,
+ 'theme' => 'default',
+ 'path' => $_path,
+ 'logfile' => null,
+ 'logo' => null,
+ 'logdebug' => false,
+ 'fancy' => false,
+ 'locale_path' => INSTALLDIR.'/locale',
+ 'language' => 'en_US',
+ 'languages' => get_all_languages(),
+ 'email' =>
+ array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : null,
+ 'broughtby' => null,
+ 'timezone' => 'UTC',
+ 'broughtbyurl' => null,
+ 'closed' => false,
+ 'inviteonly' => false,
+ 'private' => false,
+ 'ssl' => 'never',
+ 'sslserver' => null,
+ 'shorturllength' => 30,
+ 'dupelimit' => 60, # default for same person saying the same thing
+ 'textlimit' => 140,
+ ),
+ 'db' =>
+ array('database' => 'YOU HAVE TO SET THIS IN config.php',
+ 'schema_location' => INSTALLDIR . '/classes',
+ 'class_location' => INSTALLDIR . '/classes',
+ 'require_prefix' => 'classes/',
+ 'class_prefix' => '',
+ 'mirror' => null,
+ 'utf8' => true,
+ 'db_driver' => 'DB', # XXX: JanRain libs only work with DB
+ 'quote_identifiers' => false,
+ 'type' => 'mysql',
+ 'schemacheck' => 'runtime'), // 'runtime' or 'script'
+ 'syslog' =>
+ array('appname' => 'statusnet', # for syslog
+ 'priority' => 'debug', # XXX: currently ignored
+ 'facility' => LOG_USER),
+ 'queue' =>
+ array('enabled' => false,
+ 'subsystem' => 'db', # default to database, or 'stomp'
+ 'stomp_server' => null,
+ 'queue_basename' => 'statusnet',
+ 'stomp_username' => null,
+ 'stomp_password' => null,
+ ),
+ 'license' =>
+ array('url' => 'http://creativecommons.org/licenses/by/3.0/',
+ 'title' => 'Creative Commons Attribution 3.0',
+ 'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'),
+ 'mail' =>
+ array('backend' => 'mail',
+ 'params' => null,
+ 'domain_check' => true),
+ 'nickname' =>
+ array('blacklist' => array(),
+ 'featured' => array()),
+ 'profile' =>
+ array('banned' => array(),
+ 'biolimit' => null),
+ 'avatar' =>
+ array('server' => null,
+ 'dir' => INSTALLDIR . '/avatar/',
+ 'path' => $_path . '/avatar/'),
+ 'background' =>
+ array('server' => null,
+ 'dir' => INSTALLDIR . '/background/',
+ 'path' => $_path . '/background/'),
+ 'public' =>
+ array('localonly' => true,
+ 'blacklist' => array(),
+ 'autosource' => array()),
+ 'theme' =>
+ array('server' => null,
+ 'dir' => null,
+ 'path'=> null),
+ 'throttle' =>
+ array('enabled' => false, // whether to throttle edits; false by default
+ 'count' => 20, // number of allowed messages in timespan
+ 'timespan' => 600), // timespan for throttling
+ 'xmpp' =>
+ array('enabled' => false,
+ 'server' => 'INVALID SERVER',
+ 'port' => 5222,
+ 'user' => 'update',
+ 'encryption' => true,
+ 'resource' => 'uniquename',
+ 'password' => 'blahblahblah',
+ 'host' => null, # only set if != server
+ 'debug' => false, # print extra debug info
+ 'public' => array()), # JIDs of users who want to receive the public stream
+ 'invite' =>
+ array('enabled' => true),
+ 'sphinx' =>
+ array('enabled' => false,
+ 'server' => 'localhost',
+ 'port' => 3312),
+ 'tag' =>
+ array('dropoff' => 864000.0),
+ 'popular' =>
+ array('dropoff' => 864000.0),
+ 'daemon' =>
+ array('piddir' => '/var/run',
+ 'user' => false,
+ 'group' => false),
+ 'emailpost' =>
+ array('enabled' => true),
+ 'sms' =>
+ array('enabled' => true),
+ 'twitterimport' =>
+ array('enabled' => false),
+ 'integration' =>
+ array('source' => 'StatusNet', # source attribute for Twitter
+ 'taguri' => $_server.',2009'), # base for tag URIs
+ 'twitter' =>
+ array('enabled' => true,
+ 'consumer_key' => null,
+ 'consumer_secret' => null),
+ 'memcached' =>
+ array('enabled' => false,
+ 'server' => 'localhost',
+ 'base' => null,
+ 'port' => 11211),
+ 'ping' =>
+ array('notify' => array()),
+ 'inboxes' =>
+ array('enabled' => true), # ignored after 0.9.x
+ 'newuser' =>
+ array('default' => null,
+ 'welcome' => null),
+ 'snapshot' =>
+ array('run' => 'web',
+ 'frequency' => 10000,
+ 'reporturl' => 'http://status.net/stats/report'),
+ 'attachments' =>
+ array('server' => null,
+ 'dir' => INSTALLDIR . '/file/',
+ 'path' => $_path . '/file/',
+ 'supported' => array('image/png',
+ 'image/jpeg',
+ 'image/gif',
+ 'image/svg+xml',
+ 'audio/mpeg',
+ 'audio/x-speex',
+ 'application/ogg',
+ 'application/pdf',
+ 'application/vnd.oasis.opendocument.text',
+ 'application/vnd.oasis.opendocument.text-template',
+ 'application/vnd.oasis.opendocument.graphics',
+ 'application/vnd.oasis.opendocument.graphics-template',
+ 'application/vnd.oasis.opendocument.presentation',
+ 'application/vnd.oasis.opendocument.presentation-template',
+ 'application/vnd.oasis.opendocument.spreadsheet',
+ 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'application/vnd.oasis.opendocument.chart',
+ 'application/vnd.oasis.opendocument.chart-template',
+ 'application/vnd.oasis.opendocument.image',
+ 'application/vnd.oasis.opendocument.image-template',
+ 'application/vnd.oasis.opendocument.formula',
+ 'application/vnd.oasis.opendocument.formula-template',
+ 'application/vnd.oasis.opendocument.text-master',
+ 'application/vnd.oasis.opendocument.text-web',
+ 'application/x-zip',
+ 'application/zip',
+ 'text/plain',
+ 'video/mpeg',
+ 'video/mp4',
+ 'video/quicktime',
+ 'video/mpeg'),
+ 'file_quota' => 5000000,
+ 'user_quota' => 50000000,
+ 'monthly_quota' => 15000000,
+ 'uploads' => true,
+ 'filecommand' => '/usr/bin/file',
+ ),
+ 'group' =>
+ array('maxaliases' => 3,
+ 'desclimit' => null),
+ 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
+ 'search' =>
+ array('type' => 'fulltext'),
+ 'sessions' =>
+ array('handle' => false, // whether to handle sessions ourselves
+ 'debug' => false), // debugging output for sessions
+ 'design' =>
+ array('backgroundcolor' => null, // null -> 'use theme default'
+ 'contentcolor' => null,
+ 'sidebarcolor' => null,
+ 'textcolor' => null,
+ 'linkcolor' => null,
+ 'backgroundimage' => null,
+ 'disposition' => null),
+ 'notice' =>
+ array('contentlimit' => null),
+ 'message' =>
+ array('contentlimit' => null),
+ 'http' =>
+ array('client' => 'curl'), // XXX: should this be the default?
+ 'location' =>
+ array('namespace' => 1), // 1 = geonames, 2 = Yahoo Where on Earth
+ );
diff --git a/lib/deleteaction.php b/lib/deleteaction.php
deleted file mode 100644
index f702820c6..000000000
--- a/lib/deleteaction.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Base class for deleting things
- *
- * 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 Personal
- * @package StatusNet
- * @author Evan Prodromou <evan@status.net>
- * @author Sarven Capadisli <csarven@status.net>
- * @copyright 2008 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);
-}
-
-class DeleteAction extends Action
-{
- var $user = null;
- var $notice = null;
- var $profile = null;
- var $user_profile = null;
-
- function prepare($args)
- {
- parent::prepare($args);
-
- $this->user = common_current_user();
- $notice_id = $this->trimmed('notice');
- $this->notice = Notice::staticGet($notice_id);
-
- if (!$this->notice) {
- common_user_error(_('No such notice.'));
- exit;
- }
-
- $this->profile = $this->notice->getProfile();
- $this->user_profile = $this->user->getProfile();
-
- return true;
- }
-
- function handle($args)
- {
- parent::handle($args);
-
- if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
- exit;
- } else if ($this->notice->profile_id != $this->user_profile->id) {
- common_user_error(_('Can\'t delete this notice.'));
- exit;
- }
- }
-
-}
diff --git a/lib/groupeditform.php b/lib/groupeditform.php
index a649c2ee3..433f6a138 100644
--- a/lib/groupeditform.php
+++ b/lib/groupeditform.php
@@ -150,27 +150,33 @@ class GroupEditForm extends Form
$this->out->elementStart('li');
$this->out->hidden('groupid', $id);
$this->out->input('nickname', _('Nickname'),
- ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $nickname,
- _('1-64 lowercase letters or numbers, no punctuation or spaces'));
+ ($this->out->arg('nickname')) ? $this->out->arg('nickname') : $nickname,
+ _('1-64 lowercase letters or numbers, no punctuation or spaces'));
$this->out->elementEnd('li');
$this->out->elementStart('li');
$this->out->input('fullname', _('Full name'),
- ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $fullname);
+ ($this->out->arg('fullname')) ? $this->out->arg('fullname') : $fullname);
$this->out->elementEnd('li');
$this->out->elementStart('li');
$this->out->input('homepage', _('Homepage'),
- ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
- _('URL of the homepage or blog of the group or topic'));
+ ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
+ _('URL of the homepage or blog of the group or topic'));
$this->out->elementEnd('li');
$this->out->elementStart('li');
+ $desclimit = User_group::maxDescription();
+ if ($desclimit == 0) {
+ $descinstr = _('Describe the group or topic');
+ } else {
+ $descinstr = sprintf(_('Describe the group or topic in %d characters'), $desclimit);
+ }
$this->out->textarea('description', _('Description'),
- ($this->out->arg('description')) ? $this->out->arg('description') : $description,
- _('Describe the group or topic in 140 chars'));
+ ($this->out->arg('description')) ? $this->out->arg('description') : $description,
+ $descinstr);
$this->out->elementEnd('li');
$this->out->elementStart('li');
$this->out->input('location', _('Location'),
- ($this->out->arg('location')) ? $this->out->arg('location') : $location,
- _('Location for the group, if any, like "City, State (or Region), Country"'));
+ ($this->out->arg('location')) ? $this->out->arg('location') : $location,
+ _('Location for the group, if any, like "City, State (or Region), Country"'));
$this->out->elementEnd('li');
if (common_config('group', 'maxaliases') > 0) {
$aliases = (empty($this->group)) ? array() : $this->group->getAliases();
diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php
index 2ff9380cc..ce83295fb 100644
--- a/lib/htmloutputter.php
+++ b/lib/htmloutputter.php
@@ -106,7 +106,7 @@ class HTMLOutputter extends XMLOutputter
}
}
- header('Content-Type: '.$type.'; charset=UTF-8');
+ header('Content-Type: '.$type);
$this->extraHeaders();
if (preg_match("/.*\/.*xml/", $type)) {
diff --git a/lib/httpclient.php b/lib/httpclient.php
new file mode 100644
index 000000000..f16e31e10
--- /dev/null
+++ b/lib/httpclient.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Utility for doing HTTP-related things
+ *
+ * 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 Action
+ * @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);
+}
+
+/**
+ * Useful structure for HTTP responses
+ *
+ * We make HTTP calls in several places, and we have several different
+ * ways of doing them. This class hides the specifics of what underlying
+ * library (curl or PHP-HTTP or whatever) that's used.
+ *
+ * @category HTTP
+ * @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 HTTPResponse
+{
+ public $code = null;
+ public $headers = array();
+ public $body = null;
+}
+
+/**
+ * Utility class for doing HTTP client stuff
+ *
+ * We make HTTP calls in several places, and we have several different
+ * ways of doing them. This class hides the specifics of what underlying
+ * library (curl or PHP-HTTP or whatever) that's used.
+ *
+ * @category HTTP
+ * @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 HTTPClient
+{
+ static $_client = null;
+
+ static function start()
+ {
+ if (!is_null(self::$_client)) {
+ return self::$_client;
+ }
+
+ $type = common_config('http', 'client');
+
+ switch ($type) {
+ case 'curl':
+ self::$_client = new CurlClient();
+ break;
+ default:
+ throw new Exception("Unknown HTTP client type '$type'");
+ break;
+ }
+
+ return self::$_client;
+ }
+
+ function head($url, $headers)
+ {
+ throw new Exception("HEAD method unimplemented");
+ }
+
+ function get($url, $headers)
+ {
+ throw new Exception("GET method unimplemented");
+ }
+
+ function post($url, $headers, $body)
+ {
+ throw new Exception("POST method unimplemented");
+ }
+
+ function put($url, $headers, $body)
+ {
+ throw new Exception("PUT method unimplemented");
+ }
+
+ function delete($url, $headers)
+ {
+ throw new Exception("DELETE method unimplemented");
+ }
+
+ function userAgent()
+ {
+ return "StatusNet/".STATUSNET_VERSION." (".STATUSNET_CODENAME.")";
+ }
+}
diff --git a/lib/jabber.php b/lib/jabber.php
index 3dcdce5db..73f2ec660 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -176,6 +176,7 @@ function jabber_format_entry($profile, $notice)
$xs = new XMLStringer();
$xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
$xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
+ $xs->element("img", array('src'=> $profile->avatarUrl(AVATAR_MINI_SIZE) , 'alt' => $profile->nickname));
$xs->element('a', array('href' => $profile->profileurl),
$profile->nickname);
$xs->text(": ");
@@ -184,6 +185,11 @@ function jabber_format_entry($profile, $notice)
} else {
$xs->raw(common_render_content($notice->content, $notice));
}
+ $xs->raw(" ");
+ $xs->element('a', array(
+ 'href'=>common_local_url('conversation',
+ array('id' => $notice->conversation)).'#notice-'.$notice->id
+ ),sprintf(_('notice id: %s'),$notice->id));
$xs->elementEnd('body');
$xs->elementEnd('html');
diff --git a/lib/language.php b/lib/language.php
index 561a4ddb8..7dcb808c9 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -101,35 +101,36 @@ function get_nice_language_list()
*/
function get_all_languages() {
return array(
- 'bg' => array('q' => 0.8, 'lang' => 'bg_BG', 'name' => 'Bulgarian', 'direction' => 'ltr'),
- 'ca' => array('q' => 0.5, 'lang' => 'ca_ES', 'name' => 'Catalan', 'direction' => 'ltr'),
- 'cs' => array('q' => 0.5, 'lang' => 'cs_CZ', 'name' => 'Czech', 'direction' => 'ltr'),
- 'de' => array('q' => 0.8, 'lang' => 'de_DE', 'name' => 'German', 'direction' => 'ltr'),
+ 'bg' => array('q' => 0.8, 'lang' => 'bg', 'name' => 'Bulgarian', 'direction' => 'ltr'),
+ 'ca' => array('q' => 0.5, 'lang' => 'ca', 'name' => 'Catalan', 'direction' => 'ltr'),
+ 'cs' => array('q' => 0.5, 'lang' => 'cs', 'name' => 'Czech', 'direction' => 'ltr'),
+ 'de' => array('q' => 0.8, 'lang' => 'de', 'name' => 'German', 'direction' => 'ltr'),
'el' => array('q' => 0.1, 'lang' => 'el', 'name' => 'Greek', 'direction' => 'ltr'),
- 'en-us' => array('q' => 1, 'lang' => 'en_US', 'name' => 'English (US)', 'direction' => 'ltr'),
+ 'en-us' => array('q' => 1, 'lang' => 'en', 'name' => 'English (US)', 'direction' => 'ltr'),
'en-gb' => array('q' => 1, 'lang' => 'en_GB', 'name' => 'English (British)', 'direction' => 'ltr'),
- 'en' => array('q' => 1, 'lang' => 'en_US', 'name' => 'English (US)', 'direction' => 'ltr'),
+ 'en' => array('q' => 1, 'lang' => 'en', 'name' => 'English (US)', 'direction' => 'ltr'),
'es' => array('q' => 1, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'),
'fi' => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
- 'fr-fr' => array('q' => 1, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'),
- 'he' => array('q' => 0.5, 'lang' => 'he_IL', 'name' => 'Hebrew', 'direction' => 'rtl'),
- 'it' => array('q' => 1, 'lang' => 'it_IT', 'name' => 'Italian', 'direction' => 'ltr'),
- 'jp' => array('q' => 0.5, 'lang' => 'ja_JP', 'name' => 'Japanese', 'direction' => 'ltr'),
- 'ko' => array('q' => 0.9, 'lang' => 'ko_KR', 'name' => 'Korean', 'direction' => 'ltr'),
- 'mk' => array('q' => 0.5, 'lang' => 'mk_MK', 'name' => 'Macedonian', 'direction' => 'ltr'),
- 'nb' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
- 'no' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
- 'nn' => array('q' => 1, 'lang' => 'nn_NO', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'),
- 'nl' => array('q' => 0.5, 'lang' => 'nl_NL', 'name' => 'Dutch', 'direction' => 'ltr'),
- 'pl' => array('q' => 0.5, 'lang' => 'pl_PL', 'name' => 'Polish', 'direction' => 'ltr'),
+ 'fr-fr' => array('q' => 1, 'lang' => 'fr', 'name' => 'French', 'direction' => 'ltr'),
+ 'ga' => array('q' => 0.5, 'lang' => 'ga', 'name' => 'Galician', 'direction' => 'ltr'),
+ 'he' => array('q' => 0.5, 'lang' => 'he', 'name' => 'Hebrew', 'direction' => 'rtl'),
+ 'it' => array('q' => 1, 'lang' => 'it', 'name' => 'Italian', 'direction' => 'ltr'),
+ 'jp' => array('q' => 0.5, 'lang' => 'ja', 'name' => 'Japanese', 'direction' => 'ltr'),
+ 'ko' => array('q' => 0.9, 'lang' => 'ko', 'name' => 'Korean', 'direction' => 'ltr'),
+ 'mk' => array('q' => 0.5, 'lang' => 'mk', 'name' => 'Macedonian', 'direction' => 'ltr'),
+ 'nb' => array('q' => 0.1, 'lang' => 'nb', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
+ 'no' => array('q' => 0.1, 'lang' => 'nb', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
+ 'nn' => array('q' => 1, 'lang' => 'nn', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'),
+ 'nl' => array('q' => 0.5, 'lang' => 'nl', 'name' => 'Dutch', 'direction' => 'ltr'),
+ 'pl' => array('q' => 0.5, 'lang' => 'pl', 'name' => 'Polish', 'direction' => 'ltr'),
'pt' => array('q' => 0.1, 'lang' => 'pt', 'name' => 'Portuguese', 'direction' => 'ltr'),
'pt-br' => array('q' => 0.9, 'lang' => 'pt_BR', 'name' => 'Portuguese Brazil', 'direction' => 'ltr'),
- 'ru' => array('q' => 0.9, 'lang' => 'ru_RU', 'name' => 'Russian', 'direction' => 'ltr'),
- 'sv' => array('q' => 0.8, 'lang' => 'sv_SE', 'name' => 'Swedish', 'direction' => 'ltr'),
- 'te' => array('q' => 0.3, 'lang' => 'te_IN', 'name' => 'Telugu', 'direction' => 'ltr'),
- 'tr' => array('q' => 0.5, 'lang' => 'tr_TR', 'name' => 'Turkish', 'direction' => 'ltr'),
- 'uk' => array('q' => 1, 'lang' => 'uk_UA', 'name' => 'Ukrainian', 'direction' => 'ltr'),
- 'vi' => array('q' => 0.8, 'lang' => 'vi_VN', 'name' => 'Vietnamese', 'direction' => 'ltr'),
+ 'ru' => array('q' => 0.9, 'lang' => 'ru', 'name' => 'Russian', 'direction' => 'ltr'),
+ 'sv' => array('q' => 0.8, 'lang' => 'sv', 'name' => 'Swedish', 'direction' => 'ltr'),
+ 'te' => array('q' => 0.3, 'lang' => 'te', 'name' => 'Telugu', 'direction' => 'ltr'),
+ 'tr' => array('q' => 0.5, 'lang' => 'tr', 'name' => 'Turkish', 'direction' => 'ltr'),
+ 'uk' => array('q' => 1, 'lang' => 'uk', 'name' => 'Ukrainian', 'direction' => 'ltr'),
+ 'vi' => array('q' => 0.8, 'lang' => 'vi', 'name' => 'Vietnamese', 'direction' => 'ltr'),
'zh-cn' => array('q' => 0.9, 'lang' => 'zh_CN', 'name' => 'Chinese (Simplified)', 'direction' => 'ltr'),
'zh-hant' => array('q' => 0.2, 'lang' => 'zh_TW', 'name' => 'Chinese (Taiwanese)', 'direction' => 'ltr'),
);
diff --git a/lib/location.php b/lib/location.php
new file mode 100644
index 000000000..bbfc15a36
--- /dev/null
+++ b/lib/location.php
@@ -0,0 +1,188 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Class for locations
+ *
+ * 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 Location
+ * @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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * class for locations
+ *
+ * These are stored in the DB as part of notice and profile records,
+ * but since they're about the same in both, we have a separate class
+ * for them.
+ *
+ * @category Location
+ * @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 Location
+{
+ public $lat;
+ public $lon;
+ public $location_id;
+ public $location_ns;
+ private $_url;
+
+ var $names = array();
+
+ /**
+ * Constructor that makes a Location from a string name
+ *
+ * @param string $name Human-readable name (any kind)
+ * @param string $language Language, default = common_language()
+ *
+ * @return Location Location with that name (or null if not found)
+ */
+
+ static function fromName($name, $language=null)
+ {
+ if (is_null($language)) {
+ $language = common_language();
+ }
+
+ $location = null;
+
+ // Let a third-party handle it
+
+ Event::handle('LocationFromName', array($name, $language, &$location));
+
+ return $location;
+ }
+
+ /**
+ * Constructor that makes a Location from an ID
+ *
+ * @param integer $id Identifier ID
+ * @param integer $ns Namespace of the identifier
+ * @param string $language Language to return name in (default is common)
+ *
+ * @return Location The location with this ID (or null if none)
+ */
+
+ static function fromId($id, $ns, $language=null)
+ {
+ if (is_null($language)) {
+ $language = common_language();
+ }
+
+ $location = null;
+
+ // Let a third-party handle it
+
+ Event::handle('LocationFromId', array($id, $ns, $language, &$location));
+
+ return $location;
+ }
+
+ /**
+ * Constructor that finds the nearest location to a lat/lon pair
+ *
+ * @param float $lat Latitude
+ * @param float $lon Longitude
+ * @param string $language Language for results, default = current
+ *
+ * @return Location the location found, or null if none found
+ */
+
+ static function fromLatLon($lat, $lon, $language=null)
+ {
+ if (is_null($language)) {
+ $language = common_language();
+ }
+
+ $location = null;
+
+ // Let a third-party handle it
+
+ if (Event::handle('LocationFromLatLon',
+ array($lat, $lon, $language, &$location))) {
+ // Default is just the lat/lon pair
+
+ $location = new Location();
+
+ $location->lat = $lat;
+ $location->lon = $lon;
+ }
+
+ return $location;
+ }
+
+ /**
+ * Get the name for this location in the given language
+ *
+ * @param string $language language to use, default = current
+ *
+ * @return string location name or null if not found
+ */
+
+ function getName($language=null)
+ {
+ if (is_null($language)) {
+ $language = common_language();
+ }
+
+ if (array_key_exists($language, $this->names)) {
+ return $this->names[$language];
+ } else {
+ $name = null;
+ Event::handle('LocationNameLanguage', array($this, $language, &$name));
+ if (!empty($name)) {
+ $this->names[$language] = $name;
+ return $name;
+ }
+ }
+ }
+
+ /**
+ * Get an URL suitable for this location
+ *
+ * @return string URL for this location or NULL
+ */
+
+ function getURL()
+ {
+ // Keep one cached
+
+ if (is_string($this->_url)) {
+ return $this->_url;
+ }
+
+ $url = null;
+
+ Event::handle('LocationUrl', array($this, &$url));
+
+ $this->_url = $url;
+
+ return $url;
+ }
+}
diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php
index f740e329a..b545fbf26 100644
--- a/lib/logingroupnav.php
+++ b/lib/logingroupnav.php
@@ -69,30 +69,25 @@ class LoginGroupNav extends Widget
function show()
{
- // action => array('prompt', 'title')
- $menu = array();
+ $action_name = $this->action->trimmed('action');
+
+ $this->action->elementStart('ul', array('class' => 'nav'));
+
+ if (Event::handle('StartLoginGroupNav', array(&$this->action))) {
+
+ $this->action->menuItem(common_local_url('login'),
+ _('Login'),
+ _('Login with a username and password'),
+ $action_name === 'login');
- if (!common_config('site','openidonly')) {
- $menu['login'] = array(_('Login'),
- _('Login with a username and password'));
if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
- $menu['register'] = array(_('Register'),
- _('Sign up for a new account'));
+ $this->action->menuItem(common_local_url('register'),
+ _('Register'),
+ _('Sign up for a new account'),
+ $action_name === 'register');
}
- }
- if (common_config('openid', 'enabled')) {
- $menu['openidlogin'] = array(_('OpenID'),
- _('Login or register with OpenID'));
- }
-
- $action_name = $this->action->trimmed('action');
- $this->action->elementStart('ul', array('class' => 'nav'));
- foreach ($menu as $menuaction => $menudesc) {
- $this->action->menuItem(common_local_url($menuaction),
- $menudesc[0],
- $menudesc[1],
- $action_name === $menuaction);
+ Event::handle('EndLoginGroupNav', array(&$this->action));
}
$this->action->elementEnd('ul');
diff --git a/lib/mail.php b/lib/mail.php
index 5bf4d7425..5218059e9 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -640,75 +640,3 @@ function mail_notify_attn($user, $notice)
mail_to_user($user, $subject, $body);
}
-/**
- * Send a mail message to notify a user that her Twitter bridge link
- * has stopped working, and therefore has been removed. This can
- * happen when the user changes her Twitter password, or otherwise
- * revokes access.
- *
- * @param User $user user whose Twitter bridge link has been removed
- *
- * @return boolean success flag
- */
-
-function mail_twitter_bridge_removed($user)
-{
- common_init_locale($user->language);
-
- $profile = $user->getProfile();
-
- $subject = sprintf(_('Your Twitter bridge has been disabled.'));
-
- $site_name = common_config('site', 'name');
-
- $body = sprintf(_('Hi, %1$s. We\'re sorry to inform you that your ' .
- 'link to Twitter has been disabled. We no longer seem to have ' .
- 'permission to update your Twitter status. (Did you revoke ' .
- '%3$s\'s access?)' . "\n\n" .
- 'You can re-enable your Twitter bridge by visiting your ' .
- "Twitter settings page:\n\n\t%2\$s\n\n" .
- "Regards,\n%3\$s\n"),
- $profile->getBestName(),
- common_local_url('twittersettings'),
- common_config('site', 'name'));
-
- common_init_locale();
- return mail_to_user($user, $subject, $body);
-}
-
-/**
- * Send a mail message to notify a user that her Facebook Application
- * access has been removed.
- *
- * @param User $user user whose Facebook app link has been removed
- *
- * @return boolean success flag
- */
-
-function mail_facebook_app_removed($user)
-{
- common_init_locale($user->language);
-
- $profile = $user->getProfile();
-
- $site_name = common_config('site', 'name');
-
- $subject = sprintf(
- _('Your %1$s Facebook application access has been disabled.',
- $site_name));
-
- $body = sprintf(_("Hi, %1\$s. We're sorry to inform you that we are " .
- 'unable to update your Facebook status from %2$s, and have disabled ' .
- 'the Facebook application for your account. This may be because ' .
- 'you have removed the Facebook application\'s authorization, or ' .
- 'have deleted your Facebook account. You can re-enable the ' .
- 'Facebook application and automatic status updating by ' .
- "re-installing the %2\$s Facebook application.\n\nRegards,\n\n%2\$s"),
- $user->nickname, $site_name);
-
- common_init_locale();
- return mail_to_user($user, $subject, $body);
-
-}
-
-
diff --git a/lib/mediafile.php b/lib/mediafile.php
new file mode 100644
index 000000000..d4d184dd0
--- /dev/null
+++ b/lib/mediafile.php
@@ -0,0 +1,284 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Abstraction for media files in general
+ *
+ * TODO: combine with ImageFile?
+ *
+ * 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 Media
+ * @package StatusNet
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@status.net>
+ * @copyright 2008-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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+class MediaFile
+{
+
+ var $filename = null;
+ var $fileRecord = null;
+ var $user = null;
+ var $fileurl = null;
+ var $short_fileurl = null;
+ var $mimetype = null;
+
+ function __construct($user = null, $filename = null, $mimetype = null)
+ {
+ if ($user == null) {
+ $this->user = common_current_user();
+ }
+
+ $this->filename = $filename;
+ $this->mimetype = $mimetype;
+ $this->fileRecord = $this->storeFile();
+
+ $this->fileurl = common_local_url('attachment',
+ array('attachment' => $this->fileRecord->id));
+
+ $this->maybeAddRedir($this->fileRecord->id, $this->fileurl);
+ $this->short_fileurl = common_shorten_url($this->fileurl);
+ $this->maybeAddRedir($this->fileRecord->id, $this->short_fileurl);
+ }
+
+ function attachToNotice($notice)
+ {
+ File_to_post::processNew($this->fileRecord->id, $notice->id);
+ $this->maybeAddRedir($this->fileRecord->id,
+ common_local_url('file', array('notice' => $notice->id)));
+ }
+
+ function shortUrl()
+ {
+ return $this->short_fileurl;
+ }
+
+ function delete()
+ {
+ $filepath = File::path($this->filename);
+ @unlink($filepath);
+ }
+
+ function storeFile() {
+
+ $file = new File;
+
+ $file->filename = $this->filename;
+ $file->url = File::url($this->filename);
+ $filepath = File::path($this->filename);
+ $file->size = filesize($filepath);
+ $file->date = time();
+ $file->mimetype = $this->mimetype;
+
+ $file_id = $file->insert();
+
+ if (!$file_id) {
+ common_log_db_error($file, "INSERT", __FILE__);
+ throw new ClientException(_('There was a database error while saving your file. Please try again.'));
+ }
+
+ return $file;
+ }
+
+ function rememberFile($file, $short)
+ {
+ $this->maybeAddRedir($file->id, $short);
+ }
+
+ function maybeAddRedir($file_id, $url)
+ {
+ $file_redir = File_redirection::staticGet('url', $url);
+
+ if (empty($file_redir)) {
+
+ $file_redir = new File_redirection;
+ $file_redir->url = $url;
+ $file_redir->file_id = $file_id;
+
+ $result = $file_redir->insert();
+
+ if (!$result) {
+ common_log_db_error($file_redir, "INSERT", __FILE__);
+ throw new ClientException(_('There was a database error while saving your file. Please try again.'));
+ }
+ }
+ }
+
+ static function fromUpload($param = 'media', $user = null)
+ {
+ if (empty($user)) {
+ $user = common_current_user();
+ }
+
+ if (!isset($_FILES[$param]['error'])){
+ return;
+ }
+
+ switch ($_FILES[$param]['error']) {
+ case UPLOAD_ERR_OK: // success, jump out
+ break;
+ case UPLOAD_ERR_INI_SIZE:
+ throw new ClientException(_('The uploaded file exceeds the ' .
+ 'upload_max_filesize directive in php.ini.'));
+ return;
+ case UPLOAD_ERR_FORM_SIZE:
+ throw new ClientException(
+ _('The uploaded file exceeds the MAX_FILE_SIZE directive' .
+ ' that was specified in the HTML form.'));
+ return;
+ case UPLOAD_ERR_PARTIAL:
+ @unlink($_FILES[$param]['tmp_name']);
+ throw new ClientException(_('The uploaded file was only' .
+ ' partially uploaded.'));
+ return;
+ case UPLOAD_ERR_NO_TMP_DIR:
+ throw new ClientException(_('Missing a temporary folder.'));
+ return;
+ case UPLOAD_ERR_CANT_WRITE:
+ throw new ClientException(_('Failed to write file to disk.'));
+ return;
+ case UPLOAD_ERR_EXTENSION:
+ throw new ClientException(_('File upload stopped by extension.'));
+ return;
+ default:
+ throw new ClientException(_('System error uploading file.'));
+ return;
+ }
+
+ if (!MediaFile::respectsQuota($user, $_FILES['attach']['size'])) {
+
+ // Should never actually get here
+
+ @unlink($_FILES[$param]['tmp_name']);
+ throw new ClientException(_('File exceeds user\'s quota!'));
+ return;
+ }
+
+ $mimetype = MediaFile::getUploadedFileType($_FILES[$param]['tmp_name']);
+
+ $filename = null;
+
+ if (isset($mimetype)) {
+
+ $basename = basename($_FILES[$param]['name']);
+ $filename = File::filename($user->getProfile(), $basename, $mimetype);
+ $filepath = File::path($filename);
+
+ $result = move_uploaded_file($_FILES[$param]['tmp_name'], $filepath);
+
+ if (!$result) {
+ throw new ClientException(_('File could not be moved to destination directory.'));
+ return;
+ }
+
+ } else {
+ throw new ClientException(_('Could not determine file\'s mime-type!'));
+ return;
+ }
+
+ return new MediaFile($user, $filename, $mimetype);
+ }
+
+ static function fromFilehandle($fh, $user) {
+
+ $stream = stream_get_meta_data($fh);
+
+ if (!MediaFile::respectsQuota($user, filesize($stream['uri']))) {
+
+ // Should never actually get here
+
+ throw new ClientException(_('File exceeds user\'s quota!'));
+ return;
+ }
+
+ $mimetype = MediaFile::getUploadedFileType($fh);
+
+ $filename = null;
+
+ if (isset($mimetype)) {
+
+ $filename = File::filename($user->getProfile(), "email", $mimetype);
+
+ $filepath = File::path($filename);
+
+ $result = copy($stream['uri'], $filepath) && chmod($filepath, 0664);
+
+ if (!$result) {
+ throw new ClientException(_('File could not be moved to destination directory.' .
+ $stream['uri'] . ' ' . $filepath));
+ }
+ } else {
+ throw new ClientException(_('Could not determine file\'s mime-type!'));
+ return;
+ }
+
+ return new MediaFile($user, $filename, $mimetype);
+ }
+
+ static function getUploadedFileType($f) {
+ require_once 'MIME/Type.php';
+
+ $cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
+ $cmd = common_config('attachments', 'filecommand');
+
+ $filetype = null;
+
+ if (is_string($f)) {
+
+ // assuming a filename
+
+ $filetype = MIME_Type::autoDetect($f);
+ } else {
+
+ // assuming a filehandle
+
+ $stream = stream_get_meta_data($f);
+ $filetype = MIME_Type::autoDetect($stream['uri']);
+ }
+
+ if (in_array($filetype, common_config('attachments', 'supported'))) {
+ return $filetype;
+ }
+ $media = MIME_Type::getMedia($filetype);
+ if ('application' !== $media) {
+ $hint = sprintf(_(' Try using another %s format.'), $media);
+ } else {
+ $hint = '';
+ }
+ throw new ClientException(sprintf(
+ _('%s is not a supported filetype on this server.'), $filetype) . $hint);
+ }
+
+ static function respectsQuota($user, $filesize)
+ {
+ $file = new File;
+ $result = $file->isRespectsQuota($user, $filesize);
+ if ($result === true) {
+ return true;
+ } else {
+ throw new ClientException($result);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/lib/messageform.php b/lib/messageform.php
index 6431bfdcc..e25ebfa08 100644
--- a/lib/messageform.php
+++ b/lib/messageform.php
@@ -140,12 +140,19 @@ class MessageForm extends Form
'rows' => 4,
'name' => 'content'),
($this->content) ? $this->content : '');
- $this->out->elementStart('dl', 'form_note');
- $this->out->element('dt', null, _('Available characters'));
- $this->out->element('dd', array('id' => 'notice_text-count'),
- '140');
- $this->out->elementEnd('dl');
+ $contentLimit = Message::maxContent();
+
+ $this->out->element('script', array('type' => 'text/javascript'),
+ 'maxLength = ' . $contentLimit . ';');
+
+ if ($contentLimit > 0) {
+ $this->out->elementStart('dl', 'form_note');
+ $this->out->element('dt', null, _('Available characters'));
+ $this->out->element('dd', array('id' => 'notice_text-count'),
+ $contentLimit);
+ $this->out->elementEnd('dl');
+ }
}
/**
diff --git a/lib/noticeform.php b/lib/noticeform.php
index 350e37db8..9864d15eb 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -90,7 +90,7 @@ class NoticeForm extends Form
$this->action = $action;
$this->content = $content;
$this->inreplyto = $inreplyto;
-
+
if ($user) {
$this->user = $user;
} else {
@@ -124,7 +124,6 @@ class NoticeForm extends Form
return common_local_url('newnotice');
}
-
/**
* Legend of the Form
*
@@ -135,7 +134,6 @@ class NoticeForm extends Form
$this->out->element('legend', null, _('Send a notice'));
}
-
/**
* Data elements
*
@@ -144,31 +142,44 @@ class NoticeForm extends Form
function formData()
{
- $this->out->element('label', array('for' => 'notice_data-text'),
- sprintf(_('What\'s up, %s?'), $this->user->nickname));
- // XXX: vary by defined max size
- $this->out->element('textarea', array('id' => 'notice_data-text',
- 'cols' => 35,
- 'rows' => 4,
- 'name' => 'status_textarea'),
- ($this->content) ? $this->content : '');
- $this->out->elementStart('dl', 'form_note');
- $this->out->element('dt', null, _('Available characters'));
- $this->out->element('dd', array('id' => 'notice_text-count'),
- '140');
- $this->out->elementEnd('dl');
- if (common_config('attachments', 'uploads')) {
- $this->out->element('label', array('for' => 'notice_data-attach'),_('Attach'));
- $this->out->element('input', array('id' => 'notice_data-attach',
- 'type' => 'file',
- 'name' => 'attach',
- 'title' => _('Attach a file')));
- $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
- }
- if ($this->action) {
- $this->out->hidden('notice_return-to', $this->action, 'returnto');
+ if (Event::handle('StartShowNoticeFormData', array($this))) {
+ $this->out->element('label', array('for' => 'notice_data-text'),
+ sprintf(_('What\'s up, %s?'), $this->user->nickname));
+ // XXX: vary by defined max size
+ $this->out->element('textarea', array('id' => 'notice_data-text',
+ 'cols' => 35,
+ 'rows' => 4,
+ 'name' => 'status_textarea'),
+ ($this->content) ? $this->content : '');
+
+ $contentLimit = Notice::maxContent();
+
+ $this->out->element('script', array('type' => 'text/javascript'),
+ 'maxLength = ' . $contentLimit . ';');
+
+ if ($contentLimit > 0) {
+ $this->out->elementStart('dl', 'form_note');
+ $this->out->element('dt', null, _('Available characters'));
+ $this->out->element('dd', array('id' => 'notice_text-count'),
+ $contentLimit);
+ $this->out->elementEnd('dl');
+ }
+
+ if (common_config('attachments', 'uploads')) {
+ $this->out->element('label', array('for' => 'notice_data-attach'),_('Attach'));
+ $this->out->element('input', array('id' => 'notice_data-attach',
+ 'type' => 'file',
+ 'name' => 'attach',
+ 'title' => _('Attach a file')));
+ $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
+ }
+ if ($this->action) {
+ $this->out->hidden('notice_return-to', $this->action, 'returnto');
+ }
+ $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
+
+ Event::handle('StartShowNoticeFormData', array($this));
}
- $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
}
/**
diff --git a/lib/noticelist.php b/lib/noticelist.php
index d4cd3ff6e..8b3015cc3 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -178,9 +178,12 @@ class NoticeListItem extends Widget
function show()
{
$this->showStart();
- $this->showNotice();
- $this->showNoticeInfo();
- $this->showNoticeOptions();
+ if (Event::handle('StartShowNoticeItem', array($this))) {
+ $this->showNotice();
+ $this->showNoticeInfo();
+ $this->showNoticeOptions();
+ Event::handle('EndShowNoticeItem', array($this));
+ }
$this->showEnd();
}
@@ -196,6 +199,7 @@ class NoticeListItem extends Widget
{
$this->out->elementStart('div', 'entry-content');
$this->showNoticeLink();
+ $this->showNoticeLocation();
$this->showNoticeSource();
$this->showContext();
$this->out->elementEnd('div');
@@ -367,6 +371,44 @@ class NoticeListItem extends Widget
}
/**
+ * show the notice location
+ *
+ * shows the notice location in the correct language.
+ *
+ * If an URL is available, makes a link. Otherwise, just a span.
+ *
+ * @return void
+ */
+
+ function showNoticeLocation()
+ {
+ $id = $this->notice->id;
+
+ $location = $this->notice->getLocation();
+
+ if (empty($location)) {
+ return;
+ }
+
+ $name = $location->getName();
+
+ if (empty($name)) {
+ // XXX: Could be a translation issue. Fall back to... something?
+ return;
+ }
+
+ $url = $location->getUrl();
+
+ if (empty($url)) {
+ $this->out->element('span', array('class' => 'location'), $name);
+ } else {
+ $this->out->element('a', array('class' => 'location',
+ 'href' => $url),
+ $name);
+ }
+ }
+
+ /**
* Show the source of the notice
*
* Either the name (and link) of the API client that posted the notice,
@@ -469,7 +511,10 @@ class NoticeListItem extends Widget
function showDeleteLink()
{
$user = common_current_user();
- if ($user && $this->notice->profile_id == $user->id) {
+
+ if (!empty($user) &&
+ ($this->notice->profile_id == $user->id || $user->hasRight(Right::deleteOthersNotice))) {
+
$deleteurl = common_local_url('deletenotice',
array('notice' => $this->notice->id));
$this->out->element('a', array('href' => $deleteurl,
diff --git a/lib/oauthstore.php b/lib/oauthstore.php
index 6db07b20f..d617a7df7 100644
--- a/lib/oauthstore.php
+++ b/lib/oauthstore.php
@@ -19,13 +19,12 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/omb.php');
+require_once 'libomb/datastore.php';
class StatusNetOAuthDataStore extends OAuthDataStore
{
// We keep a record of who's contacted us
-
function lookup_consumer($consumer_key)
{
$con = Consumer::staticGet('consumer_key', $consumer_key);
@@ -44,7 +43,9 @@ class StatusNetOAuthDataStore extends OAuthDataStore
function lookup_token($consumer, $token_type, $token_key)
{
$t = new Token();
- $t->consumer_key = $consumer->key;
+ if (!is_null($consumer)) {
+ $t->consumer_key = $consumer->key;
+ }
$t->tok = $token_key;
$t->type = ($token_type == 'access') ? 1 : 0;
if ($t->find(true)) {
@@ -154,4 +155,345 @@ class StatusNetOAuthDataStore extends OAuthDataStore
{
return $this->new_access_token($consumer);
}
+
+ /**
+ * Revoke specified OAuth token
+ *
+ * Revokes the authorization token specified by $token_key.
+ * Throws exceptions in case of error.
+ *
+ * @param string $token_key The token to be revoked
+ *
+ * @access public
+ **/
+ public function revoke_token($token_key) {
+ $rt = new Token();
+ $rt->tok = $token_key;
+ $rt->type = 0;
+ $rt->state = 0;
+ if (!$rt->find(true)) {
+ throw new Exception('Tried to revoke unknown token');
+ }
+ if (!$rt->delete()) {
+ throw new Exception('Failed to delete revoked token');
+ }
+ }
+
+ /**
+ * Authorize specified OAuth token
+ *
+ * Authorizes the authorization token specified by $token_key.
+ * Throws exceptions in case of error.
+ *
+ * @param string $token_key The token to be authorized
+ *
+ * @access public
+ **/
+ public function authorize_token($token_key) {
+ $rt = new Token();
+ $rt->tok = $token_key;
+ $rt->type = 0;
+ $rt->state = 0;
+ if (!$rt->find(true)) {
+ throw new Exception('Tried to authorize unknown token');
+ }
+ $orig_rt = clone($rt);
+ $rt->state = 1; # Authorized but not used
+ if (!$rt->update($orig_rt)) {
+ throw new Exception('Failed to authorize token');
+ }
+ }
+
+ /**
+ * Get profile by identifying URI
+ *
+ * Returns an OMB_Profile object representing the OMB profile identified by
+ * $identifier_uri.
+ * Returns null if there is no such OMB profile.
+ * Throws exceptions in case of other error.
+ *
+ * @param string $identifier_uri The OMB identifier URI specifying the
+ * requested profile
+ *
+ * @access public
+ *
+ * @return OMB_Profile The corresponding profile
+ **/
+ public function getProfile($identifier_uri) {
+ /* getProfile is only used for remote profiles by libomb.
+ TODO: Make it work with local ones anyway. */
+ $remote = Remote_profile::staticGet('uri', $identifier_uri);
+ if (!$remote) throw new Exception('No such remote profile');
+ $profile = Profile::staticGet('id', $remote->id);
+ if (!$profile) throw new Exception('No profile for remote user');
+
+ require_once INSTALLDIR.'/lib/omb.php';
+ return profile_to_omb_profile($identifier_uri, $profile);
+ }
+
+ /**
+ * Save passed profile
+ *
+ * Stores the OMB profile $profile. Overwrites an existing entry.
+ * Throws exceptions in case of error.
+ *
+ * @param OMB_Profile $profile The OMB profile which should be saved
+ *
+ * @access public
+ **/
+ public function saveProfile($omb_profile) {
+ if (common_profile_url($omb_profile->getNickname()) ==
+ $omb_profile->getProfileURL()) {
+ throw new Exception('Not implemented');
+ } else {
+ $remote = Remote_profile::staticGet('uri', $omb_profile->getIdentifierURI());
+
+ if ($remote) {
+ $exists = true;
+ $profile = Profile::staticGet($remote->id);
+ $orig_remote = clone($remote);
+ $orig_profile = clone($profile);
+ # XXX: compare current postNotice and updateProfile URLs to the ones
+ # stored in the DB to avoid (possibly...) above attack
+ } else {
+ $exists = false;
+ $remote = new Remote_profile();
+ $remote->uri = $omb_profile->getIdentifierURI();
+ $profile = new Profile();
+ }
+
+ $profile->nickname = $omb_profile->getNickname();
+ $profile->profileurl = $omb_profile->getProfileURL();
+
+ $fullname = $omb_profile->getFullname();
+ $profile->fullname = is_null($fullname) ? '' : $fullname;
+ $homepage = $omb_profile->getHomepage();
+ $profile->homepage = is_null($homepage) ? '' : $homepage;
+ $bio = $omb_profile->getBio();
+ $profile->bio = is_null($bio) ? '' : $bio;
+ $location = $omb_profile->getLocation();
+ $profile->location = is_null($location) ? '' : $location;
+
+ if ($exists) {
+ $profile->update($orig_profile);
+ } else {
+ $profile->created = DB_DataObject_Cast::dateTime(); # current time
+ $id = $profile->insert();
+ if (!$id) {
+ throw new Exception(_('Error inserting new profile'));
+ }
+ $remote->id = $id;
+ }
+
+ $avatar_url = $omb_profile->getAvatarURL();
+ if ($avatar_url) {
+ if (!$this->add_avatar($profile, $avatar_url)) {
+ throw new Exception(_('Error inserting avatar'));
+ }
+ } else {
+ $avatar = $profile->getOriginalAvatar();
+ if($avatar) $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ if($avatar) $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
+ if($avatar) $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
+ if($avatar) $avatar->delete();
+ }
+
+ if ($exists) {
+ if (!$remote->update($orig_remote)) {
+ throw new Exception(_('Error updating remote profile'));
+ }
+ } else {
+ $remote->created = DB_DataObject_Cast::dateTime(); # current time
+ if (!$remote->insert()) {
+ throw new Exception(_('Error inserting remote profile'));
+ }
+ }
+ }
+ }
+
+ function add_avatar($profile, $url)
+ {
+ $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
+ copy($url, $temp_filename);
+ $imagefile = new ImageFile($profile->id, $temp_filename);
+ $filename = Avatar::filename($profile->id,
+ image_type_to_extension($imagefile->type),
+ null,
+ common_timestamp());
+ rename($temp_filename, Avatar::path($filename));
+ return $profile->setOriginal($filename);
+ }
+
+ /**
+ * Save passed notice
+ *
+ * Stores the OMB notice $notice. The datastore may change the passed notice.
+ * This might by neccessary for URIs depending on a database key. Note that
+ * it is the user’s duty to present a mechanism for his OMB_Datastore to
+ * appropriately change his OMB_Notice.
+ * Throws exceptions in case of error.
+ *
+ * @param OMB_Notice $notice The OMB notice which should be saved
+ *
+ * @access public
+ **/
+ public function saveNotice(&$omb_notice) {
+ if (Notice::staticGet('uri', $omb_notice->getIdentifierURI())) {
+ throw new Exception(_('Duplicate notice'));
+ }
+ $author_uri = $omb_notice->getAuthor()->getIdentifierURI();
+ common_log(LOG_DEBUG, $author_uri, __FILE__);
+ $author = Remote_profile::staticGet('uri', $author_uri);
+ if (!$author) {
+ $author = User::staticGet('uri', $author_uri);
+ }
+ if (!$author) {
+ throw new Exception('No such user');
+ }
+
+ common_log(LOG_DEBUG, print_r($author, true), __FILE__);
+
+ $notice = Notice::saveNew($author->id,
+ $omb_notice->getContent(),
+ 'omb',
+ false,
+ null,
+ $omb_notice->getIdentifierURI());
+
+ common_broadcast_notice($notice, true);
+ }
+
+ /**
+ * Get subscriptions of a given profile
+ *
+ * Returns an array containing subscription informations for the specified
+ * profile. Every array entry should in turn be an array with keys
+ * 'uri´: The identifier URI of the subscriber
+ * 'token´: The subscribe token
+ * 'secret´: The secret token
+ * Throws exceptions in case of error.
+ *
+ * @param string $subscribed_user_uri The OMB identifier URI specifying the
+ * subscribed profile
+ *
+ * @access public
+ *
+ * @return mixed An array containing the subscriptions or 0 if no
+ * subscription has been found.
+ **/
+ public function getSubscriptions($subscribed_user_uri) {
+ $sub = new Subscription();
+
+ $user = $this->_getAnyProfile($subscribed_user_uri);
+
+ $sub->subscribed = $user->id;
+
+ if (!$sub->find(true)) {
+ return 0;
+ }
+
+ /* Since we do not use OMB_Service_Provider’s action methods, there
+ is no need to actually return the subscriptions. */
+ return 1;
+ }
+
+ private function _getAnyProfile($uri)
+ {
+ $user = Remote_profile::staticGet('uri', $uri);
+ if (!$user) {
+ $user = User::staticGet('uri', $uri);
+ }
+ if (!$user) {
+ throw new Exception('No such user');
+ }
+ return $user;
+ }
+
+ /**
+ * Delete a subscription
+ *
+ * Deletes the subscription from $subscriber_uri to $subscribed_user_uri.
+ * Throws exceptions in case of error.
+ *
+ * @param string $subscriber_uri The OMB identifier URI specifying the
+ * subscribing profile
+ *
+ * @param string $subscribed_user_uri The OMB identifier URI specifying the
+ * subscribed profile
+ *
+ * @access public
+ **/
+ public function deleteSubscription($subscriber_uri, $subscribed_user_uri)
+ {
+ $sub = new Subscription();
+
+ $subscribed = $this->_getAnyProfile($subscribed_user_uri);
+ $subscriber = $this->_getAnyProfile($subscriber_uri);
+
+ $sub->subscribed = $subscribed->id;
+ $sub->subscriber = $subscriber->id;
+
+ $sub->delete();
+ }
+
+ /**
+ * Save a subscription
+ *
+ * Saves the subscription from $subscriber_uri to $subscribed_user_uri.
+ * Throws exceptions in case of error.
+ *
+ * @param string $subscriber_uri The OMB identifier URI specifying
+ * the subscribing profile
+ *
+ * @param string $subscribed_user_uri The OMB identifier URI specifying
+ * the subscribed profile
+ * @param OAuthToken $token The access token
+ *
+ * @access public
+ **/
+ public function saveSubscription($subscriber_uri, $subscribed_user_uri,
+ $token)
+ {
+ $sub = new Subscription();
+
+ $subscribed = $this->_getAnyProfile($subscribed_user_uri);
+ $subscriber = $this->_getAnyProfile($subscriber_uri);
+
+ $sub->subscribed = $subscribed->id;
+ $sub->subscriber = $subscriber->id;
+
+ $sub_exists = $sub->find(true);
+
+ if ($sub_exists) {
+ $orig_sub = clone($sub);
+ } else {
+ $sub->created = DB_DataObject_Cast::dateTime();
+ }
+
+ $sub->token = $token->key;
+ $sub->secret = $token->secret;
+
+ if ($sub_exists) {
+ $result = $sub->update($orig_sub);
+ } else {
+ $result = $sub->insert();
+ }
+
+ if (!$result) {
+ common_log_db_error($sub, ($sub_exists) ? 'UPDATE' : 'INSERT', __FILE__);
+ throw new Exception(_('Couldn\'t insert new subscription.'));
+ return;
+ }
+
+ /* Notify user, if necessary. */
+
+ if ($subscribed instanceof User) {
+ mail_subscribe_notify_profile($subscribed,
+ Profile::staticGet($subscriber->id));
+ }
+ }
}
+?>
diff --git a/lib/omb.php b/lib/omb.php
index 7dca760c6..cd6d6e1b2 100644
--- a/lib/omb.php
+++ b/lib/omb.php
@@ -19,34 +19,18 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once('OAuth.php');
-require_once(INSTALLDIR.'/lib/oauthstore.php');
-
-require_once(INSTALLDIR.'/classes/Consumer.php');
-require_once(INSTALLDIR.'/classes/Nonce.php');
-require_once(INSTALLDIR.'/classes/Token.php');
-
-require_once('Auth/Yadis/Yadis.php');
-
-define('OAUTH_NAMESPACE', 'http://oauth.net/core/1.0/');
-define('OMB_NAMESPACE', 'http://openmicroblogging.org/protocol/0.1');
-define('OMB_VERSION_01', 'http://openmicroblogging.org/protocol/0.1');
-define('OAUTH_DISCOVERY', 'http://oauth.net/discovery/1.0');
-
-define('OMB_ENDPOINT_UPDATEPROFILE', OMB_NAMESPACE.'/updateProfile');
-define('OMB_ENDPOINT_POSTNOTICE', OMB_NAMESPACE.'/postNotice');
-define('OAUTH_ENDPOINT_REQUEST', OAUTH_NAMESPACE.'endpoint/request');
-define('OAUTH_ENDPOINT_AUTHORIZE', OAUTH_NAMESPACE.'endpoint/authorize');
-define('OAUTH_ENDPOINT_ACCESS', OAUTH_NAMESPACE.'endpoint/access');
-define('OAUTH_ENDPOINT_RESOURCE', OAUTH_NAMESPACE.'endpoint/resource');
-define('OAUTH_AUTH_HEADER', OAUTH_NAMESPACE.'parameters/auth-header');
-define('OAUTH_POST_BODY', OAUTH_NAMESPACE.'parameters/post-body');
-define('OAUTH_HMAC_SHA1', OAUTH_NAMESPACE.'signature/HMAC-SHA1');
+require_once INSTALLDIR.'/lib/oauthstore.php';
+require_once 'OAuth.php';
+require_once 'libomb/constants.php';
+require_once 'libomb/service_consumer.php';
+require_once 'libomb/notice.php';
+require_once 'libomb/profile.php';
+require_once 'Auth/Yadis/Yadis.php';
function omb_oauth_consumer()
{
static $con = null;
- if (!$con) {
+ if (is_null($con)) {
$con = new OAuthConsumer(common_root_url(), '');
}
return $con;
@@ -55,7 +39,7 @@ function omb_oauth_consumer()
function omb_oauth_server()
{
static $server = null;
- if (!$server) {
+ if (is_null($server)) {
$server = new OAuthServer(omb_oauth_datastore());
$server->add_signature_method(omb_hmac_sha1());
}
@@ -65,7 +49,7 @@ function omb_oauth_server()
function omb_oauth_datastore()
{
static $store = null;
- if (!$store) {
+ if (is_null($store)) {
$store = new StatusNetOAuthDataStore();
}
return $store;
@@ -74,57 +58,18 @@ function omb_oauth_datastore()
function omb_hmac_sha1()
{
static $hmac_method = null;
- if (!$hmac_method) {
+ if (is_null($hmac_method)) {
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
}
return $hmac_method;
}
-function omb_get_services($xrd, $type)
+function omb_broadcast_notice($notice)
{
- return $xrd->services(array(omb_service_filter($type)));
-}
-
-function omb_service_filter($type)
-{
- return create_function('$s',
- 'return omb_match_service($s, \''.$type.'\');');
-}
-
-function omb_match_service($service, $type)
-{
- return in_array($type, $service->getTypes());
-}
-
-function omb_service_uri($service)
-{
- if (!$service) {
- return null;
- }
- $uris = $service->getURIs();
- if (!$uris) {
- return null;
- }
- return $uris[0];
-}
-
-function omb_local_id($service)
-{
- if (!$service) {
- return null;
- }
- $els = $service->getElements('xrd:LocalID');
- if (!$els) {
- return null;
- }
- $el = $els[0];
- return $service->parser->content($el);
-}
-function omb_broadcast_remote_subscribers($notice)
-{
+ $omb_notice = notice_to_omb_notice($notice);
- # First, get remote users subscribed to this profile
+ /* Get remote users subscribed to this profile. */
$rp = new Remote_profile();
$rp->query('SELECT postnoticeurl, token, secret ' .
@@ -135,170 +80,148 @@ function omb_broadcast_remote_subscribers($notice)
$posted = array();
while ($rp->fetch()) {
- if (!array_key_exists($rp->postnoticeurl, $posted)) {
- common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl);
- if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) {
- common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl);
- $posted[$rp->postnoticeurl] = true;
- } else {
- common_log(LOG_DEBUG, 'Failed posting to ' . $rp->postnoticeurl);
- }
+ if (isset($posted[$rp->postnoticeurl])) {
+ /* We already posted to this url. */
+ continue;
}
- }
-
- $rp->free();
- unset($rp);
+ common_debug('Posting to ' . $rp->postnoticeurl, __FILE__);
+
+ /* Post notice. */
+ $service = new StatusNet_OMB_Service_Consumer(
+ array(OMB_ENDPOINT_POSTNOTICE => $rp->postnoticeurl));
+ try {
+ $service->setToken($rp->token, $rp->secret);
+ $service->postNotice($omb_notice);
+ } catch (Exception $e) {
+ common_log(LOG_ERR, 'Failed posting to ' . $rp->postnoticeurl);
+ common_log(LOG_ERR, 'Error status '.$e);
+ continue;
+ }
+ $posted[$rp->postnoticeurl] = true;
- return true;
-}
+ common_debug('Finished to ' . $rp->postnoticeurl, __FILE__);
+ }
-function omb_post_notice($notice, $remote_profile, $subscription)
-{
- return omb_post_notice_keys($notice, $remote_profile->postnoticeurl, $subscription->token, $subscription->secret);
+ return;
}
-function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret)
+function omb_broadcast_profile($profile)
{
- $user = User::staticGet('id', $notice->profile_id);
+ $user = User::staticGet('id', $profile->id);
if (!$user) {
return false;
}
- $con = omb_oauth_consumer();
+ $profile = $user->getProfile();
- $token = new OAuthToken($tk, $secret);
-
- $url = $postnoticeurl;
- $parsed = parse_url($url);
- $params = array();
- parse_str($parsed['query'], $params);
-
- $req = OAuthRequest::from_consumer_and_token($con, $token,
- 'POST', $url, $params);
-
- $req->set_parameter('omb_version', OMB_VERSION_01);
- $req->set_parameter('omb_listenee', $user->uri);
- $req->set_parameter('omb_notice', $notice->uri);
- $req->set_parameter('omb_notice_content', $notice->content);
- $req->set_parameter('omb_notice_url', common_local_url('shownotice',
- array('notice' =>
- $notice->id)));
- $req->set_parameter('omb_notice_license', common_config('license', 'url'));
+ $omb_profile = profile_to_omb_profile($user->uri, $profile, true);
- $user->free();
- unset($user);
+ /* Get remote users subscribed to this profile. */
+ $rp = new Remote_profile();
- $req->sign_request(omb_hmac_sha1(), $con, $token);
+ $rp->query('SELECT updateprofileurl, token, secret ' .
+ 'FROM subscription JOIN remote_profile ' .
+ 'ON subscription.subscriber = remote_profile.id ' .
+ 'WHERE subscription.subscribed = ' . $profile->id . ' ');
- # We re-use this tool's fetcher, since it's pretty good
+ $posted = array();
- $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
+ while ($rp->fetch()) {
+ if (isset($posted[$rp->updateprofileurl])) {
+ /* We already posted to this url. */
+ continue;
+ }
+ common_debug('Posting to ' . $rp->updateprofileurl, __FILE__);
+
+ /* Update profile. */
+ $service = new StatusNet_OMB_Service_Consumer(
+ array(OMB_ENDPOINT_UPDATEPROFILE => $rp->updateprofileurl));
+ try {
+ $service->setToken($rp->token, $rp->secret);
+ $service->updateProfile($omb_profile);
+ } catch (Exception $e) {
+ common_log(LOG_ERR, 'Failed posting to ' . $rp->updateprofileurl);
+ common_log(LOG_ERR, 'Error status '.$e);
+ continue;
+ }
+ $posted[$rp->updateprofileurl] = true;
- if (!$fetcher) {
- common_log(LOG_WARNING, 'Failed to initialize Yadis fetcher.', __FILE__);
- return false;
+ common_debug('Finished to ' . $rp->updateprofileurl, __FILE__);
}
- $result = $fetcher->post($req->get_normalized_http_url(),
- $req->to_postdata(),
- array('User-Agent: StatusNet/' . STATUSNET_VERSION));
-
- if ($result->status == 403) { # not authorized, don't send again
- common_debug('403 result, deleting subscription', __FILE__);
- # FIXME: figure out how to delete this
- # $subscription->delete();
- return false;
- } else if ($result->status != 200) {
- common_debug('Error status '.$result->status, __FILE__);
- return false;
- } else { # success!
- parse_str($result->body, $return);
- if ($return['omb_version'] == OMB_VERSION_01) {
- return true;
- } else {
- return false;
- }
- }
+ return;
}
-function omb_broadcast_profile($profile)
-{
- # First, get remote users subscribed to this profile
- # XXX: use a join here rather than looping through results
- $sub = new Subscription();
- $sub->subscribed = $profile->id;
- if ($sub->find()) {
- $updated = array();
- while ($sub->fetch()) {
- $rp = Remote_profile::staticGet('id', $sub->subscriber);
- if ($rp) {
- if (!array_key_exists($rp->updateprofileurl, $updated)) {
- if (omb_update_profile($profile, $rp, $sub)) {
- $updated[$rp->updateprofileurl] = true;
- }
- }
- }
- }
+class StatusNet_OMB_Service_Consumer extends OMB_Service_Consumer {
+ public function __construct($urls)
+ {
+ $this->services = $urls;
+ $this->datastore = omb_oauth_datastore();
+ $this->oauth_consumer = omb_oauth_consumer();
+ $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
}
+
}
-function omb_update_profile($profile, $remote_profile, $subscription)
+function profile_to_omb_profile($uri, $profile, $force = false)
{
- $user = User::staticGet($profile->id);
- $con = omb_oauth_consumer();
- $token = new OAuthToken($subscription->token, $subscription->secret);
- $url = $remote_profile->updateprofileurl;
- $parsed = parse_url($url);
- $params = array();
- parse_str($parsed['query'], $params);
- $req = OAuthRequest::from_consumer_and_token($con, $token,
- "POST", $url, $params);
- $req->set_parameter('omb_version', OMB_VERSION_01);
- $req->set_parameter('omb_listenee', $user->uri);
- $req->set_parameter('omb_listenee_profile', common_profile_url($profile->nickname));
- $req->set_parameter('omb_listenee_nickname', $profile->nickname);
-
- # We use blanks to force emptying any existing values in these optional fields
-
- $req->set_parameter('omb_listenee_fullname',
- ($profile->fullname) ? $profile->fullname : '');
- $req->set_parameter('omb_listenee_homepage',
- ($profile->homepage) ? $profile->homepage : '');
- $req->set_parameter('omb_listenee_bio',
- ($profile->bio) ? $profile->bio : '');
- $req->set_parameter('omb_listenee_location',
- ($profile->location) ? $profile->location : '');
+ $omb_profile = new OMB_Profile($uri);
+ $omb_profile->setNickname($profile->nickname);
+ $omb_profile->setLicenseURL(common_config('license', 'url'));
+ if (!is_null($profile->fullname)) {
+ $omb_profile->setFullname($profile->fullname);
+ } elseif ($force) {
+ $omb_profile->setFullname('');
+ }
+ if (!is_null($profile->homepage)) {
+ $omb_profile->setHomepage($profile->homepage);
+ } elseif ($force) {
+ $omb_profile->setHomepage('');
+ }
+ if (!is_null($profile->bio)) {
+ $omb_profile->setBio($profile->bio);
+ } elseif ($force) {
+ $omb_profile->setBio('');
+ }
+ if (!is_null($profile->location)) {
+ $omb_profile->setLocation($profile->location);
+ } elseif ($force) {
+ $omb_profile->setLocation('');
+ }
+ if (!is_null($profile->profileurl)) {
+ $omb_profile->setProfileURL($profile->profileurl);
+ } elseif ($force) {
+ $omb_profile->setProfileURL('');
+ }
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
- $req->set_parameter('omb_listenee_avatar',
- ($avatar) ? $avatar->url : '');
+ if ($avatar) {
+ $omb_profile->setAvatarURL($avatar->url);
+ } elseif ($force) {
+ $omb_profile->setAvatarURL('');
+ }
+ return $omb_profile;
+}
- $req->sign_request(omb_hmac_sha1(), $con, $token);
+function notice_to_omb_notice($notice)
+{
+ /* Create an OMB_Notice for $notice. */
+ $user = User::staticGet('id', $notice->profile_id);
- # We re-use this tool's fetcher, since it's pretty good
+ if (!$user) {
+ return null;
+ }
- $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
+ $profile = $user->getProfile();
- $result = $fetcher->post($req->get_normalized_http_url(),
- $req->to_postdata(),
- array('User-Agent: StatusNet/' . STATUSNET_VERSION));
+ $omb_notice = new OMB_Notice(profile_to_omb_profile($user->uri, $profile),
+ $notice->uri,
+ $notice->content);
+ $omb_notice->setURL(common_local_url('shownotice', array('notice' =>
+ $notice->id)));
+ $omb_notice->setLicenseURL(common_config('license', 'url'));
- if (empty($result) || !$result) {
- common_debug("Unable to contact " . $req->get_normalized_http_url());
- } else if ($result->status == 403) { # not authorized, don't send again
- common_debug('403 result, deleting subscription', __FILE__);
- $subscription->delete();
- return false;
- } else if ($result->status != 200) {
- common_debug('Error status '.$result->status, __FILE__);
- return false;
- } else { # success!
- parse_str($result->body, $return);
- if (isset($return['omb_version']) && $return['omb_version'] === OMB_VERSION_01) {
- return true;
- } else {
- return false;
- }
- }
+ return $omb_notice;
}
+?>
diff --git a/lib/plugin.php b/lib/plugin.php
index 87d7be5a7..59bf3ba9d 100644
--- a/lib/plugin.php
+++ b/lib/plugin.php
@@ -76,4 +76,18 @@ class Plugin
{
return true;
}
+
+ /*
+ * the name of the shortener
+ * shortenerInfo associative array with additional information. One possible element is 'freeService' which can be true or false
+ * shortener array, first element is the name of the class, second element is an array to be passed as constructor parameters to the class
+ */
+ function registerUrlShortener($name, $shortenerInfo, $shortener)
+ {
+ global $_shorteners;
+ if(!is_array($_shorteners)){
+ $_shorteners=array();
+ }
+ $_shorteners[$name]=array('info'=>$shortenerInfo, 'callInfo'=>$shortener);
+ }
}
diff --git a/lib/profilelist.php b/lib/profilelist.php
index 331430b3e..5cc211e36 100644
--- a/lib/profilelist.php
+++ b/lib/profilelist.php
@@ -62,9 +62,15 @@ class ProfileList extends Widget
function show()
{
- $this->startList();
- $cnt = $this->showProfiles();
- $this->endList();
+ $cnt = 0;
+
+ if (Event::handle('StartProfileList', array($this))) {
+ $this->startList();
+ $cnt = $this->showProfiles();
+ $this->endList();
+ Event::handle('EndProfileList', array($this));
+ }
+
return $cnt;
}
@@ -117,10 +123,19 @@ class ProfileListItem extends Widget
function show()
{
- $this->startItem();
- $this->showProfile();
- $this->showActions();
- $this->endItem();
+ if (Event::handle('StartProfileListItem', array($this))) {
+ $this->startItem();
+ if (Event::handle('StartProfileListItemProfile', array($this))) {
+ $this->showProfile();
+ Event::handle('EndProfileListItemProfile', array($this));
+ }
+ if (Event::handle('StartProfileListItemActions', array($this))) {
+ $this->showActions();
+ Event::handle('EndProfileListItemActions', array($this));
+ }
+ $this->endItem();
+ Event::handle('EndProfileListItem', array($this));
+ }
}
function startItem()
@@ -132,11 +147,29 @@ class ProfileListItem extends Widget
function showProfile()
{
$this->startProfile();
- $this->showAvatar();
- $this->showFullName();
- $this->showLocation();
- $this->showHomepage();
- $this->showBio();
+ if (Event::handle('StartProfileListItemProfileElements', array($this))) {
+ if (Event::handle('StartProfileListItemAvatar', array($this))) {
+ $this->showAvatar();
+ Event::handle('EndProfileListItemAvatar', array($this));
+ }
+ if (Event::handle('StartProfileListItemFullName', array($this))) {
+ $this->showFullName();
+ Event::handle('EndProfileListItemFullName', array($this));
+ }
+ if (Event::handle('StartProfileListItemLocation', array($this))) {
+ $this->showLocation();
+ Event::handle('EndProfileListItemLocation', array($this));
+ }
+ if (Event::handle('StartProfileListItemHomepage', array($this))) {
+ $this->showHomepage();
+ Event::handle('EndProfileListItemHomepage', array($this));
+ }
+ if (Event::handle('StartProfileListItemBio', array($this))) {
+ $this->showBio();
+ Event::handle('EndProfileListItemBio', array($this));
+ }
+ Event::handle('EndProfileListItemProfileElements', array($this));
+ }
$this->endProfile();
}
@@ -225,7 +258,10 @@ class ProfileListItem extends Widget
function showActions()
{
$this->startActions();
- $this->showSubscribeButton();
+ if (Event::handle('StartProfileListItemActionElements', array($this))) {
+ $this->showSubscribeButton();
+ Event::handle('EndProfileListItemActionElements', array($this));
+ }
$this->endActions();
}
diff --git a/lib/queuehandler.php b/lib/queuehandler.php
index 8c65a97c6..cd43b1e09 100644
--- a/lib/queuehandler.php
+++ b/lib/queuehandler.php
@@ -27,6 +27,22 @@ define('CLAIM_TIMEOUT', 1200);
define('QUEUE_HANDLER_MISS_IDLE', 10);
define('QUEUE_HANDLER_HIT_IDLE', 0);
+/**
+ * Base class for queue handlers.
+ *
+ * As extensions of the Daemon class, each queue handler has the ability
+ * to launch itself in the background, at which point it'll pass control
+ * to the configured QueueManager class to poll for updates.
+ *
+ * Subclasses must override at least the following methods:
+ * - transport
+ * - start
+ * - finish
+ * - handle_notice
+ *
+ * Some subclasses will also want to override the idle handler:
+ * - idle
+ */
class QueueHandler extends Daemon
{
@@ -39,6 +55,14 @@ class QueueHandler extends Daemon
}
}
+ /**
+ * How many seconds a polling-based queue manager should wait between
+ * checks for new items to handle.
+ *
+ * Defaults to 60 seconds; override to speed up or slow down.
+ *
+ * @return int timeout in seconds
+ */
function timeout()
{
return 60;
@@ -54,24 +78,69 @@ class QueueHandler extends Daemon
return strtolower($this->class_name().'.'.$this->get_id());
}
+ /**
+ * Return transport keyword which identifies items this queue handler
+ * services; must be defined for all subclasses.
+ *
+ * Must be 8 characters or less to fit in the queue_item database.
+ * ex "email", "jabber", "sms", "irc", ...
+ *
+ * @return string
+ */
function transport()
{
return null;
}
+ /**
+ * Initialization, run when the queue handler starts.
+ * If this function indicates failure, the handler run will be aborted.
+ *
+ * @fixme run() will abort if this doesn't return true,
+ * but some subclasses don't bother.
+ * @return boolean true on success, false on failure
+ */
function start()
{
}
+ /**
+ * Cleanup, run when the queue handler ends.
+ * If this function indicates failure, a warning will be logged.
+ *
+ * @fixme run() will throw warnings if this doesn't return true,
+ * but many subclasses don't bother.
+ * @return boolean true on success, false on failure
+ */
function finish()
{
}
+ /**
+ * Here's the meat of your queue handler -- you're handed a Notice
+ * object, which you may do as you will with.
+ *
+ * If this function indicates failure, a warning will be logged
+ * and the item is placed back in the queue to be re-run.
+ *
+ * @param Notice $notice
+ * @return boolean true on success, false on failure
+ */
function handle_notice($notice)
{
return true;
}
+ /**
+ * Setup and start of run loop for this queue handler as a daemon.
+ * Most of the heavy lifting is passed on to the QueueManager's service()
+ * method, which passes control back to our handle_notice() method for
+ * each notice that comes in on the queue.
+ *
+ * Most of the time this won't need to be overridden in a subclass.
+ *
+ * @return boolean true on success, false on failure
+ */
function run()
{
if (!$this->start()) {
@@ -100,6 +169,14 @@ class QueueHandler extends Daemon
return true;
}
+ /**
+ * Called by QueueHandler after each handled item or empty polling cycle.
+ * This is a good time to e.g. service your XMPP connection.
+ *
+ * Doesn't need to be overridden if there's no maintenance to do.
+ *
+ * @param int $timeout seconds to sleep if there's nothing to do
+ */
function idle($timeout=0)
{
if ($timeout > 0) {
diff --git a/lib/right.php b/lib/right.php
new file mode 100644
index 000000000..4e0096d46
--- /dev/null
+++ b/lib/right.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Class for user rights
+ *
+ * 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 Authorization
+ * @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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * class for rights
+ *
+ * Mostly for holding the rights constants
+ *
+ * @category Authorization
+ * @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 Right
+{
+ const deleteOthersNotice = 'deleteothersnotice';
+}
+
diff --git a/lib/router.php b/lib/router.php
index 5529e60ac..2fd255fe6 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -50,8 +50,7 @@ class Router
var $m = null;
static $inst = null;
static $bare = array('requesttoken', 'accesstoken', 'userauthorization',
- 'postnotice', 'updateprofile', 'finishremotesubscribe',
- 'finishopenidlogin', 'finishaddopenid');
+ 'postnotice', 'updateprofile', 'finishremotesubscribe');
static function get()
{
@@ -72,447 +71,566 @@ class Router
{
$m = Net_URL_Mapper::getInstance();
- // In the "root"
+ if (Event::handle('StartInitializeRouter', array(&$m))) {
- $m->connect('', array('action' => 'public'));
- $m->connect('rss', array('action' => 'publicrss'));
- $m->connect('xrds', array('action' => 'publicxrds'));
- $m->connect('featuredrss', array('action' => 'featuredrss'));
- $m->connect('favoritedrss', array('action' => 'favoritedrss'));
- $m->connect('opensearch/people', array('action' => 'opensearch',
- 'type' => 'people'));
- $m->connect('opensearch/notice', array('action' => 'opensearch',
- 'type' => 'notice'));
+ // In the "root"
- // docs
+ $m->connect('', array('action' => 'public'));
+ $m->connect('rss', array('action' => 'publicrss'));
+ $m->connect('featuredrss', array('action' => 'featuredrss'));
+ $m->connect('favoritedrss', array('action' => 'favoritedrss'));
+ $m->connect('opensearch/people', array('action' => 'opensearch',
+ 'type' => 'people'));
+ $m->connect('opensearch/notice', array('action' => 'opensearch',
+ 'type' => 'notice'));
- $m->connect('doc/:title', array('action' => 'doc'));
+ // docs
- // Twitter
+ $m->connect('doc/:title', array('action' => 'doc'));
- $m->connect('twitter/authorization', array('action' => 'twitterauthorization'));
+ // main stuff is repetitive
- // facebook
+ $main = array('login', 'logout', 'register', 'subscribe',
+ 'unsubscribe', 'confirmaddress', 'recoverpassword',
+ 'invite', 'favor', 'disfavor', 'sup',
+ 'block', 'unblock', 'subedit',
+ 'groupblock', 'groupunblock');
- $m->connect('facebook', array('action' => 'facebookhome'));
- $m->connect('facebook/index.php', array('action' => 'facebookhome'));
- $m->connect('facebook/settings.php', array('action' => 'facebooksettings'));
- $m->connect('facebook/invite.php', array('action' => 'facebookinvite'));
- $m->connect('facebook/remove', array('action' => 'facebookremove'));
+ foreach ($main as $a) {
+ $m->connect('main/'.$a, array('action' => $a));
+ }
- // main stuff is repetitive
+ $m->connect('main/sup/:seconds', array('action' => 'sup'),
+ array('seconds' => '[0-9]+'));
- $main = array('login', 'logout', 'register', 'subscribe',
- 'unsubscribe', 'confirmaddress', 'recoverpassword',
- 'invite', 'favor', 'disfavor', 'sup',
- 'block', 'unblock', 'subedit',
- 'groupblock', 'groupunblock');
+ $m->connect('main/tagother/:id', array('action' => 'tagother'));
- foreach ($main as $a) {
- $m->connect('main/'.$a, array('action' => $a));
- }
-
- $m->connect('main/sup/:seconds', array('action' => 'sup'),
- array('seconds' => '[0-9]+'));
-
- $m->connect('main/tagother/:id', array('action' => 'tagother'));
+ $m->connect('main/oembed',
+ array('action' => 'oembed'));
- $m->connect('main/oembed',
- array('action' => 'oembed'));
+ // these take a code
- // these take a code
+ foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
+ $m->connect('main/'.$c.'/:code', array('action' => $c));
+ }
- foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
- $m->connect('main/'.$c.'/:code', array('action' => $c));
- }
+ // exceptional
- // exceptional
+ $m->connect('main/remote', array('action' => 'remotesubscribe'));
+ $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+'));
- $m->connect('main/openid', array('action' => 'openidlogin'));
- $m->connect('main/remote', array('action' => 'remotesubscribe'));
- $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+'));
+ foreach (Router::$bare as $action) {
+ $m->connect('index.php?action=' . $action, array('action' => $action));
+ }
- foreach (Router::$bare as $action) {
- $m->connect('index.php?action=' . $action, array('action' => $action));
- }
+ // settings
- // settings
+ foreach (array('profile', 'avatar', 'password', 'im',
+ 'email', 'sms', 'userdesign', 'other') as $s) {
+ $m->connect('settings/'.$s, array('action' => $s.'settings'));
+ }
- foreach (array('profile', 'avatar', 'password', 'openid', 'im',
- 'email', 'sms', 'twitter', 'userdesign', 'other') as $s) {
- $m->connect('settings/'.$s, array('action' => $s.'settings'));
- }
+ // search
- // search
+ foreach (array('group', 'people', 'notice') as $s) {
+ $m->connect('search/'.$s, array('action' => $s.'search'));
+ $m->connect('search/'.$s.'?q=:q',
+ array('action' => $s.'search'),
+ array('q' => '.+'));
+ }
- foreach (array('group', 'people', 'notice') as $s) {
- $m->connect('search/'.$s, array('action' => $s.'search'));
- $m->connect('search/'.$s.'?q=:q',
- array('action' => $s.'search'),
+ // The second of these is needed to make the link work correctly
+ // when inserted into the page. The first is needed to match the
+ // route on the way in. Seems to be another Net_URL_Mapper bug to me.
+ $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
+ $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),
array('q' => '.+'));
- }
- // The second of these is needed to make the link work correctly
- // when inserted into the page. The first is needed to match the
- // route on the way in. Seems to be another Net_URL_Mapper bug to me.
- $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
- $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),
- array('q' => '.+'));
-
- $m->connect('attachment/:attachment',
- array('action' => 'attachment'),
- array('attachment' => '[0-9]+'));
-
- $m->connect('attachment/:attachment/ajax',
- array('action' => 'attachment_ajax'),
- array('attachment' => '[0-9]+'));
-
- $m->connect('attachment/:attachment/thumbnail',
- array('action' => 'attachment_thumbnail'),
- array('attachment' => '[0-9]+'));
-
- $m->connect('notice/new', array('action' => 'newnotice'));
- $m->connect('notice/new?replyto=:replyto',
- array('action' => 'newnotice'),
- array('replyto' => '[A-Za-z0-9_-]+'));
- $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
- array('action' => 'newnotice'),
- array('replyto' => '[A-Za-z0-9_-]+'),
- array('inreplyto' => '[0-9]+'));
-
- $m->connect('notice/:notice/file',
- array('action' => 'file'),
- array('notice' => '[0-9]+'));
-
- $m->connect('notice/:notice',
- array('action' => 'shownotice'),
- array('notice' => '[0-9]+'));
- $m->connect('notice/delete', array('action' => 'deletenotice'));
- $m->connect('notice/delete/:notice',
- array('action' => 'deletenotice'),
- array('notice' => '[0-9]+'));
-
- // conversation
-
- $m->connect('conversation/:id',
- array('action' => 'conversation'),
- array('id' => '[0-9]+'));
-
- $m->connect('message/new', array('action' => 'newmessage'));
- $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+'));
- $m->connect('message/:message',
- array('action' => 'showmessage'),
- array('message' => '[0-9]+'));
-
- $m->connect('user/:id',
- array('action' => 'userbyid'),
- array('id' => '[0-9]+'));
-
- $m->connect('tags/', array('action' => 'publictagcloud'));
- $m->connect('tag/', array('action' => 'publictagcloud'));
- $m->connect('tags', array('action' => 'publictagcloud'));
- $m->connect('tag', array('action' => 'publictagcloud'));
- $m->connect('tag/:tag/rss',
- array('action' => 'tagrss'),
- array('tag' => '[a-zA-Z0-9]+'));
- $m->connect('tag/:tag',
- array('action' => 'tag'),
- array('tag' => '[\pL\pN_\-\.]{1,64}'));
-
- $m->connect('peopletag/:tag',
- array('action' => 'peopletag'),
- array('tag' => '[a-zA-Z0-9]+'));
-
- $m->connect('featured/', array('action' => 'featured'));
- $m->connect('featured', array('action' => 'featured'));
- $m->connect('favorited/', array('action' => 'favorited'));
- $m->connect('favorited', array('action' => 'favorited'));
-
- // groups
-
- $m->connect('group/new', array('action' => 'newgroup'));
-
- foreach (array('edit', 'join', 'leave') as $v) {
- $m->connect('group/:nickname/'.$v,
- array('action' => $v.'group'),
+ $m->connect('attachment/:attachment',
+ array('action' => 'attachment'),
+ array('attachment' => '[0-9]+'));
+
+ $m->connect('attachment/:attachment/ajax',
+ array('action' => 'attachment_ajax'),
+ array('attachment' => '[0-9]+'));
+
+ $m->connect('attachment/:attachment/thumbnail',
+ array('action' => 'attachment_thumbnail'),
+ array('attachment' => '[0-9]+'));
+
+ $m->connect('notice/new', array('action' => 'newnotice'));
+ $m->connect('notice/new?replyto=:replyto',
+ array('action' => 'newnotice'),
+ array('replyto' => '[A-Za-z0-9_-]+'));
+ $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
+ array('action' => 'newnotice'),
+ array('replyto' => '[A-Za-z0-9_-]+'),
+ array('inreplyto' => '[0-9]+'));
+
+ $m->connect('notice/:notice/file',
+ array('action' => 'file'),
+ array('notice' => '[0-9]+'));
+
+ $m->connect('notice/:notice',
+ array('action' => 'shownotice'),
+ array('notice' => '[0-9]+'));
+ $m->connect('notice/delete', array('action' => 'deletenotice'));
+ $m->connect('notice/delete/:notice',
+ array('action' => 'deletenotice'),
+ array('notice' => '[0-9]+'));
+
+ $m->connect('bookmarklet/new', array('action' => 'bookmarklet'));
+
+ // conversation
+
+ $m->connect('conversation/:id',
+ array('action' => 'conversation'),
+ array('id' => '[0-9]+'));
+
+ $m->connect('message/new', array('action' => 'newmessage'));
+ $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+'));
+ $m->connect('message/:message',
+ array('action' => 'showmessage'),
+ array('message' => '[0-9]+'));
+
+ $m->connect('user/:id',
+ array('action' => 'userbyid'),
+ array('id' => '[0-9]+'));
+
+ $m->connect('tags/', array('action' => 'publictagcloud'));
+ $m->connect('tag/', array('action' => 'publictagcloud'));
+ $m->connect('tags', array('action' => 'publictagcloud'));
+ $m->connect('tag', array('action' => 'publictagcloud'));
+ $m->connect('tag/:tag/rss',
+ array('action' => 'tagrss'),
+ array('tag' => '[a-zA-Z0-9]+'));
+ $m->connect('tag/:tag',
+ array('action' => 'tag'),
+ array('tag' => '[\pL\pN_\-\.]{1,64}'));
+
+ $m->connect('peopletag/:tag',
+ array('action' => 'peopletag'),
+ array('tag' => '[a-zA-Z0-9]+'));
+
+ $m->connect('featured/', array('action' => 'featured'));
+ $m->connect('featured', array('action' => 'featured'));
+ $m->connect('favorited/', array('action' => 'favorited'));
+ $m->connect('favorited', array('action' => 'favorited'));
+
+ // groups
+
+ $m->connect('group/new', array('action' => 'newgroup'));
+
+ foreach (array('edit', 'join', 'leave') as $v) {
+ $m->connect('group/:nickname/'.$v,
+ array('action' => $v.'group'),
+ array('nickname' => '[a-zA-Z0-9]+'));
+ }
+
+ foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
+ $m->connect('group/:nickname/'.$n,
+ array('action' => 'group'.$n),
+ array('nickname' => '[a-zA-Z0-9]+'));
+ }
+
+ $m->connect('group/:nickname/foaf',
+ array('action' => 'foafgroup'),
array('nickname' => '[a-zA-Z0-9]+'));
- }
- foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
- $m->connect('group/:nickname/'.$n,
- array('action' => 'group'.$n),
+ $m->connect('group/:nickname/blocked',
+ array('action' => 'blockedfromgroup'),
array('nickname' => '[a-zA-Z0-9]+'));
- }
-
- $m->connect('group/:nickname/blocked',
- array('action' => 'blockedfromgroup'),
- array('nickname' => '[a-zA-Z0-9]+'));
-
- $m->connect('group/:nickname/makeadmin',
- array('action' => 'makeadmin'),
- array('nickname' => '[a-zA-Z0-9]+'));
-
- $m->connect('group/:id/id',
- array('action' => 'groupbyid'),
- array('id' => '[0-9]+'));
- $m->connect('group/:nickname',
- array('action' => 'showgroup'),
- array('nickname' => '[a-zA-Z0-9]+'));
-
- $m->connect('group/', array('action' => 'groups'));
- $m->connect('group', array('action' => 'groups'));
- $m->connect('groups/', array('action' => 'groups'));
- $m->connect('groups', array('action' => 'groups'));
-
- // Twitter-compatible API
-
- // statuses API
-
- $m->connect('api/statuses/:method',
- array('action' => 'api',
- 'apiaction' => 'statuses'),
- array('method' => '(public_timeline|home_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?'));
-
- $m->connect('api/statuses/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'statuses'),
- array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
-
- // users
-
- $m->connect('api/users/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'users'),
- array('method' => 'show(\.(xml|json))?'));
+ $m->connect('group/:nickname/makeadmin',
+ array('action' => 'makeadmin'),
+ array('nickname' => '[a-zA-Z0-9]+'));
- $m->connect('api/users/:method',
- array('action' => 'api',
- 'apiaction' => 'users'),
- array('method' => 'show(\.(xml|json))?'));
+ $m->connect('group/:id/id',
+ array('action' => 'groupbyid'),
+ array('id' => '[0-9]+'));
- // direct messages
+ $m->connect('group/:nickname',
+ array('action' => 'showgroup'),
+ array('nickname' => '[a-zA-Z0-9]+'));
- foreach (array('xml', 'json') as $e) {
- $m->connect('api/direct_messages/new.'.$e,
+ $m->connect('group/', array('action' => 'groups'));
+ $m->connect('group', array('action' => 'groups'));
+ $m->connect('groups/', array('action' => 'groups'));
+ $m->connect('groups', array('action' => 'groups'));
+
+ // Twitter-compatible API
+
+ // statuses API
+
+ $m->connect('api/statuses/public_timeline.:format',
+ array('action' => 'ApiTimelinePublic',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/friends_timeline.:format',
+ array('action' => 'ApiTimelineFriends',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/friends_timeline/:id.:format',
+ array('action' => 'ApiTimelineFriends',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json|rss|atom)'));
+ $m->connect('api/statuses/home_timeline.:format',
+ array('action' => 'ApiTimelineFriends',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/home_timeline/:id.:format',
+ array('action' => 'ApiTimelineFriends',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/user_timeline.:format',
+ array('action' => 'ApiTimelineUser',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/user_timeline/:id.:format',
+ array('action' => 'ApiTimelineUser',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/mentions.:format',
+ array('action' => 'ApiTimelineMentions',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/mentions/:id.:format',
+ array('action' => 'ApiTimelineMentions',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/replies.:format',
+ array('action' => 'ApiTimelineMentions',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/replies/:id.:format',
+ array('action' => 'ApiTimelineMentions',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/friends.:format',
+ array('action' => 'ApiUserFriends',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/friends/:id.:format',
+ array('action' => 'ApiUserFriends',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/followers.:format',
+ array('action' => 'ApiUserFollowers',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/followers/:id.:format',
+ array('action' => 'ApiUserFollowers',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/show.:format',
+ array('action' => 'ApiStatusesShow',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/show/:id.:format',
+ array('action' => 'ApiStatusesShow',
+ 'id' => '[0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/update.:format',
+ array('action' => 'ApiStatusesUpdate',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/destroy.:format',
+ array('action' => 'ApiStatusesDestroy',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/destroy/:id.:format',
+ array('action' => 'ApiStatusesDestroy',
+ 'id' => '[0-9]+',
+ 'format' => '(xml|json)'));
+
+ // users
+
+ $m->connect('api/users/show/:id.:format',
+ array('action' => 'ApiUserShow',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/users/:method',
array('action' => 'api',
- 'apiaction' => 'direct_messages',
- 'method' => 'create.'.$e));
- }
+ 'apiaction' => 'users'),
+ array('method' => 'show(\.(xml|json))?'));
- foreach (array('xml', 'json', 'rss', 'atom') as $e) {
- $m->connect('api/direct_messages.'.$e,
- array('action' => 'api',
- 'apiaction' => 'direct_messages',
- 'method' => 'direct_messages.'.$e));
- }
+ // direct messages
- foreach (array('xml', 'json', 'rss', 'atom') as $e) {
- $m->connect('api/direct_messages/sent.'.$e,
- array('action' => 'api',
- 'apiaction' => 'direct_messages',
- 'method' => 'sent.'.$e));
- }
+ $m->connect('api/direct_messages.:format',
+ array('action' => 'ApiDirectMessage',
+ 'format' => '(xml|json|rss|atom)'));
- $m->connect('api/direct_messages/destroy/:argument',
- array('action' => 'api',
- 'apiaction' => 'direct_messages'));
+ $m->connect('api/direct_messages/sent.:format',
+ array('action' => 'ApiDirectMessage',
+ 'format' => '(xml|json|rss|atom)',
+ 'sent' => true));
- // friendships
+ $m->connect('api/direct_messages/new.:format',
+ array('action' => 'ApiDirectMessageNew',
+ 'format' => '(xml|json)'));
- $m->connect('api/friendships/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'friendships'),
- array('method' => '(create|destroy)'));
+ // friendships
- $m->connect('api/friendships/:method',
- array('action' => 'api',
- 'apiaction' => 'friendships'),
- array('method' => '(show|exists)(\.(xml|json))'));
+ $m->connect('api/friendships/show.:format',
+ array('action' => 'ApiFriendshipsShow',
+ 'format' => '(xml|json)'));
- // Social graph
+ $m->connect('api/friendships/exists.:format',
+ array('action' => 'ApiFriendshipsExists',
+ 'format' => '(xml|json)'));
- $m->connect('api/friends/ids/:argument',
- array('action' => 'api',
- 'apiaction' => 'statuses',
- 'method' => 'friendsIDs'));
+ $m->connect('api/friendships/create.:format',
+ array('action' => 'ApiFriendshipsCreate',
+ 'format' => '(xml|json)'));
- foreach (array('xml', 'json') as $e) {
- $m->connect('api/friends/ids.'.$e,
- array('action' => 'api',
- 'apiaction' => 'statuses',
- 'method' => 'friendsIDs.'.$e));
- }
+ $m->connect('api/friendships/destroy.:format',
+ array('action' => 'ApiFriendshipsDestroy',
+ 'format' => '(xml|json)'));
- $m->connect('api/followers/ids/:argument',
- array('action' => 'api',
- 'apiaction' => 'statuses',
- 'method' => 'followersIDs'));
+ $m->connect('api/friendships/create/:id.:format',
+ array('action' => 'ApiFriendshipsCreate',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
- foreach (array('xml', 'json') as $e) {
- $m->connect('api/followers/ids.'.$e,
- array('action' => 'api',
- 'apiaction' => 'statuses',
- 'method' => 'followersIDs.'.$e));
- }
+ $m->connect('api/friendships/destroy/:id.:format',
+ array('action' => 'ApiFriendshipsDestroy',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
- // account
+ // Social graph
- $m->connect('api/account/:method',
- array('action' => 'api',
- 'apiaction' => 'account'));
+ $m->connect('api/friends/ids/:id.:format',
+ array('action' => 'apiFriends',
+ 'ids_only' => true));
- // favorites
+ $m->connect('api/followers/ids/:id.:format',
+ array('action' => 'apiFollowers',
+ 'ids_only' => true));
- $m->connect('api/favorites/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'favorites',
- array('method' => '(create|destroy)')));
+ $m->connect('api/friends/ids.:format',
+ array('action' => 'apiFriends',
+ 'ids_only' => true));
- $m->connect('api/favorites/:argument',
- array('action' => 'api',
- 'apiaction' => 'favorites',
- 'method' => 'favorites'));
+ $m->connect('api/followers/ids.:format',
+ array('action' => 'apiFollowers',
+ 'ids_only' => true));
- foreach (array('xml', 'json', 'rss', 'atom') as $e) {
- $m->connect('api/favorites.'.$e,
- array('action' => 'api',
- 'apiaction' => 'favorites',
- 'method' => 'favorites.'.$e));
- }
+ // account
- // notifications
+ $m->connect('api/account/verify_credentials.:format',
+ array('action' => 'ApiAccountVerifyCredentials'));
- $m->connect('api/notifications/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'favorites'));
+ // special case where verify_credentials is called w/out a format
- // blocks
+ $m->connect('api/account/verify_credentials',
+ array('action' => 'ApiAccountVerifyCredentials'));
- $m->connect('api/blocks/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'blocks'));
+ $m->connect('api/account/rate_limit_status.:format',
+ array('action' => 'ApiAccountRateLimitStatus'));
- // help
+ // favorites
- $m->connect('api/help/:method',
- array('action' => 'api',
- 'apiaction' => 'help'));
+ $m->connect('api/favorites.:format',
+ array('action' => 'ApiTimelineFavorites',
+ 'format' => '(xml|json|rss|atom)'));
- // statusnet
+ $m->connect('api/favorites/:id.:format',
+ array('action' => 'ApiTimelineFavorites',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xmljson|rss|atom)'));
- $m->connect('api/statusnet/:method',
- array('action' => 'api',
- 'apiaction' => 'statusnet'));
+ $m->connect('api/favorites/create/:id.:format',
+ array('action' => 'ApiFavoriteCreate',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
- // For older methods, we provide "laconica" base action
+ $m->connect('api/favorites/destroy/:id.:format',
+ array('action' => 'ApiFavoriteDestroy',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
- $m->connect('api/laconica/:method',
- array('action' => 'api',
- 'apiaction' => 'statusnet'));
+ // notifications
- // Groups and tags are newer than 0.8.1 so no backward-compatibility
- // necessary
+ $m->connect('api/notifications/:method/:argument',
+ array('action' => 'api',
+ 'apiaction' => 'favorites'));
- // Groups
- //'list' has to be handled differently, as php will not allow a method to be named 'list'
- $m->connect('api/statusnet/groups/list/:argument',
- array('action' => 'api',
- 'method' => 'list_groups',
- 'apiaction' => 'groups'));
+ // blocks
- foreach (array('xml', 'json', 'rss', 'atom') as $e) {
- $m->connect('api/statusnet/groups/list.' . $e,
- array('action' => 'api',
- 'method' => 'list_groups.' . $e,
- 'apiaction' => 'groups'));
- }
+ $m->connect('api/blocks/create/:id.:format',
+ array('action' => 'ApiBlockCreate',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/blocks/destroy/:id.:format',
+ array('action' => 'ApiBlockDestroy',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+ // help
+
+ $m->connect('api/help/test.:format',
+ array('action' => 'ApiHelpTest',
+ 'format' => '(xml|json)'));
- $m->connect('api/statusnet/groups/:method',
- array('action' => 'api',
- 'apiaction' => 'statuses'),
- array('method' => '(list_all|)(\.(atom|rss|xml|json))?'));
-
- $m->connect('api/statuses/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'statuses'),
- array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
-
- $m->connect('api/statusnet/groups/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'groups'));
-
- $m->connect('api/statusnet/groups/:method',
- array('action' => 'api',
- 'apiaction' => 'groups'));
-
- // Tags
- $m->connect('api/statusnet/tags/:method/:argument',
- array('action' => 'api',
- 'apiaction' => 'tags'));
-
- $m->connect('api/statusnet/tags/:method',
- array('action' => 'api',
- 'apiaction' => 'tags'));
-
- // search
- $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
- $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
- $m->connect('api/trends.json', array('action' => 'twitapitrends'));
-
- // user stuff
-
- foreach (array('subscriptions', 'subscribers',
- 'nudge', 'xrds', 'all', 'foaf',
- 'replies', 'inbox', 'outbox', 'microsummary') as $a) {
- $m->connect(':nickname/'.$a,
- array('action' => $a),
+ // statusnet
+
+ $m->connect('api/statusnet/version.:format',
+ array('action' => 'ApiStatusnetVersion',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/config.:format',
+ array('action' => 'ApiStatusnetConfig',
+ 'format' => '(xml|json)'));
+
+ // For older methods, we provide "laconica" base action
+
+ $m->connect('api/laconica/version.:format',
+ array('action' => 'ApiStatusnetVersion',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/laconica/config.:format',
+ array('action' => 'ApiStatusnetConfig',
+ 'format' => '(xml|json)'));
+
+ // Groups and tags are newer than 0.8.1 so no backward-compatibility
+ // necessary
+
+ // Groups
+ //'list' has to be handled differently, as php will not allow a method to be named 'list'
+
+ $m->connect('api/statusnet/groups/timeline/:id.:format',
+ array('action' => 'ApiTimelineGroup',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xmljson|rss|atom)'));
+
+ $m->connect('api/statusnet/groups/show.:format',
+ array('action' => 'ApiGroupShow',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/show/:id.:format',
+ array('action' => 'ApiGroupShow',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/join.:format',
+ array('action' => 'ApiGroupJoin',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/join/:id.:format',
+ array('action' => 'ApiGroupJoin',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/leave.:format',
+ array('action' => 'ApiGroupLeave',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/leave/:id.:format',
+ array('action' => 'ApiGroupLeave',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/is_member.:format',
+ array('action' => 'ApiGroupIsMember',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/list.:format',
+ array('action' => 'ApiGroupList',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statusnet/groups/list/:id.:format',
+ array('action' => 'ApiGroupList',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statusnet/groups/list_all.:format',
+ array('action' => 'ApiGroupListAll',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statusnet/groups/membership.:format',
+ array('action' => 'ApiGroupMembership',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/membership/:id.:format',
+ array('action' => 'ApiGroupMembership',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statusnet/groups/create.:format',
+ array('action' => 'ApiGroupCreate',
+ 'format' => '(xml|json)'));
+ // Tags
+ $m->connect('api/statusnet/tags/timeline/:tag.:format',
+ array('action' => 'ApiTimelineTag',
+ 'format' => '(xmljson|rss|atom)'));
+
+ // search
+ $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
+ $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
+ $m->connect('api/trends.json', array('action' => 'twitapitrends'));
+
+ // user stuff
+
+ foreach (array('subscriptions', 'subscribers',
+ 'nudge', 'all', 'foaf', 'xrds',
+ 'replies', 'inbox', 'outbox', 'microsummary') as $a) {
+ $m->connect(':nickname/'.$a,
+ array('action' => $a),
+ array('nickname' => '[a-zA-Z0-9]{1,64}'));
+ }
+
+ foreach (array('subscriptions', 'subscribers') as $a) {
+ $m->connect(':nickname/'.$a.'/:tag',
+ array('action' => $a),
+ array('tag' => '[a-zA-Z0-9]+',
+ 'nickname' => '[a-zA-Z0-9]{1,64}'));
+ }
+
+ foreach (array('rss', 'groups') as $a) {
+ $m->connect(':nickname/'.$a,
+ array('action' => 'user'.$a),
+ array('nickname' => '[a-zA-Z0-9]{1,64}'));
+ }
+
+ foreach (array('all', 'replies', 'favorites') as $a) {
+ $m->connect(':nickname/'.$a.'/rss',
+ array('action' => $a.'rss'),
+ array('nickname' => '[a-zA-Z0-9]{1,64}'));
+ }
+
+ $m->connect(':nickname/favorites',
+ array('action' => 'showfavorites'),
array('nickname' => '[a-zA-Z0-9]{1,64}'));
- }
- foreach (array('subscriptions', 'subscribers') as $a) {
- $m->connect(':nickname/'.$a.'/:tag',
- array('action' => $a),
- array('tag' => '[a-zA-Z0-9]+',
+ $m->connect(':nickname/avatar/:size',
+ array('action' => 'avatarbynickname'),
+ array('size' => '(original|96|48|24)',
'nickname' => '[a-zA-Z0-9]{1,64}'));
- }
-
- foreach (array('rss', 'groups') as $a) {
- $m->connect(':nickname/'.$a,
- array('action' => 'user'.$a),
- array('nickname' => '[a-zA-Z0-9]{1,64}'));
- }
- foreach (array('all', 'replies', 'favorites') as $a) {
- $m->connect(':nickname/'.$a.'/rss',
- array('action' => $a.'rss'),
- array('nickname' => '[a-zA-Z0-9]{1,64}'));
- }
+ $m->connect(':nickname/tag/:tag/rss',
+ array('action' => 'userrss'),
+ array('nickname' => '[a-zA-Z0-9]{1,64}'),
+ array('tag' => '[a-zA-Z0-9]+'));
- $m->connect(':nickname/favorites',
- array('action' => 'showfavorites'),
- array('nickname' => '[a-zA-Z0-9]{1,64}'));
+ $m->connect(':nickname/tag/:tag',
+ array('action' => 'showstream'),
+ array('nickname' => '[a-zA-Z0-9]{1,64}'),
+ array('tag' => '[a-zA-Z0-9]+'));
- $m->connect(':nickname/avatar/:size',
- array('action' => 'avatarbynickname'),
- array('size' => '(original|96|48|24)',
- 'nickname' => '[a-zA-Z0-9]{1,64}'));
-
- $m->connect(':nickname/tag/:tag/rss',
- array('action' => 'userrss'),
- array('nickname' => '[a-zA-Z0-9]{1,64}'),
- array('tag' => '[a-zA-Z0-9]+'));
-
- $m->connect(':nickname/tag/:tag',
- array('action' => 'showstream'),
- array('nickname' => '[a-zA-Z0-9]{1,64}'),
- array('tag' => '[a-zA-Z0-9]+'));
-
- $m->connect(':nickname',
- array('action' => 'showstream'),
- array('nickname' => '[a-zA-Z0-9]{1,64}'));
+ $m->connect(':nickname',
+ array('action' => 'showstream'),
+ array('nickname' => '[a-zA-Z0-9]{1,64}'));
- Event::handle('RouterInitialized', array($m));
+ Event::handle('RouterInitialized', array($m));
+ }
return $m;
}
diff --git a/lib/rssaction.php b/lib/rssaction.php
index 60611e48d..faf6bec7d 100644
--- a/lib/rssaction.php
+++ b/lib/rssaction.php
@@ -78,25 +78,12 @@ class Rss10Action extends Action
function prepare($args)
{
parent::prepare($args);
+
$this->limit = (int) $this->trimmed('limit');
+
if ($this->limit == 0) {
$this->limit = DEFAULT_RSS_LIMIT;
}
- return true;
- }
-
- /**
- * Handle a request
- *
- * @param array $args Arguments from $_REQUEST
- *
- * @return void
- */
-
- function handle($args)
- {
- // Parent handling, including cache check
- parent::handle($args);
if (common_config('site', 'private')) {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
@@ -122,8 +109,21 @@ class Rss10Action extends Action
}
}
- // Get the list of notices
- $this->notices = $this->getNotices($this->limit);
+ return true;
+ }
+
+ /**
+ * Handle a request
+ *
+ * @param array $args Arguments from $_REQUEST
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ // Parent handling, including cache check
+ parent::handle($args);
$this->showRss();
}
@@ -140,7 +140,7 @@ class Rss10Action extends Action
}
/**
- * Get the notices to output in this stream
+ * Get the notices to output in this stream.
*
* @return array an array of Notice objects sorted in reverse chron
*/
@@ -258,26 +258,27 @@ class Rss10Action extends Action
$attachments = $notice->attachments();
if($attachments){
foreach($attachments as $attachment){
- if ($attachment->isEnclosure()) {
+ $enclosure=$attachment->getEnclosure();
+ if ($enclosure) {
// DO NOT move xmlns declaration to root element. Making it
// the default namespace here improves compatibility with
// real-world feed readers.
$attribs = array(
- 'rdf:resource' => $attachment->url,
- 'url' => $attachment->url,
+ 'rdf:resource' => $enclosure->url,
+ 'url' => $enclosure->url,
'xmlns' => 'http://purl.oclc.org/net/rss_2.0/enc#'
);
- if ($attachment->title) {
- $attribs['dc:title'] = $attachment->title;
+ if ($enclosure->title) {
+ $attribs['dc:title'] = $enclosure->title;
}
- if ($attachment->modified) {
- $attribs['dc:date'] = common_date_w3dtf($attachment->modified);
+ if ($enclosure->modified) {
+ $attribs['dc:date'] = common_date_w3dtf($enclosure->modified);
}
- if ($attachment->size) {
- $attribs['length'] = $attachment->size;
+ if ($enclosure->size) {
+ $attribs['length'] = $enclosure->size;
}
- if ($attachment->mimetype) {
- $attribs['type'] = $attachment->mimetype;
+ if ($enclosure->mimetype) {
+ $attribs['type'] = $enclosure->mimetype;
}
$this->element('enclosure', $attribs);
}
diff --git a/lib/schema.php b/lib/schema.php
new file mode 100644
index 000000000..1e0c1f3e9
--- /dev/null
+++ b/lib/schema.php
@@ -0,0 +1,680 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Database schema utilities
+ *
+ * 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 Database
+ * @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);
+}
+
+/**
+ * Class representing the database schema
+ *
+ * A class representing the database schema. Can be used to
+ * manipulate the schema -- especially for plugins and upgrade
+ * utilities.
+ *
+ * @category Database
+ * @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 Schema
+{
+ static $_single = null;
+ protected $conn = null;
+
+ /**
+ * Constructor. Only run once for singleton object.
+ */
+
+ protected function __construct()
+ {
+ // XXX: there should be an easier way to do this.
+ $user = new User();
+
+ $this->conn = $user->getDatabaseConnection();
+
+ $user->free();
+
+ unset($user);
+ }
+
+ /**
+ * Main public entry point. Use this to get
+ * the singleton object.
+ *
+ * @return Schema the (single) Schema object
+ */
+
+ static function get()
+ {
+ if (empty(self::$_single)) {
+ self::$_single = new Schema();
+ }
+ return self::$_single;
+ }
+
+ /**
+ * Returns a TableDef object for the table
+ * in the schema with the given name.
+ *
+ * Throws an exception if the table is not found.
+ *
+ * @param string $name Name of the table to get
+ *
+ * @return TableDef tabledef for that table.
+ */
+
+ public function getTableDef($name)
+ {
+ $res =& $this->conn->query('DESCRIBE ' . $name);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ $td = new TableDef();
+
+ $td->name = $name;
+ $td->columns = array();
+
+ $row = array();
+
+ while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+
+ $cd = new ColumnDef();
+
+ $cd->name = $row['Field'];
+
+ $packed = $row['Type'];
+
+ if (preg_match('/^(\w+)\((\d+)\)$/', $packed, $match)) {
+ $cd->type = $match[1];
+ $cd->size = $match[2];
+ } else {
+ $cd->type = $packed;
+ }
+
+ $cd->nullable = ($row['Null'] == 'YES') ? true : false;
+ $cd->key = $row['Key'];
+ $cd->default = $row['Default'];
+ $cd->extra = $row['Extra'];
+
+ $td->columns[] = $cd;
+ }
+
+ return $td;
+ }
+
+ /**
+ * Gets a ColumnDef object for a single column.
+ *
+ * Throws an exception if the table is not found.
+ *
+ * @param string $table name of the table
+ * @param string $column name of the column
+ *
+ * @return ColumnDef definition of the column or null
+ * if not found.
+ */
+
+ public function getColumnDef($table, $column)
+ {
+ $td = $this->getTableDef($table);
+
+ foreach ($td->columns as $cd) {
+ if ($cd->name == $column) {
+ return $cd;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates a table with the given names and columns.
+ *
+ * @param string $name Name of the table
+ * @param array $columns Array of ColumnDef objects
+ * for new table.
+ *
+ * @return boolean success flag
+ */
+
+ public function createTable($name, $columns)
+ {
+ $uniques = array();
+ $primary = array();
+ $indices = array();
+
+ $sql = "CREATE TABLE $name (\n";
+
+ for ($i = 0; $i < count($columns); $i++) {
+
+ $cd =& $columns[$i];
+
+ if ($i > 0) {
+ $sql .= ",\n";
+ }
+
+ $sql .= $this->_columnSql($cd);
+
+ switch ($cd->key) {
+ case 'UNI':
+ $uniques[] = $cd->name;
+ break;
+ case 'PRI':
+ $primary[] = $cd->name;
+ break;
+ case 'MUL':
+ $indices[] = $cd->name;
+ break;
+ }
+ }
+
+ if (count($primary) > 0) { // it really should be...
+ $sql .= ",\nconstraint primary key (" . implode(',', $primary) . ")";
+ }
+
+ foreach ($uniques as $u) {
+ $sql .= ",\nunique index {$name}_{$u}_idx ($u)";
+ }
+
+ foreach ($indices as $i) {
+ $sql .= ",\nindex {$name}_{$i}_idx ($i)";
+ }
+
+ $sql .= "); ";
+
+ $res =& $this->conn->query($sql);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Drops a table from the schema
+ *
+ * Throws an exception if the table is not found.
+ *
+ * @param string $name Name of the table to drop
+ *
+ * @return boolean success flag
+ */
+
+ public function dropTable($name)
+ {
+ $res =& $this->conn->query("DROP TABLE $name");
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Adds an index to a table.
+ *
+ * If no name is provided, a name will be made up based
+ * on the table name and column names.
+ *
+ * Throws an exception on database error, esp. if the table
+ * does not exist.
+ *
+ * @param string $table Name of the table
+ * @param array $columnNames Name of columns to index
+ * @param string $name (Optional) name of the index
+ *
+ * @return boolean success flag
+ */
+
+ public function createIndex($table, $columnNames, $name=null)
+ {
+ if (!is_array($columnNames)) {
+ $columnNames = array($columnNames);
+ }
+
+ if (empty($name)) {
+ $name = "$table_".implode("_", $columnNames)."_idx";
+ }
+
+ $res =& $this->conn->query("ALTER TABLE $table ".
+ "ADD INDEX $name (".
+ implode(",", $columnNames).")");
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Drops a named index from a table.
+ *
+ * @param string $table name of the table the index is on.
+ * @param string $name name of the index
+ *
+ * @return boolean success flag
+ */
+
+ public function dropIndex($table, $name)
+ {
+ $res =& $this->conn->query("ALTER TABLE $table DROP INDEX $name");
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Adds a column to a table
+ *
+ * @param string $table name of the table
+ * @param ColumnDef $columndef Definition of the new
+ * column.
+ *
+ * @return boolean success flag
+ */
+
+ public function addColumn($table, $columndef)
+ {
+ $sql = "ALTER TABLE $table ADD COLUMN " . $this->_columnSql($columndef);
+
+ $res =& $this->conn->query($sql);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Modifies a column in the schema.
+ *
+ * The name must match an existing column and table.
+ *
+ * @param string $table name of the table
+ * @param ColumnDef $columndef new definition of the column.
+ *
+ * @return boolean success flag
+ */
+
+ public function modifyColumn($table, $columndef)
+ {
+ $sql = "ALTER TABLE $table MODIFY COLUMN " .
+ $this->_columnSql($columndef);
+
+ $res =& $this->conn->query($sql);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Drops a column from a table
+ *
+ * The name must match an existing column.
+ *
+ * @param string $table name of the table
+ * @param string $columnName name of the column to drop
+ *
+ * @return boolean success flag
+ */
+
+ public function dropColumn($table, $columnName)
+ {
+ $sql = "ALTER TABLE $table DROP COLUMN $columnName";
+
+ $res =& $this->conn->query($sql);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Ensures that a table exists with the given
+ * name and the given column definitions.
+ *
+ * If the table does not yet exist, it will
+ * create the table. If it does exist, it will
+ * alter the table to match the column definitions.
+ *
+ * @param string $tableName name of the table
+ * @param array $columns array of ColumnDef
+ * objects for the table
+ *
+ * @return boolean success flag
+ */
+
+ public function ensureTable($tableName, $columns)
+ {
+ // XXX: DB engine portability -> toilet
+
+ try {
+ $td = $this->getTableDef($tableName);
+ } catch (Exception $e) {
+ if (preg_match('/no such table/', $e->getMessage())) {
+ return $this->createTable($tableName, $columns);
+ } else {
+ throw $e;
+ }
+ }
+
+ $cur = $this->_names($td->columns);
+ $new = $this->_names($columns);
+
+ $toadd = array_diff($new, $cur);
+ $todrop = array_diff($cur, $new);
+ $same = array_intersect($new, $cur);
+ $tomod = array();
+
+ foreach ($same as $m) {
+ $curCol = $this->_byName($td->columns, $m);
+ $newCol = $this->_byName($columns, $m);
+
+ if (!$newCol->equals($curCol)) {
+ $tomod[] = $newCol->name;
+ }
+ }
+
+ if (count($toadd) + count($todrop) + count($tomod) == 0) {
+ // nothing to do
+ return true;
+ }
+
+ // For efficiency, we want this all in one
+ // query, instead of using our methods.
+
+ $phrase = array();
+
+ foreach ($toadd as $columnName) {
+ $cd = $this->_byName($columns, $columnName);
+
+ $phrase[] = 'ADD COLUMN ' . $this->_columnSql($cd);
+ }
+
+ foreach ($todrop as $columnName) {
+ $phrase[] = 'DROP COLUMN ' . $columnName;
+ }
+
+ foreach ($tomod as $columnName) {
+ $cd = $this->_byName($columns, $columnName);
+
+ $phrase[] = 'MODIFY COLUMN ' . $this->_columnSql($cd);
+ }
+
+ $sql = 'ALTER TABLE ' . $tableName . ' ' . implode(', ', $phrase);
+
+ $res =& $this->conn->query($sql);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the array of names from an array of
+ * ColumnDef objects.
+ *
+ * @param array $cds array of ColumnDef objects
+ *
+ * @return array strings for name values
+ */
+
+ private function _names($cds)
+ {
+ $names = array();
+
+ foreach ($cds as $cd) {
+ $names[] = $cd->name;
+ }
+
+ return $names;
+ }
+
+ /**
+ * Get a ColumnDef from an array matching
+ * name.
+ *
+ * @param array $cds Array of ColumnDef objects
+ * @param string $name Name of the column
+ *
+ * @return ColumnDef matching item or null if no match.
+ */
+
+ private function _byName($cds, $name)
+ {
+ foreach ($cds as $cd) {
+ if ($cd->name == $name) {
+ return $cd;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return the proper SQL for creating or
+ * altering a column.
+ *
+ * Appropriate for use in CREATE TABLE or
+ * ALTER TABLE statements.
+ *
+ * @param ColumnDef $cd column to create
+ *
+ * @return string correct SQL for that column
+ */
+
+ private function _columnSql($cd)
+ {
+ $sql = "{$cd->name} ";
+
+ if (!empty($cd->size)) {
+ $sql .= "{$cd->type}({$cd->size}) ";
+ } else {
+ $sql .= "{$cd->type} ";
+ }
+
+ if (!empty($cd->default)) {
+ $sql .= "default {$cd->default} ";
+ } else {
+ $sql .= ($cd->nullable) ? "null " : "not null ";
+ }
+
+ return $sql;
+ }
+}
+
+/**
+ * A class encapsulating the structure of a table.
+ *
+ * @category Database
+ * @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 TableDef
+{
+ /** name of the table */
+ public $name;
+ /** array of ColumnDef objects for the columns. */
+ public $columns;
+}
+
+/**
+ * A class encapsulating the structure of a column in a table.
+ *
+ * @category Database
+ * @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 ColumnDef
+{
+ /** name of the column. */
+ public $name;
+ /** type of column, e.g. 'int', 'varchar' */
+ public $type;
+ /** size of the column. */
+ public $size;
+ /** boolean flag; can it be null? */
+ public $nullable;
+ /**
+ * type of key: null = no key; 'PRI' => primary;
+ * 'UNI' => unique key; 'MUL' => multiple values.
+ */
+ public $key;
+ /** default value if any. */
+ public $default;
+ /** 'extra' stuff. Returned by MySQL, largely
+ * unused. */
+ public $extra;
+
+ /**
+ * Constructor.
+ *
+ * @param string $name name of the column
+ * @param string $type type of the column
+ * @param int $size size of the column
+ * @param boolean $nullable can this be null?
+ * @param string $key type of key
+ * @param value $default default value
+ * @param value $extra unused
+ */
+
+ function __construct($name=null, $type=null, $size=null,
+ $nullable=true, $key=null, $default=null,
+ $extra=null)
+ {
+ $this->name = strtolower($name);
+ $this->type = strtolower($type);
+ $this->size = $size+0;
+ $this->nullable = $nullable;
+ $this->key = $key;
+ $this->default = $default;
+ $this->extra = $extra;
+ }
+
+ /**
+ * Compares this columndef with another to see
+ * if they're functionally equivalent.
+ *
+ * @param ColumnDef $other column to compare
+ *
+ * @return boolean true if equivalent, otherwise false.
+ */
+
+ function equals($other)
+ {
+ return ($this->name == $other->name &&
+ $this->_typeMatch($other) &&
+ $this->_defaultMatch($other) &&
+ $this->_nullMatch($other) &&
+ $this->key == $other->key);
+ }
+
+ /**
+ * Does the type of this column match the
+ * type of the other column?
+ *
+ * Checks the type and size of a column. Tries
+ * to ignore differences between synonymous
+ * data types, like 'integer' and 'int'.
+ *
+ * @param ColumnDef $other other column to check
+ *
+ * @return boolean true if they're about equivalent
+ */
+
+ private function _typeMatch($other)
+ {
+ switch ($this->type) {
+ case 'integer':
+ case 'int':
+ return ($other->type == 'integer' ||
+ $other->type == 'int');
+ break;
+ default:
+ return ($this->type == $other->type &&
+ $this->size == $other->size);
+ }
+ }
+
+ /**
+ * Does the default behaviour of this column match
+ * the other?
+ *
+ * @param ColumnDef $other other column to check
+ *
+ * @return boolean true if defaults are effectively the same.
+ */
+
+ private function _defaultMatch($other)
+ {
+ return ((is_null($this->default) && is_null($other->default)) ||
+ ($this->default == $other->default));
+ }
+
+ /**
+ * Does the null behaviour of this column match
+ * the other?
+ *
+ * @param ColumnDef $other other column to check
+ *
+ * @return boolean true if these columns 'null' the same.
+ */
+
+ private function _nullMatch($other)
+ {
+ return ((!is_null($this->default) && !is_null($other->default) &&
+ $this->default == $other->default) ||
+ ($this->nullable == $other->nullable));
+ }
+}
diff --git a/lib/settingsaction.php b/lib/settingsaction.php
index a1f305f5b..c3669868d 100644
--- a/lib/settingsaction.php
+++ b/lib/settingsaction.php
@@ -77,9 +77,7 @@ class SettingsAction extends CurrentUserDesignAction
// _all_ our settings are important
common_set_returnto($this->selfUrl());
$user = common_current_user();
- if ($user->hasOpenID()) {
- common_redirect(common_local_url('openidlogin'), 303);
- } else {
+ if (Event::handle('RedirectToLogin', array($this, $user))) {
common_redirect(common_local_url('login'), 303);
}
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php
index 3cdad0b54..72dbc4eed 100644
--- a/lib/unqueuemanager.php
+++ b/lib/unqueuemanager.php
@@ -39,7 +39,7 @@ class UnQueueManager
case 'omb':
if ($this->_isLocal($notice)) {
require_once(INSTALLDIR.'/lib/omb.php');
- omb_broadcast_remote_subscribers($notice);
+ omb_broadcast_notice($notice);
}
break;
case 'public':
@@ -48,17 +48,6 @@ class UnQueueManager
jabber_public_notice($notice);
}
break;
- case 'twitter':
- if ($this->_isLocal($notice)) {
- broadcast_twitter($notice);
- }
- break;
- case 'facebook':
- if ($this->_isLocal($notice)) {
- require_once INSTALLDIR . '/lib/facebookutil.php';
- return facebookBroadcastNotice($notice);
- }
- break;
case 'ping':
if ($this->_isLocal($notice)) {
require_once INSTALLDIR . '/lib/ping.php';
@@ -72,8 +61,13 @@ class UnQueueManager
require_once(INSTALLDIR.'/lib/jabber.php');
jabber_broadcast_notice($notice);
break;
+ case 'plugin':
+ Event::handle('HandleQueuedNotice', array(&$notice));
+ break;
default:
- throw ServerException("UnQueueManager: Unknown queue: $type");
+ if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) {
+ throw new ServerException("UnQueueManager: Unknown queue: $queue");
+ }
}
}
diff --git a/lib/util.php b/lib/util.php
index 0052090f6..d159c583e 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -51,13 +51,23 @@ function common_init_locale($language=null)
function common_init_language()
{
mb_internal_encoding('UTF-8');
+
+ // gettext seems very picky... We first need to setlocale()
+ // to a locale which _does_ exist on the system, and _then_
+ // we can set in another locale that may not be set up
+ // (say, ga_ES for Galego/Galician) it seems to take it.
+ common_init_locale("en_US");
+
$language = common_language();
- // So we don't have to make people install the gettext locales
$locale_set = common_init_locale($language);
- bindtextdomain("statusnet", common_config('site','locale_path'));
+ setlocale(LC_CTYPE, 'C');
+
+ // So we don't have to make people install the gettext locales
+ $path = common_config('site','locale_path');
+ bindtextdomain("statusnet", $path);
bind_textdomain_codeset("statusnet", "UTF-8");
textdomain("statusnet");
- setlocale(LC_CTYPE, 'C');
+
if(!$locale_set) {
common_log(LOG_INFO, 'Language requested:' . $language . ' - locale could not be set. Perhaps that system locale is not installed.', __FILE__);
}
@@ -393,8 +403,8 @@ function common_render_content($text, $notice)
$id = $notice->profile_id;
$r = preg_replace('/(^|\s+)@(['.NICKNAME_FMT.']{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
- $r = preg_replace('/(^|\s+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
- $r = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
+ $r = preg_replace('/(^|[\s\.\,\:\;]+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
+ $r = preg_replace('/(^|[\s\.\,\:\;]+)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
return $r;
}
@@ -493,7 +503,7 @@ function callback_helper($matches, $callback, $notice_id) {
}while($original_url!=$url);
if(empty($notice_id)){
- $result = call_user_func_array($callback,$url);
+ $result = call_user_func_array($callback, array($url));
}else{
$result = call_user_func_array($callback, array(array($url,$notice_id)) );
}
@@ -522,21 +532,22 @@ function common_linkify($url) {
if(strpos($url, '@') !== false && strpos($url, ':') === false) {
//url is an email address without the mailto: protocol
- return XMLStringer::estring('a', array('href' => "mailto:$url", 'rel' => 'external'), $url);
- }
+ $canon = "mailto:$url";
+ $longurl = "mailto:$url";
+ }else{
- $canon = File_redirection::_canonUrl($url);
+ $canon = File_redirection::_canonUrl($url);
- $longurl_data = File_redirection::where($url);
- if (is_array($longurl_data)) {
- $longurl = $longurl_data['url'];
- } elseif (is_string($longurl_data)) {
- $longurl = $longurl_data;
- } else {
- throw new ServerException("Can't linkify url '$url'");
+ $longurl_data = File_redirection::where($canon);
+ if (is_array($longurl_data)) {
+ $longurl = $longurl_data['url'];
+ } elseif (is_string($longurl_data)) {
+ $longurl = $longurl_data;
+ } else {
+ throw new ServerException("Can't linkify url '$url'");
+ }
}
-
- $attrs = array('href' => $canon, 'rel' => 'external');
+ $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');
$is_attachment = false;
$attachment_id = null;
@@ -584,7 +595,8 @@ function common_linkify($url) {
function common_shorten_links($text)
{
- if (mb_strlen($text) <= 140) return $text;
+ $maxLength = Notice::maxContent();
+ if ($maxLength == 0 || mb_strlen($text) <= $maxLength) return $text;
return common_replace_urls_callback($text, array('File_redirection', 'makeShort'));
}
@@ -729,14 +741,10 @@ function common_relative_profile($sender, $nickname, $dt=null)
function common_local_url($action, $args=null, $params=null, $fragment=null)
{
- static $sensitive = array('login', 'register', 'passwordsettings',
- 'twittersettings', 'finishopenidlogin',
- 'finishaddopenid', 'api');
-
$r = Router::get();
$path = $r->build($action, $args, $params, $fragment);
- $ssl = in_array($action, $sensitive);
+ $ssl = common_is_sensitive($action);
if (common_config('site','fancy')) {
$url = common_path(mb_substr($path, 1), $ssl);
@@ -750,6 +758,19 @@ function common_local_url($action, $args=null, $params=null, $fragment=null)
return $url;
}
+function common_is_sensitive($action)
+{
+ static $sensitive = array('login', 'register', 'passwordsettings',
+ 'twittersettings', 'api');
+ $ssl = null;
+
+ if (Event::handle('SensitiveAction', array($action, &$ssl))) {
+ $ssl = in_array($action, $sensitive);
+ }
+
+ return $ssl;
+}
+
function common_path($relative, $ssl=false)
{
$pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : '';
@@ -891,10 +912,9 @@ function common_broadcast_notice($notice, $remote=false)
function common_enqueue_notice($notice)
{
static $localTransports = array('omb',
- 'twitter',
- 'facebook',
'ping');
- static $allTransports = array('sms');
+
+ static $allTransports = array('sms', 'plugin');
$transports = $allTransports;
@@ -912,11 +932,16 @@ function common_enqueue_notice($notice)
}
}
- $qm = QueueManager::get();
+ if (Event::handle('StartEnqueueNotice', array($notice, &$transports))) {
- foreach ($transports as $transport)
- {
- $qm->enqueue($notice, $transport);
+ $qm = QueueManager::get();
+
+ foreach ($transports as $transport)
+ {
+ $qm->enqueue($notice, $transport);
+ }
+
+ Event::handle('EndEnqueueNotice', array($notice, $transports));
}
return true;
@@ -1154,7 +1179,7 @@ function common_negotiate_type($cprefs, $sprefs)
}
if ('text/html' === $besttype) {
- return "text/html";
+ return "text/html; charset=utf-8";
}
return $besttype;
}
@@ -1162,7 +1187,8 @@ function common_negotiate_type($cprefs, $sprefs)
function common_config($main, $sub)
{
global $config;
- return isset($config[$main][$sub]) ? $config[$main][$sub] : false;
+ return (array_key_exists($main, $config) &&
+ array_key_exists($sub, $config[$main])) ? $config[$main][$sub] : false;
}
function common_copy_args($from)
@@ -1369,57 +1395,19 @@ function common_shorten_url($long_url)
} else {
$svc = $user->urlshorteningservice;
}
-
- $curlh = curl_init();
- curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
- curl_setopt($curlh, CURLOPT_USERAGENT, 'StatusNet');
- curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
-
- switch($svc) {
- case 'ur1.ca':
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url_service = new LilUrl;
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case '2tu.us':
- $short_url_service = new TightUrl;
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case 'ptiturl.com':
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url_service = new PtitUrl;
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case 'bit.ly':
- curl_setopt($curlh, CURLOPT_URL, 'http://bit.ly/api?method=shorten&long_url='.urlencode($long_url));
- $short_url = current(json_decode(curl_exec($curlh))->results)->hashUrl;
- break;
-
- case 'is.gd':
- curl_setopt($curlh, CURLOPT_URL, 'http://is.gd/api.php?longurl='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'snipr.com':
- curl_setopt($curlh, CURLOPT_URL, 'http://snipr.com/site/snip?r=simple&link='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'metamark.net':
- curl_setopt($curlh, CURLOPT_URL, 'http://metamark.net/api/rest/simple?long_url='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'tinyurl.com':
- curl_setopt($curlh, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- default:
- $short_url = false;
+ global $_shorteners;
+ if (!isset($_shorteners[$svc])) {
+ //the user selected service doesn't exist, so default to ur1.ca
+ $svc = 'ur1.ca';
+ }
+ if (!isset($_shorteners[$svc])) {
+ // no shortener plugins installed.
+ return $long_url;
}
- curl_close($curlh);
+ $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]);
+ $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
+ $short_url = $short_url_service->shorten($long_url);
return $short_url;
}
diff --git a/locale/bg/LC_MESSAGES/statusnet.mo b/locale/bg/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..335fe0b92
--- /dev/null
+++ b/locale/bg/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/bg_BG/LC_MESSAGES/statusnet.po b/locale/bg/LC_MESSAGES/statusnet.po
index c0bc8379f..c0bc8379f 100644
--- a/locale/bg_BG/LC_MESSAGES/statusnet.po
+++ b/locale/bg/LC_MESSAGES/statusnet.po
diff --git a/locale/bg_BG/LC_MESSAGES/statusnet.mo b/locale/bg_BG/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index 8cfa1523d..000000000
--- a/locale/bg_BG/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/ca_ES/LC_MESSAGES/statusnet.mo b/locale/ca/LC_MESSAGES/statusnet.mo
index aadf38da9..aadf38da9 100644
--- a/locale/ca_ES/LC_MESSAGES/statusnet.mo
+++ b/locale/ca/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/ca_ES/LC_MESSAGES/statusnet.po b/locale/ca/LC_MESSAGES/statusnet.po
index 44944c8ba..44944c8ba 100644
--- a/locale/ca_ES/LC_MESSAGES/statusnet.po
+++ b/locale/ca/LC_MESSAGES/statusnet.po
diff --git a/locale/cs/LC_MESSAGES/statusnet.mo b/locale/cs/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..4618fd73d
--- /dev/null
+++ b/locale/cs/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/cs_CZ/LC_MESSAGES/statusnet.po b/locale/cs/LC_MESSAGES/statusnet.po
index aee74f1af..aee74f1af 100644
--- a/locale/cs_CZ/LC_MESSAGES/statusnet.po
+++ b/locale/cs/LC_MESSAGES/statusnet.po
diff --git a/locale/cs_CZ/LC_MESSAGES/statusnet.mo b/locale/cs_CZ/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index e126daaf0..000000000
--- a/locale/cs_CZ/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/de/LC_MESSAGES/statusnet.mo b/locale/de/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..335b26715
--- /dev/null
+++ b/locale/de/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/de_DE/LC_MESSAGES/statusnet.po b/locale/de/LC_MESSAGES/statusnet.po
index ed0252879..ed0252879 100644
--- a/locale/de_DE/LC_MESSAGES/statusnet.po
+++ b/locale/de/LC_MESSAGES/statusnet.po
diff --git a/locale/de_DE/LC_MESSAGES/statusnet.mo b/locale/de_DE/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index fe6072c1b..000000000
--- a/locale/de_DE/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/el_GR/LC_MESSAGES/statusnet.mo b/locale/el/LC_MESSAGES/statusnet.mo
index 184639963..184639963 100644
--- a/locale/el_GR/LC_MESSAGES/statusnet.mo
+++ b/locale/el/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/el_GR/LC_MESSAGES/statusnet.po b/locale/el/LC_MESSAGES/statusnet.po
index 4a54996a8..4a54996a8 100644
--- a/locale/el_GR/LC_MESSAGES/statusnet.po
+++ b/locale/el/LC_MESSAGES/statusnet.po
diff --git a/locale/en_GB/LC_MESSAGES/statusnet.mo b/locale/en_GB/LC_MESSAGES/statusnet.mo
index 11eacc9ac..4eeac7304 100644
--- a/locale/en_GB/LC_MESSAGES/statusnet.mo
+++ b/locale/en_GB/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/es/LC_MESSAGES/statusnet.mo b/locale/es/LC_MESSAGES/statusnet.mo
index ab03d12e0..05eabcc75 100644
--- a/locale/es/LC_MESSAGES/statusnet.mo
+++ b/locale/es/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/fr/LC_MESSAGES/statusnet.mo b/locale/fr/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..1d3509af1
--- /dev/null
+++ b/locale/fr/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/fr_FR/LC_MESSAGES/statusnet.po b/locale/fr/LC_MESSAGES/statusnet.po
index 23365960b..23365960b 100644
--- a/locale/fr_FR/LC_MESSAGES/statusnet.po
+++ b/locale/fr/LC_MESSAGES/statusnet.po
diff --git a/locale/fr_FR/LC_MESSAGES/statusnet.mo b/locale/fr_FR/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index f26b8708d..000000000
--- a/locale/fr_FR/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/ga/LC_MESSAGES/statusnet.mo b/locale/ga/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..c13acd1a8
--- /dev/null
+++ b/locale/ga/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/ga/LC_MESSAGES/statusnet.po b/locale/ga/LC_MESSAGES/statusnet.po
new file mode 100644
index 000000000..3815e4853
--- /dev/null
+++ b/locale/ga/LC_MESSAGES/statusnet.po
@@ -0,0 +1,4713 @@
+# translation of statusnet.po to Galician
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Francisco Diéguez <fran.dieguez@glug.es>, 2008.
+msgid ""
+msgstr ""
+"Project-Id-Version: laconica-new\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-12-17 20:08+0100\n"
+"PO-Revision-Date: 2008-12-17 20:10+0100\n"
+"Last-Translator: Martín Vázquez Cabanas <eu@martinvazquez.net>\n"
+"Language-Team: Galician <en@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.11.4\n"
+
+#: ../actions/noticesearchrss.php:64
+#: actions/noticesearchrss.php:68
+#: actions/noticesearchrss.php:61
+#, php-format
+msgid " Search Stream for \"%s\""
+msgstr "Buscar \"%s\" na Liña de tempo"
+
+#: ../actions/finishopenidlogin.php:82
+#: ../actions/register.php:191
+#: actions/finishopenidlogin.php:88
+#: actions/register.php:205
+#: actions/register.php:232
+msgid " except this private data: password, email address, IM address, phone number."
+msgstr " agás esta informción privada: contrasinal, dirección de correo electrónico, dirección IM, número de teléfono."
+
+#: ../actions/showstream.php:400
+#: ../lib/stream.php:109
+#: actions/showstream.php:418
+#: lib/mailbox.php:164
+#: lib/stream.php:76
+#: lib/facebookaction.php:195
+#: lib/noticelist.php:160
+msgid " from "
+msgstr " dende "
+
+#: ../actions/twitapistatuses.php:478
+#: actions/twitapistatuses.php:412
+#: actions/twitapistatuses.php:341
+#, php-format
+msgid "%1$s / Updates replying to %2$s"
+msgstr "%1$s / Chíos que respostan a %2$s"
+
+#: ../actions/invite.php:168
+#: actions/invite.php:176
+#, php-format
+msgid "%1$s has invited you to join them on %2$s"
+msgstr "%1$s invitoute a unirse a él en %2$s."
+
+#: ../actions/invite.php:170
+#: actions/invite.php:178
+#, php-format
+msgid ""
+"%1$s has invited you to join them on %2$s (%3$s).\n"
+"\n"
+"%2$s is a micro-blogging service that lets you keep up-to-date with people you know and people who interest you.\n"
+"\n"
+"You can also share news about yourself, your thoughts, or your life online with people who know about you. It's also great for meeting new people who share your interests.\n"
+"\n"
+"%1$s said:\n"
+"\n"
+"%4$s\n"
+"\n"
+"You can see %1$s's profile page on %2$s here:\n"
+"\n"
+"%5$s\n"
+"\n"
+"If you'd like to try the service, click on the link below to accept the invitation.\n"
+"\n"
+"%6$s\n"
+"\n"
+"If not, you can ignore this message. Thanks for your patience and your time.\n"
+"\n"
+"Sincerely, %2$s\n"
+msgstr ""
+"%1$s invitoute a unirte a el en %2$s (%3$s).\n"
+"\n"
+"%2$s é un servizo de microbloguexo que che permite manterte actualizado coa xente que coñeces e xente na que tes interese.\n"
+"\n"
+"Tamén podes compartir novas contigo mesmo, ou pensamentos, ou vivir en liña con xente que te coñece. Tamén está moi ben para coñecer xente que comparte os mesmos intereses..\n"
+"\n"
+"%1$s dixo:\n"
+"\n"
+"%4$s\n"
+"\n"
+"Podes ollar a súa páxina de perfil %1$s's en %2$s here:\n"
+"\n"
+"%5$s\n"
+"\n"
+"Se queres probar, fai clic na ligazón de abaixo para aceptar a invitación..\n"
+"\n"
+"%6$s\n"
+"\n"
+"Se non, pois ignora esta mensaxe. Pero aló ti, aquí se pasa moi ben.\n"
+"\n"
+"Saudiños, %2$s\n"
+
+#: ../lib/mail.php:124
+#: lib/mail.php:124
+#: lib/mail.php:126
+#: lib/mail.php:115
+#, php-format
+msgid "%1$s is now listening to your notices on %2$s."
+msgstr "%1$s está a escoitar os teus chíos %2$s."
+
+#: ../lib/mail.php:126
+#: lib/mail.php:117
+#, php-format
+msgid ""
+"%1$s is now listening to your notices on %2$s.\n"
+"\n"
+"\t%3$s\n"
+"\n"
+"Faithfully yours,\n"
+"%4$s.\n"
+msgstr ""
+"%1$s está a escoitar os teus chíos en %2$s.\n"
+"\n"
+"\t%3$s\n"
+"\n"
+"Atentamente todo seu,\n"
+"%4$s.\n"
+
+#: ../actions/twitapistatuses.php:482
+#: actions/twitapistatuses.php:415
+#: actions/twitapistatuses.php:344
+#, php-format
+msgid "%1$s updates that reply to updates from %2$s / %3$s."
+msgstr "Hai %1$s chíos en resposta a chíos dende %2$s / %3$s."
+
+#: ../actions/shownotice.php:45
+#: actions/shownotice.php:45
+#: actions/shownotice.php:73
+#, php-format
+msgid "%1$s's status on %2$s"
+msgstr "Estado de %1$s en %2$s"
+
+#: ../actions/invite.php:84
+#: ../actions/invite.php:92
+#: actions/invite.php:91
+#: actions/invite.php:99
+#, php-format
+msgid "%s (%s)"
+msgstr "%s (%s)"
+
+#: ../actions/publicrss.php:62
+#: actions/publicrss.php:48
+#, php-format
+msgid "%s Public Stream"
+msgstr "%s Fio Público"
+
+#: ../actions/all.php:47
+#: ../actions/allrss.php:60
+#: ../actions/twitapistatuses.php:238
+#: ../lib/stream.php:51
+#: actions/all.php:47
+#: actions/allrss.php:60
+#: actions/twitapistatuses.php:155
+#: lib/personal.php:51
+#: actions/twitapistatuses.php:123
+#, php-format
+msgid "%s and friends"
+msgstr "%s e amigos"
+
+#: ../actions/twitapistatuses.php:49
+#: actions/twitapistatuses.php:49
+#: actions/twitapistatuses.php:31
+#, php-format
+msgid "%s public timeline"
+msgstr "Liña de tempo pública de %s"
+
+#: ../lib/mail.php:206
+#: lib/mail.php:212
+#: lib/mail.php:207
+#, php-format
+msgid "%s status"
+msgstr "Estado de %s"
+
+#: ../actions/twitapistatuses.php:338
+#: actions/twitapistatuses.php:265
+#: actions/twitapistatuses.php:195
+#, php-format
+msgid "%s timeline"
+msgstr "Liña de tempo de %s"
+
+#: ../actions/twitapistatuses.php:52
+#: actions/twitapistatuses.php:52
+#: actions/twitapistatuses.php:34
+#, php-format
+msgid "%s updates from everyone!"
+msgstr "%s chíos de calquera!"
+
+#: ../actions/register.php:213
+#: actions/register.php:254
+msgid "(You should receive a message by email momentarily, with instructions on how to confirm your email address.)"
+msgstr "(Deberías recibir unha mensaxe no teu email nun intre, coas instrucións de como confirmar a túa dirección de correo.)"
+
+#: ../lib/util.php:257
+#: lib/util.php:273
+#: lib/util.php:290
+#, php-format
+msgid "**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). "
+msgstr "**%%site.name%%** é un servizo de microbloguexo que che proporciona [%%site.broughtby%%](%%site.broughtbyurl%%). "
+
+#: ../lib/util.php:259
+#: lib/util.php:275
+#: lib/util.php:292
+#, php-format
+msgid "**%%site.name%%** is a microblogging service. "
+msgstr "**%%site.name%%** é un servizo de microbloguexo."
+
+#: ../lib/util.php:274
+#: lib/util.php:290
+#: lib/util.php:307
+msgid ". Contributors should be attributed by full name or nickname."
+msgstr ". Os contribuíntes deben atribuiselles polo nome completo ou apodo."
+
+#: ../actions/finishopenidlogin.php:73
+#: ../actions/profilesettings.php:43
+#: actions/finishopenidlogin.php:79
+#: actions/profilesettings.php:76
+#: actions/profilesettings.php:78
+msgid "1-64 lowercase letters or numbers, no punctuation or spaces"
+msgstr "De 1 a 64 letras minúsculas ou númeors, nin espazos nin signos de puntuación"
+
+#: ../actions/register.php:152
+#: actions/register.php:166
+#: actions/register.php:193
+msgid "1-64 lowercase letters or numbers, no punctuation or spaces. Required."
+msgstr "De 1 a 64 letras minúsculas ou números, nin espazos nin signos de puntuación. Requerido."
+
+#: ../actions/password.php:42
+#: actions/profilesettings.php:181
+#: actions/profilesettings.php:198
+msgid "6 or more characters"
+msgstr "6 ou máis caracteres"
+
+#: ../actions/recoverpassword.php:180
+#: actions/recoverpassword.php:186
+msgid "6 or more characters, and don't forget it!"
+msgstr "6 ou máis caracteres, non o esquenzas!"
+
+#: ../actions/register.php:154
+#: actions/register.php:168
+#: actions/register.php:195
+msgid "6 or more characters. Required."
+msgstr "6 ou máis caracteres. Requerido."
+
+#: ../actions/imsettings.php:197
+#: actions/imsettings.php:205
+#: actions/imsettings.php:210
+#, php-format
+msgid "A confirmation code was sent to the IM address you added. You must approve %s for sending messages to you."
+msgstr "O código de confirmación foi embiado á dirección IM que engadiches. Deberías engadir a %s como contacto para que che poida enviar mensaxes."
+
+#: ../actions/emailsettings.php:213
+#: actions/emailsettings.php:231
+#: actions/emailsettings.php:235
+msgid "A confirmation code was sent to the email address you added. Check your inbox (and spam box!) for the code and instructions on how to use it."
+msgstr "Enviouseche un código de confirmación á dirección de correo que engadiches. Comproba a túa bandexa de entrada (ou spam!) polo código e instrucións que debes seguir."
+
+#: ../actions/smssettings.php:216
+#: actions/smssettings.php:224
+#: actions/smssettings.php:226
+msgid "A confirmation code was sent to the phone number you added. Check your inbox (and spam box!) for the code and instructions on how to use it."
+msgstr "Enviouseche o código de confirmación ó número de teléfono que engadiches. Comproba a túa bandexa de entrada (ou spam!) polo código e instrucións que debes seguir."
+
+#: ../actions/twitapiaccount.php:49
+#: ../actions/twitapihelp.php:45
+#: ../actions/twitapistatuses.php:88
+#: ../actions/twitapistatuses.php:259
+#: ../actions/twitapistatuses.php:370
+#: ../actions/twitapistatuses.php:532
+#: ../actions/twitapiusers.php:122
+#: actions/twitapiaccount.php:49
+#: actions/twitapidirect_messages.php:104
+#: actions/twitapifavorites.php:111
+#: actions/twitapifavorites.php:120
+#: actions/twitapifriendships.php:156
+#: actions/twitapihelp.php:46
+#: actions/twitapistatuses.php:93
+#: actions/twitapistatuses.php:176
+#: actions/twitapistatuses.php:288
+#: actions/twitapistatuses.php:298
+#: actions/twitapistatuses.php:454
+#: actions/twitapistatuses.php:463
+#: actions/twitapistatuses.php:504
+#: actions/twitapiusers.php:55
+#: actions/twitapiaccount.php:35
+#: actions/twitapidirect_messages.php:107
+#: actions/twitapifavorites.php:83
+#: actions/twitapifavorites.php:99
+#: actions/twitapifriendships.php:117
+#: actions/twitapihelp.php:42
+#: actions/twitapistatuses.php:77
+#: actions/twitapistatuses.php:144
+#: actions/twitapistatuses.php:224
+#: actions/twitapistatuses.php:234
+#: actions/twitapistatuses.php:386
+#: actions/twitapistatuses.php:395
+#: actions/twitapistatuses.php:421
+#: actions/twitapiusers.php:30
+msgid "API method not found!"
+msgstr "Método da API non atopado"
+
+#: ../actions/twitapiaccount.php:57
+#: ../actions/twitapiaccount.php:113
+#: ../actions/twitapiaccount.php:119
+#: ../actions/twitapiblocks.php:28
+#: ../actions/twitapiblocks.php:34
+#: ../actions/twitapidirect_messages.php:43
+#: ../actions/twitapidirect_messages.php:49
+#: ../actions/twitapidirect_messages.php:56
+#: ../actions/twitapidirect_messages.php:62
+#: ../actions/twitapifavorites.php:41
+#: ../actions/twitapifavorites.php:47
+#: ../actions/twitapifavorites.php:53
+#: ../actions/twitapihelp.php:52
+#: ../actions/twitapinotifications.php:29
+#: ../actions/twitapinotifications.php:35
+#: ../actions/twitapistatuses.php:768
+#: actions/twitapiaccount.php:56
+#: actions/twitapiaccount.php:109
+#: actions/twitapiaccount.php:114
+#: actions/twitapiblocks.php:28
+#: actions/twitapiblocks.php:33
+#: actions/twitapidirect_messages.php:170
+#: actions/twitapifavorites.php:168
+#: actions/twitapihelp.php:53
+#: actions/twitapinotifications.php:29
+#: actions/twitapinotifications.php:34
+#: actions/twitapistatuses.php:690
+#: actions/twitapiaccount.php:42
+#: actions/twitapiaccount.php:92
+#: actions/twitapiaccount.php:97
+#: actions/twitapidirect_messages.php:178
+#: actions/twitapifavorites.php:139
+#: actions/twitapihelp.php:49
+#: actions/twitapistatuses.php:549
+msgid "API method under construction."
+msgstr "Método da API en contrución."
+
+#: ../lib/util.php:324
+#: lib/util.php:340
+#: lib/util.php:369
+msgid "About"
+msgstr "Sobre"
+
+#: ../actions/userauthorization.php:119
+#: actions/userauthorization.php:126
+msgid "Accept"
+msgstr "Aceptar"
+
+#: ../actions/emailsettings.php:62
+#: ../actions/imsettings.php:63
+#: ../actions/openidsettings.php:57
+#: ../actions/smssettings.php:71
+#: actions/emailsettings.php:63
+#: actions/imsettings.php:64
+#: actions/openidsettings.php:58
+#: actions/smssettings.php:71
+#: actions/twittersettings.php:85
+#: actions/smspostsettings.php:50
+#: actions/twittersettings.php:84
+#: actions/smspostsettings.php:51
+msgid "Add"
+msgstr "Engadir"
+
+#: ../actions/openidsettings.php:43
+#: actions/openidsettings.php:44
+msgid "Add OpenID"
+msgstr "Engadir dirección OpenID"
+
+#: ../lib/settingsaction.php:97
+#: lib/settingsaction.php:91
+#: actions/deleteprofile.php:248
+msgid "Add or remove OpenIDs"
+msgstr "Engadir ou eliminar OpenID"
+
+#: ../actions/emailsettings.php:38
+#: ../actions/imsettings.php:39
+#: ../actions/smssettings.php:39
+#: actions/emailsettings.php:39
+#: actions/imsettings.php:40
+#: actions/smssettings.php:39
+msgid "Address"
+msgstr "Enderezo"
+
+#: ../actions/invite.php:131
+#: actions/invite.php:139
+msgid "Addresses of friends to invite (one per line)"
+msgstr "Direccións dos amigos que queres invitar (unha por liña)"
+
+#: ../actions/showstream.php:273
+#: actions/showstream.php:288
+#: actions/showstream.php:336
+msgid "All subscriptions"
+msgstr "Tódalas subscricións"
+
+#: ../actions/publicrss.php:64
+#: actions/publicrss.php:50
+#, php-format
+msgid "All updates for %s"
+msgstr "Tódalas actualizacións de %s"
+
+#: ../actions/noticesearchrss.php:66
+#: actions/noticesearchrss.php:70
+#: actions/noticesearchrss.php:63
+#, php-format
+msgid "All updates matching search term \"%s\""
+msgstr "Tódalas actualizacións que coinciden co termo de procura \"%s\""
+
+#: ../actions/finishopenidlogin.php:29
+#: ../actions/login.php:31
+#: ../actions/openidlogin.php:29
+#: ../actions/register.php:30
+#: actions/finishopenidlogin.php:29
+#: actions/login.php:31
+#: actions/openidlogin.php:29
+#: actions/register.php:30
+msgid "Already logged in."
+msgstr "Sesión xa iniciada"
+
+#: ../lib/subs.php:42
+#: lib/subs.php:42
+#: lib/subs.php:47
+msgid "Already subscribed!."
+msgstr "¡Xa está subscrito!."
+
+#: ../actions/deletenotice.php:54
+#: actions/deletenotice.php:55
+msgid "Are you sure you want to delete this notice?"
+msgstr "Estas seguro que queres eliminar este chío?"
+
+#: ../actions/userauthorization.php:77
+#: actions/userauthorization.php:83
+msgid "Authorize subscription"
+msgstr "Subscrición de autorización."
+
+#: ../actions/login.php:104
+#: ../actions/register.php:178
+#: actions/register.php:192
+#: actions/login.php:111
+#: actions/openidlogin.php:86
+#: actions/register.php:219
+msgid "Automatically login in the future; not for shared computers!"
+msgstr "Endiante acceder automáticamente, coidado en equipos compartidos!"
+
+#: ../actions/profilesettings.php:65
+#: actions/profilesettings.php:98
+#: actions/profilesettings.php:112
+msgid "Automatically subscribe to whoever subscribes to me (best for non-humans)"
+msgstr "Suscribirse automáticamente a calquera que se suscriba a min (o mellor para non humáns)"
+
+#: ../actions/avatar.php:32
+#: ../lib/settingsaction.php:90
+#: actions/profilesettings.php:34
+msgid "Avatar"
+msgstr "Avatar"
+
+#: ../actions/avatar.php:113
+#: actions/profilesettings.php:350
+#: actions/profilesettings.php:396
+msgid "Avatar updated."
+msgstr "Avatar actualizado."
+
+#: ../actions/imsettings.php:55
+#: actions/imsettings.php:56
+#, php-format
+msgid "Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)"
+msgstr "Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)"
+
+#: ../actions/emailsettings.php:54
+#: actions/emailsettings.php:55
+msgid "Awaiting confirmation on this address. Check your inbox (and spam box!) for a message with further instructions."
+msgstr "Agardando confirmación para esta dirección. Comproba a túa conta de Jabber/GTalk que ten que haber unha mensaxe coas seguintes instrucións. (Engadiches a %s á túa lista de contactos?)"
+
+#: ../actions/smssettings.php:58
+#: actions/smssettings.php:58
+msgid "Awaiting confirmation on this phone number."
+msgstr "Agardando a confirmación neste número de teléfono."
+
+#: ../lib/util.php:1318
+#: lib/util.php:1452
+#: lib/facebookaction.php:259
+#: lib/util.php:1851
+msgid "Before »"
+msgstr "Antes »"
+
+#: ../actions/profilesettings.php:49
+#: ../actions/register.php:170
+#: actions/profilesettings.php:82
+#: actions/register.php:184
+#: actions/profilesettings.php:84
+#: actions/register.php:211
+msgid "Bio"
+msgstr "Bio"
+
+#: ../actions/profilesettings.php:101
+#: ../actions/register.php:82
+#: ../actions/updateprofile.php:103
+#: actions/profilesettings.php:216
+#: actions/register.php:89
+#: actions/updateprofile.php:104
+#: actions/profilesettings.php:235
+#: actions/register.php:98
+msgid "Bio is too long (max 140 chars)."
+msgstr "O teu Bio é demasiado longo (max 140 car.)."
+
+#: ../lib/deleteaction.php:41
+#: lib/deleteaction.php:41
+msgid "Can't delete this notice."
+msgstr "Non se pode eliminar este chíos."
+
+#: ../actions/updateprofile.php:119
+#: actions/updateprofile.php:120
+#, php-format
+msgid "Can't read avatar URL '%s'"
+msgstr "Non se pode ler a URL do avatar de '%s'"
+
+#: ../actions/password.php:85
+#: ../actions/recoverpassword.php:300
+#: actions/profilesettings.php:404
+#: actions/recoverpassword.php:313
+#: actions/profilesettings.php:450
+msgid "Can't save new password."
+msgstr "Non se pode gardar a contrasinal."
+
+#: ../actions/emailsettings.php:57
+#: ../actions/imsettings.php:58
+#: ../actions/smssettings.php:62
+#: actions/emailsettings.php:58
+#: actions/imsettings.php:59
+#: actions/smssettings.php:62
+msgid "Cancel"
+msgstr "Cancelar"
+
+#: ../lib/openid.php:121
+#: lib/openid.php:121
+msgid "Cannot instantiate OpenID consumer object."
+msgstr "Non se pode instanciar o obxecto consumidor de OpenID."
+
+#: ../actions/imsettings.php:163
+#: actions/imsettings.php:171
+#: actions/imsettings.php:176
+msgid "Cannot normalize that Jabber ID"
+msgstr "Non se pode normalizar ese identificador de Jabber"
+
+#: ../actions/emailsettings.php:181
+#: actions/emailsettings.php:199
+#: actions/emailsettings.php:205
+msgid "Cannot normalize that email address"
+msgstr "Esa dirección de correo non se pode normalizar "
+
+#: ../actions/password.php:45
+#: actions/profilesettings.php:184
+#: actions/profilesettings.php:201
+msgid "Change"
+msgstr "Modificado"
+
+#: ../lib/settingsaction.php:88
+#: lib/settingsaction.php:88
+#: actions/deleteprofile.php:245
+msgid "Change email handling"
+msgstr "Cambiar a xestión de email"
+
+#: ../actions/password.php:32
+#: actions/profilesettings.php:36
+msgid "Change password"
+msgstr "Cambiar contrasinal"
+
+#: ../lib/settingsaction.php:94
+msgid "Change your password"
+msgstr "Cambiar contrasinal"
+
+#: ../lib/settingsaction.php:85
+#: lib/settingsaction.php:85
+#: actions/deleteprofile.php:242
+msgid "Change your profile settings"
+msgstr "Configuración de perfil"
+
+#: ../actions/password.php:43
+#: ../actions/recoverpassword.php:181
+#: ../actions/register.php:155
+#: ../actions/smssettings.php:65
+#: actions/profilesettings.php:182
+#: actions/recoverpassword.php:187
+#: actions/register.php:169
+#: actions/smssettings.php:65
+#: actions/profilesettings.php:199
+#: actions/register.php:196
+msgid "Confirm"
+msgstr "Confirmar"
+
+#: ../actions/confirmaddress.php:90
+#: actions/confirmaddress.php:90
+msgid "Confirm Address"
+msgstr "Confirmar enderezo"
+
+#: ../actions/emailsettings.php:238
+#: ../actions/imsettings.php:222
+#: ../actions/smssettings.php:245
+#: actions/emailsettings.php:256
+#: actions/imsettings.php:230
+#: actions/smssettings.php:253
+#: actions/emailsettings.php:260
+#: actions/imsettings.php:235
+#: actions/smssettings.php:255
+msgid "Confirmation cancelled."
+msgstr "Confirmación cancealada."
+
+#: ../actions/smssettings.php:63
+#: actions/smssettings.php:63
+msgid "Confirmation code"
+msgstr "Código de confirmación."
+
+#: ../actions/confirmaddress.php:38
+#: actions/confirmaddress.php:38
+msgid "Confirmation code not found."
+msgstr "Confirmation code not found."
+
+#: ../actions/register.php:202
+#: actions/register.php:243
+#, php-format
+msgid ""
+"Congratulations, %s! And welcome to %%%%site.name%%%%. From here, you may want to...\n"
+"\n"
+"* Go to [your profile](%s) and post your first message.\n"
+"* Add a [Jabber/GTalk address](%%%%action.imsettings%%%%) so you can send notices through instant messages.\n"
+"* [Search for people](%%%%action.peoplesearch%%%%) that you may know or that share your interests. \n"
+"* Update your [profile settings](%%%%action.profilesettings%%%%) to tell others more about you. \n"
+"* Read over the [online docs](%%%%doc.help%%%%) for features you may have missed. \n"
+"\n"
+"Thanks for signing up and we hope you enjoy using this service."
+msgstr ""
+"Noraboa, %s! e benvido a %%%%site.name%%%%. Dende aquí, podes...\n"
+"\n"
+"* Ír ó [teu perfil](%s) e enviar o teu primeiro chío.\n"
+"* Engadir unha [conta de Jabber/Gtalk](%%%%action.imsettings%%%%) para enviar os teus chíos a través de mensaxería instantánea.\n"
+"* [Buscar xente ](%%%%action.peoplesearch%%%%) que poidas coñecer ou que comparta os teus intereses. \n"
+"* Actualizar as túas [preferencias no perfil](%%%%action.profilesettings%%%%) para decirlle a outros máis sobre ti. \n"
+"* Ler os [manuais en liña](%%%%doc.help%%%%) para ollar máis cousas que podes facer aquí. \n"
+"\n"
+"Grazas por rexistrarte e esperamos que laretexes moito."
+
+#: ../actions/finishopenidlogin.php:91
+#: actions/finishopenidlogin.php:97
+msgid "Connect"
+msgstr "Conectar"
+
+#: ../actions/finishopenidlogin.php:86
+#: actions/finishopenidlogin.php:92
+msgid "Connect existing account"
+msgstr "Conectar con unha conta existente"
+
+#: ../lib/util.php:332
+#: lib/util.php:348
+#: lib/util.php:377
+msgid "Contact"
+msgstr "Contacto"
+
+#: ../lib/openid.php:178
+#: lib/openid.php:178
+#, php-format
+msgid "Could not create OpenID form: %s"
+msgstr "Non se pode crear o formulario OpenID: %s"
+
+#: ../actions/twitapifriendships.php:60
+#: ../actions/twitapifriendships.php:76
+#: actions/twitapifriendships.php:60
+#: actions/twitapifriendships.php:76
+#: actions/twitapifriendships.php:46
+#: actions/twitapifriendships.php:62
+#, php-format
+msgid "Could not follow user: %s is already on your list."
+msgstr "Non podes seguir a este usuario: %s xa está na túa lista."
+
+#: ../actions/twitapifriendships.php:53
+#: actions/twitapifriendships.php:53
+#: actions/twitapifriendships.php:39
+msgid "Could not follow user: User not found."
+msgstr "Non podes seguir a este usuario: o Usuario non se atopa."
+
+#: ../lib/openid.php:160
+#: lib/openid.php:160
+#, php-format
+msgid "Could not redirect to server: %s"
+msgstr "Non se pode redireccionar ao servidor: %s"
+
+#: ../actions/updateprofile.php:162
+#: actions/updateprofile.php:163
+msgid "Could not save avatar info"
+msgstr "Non se pode gardar a información do avatar"
+
+#: ../actions/updateprofile.php:155
+#: actions/updateprofile.php:156
+msgid "Could not save new profile info"
+msgstr "Non se pode gardar a nova información do perfil"
+
+#: ../lib/subs.php:54
+#: lib/subs.php:61
+#: lib/subs.php:70
+msgid "Could not subscribe other to you."
+msgstr "Outro usuario non se puido suscribir a ti."
+
+#: ../lib/subs.php:46
+#: lib/subs.php:46
+#: lib/subs.php:55
+msgid "Could not subscribe."
+msgstr "No se pode suscribir."
+
+#: ../actions/recoverpassword.php:102
+#: actions/recoverpassword.php:105
+msgid "Could not update user with confirmed email address."
+msgstr "Non se puido actualizar o usuario coa dirección de correo electrónico."
+
+#: ../actions/finishremotesubscribe.php:99
+#: actions/finishremotesubscribe.php:101
+#: actions/finishremotesubscribe.php:112
+msgid "Couldn't convert request tokens to access tokens."
+msgstr "Non se pode convertir o token da petición a tokens de acceso."
+
+#: ../actions/confirmaddress.php:84
+#: ../actions/emailsettings.php:234
+#: ../actions/imsettings.php:218
+#: ../actions/smssettings.php:241
+#: actions/confirmaddress.php:84
+#: actions/emailsettings.php:252
+#: actions/imsettings.php:226
+#: actions/smssettings.php:249
+#: actions/emailsettings.php:256
+#: actions/imsettings.php:231
+#: actions/smssettings.php:251
+msgid "Couldn't delete email confirmation."
+msgstr "Non se pode eliminar a confirmación de email."
+
+#: ../lib/subs.php:103
+#: lib/subs.php:116
+#: lib/subs.php:129
+msgid "Couldn't delete subscription."
+msgstr "Non se pode eliminar a subscrición."
+
+#: ../actions/twitapistatuses.php:93
+#: actions/twitapistatuses.php:98
+#: actions/twitapistatuses.php:82
+msgid "Couldn't find any statuses."
+msgstr "Non se puido atopar ningún estado"
+
+#: ../actions/remotesubscribe.php:127
+#: actions/remotesubscribe.php:136
+#: actions/remotesubscribe.php:148
+msgid "Couldn't get a request token."
+msgstr "Non se puido recoller o token de petición."
+
+#: ../actions/emailsettings.php:205
+#: ../actions/imsettings.php:187
+#: ../actions/smssettings.php:206
+#: actions/emailsettings.php:223
+#: actions/imsettings.php:195
+#: actions/smssettings.php:214
+#: actions/emailsettings.php:229
+#: actions/imsettings.php:200
+#: actions/smssettings.php:216
+msgid "Couldn't insert confirmation code."
+msgstr "Non se puido inserir o código de confirmación."
+
+#: ../actions/finishremotesubscribe.php:180
+#: actions/finishremotesubscribe.php:182
+#: actions/finishremotesubscribe.php:198
+#: actions/finishremotesubscribe.php:216
+msgid "Couldn't insert new subscription."
+msgstr "Non se puido inserir a nova subscrición."
+
+#: ../actions/profilesettings.php:184
+#: ../actions/twitapiaccount.php:96
+#: actions/profilesettings.php:299
+#: actions/twitapiaccount.php:94
+#: actions/profilesettings.php:336
+#: actions/twitapiaccount.php:77
+msgid "Couldn't save profile."
+msgstr "Non se puido gardar o perfil."
+
+#: ../actions/profilesettings.php:161
+#: actions/profilesettings.php:276
+#: actions/profilesettings.php:313
+msgid "Couldn't update user for autosubscribe."
+msgstr "Non se puido actualizar o usuario para autosuscrición."
+
+#: ../actions/emailsettings.php:280
+#: ../actions/emailsettings.php:294
+#: actions/emailsettings.php:298
+#: actions/emailsettings.php:312
+#: actions/emailsettings.php:302
+#: actions/emailsettings.php:316
+msgid "Couldn't update user record."
+msgstr "Non se puido actualizar o rexistro de usuario."
+
+#: ../actions/confirmaddress.php:72
+#: ../actions/emailsettings.php:156
+#: ../actions/emailsettings.php:259
+#: ../actions/imsettings.php:138
+#: ../actions/imsettings.php:243
+#: ../actions/profilesettings.php:141
+#: ../actions/smssettings.php:157
+#: ../actions/smssettings.php:269
+#: actions/confirmaddress.php:72
+#: actions/emailsettings.php:174
+#: actions/emailsettings.php:277
+#: actions/imsettings.php:146
+#: actions/imsettings.php:251
+#: actions/profilesettings.php:256
+#: actions/smssettings.php:165
+#: actions/smssettings.php:277
+#: actions/emailsettings.php:180
+#: actions/emailsettings.php:281
+#: actions/imsettings.php:151
+#: actions/imsettings.php:256
+#: actions/othersettings.php:173
+#: actions/profilesettings.php:293
+#: actions/smspostsettings.php:96
+#: actions/smspostsettings.php:123
+#: actions/smssettings.php:167
+#: actions/smssettings.php:279
+#: actions/smspostsettings.php:101
+#: actions/smspostsettings.php:128
+msgid "Couldn't update user."
+msgstr "Non se puido actualizar o usuario."
+
+#: ../actions/finishopenidlogin.php:84
+#: actions/finishopenidlogin.php:90
+msgid "Create"
+msgstr "Crear"
+
+#: ../actions/finishopenidlogin.php:70
+#: actions/finishopenidlogin.php:76
+msgid "Create a new user with this nickname."
+msgstr "Crear un novo usuario con este alcume."
+
+#: ../actions/finishopenidlogin.php:68
+#: actions/finishopenidlogin.php:74
+msgid "Create new account"
+msgstr "Crear nova conta"
+
+#: ../actions/finishopenidlogin.php:191
+#: actions/finishopenidlogin.php:197
+#: actions/finishopenidlogin.php:208
+msgid "Creating new account for OpenID that already has a user."
+msgstr "Creando nova conta para OpenID que xa ten un usuario."
+
+#: ../actions/imsettings.php:45
+#: actions/imsettings.php:46
+msgid "Current confirmed Jabber/GTalk address."
+msgstr "Direccións Jabber/GTalk confirmadas."
+
+#: ../actions/smssettings.php:46
+#: actions/smssettings.php:46
+msgid "Current confirmed SMS-enabled phone number."
+msgstr "Número de teléfono actual confirmado mediante SMS."
+
+#: ../actions/emailsettings.php:44
+#: actions/emailsettings.php:45
+msgid "Current confirmed email address."
+msgstr "Direccións de correo confirmadas actualmente."
+
+#: ../actions/showstream.php:356
+#: actions/showstream.php:367
+#: actions/showstream.php:418
+msgid "Currently"
+msgstr "Actual"
+
+#: ../classes/Notice.php:72
+#: classes/Notice.php:86
+#: classes/Notice.php:87
+#, php-format
+msgid "DB error inserting hashtag: %s"
+msgstr "Erro ó inserir o hashtag na BD: %s"
+
+#: ../lib/util.php:1061
+#: lib/util.php:1110
+#: lib/util.php:1479
+#, php-format
+msgid "DB error inserting reply: %s"
+msgstr "Erro ó inserir a contestación na BD: %s"
+
+#: ../actions/deletenotice.php:41
+#: actions/deletenotice.php:41
+msgid "Delete notice"
+msgstr "Eliminar chío"
+
+#: ../actions/profilesettings.php:51
+#: ../actions/register.php:172
+#: actions/profilesettings.php:84
+#: actions/register.php:186
+#: actions/profilesettings.php:86
+#: actions/register.php:213
+msgid "Describe yourself and your interests in 140 chars"
+msgstr "Contanos un pouco de ti e dos teus intereses en 140 caractéres."
+
+#: ../actions/register.php:158
+#: ../actions/register.php:161
+#: ../lib/settingsaction.php:87
+#: actions/register.php:172
+#: actions/register.php:175
+#: lib/settingsaction.php:87
+#: actions/deleteprofile.php:244
+#: actions/register.php:199
+#: actions/register.php:202
+msgid "Email"
+msgstr "Correo Electrónico"
+
+#: ../actions/emailsettings.php:59
+#: actions/emailsettings.php:60
+msgid "Email Address"
+msgstr "Enderezo de correo"
+
+#: ../actions/emailsettings.php:32
+#: actions/emailsettings.php:32
+msgid "Email Settings"
+msgstr "Configuración de Correo"
+
+#: ../actions/register.php:73
+#: actions/register.php:80
+#: actions/register.php:89
+msgid "Email address already exists."
+msgstr "O enderezo de correo xa existe."
+
+#: ../lib/mail.php:90
+#: lib/mail.php:90
+msgid "Email address confirmation"
+msgstr "Confirmar correo electrónico"
+
+#: ../actions/emailsettings.php:61
+#: actions/emailsettings.php:62
+msgid "Email address, like \"UserName@example.org\""
+msgstr "Dirección de correo, coma \"Nomede Usuario@exemplo.org\""
+
+#: ../actions/invite.php:129
+#: actions/invite.php:137
+msgid "Email addresses"
+msgstr "Enderezos de correo"
+
+#: ../actions/recoverpassword.php:191
+#: actions/recoverpassword.php:197
+msgid "Enter a nickname or email address."
+msgstr "Insire o teu alcume ou enderezo de correo."
+
+#: ../actions/smssettings.php:64
+#: actions/smssettings.php:64
+msgid "Enter the code you received on your phone."
+msgstr "Insire o código que recibiches no teu teléfono."
+
+#: ../actions/userauthorization.php:137
+#: actions/userauthorization.php:144
+msgid "Error authorizing token"
+msgstr "Erro no token de autorización."
+
+#: ../actions/finishopenidlogin.php:253
+#: actions/finishopenidlogin.php:259
+#: actions/finishopenidlogin.php:274
+msgid "Error connecting user to OpenID."
+msgstr "Acounteceu un erro conectando o usuario ó OpenID."
+
+#: ../actions/finishaddopenid.php:78
+#: actions/finishaddopenid.php:78
+msgid "Error connecting user."
+msgstr "Acounteceu un erro ó conectar co usuario"
+
+#: ../actions/finishremotesubscribe.php:151
+#: actions/finishremotesubscribe.php:153
+#: actions/finishremotesubscribe.php:164
+msgid "Error inserting avatar"
+msgstr "Acounteceu un erro ó inserir o avatar"
+
+#: ../actions/finishremotesubscribe.php:143
+#: actions/finishremotesubscribe.php:145
+#: actions/finishremotesubscribe.php:156
+msgid "Error inserting new profile"
+msgstr "Acounteceu un erro ó inserir o novo perfil"
+
+#: ../actions/finishremotesubscribe.php:167
+#: actions/finishremotesubscribe.php:169
+#: actions/finishremotesubscribe.php:180
+msgid "Error inserting remote profile"
+msgstr "Aconteceu un erro ó inserir o perfil remoto"
+
+#: ../actions/recoverpassword.php:240
+#: actions/recoverpassword.php:246
+msgid "Error saving address confirmation."
+msgstr "Acounteceu un erro gardando a confirmación de enderezo."
+
+#: ../actions/userauthorization.php:140
+#: actions/userauthorization.php:147
+msgid "Error saving remote profile"
+msgstr "Acounteceu un erro gardando o perfil remoto."
+
+#: ../lib/openid.php:226
+#: lib/openid.php:226
+msgid "Error saving the profile."
+msgstr "Acounteceu un erro ó gardar o perfil."
+
+#: ../lib/openid.php:237
+#: lib/openid.php:237
+msgid "Error saving the user."
+msgstr "Acounteceu un erro gardando o usuario."
+
+#: ../actions/password.php:80
+#: actions/profilesettings.php:399
+#: actions/profilesettings.php:445
+msgid "Error saving user; invalid."
+msgstr "Acounteceu un erro gardando o usuario: é inválido."
+
+#: ../actions/login.php:47
+#: ../actions/login.php:73
+#: ../actions/recoverpassword.php:307
+#: ../actions/register.php:98
+#: actions/login.php:47
+#: actions/login.php:73
+#: actions/recoverpassword.php:320
+#: actions/register.php:108
+#: actions/login.php:54
+#: actions/login.php:80
+#: actions/register.php:117
+msgid "Error setting user."
+msgstr "Acounteceu un erro configurando o usuario."
+
+#: ../actions/finishaddopenid.php:83
+#: actions/finishaddopenid.php:83
+msgid "Error updating profile"
+msgstr "Acounteceu un erro actualizando o usuario"
+
+#: ../actions/finishremotesubscribe.php:161
+#: actions/finishremotesubscribe.php:163
+#: actions/finishremotesubscribe.php:174
+msgid "Error updating remote profile"
+msgstr "Acounteceu un erro actualizando o perfil remoto"
+
+#: ../actions/recoverpassword.php:80
+#: actions/recoverpassword.php:80
+msgid "Error with confirmation code."
+msgstr "Acounteceu un erro co código de confirmación."
+
+#: ../actions/finishopenidlogin.php:89
+#: actions/finishopenidlogin.php:95
+msgid "Existing nickname"
+msgstr "Alcume existente"
+
+#: ../lib/util.php:326
+#: lib/util.php:342
+#: lib/util.php:371
+msgid "FAQ"
+msgstr "Preguntas frecuentes"
+
+#: ../actions/avatar.php:115
+#: actions/profilesettings.php:352
+#: actions/profilesettings.php:398
+msgid "Failed updating avatar."
+msgstr "Acounteceu un fallo ó actualizar o avatar."
+
+#: ../actions/all.php:61
+#: ../actions/allrss.php:64
+#: actions/all.php:61
+#: actions/allrss.php:64
+#, php-format
+msgid "Feed for friends of %s"
+msgstr "Fonte para os amigos de %s"
+
+#: ../actions/replies.php:65
+#: ../actions/repliesrss.php:80
+#: actions/replies.php:65
+#: actions/repliesrss.php:66
+#, php-format
+msgid "Feed for replies to %s"
+msgstr "Fonte para as contestacións de %s"
+
+#: ../actions/tag.php:55
+#: actions/tag.php:55
+#: actions/tag.php:61
+#, php-format
+msgid "Feed for tag %s"
+msgstr "Fonte para a etiqueta %s"
+
+#: ../lib/searchaction.php:105
+#: lib/searchaction.php:105
+msgid "Find content of notices"
+msgstr "Atopar no contido dos chíos"
+
+#: ../lib/searchaction.php:101
+#: lib/searchaction.php:101
+msgid "Find people on this site"
+msgstr "Atopar xente neste sitio"
+
+#: ../actions/login.php:122
+#: actions/login.php:142
+msgid "For security reasons, please re-enter your user name and password before changing your settings."
+msgstr "Por razóns de seguranza, por favor re-insire o teu nome de usuario e contrasinal antes de cambiar as túas preferenzas."
+
+#: ../actions/profilesettings.php:44
+#: ../actions/register.php:164
+#: actions/profilesettings.php:77
+#: actions/register.php:178
+#: actions/profilesettings.php:79
+#: actions/register.php:205
+msgid "Full name"
+msgstr "Nome completo"
+
+#: ../actions/profilesettings.php:98
+#: ../actions/register.php:79
+#: ../actions/updateprofile.php:93
+#: actions/profilesettings.php:213
+#: actions/register.php:86
+#: actions/updateprofile.php:94
+#: actions/profilesettings.php:232
+#: actions/register.php:95
+msgid "Full name is too long (max 255 chars)."
+msgstr "O nome completo é demasiado longo (max 255 car)."
+
+#: ../lib/util.php:322
+#: lib/util.php:338
+#: lib/util.php:359
+#: lib/util.php:367
+msgid "Help"
+msgstr "Axuda"
+
+#: ../lib/util.php:298
+#: lib/util.php:314
+#: lib/util.php:343
+msgid "Home"
+msgstr "Persoal"
+
+#: ../actions/profilesettings.php:46
+#: ../actions/register.php:167
+#: actions/profilesettings.php:79
+#: actions/register.php:181
+#: actions/profilesettings.php:81
+#: actions/register.php:208
+msgid "Homepage"
+msgstr "Páxina persoal"
+
+#: ../actions/profilesettings.php:95
+#: ../actions/register.php:76
+#: actions/profilesettings.php:210
+#: actions/register.php:83
+#: actions/profilesettings.php:229
+#: actions/register.php:92
+msgid "Homepage is not a valid URL."
+msgstr "A páxina persoal semella que non é unha URL válida."
+
+#: ../actions/emailsettings.php:91
+#: actions/emailsettings.php:98
+msgid "I want to post notices by email."
+msgstr "Quero enviar chíos dende o mail."
+
+#: ../lib/settingsaction.php:102
+#: lib/settingsaction.php:96
+#: actions/deleteprofile.php:253
+#: lib/settingsaction.php:100
+#: lib/settingsaction.php:102
+msgid "IM"
+msgstr "IM"
+
+#: ../actions/imsettings.php:60
+#: actions/imsettings.php:61
+msgid "IM Address"
+msgstr "Enderezo de IM"
+
+#: ../actions/imsettings.php:33
+#: actions/imsettings.php:33
+msgid "IM Settings"
+msgstr "Configuracións de IM"
+
+#: ../actions/finishopenidlogin.php:88
+#: actions/finishopenidlogin.php:94
+msgid "If you already have an account, login with your username and password to connect it to your OpenID."
+msgstr "Se xa tes unha conta, accede co teu usuario e contrasinal para conectar co teu OpenID."
+
+#: ../actions/openidsettings.php:45
+#: actions/openidsettings.php:46
+msgid "If you want to add an OpenID to your account, enter it in the box below and click \"Add\"."
+msgstr "Se queres engadir un enderezo OpenID á tua conta, insirea na caixa de embaixo e fai clic en \"Engadir\"."
+
+#: ../actions/recoverpassword.php:137
+#: actions/recoverpassword.php:141
+msgid "If you've forgotten or lost your password, you can get a new one sent to the email address you have stored in your account."
+msgstr "Se esquenceches ou perdeches a túa contrasinal, podes obter unha nova no enderezo de correo que configuraches na túa conta."
+
+#: ../actions/emailsettings.php:67
+#: ../actions/smssettings.php:76
+#: actions/emailsettings.php:68
+#: actions/smssettings.php:76
+msgid "Incoming email"
+msgstr "Correo Entrante"
+
+#: ../actions/emailsettings.php:283
+#: actions/emailsettings.php:301
+#: actions/emailsettings.php:305
+msgid "Incoming email address removed."
+msgstr "Dirección de correo entrante eliminada."
+
+#: ../actions/password.php:69
+#: actions/profilesettings.php:388
+#: actions/profilesettings.php:434
+msgid "Incorrect old password"
+msgstr "Contrasinal actual incorrecta"
+
+#: ../actions/login.php:67
+#: actions/login.php:67
+#: actions/login.php:74
+msgid "Incorrect username or password."
+msgstr "Usuario ou contrasinal incorrectos."
+
+#: ../actions/recoverpassword.php:265
+#: actions/recoverpassword.php:271
+msgid "Instructions for recovering your password have been sent to the email address registered to your account."
+msgstr "As instruccións para recuperar a túa contrasinal foron enviadas ó enderezo de correo da túa conta."
+
+#: ../actions/updateprofile.php:114
+#: actions/updateprofile.php:115
+#, php-format
+msgid "Invalid avatar URL '%s'"
+msgstr "URL do avatar '%s' inválido"
+
+#: ../actions/invite.php:55
+#: actions/invite.php:62
+#, php-format
+msgid "Invalid email address: %s"
+msgstr "Dirección de correo Inválida: %s"
+
+#: ../actions/updateprofile.php:98
+#: actions/updateprofile.php:99
+#, php-format
+msgid "Invalid homepage '%s'"
+msgstr "Páxina persoal '%s' inválida"
+
+#: ../actions/updateprofile.php:82
+#: actions/updateprofile.php:83
+#, php-format
+msgid "Invalid license URL '%s'"
+msgstr "URL de licenza '%s' inválida"
+
+#: ../actions/postnotice.php:61
+#: actions/postnotice.php:62
+#: actions/postnotice.php:63
+msgid "Invalid notice content"
+msgstr "Contido do chío inválido"
+
+#: ../actions/postnotice.php:67
+#: actions/postnotice.php:68
+#: actions/postnotice.php:69
+msgid "Invalid notice uri"
+msgstr "Enderezo de chío inválido"
+
+#: ../actions/postnotice.php:72
+#: actions/postnotice.php:73
+#: actions/postnotice.php:74
+msgid "Invalid notice url"
+msgstr "Enderezo de chío inválido"
+
+#: ../actions/updateprofile.php:87
+#: actions/updateprofile.php:88
+#, php-format
+msgid "Invalid profile URL '%s'."
+msgstr "Enderezo de perfil inválido '%s'."
+
+#: ../actions/remotesubscribe.php:96
+#: actions/remotesubscribe.php:105
+msgid "Invalid profile URL (bad format)"
+msgstr "Enderezo de perfil inválido (formato incorrecto)"
+
+#: ../actions/finishremotesubscribe.php:77
+#: actions/finishremotesubscribe.php:79
+#: actions/finishremotesubscribe.php:78
+msgid "Invalid profile URL returned by server."
+msgstr "Enderezo de perfil inválido devolto polo servidor."
+
+#: ../actions/avatarbynickname.php:37
+#: actions/avatarbynickname.php:37
+msgid "Invalid size."
+msgstr "Tamaño inválido."
+
+#: ../actions/finishopenidlogin.php:235
+#: ../actions/register.php:93
+#: ../actions/register.php:111
+#: actions/finishopenidlogin.php:241
+#: actions/register.php:103
+#: actions/register.php:121
+#: actions/finishopenidlogin.php:256
+#: actions/register.php:112
+#: actions/register.php:130
+msgid "Invalid username or password."
+msgstr "Usuario ou contrasinal inválidos."
+
+#: ../actions/invite.php:79
+#: actions/invite.php:86
+msgid "Invitation(s) sent"
+msgstr "Invitación(s) enviada(s)."
+
+#: ../actions/invite.php:97
+#: actions/invite.php:104
+msgid "Invitation(s) sent to the following people:"
+msgstr "Invitación(s) enviada(s) á seguinte xente:"
+
+#: ../lib/util.php:306
+#: lib/util.php:322
+#: lib/util.php:382
+msgid "Invite"
+msgstr "Invitar"
+
+#: ../actions/invite.php:123
+#: actions/invite.php:130
+msgid "Invite new users"
+msgstr "Invitar a novos usuarios"
+
+#: ../lib/util.php:261
+#: lib/util.php:277
+#: lib/util.php:294
+#, php-format
+msgid "It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html)."
+msgstr "Correndo o software de microblogaxe [StatusNet](http://status.net/), versión %s, dispoñible baixo licenza [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html)."
+
+#: ../actions/imsettings.php:173
+#: actions/imsettings.php:181
+#: actions/imsettings.php:186
+msgid "Jabber ID already belongs to another user."
+msgstr "O identificador de Jabber xa pertence a outro usuario."
+
+#: ../actions/imsettings.php:62
+#: actions/imsettings.php:63
+#, php-format
+msgid "Jabber or GTalk address, like \"UserName@example.org\". First, make sure to add %s to your buddy list in your IM client or on GTalk."
+msgstr "Enderezo Jabber ou GTalk, coma \"NomeUsuario@Exemplo.org\". Primeiro, asegurate de engadir %s á tua lista de contactos no teu cliente de IM ou no GTalk."
+
+#: ../actions/profilesettings.php:57
+#: actions/profilesettings.php:90
+#: actions/profilesettings.php:98
+msgid "Language"
+msgstr "Linguaxe"
+
+#: ../actions/profilesettings.php:113
+#: actions/profilesettings.php:228
+#: actions/profilesettings.php:247
+msgid "Language is too long (max 50 chars)."
+msgstr "A Linguaxe é demasiado longa (max 50 car.)."
+
+#: ../actions/profilesettings.php:52
+#: ../actions/register.php:173
+#: actions/profilesettings.php:85
+#: actions/register.php:187
+#: actions/profilesettings.php:87
+#: actions/register.php:214
+msgid "Location"
+msgstr "Localización"
+
+#: ../actions/profilesettings.php:104
+#: ../actions/register.php:85
+#: ../actions/updateprofile.php:108
+#: actions/profilesettings.php:219
+#: actions/register.php:92
+#: actions/updateprofile.php:109
+#: actions/profilesettings.php:238
+#: actions/register.php:101
+msgid "Location is too long (max 255 chars)."
+msgstr "A localización é demasiado longa (max 255 car.)."
+
+#: ../actions/login.php:97
+#: ../actions/login.php:106
+#: ../actions/openidlogin.php:68
+#: ../lib/util.php:310
+#: actions/login.php:97
+#: actions/login.php:106
+#: actions/openidlogin.php:77
+#: lib/util.php:326
+#: actions/login.php:104
+#: actions/login.php:113
+#: actions/login.php:129
+#: actions/openidlogin.php:88
+#: lib/util.php:352
+msgid "Login"
+msgstr "Inicio de sesión"
+
+#: ../actions/openidlogin.php:44
+#: actions/openidlogin.php:52
+#: actions/openidlogin.php:60
+#, php-format
+msgid "Login with an [OpenID](%%doc.openid%%) account."
+msgstr "Acceder con unha conta [OpenID](%%doc.openid%%)."
+
+#: ../actions/login.php:126
+#: actions/login.php:146
+#, php-format
+msgid "Login with your username and password. Don't have a username yet? [Register](%%action.register%%) a new account, or try [OpenID](%%action.openidlogin%%). "
+msgstr "Accede co teu nome de usuario e contrasinal. ¿Non tes un todavía?? [Rexistra](%%action.register%%) unha nova conta, ou accede co teu enderezo [OpenID](%%action.openidlogin%%). "
+
+#: ../lib/util.php:308
+#: lib/util.php:324
+#: lib/util.php:350
+msgid "Logout"
+msgstr "Sair"
+
+#: ../actions/register.php:166
+#: actions/register.php:180
+#: actions/register.php:207
+msgid "Longer name, preferably your \"real\" name"
+msgstr "Nome máis longo, preferiblemente o teu nome \"real\""
+
+#: ../actions/login.php:110
+#: actions/login.php:110
+#: actions/login.php:118
+msgid "Lost or forgotten password?"
+msgstr "¿Perdeches a contrasinal?"
+
+#: ../actions/emailsettings.php:80
+#: ../actions/smssettings.php:89
+#: actions/emailsettings.php:81
+#: actions/smssettings.php:89
+msgid "Make a new email address for posting to; cancels the old one."
+msgstr "Crear unha nova dirección de correo para enviar, elimina a antiga."
+
+#: ../actions/emailsettings.php:27
+#: actions/emailsettings.php:27
+#, php-format
+msgid "Manage how you get email from %%site.name%%."
+msgstr "Xestina como recibir correo dende %%site.name%%."
+
+#: ../actions/showstream.php:300
+#: actions/showstream.php:315
+#: actions/showstream.php:363
+msgid "Member since"
+msgstr "Membro dende"
+
+#: ../actions/userrss.php:70
+#: actions/userrss.php:67
+#, php-format
+msgid "Microblog by %s"
+msgstr "Microblogue por %s"
+
+#: ../actions/smssettings.php:304
+#: actions/smssettings.php:314
+#, php-format
+msgid "Mobile carrier for your phone. If you know a carrier that accepts SMS over email but isn't listed here, send email to let us know at %s."
+msgstr "Operadora móbil do teu teléfono. Se sabes se a operadora acepta SMS sobre email e non está listada aquí, envianos unha mensaxe para incluilo en %s."
+
+#: ../actions/finishopenidlogin.php:79
+#: ../actions/register.php:188
+#: actions/finishopenidlogin.php:85
+#: actions/register.php:202
+#: actions/register.php:229
+msgid "My text and files are available under "
+msgstr "O meu texto e arquivos están dispoñibles baixo licenza "
+
+#: ../actions/emailsettings.php:82
+#: ../actions/smssettings.php:91
+#: actions/emailsettings.php:83
+#: actions/smssettings.php:91
+msgid "New"
+msgstr "Novo"
+
+#: ../lib/mail.php:144
+#: lib/mail.php:144
+#: lib/mail.php:138
+#, php-format
+msgid "New email address for posting to %s"
+msgstr "Nova dirección de email para posterar en %s"
+
+#: ../actions/emailsettings.php:297
+#: actions/emailsettings.php:315
+#: actions/emailsettings.php:319
+msgid "New incoming email address added."
+msgstr "Engadida nova dirección de correo entrante."
+
+#: ../actions/finishopenidlogin.php:71
+#: actions/finishopenidlogin.php:77
+msgid "New nickname"
+msgstr "Novo alcume"
+
+#: ../actions/newnotice.php:87
+#: actions/newnotice.php:96
+#: actions/newnotice.php:141
+msgid "New notice"
+msgstr "Novo chío"
+
+#: ../actions/password.php:41
+#: ../actions/recoverpassword.php:179
+#: actions/profilesettings.php:180
+#: actions/recoverpassword.php:185
+#: actions/profilesettings.php:197
+msgid "New password"
+msgstr "Nova contrasinal"
+
+#: ../actions/recoverpassword.php:314
+#: actions/recoverpassword.php:327
+msgid "New password successfully saved. You are now logged in."
+msgstr "A nova contrasinal gardouse correctamente. Xa estas logueado."
+
+#: ../actions/login.php:101
+#: ../actions/profilesettings.php:41
+#: ../actions/register.php:151
+#: actions/login.php:101
+#: actions/profilesettings.php:74
+#: actions/register.php:165
+#: actions/login.php:108
+#: actions/profilesettings.php:76
+#: actions/register.php:192
+msgid "Nickname"
+msgstr "Alcume"
+
+#: ../actions/finishopenidlogin.php:175
+#: ../actions/profilesettings.php:110
+#: ../actions/register.php:69
+#: actions/finishopenidlogin.php:181
+#: actions/profilesettings.php:225
+#: actions/register.php:76
+#: actions/finishopenidlogin.php:192
+#: actions/profilesettings.php:244
+#: actions/register.php:85
+msgid "Nickname already in use. Try another one."
+msgstr "O alcume xa está sendo empregado por outro usuario. Tenta con outro."
+
+#: ../actions/finishopenidlogin.php:165
+#: ../actions/profilesettings.php:88
+#: ../actions/register.php:67
+#: ../actions/updateprofile.php:77
+#: actions/finishopenidlogin.php:171
+#: actions/profilesettings.php:203
+#: actions/register.php:74
+#: actions/updateprofile.php:78
+#: actions/finishopenidlogin.php:182
+#: actions/profilesettings.php:222
+#: actions/register.php:83
+msgid "Nickname must have only lowercase letters and numbers and no spaces."
+msgstr "O alcume debe ter só letras minúsculas e números, e sen espazos."
+
+#: ../actions/finishopenidlogin.php:170
+#: actions/finishopenidlogin.php:176
+#: actions/finishopenidlogin.php:187
+msgid "Nickname not allowed."
+msgstr "Alcume non permitido."
+
+#: ../actions/remotesubscribe.php:72
+#: actions/remotesubscribe.php:81
+msgid "Nickname of the user you want to follow"
+msgstr "Alcume de usuario que queres"
+
+#: ../actions/recoverpassword.php:162
+#: actions/recoverpassword.php:167
+msgid "Nickname or email"
+msgstr "Alcume ou email"
+
+#: ../actions/deletenotice.php:59
+#: actions/deletenotice.php:60
+#: actions/block.php:104
+msgid "No"
+msgstr "No"
+
+#: ../actions/imsettings.php:156
+#: actions/imsettings.php:164
+#: actions/imsettings.php:169
+msgid "No Jabber ID."
+msgstr "Sen Identificador de Jabber."
+
+#: ../actions/userauthorization.php:129
+#: actions/userauthorization.php:136
+msgid "No authorization request!"
+msgstr "Sen petición de autorización!"
+
+#: ../actions/smssettings.php:181
+#: actions/smssettings.php:189
+#: actions/smssettings.php:191
+msgid "No carrier selected."
+msgstr "Non se seleccionou unha operadora."
+
+#: ../actions/smssettings.php:316
+#: actions/smssettings.php:324
+#: actions/smssettings.php:326
+msgid "No code entered"
+msgstr "Non se inseriu ningún código"
+
+#: ../actions/confirmaddress.php:33
+#: actions/confirmaddress.php:33
+msgid "No confirmation code."
+msgstr "Sen código de confirmación."
+
+#: ../actions/newnotice.php:44
+#: actions/newmessage.php:53
+#: actions/newnotice.php:44
+#: classes/Command.php:197
+#: actions/newmessage.php:52
+#: actions/newnotice.php:53
+msgid "No content!"
+msgstr "Sen contido!"
+
+#: ../actions/emailsettings.php:174
+#: actions/emailsettings.php:192
+#: actions/emailsettings.php:198
+msgid "No email address."
+msgstr "Non se inseriu unha dirección de correo"
+
+#: ../actions/userbyid.php:32
+#: actions/userbyid.php:32
+msgid "No id."
+msgstr "Sen id."
+
+#: ../actions/emailsettings.php:271
+#: actions/emailsettings.php:289
+#: actions/emailsettings.php:293
+msgid "No incoming email address."
+msgstr "Non hai direccións de correo entrante"
+
+#: ../actions/finishremotesubscribe.php:65
+#: actions/finishremotesubscribe.php:67
+#: actions/finishremotesubscribe.php:66
+msgid "No nickname provided by remote server."
+msgstr "O servidor remoto non proporcionou un alcume."
+
+#: ../actions/avatarbynickname.php:27
+#: actions/avatarbynickname.php:27
+msgid "No nickname."
+msgstr "Sen alcume."
+
+#: ../actions/emailsettings.php:222
+#: ../actions/imsettings.php:206
+#: ../actions/smssettings.php:229
+#: actions/emailsettings.php:240
+#: actions/imsettings.php:214
+#: actions/smssettings.php:237
+#: actions/emailsettings.php:244
+#: actions/imsettings.php:219
+#: actions/smssettings.php:239
+msgid "No pending confirmation to cancel."
+msgstr "Non hai ningunha confirmación pendente para cancelar."
+
+#: ../actions/smssettings.php:176
+#: actions/smssettings.php:184
+#: actions/smspostsettings.php:76
+#: actions/smssettings.php:186
+#: actions/smspostsettings.php:81
+msgid "No phone number."
+msgstr "Non hai ningún número de teléfono."
+
+#: ../actions/finishremotesubscribe.php:72
+#: actions/finishremotesubscribe.php:74
+#: actions/finishremotesubscribe.php:73
+msgid "No profile URL returned by server."
+msgstr "O servidor non voltou ningún enderezo de perfil."
+
+#: ../actions/recoverpassword.php:226
+#: actions/recoverpassword.php:232
+msgid "No registered email address for that user."
+msgstr "Non hai un enderezo de correo rexistrado para ese usuario."
+
+#: ../actions/userauthorization.php:49
+#: actions/userauthorization.php:55
+msgid "No request found!"
+msgstr "¡Non se atoparon peticións!"
+
+#: ../actions/noticesearch.php:64
+#: ../actions/peoplesearch.php:64
+#: actions/noticesearch.php:69
+#: actions/peoplesearch.php:69
+#: actions/noticesearch.php:68
+#: actions/peoplesearch.php:59
+msgid "No results"
+msgstr "Non se atoparon resultados"
+
+#: ../actions/avatarbynickname.php:32
+#: actions/avatarbynickname.php:32
+msgid "No size."
+msgstr "Sen tamaño."
+
+#: ../actions/twitapistatuses.php:595
+#: actions/twitapifavorites.php:136
+#: actions/twitapistatuses.php:520
+#: actions/twitapifavorites.php:109
+#: actions/twitapistatuses.php:438
+msgid "No status found with that ID."
+msgstr "Non se atopou un estado con ese ID."
+
+#: ../actions/twitapistatuses.php:555
+#: actions/twitapistatuses.php:478
+#: actions/twitapistatuses.php:411
+msgid "No status with that ID found."
+msgstr "Non existe ningún estado con esa ID atopada."
+
+#: ../actions/openidsettings.php:135
+#: actions/openidsettings.php:144
+msgid "No such OpenID."
+msgstr "Ningún OpenID."
+
+#: ../actions/doc.php:29
+#: actions/doc.php:29
+msgid "No such document."
+msgstr "Ningún documento."
+
+#: ../actions/shownotice.php:32
+#: ../actions/shownotice.php:83
+#: ../lib/deleteaction.php:30
+#: actions/shownotice.php:32
+#: actions/shownotice.php:83
+#: lib/deleteaction.php:30
+#: actions/shownotice.php:38
+#: actions/shownotice.php:114
+msgid "No such notice."
+msgstr "Ningún chío."
+
+#: ../actions/recoverpassword.php:56
+#: actions/recoverpassword.php:56
+msgid "No such recovery code."
+msgstr "Ningún código de recuperación."
+
+#: ../actions/postnotice.php:56
+#: actions/postnotice.php:57
+msgid "No such subscription"
+msgstr "Ningunha subscripción"
+
+#: ../actions/all.php:34
+#: ../actions/allrss.php:35
+#: ../actions/avatarbynickname.php:43
+#: ../actions/foaf.php:40
+#: ../actions/remotesubscribe.php:84
+#: ../actions/remotesubscribe.php:91
+#: ../actions/replies.php:57
+#: ../actions/repliesrss.php:35
+#: ../actions/showstream.php:110
+#: ../actions/userbyid.php:36
+#: ../actions/userrss.php:35
+#: ../actions/xrds.php:35
+#: ../lib/gallery.php:57
+#: ../lib/subs.php:33
+#: ../lib/subs.php:82
+#: actions/all.php:34
+#: actions/allrss.php:35
+#: actions/avatarbynickname.php:43
+#: actions/favoritesrss.php:35
+#: actions/foaf.php:40
+#: actions/ical.php:31
+#: actions/remotesubscribe.php:93
+#: actions/remotesubscribe.php:100
+#: actions/replies.php:57
+#: actions/repliesrss.php:35
+#: actions/showfavorites.php:34
+#: actions/showstream.php:110
+#: actions/userbyid.php:36
+#: actions/userrss.php:35
+#: actions/xrds.php:35
+#: classes/Command.php:120
+#: classes/Command.php:162
+#: classes/Command.php:203
+#: classes/Command.php:237
+#: lib/gallery.php:62
+#: lib/mailbox.php:36
+#: lib/subs.php:33
+#: lib/subs.php:95
+#: actions/showstream.php:157
+#: classes/Command.php:208
+#: classes/Command.php:242
+#: lib/gallery.php:85
+#: lib/subs.php:105
+msgid "No such user."
+msgstr "Ningún usuario."
+
+#: ../actions/recoverpassword.php:211
+#: actions/recoverpassword.php:217
+msgid "No user with that email address or username."
+msgstr "Non hai ningún usuario con isa dirección de correo ou nome de usuario."
+
+#: ../lib/gallery.php:80
+#: lib/gallery.php:85
+#: actions/users.php:59
+msgid "Nobody to show!"
+msgstr "Ninguén para amosar"
+
+#: ../actions/recoverpassword.php:60
+#: actions/recoverpassword.php:60
+msgid "Not a recovery code."
+msgstr "Non é un código de recuperación."
+
+#: ../scripts/maildaemon.php:50
+#: scripts/maildaemon.php:50
+msgid "Not a registered user."
+msgstr "Non é un usuario rexistrado."
+
+#: ../lib/twitterapi.php:226
+#: ../lib/twitterapi.php:247
+#: ../lib/twitterapi.php:332
+#: lib/twitterapi.php:391
+#: lib/twitterapi.php:418
+#: lib/twitterapi.php:502
+#: lib/twitterapi.php:423
+#: lib/twitterapi.php:450
+#: lib/twitterapi.php:534
+msgid "Not a supported data format."
+msgstr "Non é un formato de datos soportado."
+
+#: ../actions/imsettings.php:167
+#: actions/imsettings.php:175
+#: actions/imsettings.php:180
+msgid "Not a valid Jabber ID"
+msgstr "Non é un Identificador de Jabber válido"
+
+#: ../lib/openid.php:131
+#: lib/openid.php:131
+msgid "Not a valid OpenID."
+msgstr "Non é un enderezo OpenID válido."
+
+#: ../actions/emailsettings.php:185
+#: actions/emailsettings.php:203
+#: actions/emailsettings.php:209
+msgid "Not a valid email address"
+msgstr "Non é unha dirección de correo válida"
+
+#: ../actions/register.php:63
+#: actions/register.php:70
+#: actions/register.php:79
+msgid "Not a valid email address."
+msgstr "Non é un enderezo de correo válido."
+
+#: ../actions/profilesettings.php:91
+#: ../actions/register.php:71
+#: actions/profilesettings.php:206
+#: actions/register.php:78
+#: actions/profilesettings.php:225
+#: actions/register.php:87
+msgid "Not a valid nickname."
+msgstr "Non é un alcume válido."
+
+#: ../actions/remotesubscribe.php:120
+#: actions/remotesubscribe.php:129
+msgid "Not a valid profile URL (incorrect services)."
+msgstr "Non é un enderezo de perfil válido (servizos incorrectos)."
+
+#: ../actions/remotesubscribe.php:113
+#: actions/remotesubscribe.php:122
+msgid "Not a valid profile URL (no XRDS defined)."
+msgstr "Non é un enderezo de perfil válido (non está definido ningún XRDS)."
+
+#: ../actions/remotesubscribe.php:104
+#: actions/remotesubscribe.php:113
+msgid "Not a valid profile URL (no YADIS document)."
+msgstr "Non é un enderezo de perfil válido (non ten documento YADIS)."
+
+#: ../actions/avatar.php:95
+#: actions/profilesettings.php:332
+#: actions/profilesettings.php:378
+msgid "Not an image or corrupt file."
+msgstr "Non é unha imaxe ou está corrupta."
+
+#: ../actions/finishremotesubscribe.php:51
+#: actions/finishremotesubscribe.php:53
+#: actions/finishremotesubscribe.php:52
+msgid "Not authorized."
+msgstr "Non está autorizado."
+
+#: ../actions/finishremotesubscribe.php:38
+#: actions/finishremotesubscribe.php:38
+msgid "Not expecting this response!"
+msgstr "¡Non esperaba esa resposta!"
+
+#: ../actions/twitapistatuses.php:422
+#: actions/twitapistatuses.php:361
+#: actions/twitapistatuses.php:304
+msgid "Not found"
+msgstr "Non atopado"
+
+#: ../actions/finishaddopenid.php:29
+#: ../actions/logout.php:33
+#: ../actions/newnotice.php:29
+#: ../actions/subscribe.php:28
+#: ../actions/unsubscribe.php:25
+#: ../lib/deleteaction.php:38
+#: ../lib/settingsaction.php:27
+#: actions/disfavor.php:29
+#: actions/favor.php:30
+#: actions/finishaddopenid.php:29
+#: actions/logout.php:33
+#: actions/newmessage.php:28
+#: actions/newnotice.php:29
+#: actions/subscribe.php:28
+#: actions/unsubscribe.php:25
+#: lib/deleteaction.php:38
+#: lib/settingsaction.php:27
+#: actions/block.php:31
+#: actions/misc.php:27
+#: actions/newnotice.php:30
+#: actions/nudge.php:30
+#: actions/subedit.php:31
+#: actions/unblock.php:31
+msgid "Not logged in."
+msgstr "Non está logueado."
+
+#: ../lib/subs.php:91
+#: lib/subs.php:104
+#: lib/subs.php:117
+msgid "Not subscribed!."
+msgstr "Non está suscrito!"
+
+#: ../actions/opensearch.php:35
+#: actions/opensearch.php:35
+msgid "Notice Search"
+msgstr "Procura de Chíos"
+
+#: ../actions/showstream.php:82
+#: actions/showstream.php:82
+#: actions/showstream.php:111
+#: actions/showstream.php:118
+#: actions/showstream.php:123
+#, php-format
+msgid "Notice feed for %s"
+msgstr "Fonte de chíos para %s"
+
+#: ../actions/shownotice.php:39
+#: actions/shownotice.php:39
+#: actions/shownotice.php:45
+msgid "Notice has no profile"
+msgstr "O chío non ten perfil"
+
+#: ../actions/showstream.php:316
+#: actions/showstream.php:331
+#: actions/showstream.php:379
+msgid "Notices"
+msgstr "Chíos"
+
+#: ../actions/tag.php:35
+#: ../actions/tag.php:81
+#: actions/tag.php:35
+#: actions/tag.php:81
+#, php-format
+msgid "Notices tagged with %s"
+msgstr "Chíos tagueados con %s"
+
+#: ../actions/password.php:39
+#: actions/profilesettings.php:178
+#: actions/profilesettings.php:195
+msgid "Old password"
+msgstr "Contrasinal antiga"
+
+#: ../lib/settingsaction.php:96
+#: ../lib/util.php:314
+#: lib/settingsaction.php:90
+#: lib/util.php:330
+#: actions/deleteprofile.php:247
+msgid "OpenID"
+msgstr "OpenID"
+
+#: ../actions/finishopenidlogin.php:61
+#: actions/finishopenidlogin.php:66
+msgid "OpenID Account Setup"
+msgstr "Configuración de conta OpenID"
+
+#: ../lib/openid.php:180
+#: lib/openid.php:180
+msgid "OpenID Auto-Submit"
+msgstr "Auto-Envío de OpenID"
+
+#: ../actions/finishaddopenid.php:99
+#: ../actions/finishopenidlogin.php:140
+#: ../actions/openidlogin.php:60
+#: actions/finishaddopenid.php:99
+#: actions/finishopenidlogin.php:146
+#: actions/openidlogin.php:68
+#: actions/finishopenidlogin.php:150
+#: actions/openidlogin.php:76
+msgid "OpenID Login"
+msgstr "Acceso OpenID"
+
+#: ../actions/openidlogin.php:65
+#: ../actions/openidsettings.php:49
+#: actions/openidlogin.php:74
+#: actions/openidsettings.php:50
+#: actions/login.php:125
+#: actions/openidlogin.php:82
+msgid "OpenID URL"
+msgstr "Enderezo OpenID"
+
+#: ../actions/finishaddopenid.php:42
+#: ../actions/finishopenidlogin.php:103
+#: actions/finishaddopenid.php:42
+#: actions/finishopenidlogin.php:109
+msgid "OpenID authentication cancelled."
+msgstr "Autenticación OpenID cancelada."
+
+#: ../actions/finishaddopenid.php:46
+#: ../actions/finishopenidlogin.php:107
+#: actions/finishaddopenid.php:46
+#: actions/finishopenidlogin.php:113
+#, php-format
+msgid "OpenID authentication failed: %s"
+msgstr "A autenticación OpenID fallou: %s"
+
+#: ../lib/openid.php:133
+#: lib/openid.php:133
+#, php-format
+msgid "OpenID failure: %s"
+msgstr "Fallou o OpenID: %s"
+
+#: ../actions/openidsettings.php:144
+#: actions/openidsettings.php:153
+msgid "OpenID removed."
+msgstr "OpenID eliminado."
+
+#: ../actions/openidsettings.php:37
+#: actions/openidsettings.php:37
+msgid "OpenID settings"
+msgstr "Configuracións de OpenID"
+
+#: ../actions/invite.php:135
+#: actions/invite.php:143
+msgid "Optionally add a personal message to the invitation."
+msgstr "Opcionalmente engadir unha mensaxe persoal á invitación."
+
+#: ../actions/avatar.php:84
+#: actions/profilesettings.php:321
+#: actions/profilesettings.php:367
+msgid "Partial upload."
+msgstr "Carga parcial."
+
+#: ../actions/finishopenidlogin.php:90
+#: ../actions/login.php:102
+#: ../actions/register.php:153
+#: ../lib/settingsaction.php:93
+#: actions/finishopenidlogin.php:96
+#: actions/login.php:102
+#: actions/register.php:167
+#: actions/login.php:109
+#: actions/register.php:194
+msgid "Password"
+msgstr "Contrasinal"
+
+#: ../actions/recoverpassword.php:288
+#: actions/recoverpassword.php:301
+msgid "Password and confirmation do not match."
+msgstr "A contrasinal e a súa confirmación non coinciden."
+
+#: ../actions/recoverpassword.php:284
+#: actions/recoverpassword.php:297
+msgid "Password must be 6 chars or more."
+msgstr "A contrasinal debe ter 6 caracteres ou máis."
+
+#: ../actions/recoverpassword.php:261
+#: ../actions/recoverpassword.php:263
+#: actions/recoverpassword.php:267
+#: actions/recoverpassword.php:269
+msgid "Password recovery requested"
+msgstr "Petición de recuperación de contrasinal"
+
+#: ../actions/password.php:89
+#: ../actions/recoverpassword.php:313
+#: actions/profilesettings.php:408
+#: actions/recoverpassword.php:326
+#: actions/profilesettings.php:454
+msgid "Password saved."
+msgstr "Contrasinal gardada."
+
+#: ../actions/password.php:61
+#: ../actions/register.php:88
+#: actions/profilesettings.php:380
+#: actions/register.php:98
+#: actions/profilesettings.php:426
+#: actions/register.php:107
+msgid "Passwords don't match."
+msgstr "As contrasinais non coinciden"
+
+#: ../lib/searchaction.php:100
+#: lib/searchaction.php:100
+msgid "People"
+msgstr "Xente"
+
+#: ../actions/opensearch.php:33
+#: actions/opensearch.php:33
+msgid "People Search"
+msgstr "Procurar xente"
+
+#: ../actions/peoplesearch.php:33
+#: actions/peoplesearch.php:33
+msgid "People search"
+msgstr "Procurar xente."
+
+#: ../lib/stream.php:50
+#: lib/personal.php:50
+msgid "Personal"
+msgstr "Persoal"
+
+#: ../actions/invite.php:133
+#: actions/invite.php:141
+msgid "Personal message"
+msgstr "Mensaxe persoal"
+
+#: ../actions/smssettings.php:69
+#: actions/smssettings.php:69
+#: actions/smspostsettings.php:49
+#: actions/smspostsettings.php:50
+msgid "Phone number, no punctuation or spaces, with area code"
+msgstr "Número de teléfono, sen puntuacións ou espazos, co código de área"
+
+#: ../actions/userauthorization.php:78
+#: actions/userauthorization.php:84
+msgid "Please check these details to make sure that you want to subscribe to this user's notices. If you didn't just ask to subscribe to someone's notices, click \"Cancel\"."
+msgstr "Please check these details to make sure that you want to subscribe to this user's notices. If you didn't just ask to subscribe to someone's notices, click \"Cancel\"."
+
+#: ../actions/imsettings.php:73
+#: actions/imsettings.php:74
+msgid "Post a notice when my Jabber/GTalk status changes."
+msgstr "Post a notice when my Jabber/GTalk status changes."
+
+#: ../actions/emailsettings.php:85
+#: ../actions/imsettings.php:67
+#: ../actions/smssettings.php:94
+#: actions/emailsettings.php:86
+#: actions/imsettings.php:68
+#: actions/smssettings.php:94
+#: actions/twittersettings.php:70
+msgid "Preferences"
+msgstr "Preferencias"
+
+#: ../actions/emailsettings.php:162
+#: ../actions/imsettings.php:144
+#: ../actions/smssettings.php:163
+#: actions/emailsettings.php:180
+#: actions/imsettings.php:152
+#: actions/smssettings.php:171
+#: actions/emailsettings.php:186
+#: actions/imsettings.php:157
+#: actions/othersettings.php:179
+#: actions/smssettings.php:173
+msgid "Preferences saved."
+msgstr "Preferencias gardadas."
+
+#: ../actions/profilesettings.php:57
+#: actions/profilesettings.php:90
+#: actions/profilesettings.php:98
+msgid "Preferred language"
+msgstr "Linguaxe preferida"
+
+#: ../lib/util.php:328
+#: lib/util.php:344
+#: lib/util.php:373
+msgid "Privacy"
+msgstr "Privacidade"
+
+#: ../classes/Notice.php:95
+#: ../classes/Notice.php:106
+#: classes/Notice.php:109
+#: classes/Notice.php:119
+#: classes/Notice.php:139
+#: classes/Notice.php:149
+msgid "Problem saving notice."
+msgstr "Aconteceu un erro ó gardar o chío."
+
+#: ../lib/settingsaction.php:84
+#: ../lib/stream.php:60
+#: lib/personal.php:60
+#: lib/settingsaction.php:84
+#: actions/deleteprofile.php:241
+msgid "Profile"
+msgstr "Perfil"
+
+#: ../actions/remotesubscribe.php:73
+#: actions/remotesubscribe.php:82
+msgid "Profile URL"
+msgstr "Enderezo de perfil"
+
+#: ../actions/profilesettings.php:34
+#: actions/profilesettings.php:32
+msgid "Profile settings"
+msgstr "Configuración de perfil"
+
+#: ../actions/postnotice.php:51
+#: ../actions/updateprofile.php:52
+#: actions/postnotice.php:52
+#: actions/updateprofile.php:53
+msgid "Profile unknown"
+msgstr "Perfil descoñecido"
+
+#: ../actions/public.php:54
+#: actions/public.php:54
+#: actions/public.php:77
+msgid "Public Stream Feed"
+msgstr "Sindicación do Fio Público"
+
+#: ../actions/public.php:33
+#: actions/public.php:33
+#: lib/stream.php:34
+msgid "Public timeline"
+msgstr "Liña de tempo pública"
+
+#: ../actions/imsettings.php:79
+#: actions/imsettings.php:80
+msgid "Publish a MicroID for my Jabber/GTalk address."
+msgstr "Publicar unha MicroID dende a miña dirección de Jabber/GTalk."
+
+#: ../actions/emailsettings.php:94
+#: actions/emailsettings.php:101
+msgid "Publish a MicroID for my email address."
+msgstr "Publicar unha MicroID dende a miña dirección de correo."
+
+#: ../actions/tag.php:75
+#: ../actions/tag.php:76
+#: actions/tag.php:75
+#: actions/tag.php:76
+msgid "Recent Tags"
+msgstr "Tags Recentes"
+
+#: ../actions/recoverpassword.php:166
+#: actions/recoverpassword.php:171
+msgid "Recover"
+msgstr "Recuperar"
+
+#: ../actions/recoverpassword.php:156
+#: actions/recoverpassword.php:161
+msgid "Recover password"
+msgstr "Recuperar contrasinal"
+
+#: ../actions/recoverpassword.php:67
+#: actions/recoverpassword.php:67
+msgid "Recovery code for unknown user."
+msgstr "Código de recuperación para usuario descoñecido."
+
+#: ../actions/register.php:142
+#: ../actions/register.php:193
+#: ../lib/util.php:312
+#: actions/register.php:152
+#: actions/register.php:207
+#: lib/util.php:328
+#: actions/register.php:181
+#: actions/register.php:234
+#: lib/util.php:354
+msgid "Register"
+msgstr "Rexistrar"
+
+#: ../actions/register.php:28
+#: actions/register.php:28
+#: actions/finishopenidlogin.php:173
+msgid "Registration not allowed."
+msgstr "Non se permite o rexistro neste intre."
+
+#: ../actions/register.php:200
+#: actions/register.php:214
+#: actions/register.php:241
+msgid "Registration successful"
+msgstr "Xa estas rexistrado!!"
+
+#: ../actions/userauthorization.php:120
+#: actions/userauthorization.php:127
+msgid "Reject"
+msgstr "Rexeitar"
+
+#: ../actions/login.php:103
+#: ../actions/register.php:176
+#: actions/login.php:103
+#: actions/register.php:190
+#: actions/login.php:110
+#: actions/openidlogin.php:85
+#: actions/register.php:217
+msgid "Remember me"
+msgstr "Lembrarme"
+
+#: ../actions/updateprofile.php:70
+#: actions/updateprofile.php:71
+msgid "Remote profile with no matching profile"
+msgstr "Non hai ningún perfil que coincida co perfil remoto"
+
+#: ../actions/remotesubscribe.php:65
+#: actions/remotesubscribe.php:73
+msgid "Remote subscribe"
+msgstr "Suscrición remota"
+
+#: ../actions/emailsettings.php:47
+#: ../actions/emailsettings.php:75
+#: ../actions/imsettings.php:48
+#: ../actions/openidsettings.php:106
+#: ../actions/smssettings.php:50
+#: ../actions/smssettings.php:84
+#: actions/emailsettings.php:48
+#: actions/emailsettings.php:76
+#: actions/imsettings.php:49
+#: actions/openidsettings.php:108
+#: actions/smssettings.php:50
+#: actions/smssettings.php:84
+#: actions/twittersettings.php:59
+#: actions/smspostsettings.php:45
+#: actions/twittersettings.php:61
+#: actions/smspostsettings.php:46
+msgid "Remove"
+msgstr "Eliminar"
+
+#: ../actions/openidsettings.php:68
+#: actions/openidsettings.php:69
+msgid "Remove OpenID"
+msgstr "Eliminar OpenID"
+
+#: ../actions/openidsettings.php:73
+#: actions/openidsettings.php:74
+msgid "Removing your only OpenID would make it impossible to log in! If you need to remove it, add another OpenID first."
+msgstr "Eliminando o teu enderezo OpenID vaiche ser imposible acceder! Se queres eliminalo, primeiro engade outro enderezo OpenID."
+
+#: ../lib/stream.php:55
+#: lib/personal.php:55
+msgid "Replies"
+msgstr "Respostas"
+
+#: ../actions/replies.php:47
+#: ../actions/repliesrss.php:76
+#: ../lib/stream.php:56
+#: actions/replies.php:47
+#: actions/repliesrss.php:62
+#: lib/personal.php:56
+#, php-format
+msgid "Replies to %s"
+msgstr "Replies to %s"
+
+#: ../actions/recoverpassword.php:183
+#: actions/recoverpassword.php:189
+msgid "Reset"
+msgstr "Restaurar"
+
+#: ../actions/recoverpassword.php:173
+#: actions/recoverpassword.php:178
+msgid "Reset password"
+msgstr "Restaurar contrasinal"
+
+#: ../lib/settingsaction.php:99
+#: lib/settingsaction.php:93
+#: actions/deleteprofile.php:250
+#: actions/subscriptions.php:73
+msgid "SMS"
+msgstr "SMS"
+
+#: ../actions/smssettings.php:67
+#: actions/smssettings.php:67
+#: actions/smspostsettings.php:38
+#: actions/smspostsettings.php:39
+msgid "SMS Phone number"
+msgstr "Número de Teléfono do SMS"
+
+#: ../actions/smssettings.php:33
+#: actions/smssettings.php:33
+msgid "SMS Settings"
+msgstr "Configuracións de SMS"
+
+#: ../lib/mail.php:219
+#: lib/mail.php:225
+#: lib/mail.php:220
+msgid "SMS confirmation"
+msgstr "Confirmación de SMS"
+
+#: ../actions/recoverpassword.php:182
+#: actions/recoverpassword.php:188
+msgid "Same as password above"
+msgstr "Igual que a contrasinal de enriba"
+
+#: ../actions/register.php:156
+#: actions/register.php:170
+#: actions/register.php:197
+msgid "Same as password above. Required."
+msgstr "A mesma contrasinal que arriba. Requerido."
+
+#: ../actions/emailsettings.php:97
+#: ../actions/imsettings.php:81
+#: ../actions/profilesettings.php:67
+#: ../actions/smssettings.php:100
+#: actions/emailsettings.php:104
+#: actions/imsettings.php:82
+#: actions/profilesettings.php:101
+#: actions/smssettings.php:100
+#: actions/twittersettings.php:83
+#: actions/emailsettings.php:108
+#: actions/imsettings.php:85
+#: actions/othersettings.php:56
+#: actions/profilesettings.php:118
+#: actions/subscriptions.php:74
+#: actions/tagother.php:100
+#: actions/twittersettings.php:82
+msgid "Save"
+msgstr "Gardar"
+
+#: ../lib/searchaction.php:84
+#: ../lib/util.php:300
+#: lib/searchaction.php:84
+#: lib/util.php:316
+#: lib/util.php:345
+msgid "Search"
+msgstr "Buscar"
+
+#: ../actions/noticesearch.php:80
+#: actions/noticesearch.php:85
+#: actions/noticesearch.php:84
+msgid "Search Stream Feed"
+msgstr "Procura no Fío"
+
+#: ../actions/noticesearch.php:30
+#: actions/noticesearch.php:30
+#: actions/noticesearch.php:29
+#, php-format
+msgid "Search for notices on %%site.name%% by their contents. Separate search terms by spaces; they must be 3 characters or more."
+msgstr "Procurar chíos en %%site.name%% polos seus contidos. Separa os termos de procura por espazos, deben ter 3 caracteres ou máis."
+
+#: ../actions/peoplesearch.php:28
+#: actions/peoplesearch.php:28
+#, php-format
+msgid "Search for people on %%site.name%% by their name, location, or interests. Separate the terms by spaces; they must be 3 characters or more."
+msgstr "Procurar xente en %%site.name%% pola seu nome, localización, ou intereses. Separa os termos por espazos; deben ter 3 caracteres ou máis."
+
+#: ../actions/smssettings.php:296
+#: actions/smssettings.php:304
+#: actions/smssettings.php:306
+msgid "Select a carrier"
+msgstr "Selecciona unha operadora"
+
+#: ../actions/invite.php:137
+#: ../lib/util.php:1172
+#: actions/invite.php:145
+#: lib/util.php:1306
+#: lib/util.php:1731
+#: lib/util.php:1705
+#: lib/util.php:2217
+msgid "Send"
+msgstr "Enviar"
+
+#: ../actions/emailsettings.php:73
+#: ../actions/smssettings.php:82
+#: actions/emailsettings.php:74
+#: actions/smssettings.php:82
+msgid "Send email to this address to post new notices."
+msgstr "Enviar un correo a esta dirección para enviar novos chíos."
+
+#: ../actions/emailsettings.php:88
+#: actions/emailsettings.php:89
+msgid "Send me notices of new subscriptions through email."
+msgstr "Envíame chios de novas suscricións por email."
+
+#: ../actions/imsettings.php:70
+#: actions/imsettings.php:71
+msgid "Send me notices through Jabber/GTalk."
+msgstr "Enviarme advertencias a través de Jabber/GTalk."
+
+#: ../actions/smssettings.php:97
+#: actions/smssettings.php:97
+msgid "Send me notices through SMS; I understand I may incur exorbitant charges from my carrier."
+msgstr "Enviarme chíos mediante SMS, entendo que a miña operadora poida cobrarme grandes facturas."
+
+#: ../actions/imsettings.php:76
+#: actions/imsettings.php:77
+msgid "Send me replies through Jabber/GTalk from people I'm not subscribed to."
+msgstr "Envíame respostas a través de Jabber/GTalk da xente á que non estou suscrito."
+
+#: ../lib/util.php:304
+#: lib/util.php:320
+#: lib/util.php:348
+msgid "Settings"
+msgstr "Configuración"
+
+#: ../actions/profilesettings.php:192
+#: actions/profilesettings.php:307
+#: actions/profilesettings.php:353
+msgid "Settings saved."
+msgstr "Configuracións gardadas."
+
+#: ../actions/tag.php:60
+#: actions/tag.php:60
+#: actions/tag.php:67
+msgid "Showing most popular tags from the last week"
+msgstr "Amoa os tags máis populares dende a semana pasada"
+
+#: ../actions/finishaddopenid.php:66
+#: actions/finishaddopenid.php:66
+msgid "Someone else already has this OpenID."
+msgstr "Alguen máis ten ese enderezo OpenID."
+
+#: ../actions/finishopenidlogin.php:42
+#: ../actions/openidsettings.php:126
+#: actions/finishopenidlogin.php:47
+#: actions/openidsettings.php:135
+msgid "Something weird happened."
+msgstr "Algo gordo aconteceu."
+
+#: ../scripts/maildaemon.php:58
+#: scripts/maildaemon.php:58
+msgid "Sorry, no incoming email allowed."
+msgstr "Aivá, non se permiten correos entrantes."
+
+#: ../scripts/maildaemon.php:54
+#: scripts/maildaemon.php:54
+msgid "Sorry, that is not your incoming email address."
+msgstr "Ise é un enderezo IM incorrecto."
+
+#: ../lib/util.php:330
+#: lib/util.php:346
+#: lib/util.php:375
+msgid "Source"
+msgstr "Fonte"
+
+#: ../actions/showstream.php:296
+#: actions/showstream.php:311
+#: actions/showstream.php:359
+#: actions/misc.php:87
+msgid "Statistics"
+msgstr "Estatísticas"
+
+#: ../actions/finishopenidlogin.php:182
+#: ../actions/finishopenidlogin.php:246
+#: actions/finishopenidlogin.php:188
+#: actions/finishopenidlogin.php:252
+#: actions/finishopenidlogin.php:199
+#: actions/finishopenidlogin.php:267
+msgid "Stored OpenID not found."
+msgstr "OpenID almacenado non atopado"
+
+#: ../actions/remotesubscribe.php:75
+#: ../actions/showstream.php:188
+#: ../actions/showstream.php:197
+#: actions/remotesubscribe.php:84
+#: actions/showstream.php:197
+#: actions/showstream.php:206
+#: actions/showstream.php:254
+#: lib/util.php:2137
+msgid "Subscribe"
+msgstr "Subscribir"
+
+#: ../actions/showstream.php:313
+#: ../actions/subscribers.php:27
+#: actions/showstream.php:328
+#: actions/subscribers.php:27
+#: actions/showstream.php:376
+#: lib/gallery.php:136
+#: lib/gallery.php:137
+msgid "Subscribers"
+msgstr "Subscritores"
+
+#: ../actions/userauthorization.php:310
+#: actions/userauthorization.php:322
+msgid "Subscription authorized"
+msgstr "Subscrición autorizada"
+
+#: ../actions/userauthorization.php:320
+#: actions/userauthorization.php:332
+msgid "Subscription rejected"
+msgstr "Subscrición rexeitada"
+
+#: ../actions/showstream.php:230
+#: ../actions/showstream.php:307
+#: ../actions/subscriptions.php:27
+#: actions/showstream.php:240
+#: actions/showstream.php:322
+#: actions/subscriptions.php:27
+#: actions/showstream.php:288
+#: actions/showstream.php:370
+#: lib/gallery.php:131
+#: lib/gallery.php:132
+msgid "Subscriptions"
+msgstr "Subscricións"
+
+#: ../actions/avatar.php:87
+#: actions/profilesettings.php:324
+#: actions/profilesettings.php:370
+msgid "System error uploading file."
+msgstr "Aconteceu un erro no sistema namentras se estaba cargando o ficheiro."
+
+#: ../actions/tag.php:41
+#: ../lib/util.php:301
+#: actions/tag.php:41
+#: lib/util.php:317
+#: actions/profilesettings.php:90
+#: actions/showstream.php:382
+#: actions/tagother.php:96
+#: actions/tagother.php:162
+#: actions/tag.php:47
+#: lib/profilelist.php:126
+#: lib/profilelist.php:128
+msgid "Tags"
+msgstr "Tags"
+
+#: ../lib/searchaction.php:104
+#: lib/searchaction.php:104
+msgid "Text"
+msgstr "Texto"
+
+#: ../actions/noticesearch.php:34
+#: actions/noticesearch.php:34
+#: actions/noticesearch.php:33
+msgid "Text search"
+msgstr "Procura de texto"
+
+#: ../actions/openidsettings.php:140
+#: actions/openidsettings.php:149
+msgid "That OpenID does not belong to you."
+msgstr "Ese OpenID non che pertence."
+
+#: ../actions/confirmaddress.php:52
+#: actions/confirmaddress.php:52
+msgid "That address has already been confirmed."
+msgstr "Esa dirección xa foi confirmada."
+
+#: ../actions/confirmaddress.php:43
+#: actions/confirmaddress.php:43
+msgid "That confirmation code is not for you!"
+msgstr "¡Ese código de confirmación non é para ti!"
+
+#: ../actions/emailsettings.php:191
+#: actions/emailsettings.php:209
+#: actions/emailsettings.php:215
+msgid "That email address already belongs to another user."
+msgstr "Este enderezo de correo xa pertence a outro usuario."
+
+#: ../actions/avatar.php:80
+#: actions/profilesettings.php:317
+#: actions/profilesettings.php:363
+msgid "That file is too big."
+msgstr "Ese arquivo é demasiado grande."
+
+#: ../actions/imsettings.php:170
+#: actions/imsettings.php:178
+#: actions/imsettings.php:183
+msgid "That is already your Jabber ID."
+msgstr "Xa é a túa conta de Jabber."
+
+#: ../actions/emailsettings.php:188
+#: actions/emailsettings.php:206
+#: actions/emailsettings.php:212
+msgid "That is already your email address."
+msgstr "Xa é o teu enderezo de correo."
+
+#: ../actions/smssettings.php:188
+#: actions/smssettings.php:196
+#: actions/smspostsettings.php:83
+#: actions/smssettings.php:198
+#: actions/smspostsettings.php:88
+msgid "That is already your phone number."
+msgstr "Xa é o teu número de teléfono."
+
+#: ../actions/imsettings.php:233
+#: actions/imsettings.php:241
+#: actions/imsettings.php:246
+msgid "That is not your Jabber ID."
+msgstr "Esa non é a túa conta Jabber."
+
+#: ../actions/emailsettings.php:249
+#: actions/emailsettings.php:267
+#: actions/emailsettings.php:271
+msgid "That is not your email address."
+msgstr "Esa non é a túa dirección de correo."
+
+#: ../actions/smssettings.php:257
+#: actions/smssettings.php:265
+#: actions/smspostsettings.php:113
+#: actions/smssettings.php:267
+#: actions/smspostsettings.php:118
+msgid "That is not your phone number."
+msgstr "Ese non é o teu número de teléfono."
+
+#: ../actions/emailsettings.php:226
+#: ../actions/imsettings.php:210
+#: actions/emailsettings.php:244
+#: actions/imsettings.php:218
+#: actions/emailsettings.php:248
+#: actions/imsettings.php:223
+msgid "That is the wrong IM address."
+msgstr "Esa é unha enderezo IM incorrecto."
+
+#: ../actions/smssettings.php:233
+#: actions/smssettings.php:241
+#: actions/smssettings.php:243
+msgid "That is the wrong confirmation number."
+msgstr "Ese é un número de confirmación incorrecto."
+
+#: ../actions/smssettings.php:191
+#: actions/smssettings.php:199
+#: actions/smspostsettings.php:86
+#: actions/smssettings.php:201
+#: actions/smspostsettings.php:91
+msgid "That phone number already belongs to another user."
+msgstr "O número de teléfono xa pertence a outro usuario."
+
+#: ../actions/newnotice.php:49
+#: ../actions/twitapistatuses.php:408
+#: actions/newnotice.php:49
+#: actions/twitapistatuses.php:330
+#: actions/newnotice.php:61
+#: actions/newsmsnotice.php:73
+#: actions/twitapistatuses.php:271
+#: actions/newsmsnotice.php:79
+msgid "That's too long. Max notice size is 140 chars."
+msgstr "Iso é demasiado longo. O tamaño máximo para un chío é de 140 caracteres."
+
+#: ../actions/twitapiaccount.php:74
+#: actions/twitapiaccount.php:72
+#: actions/twitapiaccount.php:58
+msgid "That's too long. Max notice size is 255 chars."
+msgstr "Iso é demasiado longo. O tamaño máximo para un chío é de 255 caracteres."
+
+#: ../actions/confirmaddress.php:92
+#: actions/confirmaddress.php:92
+#, php-format
+msgid "The address \"%s\" has been confirmed for your account."
+msgstr "A dirección \"%s\" xa foi confirmada para a túa conta."
+
+#: ../actions/emailsettings.php:264
+#: ../actions/imsettings.php:250
+#: ../actions/smssettings.php:274
+#: actions/emailsettings.php:282
+#: actions/imsettings.php:258
+#: actions/smssettings.php:282
+#: actions/emailsettings.php:286
+#: actions/imsettings.php:263
+#: actions/smspostsettings.php:128
+#: actions/smssettings.php:284
+#: actions/smspostsettings.php:133
+msgid "The address was removed."
+msgstr "Enderezo eliminado."
+
+#: ../actions/userauthorization.php:312
+#: actions/userauthorization.php:324
+msgid "The subscription has been authorized, but no callback URL was passed. Check with the site's instructions for details on how to authorize the subscription. Your subscription token is:"
+msgstr "A subscrición foi autorizada, pero ningunha URL de retorno foi proporcionada. Comproba coas instruccións do sitio para máis detalles en como autorizar subscricións. O teu token de subscrición é:"
+
+#: ../actions/userauthorization.php:322
+#: actions/userauthorization.php:334
+msgid "The subscription has been rejected, but no callback URL was passed. Check with the site's instructions for details on how to fully reject the subscription."
+msgstr "The subscription has been rejected, but no callback URL was passed. Check with the site's instructions for details on how to fully reject the subscription."
+
+#: ../actions/subscribers.php:35
+#: actions/subscribers.php:35
+#, php-format
+msgid "These are the people who listen to %s's notices."
+msgstr "Esa é a xente que escoita os chíos de %s."
+
+#: ../actions/subscribers.php:33
+#: actions/subscribers.php:33
+msgid "These are the people who listen to your notices."
+msgstr "Esa é a xente que escoita os teus chíos."
+
+#: ../actions/subscriptions.php:35
+#: actions/subscriptions.php:35
+#, php-format
+msgid "These are the people whose notices %s listens to."
+msgstr "Esta é a xente á que lle estas a escoitar os chíos %s."
+
+#: ../actions/subscriptions.php:33
+#: actions/subscriptions.php:33
+msgid "These are the people whose notices you listen to."
+msgstr "Esa é a xente á que lle estas a escoitar os seus chíos"
+
+#: ../actions/invite.php:89
+#: actions/invite.php:96
+msgid "These people are already users and you were automatically subscribed to them:"
+msgstr "Esta xente xa é usuario e ti foches suscrito automaticamente a eles:"
+
+#: ../actions/recoverpassword.php:88
+#: actions/recoverpassword.php:91
+msgid "This confirmation code is too old. Please start again."
+msgstr "Ese código de confirmación é demasiado antigo. Comeza de novo."
+
+#: ../lib/openid.php:195
+#: lib/openid.php:195
+msgid "This form should automatically submit itself. If not, click the submit button to go to your OpenID provider."
+msgstr "Este formulario debería enviarse automáticamente. Se non é así, fai clic no botón de enviar para ir ó teu proveedro OpenID."
+
+#: ../actions/finishopenidlogin.php:56
+#: actions/finishopenidlogin.php:61
+#, php-format
+msgid "This is the first time you've logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one."
+msgstr "Esta é a primeria vez que accedes a %s polo que debes conectar o teu enderezo OpenID á conta local. Podes ademáis crear unha nova conta, ou conectarte cunha existente, se xa tes unha."
+
+#: ../actions/twitapifriendships.php:108
+#: ../actions/twitapistatuses.php:586
+#: actions/twitapifavorites.php:127
+#: actions/twitapifriendships.php:108
+#: actions/twitapistatuses.php:511
+#: actions/twitapifavorites.php:94
+#: actions/twitapifriendships.php:82
+#: actions/twitapistatuses.php:428
+msgid "This method requires a POST or DELETE."
+msgstr "Este método require un POST ou DELETE."
+
+#: ../actions/twitapiaccount.php:65
+#: ../actions/twitapifriendships.php:44
+#: ../actions/twitapistatuses.php:381
+#: actions/twitapiaccount.php:63
+#: actions/twitapidirect_messages.php:114
+#: actions/twitapifriendships.php:44
+#: actions/twitapistatuses.php:303
+#: actions/twitapiaccount.php:49
+#: actions/twitapidirect_messages.php:117
+#: actions/twitapifriendships.php:30
+#: actions/twitapistatuses.php:239
+msgid "This method requires a POST."
+msgstr "Este método require un POST."
+
+#: ../lib/util.php:164
+#: lib/util.php:246
+#: lib/util.php:263
+msgid "This page is not available in a media type you accept"
+msgstr "Esta páxina non está dispoñíbel no tipo de medio que aceptas"
+
+#: ../actions/profilesettings.php:63
+#: actions/profilesettings.php:96
+#: actions/profilesettings.php:109
+msgid "Timezone"
+msgstr "Fuso Horario"
+
+#: ../actions/profilesettings.php:107
+#: actions/profilesettings.php:222
+#: actions/profilesettings.php:241
+msgid "Timezone not selected."
+msgstr "Fuso Horario non seleccionado"
+
+#: ../actions/remotesubscribe.php:43
+#: actions/remotesubscribe.php:51
+#, php-format
+msgid "To subscribe, you can [login](%%action.login%%), or [register](%%action.register%%) a new account. If you already have an account on a [compatible microblogging site](%%doc.openmublog%%), enter your profile URL below."
+msgstr "Para subscribirse, podes [acceder](%%action.login%%), ou [rexistrar](%%action.register%%) unha nova conta. Se xa tes unha conta nun [sitio de microblogaxe compatíbel](%%doc.openmublog%%), insire a dirección do perfil abaixo."
+
+#: ../actions/twitapifriendships.php:163
+#: actions/twitapifriendships.php:167
+#: actions/twitapifriendships.php:128
+msgid "Two user ids or screen_names must be supplied."
+msgstr "Dous identificadores de usuario ou nomes_en_pantalla deben ser proporcionados."
+
+#: ../actions/profilesettings.php:48
+#: ../actions/register.php:169
+#: actions/profilesettings.php:81
+#: actions/register.php:183
+#: actions/profilesettings.php:83
+#: actions/register.php:210
+msgid "URL of your homepage, blog, or profile on another site"
+msgstr "Enderezo da túa páxina persoal, blogue, ou perfil noutro sitio"
+
+#: ../actions/remotesubscribe.php:74
+#: actions/remotesubscribe.php:83
+msgid "URL of your profile on another compatible microblogging service"
+msgstr "Enderezo do teu perfil en outro servizo de microblogaxe compatíbel"
+
+#: ../actions/emailsettings.php:130
+#: ../actions/imsettings.php:110
+#: ../actions/recoverpassword.php:39
+#: ../actions/smssettings.php:135
+#: actions/emailsettings.php:144
+#: actions/imsettings.php:118
+#: actions/recoverpassword.php:39
+#: actions/smssettings.php:143
+#: actions/twittersettings.php:108
+#: actions/emailsettings.php:148
+#: actions/imsettings.php:121
+#: actions/othersettings.php:146
+#: actions/smspostsettings.php:64
+#: actions/smssettings.php:145
+#: actions/twittersettings.php:199
+#: actions/smspostsettings.php:69
+msgid "Unexpected form submission."
+msgstr "Envio de formulario non esperada."
+
+#: ../actions/recoverpassword.php:276
+#: actions/recoverpassword.php:289
+msgid "Unexpected password reset."
+msgstr "Restauración de contrasinal non esperada."
+
+#: ../index.php:57
+#: index.php:57
+msgid "Unknown action"
+msgstr "Acción descoñecida"
+
+#: ../actions/finishremotesubscribe.php:58
+#: actions/finishremotesubscribe.php:60
+#: actions/finishremotesubscribe.php:59
+msgid "Unknown version of OMB protocol."
+msgstr "Versión de protocolo OMB descoñecida."
+
+#: ../lib/util.php:269
+#: lib/util.php:285
+#: lib/util.php:302
+msgid "Unless otherwise specified, contents of this site are copyright by the contributors and available under the "
+msgstr "Aínda que especifiques outro, os contidos de este sitio teñen copyright polos contribuidores e está dispoñible baixo "
+
+#: ../actions/confirmaddress.php:48
+#: actions/confirmaddress.php:48
+#, php-format
+msgid "Unrecognized address type %s"
+msgstr "Tipo de enderezo %s non recoñecido"
+
+#: ../actions/showstream.php:209
+#: actions/showstream.php:219
+#: actions/showstream.php:267
+#: lib/util.php:2153
+msgid "Unsubscribe"
+msgstr "Eliminar subscrición"
+
+#: ../actions/postnotice.php:44
+#: ../actions/updateprofile.php:45
+#: actions/postnotice.php:45
+#: actions/updateprofile.php:46
+msgid "Unsupported OMB version"
+msgstr "Versión OMB non soportada"
+
+#: ../actions/avatar.php:105
+#: actions/profilesettings.php:342
+#: actions/profilesettings.php:388
+msgid "Unsupported image file format."
+msgstr "Formato de ficheiro de imaxe non soportado."
+
+#: ../lib/settingsaction.php:100
+#: lib/settingsaction.php:94
+#: actions/deleteprofile.php:251
+msgid "Updates by SMS"
+msgstr "Chíos dende SMS"
+
+#: ../lib/settingsaction.php:103
+#: lib/settingsaction.php:97
+#: actions/deleteprofile.php:254
+#: lib/settingsaction.php:101
+#: lib/settingsaction.php:103
+msgid "Updates by instant messenger (IM)"
+msgstr "Chíos dende mensaxería instantánea (IM)"
+
+#: ../actions/twitapistatuses.php:241
+#: actions/twitapistatuses.php:158
+#: actions/twitapistatuses.php:126
+#, php-format
+msgid "Updates from %1$s and friends on %2$s!"
+msgstr "Actualizacións dende %1$s e amigos en %2$s!"
+
+#: ../actions/twitapistatuses.php:341
+#: actions/twitapistatuses.php:268
+#: actions/twitapistatuses.php:198
+#, php-format
+msgid "Updates from %1$s on %2$s!"
+msgstr "Actualizacións dende %1$s en %2$s!"
+
+#: ../actions/avatar.php:68
+#: actions/profilesettings.php:161
+#: actions/profilesettings.php:178
+msgid "Upload"
+msgstr "Subir"
+
+#: ../actions/avatar.php:27
+msgid "Upload a new \"avatar\" (user image) here. You can't edit the picture after you upload it, so make sure it's more or less square. It must be under the site license, also. Use a picture that belongs to you and that you want to share."
+msgstr "Sube un novo \"avatar\" (imaxe de usuario) dende aquí. Non podes editar a imaxe despois de subila, polo que asegurate de que é máis ou menos cadrado. Debe estar baixo a licenza do sistio. Emprega unha imaxe que che pertenza e que queiras compartir."
+
+#: ../lib/settingsaction.php:91
+msgid "Upload a new profile image"
+msgstr "Subir unha nova imaxe de usuario"
+
+#: ../actions/invite.php:114
+#: actions/invite.php:121
+msgid "Use this form to invite your friends and colleagues to use this service."
+msgstr "Emprega este formulario para invitar ós teus amigos e colegas a empregar este servizo."
+
+#: ../actions/register.php:159
+#: ../actions/register.php:162
+#: actions/register.php:173
+#: actions/register.php:176
+#: actions/register.php:200
+#: actions/register.php:203
+msgid "Used only for updates, announcements, and password recovery"
+msgstr "Empregado só para actualizacións, novidades, e recuperación de contrasinais"
+
+#: ../actions/finishremotesubscribe.php:86
+#: actions/finishremotesubscribe.php:88
+#: actions/finishremotesubscribe.php:92
+msgid "User being listened to doesn't exist."
+msgstr "O usuario que está sendo escoitado non existe."
+
+#: ../actions/all.php:41
+#: ../actions/avatarbynickname.php:48
+#: ../actions/foaf.php:47
+#: ../actions/replies.php:41
+#: ../actions/showstream.php:44
+#: ../actions/twitapiaccount.php:82
+#: ../actions/twitapistatuses.php:319
+#: ../actions/twitapistatuses.php:685
+#: ../actions/twitapiusers.php:82
+#: actions/all.php:41
+#: actions/avatarbynickname.php:48
+#: actions/foaf.php:47
+#: actions/replies.php:41
+#: actions/showfavorites.php:41
+#: actions/showstream.php:44
+#: actions/twitapiaccount.php:80
+#: actions/twitapifavorites.php:68
+#: actions/twitapistatuses.php:235
+#: actions/twitapistatuses.php:609
+#: actions/twitapiusers.php:87
+#: lib/mailbox.php:50
+#: actions/showstream.php:57
+#: actions/twitapiaccount.php:66
+#: actions/twitapifavorites.php:40
+#: actions/twitapistatuses.php:163
+#: actions/twitapistatuses.php:492
+#: actions/twitapiusers.php:53
+msgid "User has no profile."
+msgstr "O usuario non ten perfil."
+
+#: ../actions/remotesubscribe.php:71
+#: actions/remotesubscribe.php:80
+msgid "User nickname"
+msgstr "Alcume de usuario"
+
+#: ../actions/twitapiusers.php:75
+#: actions/twitapiusers.php:80
+msgid "User not found."
+msgstr "Usuario non atopado."
+
+#: ../actions/profilesettings.php:63
+#: actions/profilesettings.php:96
+#: actions/profilesettings.php:109
+msgid "What timezone are you normally in?"
+msgstr "En que fuso horario estas normalmente?"
+
+#: ../lib/util.php:1159
+#: lib/util.php:1293
+#: lib/util.php:1689
+#, php-format
+msgid "What's up, %s?"
+msgstr "¿Que pasa, %s?"
+
+#: ../actions/profilesettings.php:54
+#: ../actions/register.php:175
+#: actions/profilesettings.php:87
+#: actions/register.php:189
+#: actions/profilesettings.php:89
+#: actions/register.php:216
+msgid "Where you are, like \"City, State (or Region), Country\""
+msgstr "¿Onde estas, coma \"Cidade, Provincia, País\""
+
+#: ../actions/updateprofile.php:128
+#: actions/updateprofile.php:129
+#, php-format
+msgid "Wrong image type for '%s'"
+msgstr "Tipo de imaxe incorrecto para '%s'"
+
+#: ../actions/updateprofile.php:123
+#: actions/updateprofile.php:124
+#, php-format
+msgid "Wrong size image at '%s'"
+msgstr "Tamaño de imaxe incorrecto en '%s'"
+
+#: ../actions/deletenotice.php:63
+#: ../actions/deletenotice.php:72
+#: actions/deletenotice.php:64
+#: actions/deletenotice.php:79
+#: actions/block.php:105
+msgid "Yes"
+msgstr "Si"
+
+#: ../actions/finishaddopenid.php:64
+#: actions/finishaddopenid.php:64
+msgid "You already have this OpenID!"
+msgstr "¡Xa tes esa OpenID!"
+
+#: ../actions/deletenotice.php:37
+#: actions/deletenotice.php:37
+msgid "You are about to permanently delete a notice. Once this is done, it cannot be undone."
+msgstr "Vas a eliminar permanentemente este chío. Unha vez feito, xa non hai volta atrás... Quedas avisado!"
+
+#: ../actions/recoverpassword.php:31
+#: actions/recoverpassword.php:31
+msgid "You are already logged in!"
+msgstr "¡Xa estás logueado!"
+
+#: ../actions/invite.php:81
+#: actions/invite.php:88
+msgid "You are already subscribed to these users:"
+msgstr "Xa estas suscrito a estes usuarios:"
+
+#: ../actions/twitapifriendships.php:128
+#: actions/twitapifriendships.php:128
+#: actions/twitapifriendships.php:102
+msgid "You are not friends with the specified user."
+msgstr "No tes amigos con un usuario específico."
+
+#: ../actions/password.php:27
+msgid "You can change your password here. Choose a good one!"
+msgstr "Podes cambiar a túa contrasinal aquí. ¡Escolle unha boa!"
+
+#: ../actions/register.php:135
+#: actions/register.php:145
+msgid "You can create a new account to start posting notices."
+msgstr "Podes crear unha nova conta para comezar a escribir chíos."
+
+#: ../actions/smssettings.php:28
+#: actions/smssettings.php:28
+#, php-format
+msgid "You can receive SMS messages through email from %%site.name%%."
+msgstr "Podes recibir mensaxes SMS a través do email dende %%site.name%%."
+
+#: ../actions/openidsettings.php:86
+#: actions/openidsettings.php:87
+msgid "You can remove an OpenID from your account by clicking the button marked \"Remove\"."
+msgstr "Podes eliminar unha OpenID da túa conta facendo clic no botón marcado \"Eliminar\"."
+
+#: ../actions/imsettings.php:28
+#: actions/imsettings.php:28
+#, php-format
+msgid "You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below."
+msgstr "Podes enviar e recibir chíos a través de Jabber/GTalk [mensaxes instantáneos](%%doc.im%%). Configura a túa conta e configuracións abaixo."
+
+#: ../actions/profilesettings.php:27
+#: actions/profilesettings.php:27
+msgid "You can update your personal profile info here so people know more about you."
+msgstr "Podes actualizar a túa información do perfil persoal aquí para que a xente che poida coñecer mellor."
+
+#: ../actions/finishremotesubscribe.php:31
+#: ../actions/remotesubscribe.php:31
+#: actions/finishremotesubscribe.php:31
+#: actions/remotesubscribe.php:31
+#: actions/finishremotesubscribe.php:83
+#: actions/finishremotesubscribe.php:99
+msgid "You can use the local subscription!"
+msgstr "¡Podes empregar a túa subscrición local!"
+
+#: ../actions/finishopenidlogin.php:33
+#: ../actions/register.php:61
+#: actions/finishopenidlogin.php:38
+#: actions/register.php:68
+#: actions/register.php:77
+msgid "You can't register if you don't agree to the license."
+msgstr "Non podes rexistrarte se non estas de acordo coa licenza."
+
+#: ../actions/updateprofile.php:63
+#: actions/updateprofile.php:64
+msgid "You did not send us that profile"
+msgstr "Non nos enviaches ese perfil"
+
+#: ../lib/mail.php:147
+#: lib/mail.php:141
+#, php-format
+msgid ""
+"You have a new posting address on %1$s.\n"
+"\n"
+"Send email to %2$s to post new messages.\n"
+"\n"
+"More email instructions at %3$s.\n"
+"\n"
+"Faithfully yours,\n"
+"%4$s"
+msgstr ""
+"Tes unha nova dirección de envio de mensaxes en %1$s.\n"
+"\n"
+"Envia unha mensaxe a %2$s para enviar novas mensaxes.\n"
+"\n"
+"Hai máis instruccións de envio en %3$s.\n"
+"\n"
+"Sempre teu...,\n"
+"%4$s"
+
+#: ../actions/twitapistatuses.php:612
+#: actions/twitapistatuses.php:537
+#: actions/twitapistatuses.php:455
+msgid "You may not delete another user's status."
+msgstr "Non deberías eliminar o estado de outro usuario"
+
+#: ../actions/invite.php:31
+#: actions/invite.php:31
+#, php-format
+msgid "You must be logged in to invite other users to use %s"
+msgstr "Debes estar logueado para invitar a outros usuarios a empregar %s"
+
+#: ../actions/invite.php:103
+#: actions/invite.php:110
+msgid "You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!"
+msgstr "Notificaráseche cando os teus invitados acepten unha invitación e se rexistren neste sitio. Grazas por facer crecer o gremio lareteiro!"
+
+#: ../actions/recoverpassword.php:149
+#: actions/recoverpassword.php:154
+msgid "You've been identified. Enter a new password below. "
+msgstr "Foiches identificado. Insire unha nova contrasinal abaixo."
+
+#: ../actions/openidlogin.php:67
+#: actions/openidlogin.php:76
+#: actions/login.php:127
+#: actions/openidlogin.php:84
+msgid "Your OpenID URL"
+msgstr "O teu enderezo OpenID"
+
+#: ../actions/recoverpassword.php:164
+#: actions/recoverpassword.php:169
+msgid "Your nickname on this server, or your registered email address."
+msgstr "O teu alcume neste servidor, ou o teu enderezo rexistrado."
+
+#: ../actions/openidsettings.php:28
+#: actions/openidsettings.php:28
+#, php-format
+msgid "[OpenID](%%doc.openid%%) lets you log into many sites with the same user account. Manage your associated OpenIDs from here."
+msgstr "[OpenID](%%doc.openid%%) permiteche acceder en moitos sitios coa mesma conta. Xestina os teus OpenIDs asociados dende aquí."
+
+#: ../lib/util.php:943
+#: lib/util.php:992
+#: lib/util.php:1349
+msgid "a few seconds ago"
+msgstr "fai uns segundos"
+
+#: ../lib/util.php:955
+#: lib/util.php:1004
+#: lib/util.php:1361
+#, php-format
+msgid "about %d days ago"
+msgstr "fai %d días"
+
+#: ../lib/util.php:951
+#: lib/util.php:1000
+#: lib/util.php:1357
+#, php-format
+msgid "about %d hours ago"
+msgstr "fai %d horas"
+
+#: ../lib/util.php:947
+#: lib/util.php:996
+#: lib/util.php:1353
+#, php-format
+msgid "about %d minutes ago"
+msgstr "fai %d minutos"
+
+#: ../lib/util.php:959
+#: lib/util.php:1008
+#: lib/util.php:1365
+#, php-format
+msgid "about %d months ago"
+msgstr "fai %d meses"
+
+#: ../lib/util.php:953
+#: lib/util.php:1002
+#: lib/util.php:1359
+msgid "about a day ago"
+msgstr "fai un día"
+
+#: ../lib/util.php:945
+#: lib/util.php:994
+#: lib/util.php:1351
+msgid "about a minute ago"
+msgstr "fai un minuto"
+
+#: ../lib/util.php:957
+#: lib/util.php:1006
+#: lib/util.php:1363
+msgid "about a month ago"
+msgstr "fai un mes"
+
+#: ../lib/util.php:961
+#: lib/util.php:1010
+#: lib/util.php:1367
+msgid "about a year ago"
+msgstr "fai un ano"
+
+#: ../lib/util.php:949
+#: lib/util.php:998
+#: lib/util.php:1355
+msgid "about an hour ago"
+msgstr "fai unha hora"
+
+#: ../actions/showstream.php:423
+#: ../lib/stream.php:132
+#: actions/showstream.php:441
+#: lib/stream.php:99
+#: lib/noticelist.php:211
+msgid "delete"
+msgstr "eliminar"
+
+#: ../actions/noticesearch.php:130
+#: ../actions/showstream.php:408
+#: ../lib/stream.php:117
+#: actions/noticesearch.php:136
+#: actions/showstream.php:426
+#: lib/stream.php:84
+#: actions/noticesearch.php:135
+#: lib/facebookaction.php:202
+#: lib/noticelist.php:189
+msgid "in reply to..."
+msgstr "en contestación a..."
+
+#: ../actions/noticesearch.php:137
+#: ../actions/showstream.php:415
+#: ../lib/stream.php:124
+#: actions/noticesearch.php:143
+#: actions/showstream.php:433
+#: lib/stream.php:91
+#: actions/noticesearch.php:142
+#: lib/noticelist.php:199
+msgid "reply"
+msgstr "contestar"
+
+#: ../actions/password.php:44
+#: actions/profilesettings.php:183
+#: actions/profilesettings.php:200
+msgid "same as password above"
+msgstr "igual á contrasinal de enriba"
+
+#: ../actions/twitapistatuses.php:755
+#: actions/twitapistatuses.php:678
+#: actions/twitapistatuses.php:543
+msgid "unsupported file type"
+msgstr "tipo de ficheiro non soportado"
+
+#: ../lib/util.php:1309
+#: lib/util.php:1443
+#: lib/facebookaction.php:251
+#: lib/util.php:1842
+msgid "« After"
+msgstr "« Despois"
+
+#: actions/deletenotice.php:74
+#: actions/disfavor.php:43
+#: actions/emailsettings.php:127
+#: actions/favor.php:45
+#: actions/finishopenidlogin.php:33
+#: actions/imsettings.php:105
+#: actions/invite.php:46
+#: actions/newmessage.php:45
+#: actions/openidlogin.php:36
+#: actions/openidsettings.php:123
+#: actions/profilesettings.php:47
+#: actions/recoverpassword.php:282
+#: actions/register.php:42
+#: actions/remotesubscribe.php:40
+#: actions/smssettings.php:124
+#: actions/subscribe.php:44
+#: actions/twittersettings.php:97
+#: actions/unsubscribe.php:41
+#: actions/userauthorization.php:35
+#: actions/block.php:38
+#: actions/deleteprofile.php:127
+#: actions/disfavor.php:47
+#: actions/emailsettings.php:131
+#: actions/favor.php:49
+#: actions/imsettings.php:108
+#: actions/login.php:45
+#: actions/newmessage.php:44
+#: actions/newnotice.php:36
+#: actions/nudge.php:47
+#: actions/othersettings.php:139
+#: actions/profilesettings.php:49
+#: actions/smssettings.php:126
+#: actions/subedit.php:38
+#: actions/tagother.php:113
+#: actions/twittersettings.php:188
+#: actions/unblock.php:38
+msgid "There was a problem with your session token. Try again, please."
+msgstr "Houbo un problema co teu token de sesión. Tentao de novo, anda..."
+
+#: actions/disfavor.php:55
+msgid "This notice is not a favorite!"
+msgstr "Este chío non é un favorito!"
+
+#: actions/disfavor.php:63
+msgid "Could not delete favorite."
+msgstr "Non se puido eliminar o favorito."
+
+#: actions/disfavor.php:72
+msgid "Favor"
+msgstr "Gostame"
+
+#: actions/emailsettings.php:92
+msgid "Send me email when someone adds my notice as a favorite."
+msgstr "Enviar un correo cando alguen enganda un chío meu coma favorito."
+
+#: actions/emailsettings.php:95
+msgid "Send me email when someone sends me a private message."
+msgstr "Enviarme un email cando alguén me envíe unha mensaxe privada."
+
+#: actions/favor.php:53
+#: actions/twitapifavorites.php:142
+#: actions/favor.php:54
+#: actions/twitapifavorites.php:115
+msgid "This notice is already a favorite!"
+msgstr "Este chío xa é un favorito!"
+
+#: actions/favor.php:60
+#: actions/twitapifavorites.php:151
+#: classes/Command.php:132
+#: actions/favor.php:61
+#: actions/twitapifavorites.php:122
+msgid "Could not create favorite."
+msgstr "Non se puido crear o favorito."
+
+#: actions/favor.php:70
+msgid "Disfavor"
+msgstr "Non me gosta"
+
+#: actions/favoritesrss.php:60
+#: actions/showfavorites.php:47
+#: actions/favoritesrss.php:62
+#, php-format
+msgid "%s favorite notices"
+msgstr "%s chíos favoritos"
+
+#: actions/favoritesrss.php:64
+#: actions/favoritesrss.php:66
+#, php-format
+msgid "Feed of favorite notices of %s"
+msgstr "Fonte para os chíos favoritos de %s"
+
+#: actions/inbox.php:28
+#, php-format
+msgid "Inbox for %s - page %d"
+msgstr "Band. Entrada para %s - páxina %d"
+
+#: actions/inbox.php:30
+#, php-format
+msgid "Inbox for %s"
+msgstr "Band. Entrada para %s"
+
+#: actions/inbox.php:53
+msgid "This is your inbox, which lists your incoming private messages."
+msgstr "Esta é a túa bandexa de entrada, aquí móstranse as túas mensaxes privadas."
+
+#: actions/invite.php:178
+#, php-format
+msgid ""
+"%1$s has invited you to join them on %2$s (%3$s).\n"
+"\n"
+msgstr "Acabas de invitar a %1$s a unirse a %2$s (%3$s).\n"
+
+#: actions/login.php:104
+msgid "Automatically login in the future; "
+msgstr "Loguearse automáticamente no futuro:"
+
+#: actions/login.php:122
+msgid "For security reasons, please re-enter your "
+msgstr "Por razóns de seguranza, por favor re-insire o teu "
+
+#: actions/login.php:126
+msgid "Login with your username and password. "
+msgstr "Accede co teu nome de usuario e contrasinal."
+
+#: actions/newmessage.php:58
+#: actions/twitapidirect_messages.php:130
+#: actions/newmessage.php:60
+#: actions/twitapidirect_messages.php:136
+msgid "That's too long. Max message size is 140 chars."
+msgstr "Iso é demasiado longo. O tamaño máximo para unha mensaxe é de 140 caracteres."
+
+#: actions/newmessage.php:65
+#: actions/newmessage.php:68
+msgid "No recipient specified."
+msgstr "Non se especificou ningún destinatario"
+
+#: actions/newmessage.php:68
+#: actions/newmessage.php:113
+#: classes/Command.php:206
+#: actions/newmessage.php:71
+#: actions/newmessage.php:116
+#: classes/Command.php:211
+msgid "You can't send a message to this user."
+msgstr "Non podes enviar mensaxes a este usurio."
+
+#: actions/newmessage.php:71
+#: actions/twitapidirect_messages.php:146
+#: classes/Command.php:209
+#: actions/newmessage.php:74
+#: actions/twitapidirect_messages.php:153
+#: classes/Command.php:214
+msgid "Don't send a message to yourself; just say it to yourself quietly instead."
+msgstr "Non te envies mensaxes a ti mesmo!! só fala contigo mesmo baixiño, senón vante tomar por tolo."
+
+#: actions/newmessage.php:108
+#: actions/microsummary.php:32
+#: actions/newmessage.php:111
+msgid "No such user"
+msgstr "Non é o usuario"
+
+#: actions/newmessage.php:117
+#: actions/newmessage.php:120
+msgid "New message"
+msgstr "Nova mensaxe"
+
+#: actions/noticesearch.php:95
+#: actions/noticesearch.php:94
+msgid "Notice without matching profile"
+msgstr "Chío sen perfil coincidente"
+
+#: actions/openidsettings.php:28
+#, php-format
+msgid "[OpenID](%%doc.openid%%) lets you log into many sites "
+msgstr "[OpenID](%%doc.openid%%) permiteche acceder en moitos sitios"
+
+#: actions/openidsettings.php:46
+msgid "If you want to add an OpenID to your account, "
+msgstr "Se queres engadir un enderezo OpenID á tua conta, "
+
+#: actions/openidsettings.php:74
+msgid "Removing your only OpenID would make it impossible to log in! "
+msgstr "Eliminando o teu enderezo OpenID serache imposíbel acceder!"
+
+#: actions/openidsettings.php:87
+msgid "You can remove an OpenID from your account "
+msgstr "Podes eliminar un identificador OpenID da túa conta "
+
+#: actions/outbox.php:28
+#, php-format
+msgid "Outbox for %s - page %d"
+msgstr "Band. Saída para %s - páxina %d"
+
+#: actions/outbox.php:30
+#, php-format
+msgid "Outbox for %s"
+msgstr "Band. Saída para %s"
+
+#: actions/outbox.php:53
+msgid "This is your outbox, which lists private messages you have sent."
+msgstr "Esta é a túa band. saída, que mostra as mensaxes privadas que enviaches."
+
+#: actions/peoplesearch.php:28
+#, php-format
+msgid "Search for people on %%site.name%% by their name, location, or interests. "
+msgstr "Procurar xente en %%site.name%% polo seu nome, localización, ou intereses. "
+
+#: actions/profilesettings.php:27
+msgid "You can update your personal profile info here "
+msgstr "Podes actualizar a túa información do perfil persoal aquí"
+
+#: actions/profilesettings.php:115
+#: actions/remotesubscribe.php:320
+#: actions/userauthorization.php:159
+#: actions/userrss.php:76
+#: actions/profilesettings.php:132
+#: actions/remotesubscribe.php:333
+msgid "User without matching profile"
+msgstr "Usuario sen un perfil que coincida."
+
+#: actions/recoverpassword.php:91
+msgid "This confirmation code is too old. "
+msgstr "Ese código de confirmación é demasiado antigo."
+
+#: actions/recoverpassword.php:141
+msgid "If you've forgotten or lost your"
+msgstr "Se esquenciches ou perdeches a túa"
+
+#: actions/recoverpassword.php:154
+msgid "You've been identified. Enter a "
+msgstr "Foches identificado. Insire unha "
+
+#: actions/recoverpassword.php:169
+msgid "Your nickname on this server, "
+msgstr "O teu alcume neste servidor, "
+
+#: actions/recoverpassword.php:271
+msgid "Instructions for recovering your password "
+msgstr "Instruccións para recuperar a túa contrasinal."
+
+#: actions/recoverpassword.php:327
+msgid "New password successfully saved. "
+msgstr "A nova contrasinal foi gardada correctamente."
+
+#: actions/register.php:95
+#: actions/register.php:104
+msgid "Password must be 6 or more characters."
+msgstr "A contrasinal debe ter 6 caracteres ou máis."
+
+#: actions/register.php:216
+#, php-format
+msgid "Congratulations, %s! And welcome to %%%%site.name%%%%. From here, you may want to..."
+msgstr "Noraboa, %s! E benvido a %%%%site.name%%%%. Dende aquí, igual queres..."
+
+#: actions/register.php:227
+msgid "(You should receive a message by email momentarily, with "
+msgstr "(Deberías recibir unha mensaxe no teu email nun intre, con"
+
+#: actions/remotesubscribe.php:51
+#, php-format
+msgid "To subscribe, you can [login](%%action.login%%),"
+msgstr "Para suscribirse, podes [loguearte](%%action.login%%),"
+
+#: actions/showfavorites.php:61
+#, php-format
+msgid "Feed for favorites of %s"
+msgstr "Fonte para os favoritos de %s"
+
+#: actions/showfavorites.php:84
+#: actions/twitapifavorites.php:85
+#: actions/showfavorites.php:88
+#: actions/twitapifavorites.php:57
+msgid "Could not retrieve favorite notices."
+msgstr "Non se pode "
+
+#: actions/showmessage.php:33
+msgid "No such message."
+msgstr "Non existe a mensaxe."
+
+#: actions/showmessage.php:42
+msgid "Only the sender and recipient may read this message."
+msgstr "Só o emisor e destinatario poden ler esta mensaxe."
+
+#: actions/showmessage.php:61
+#, php-format
+msgid "Message to %1$s on %2$s"
+msgstr "Mensaxe de %1$s en %2$s"
+
+#: actions/showmessage.php:66
+#, php-format
+msgid "Message from %1$s on %2$s"
+msgstr "Mensaxe dende %1$s en %2$s"
+
+#: actions/showstream.php:154
+#: lib/util.php:2164
+msgid "Send a message"
+msgstr "Enviar unha mensaxe"
+
+#: actions/smssettings.php:312
+#, php-format
+msgid "Mobile carrier for your phone. "
+msgstr "Operadora móbil do teu teléfono."
+
+#: actions/twitapidirect_messages.php:76
+#: actions/twitapidirect_messages.php:64
+#, php-format
+msgid "Direct messages to %s"
+msgstr "Mensaxes directas para %s"
+
+#: actions/twitapidirect_messages.php:77
+#: actions/twitapidirect_messages.php:65
+#, php-format
+msgid "All the direct messages sent to %s"
+msgstr "Tódalas mensaxes directas enviadas a %s"
+
+#: actions/twitapidirect_messages.php:81
+#: actions/twitapidirect_messages.php:69
+msgid "Direct Messages You've Sent"
+msgstr "Mensaxes Directas que Enviaches."
+
+#: actions/twitapidirect_messages.php:82
+#: actions/twitapidirect_messages.php:70
+#, php-format
+msgid "All the direct messages sent from %s"
+msgstr "Tódalas mensaxes directas enviadas dende %s"
+
+#: actions/twitapidirect_messages.php:128
+#: actions/twitapidirect_messages.php:132
+msgid "No message text!"
+msgstr "Non hai mensaxes de texto!"
+
+#: actions/twitapidirect_messages.php:138
+#: actions/twitapidirect_messages.php:145
+msgid "Recipient user not found."
+msgstr "Usuario destinatario non atopado."
+
+#: actions/twitapidirect_messages.php:141
+#: actions/twitapidirect_messages.php:148
+msgid "Can't send direct messages to users who aren't your friend."
+msgstr "Non se pode enviar a mensaxe directa a usuarios dos que non eres amigo."
+
+#: actions/twitapifavorites.php:92
+#: actions/twitapifavorites.php:64
+#, php-format
+msgid "%s / Favorites from %s"
+msgstr "%s / Favoritos dende %s"
+
+#: actions/twitapifavorites.php:95
+#: actions/twitapifavorites.php:67
+#, php-format
+msgid "%s updates favorited by %s / %s."
+msgstr "%s updates favorited by %s / %s."
+
+#: actions/twitapifavorites.php:187
+#: lib/mail.php:275
+#: actions/twitapifavorites.php:158
+#: lib/mail.php:293
+#, php-format
+msgid "%s added your notice as a favorite"
+msgstr "%s gustoulle o teu chío"
+
+#: actions/twitapifavorites.php:188
+#: lib/mail.php:276
+#, php-format
+msgid ""
+"%1$s just added your notice from %2$s as one of their favorites.\n"
+"\n"
+msgstr ""
+"A %1$s gustoulle o teu chío %2$s e marcouno como favorito.\n"
+"\n"
+
+#: actions/twittersettings.php:27
+msgid "Add your Twitter account to automatically send your notices to Twitter, "
+msgstr "Engade a túa conta de Twitter para enviar automáticamente os teus chíos a Twitter."
+
+#: actions/twittersettings.php:41
+#: actions/twittersettings.php:43
+msgid "Twitter settings"
+msgstr "Configuracións de Twitter"
+
+#: actions/twittersettings.php:48
+#: actions/twittersettings.php:50
+msgid "Twitter Account"
+msgstr "Conta de Twitter"
+
+#: actions/twittersettings.php:56
+#: actions/twittersettings.php:58
+msgid "Current verified Twitter account."
+msgstr "Conta de twitter verificada actualmente."
+
+#: actions/twittersettings.php:63
+msgid "Twitter Username"
+msgstr "Nome de usuario en Twitter"
+
+#: actions/twittersettings.php:65
+msgid "No spaces, please."
+msgstr "Sen espazos, anda..."
+
+#: actions/twittersettings.php:67
+msgid "Twitter Password"
+msgstr "Contrasinal de Twitter"
+
+#: actions/twittersettings.php:72
+msgid "Automatically send my notices to Twitter."
+msgstr "Enviar automáticamente os meus chíos a Twitter."
+
+#: actions/twittersettings.php:75
+msgid "Send local \"@\" replies to Twitter."
+msgstr "Enviar respostas \"@\" locais a Twitter."
+
+#: actions/twittersettings.php:78
+msgid "Subscribe to my Twitter friends here."
+msgstr "Suscribirse ós meus amigos de Twitter aquí."
+
+#: actions/twittersettings.php:122
+#: actions/twittersettings.php:216
+msgid "Username must have only numbers, upper- and lowercase letters, and underscore (_). 15 chars max."
+msgstr "O nome de usuario debe ter só letras, minúsculas e maiúsculas, e números, e sen espazos."
+
+#: actions/twittersettings.php:128
+#: actions/twittersettings.php:221
+msgid "Could not verify your Twitter credentials!"
+msgstr "Non se puideron verificar as túas credenciais en Twitter!"
+
+#: actions/twittersettings.php:137
+#: actions/twittersettings.php:228
+#, php-format
+msgid "Unable to retrieve account information for \"%s\" from Twitter."
+msgstr "Non se puido recoller información da túa conta \"%s\" en Twitter."
+
+#: actions/twittersettings.php:151
+#: actions/twittersettings.php:170
+#: actions/twittersettings.php:234
+#: actions/twittersettings.php:253
+msgid "Unable to save your Twitter settings!"
+msgstr "Non se puideron gardar os teus axustes de Twitter!"
+
+#: actions/twittersettings.php:174
+#: actions/twittersettings.php:261
+msgid "Twitter settings saved."
+msgstr "Configuracións de Twitter gardadas."
+
+#: actions/twittersettings.php:192
+#: actions/twittersettings.php:272
+msgid "That is not your Twitter account."
+msgstr "Esa non é a túa conta de Twitter."
+
+#: actions/twittersettings.php:200
+#: actions/twittersettings.php:208
+#: actions/twittersettings.php:280
+msgid "Couldn't remove Twitter user."
+msgstr "Non se puido eliminar o usuario."
+
+#: actions/twittersettings.php:212
+#: actions/twittersettings.php:284
+msgid "Twitter account removed."
+msgstr "Conta de Twitter "
+
+#: actions/twittersettings.php:225
+#: actions/twittersettings.php:239
+#: actions/twittersettings.php:299
+#: actions/twittersettings.php:310
+#: actions/twittersettings.php:322
+msgid "Couldn't save Twitter preferences."
+msgstr "Non se puideron gardar as preferenzas de Twitter."
+
+#: actions/twittersettings.php:245
+#: actions/twittersettings.php:330
+msgid "Twitter preferences saved."
+msgstr "Preferencias de Twitter gardadas."
+
+#: actions/userauthorization.php:84
+msgid "Please check these details to make sure "
+msgstr "Comproba estes datos para asegurarte"
+
+#: actions/userauthorization.php:324
+msgid "The subscription has been authorized, but no "
+msgstr "A suscrición foi autorizada, pero non"
+
+#: actions/userauthorization.php:334
+msgid "The subscription has been rejected, but no "
+msgstr "A suscrición foi rexeitada, pero non"
+
+#: classes/Channel.php:113
+#: classes/Channel.php:129
+msgid "Command results"
+msgstr "Resultados do comando"
+
+#: classes/Channel.php:148
+#: classes/Channel.php:175
+msgid "Command complete"
+msgstr "Comando completo"
+
+#: classes/Channel.php:158
+#: classes/Channel.php:185
+msgid "Command failed"
+msgstr "Comando fallido"
+
+#: classes/Command.php:39
+msgid "Sorry, this command is not yet implemented."
+msgstr "Desculpa, este comando todavía non está implementado."
+
+#: classes/Command.php:96
+#, php-format
+msgid "Subscriptions: %1$s\n"
+msgstr "Subscricións: %1$s.\n"
+
+#: classes/Command.php:125
+#: classes/Command.php:242
+#: classes/Command.php:247
+msgid "User has no last notice"
+msgstr "O usuario non ten último chio."
+
+#: classes/Command.php:146
+msgid "Notice marked as fave."
+msgstr "Chío marcado coma favorito."
+
+#: classes/Command.php:166
+#, php-format
+msgid "%1$s (%2$s)"
+msgstr "%1$s (%2$s)"
+
+#: classes/Command.php:169
+#, php-format
+msgid "Fullname: %s"
+msgstr "Nome completo: %s"
+
+#: classes/Command.php:172
+#, php-format
+msgid "Location: %s"
+msgstr "Ubicación: %s"
+
+#: classes/Command.php:175
+#, php-format
+msgid "Homepage: %s"
+msgstr "Páxina persoal: %s"
+
+#: classes/Command.php:178
+#, php-format
+msgid "About: %s"
+msgstr "Sobre: %s"
+
+#: classes/Command.php:200
+#: classes/Command.php:202
+#, php-format
+msgid "Message too long - maximum is 140 characters, you sent %d"
+msgstr "Mensaxe demasiado longa - o máximo é 140 caracteres, ti enviaches %d "
+
+#: classes/Command.php:214
+#: classes/Command.php:219
+#, php-format
+msgid "Direct message to %s sent"
+msgstr "Mensaxe directo a %s enviado"
+
+#: classes/Command.php:216
+#: classes/Command.php:221
+msgid "Error sending direct message."
+msgstr "Erro ó enviar a mensaxe directa."
+
+#: classes/Command.php:263
+#: classes/Command.php:268
+msgid "Specify the name of the user to subscribe to"
+msgstr "Especifica o nome do usuario ó que queres suscribirte"
+
+#: classes/Command.php:270
+#: classes/Command.php:275
+#, php-format
+msgid "Subscribed to %s"
+msgstr "Suscrito a %s"
+
+#: classes/Command.php:288
+#: classes/Command.php:293
+msgid "Specify the name of the user to unsubscribe from"
+msgstr "Especifica o nome de usuario ó que queres deixar de seguir"
+
+#: classes/Command.php:295
+#: classes/Command.php:300
+#, php-format
+msgid "Unsubscribed from %s"
+msgstr "Desuscribir de %s"
+
+#: classes/Command.php:310
+#: classes/Command.php:330
+#: classes/Command.php:315
+#: classes/Command.php:335
+msgid "Command not yet implemented."
+msgstr "Comando non implementado."
+
+#: classes/Command.php:313
+#: classes/Command.php:318
+msgid "Notification off."
+msgstr "Notificación desactivada."
+
+#: classes/Command.php:315
+#: classes/Command.php:320
+msgid "Can't turn off notification."
+msgstr "No se pode desactivar a notificación."
+
+#: classes/Command.php:333
+#: classes/Command.php:338
+msgid "Notification on."
+msgstr "Notificación habilitada."
+
+#: classes/Command.php:335
+#: classes/Command.php:340
+msgid "Can't turn on notification."
+msgstr "Non se pode activar a notificación."
+
+#: classes/Command.php:344
+msgid "Commands:\n"
+msgstr "Comandos:\n"
+
+#: classes/Message.php:53
+msgid "Could not insert message."
+msgstr "Non se pode inserir unha mensaxe."
+
+#: classes/Message.php:63
+msgid "Could not update message with new URI."
+msgstr "Non se puido actualizar a mensaxe coa nova URI."
+
+#: lib/gallery.php:46
+#: lib/gallery.php:55
+msgid "User without matching profile in system."
+msgstr "Usuario sen perfil coincidente no sistema."
+
+#: lib/mail.php:147
+#, php-format
+msgid ""
+"You have a new posting address on %1$s.\n"
+"\n"
+msgstr ""
+"Tes novas direccións de posteo en %1$s.\n"
+"\n"
+
+#: lib/mail.php:249
+#: lib/mail.php:265
+#, php-format
+msgid "New private message from %s"
+msgstr "%s enviouche unha nova mensaxe privada"
+
+#: lib/mail.php:253
+#, php-format
+msgid ""
+"%1$s (%2$s) sent you a private message:\n"
+"\n"
+msgstr ""
+"%1$s (%2$s) enviouche unha mensaxe privada:\n"
+"\n"
+
+#: lib/mailbox.php:43
+msgid "Only the user can read their own mailboxes."
+msgstr "Só o usuario pode ler os seus propios buzóns."
+
+#: lib/openid.php:195
+msgid "This form should automatically submit itself. "
+msgstr "Este formulario debería enviarse automáticamente él mesmo."
+
+#: lib/personal.php:65
+msgid "Favorites"
+msgstr "Favoritos"
+
+#: lib/personal.php:66
+#, php-format
+msgid "%s's favorite notices"
+msgstr "Chíos favoritos de %s"
+
+#: lib/personal.php:66
+msgid "User"
+msgstr "Usuario"
+
+#: lib/personal.php:75
+msgid "Inbox"
+msgstr "Band. Entrada"
+
+#: lib/personal.php:76
+msgid "Your incoming messages"
+msgstr "As túas mensaxes entrantes"
+
+#: lib/personal.php:80
+msgid "Outbox"
+msgstr "Band. Saída"
+
+#: lib/personal.php:81
+msgid "Your sent messages"
+msgstr "As túas mensaxes enviadas"
+
+#: lib/settingsaction.php:99
+#: actions/deleteprofile.php:256
+#: lib/settingsaction.php:103
+#: lib/settingsaction.php:105
+msgid "Twitter"
+msgstr "Twitter"
+
+#: lib/settingsaction.php:100
+#: actions/deleteprofile.php:257
+#: lib/settingsaction.php:104
+#: lib/settingsaction.php:106
+msgid "Twitter integration options"
+msgstr "Opcións de integración de Twitter"
+
+#: lib/util.php:1718
+#: lib/util.php:2204
+msgid "To"
+msgstr "A"
+
+#: scripts/maildaemon.php:45
+msgid "Could not parse message."
+msgstr "Non se puido analizaar a mensaxe."
+
+#: actions/block.php:45
+#: actions/subedit.php:45
+#: actions/unblock.php:45
+msgid "No profile specified."
+msgstr "Non se especificou ningún perfil."
+
+#: actions/block.php:52
+#: actions/subedit.php:52
+#: actions/tagother.php:45
+#: actions/unblock.php:52
+msgid "No profile with that ID."
+msgstr "Non se atopou un perfil con ese ID."
+
+#: actions/block.php:78
+msgid "Block user"
+msgstr "Bloquear usuario"
+
+#: actions/block.php:81
+msgid "Are you sure you want to block this user? Afterwards, they will be unsubscribed from you, unable to subscribe to you in the future, and you will not be notified of any @-replies from them."
+msgstr "Seguro que queres bloquear a este usuario? Despois diso, vai ser de-suscrito do teur perfil, non será capaz de suscribirse a ti nun futuro, e non vas a ser notificado de ningunha resposta-@ del."
+
+#: actions/block.php:117
+msgid "You have already blocked this user."
+msgstr "Xa bloqueaches a este usuario."
+
+#: actions/block.php:124
+msgid "Failed to save block information."
+msgstr "Erro ao gardar información de bloqueo."
+
+#: actions/deleteprofile.php:25
+msgid "Code not yet ready."
+msgstr "Código non implementado."
+
+#: actions/deleteprofile.php:36
+msgid "Export and delete your user information."
+msgstr "Exportar e eliminar a túa información de usuario."
+
+#: actions/deleteprofile.php:88
+#: actions/deleteprofile.php:119
+msgid "Delete my account"
+msgstr "Borrar a miña conta"
+
+#: actions/deleteprofile.php:89
+msgid "Delete my account confirmation"
+msgstr "Confirmación de borrado da miña conta"
+
+#: actions/deleteprofile.php:117
+msgid "Check if you are sure you want to delete your account."
+msgstr "Estas seguro que queres eliminar a tua conta?"
+
+#: actions/deleteprofile.php:259
+#: lib/settingsaction.php:106
+#: lib/util.php:384
+#: lib/settingsaction.php:108
+msgid "Other"
+msgstr "Outros"
+
+#: actions/deleteprofile.php:260
+#: lib/settingsaction.php:107
+#: lib/settingsaction.php:109
+msgid "Other options"
+msgstr "Outras opcions"
+
+#: actions/disfavor.php:72
+msgid "Add to favorites"
+msgstr "Engadir a favoritos"
+
+#: actions/emailsettings.php:98
+msgid "Allow friends to nudge me and send me an email."
+msgstr "Permitir aos amigos darme toques e enviarme correos electrónicos."
+
+#: actions/facebookremove.php:54
+msgid "Couldn't remove Facebook user."
+msgstr "Non se puido eliminar o usuario de Facebook."
+
+#: actions/favorited.php:31
+#: lib/stream.php:48
+msgid "Popular notices"
+msgstr "Chíos populares"
+
+#: actions/favorited.php:54
+msgid "Showing recently popular notices"
+msgstr "Amosando chíos populares recentes"
+
+#: actions/favor.php:71
+msgid "Disfavor favorite"
+msgstr "Desactivar favorito"
+
+#: actions/featured.php:32
+#: actions/featured.php:54
+#: lib/stream.php:44
+msgid "Featured users"
+msgstr "Usuarios destacados"
+
+#: actions/finishremotesubscribe.php:186
+msgid "That user has blocked you from subscribing."
+msgstr "Este usuario non che permite suscribirte a el."
+
+#: actions/imsettings.php:83
+msgid "Send me notices from public timeline through Jabber/GTalk."
+msgstr "Enviarme os chíos da liña de tempo pública a través de Jabber/GTalk."
+
+#: actions/login.php:120
+msgid "you can also login using OpenID"
+msgstr "tamén te podes rexistrar cunha conta OpenID"
+
+#: actions/microsummary.php:39
+msgid "No current status"
+msgstr "Sen estado actual"
+
+#: actions/misc.php:81
+msgid "Embedded"
+msgstr "Embebida"
+
+#: actions/misc.php:82
+#, php-format
+msgid "Embedded %1s"
+msgstr "%1s embebida"
+
+#: actions/misc.php:84
+msgid "WP"
+msgstr "WP"
+
+#: actions/newnotice.php:93
+msgid "Notice posted"
+msgstr "Chío publicado"
+
+#: actions/newnotice.php:116
+#: classes/Channel.php:140
+msgid "Ajax Error"
+msgstr "Erro de Ajax"
+
+#: actions/nudge.php:52
+msgid "This user doesn't allow nudges or hasn't confirmed or set his email yet."
+msgstr "Este usuario non permite toques, ou non confirmou ainda o seu correo electrónico."
+
+#: actions/nudge.php:61
+msgid "Nudge sent"
+msgstr "Toque enviado"
+
+#: actions/othersettings.php:27
+msgid "Manage various other options."
+msgstr "Xestionár axustes varios."
+
+#: actions/othersettings.php:33
+msgid "Other Settings"
+msgstr "Outros axustes"
+
+#: actions/othersettings.php:35
+msgid "URL Auto-shortening"
+msgstr "Auto-acortado de URL"
+
+#: actions/othersettings.php:54
+msgid "Service"
+msgstr "Servizo"
+
+#: actions/othersettings.php:54
+msgid "Automatic shortening service to use."
+msgstr "Servizo de acortado automático a usar."
+
+#: actions/othersettings.php:155
+msgid "URL shortening service is too long (max 50 chars)."
+msgstr "Sistema de acortamento de URLs demasiado longo (max 50 car.)."
+
+#: actions/peopletag.php:33
+#, php-format
+msgid "Not a valid people tag: %s"
+msgstr "%s non é unha etiqueta de xente válida"
+
+#: actions/peopletag.php:45
+#, php-format
+msgid "Users self-tagged with %s - page %d"
+msgstr "Usuarios auto-etiquetados como %s - páxina %d"
+
+#: actions/peopletag.php:87
+#, php-format
+msgid "These are users who have tagged themselves \"%s\" to show a common interest, characteristic, hobby or job."
+msgstr "Estes son usuarios que se etiquetaron a sí mesmos como \"%s\" para mostrar intereses comuns, características, aficións ou traballos."
+
+#: actions/profilesettings.php:92
+msgid "Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated"
+msgstr "Etiquetas para o teu usuario (letras, números, -, ., e _), separados por coma ou espazo"
+
+#: actions/profilesettings.php:116
+msgid "Theme"
+msgstr "Tema"
+
+#: actions/profilesettings.php:116
+msgid "Preferred theme"
+msgstr "Tema preferido"
+
+#: actions/profilesettings.php:259
+#: actions/tagother.php:131
+#, php-format
+msgid "Invalid tag: \"%s\""
+msgstr "Etiqueta inválida: '%s'"
+
+#: actions/profilesettings.php:345
+msgid "Couldn't save tags."
+msgstr "Non se puideron gardar as etiquetas."
+
+#: actions/public.php:68
+#, php-format
+msgid "This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service based on the Free Software [StatusNet](http://status.net/) tool. [Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))"
+msgstr "Esto é %%site.name%%, un servizo de [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) basado na ferramenta de código aberto [StatusNet](http://status.net/). [Únete agora](%%action.register%%) para compartir chíos cos teus amigos, colegas e familia! ([Ler mais](%%doc.help%%))"
+
+#: actions/public.php:90
+msgid "Could not retrieve public stream."
+msgstr "Non se pudo recuperar a liña de tempo publica."
+
+#: actions/register.php:67
+#: actions/register.php:177
+msgid "Sorry, only invited people can register."
+msgstr "Desculpa, só se pode rexistrar a xente con invitación."
+
+#: actions/register.php:156
+#, php-format
+msgid "With this form you can create a new account. You can then post notices and link up to friends and colleagues. (Have an [OpenID](http://openid.net/)? Try our [OpenID registration](%%action.openidlogin%%)!)"
+msgstr "Neste formulario podes crear unha conta de usuario. Logo poderás publicar chíos, e suscribirte a amigos. (Tes unha conta [OpenID](http://openid.net/)? Proba o noso [Rexistro OpenID](%%action.openidlogin%%)!)"
+
+#: actions/remotesubscribe.php:136
+#: actions/remotesubscribe.php:141
+msgid "That's a local profile! Login to subscribe."
+msgstr "Este é un perfil local! Rexístrate para suscribirte."
+
+#: actions/smspostsettings.php:27
+#, php-format
+msgid "You can post on %1s sending an sms to %2s in the followin format: '%3s'"
+msgstr "Podes publicar chíos en %1s enviando un SMS a %2s co seguinte formato: '%3s'"
+
+#: actions/smspostsettings.php:32
+#: actions/smspostsettings.php:33
+#: actions/smspostsettings.php:57
+msgid "SMS Post Settings"
+msgstr "Configuracións de envio por SMS"
+
+#: actions/smspostsettings.php:101
+#: actions/smspostsettings.php:106
+msgid "The address was added."
+msgstr "Enderezo engadido."
+
+#: actions/subedit.php:68
+msgid "You are not subscribed to that profile."
+msgstr "Non estás suscrito a ese perfil"
+
+#: actions/subedit.php:81
+msgid "Could not save subscription."
+msgstr "Non se pode gardar a subscrición."
+
+#: actions/subscribe.php:53
+msgid "Not a local user."
+msgstr "Non é usuario local."
+
+#: actions/subscribe.php:67
+msgid "Subscribed"
+msgstr "Suscrito"
+
+#: actions/subscriptions.php:72
+msgid "Jabber"
+msgstr "Jabber."
+
+#: actions/tagother.php:31
+msgid "Not logged in"
+msgstr "Non estás logueado."
+
+#: actions/tagother.php:40
+msgid "No id argument."
+msgstr "Non hai argumento id."
+
+#: actions/tagother.php:56
+msgid "Tag a person"
+msgstr "Etiquetar a unha persoa"
+
+#: actions/tagother.php:98
+msgid "Tags for this user (letters, numbers, -, ., and _), comma- or space- separated"
+msgstr "Etiquetas para este usuario (letras, numeros, -, ., e _), separados por coma ou espazo"
+
+#: actions/tagother.php:120
+msgid "No such profile."
+msgstr "Non existe o perfil."
+
+#: actions/tagother.php:146
+msgid "You can only tag people you are subscribed to or who are subscribed to you."
+msgstr "Só podes etiquetar xente á que estás suscrito ou aos que están suscritos a ti."
+
+#: actions/tagother.php:153
+msgid "Could not save tags."
+msgstr "Non se poden gardar as etiquetas."
+
+#: actions/tagother.php:188
+msgid "Use this form to add tags to your subscribers or subscriptions."
+msgstr "Usa este formulario para engadir etiquetas aos teus seguidores ou aos que sigues."
+
+#: actions/tag.php:66
+msgid "Showing all tags"
+msgstr "Amosando tódalas etiquetas"
+
+#: actions/tagrss.php:33
+msgid "No such tag."
+msgstr "Non existe a etiqueta."
+
+#: actions/tagrss.php:62
+#, php-format
+msgid "Microblog tagged with %s"
+msgstr "Microblog etiquetado con %s"
+
+#: actions/twitapiblocks.php:45
+msgid "Block user failed."
+msgstr "Bloqueo de usuario fallido."
+
+#: actions/twitapiblocks.php:66
+msgid "Unblock user failed."
+msgstr "Desbloqueo de usuario fallido."
+
+#: actions/twitapifavorites.php:159
+#: lib/mail.php:294
+#, php-format
+msgid ""
+"%1$s just added your notice from %2$s as one of their favorites.\n"
+"\n"
+"In case you forgot, you can see the text of your notice here:\n"
+"\n"
+"%3$s\n"
+"\n"
+"You can see the list of %1$s's favorites here:\n"
+"\n"
+"%4$s\n"
+"\n"
+"Faithfully yours,\n"
+"%5$s\n"
+msgstr ""
+"%1$s acaba de engadir o teu chío en %2$s como un dos seus favoritos.\n"
+"\n"
+"Se o olvidaches, podes velo texto do teu chío aquí:\n"
+"\n"
+"%3$s\n"
+"\n"
+"Podes vela lista de cíos favoritos de %1$s aquí:\n"
+"\n"
+"%4$s\n"
+"\n"
+"Fielmente teu,\n"
+"%5$s\n"
+
+#: actions/twitapiusers.php:46
+msgid "Not found."
+msgstr "Non atopado"
+
+#: actions/twittersettings.php:29
+msgid "Add your Twitter account to automatically send your notices to Twitter, and subscribe to Twitter friends already here."
+msgstr "Engade a túa conta de Twitter para enviar automáticamente os teus chíos a Twitter, e suscribirte aos usuarios de twiter que teñas como amigos aqui."
+
+#: actions/twittersettings.php:63
+msgid "Twitter user name"
+msgstr "Nome de usuario en Twitter"
+
+#: actions/twittersettings.php:67
+msgid "Twitter password"
+msgstr "Contrasinal de Twitter"
+
+#: actions/twittersettings.php:129
+msgid "Twitter Friends"
+msgstr "Amigos de Twitter"
+
+#: actions/unblock.php:73
+msgid "Error removing the block."
+msgstr "Acounteceu un erro borrando o bloqueo."
+
+#: actions/unsubscribe.php:48
+msgid "No profile id in request."
+msgstr "Non hai identificador de perfil na peticion."
+
+#: actions/unsubscribe.php:55
+msgid "No profile with that id."
+msgstr "Non se atopou un perfil con ese ID."
+
+#: actions/unsubscribe.php:69
+msgid "Unsubscribed"
+msgstr "De-suscribido"
+
+#: actions/users.php:38
+#: lib/util.php:378
+msgid "Users list"
+msgstr "Lista de usuarios"
+
+#: classes/Command.php:96
+#, php-format
+msgid ""
+"Subscriptions: %1$s\n"
+"Subscribers: %2$s\n"
+"Notices: %3$s"
+msgstr ""
+"Suscripcións: %1$s\n"
+"Suscriptores: %2$s\n"
+"Chíos: %3$s"
+
+#: classes/Command.php:349
+msgid ""
+"Commands:\n"
+"on - turn on notifications\n"
+"off - turn off notifications\n"
+"help - show this help\n"
+"follow <nickname> - subscribe to user\n"
+"leave <nickname> - unsubscribe from user\n"
+"d <nickname> <text> - direct message to user\n"
+"get <nickname> - get last notice from user\n"
+"whois <nickname> - get profile info on user\n"
+"fav <nickname> - add user's last notice as a 'fave'\n"
+"stats - get your stats\n"
+"stop - same as 'off'\n"
+"quit - same as 'off'\n"
+"sub <nickname> - same as 'follow'\n"
+"unsub <nickname> - same as 'leave'\n"
+"last <nickname> - same as 'get'\n"
+"on <nickname> - not yet implemented.\n"
+"off <nickname> - not yet implemented.\n"
+"nudge <nickname> - not yet implemented.\n"
+"invite <phone number> - not yet implemented.\n"
+"track <word> - not yet implemented.\n"
+"untrack <word> - not yet implemented.\n"
+"track off - not yet implemented.\n"
+"untrack all - not yet implemented.\n"
+"tracks - not yet implemented.\n"
+"tracking - not yet implemented.\n"
+msgstr ""
+"Comandos:\n"
+"on - activar as notificacións\n"
+"off - desactivar as notificacións\n"
+"help - mostrar esta axuda\n"
+"follow <nickname> - suscribirse ao usuario\n"
+"leave <nickname> - de-suscribirse do usuario\n"
+"d <nickname> <text> - mensaxe directa ao usuario\n"
+"get <nickname> - lelo último chío do usuario\n"
+"whois <nickname> - amosar informacion do usuario\n"
+"fav <nickname> - engadilo último chío do usuario como favorito\n"
+"stats - amosalas túas estatísticas\n"
+"stop - o mesmo que 'off'\n"
+"quit - o mesmo que 'off'\n"
+"sub <nickname> - o mesmo que 'follow'\n"
+"unsub <nickname> - o mesmo que 'leave'\n"
+"last <nickname> - o mesmo que 'get'\n"
+"on <nickname> - non implementado por agora.\n"
+"off <nickname> - non implementado por agora.\n"
+"nudge <nickname> - non implementado por agora.\n"
+"invite <phone number> - non implementado por agora.\n"
+"track <word> - non implementado por agora.\n"
+"untrack <word> - non implementado por agora.\n"
+"track off - non implementado por agora.\n"
+"untrack all - non implementado por agora.\n"
+"tracks - non implementado por agora.\n"
+"tracking - non implementado por agora.\n"
+
+#: classes/Notice.php:100
+msgid "Problem saving notice. Unknown user."
+msgstr "Aconteceu un erro ó gardar o chío. Usuario descoñecido."
+
+#: classes/Notice.php:105
+msgid "Too many notices too fast; take a breather and post again in a few minutes."
+msgstr "Demasiados chíos en pouco tempo; tomate un respiro e envíao de novo dentro duns minutos."
+
+#: classes/Notice.php:112
+msgid "You are banned from posting notices on this site."
+msgstr "Tes restrinxido o envio de chíos neste sitio."
+
+#: lib/gallery.php:98
+msgid "Filter tags"
+msgstr "Filtrar etiquetas"
+
+#: lib/gallery.php:104
+msgid "All"
+msgstr "Todos"
+
+#: lib/gallery.php:108
+msgid "Tag"
+msgstr "Etiqueta"
+
+#: lib/gallery.php:109
+msgid "Choose a tag to narrow list"
+msgstr "Elixe unha etiqueta para reducila lista"
+
+#: lib/gallery.php:110
+msgid "Go"
+msgstr "Ir"
+
+#: lib/gallery.php:264
+msgid "Subscriptions navigation"
+msgstr "Navegación de subscricións"
+
+#: lib/gallery.php:270
+#: lib/gallery.php:292
+msgid "List"
+msgstr "Lista"
+
+#: lib/gallery.php:280
+#: lib/gallery.php:294
+msgid "Icons"
+msgstr "Iconos"
+
+#: lib/mail.php:92
+#, php-format
+msgid ""
+"Hey, %s.\n"
+"\n"
+"Someone just entered this email address on %s.\n"
+"\n"
+"If it was you, and you want to confirm your entry, use the URL below:\n"
+"\n"
+"\t%s\n"
+"\n"
+"If not, just ignore this message.\n"
+"\n"
+"Thanks for your time, \n"
+"%s\n"
+msgstr ""
+"Ei, %s.\n"
+"\n"
+"Alguén introduceu o teu correo electrónico en %s.\n"
+"\n"
+"Se foches ti, e queres confirmar a entrada, pincha na seguinte URL:\n"
+"\n"
+"\t%s\n"
+"\n"
+"Se non, simplemente ignora esta mensaxe.\n"
+"\n"
+"Grazas polo teu tempo, \n"
+"%s\n"
+
+#: lib/mail.php:232
+#, php-format
+msgid "You've been nudged by %s"
+msgstr "%s douche un toque"
+
+#: lib/mail.php:236
+#, php-format
+msgid ""
+"%1$s (%2$s) is wondering what you are up to these days and is inviting you to post some news.\n"
+"\n"
+"So let's hear from you :)\n"
+"\n"
+"%3$s\n"
+"\n"
+"Don't reply to this email; it won't get to them.\n"
+"\n"
+"With kind regards,\n"
+"%4$s\n"
+msgstr ""
+"%1$s (%2$s) preguntase que é de ti, e invítate a publicar algun chío.\n"
+"\n"
+"So let's hear from you :)\n"
+"\n"
+"%3$s\n"
+"\n"
+"Don't reply to this email; it won't get to them.\n"
+"\n"
+"With kind regards,\n"
+"%4$s\n"
+
+#: lib/mail.php:269
+#, php-format
+msgid ""
+"%1$s (%2$s) sent you a private message:\n"
+"\n"
+"------------------------------------------------------\n"
+"%3$s\n"
+"------------------------------------------------------\n"
+"\n"
+"You can reply to their message here:\n"
+"\n"
+"%4$s\n"
+"\n"
+"Don't reply to this email; it won't get to them.\n"
+"\n"
+"With kind regards,\n"
+"%5$s\n"
+msgstr ""
+"%1$s (%2$s) enviouche unha mensaxe privada:\n"
+"\n"
+"------------------------------------------------------\n"
+"%3$s\n"
+"------------------------------------------------------\n"
+"\n"
+"You can reply to their message here:\n"
+"\n"
+"%4$s\n"
+"\n"
+"Don't reply to this email; it won't get to them.\n"
+"\n"
+"With kind regards,\n"
+"%5$s\n"
+
+#: lib/profilelist.php:146
+msgid "(none)"
+msgstr "(nada)"
+
+#: lib/settingsaction.php:97
+#: lib/settingsaction.php:98
+msgid "SMS Post"
+msgstr "Envío por SMS"
+
+#: lib/settingsaction.php:98
+#: lib/settingsaction.php:99
+msgid "Posts by SMS"
+msgstr "Chíos dende SMS"
+
+#: lib/stream.php:33
+msgid "Public"
+msgstr "Público"
+
+#: lib/stream.php:36
+#: lib/stream.php:37
+msgid "Recent tags"
+msgstr "Etiquetas recentes"
+
+#: lib/stream.php:39
+#: lib/stream.php:40
+msgid "All tags"
+msgstr "Tódalas etiquetas"
+
+#: lib/stream.php:43
+msgid "Featured"
+msgstr "Destacado"
+
+#: lib/stream.php:47
+msgid "Popular"
+msgstr "Popular"
+
+#: lib/subs.php:51
+msgid "User has blocked you."
+msgstr "O usuario bloqueoute."
+
+#: lib/util.php:379
+msgid "Users"
+msgstr "Usuarios"
+
+#: lib/util.php:2118
+msgid "Send a nudge"
+msgstr "Dar un toque"
+
+#: lib/util.php:2122
+msgid "Nudge sent!"
+msgstr "Toque enviado!"
+
+#: lib/util.php:2253
+msgid "Block"
+msgstr "Bloquear"
+
+#: lib/util.php:2257
+msgid "Unblock"
+msgstr "Desbloquear"
+
+#: actions/newsmsnotice.php:29
+#: actions/smspostsettings.php:57
+msgid "SMS Post Disabled!"
+msgstr "Publicación de chíos por SMS desactivado!"
+
+#: actions/badgemisc.php:31
+#, php-format
+msgid "%1s in your blog"
+msgstr "%1s no teu blogue"
+
+#: actions/misc.php:85
+msgid "WordPress Plugin"
+msgstr "Plugin WordPress"
+
+#: actions/misc.php:88
+#, php-format
+msgid "Graphics and statistics about the state of %1s"
+msgstr "Gráficos e estatísticas sobre o estado de %1s"
+
+#: actions/newsmsnotice.php:35
+#, php-format
+msgid "%1s is not a reliable source."
+msgstr "%1s non é unha orixe fiable."
+
+#: actions/newsmsnotice.php:60
+msgid "Unexpected error"
+msgstr "Erro inesperado"
+
+#: actions/newsmsnotice.php:65
+msgid "No such phone"
+msgstr "Non existe o telefono"
+
+#: actions/newsmsnotice.php:75
+msgid "Missing message"
+msgstr "Falta a mensaxe"
+
+#: actions/newsmsnotice.php:91
+msgid "Notice published correctly"
+msgstr "Chío publicado correctamente"
+
+#: actions/wpmisc.php:27
+msgid "If you want to have your notices on your Wordpress, then follow the instructions"
+msgstr "Se queres ter os teus chios no teu Wordpress, sigue as instruccións"
+
+#: actions/wpmisc.php:31
+#, php-format
+msgid "%1s on your Wordpress"
+msgstr "%1s no teu Wordpress"
+
+#: actions/badgemisc.php:27
+msgid "If you want to have your notices on your blog/website, then follow the instructions"
+msgstr "Se queres ter os teus chios no teu blogue/sitio web, sigue as instruccións"
+
diff --git a/locale/he_IL/LC_MESSAGES/statusnet.mo b/locale/he/LC_MESSAGES/statusnet.mo
index 609918d92..609918d92 100644
--- a/locale/he_IL/LC_MESSAGES/statusnet.mo
+++ b/locale/he/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/he_IL/LC_MESSAGES/statusnet.po b/locale/he/LC_MESSAGES/statusnet.po
index 97a44a030..97a44a030 100644
--- a/locale/he_IL/LC_MESSAGES/statusnet.po
+++ b/locale/he/LC_MESSAGES/statusnet.po
diff --git a/locale/is/LC_MESSAGES/statusnet.mo b/locale/is/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..36039f4aa
--- /dev/null
+++ b/locale/is/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/is_IS/LC_MESSAGES/statusnet.po b/locale/is/LC_MESSAGES/statusnet.po
index 524b85a0d..524b85a0d 100644
--- a/locale/is_IS/LC_MESSAGES/statusnet.po
+++ b/locale/is/LC_MESSAGES/statusnet.po
diff --git a/locale/it/LC_MESSAGES/statusnet.mo b/locale/it/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..00ab59804
--- /dev/null
+++ b/locale/it/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/it_IT/LC_MESSAGES/statusnet.po b/locale/it/LC_MESSAGES/statusnet.po
index 1a59adf85..1a59adf85 100644
--- a/locale/it_IT/LC_MESSAGES/statusnet.po
+++ b/locale/it/LC_MESSAGES/statusnet.po
diff --git a/locale/it_IT/LC_MESSAGES/statusnet.mo b/locale/it_IT/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index 95764f1e2..000000000
--- a/locale/it_IT/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/ja/LC_MESSAGES/statusnet.mo b/locale/ja/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..7026035cc
--- /dev/null
+++ b/locale/ja/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/ja_JP/LC_MESSAGES/statusnet.po b/locale/ja/LC_MESSAGES/statusnet.po
index bb7d777ba..bb7d777ba 100644
--- a/locale/ja_JP/LC_MESSAGES/statusnet.po
+++ b/locale/ja/LC_MESSAGES/statusnet.po
diff --git a/locale/ja_JP/LC_MESSAGES/statusnet.mo b/locale/ja_JP/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index 86efaaf5d..000000000
--- a/locale/ja_JP/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/ko_KR/LC_MESSAGES/statusnet.mo b/locale/ko/LC_MESSAGES/statusnet.mo
index 2b177ff86..2b177ff86 100644
--- a/locale/ko_KR/LC_MESSAGES/statusnet.mo
+++ b/locale/ko/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/ko_KR/LC_MESSAGES/statusnet.po b/locale/ko/LC_MESSAGES/statusnet.po
index 7bbdcdcf2..7bbdcdcf2 100644
--- a/locale/ko_KR/LC_MESSAGES/statusnet.po
+++ b/locale/ko/LC_MESSAGES/statusnet.po
diff --git a/locale/mk/LC_MESSAGES/statusnet.mo b/locale/mk/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..5dec309dd
--- /dev/null
+++ b/locale/mk/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/mk_MK/LC_MESSAGES/statusnet.po b/locale/mk/LC_MESSAGES/statusnet.po
index d4c4eb235..0e91f0522 100644
--- a/locale/mk_MK/LC_MESSAGES/statusnet.po
+++ b/locale/mk/LC_MESSAGES/statusnet.po
@@ -4670,12 +4670,12 @@ msgstr "%1$s сега ги следи вашите забелешки за %2$s.
#: lib/mail.php:254
#, fuzzy, php-format
msgid "Location: %s\n"
-msgstr "Локација"
+msgstr ""
#: lib/mail.php:256
#, fuzzy, php-format
msgid "Homepage: %s\n"
-msgstr "Домашна страница"
+msgstr ""
#: lib/mail.php:258
#, php-format
diff --git a/locale/mk_MK/LC_MESSAGES/statusnet.mo b/locale/mk_MK/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index 0ac378c79..000000000
--- a/locale/mk_MK/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/nb_NO/LC_MESSAGES/statusnet.mo b/locale/nb/LC_MESSAGES/statusnet.mo
index ee3bad415..ee3bad415 100644
--- a/locale/nb_NO/LC_MESSAGES/statusnet.mo
+++ b/locale/nb/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/nb_NO/LC_MESSAGES/statusnet.po b/locale/nb/LC_MESSAGES/statusnet.po
index 5e2d6613c..5e2d6613c 100644
--- a/locale/nb_NO/LC_MESSAGES/statusnet.po
+++ b/locale/nb/LC_MESSAGES/statusnet.po
diff --git a/locale/nl/LC_MESSAGES/statusnet.mo b/locale/nl/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..122a49285
--- /dev/null
+++ b/locale/nl/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/nl_NL/LC_MESSAGES/statusnet.po b/locale/nl/LC_MESSAGES/statusnet.po
index 6cc0a52c4..6cc0a52c4 100644
--- a/locale/nl_NL/LC_MESSAGES/statusnet.po
+++ b/locale/nl/LC_MESSAGES/statusnet.po
diff --git a/locale/nl_NL/LC_MESSAGES/statusnet.mo b/locale/nl_NL/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index 16ce96d0d..000000000
--- a/locale/nl_NL/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/nn_NO/LC_MESSAGES/statusnet.mo b/locale/nn/LC_MESSAGES/statusnet.mo
index 7dbde4019..7dbde4019 100644
--- a/locale/nn_NO/LC_MESSAGES/statusnet.mo
+++ b/locale/nn/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/nn_NO/LC_MESSAGES/statusnet.po b/locale/nn/LC_MESSAGES/statusnet.po
index 4da276adb..4da276adb 100644
--- a/locale/nn_NO/LC_MESSAGES/statusnet.po
+++ b/locale/nn/LC_MESSAGES/statusnet.po
diff --git a/locale/pl_PL/LC_MESSAGES/statusnet.mo b/locale/pl/LC_MESSAGES/statusnet.mo
index dba116252..dba116252 100644
--- a/locale/pl_PL/LC_MESSAGES/statusnet.mo
+++ b/locale/pl/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/pl_PL/LC_MESSAGES/statusnet.po b/locale/pl/LC_MESSAGES/statusnet.po
index 54c52e949..54c52e949 100644
--- a/locale/pl_PL/LC_MESSAGES/statusnet.po
+++ b/locale/pl/LC_MESSAGES/statusnet.po
diff --git a/locale/pt/LC_MESSAGES/statusnet.mo b/locale/pt/LC_MESSAGES/statusnet.mo
index 35d7053be..e6168a340 100644
--- a/locale/pt/LC_MESSAGES/statusnet.mo
+++ b/locale/pt/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/pt_BR/LC_MESSAGES/statusnet.mo b/locale/pt_BR/LC_MESSAGES/statusnet.mo
index 9db1638b0..a5a6f2725 100644
--- a/locale/pt_BR/LC_MESSAGES/statusnet.mo
+++ b/locale/pt_BR/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/ru_RU/LC_MESSAGES/statusnet.mo b/locale/ru/LC_MESSAGES/statusnet.mo
index c4066c65e..c4066c65e 100644
--- a/locale/ru_RU/LC_MESSAGES/statusnet.mo
+++ b/locale/ru/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/ru_RU/LC_MESSAGES/statusnet.po b/locale/ru/LC_MESSAGES/statusnet.po
index 8a553a37f..8a553a37f 100644
--- a/locale/ru_RU/LC_MESSAGES/statusnet.po
+++ b/locale/ru/LC_MESSAGES/statusnet.po
diff --git a/locale/sv/LC_MESSAGES/statusnet.mo b/locale/sv/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..2cb0397ec
--- /dev/null
+++ b/locale/sv/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/sv_SE/LC_MESSAGES/statusnet.po b/locale/sv/LC_MESSAGES/statusnet.po
index d0a5001da..d0a5001da 100644
--- a/locale/sv_SE/LC_MESSAGES/statusnet.po
+++ b/locale/sv/LC_MESSAGES/statusnet.po
diff --git a/locale/sv_SE/LC_MESSAGES/statusnet.mo b/locale/sv_SE/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index ce3c6c1f5..000000000
--- a/locale/sv_SE/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/te/LC_MESSAGES/statusnet.mo b/locale/te/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..5cfa0c3fb
--- /dev/null
+++ b/locale/te/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/te_IN/LC_MESSAGES/statusnet.po b/locale/te/LC_MESSAGES/statusnet.po
index 4576f3613..4576f3613 100644
--- a/locale/te_IN/LC_MESSAGES/statusnet.po
+++ b/locale/te/LC_MESSAGES/statusnet.po
diff --git a/locale/te_IN/LC_MESSAGES/statusnet.mo b/locale/te_IN/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index bb837b977..000000000
--- a/locale/te_IN/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/tr/LC_MESSAGES/statusnet.mo b/locale/tr/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..d49c7093d
--- /dev/null
+++ b/locale/tr/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/tr_TR/LC_MESSAGES/statusnet.po b/locale/tr/LC_MESSAGES/statusnet.po
index e67fbf33c..4dbc221d1 100644
--- a/locale/tr_TR/LC_MESSAGES/statusnet.po
+++ b/locale/tr/LC_MESSAGES/statusnet.po
@@ -4676,13 +4676,13 @@ msgstr "%1$s %2$s'da durumunuzu takip ediyor"
#: lib/mail.php:254
#, fuzzy, php-format
msgid "Location: %s\n"
-msgstr "Yer"
+msgstr ""
# Belki Durum Merkezi falan denebilir mi ki?
#: lib/mail.php:256
#, fuzzy, php-format
msgid "Homepage: %s\n"
-msgstr "Başlangıç Sayfası"
+msgstr ""
#: lib/mail.php:258
#, php-format
diff --git a/locale/tr_TR/LC_MESSAGES/statusnet.mo b/locale/tr_TR/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index e0ef80560..000000000
--- a/locale/tr_TR/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/uk_UA/LC_MESSAGES/statusnet.mo b/locale/uk/LC_MESSAGES/statusnet.mo
index e08dc4e9c..e08dc4e9c 100644
--- a/locale/uk_UA/LC_MESSAGES/statusnet.mo
+++ b/locale/uk/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/uk_UA/LC_MESSAGES/statusnet.po b/locale/uk/LC_MESSAGES/statusnet.po
index 55cea21c3..55cea21c3 100644
--- a/locale/uk_UA/LC_MESSAGES/statusnet.po
+++ b/locale/uk/LC_MESSAGES/statusnet.po
diff --git a/locale/vi/LC_MESSAGES/statusnet.mo b/locale/vi/LC_MESSAGES/statusnet.mo
new file mode 100644
index 000000000..b2f4dd370
--- /dev/null
+++ b/locale/vi/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/vi_VN/LC_MESSAGES/statusnet.po b/locale/vi/LC_MESSAGES/statusnet.po
index af34d5210..af34d5210 100644
--- a/locale/vi_VN/LC_MESSAGES/statusnet.po
+++ b/locale/vi/LC_MESSAGES/statusnet.po
diff --git a/locale/vi_VN/LC_MESSAGES/statusnet.mo b/locale/vi_VN/LC_MESSAGES/statusnet.mo
deleted file mode 100644
index 65add28b4..000000000
--- a/locale/vi_VN/LC_MESSAGES/statusnet.mo
+++ /dev/null
Binary files differ
diff --git a/locale/zh_TW/LC_MESSAGES/statusnet.mo b/locale/zh_TW/LC_MESSAGES/statusnet.mo
index e13548831..9bdfbaf9f 100644
--- a/locale/zh_TW/LC_MESSAGES/statusnet.mo
+++ b/locale/zh_TW/LC_MESSAGES/statusnet.mo
Binary files differ
diff --git a/locale/zh_TW/LC_MESSAGES/statusnet.po b/locale/zh_TW/LC_MESSAGES/statusnet.po
index a94187518..4f1168601 100644
--- a/locale/zh_TW/LC_MESSAGES/statusnet.po
+++ b/locale/zh_TW/LC_MESSAGES/statusnet.po
@@ -4563,12 +4563,12 @@ msgstr "現在%1$s在%2$s成為你的粉絲囉"
#: lib/mail.php:254
#, fuzzy, php-format
msgid "Location: %s\n"
-msgstr "地點"
+msgstr ""
#: lib/mail.php:256
#, fuzzy, php-format
msgid "Homepage: %s\n"
-msgstr "個人首頁"
+msgstr ""
#: lib/mail.php:258
#, php-format
diff --git a/plugins/FBConnect/README b/plugins/FBConnect/README
deleted file mode 100644
index 77d57eff9..000000000
--- a/plugins/FBConnect/README
+++ /dev/null
@@ -1,76 +0,0 @@
-This plugin allows you to utilize Facebook Connect with StatusNet.
-Supported Facebook Connect features:
-
-- Authenticate (register/login/logout -- works similar to OpenID)
-- Associate an existing StatusNet account with a Facebook account
-- Disconnect a Facebook account from a StatusNet account
-
-Future planned functionality:
-
-- Invite Facebook friends to use your StatusNet installation
-- Auto-subscribe Facebook friends already using StatusNet
-- Share StatusNet favorite notices to your Facebook stream
-
-To use the plugin you will need to configure a Facebook application
-to point to your StatusNet installation (see the Installation section
-below).
-
-Installation
-============
-
-If you don't already have the built-in Facebook application configured,
-you'll need to log into Facebook and create/configure a new application.
-Please follow the instructions in the section titled, "Setting Up Your
-Application and Getting an API Key," on the following page of the
-Facebook developer wiki:
-
- http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site
-
-If you already are using the build-in StatusNet Facebook application,
-you can modify your existing application's configuration using the
-Facebook Developer Application on Facebook. Use it to edit your
-application settings, and under the 'Connect' tab, change the 'Connect
-URL' to be the main URL for your StatusNet site. E.g.:
-
- http://SITE/PATH_TO_STATUSNET/
-
-After you application is created and configured, you'll need to add its
-API key and secret to your StatusNet config.php file:
-
- $config['facebook']['apikey'] = 'APIKEY';
- $config['facebook']['secret'] = 'SECRET';
-
-Finally, to enable the plugin, add the following stanza to your
-config.php:
-
- addPlugin('FBConnect');
-
-To try out the plugin, fire up your browser and connect to:
-
- http://SITE/PATH_TO_STATUSNET/main/facebooklogin
-
-or, if you do not have fancy URLs turned on:
-
- http://SITE/PATH_TO_STATUSNET/index.php/main/facebooklogin
-
-You should see a page with a blue button that says: "Connect with
-Facebook".
-
-Connect/Disconnect existing account
-===================================
-
-If the Facebook Connect plugin is enabled, there will be a new Facebook
-Connect Settings tab under each user's Connect menu. Users can connect
-and disconnect to their Facebook accounts from it. Note: Before a user
-can disconnect from Facebook, she must set a normal StatusNet password.
-Otherwise, she might not be able to login in to her account in the
-future. This is usually only required for users who have used Facebook
-Connect to register their StatusNet account, and therefore haven't
-already set a local password.
-
-Helpful links
-=============
-
-Facebook Connect Homepage:
-http://developers.facebook.com/connect.php
-
diff --git a/plugins/FBConnect/FBCLoginGroupNav.php b/plugins/Facebook/FBCLoginGroupNav.php
index 81b2520a4..81b2520a4 100644
--- a/plugins/FBConnect/FBCLoginGroupNav.php
+++ b/plugins/Facebook/FBCLoginGroupNav.php
diff --git a/plugins/FBConnect/FBCSettingsNav.php b/plugins/Facebook/FBCSettingsNav.php
index ed02371e2..ed02371e2 100644
--- a/plugins/FBConnect/FBCSettingsNav.php
+++ b/plugins/Facebook/FBCSettingsNav.php
diff --git a/plugins/FBConnect/FBC_XDReceiver.php b/plugins/Facebook/FBC_XDReceiver.php
index 2bc790d5a..2bc790d5a 100644
--- a/plugins/FBConnect/FBC_XDReceiver.php
+++ b/plugins/Facebook/FBC_XDReceiver.php
diff --git a/plugins/FBConnect/FBConnectPlugin.css b/plugins/Facebook/FBConnect.css
index 49217bf13..49217bf13 100644
--- a/plugins/FBConnect/FBConnectPlugin.css
+++ b/plugins/Facebook/FBConnect.css
diff --git a/plugins/FBConnect/FBConnectAuth.php b/plugins/Facebook/FBConnectAuth.php
index 647d5def8..b909a4977 100644
--- a/plugins/FBConnect/FBConnectAuth.php
+++ b/plugins/Facebook/FBConnectAuth.php
@@ -27,7 +27,7 @@
* @link http://status.net/
*/
-require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php';
+require_once INSTALLDIR . '/plugins/Facebook/FacebookPlugin.php';
class FBConnectauthAction extends Action
{
diff --git a/plugins/FBConnect/FBConnectLogin.php b/plugins/Facebook/FBConnectLogin.php
index 5696d8848..f146bef7d 100644
--- a/plugins/FBConnect/FBConnectLogin.php
+++ b/plugins/Facebook/FBConnectLogin.php
@@ -21,7 +21,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php';
+
+require_once INSTALLDIR . '/plugins/Facebook/FacebookPlugin.php';
class FBConnectLoginAction extends Action
{
diff --git a/plugins/FBConnect/FBConnectSettings.php b/plugins/Facebook/FBConnectSettings.php
index 911c56787..911c56787 100644
--- a/plugins/FBConnect/FBConnectSettings.php
+++ b/plugins/Facebook/FBConnectSettings.php
diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/Facebook/FacebookPlugin.php
index ff74aade4..b68534b24 100644
--- a/plugins/FBConnect/FBConnectPlugin.php
+++ b/plugins/Facebook/FacebookPlugin.php
@@ -2,7 +2,7 @@
/**
* StatusNet, the distributed open-source microblogging tool
*
- * Plugin to enable Facebook Connect
+ * Plugin to add a StatusNet Facebook application
*
* PHP version 5
*
@@ -27,22 +27,16 @@
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
+if (!defined('STATUSNET')) {
exit(1);
}
define("FACEBOOK_CONNECT_SERVICE", 3);
-require_once INSTALLDIR . '/lib/facebookutil.php';
-require_once INSTALLDIR . '/plugins/FBConnect/FBConnectAuth.php';
-require_once INSTALLDIR . '/plugins/FBConnect/FBConnectLogin.php';
-require_once INSTALLDIR . '/plugins/FBConnect/FBConnectSettings.php';
-require_once INSTALLDIR . '/plugins/FBConnect/FBCLoginGroupNav.php';
-require_once INSTALLDIR . '/plugins/FBConnect/FBCSettingsNav.php';
-require_once INSTALLDIR . '/plugins/FBConnect/FBC_XDReceiver.php';
+require_once INSTALLDIR . '/plugins/Facebook/facebookutil.php';
/**
- * Plugin to enable Facebook Connect
+ * Facebook plugin to add a StatusNet Facebook application
*
* @category Plugin
* @package StatusNet
@@ -51,22 +45,88 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBC_XDReceiver.php';
* @link http://status.net/
*/
-class FBConnectPlugin extends Plugin
+class FacebookPlugin extends Plugin
{
- function __construct()
+
+ /**
+ * Add Facebook app actions to the router table
+ *
+ * Hook for RouterInitialized event.
+ *
+ * @param Net_URL_Mapper &$m path-to-action mapper
+ *
+ * @return boolean hook return
+ */
+
+ function onRouterInitialized($m)
{
- parent::__construct();
- }
- // Hook in new actions
- function onRouterInitialized(&$m) {
+ // Facebook App stuff
+
+ $m->connect('facebook/app', array('action' => 'facebookhome'));
+ $m->connect('facebook/app/index.php', array('action' => 'facebookhome'));
+ $m->connect('facebook/app/settings.php',
+ array('action' => 'facebooksettings'));
+ $m->connect('facebook/app/invite.php', array('action' => 'facebookinvite'));
+ $m->connect('facebook/app/remove', array('action' => 'facebookremove'));
+
+ // Facebook Connect stuff
+
$m->connect('main/facebookconnect', array('action' => 'FBConnectAuth'));
$m->connect('main/facebooklogin', array('action' => 'FBConnectLogin'));
$m->connect('settings/facebook', array('action' => 'FBConnectSettings'));
$m->connect('xd_receiver.html', array('action' => 'FBC_XDReceiver'));
- }
- // Add in xmlns:fb
+ return true;
+ }
+
+ /**
+ * Automatically load the actions and libraries used by the Facebook app
+ *
+ * @param Class $cls the class
+ *
+ * @return boolean hook return
+ *
+ */
+
+ function onAutoload($cls)
+ {
+ switch ($cls) {
+ case 'FacebookAction':
+ case 'FacebookhomeAction':
+ case 'FacebookinviteAction':
+ case 'FacebookremoveAction':
+ case 'FacebooksettingsAction':
+ include_once INSTALLDIR . '/plugins/Facebook/' .
+ strtolower(mb_substr($cls, 0, -6)) . '.php';
+ return false;
+ case 'FBConnectAuthAction':
+ case 'FBConnectLoginAction':
+ case 'FBConnectSettingsAction':
+ case 'FBC_XDReceiverAction':
+ include_once INSTALLDIR . '/plugins/Facebook/' .
+ mb_substr($cls, 0, -6) . '.php';
+ return false;
+ case 'FBCLoginGroupNav':
+ include_once INSTALLDIR . '/plugins/Facebook/FBCLoginGroupNav.php';
+ return false;
+ case 'FBCSettingsNav':
+ include_once INSTALLDIR . '/plugins/Facebook/FBCSettingsNav.php';
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * Override normal HTML output to force the content type to
+ * text/html and add in xmlns:fb
+ *
+ * @param Action $action the current action
+ *
+ * @return void
+ */
+
function onStartShowHTML($action)
{
@@ -78,6 +138,7 @@ class FBConnectPlugin extends Plugin
// text/html even though Facebook Connect uses XHTML. This is
// A bug in Facebook Connect, and this is a temporary solution
// until they fix their JavaScript libs.
+
header('Content-Type: text/html');
$action->extraHeaders();
@@ -100,59 +161,108 @@ class FBConnectPlugin extends Plugin
}
}
- // Note: this script needs to appear in the <body>
+ /**
+ * Add in the Facebook Connect JavaScript stuff
+ *
+ * Note: this script needs to appear in the <body>
+ *
+ * @param Action $action the current action
+ *
+ * @return void
+ *
+ */
- function onStartShowHeader($action)
+ function onEndShowScripts($action)
{
if ($this->reqFbScripts($action)) {
- $apikey = common_config('facebook', 'apikey');
- $plugin_path = common_path('plugins/FBConnect');
+ $apikey = common_config('facebook', 'apikey');
+ $plugin_path = common_path('plugins/Facebook');
- $login_url = common_local_url('FBConnectAuth');
+ $login_url = common_local_url('FBConnectAuth');
$logout_url = common_local_url('logout');
// XXX: Facebook says we don't need this FB_RequireFeatures(),
// but we actually do, for IE and Safari. Gar.
- $html = sprintf('<script type="text/javascript">
- $(document).ready(function () {
- FB_RequireFeatures(
- ["XFBML"],
- function() {
- FB.init("%s", "../xd_receiver.html");
- }
- ); });
-
- function goto_login() {
- window.location = "%s";
- }
-
- function goto_logout() {
- window.location = "%s";
- }
- </script>', $apikey,
- $login_url, $logout_url);
-
- $action->raw($html);
+ $js = '<script type="text/javascript">';
+ $js .= ' $(document).ready(function () {';
+ $js .= ' FB_RequireFeatures(';
+ $js .= ' ["XFBML"], function() {';
+ $js .= ' FB.init("%1$s", "../xd_receiver.html");';
+ $js .= ' }';
+ $js .= ' );';
+ $js .= ' });';
+
+ $js .= ' function goto_login() {';
+ $js .= ' window.location = "%2$s";';
+ $js .= ' }';
+
+ // The below function alters the logout link so that it logs the user out
+ // of Facebook Connect as well as the site. However, for some pages
+ // (FB Connect Settings) we need to output the FB Connect scripts (to
+ // show an existing FB connection even if the user isn't authenticated
+ // with Facebook connect) but NOT alter the logout link. And the only
+ // way to reliably do that is with the FB Connect .js libs. Crazy.
+
+ $js .= ' FB.ensureInit(function() {';
+ $js .= ' FB.Connect.ifUserConnected(';
+ $js .= ' function() { ';
+ $js .= ' $(\'#nav_logout a\').attr(\'href\', \'#\');';
+ $js .= ' $(\'#nav_logout a\').click(function() {';
+ $js .= ' FB.Connect.logoutAndRedirect(\'%3$s\');';
+ $js .= ' return false;';
+ $js .= ' })';
+ $js .= ' },';
+ $js .= ' function() {';
+ $js .= ' return false;';
+ $js .= ' }';
+ $js .= ' );';
+ $js .= ' });';
+ $js .= '</script>';
+
+ $js = sprintf($js, $apikey, $login_url, $logout_url);
+
+ // Compress the bugger down a bit
+
+ $js = str_replace(' ', '', $js);
+
+ $action->raw(" $js"); // leading two spaces to make it line up
}
}
- // Note: this script needs to appear as close as possible to </body>
+ /**
+ * Add in an additional Facebook Connect script that's supposed to
+ * appear as close as possible to </body>
+ *
+ * @param Action $action the current action
+ *
+ * @return void
+ *
+ */
function onEndShowFooter($action)
{
if ($this->reqFbScripts($action)) {
- $action->script('http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php');
+ $action->script('http://static.ak.connect.facebook.com' .
+ '/js/api_lib/v0.4/FeatureLoader.js.php');
}
}
+ /**
+ * Output Facebook Connect specific CSS link
+ *
+ * @param Action $action the current action
+ *
+ * @return void
+ *
+ */
+
function onEndShowStatusNetStyles($action)
{
-
if ($this->reqFbScripts($action)) {
- $action->cssLink('plugins/FBConnect/FBConnectPlugin.css');
+ $action->cssLink('plugins/Facebook/FBConnect.css');
}
}
@@ -161,12 +271,13 @@ class FBConnectPlugin extends Plugin
* want to output FB namespace, scripts, CSS, etc. on the pages that
* really need them.
*
- * @param Action the action in question
+ * @param Action $action the current action
*
* @return boolean true
*/
- function reqFbScripts($action) {
+ function reqFbScripts($action)
+ {
// If you're logged in w/FB Connect, you always need the FB stuff
@@ -228,10 +339,19 @@ class FBConnectPlugin extends Plugin
return null;
}
+ /**
+ * Add in a Facebook Connect avatar to the primary nav menu
+ *
+ * @param Action $action the current action
+ *
+ * @return void
+ *
+ */
+
function onStartPrimaryNav($action)
{
-
$user = common_current_user();
+
$connect = 'FBConnectSettings';
if (common_config('xmpp', 'enabled')) {
$connect = 'imsettings';
@@ -262,78 +382,31 @@ class FBConnectPlugin extends Plugin
'alt' => 'Facebook Connect User',
'width' => '16'), '');
- $iconurl = common_path('plugins/FBConnect/fbfavicon.ico');
+ $iconurl = common_path('plugins/Facebook/fbfavicon.ico');
$action->element('img', array('id' => 'fb_favicon',
'src' => $iconurl));
$action->elementEnd('li');
}
+ }
- $action->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
- _('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
- $action->menuItem(common_local_url('profilesettings'),
- _('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account');
- $action->menuItem(common_local_url($connect),
- _('Connect'), _('Connect to services'), false, 'nav_connect');
- if (common_config('invite', 'enabled')) {
- $action->menuItem(common_local_url('invite'),
- _('Invite'),
- sprintf(_('Invite friends and colleagues to join you on %s'),
- common_config('site', 'name')),
- false, 'nav_invitecontact');
- }
-
- // Need to override the Logout link to make it do FB stuff
- if (!empty($fbuid)) {
-
- $logout_url = common_local_url('logout');
- $title = _('Logout from the site');
- $text = _('Logout');
-
- $html = sprintf('<li id="nav_logout"><a href="#" title="%s" ' .
- 'onclick="FB.Connect.logoutAndRedirect(\'%s\');">%s</a></li>',
- $title, $logout_url, $text);
-
- $action->raw($html);
-
- } else {
- $action->menuItem(common_local_url('logout'),
- _('Logout'), _('Logout from the site'), false, 'nav_logout');
- }
- }
- else {
- if (!common_config('site', 'openidonly')) {
- if (!common_config('site', 'closed')) {
- $action->menuItem(common_local_url('register'),
- _('Register'), _('Create an account'), false, 'nav_register');
- }
- $action->menuItem(common_local_url('login'),
- _('Login'), _('Login to the site'), false, 'nav_login');
- } else {
- $this->menuItem(common_local_url('openidlogin'),
- _('OpenID'), _('Login with OpenID'), false, 'nav_openid');
- }
- }
-
- $action->menuItem(common_local_url('doc', array('title' => 'help')),
- _('Help'), _('Help me!'), false, 'nav_help');
- if ($user || !common_config('site', 'private')) {
- $action->menuItem(common_local_url('peoplesearch'),
- _('Search'), _('Search for people or text'), false, 'nav_search');
- }
-
- // We are replacing the primary nav entirely; give other
- // plugins a chance to handle it here.
-
- Event::handle('EndPrimaryNav', array($action));
-
- return false;
+ return true;
}
+ /**
+ * Alter the local nav menu to have a Facebook Connect login and
+ * settings pages
+ *
+ * @param Action $action the current action
+ *
+ * @return void
+ *
+ */
+
function onStartShowLocalNavBlock($action)
{
- $action_name = get_class($action);
+ $action_name = get_class($action);
$login_actions = array('LoginAction', 'RegisterAction',
'OpenidloginAction', 'FBConnectLoginAction');
@@ -356,8 +429,16 @@ class FBConnectPlugin extends Plugin
return true;
}
+ /**
+ * Have the logout process do some Facebook Connect cookie cleanup
+ *
+ * @param Action $action the current action
+ *
+ * @return void
+ */
+
function onStartLogout($action)
-{
+ {
$action->logout();
$fbuid = $this->loggedIn();
@@ -375,9 +456,16 @@ class FBConnectPlugin extends Plugin
return true;
}
+ /**
+ * Get the URL of the user's Facebook avatar
+ *
+ * @param int $fbuid the Facebook user ID
+ *
+ * @return string $url the url for the user's Facebook avatar
+ */
+
function getProfilePicURL($fbuid)
{
-
$facebook = getFacebook();
$url = null;
@@ -396,8 +484,70 @@ class FBConnectPlugin extends Plugin
"Facebook client failure requesting profile pic!");
}
- return $url;
+ return $url;
+ }
+
+ /**
+ * Add a Facebook queue item for each notice
+ *
+ * @param Notice $notice the notice
+ * @param array &$transports the list of transports (queues)
+ *
+ * @return boolean hook return
+ */
+ function onStartEnqueueNotice($notice, &$transports)
+ {
+ array_push($transports, 'facebook');
+ return true;
+ }
+
+ /**
+ * broadcast the message when not using queuehandler
+ *
+ * @param Notice &$notice the notice
+ * @param array $queue destination queue
+ *
+ * @return boolean hook return
+ */
+
+ function onUnqueueHandleNotice(&$notice, $queue)
+ {
+ if (($queue == 'facebook') && ($this->_isLocal($notice))) {
+ facebookBroadcastNotice($notice);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Determine whether the notice was locally created
+ *
+ * @param Notice $notice the notice
+ *
+ * @return boolean locality
+ */
+
+ function _isLocal($notice)
+ {
+ return ($notice->is_local == Notice::LOCAL_PUBLIC ||
+ $notice->is_local == Notice::LOCAL_NONPUBLIC);
+ }
+
+ /**
+ * Add Facebook queuehandler to the list of daemons to start
+ *
+ * @param array $daemons the list fo daemons to run
+ *
+ * @return boolean hook return
+ *
+ */
+
+ function onGetValidDaemons($daemons)
+ {
+ array_push($daemons, INSTALLDIR .
+ '/plugins/Facebook/facebookqueuehandler.php');
+ return true;
}
}
diff --git a/plugins/Facebook/README b/plugins/Facebook/README
new file mode 100644
index 000000000..bf2f4a180
--- /dev/null
+++ b/plugins/Facebook/README
@@ -0,0 +1,129 @@
+This plugin allows you to use Facebook Connect with StatusNet, provides a
+Facebook application for your users, and allows them to update their
+Facebook statuses from StatusNet.
+
+Facebook Connect
+----------------
+
+Facebook connect allows users to register and login using nothing but their
+Facebook credentials. With Facebook Connect, your users can:
+
+- Authenticate (register/login/logout -- works similar to OpenID)
+- Associate an existing StatusNet account with a Facebook account
+- Disconnect a Facebook account from a StatusNet account
+
+Built-in Facebook Application
+-----------------------------
+
+The plugin also installs a StatusNet Facebook application that allows your
+users to automatically update their Facebook statuses with their latest
+notices, invite their friends to use the app (and thus your site), view
+their notice timelines, and post notices -- all from within Facebook. The
+application is built into the StatusNet Facebook plugin and runs on your
+host.
+
+Quick setup instructions*
+-------------------------
+
+Install the Facebook Developer application on Facebook:
+
+ http://www.facebook.com/developers/
+
+Use it to create a new application and generate an API key and secret. Add a
+Facebook app section of your config.php and copy in the key and secret,
+e.g.:
+
+ // Config section for the built-in Facebook application
+ $config['facebook']['apikey'] = 'APIKEY';
+ $config['facebook']['secret'] = 'SECRET';
+
+In Facebook's application editor, specify the following URLs for your app:
+
+- Canvas Callback URL : http://example.net/mublog/facebook/app/
+- Post-Remove Callback URL: http://example.net/mublog/facebook/app/remove
+- Post-Add Redirect URL : http://apps.facebook.com/yourapp/
+- Canvas Page URL : http://apps.facebook.com/yourapp/
+- Connect URL : http://example.net/mublog/
+
+ *** ATTENTION ***
+ These URLs have changed slightly since StatusNet version 0.8.1,
+ so if you have been using the Facebook app previously, you will
+ need to update your configuration!
+
+Replace "example.net" with your host's URL, "mublog" with the path to your
+StatusNet installation, and 'yourapp' with the name of the Facebook
+application you created. (If you don't have "Fancy URLs" on, you'll need to
+change http://example.net/mublog/ to http://example.net/mublog/index.php/).
+
+Additionally, Choose "Web" for Application type in the Advanced tab. In the
+"Canvas setting" section, choose the "FBML" for Render Method, "Smart Size"
+for IFrame size, and "Full width (760px)" for Canvas Width. Everything else
+can be left with default values.
+
+* NOTE: For more under-the-hood detailed instructions about setting up a
+ Facebook application and getting an API key, check out the
+ following pages on the Facebook wiki:
+
+ http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site
+ http://wiki.developers.facebook.com/index.php/Creating_your_first_application
+
+Finally you must activate the plugin by adding the following line to your
+config.php:
+
+ addPlugin('Facebook');
+
+Testing It Out
+--------------
+
+If the Facebook plugin is enabled and working, there will be a new Facebook
+Connect Settings tab under each user's Connect menu. Users can connect and
+disconnect* to their Facebook accounts from it.
+
+To try out the plugin, fire up your browser and connect to:
+
+ http://SITE/PATH_TO_STATUSNET/main/facebooklogin
+
+or, if you do not have fancy URLs turned on:
+
+ http://SITE/PATH_TO_STATUSNET/index.php/main/facebooklogin
+
+You should see a page with a blue button that says: "Connect with Facebook"
+and you should be able to login or register.
+
+From within Facebook, you should also be able to get to the Facebook
+application, and run it by hitting the link you specified above when
+configuring it:
+
+ http://apps.facebook.com/yourapp/
+
+That link should be present you with a login screen. After logging in to
+the app, you are given the option to update their Facebook status via
+StatusNet.
+
+* Note: Before a user can disconnect from Facebook, she must set a normal
+ StatusNet password. Otherwise, she might not be able to login in to her
+ account in the future. This is usually only required for users who have
+ used Facebook Connect to register their StatusNet account, and therefore
+ haven't already set a local password.
+
+Offline Queue Handling
+----------------------
+
+For larger sites needing better performance it's possible to enable queuing
+and have users' notices posted to Facebook via a separate "offline"
+FacebookQueueHandler (facebookqueuhandler.php in the Facebook plugin
+directory), which will be started by the plugin along with their other
+daemons when you run scripts/startdaemons.sh. See the StatusNet README for
+more about queuing and daemons.
+
+TODO
+----
+
+- Invite Facebook friends to use your StatusNet installation via Facebook
+ Connect
+- Auto-subscribe Facebook friends already using StatusNet
+- Share StatusNet favorite notices to your Facebook stream
+- Allow users to update their Facebook statuses once they have authenticated
+ with Facebook Connect (no need for them to use the Facebook app if they
+ don't want to).
+- Re-design the whole thing to support multiple instances of StatusNet
diff --git a/extlib/facebook/facebook.php b/plugins/Facebook/facebook/facebook.php
index 016e8e8e0..016e8e8e0 100644
--- a/extlib/facebook/facebook.php
+++ b/plugins/Facebook/facebook/facebook.php
diff --git a/extlib/facebook/facebook_desktop.php b/plugins/Facebook/facebook/facebook_desktop.php
index e79a2ca34..e79a2ca34 100644
--- a/extlib/facebook/facebook_desktop.php
+++ b/plugins/Facebook/facebook/facebook_desktop.php
diff --git a/extlib/facebook/facebookapi_php5_restlib.php b/plugins/Facebook/facebook/facebookapi_php5_restlib.php
index 55cb7fb86..55cb7fb86 100755
--- a/extlib/facebook/facebookapi_php5_restlib.php
+++ b/plugins/Facebook/facebook/facebookapi_php5_restlib.php
diff --git a/extlib/facebook/jsonwrapper/JSON/JSON.php b/plugins/Facebook/facebook/jsonwrapper/JSON/JSON.php
index 0cddbddb4..0cddbddb4 100644
--- a/extlib/facebook/jsonwrapper/JSON/JSON.php
+++ b/plugins/Facebook/facebook/jsonwrapper/JSON/JSON.php
diff --git a/extlib/facebook/jsonwrapper/JSON/LICENSE b/plugins/Facebook/facebook/jsonwrapper/JSON/LICENSE
index 4ae6bef55..4ae6bef55 100644
--- a/extlib/facebook/jsonwrapper/JSON/LICENSE
+++ b/plugins/Facebook/facebook/jsonwrapper/JSON/LICENSE
diff --git a/extlib/facebook/jsonwrapper/jsonwrapper.php b/plugins/Facebook/facebook/jsonwrapper/jsonwrapper.php
index 29509deba..29509deba 100644
--- a/extlib/facebook/jsonwrapper/jsonwrapper.php
+++ b/plugins/Facebook/facebook/jsonwrapper/jsonwrapper.php
diff --git a/extlib/facebook/jsonwrapper/jsonwrapper_inner.php b/plugins/Facebook/facebook/jsonwrapper/jsonwrapper_inner.php
index 36a3f2863..36a3f2863 100644
--- a/extlib/facebook/jsonwrapper/jsonwrapper_inner.php
+++ b/plugins/Facebook/facebook/jsonwrapper/jsonwrapper_inner.php
diff --git a/lib/facebookaction.php b/plugins/Facebook/facebookaction.php
index 5cbb9be53..a10fdf90d 100644
--- a/lib/facebookaction.php
+++ b/plugins/Facebook/facebookaction.php
@@ -2,7 +2,7 @@
/**
* StatusNet, the distributed open-source microblogging tool
*
- * Low-level generator for HTML
+ * Base Facebook Action
*
* PHP version 5
*
@@ -22,19 +22,17 @@
* @category Faceboook
* @package StatusNet
* @author Zach Copley <zach@status.net>
- * @copyright 2008 StatusNet, Inc.
+ * @copyright 2008-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') && !defined('LACONICA'))
-{
+if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/facebookutil.php';
-require_once INSTALLDIR.'/lib/noticeform.php';
-
+require_once INSTALLDIR . '/plugins/Facebook/facebookutil.php';
+require_once INSTALLDIR . '/lib/noticeform.php';
class FacebookAction extends Action
{
@@ -46,17 +44,6 @@ class FacebookAction extends Action
var $app_uri = null;
var $app_name = null;
- /**
- * Constructor
- *
- * Just wraps the HTMLOutputter constructor.
- *
- * @param string $output URI to output to, default = stdout
- * @param boolean $indent Whether to indent output, default true
- *
- * @see XMLOutputter::__construct
- * @see HTMLOutputter::__construct
- */
function __construct($output='php://output', $indent=true, $facebook=null, $flink=null)
{
parent::__construct($output, $indent);
@@ -96,8 +83,8 @@ class FacebookAction extends Action
function showStylesheets()
{
$this->cssLink('css/display.css', 'base');
- $this->cssLink('css/display.css',null,'screen, projection, tv');
- $this->cssLink('css/facebookapp.css', 'base');
+ $this->cssLink('css/display.css', null, 'screen, projection, tv');
+ $this->cssLink('plugins/Facebook/facebookapp.css');
}
function showScripts()
@@ -108,10 +95,8 @@ class FacebookAction extends Action
/**
* Start an Facebook ready HTML document
*
- * For Facebook we don't want to actually output any headers,
- * DTD info, etc. Just Stylesheet and JavaScript links.
- *
- * If $type isn't specified, will attempt to do content negotiation.
+ * For Facebook we don't want to actually output any headers,
+ * DTD info, etc. Just Stylesheet and JavaScript links.
*
* @param string $type MIME type to use; default is to do negotation.
*
@@ -140,8 +125,6 @@ class FacebookAction extends Action
/**
* Show notice form.
*
- * MAY overload if no notice form needed... or direct message box????
- *
* @return nothing
*/
function showNoticeForm()
@@ -158,10 +141,6 @@ class FacebookAction extends Action
$this->elementEnd('div');
}
- function showAside()
- {
- }
-
function showHead($error, $success)
{
@@ -181,7 +160,6 @@ class FacebookAction extends Action
}
-
// Make this into a widget later
function showLocalNav()
{
@@ -216,8 +194,6 @@ class FacebookAction extends Action
/**
* Show header of the page.
*
- * Calls template methods
- *
* @return nothing
*/
function showHeader()
@@ -241,7 +217,6 @@ class FacebookAction extends Action
$this->endHTML();
}
-
function showInstructions()
{
@@ -257,22 +232,16 @@ class FacebookAction extends Action
$this->elementStart('dd');
$this->elementStart('p');
$this->text(sprintf($loginmsg_part1, common_config('site', 'name')));
- if (!common_config('site', 'openidonly')) {
- $this->element('a',
- array('href' => common_local_url('register')), _('Register'));
- } else {
- $this->element('a',
- array('href' => common_local_url('openidlogin')), _('Register'));
- }
+ $this->element('a',
+ array('href' => common_local_url('register')), _('Register'));
$this->text($loginmsg_part2);
- $this->elementEnd('p');
+ $this->elementEnd('p');
$this->elementEnd('dd');
$this->elementEnd('dl');
$this->elementEnd('div');
}
-
function showLoginForm($msg = null)
{
@@ -304,7 +273,7 @@ class FacebookAction extends Action
$this->elementEnd('ul');
$this->submit('submit', _('Login'));
- $this->elementEnd('fieldset');
+ $this->elementEnd('fieldset');
$this->elementEnd('form');
$this->elementStart('p');
@@ -317,14 +286,13 @@ class FacebookAction extends Action
}
-
function updateProfileBox($notice)
{
// Need to include inline CSS for styling the Profile box
- $app_props = $this->facebook->api_client->Admin_getAppProperties(array('icon_url'));
- $icon_url = $app_props['icon_url'];
+ $app_props = $this->facebook->api_client->Admin_getAppProperties(array('icon_url'));
+ $icon_url = $app_props['icon_url'];
$style = '<style>
.entry-title *,
@@ -399,7 +367,6 @@ class FacebookAction extends Action
$this->xw->openURI('php://output');
}
-
/**
* Generate pagination links
*
@@ -458,8 +425,9 @@ class FacebookAction extends Action
} else {
$content_shortened = common_shorten_links($content);
- if (mb_strlen($content_shortened) > 140) {
- $this->showPage(_('That\'s too long. Max notice size is 140 chars.'));
+ if (Notice::contentTooLong($content_shortened)) {
+ $this->showPage(sprintf(_('That\'s too long. Max notice size is %d chars.'),
+ Notice::maxContent()));
return;
}
}
@@ -478,11 +446,11 @@ class FacebookAction extends Action
$replyto = $this->trimmed('inreplyto');
- $notice = Notice::saveNew($user->id, $content,
- 'web', 1, ($replyto == 'false') ? null : $replyto);
-
- if (is_string($notice)) {
- $this->showPage($notice);
+ try {
+ $notice = Notice::saveNew($user->id, $content,
+ 'web', 1, ($replyto == 'false') ? null : $replyto);
+ } catch (Exception $e) {
+ $this->showPage($e->getMessage());
return;
}
diff --git a/theme/base/css/facebookapp.css b/plugins/Facebook/facebookapp.css
index e6b1c9ee5..8cd06f78a 100644
--- a/theme/base/css/facebookapp.css
+++ b/plugins/Facebook/facebookapp.css
@@ -5,8 +5,8 @@ font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
#wrap {
background-color:#F0F2F5;
-padding-left:18px;
-padding-right:18px;
+padding-left:1.795%;
+padding-right:1.795%;
width:auto;
}
@@ -15,8 +15,16 @@ h1,h2,h3,h4,h5,h6 {
color:#000;
}
+#header {
+width:131%;
+}
+
#content {
-width:95%;
+width:92.7%;
+}
+
+#aside_primary {
+display:none;
}
#site_nav_local_views a {
@@ -26,6 +34,16 @@ background-color:#D0DFE7;
background-color:#FAFBFC;
}
+#form_notice .form_note + label,
+#form_notice #notice_data-attach {
+display:none;
+}
+
+#form_notice #notice_action-submit {
+height:47px !important;
+}
+
+
span.facebook-button {
border: 2px solid #aaa;
padding: 3px;
diff --git a/actions/facebookhome.php b/plugins/Facebook/facebookhome.php
index 70f205205..91c0cc6b8 100644
--- a/actions/facebookhome.php
+++ b/plugins/Facebook/facebookhome.php
@@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
-require_once INSTALLDIR.'/lib/facebookaction.php';
+require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookhomeAction extends FacebookAction
{
diff --git a/actions/facebookinvite.php b/plugins/Facebook/facebookinvite.php
index 6dfc9d688..3380b4c85 100644
--- a/actions/facebookinvite.php
+++ b/plugins/Facebook/facebookinvite.php
@@ -21,7 +21,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once(INSTALLDIR.'/lib/facebookaction.php');
+require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookinviteAction extends FacebookAction
{
@@ -105,6 +105,7 @@ class FacebookinviteAction extends FacebookAction
$multi_params = array('showborder' => 'false');
$multi_params['actiontext'] = $actiontext;
$multi_params['bypass'] = 'cancel';
+ $multi_params['cols'] = 4;
// Get a list of users who are already using the app for exclusion
$exclude_ids = $this->facebook->api_client->friends_getAppUsers();
diff --git a/actions/facebooklogin.php b/plugins/Facebook/facebooklogin.php
index 8ac2477ab..f77aecca3 100644
--- a/actions/facebooklogin.php
+++ b/plugins/Facebook/facebooklogin.php
@@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
-require_once(INSTALLDIR.'/lib/facebookaction.php');
+require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookinviteAction extends FacebookAction
{
@@ -27,25 +29,24 @@ class FacebookinviteAction extends FacebookAction
function handle($args)
{
parent::handle($args);
-
+
$this->error = $error;
-
+
if ($this->flink) {
if (!$this->facebook->api_client->users_hasAppPermission('publish_stream') &&
$this->facebook->api_client->data_getUserPreference(
FACEBOOK_PROMPTED_UPDATE_PREF) == 'true') {
-
+
echo '<h1>REDIRECT TO HOME</h1>';
}
- } else {
+ } else {
$this->showPage();
}
}
-
function showContent()
{
-
+
// If the user has opted not to initially allow the app to have
// Facebook status update permission, store that preference. Only
// promt the user the first time she uses the app
@@ -68,34 +69,31 @@ class FacebookinviteAction extends FacebookAction
return;
}
}
-
+
} else {
$this->showLoginForm();
}
-
+
}
function showSuccessContent()
{
-
-
}
function showFormContent()
{
-
}
-
- function title()
+
+ function title()
{
return sprintf(_('Login'));
}
-
- function redirectHome()
+
+ function redirectHome()
{
-
+
}
}
diff --git a/scripts/facebookqueuehandler.php b/plugins/Facebook/facebookqueuehandler.php
index e13ac4e85..e4ae7d4ee 100755
--- a/scripts/facebookqueuehandler.php
+++ b/plugins/Facebook/facebookqueuehandler.php
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
$shortoptions = 'i::';
$longoptions = array('id::');
@@ -30,9 +30,8 @@ Daemon script for pushing new notices to Facebook.
END_OF_FACEBOOK_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
-
-require_once INSTALLDIR . '/lib/facebookutil.php';
+require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/plugins/Facebook/facebookutil.php';
require_once INSTALLDIR . '/lib/queuehandler.php';
class FacebookQueueHandler extends QueueHandler
diff --git a/actions/facebookremove.php b/plugins/Facebook/facebookremove.php
index ae231c0fb..8531a8e6e 100644
--- a/actions/facebookremove.php
+++ b/plugins/Facebook/facebookremove.php
@@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
-require_once INSTALLDIR.'/lib/facebookaction.php';
+require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookremoveAction extends FacebookAction
{
diff --git a/actions/facebooksettings.php b/plugins/Facebook/facebooksettings.php
index b2b1d6807..2f182e368 100644
--- a/actions/facebooksettings.php
+++ b/plugins/Facebook/facebooksettings.php
@@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
-require_once INSTALLDIR.'/lib/facebookaction.php';
+require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebooksettingsAction extends FacebookAction
{
@@ -91,16 +93,16 @@ class FacebooksettingsAction extends FacebookAction
'id' => 'facebook_settings'));
$this->elementStart('ul', 'form_data');
-
+
$this->elementStart('li');
-
+
$this->checkbox('noticesync', _('Automatically update my Facebook status with my notices.'),
($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND) : true);
$this->elementEnd('li');
-
+
$this->elementStart('li');
-
+
$this->checkbox('replysync', _('Send "@" replies to Facebook.'),
($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
@@ -115,15 +117,15 @@ class FacebooksettingsAction extends FacebookAction
_('A string to prefix notices with.'));
$this->elementEnd('li');
-
+
$this->elementStart('li');
-
+
$this->submit('save', _('Save'));
$this->elementEnd('li');
$this->elementEnd('ul');
-
+
$this->elementEnd('form');
} else {
@@ -148,8 +150,8 @@ class FacebooksettingsAction extends FacebookAction
}
}
-
- function title()
+
+ function title()
{
return _('Sync preferences');
}
diff --git a/lib/facebookutil.php b/plugins/Facebook/facebookutil.php
index c29576b64..6f50c173a 100644
--- a/lib/facebookutil.php
+++ b/plugins/Facebook/facebookutil.php
@@ -17,9 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-require_once INSTALLDIR.'/extlib/facebook/facebook.php';
-require_once INSTALLDIR.'/lib/facebookaction.php';
-require_once INSTALLDIR.'/lib/noticelist.php';
+require_once INSTALLDIR . '/plugins/Facebook/facebook/facebook.php';
+require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
+require_once INSTALLDIR . '/lib/noticelist.php';
define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2
define("FACEBOOK_NOTICE_PREFIX", 1);
@@ -109,7 +109,6 @@ function facebookBroadcastNotice($notice)
$can_update = $facebook->api_client->users_hasAppPermission('status_update',
$fbuid);
-
if (!empty($attachments) && $can_publish == 1) {
$fbattachment = format_attachments($attachments);
$facebook->api_client->stream_publish($status, $fbattachment,
@@ -180,7 +179,11 @@ function format_attachments($attachments)
foreach($attachments as $attachment)
{
- $fbmedia = get_fbmedia_for_attachment($attachment);
+ if($enclosure = $attachment->getEnclosure()){
+ $fbmedia = get_fbmedia_for_attachment($enclosure);
+ }else{
+ $fbmedia = get_fbmedia_for_attachment($attachment);
+ }
if($fbmedia){
$fbattachment['media'][]=$fbmedia;
}else{
@@ -255,3 +258,38 @@ function remove_facebook_app($flink)
}
}
+
+/**
+ * Send a mail message to notify a user that her Facebook Application
+ * access has been removed.
+ *
+ * @param User $user user whose Facebook app link has been removed
+ *
+ * @return boolean success flag
+ */
+
+function mail_facebook_app_removed($user)
+{
+ common_init_locale($user->language);
+
+ $profile = $user->getProfile();
+
+ $site_name = common_config('site', 'name');
+
+ $subject = sprintf(
+ _('Your %1$s Facebook application access has been disabled.',
+ $site_name));
+
+ $body = sprintf(_("Hi, %1\$s. We're sorry to inform you that we are " .
+ 'unable to update your Facebook status from %2$s, and have disabled ' .
+ 'the Facebook application for your account. This may be because ' .
+ 'you have removed the Facebook application\'s authorization, or ' .
+ 'have deleted your Facebook account. You can re-enable the ' .
+ 'Facebook application and automatic status updating by ' .
+ "re-installing the %2\$s Facebook application.\n\nRegards,\n\n%2\$s"),
+ $user->nickname, $site_name);
+
+ common_init_locale();
+ return mail_to_user($user, $subject, $body);
+
+}
diff --git a/plugins/FBConnect/fbfavicon.ico b/plugins/Facebook/fbfavicon.ico
index c57c0342f..c57c0342f 100644
--- a/plugins/FBConnect/fbfavicon.ico
+++ b/plugins/Facebook/fbfavicon.ico
Binary files differ
diff --git a/plugins/GeonamesPlugin.php b/plugins/GeonamesPlugin.php
new file mode 100644
index 000000000..80ef44cc9
--- /dev/null
+++ b/plugins/GeonamesPlugin.php
@@ -0,0 +1,305 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to convert string locations to Geonames IDs and vice versa
+ *
+ * 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 Action
+ * @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);
+}
+
+/**
+ * Plugin to convert string locations to Geonames IDs and vice versa
+ *
+ * This handles most of the events that Location class emits. It uses
+ * the geonames.org Web service to convert names like 'Montreal, Quebec, Canada'
+ * into IDs and lat/lon pairs.
+ *
+ * @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 GeonamesPlugin extends Plugin
+{
+ const NAMESPACE = 1;
+
+ /**
+ * convert a name into a Location object
+ *
+ * @param string $name Name to convert
+ * @param string $language ISO code for anguage the name is in
+ * @param Location &$location Location object (may be null)
+ *
+ * @return boolean whether to continue (results in $location)
+ */
+
+ function onLocationFromName($name, $language, &$location)
+ {
+ $client = HTTPClient::start();
+
+ // 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);
+
+ if ($result->code == "200") {
+ $rj = json_decode($result->body);
+ if (count($rj->geonames) > 0) {
+ $n = $rj->geonames[0];
+
+ $location = new Location();
+
+ $location->lat = $n->lat;
+ $location->lon = $n->lng;
+ $location->names[$language] = $n->name;
+ $location->location_id = $n->geonameId;
+ $location->location_ns = self::NAMESPACE;
+
+ // handled, don't continue processing!
+ return false;
+ }
+ }
+
+ // Continue processing; we don't have the answer
+ return true;
+ }
+
+ /**
+ * convert an id into a Location object
+ *
+ * @param string $id Name to convert
+ * @param string $ns Name to convert
+ * @param string $language ISO code for language for results
+ * @param Location &$location Location object (may be null)
+ *
+ * @return boolean whether to continue (results in $location)
+ */
+
+ function onLocationFromId($id, $ns, $language, &$location)
+ {
+ if ($ns != self::NAMESPACE) {
+ // It's not one of our IDs... keep processing
+ return true;
+ }
+
+ $client = HTTPClient::start();
+
+ $str = http_build_query(array('geonameId' => $id,
+ 'lang' => $language));
+
+ $result = $client->get('http://ws.geonames.org/hierarchyJSON?'.$str);
+
+ if ($result->code == "200") {
+
+ $rj = json_decode($result->body);
+
+ if (count($rj->geonames) > 0) {
+
+ $parts = array();
+
+ foreach ($rj->geonames as $level) {
+ if (in_array($level->fcode, array('PCLI', 'ADM1', 'PPL'))) {
+ $parts[] = $level->name;
+ }
+ }
+
+ $last = $rj->geonames[count($rj->geonames)-1];
+
+ if (!in_array($level->fcode, array('PCLI', 'ADM1', 'PPL'))) {
+ $parts[] = $last->name;
+ }
+
+ $location = new Location();
+
+ $location->location_id = $last->geonameId;
+ $location->location_ns = self::NAMESPACE;
+ $location->lat = $last->lat;
+ $location->lon = $last->lng;
+ $location->names[$language] = implode(', ', array_reverse($parts));
+ }
+ }
+
+ // We're responsible for this NAMESPACE; nobody else
+ // can resolve it
+
+ return false;
+ }
+
+ /**
+ * convert a lat/lon pair into a Location object
+ *
+ * Given a lat/lon, we try to find a Location that's around
+ * it or nearby. We prefer populated places (cities, towns, villages).
+ *
+ * @param string $lat Latitude
+ * @param string $lon Longitude
+ * @param string $language ISO code for language for results
+ * @param Location &$location Location object (may be null)
+ *
+ * @return boolean whether to continue (results in $location)
+ */
+
+ function onLocationFromLatLon($lat, $lon, $language, &$location)
+ {
+ $client = HTTPClient::start();
+
+ $str = http_build_query(array('lat' => $lat,
+ 'lng' => $lon,
+ 'lang' => $language));
+
+ $result =
+ $client->get('http://ws.geonames.org/findNearbyPlaceNameJSON?'.$str);
+
+ if ($result->code == "200") {
+
+ $rj = json_decode($result->body);
+
+ if (count($rj->geonames) > 0) {
+
+ $n = $rj->geonames[0];
+
+ $parts = array();
+
+ $location = new Location();
+
+ $parts[] = $n->name;
+
+ if (!empty($n->adminName1)) {
+ $parts[] = $n->adminName1;
+ }
+
+ if (!empty($n->countryName)) {
+ $parts[] = $n->countryName;
+ }
+
+ $location->location_id = $n->geonameId;
+ $location->location_ns = self::NAMESPACE;
+ $location->lat = $lat;
+ $location->lon = $lon;
+
+ $location->names[$language] = implode(', ', $parts);
+
+ // Success! We handled it, so no further processing
+
+ return false;
+ }
+ }
+
+ // For some reason we don't know, so pass.
+
+ return true;
+ }
+
+ /**
+ * Human-readable name for a location
+ *
+ * Given a location, we try to retrieve a human-readable name
+ * in the target language.
+ *
+ * @param Location $location Location to get the name for
+ * @param string $language ISO code for language to find name in
+ * @param string &$name Place to put the name
+ *
+ * @return boolean whether to continue
+ */
+
+ function onLocationNameLanguage($location, $language, &$name)
+ {
+ if ($location->location_ns != self::NAMESPACE) {
+ // It's not one of our IDs... keep processing
+ return true;
+ }
+
+ $client = HTTPClient::start();
+
+ $str = http_build_query(array('geonameId' => $id,
+ 'lang' => $language));
+
+ $result = $client->get('http://ws.geonames.org/hierarchyJSON?'.$str);
+
+ if ($result->code == "200") {
+
+ $rj = json_decode($result->body);
+
+ if (count($rj->geonames) > 0) {
+
+ $parts = array();
+
+ foreach ($rj->geonames as $level) {
+ if (in_array($level->fcode, array('PCLI', 'ADM1', 'PPL'))) {
+ $parts[] = $level->name;
+ }
+ }
+
+ $last = $rj->geonames[count($rj->geonames)-1];
+
+ if (!in_array($level->fcode, array('PCLI', 'ADM1', 'PPL'))) {
+ $parts[] = $last->name;
+ }
+
+ if (count($parts)) {
+ $name = implode(', ', array_reverse($parts));
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Human-readable name for a location
+ *
+ * Given a location, we try to retrieve a geonames.org URL.
+ *
+ * @param Location $location Location to get the url for
+ * @param string &$url Place to put the url
+ *
+ * @return boolean whether to continue
+ */
+
+ function onLocationUrl($location, &$url)
+ {
+ if ($location->location_ns != self::NAMESPACE) {
+ // It's not one of our IDs... keep processing
+ return true;
+ }
+
+ $url = 'http://www.geonames.org/' . $location->location_id;
+
+ // it's been filled, so don't process further.
+ return false;
+ }
+}
diff --git a/plugins/LilUrl/LilUrlPlugin.php b/plugins/LilUrl/LilUrlPlugin.php
new file mode 100644
index 000000000..7665b6c1e
--- /dev/null
+++ b/plugins/LilUrl/LilUrlPlugin.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://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/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once(INSTALLDIR.'/lib/Shorturl_api.php');
+
+class LilUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->registerUrlShortener(
+ 'ur1.ca',
+ array('freeService'=>true),
+ array('LilUrl',array('http://ur1.ca/'))
+ );
+ }
+}
+
+class LilUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $data['longurl'] = $url;
+ $response = $this->http_post($data);
+ if (!$response) return $url;
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $x = $y->body->p[0]->a->attributes();
+ if (isset($x['href'])) return $x['href'];
+ return $url;
+ }
+}
diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php
new file mode 100644
index 000000000..81e3ed9c4
--- /dev/null
+++ b/plugins/OpenID/OpenIDPlugin.php
@@ -0,0 +1,244 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * 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 Plugin
+ * @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);
+}
+
+/**
+ * Plugin for OpenID authentication and identity
+ *
+ * This class enables consumer support for OpenID, the distributed authentication
+ * and identity system.
+ *
+ * @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/
+ * @link http://openid.net/
+ */
+
+class OpenIDPlugin extends Plugin
+{
+ /**
+ * Initializer for the plugin.
+ */
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Add OpenID-related paths to the router table
+ *
+ * Hook for RouterInitialized event.
+ *
+ * @return boolean hook return
+ */
+
+ function onRouterInitialized($m)
+ {
+ $m->connect('main/openid', array('action' => 'openidlogin'));
+ $m->connect('settings/openid', array('action' => 'openidsettings'));
+ $m->connect('xrds', array('action' => 'publicxrds'));
+ $m->connect('index.php?action=finishopenidlogin', array('action' => 'finishopenidlogin'));
+ $m->connect('index.php?action=finishaddopenid', array('action' => 'finishaddopenid'));
+
+ return true;
+ }
+
+ function onEndLoginGroupNav(&$action)
+ {
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('openidlogin'),
+ _('OpenID'),
+ _('Login or register with OpenID'),
+ $action_name === 'openidlogin');
+
+ return true;
+ }
+
+ function onEndAccountSettingsNav(&$action)
+ {
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('openidsettings'),
+ _('OpenID'),
+ _('Add or remove OpenIDs'),
+ $action_name === 'openidsettings');
+
+ return true;
+ }
+
+ function onAutoload($cls)
+ {
+ switch ($cls)
+ {
+ case 'OpenidloginAction':
+ case 'FinishopenidloginAction':
+ case 'FinishaddopenidAction':
+ case 'XrdsAction':
+ case 'PublicxrdsAction':
+ case 'OpenidsettingsAction':
+ require_once(INSTALLDIR.'/plugins/OpenID/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
+ return false;
+ case 'User_openid':
+ require_once(INSTALLDIR.'/plugins/OpenID/User_openid.php');
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onSensitiveAction($action, &$ssl)
+ {
+ switch ($action)
+ {
+ case 'finishopenidlogin':
+ case 'finishaddopenid':
+ $ssl = true;
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onLoginAction($action, &$login)
+ {
+ switch ($action)
+ {
+ case 'openidlogin':
+ case 'finishopenidlogin':
+ $login = true;
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * We include a <meta> element linking to the publicxrds page, for OpenID
+ * client-side authentication.
+ *
+ * @return void
+ */
+
+ function onEndShowHeadElements($action)
+ {
+ if ($action->trimmed('action') == 'public') {
+ // for client side of OpenID authentication
+ $action->element('meta', array('http-equiv' => 'X-XRDS-Location',
+ 'content' => common_local_url('publicxrds')));
+ }
+
+ return true;
+ }
+
+ /**
+ * Redirect to OpenID login if they have an OpenID
+ *
+ * @return boolean whether to continue
+ */
+
+ function onRedirectToLogin($action, $user)
+ {
+ if (!empty($user) && User_openid::hasOpenID($user->id)) {
+ common_redirect(common_local_url('openidlogin'), 303);
+ return false;
+ }
+ return true;
+ }
+
+ function onEndShowPageNotice($action)
+ {
+ $name = $action->trimmed('action');
+
+ switch ($name)
+ {
+ case 'register':
+ $instr = '(Have an [OpenID](http://openid.net/)? ' .
+ 'Try our [OpenID registration]'.
+ '(%%action.openidlogin%%)!)';
+ break;
+ case 'login':
+ $instr = '(Have an [OpenID](http://openid.net/)? ' .
+ 'Try our [OpenID login]'.
+ '(%%action.openidlogin%%)!)';
+ break;
+ default:
+ return true;
+ }
+
+ $output = common_markup_to_html($instr);
+ $action->raw($output);
+ return true;
+ }
+
+ function onStartLoadDoc(&$title, &$output)
+ {
+ if ($title == 'openid')
+ {
+ $filename = INSTALLDIR.'/plugins/OpenID/doc-src/openid';
+
+ $c = file_get_contents($filename);
+ $output = common_markup_to_html($c);
+ return false; // success!
+ }
+
+ return true;
+ }
+
+ function onEndLoadDoc($title, &$output)
+ {
+ if ($title == 'help')
+ {
+ $menuitem = '* [OpenID](%%doc.openid%%) - what OpenID is and how to use it with this service';
+
+ $output .= common_markup_to_html($menuitem);
+ }
+
+ return true;
+ }
+
+ function onCheckSchema() {
+ $schema = Schema::get();
+ $schema->ensureTable('user_openid',
+ array(new ColumnDef('canonical', 'varchar',
+ '255', false, 'PRI'),
+ new ColumnDef('display', 'varchar',
+ '255', false),
+ new ColumnDef('user_id', 'integer',
+ null, false, 'MUL'),
+ new ColumnDef('created', 'datetime',
+ null, false),
+ new ColumnDef('modified', 'timestamp')));
+ return true;
+ }
+}
diff --git a/classes/User_openid.php b/plugins/OpenID/User_openid.php
index f4fda1c72..338e0f6e9 100644
--- a/classes/User_openid.php
+++ b/plugins/OpenID/User_openid.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class User_openid extends Memcached_DataObject
+class User_openid extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -22,4 +22,15 @@ class User_openid extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+
+ static function hasOpenID($user_id)
+ {
+ $oid = new User_openid();
+
+ $oid->user_id = $user_id;
+
+ $cnt = $oid->find();
+
+ return ($cnt > 0);
+ }
}
diff --git a/doc-src/openid b/plugins/OpenID/doc-src/openid
index c741e3674..c741e3674 100644
--- a/doc-src/openid
+++ b/plugins/OpenID/doc-src/openid
diff --git a/actions/finishaddopenid.php b/plugins/OpenID/finishaddopenid.php
index b6de4f244..6e889205d 100644
--- a/actions/finishaddopenid.php
+++ b/plugins/OpenID/finishaddopenid.php
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/openid.php';
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
/**
* Complete adding an OpenID
diff --git a/actions/finishopenidlogin.php b/plugins/OpenID/finishopenidlogin.php
index 9ac036985..ff0b451d3 100644
--- a/actions/finishopenidlogin.php
+++ b/plugins/OpenID/finishopenidlogin.php
@@ -19,7 +19,7 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/openid.php');
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
class FinishopenidloginAction extends Action
{
@@ -30,9 +30,7 @@ class FinishopenidloginAction extends Action
function handle($args)
{
parent::handle($args);
- if (!common_config('openid', 'enabled')) {
- common_redirect(common_local_url('login'));
- } else if (common_is_real_login()) {
+ if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$token = $this->trimmed('token');
@@ -267,7 +265,7 @@ class FinishopenidloginAction extends Action
$fullname = '';
}
- if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) {
+ if (!empty($sreg['email']) && Validate::email($sreg['email'], common_config('email', 'check_domain'))) {
$email = $sreg['email'];
} else {
$email = '';
diff --git a/lib/openid.php b/plugins/OpenID/openid.php
index 7a2c46f00..b76497c28 100644
--- a/lib/openid.php
+++ b/plugins/OpenID/openid.php
@@ -19,7 +19,7 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/classes/User_openid.php');
+require_once(INSTALLDIR.'/plugins/OpenID/User_openid.php');
require_once('Auth/OpenID.php');
require_once('Auth/OpenID/Consumer.php');
@@ -241,7 +241,7 @@ function oid_update_user(&$user, &$sreg)
$orig_user = clone($user);
- if ($sreg['email'] && Validate::email($sreg['email'], true)) {
+ if ($sreg['email'] && Validate::email($sreg['email'], common_config('email', 'check_domain'))) {
$user->email = $sreg['email'];
}
diff --git a/actions/openidlogin.php b/plugins/OpenID/openidlogin.php
index 9b7deefb6..29e89234e 100644
--- a/actions/openidlogin.php
+++ b/plugins/OpenID/openidlogin.php
@@ -19,16 +19,14 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/openid.php');
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
class OpenidloginAction extends Action
{
function handle($args)
{
parent::handle($args);
- if (!common_config('openid', 'enabled')) {
- common_redirect(common_local_url('login'));
- } else if (common_is_real_login()) {
+ if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$openid_url = $this->trimmed('openid_url');
diff --git a/actions/openidsettings.php b/plugins/OpenID/openidsettings.php
index 30725fc1b..3ad46f5f5 100644
--- a/actions/openidsettings.php
+++ b/plugins/OpenID/openidsettings.php
@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
-require_once INSTALLDIR.'/lib/openid.php';
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
/**
* Settings for OpenID
@@ -88,12 +88,6 @@ class OpenidsettingsAction extends AccountSettingsAction
function showContent()
{
- if (!common_config('openid', 'enabled')) {
- $this->element('div', array('class' => 'error'),
- _('OpenID is not available.'));
- return;
- }
-
$user = common_current_user();
$this->elementStart('form', array('method' => 'post',
diff --git a/actions/publicxrds.php b/plugins/OpenID/publicxrds.php
index 209a10e3d..1b2b359ca 100644
--- a/actions/publicxrds.php
+++ b/plugins/OpenID/publicxrds.php
@@ -33,7 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/openid.php';
+require_once INSTALLDIR.'/plugins/OpenID/openid.php';
/**
* Public XRDS for OpenID
diff --git a/plugins/Orbited/OrbitedPlugin.php b/plugins/Orbited/OrbitedPlugin.php
new file mode 100644
index 000000000..ba87b266a
--- /dev/null
+++ b/plugins/Orbited/OrbitedPlugin.php
@@ -0,0 +1,154 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Plugin to do "real time" updates using Orbited + STOMP
+ *
+ * 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 Plugin
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2009 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/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/plugins/Realtime/RealtimePlugin.php';
+
+/**
+ * Plugin to do realtime updates using Orbited + STOMP
+ *
+ * This plugin pushes data to a STOMP server which is then served to the
+ * browser by the Orbited server.
+ *
+ * @category Plugin
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class OrbitedPlugin extends RealtimePlugin
+{
+ public $webserver = null;
+ public $webport = null;
+ public $channelbase = null;
+ public $stompserver = null;
+ public $stompport = null;
+ public $username = null;
+ public $password = null;
+ public $webuser = null;
+ public $webpass = null;
+
+ protected $con = null;
+
+ function onStartShowHeadElements($action)
+ {
+ // See http://orbited.org/wiki/Deployment#Cross-SubdomainDeployment
+ $action->element('script', null, ' document.domain = document.domain; ');
+ }
+
+ function _getScripts()
+ {
+ $scripts = parent::_getScripts();
+
+ $port = (is_null($this->webport)) ? 8000 : $this->webport;
+
+ $server = (is_null($this->webserver)) ? common_config('site', 'server') : $this->webserver;
+
+ $root = 'http://'.$server.(($port == 80) ? '':':'.$port);
+
+ $scripts[] = $root.'/static/Orbited.js';
+ $scripts[] = common_path('plugins/Orbited/orbitedextra.js');
+ $scripts[] = $root.'/static/protocols/stomp/stomp.js';
+ $scripts[] = common_path('plugins/Orbited/orbitedupdater.js');
+
+ return $scripts;
+ }
+
+ function _updateInitialize($timeline, $user_id)
+ {
+ $script = parent::_updateInitialize($timeline, $user_id);
+
+ $server = $this->_getStompServer();
+ $port = $this->_getStompPort();
+
+ return $script." OrbitedUpdater.init(\"$server\", $port, ".
+ "\"{$timeline}\", \"{$this->webuser}\", \"{$this->webpass}\");";
+ }
+
+ function _connect()
+ {
+ require_once(INSTALLDIR.'/extlib/Stomp.php');
+
+ $url = $this->_getStompUrl();
+
+ $this->con = new Stomp($url);
+
+ if ($this->con->connect($this->username, $this->password)) {
+ $this->log(LOG_INFO, "Connected.");
+ } else {
+ $this->log(LOG_ERR, 'Failed to connect to queue server');
+ throw new ServerException('Failed to connect to queue server');
+ }
+ }
+
+ function _publish($channel, $message)
+ {
+ $result = $this->con->send($channel,
+ json_encode($message));
+
+ return $result;
+ // TODO: parse and deal with result
+ }
+
+ function _disconnect()
+ {
+ $this->con->disconnect();
+ }
+
+ function _pathToChannel($path)
+ {
+ if (!empty($this->channelbase)) {
+ array_unshift($path, $this->channelbase);
+ }
+ return '/' . implode('/', $path);
+ }
+
+ function _getStompServer()
+ {
+ return (!is_null($this->stompserver)) ? $this->stompserver :
+ (!is_null($this->webserver)) ? $this->webserver :
+ common_config('site', 'server');
+ }
+
+ function _getStompPort()
+ {
+ return (!is_null($this->stompport)) ? $this->stompport : 61613;
+ }
+
+ function _getStompUrl()
+ {
+ $server = $this->_getStompServer();
+ $port = $this->_getStompPort();
+ return "tcp://$server:$port/";
+ }
+}
diff --git a/plugins/Orbited/orbitedextra.js b/plugins/Orbited/orbitedextra.js
new file mode 100644
index 000000000..47e5c0c80
--- /dev/null
+++ b/plugins/Orbited/orbitedextra.js
@@ -0,0 +1,2 @@
+TCPSocket = Orbited.TCPSocket;
+
diff --git a/plugins/Orbited/orbitedupdater.js b/plugins/Orbited/orbitedupdater.js
new file mode 100644
index 000000000..8c5ab3b73
--- /dev/null
+++ b/plugins/Orbited/orbitedupdater.js
@@ -0,0 +1,24 @@
+// Update the local timeline from a Orbited server
+
+var OrbitedUpdater = function()
+{
+ return {
+
+ init: function(server, port, timeline, username, password)
+ {
+ // set up stomp client.
+ stomp = new STOMPClient();
+
+ stomp.onmessageframe = function(frame) {
+ RealtimeUpdate.receive(JSON.parse(frame.body));
+ };
+
+ stomp.onconnectedframe = function() {
+ stomp.subscribe(timeline);
+ }
+
+ stomp.connect(server, port, username, password);
+ }
+ }
+}();
+
diff --git a/plugins/PtitUrl/PtitUrlPlugin.php b/plugins/PtitUrl/PtitUrlPlugin.php
new file mode 100644
index 000000000..f00d3e2f2
--- /dev/null
+++ b/plugins/PtitUrl/PtitUrlPlugin.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://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/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+class PtitUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->registerUrlShortener(
+ 'ptiturl.com',
+ array(),
+ array('PtitUrl',array('http://ptiturl.com/?creer=oui&action=Reduire&url='))
+ );
+ }
+}
+
+class PtitUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $response = $this->http_get($url);
+ if (!$response) return $url;
+ $response = $this->tidy($response);
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $xml = $y->body->center->table->tr->td->pre->a->attributes();
+ if (isset($xml['href'])) return $xml['href'];
+ return $url;
+ }
+}
diff --git a/plugins/PubSubHubBub/PubSubHubBubPlugin.php b/plugins/PubSubHubBub/PubSubHubBubPlugin.php
new file mode 100644
index 000000000..e1e82e352
--- /dev/null
+++ b/plugins/PubSubHubBub/PubSubHubBubPlugin.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://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/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+define('DEFAULT_HUB','http://pubsubhubbub.appspot.com');
+
+require_once(INSTALLDIR.'/plugins/PubSubHubBub/publisher.php');
+
+class PubSubHubBubPlugin extends Plugin
+{
+ private $hub;
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->hub = common_config('PubSubHubBub', 'hub');
+ if(empty($this->hub)){
+ $this->hub = DEFAULT_HUB;
+ }
+ }
+
+ function onStartApiAtom($action){
+ $action->element('link',array('rel'=>'hub','href'=>$this->hub),null);
+ }
+
+ function onStartApiRss($action){
+ $action->element('atom:link',array('rel'=>'hub','href'=>$this->hub),null);
+ }
+
+ function onHandleQueuedNotice($notice){
+ $publisher = new Publisher($this->hub);
+
+ $feeds = array();
+
+ //public timeline feeds
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'public_timeline.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'public_timeline.atom'));
+
+ //author's own feeds
+ $user = User::staticGet('id',$notice->profile_id);
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom'));
+
+ //tag feeds
+ $tag = new Notice_tag();
+ $tag->notice_id = $notice->id;
+ if ($tag->find()) {
+ while ($tag->fetch()) {
+ $feeds[]=common_local_url('api',array('apiaction' => 'tags','method' => 'timeline', 'argument'=>$tag->tag.'.atom'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'tags','method' => 'timeline', 'argument'=>$tag->tag.'.rss'));
+ }
+ }
+
+ //group feeds
+ $group_inbox = new Group_inbox();
+ $group_inbox->notice_id = $notice->id;
+ if ($group_inbox->find()) {
+ while ($group_inbox->fetch()) {
+ $group = User_group::staticGet('id',$group_inbox->group_id);
+ $feeds[]=common_local_url('api',array('apiaction' => 'groups','method' => 'timeline','argument' => $group->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'groups','method' => 'timeline','argument' => $group->nickname.'.atom'));
+ }
+ }
+
+ //feed of each user that subscribes to the notice's author
+ $notice_inbox = new Notice_inbox();
+ $notice_inbox->notice_id = $notice->id;
+ if ($notice_inbox->find()) {
+ while ($notice_inbox->fetch()) {
+ $user = User::staticGet('id',$notice_inbox->user_id);
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom'));
+ }
+ }
+
+ /* TODO: when the reply page gets RSS and ATOM feeds, implement this
+ //feed of user replied to
+ if($notice->reply_to){
+ $user = User::staticGet('id',$notice->reply_to);
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.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());
+ }
+ }
+ }
+}
diff --git a/plugins/PubSubHubBub/publisher.php b/plugins/PubSubHubBub/publisher.php
new file mode 100644
index 000000000..f176a9b8a
--- /dev/null
+++ b/plugins/PubSubHubBub/publisher.php
@@ -0,0 +1,86 @@
+<?php
+
+// a PHP client library for pubsubhubbub
+// as defined at http://code.google.com/p/pubsubhubbub/
+// written by Josh Fraser | joshfraser.com | josh@eventvue.com
+// Released under Apache License 2.0
+
+class Publisher {
+
+ protected $hub_url;
+ protected $last_response;
+
+ // create a new Publisher
+ public function __construct($hub_url) {
+
+ if (!isset($hub_url))
+ throw new Exception('Please specify a hub url');
+
+ if (!preg_match("|^https?://|i",$hub_url))
+ throw new Exception('The specified hub url does not appear to be valid: '.$hub_url);
+
+ $this->hub_url = $hub_url;
+ }
+
+ // accepts either a single url or an array of urls
+ public function publish_update($topic_urls, $http_function = false) {
+ if (!isset($topic_urls))
+ throw new Exception('Please specify a topic url');
+
+ // check that we're working with an array
+ if (!is_array($topic_urls)) {
+ $topic_urls = array($topic_urls);
+ }
+
+ // set the mode to publish
+ $post_string = "hub.mode=publish";
+ // loop through each topic url
+ foreach ($topic_urls as $topic_url) {
+
+ // lightweight check that we're actually working w/ a valid url
+ if (!preg_match("|^https?://|i",$topic_url))
+ throw new Exception('The specified topic url does not appear to be valid: '.$topic_url);
+
+ // append the topic url parameters
+ $post_string .= "&hub.url=".urlencode($topic_url);
+ }
+
+ // make the http post request and return true/false
+ // easy to over-write to use your own http function
+ if ($http_function)
+ return $http_function($this->hub_url,$post_string);
+ else
+ return $this->http_post($this->hub_url,$post_string);
+ }
+
+ // returns any error message from the latest request
+ public function last_response() {
+ return $this->last_response;
+ }
+
+ // default http function that uses curl to post to the hub endpoint
+ private function http_post($url, $post_string) {
+
+ // add any additional curl options here
+ $options = array(CURLOPT_URL => $url,
+ CURLOPT_POST => true,
+ CURLOPT_POSTFIELDS => $post_string,
+ CURLOPT_USERAGENT => "PubSubHubbub-Publisher-PHP/1.0");
+
+ $ch = curl_init();
+ curl_setopt_array($ch, $options);
+
+ $response = curl_exec($ch);
+ $this->last_response = $response;
+ $info = curl_getinfo($ch);
+
+ curl_close($ch);
+
+ // all good
+ if ($info['http_code'] == 204)
+ return true;
+ return false;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php
index 0f0d0f9f4..0c7c1240c 100644
--- a/plugins/Realtime/RealtimePlugin.php
+++ b/plugins/Realtime/RealtimePlugin.php
@@ -230,6 +230,7 @@ class RealtimePlugin extends Plugin
}
$action->showContentBlock();
+ $action->showScripts();
$action->elementEnd('body');
return false; // No default processing
}
@@ -239,13 +240,13 @@ class RealtimePlugin extends Plugin
// 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 TwitterApiAction method. Don't do this unless you're me!
+ // the ApiAction method. Don't do this unless you're me!
- require_once(INSTALLDIR.'/lib/twitterapi.php');
+ require_once(INSTALLDIR.'/lib/api.php');
- $act = new TwitterApiAction('/dev/null');
+ $act = new ApiAction('/dev/null');
- $arr = $act->twitter_status_array($notice, true);
+ $arr = $act->twitterStatusArray($notice, true);
$arr['url'] = $notice->bestUrl();
$arr['html'] = htmlspecialchars($notice->rendered);
$arr['source'] = htmlspecialchars($arr['source']);
diff --git a/plugins/Realtime/jquery.getUrlParam.js b/plugins/Realtime/jquery.getUrlParam.js
deleted file mode 100644
index e8f73eb47..000000000
--- a/plugins/Realtime/jquery.getUrlParam.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright (c) 2006-2007 Mathias Bank (http://www.mathias-bank.de)
- * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
- * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
- *
- * Version 2.1
- *
- * Thanks to
- * Hinnerk Ruemenapf - http://hinnerk.ruemenapf.de/ for bug reporting and fixing.
- * Tom Leonard for some improvements
- *
- */
-jQuery.fn.extend({
-/**
-* Returns get parameters.
-*
-* If the desired param does not exist, null will be returned
-*
-* To get the document params:
-* @example value = $(document).getUrlParam("paramName");
-*
-* To get the params of a html-attribut (uses src attribute)
-* @example value = $('#imgLink').getUrlParam("paramName");
-*/
- getUrlParam: function(strParamName){
- strParamName = escape(unescape(strParamName));
-
- var returnVal = new Array();
- var qString = null;
-
- if ($(this).attr("nodeName")=="#document") {
- //document-handler
-
- if (window.location.search.search(strParamName) > -1 ){
-
- qString = window.location.search.substr(1,window.location.search.length).split("&");
- }
-
- } else if ($(this).attr("src")!="undefined") {
-
- var strHref = $(this).attr("src")
- if ( strHref.indexOf("?") > -1 ){
- var strQueryString = strHref.substr(strHref.indexOf("?")+1);
- qString = strQueryString.split("&");
- }
- } else if ($(this).attr("href")!="undefined") {
-
- var strHref = $(this).attr("href")
- if ( strHref.indexOf("?") > -1 ){
- var strQueryString = strHref.substr(strHref.indexOf("?")+1);
- qString = strQueryString.split("&");
- }
- } else {
- return null;
- }
-
-
- if (qString==null) return null;
-
-
- for (var i=0;i<qString.length; i++){
- if (escape(unescape(qString[i].split("=")[0])) == strParamName){
- returnVal.push(qString[i].split("=")[1]);
- }
-
- }
-
-
- if (returnVal.length==0) return null;
- else if (returnVal.length==1) return returnVal[0];
- else return returnVal;
- }
-}); \ No newline at end of file
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js
index 4cd68a816..9371326fe 100644
--- a/plugins/Realtime/realtimeupdate.js
+++ b/plugins/Realtime/realtimeupdate.js
@@ -7,6 +7,7 @@ RealtimeUpdate = {
_replyurl: '',
_favorurl: '',
_deleteurl: '',
+ _updatecounter: 0,
init: function(userid, replyurl, favorurl, deleteurl)
{
@@ -15,6 +16,8 @@ RealtimeUpdate = {
RealtimeUpdate._favorurl = favorurl;
RealtimeUpdate._deleteurl = deleteurl;
+ DT = document.title;
+
$(window).blur(function() {
$('#notices_primary .notice').css({
'border-top-color':$('#notices_primary .notice:last').css('border-top-color'),
@@ -25,24 +28,33 @@ RealtimeUpdate = {
'border-top-color':'#AAAAAA',
'border-top-style':'solid'
});
+
+ RealtimeUpdate._updatecounter = 0;
+ document.title = DT;
+
+ return false;
});
},
receive: function(data)
{
- id = data.id;
-
- // Don't add it if it already exists
- //
- if ($("#notice-"+id).length > 0) {
- return;
- }
-
- var noticeItem = RealtimeUpdate.makeNoticeItem(data);
- $("#notices_primary .notices").prepend(noticeItem);
- $("#notices_primary .notice:first").css({display:"none"});
- $("#notices_primary .notice:first").fadeIn(1000);
- NoticeReply();
+ setTimeout(function() {
+ id = data.id;
+
+ // Don't add it if it already exists
+ if ($("#notice-"+id).length > 0) {
+ return;
+ }
+
+ var noticeItem = RealtimeUpdate.makeNoticeItem(data);
+ $("#notices_primary .notices").prepend(noticeItem);
+ $("#notices_primary .notice:first").css({display:"none"});
+ $("#notices_primary .notice:first").fadeIn(1000);
+ NoticeReply();
+
+ RealtimeUpdate._updatecounter += 1;
+ document.title = '('+RealtimeUpdate._updatecounter+') ' + DT;
+ }, 500);
},
makeNoticeItem: function(data)
@@ -125,14 +137,17 @@ RealtimeUpdate = {
addPopup: function(url, timeline, iconurl)
{
- $('#content').prepend('<button id="realtime_timeline" title="Pop up in a window">Pop up</button>');
+ $('#notices_primary').css({'position':'relative'});
+ $('#notices_primary').prepend('<button id="realtime_timeline" title="Pop up in a window">Pop up</button>');
$('#realtime_timeline').css({
- 'margin':'0 0 18px 0',
+ 'margin':'0 0 11px 0',
'background':'transparent url('+ iconurl + ') no-repeat 0% 30%',
'padding':'0 0 0 20px',
'display':'block',
- 'float':'right',
+ 'position':'absolute',
+ 'top':'-20px',
+ 'right':'0',
'border':'none',
'cursor':'pointer',
'color':$("a").css("color"),
diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
new file mode 100644
index 000000000..4806538a0
--- /dev/null
+++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin that requires the user to have a validated email address before they can post 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://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/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+class RequireValidatedEmailPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onStartNoticeSave($notice)
+ {
+ $user = User::staticGet('id', $notice->profile_id);
+ if (!empty($user)) { // it's a remote notice
+ if (empty($user->email)) {
+ throw new ClientException(_("You must validate your email address before posting."));
+ }
+ }
+ return true;
+ }
+}
+
diff --git a/plugins/SimpleUrl/SimpleUrlPlugin.php b/plugins/SimpleUrl/SimpleUrlPlugin.php
new file mode 100644
index 000000000..82d772048
--- /dev/null
+++ b/plugins/SimpleUrl/SimpleUrlPlugin.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://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/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+class SimpleUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->registerUrlShortener(
+ 'is.gd',
+ array(),
+ array('SimpleUrl',array('http://is.gd/api.php?longurl='))
+ );
+ $this->registerUrlShortener(
+ 'snipr.com',
+ array(),
+ array('SimpleUrl',array('http://snipr.com/site/snip?r=simple&link='))
+ );
+ $this->registerUrlShortener(
+ 'metamark.net',
+ array(),
+ array('SimpleUrl',array('http://metamark.net/api/rest/simple?long_url='))
+ );
+ $this->registerUrlShortener(
+ 'tinyurl.com',
+ array(),
+ array('SimpleUrl',array('http://tinyurl.com/api-create.php?url='))
+ );
+ }
+}
+
+class SimpleUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $curlh = curl_init();
+ curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
+ curl_setopt($curlh, CURLOPT_USERAGENT, 'StatusNet');
+ curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
+
+ curl_setopt($curlh, CURLOPT_URL, $this->service_url.urlencode($url));
+ $short_url = curl_exec($curlh);
+
+ curl_close($curlh);
+ return $short_url;
+ }
+}
diff --git a/plugins/TemplatePlugin.php b/plugins/TemplatePlugin.php
index cfa051162..5f3ad81f5 100644
--- a/plugins/TemplatePlugin.php
+++ b/plugins/TemplatePlugin.php
@@ -32,7 +32,7 @@ class TemplatePlugin extends Plugin {
// capture the RouterInitialized event
// and connect a new API method
// for updating the template
- function onRouterInitialized( &$m ) {
+ function onRouterInitialized( $m ) {
$m->connect( 'template/update', array(
'action' => 'template',
));
diff --git a/plugins/TightUrl/TightUrlPlugin.php b/plugins/TightUrl/TightUrlPlugin.php
new file mode 100644
index 000000000..48efb355f
--- /dev/null
+++ b/plugins/TightUrl/TightUrlPlugin.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://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/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+class TightUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->registerUrlShortener(
+ '2tu.us',
+ array('freeService'=>true),
+ array('TightUrl',array('http://2tu.us/?save=y&url='))
+ );
+ }
+}
+
+class TightUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $response = $this->http_get($url);
+ if (!$response) return $url;
+ $response = $this->tidy($response);
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $xml = $y->body->p[0]->code[0]->a->attributes();
+ if (isset($xml['href'])) return $xml['href'];
+ return $url;
+ }
+}
diff --git a/plugins/TwitterBridge/README b/plugins/TwitterBridge/README
new file mode 100644
index 000000000..d3bcda598
--- /dev/null
+++ b/plugins/TwitterBridge/README
@@ -0,0 +1,85 @@
+This Twitter "bridge" plugin allows you to integrate your StatusNet
+instance with Twitter. Installing it will allow your users to:
+
+ - automatically post notices to thier Twitter accounts
+ - automatically subscribe to other Twitter users who are also using
+ your StatusNet install, if possible (requires running a daemon)
+ - import their Twitter friends' tweets (requires running a daemon)
+
+Installation
+------------
+
+To enable the plugin, add the following to your config.php:
+
+ addPlugin("TwitterBridge");
+
+OAuth is used to to access protected resources on Twitter (as opposed to
+HTTP Basic Auth)*. To use Twitter bridging you will need to register
+your instance of StatusNet as an application on Twitter
+(http://twitter.com/apps), and update the following variables in your
+config.php with the consumer key and secret Twitter generates for you:
+
+ $config['twitter']['consumer_key'] = 'YOURKEY';
+ $config['twitter']['consumer_secret'] = 'YOURSECRET';
+
+When registering your application with Twitter set the type to "Browser"
+and your Callback URL to:
+
+ http://example.org/mublog/twitter/authorization
+
+The default access type should be, "Read & Write".
+
+* Note: The plugin will still push notices to Twitter for users who
+ have previously setup the Twitter bridge using their Twitter name and
+ password under an older versions of StatusNet, but all new Twitter
+ bridge connections will use OAuth.
+
+Deamons
+-------
+
+For friend syncing and importing notices running two additional daemon
+scripts is necessary (synctwitterfriends.php and
+twitterstatusfetcher.php).
+
+In the daemons subidrectory of the plugin are three scripts:
+
+* Twitter Friends Syncing (daemons/synctwitterfriends.php)
+
+Users may set a flag in their settings ("Subscribe to my Twitter friends
+here" under the Twitter tab) to have StatusNet attempt to locate and
+subscribe to "friends" (people they "follow") on Twitter who also have
+accounts on your StatusNet system, and who have previously set up a link
+for automatically posting notices to Twitter.
+
+The plugin will try to start this daemon when you run
+scripts/startdaemons.sh.
+
+* Importing statuses from Twitter (daemons/twitterstatusfetcher.php)
+
+To allow your users to import their friends' Twitter statuses, you will
+need to enable the bidirectional Twitter bridge in your config.php:
+
+ $config['twitterimport']['enabled'] = true;
+
+The plugin will then start the TwitterStatusFetcher daemon along with the
+other daemons when you run scripts/startdaemons.sh.
+
+Additionally, you will want to set the integration source variable,
+which will keep notices posted to Twitter via StatusNet from looping
+back. The integration source should be set to the name of your
+application, exactly as you specified it on the settings page for your
+StatusNet application on Twitter, e.g.:
+
+ $config['integration']['source'] = 'YourApp';
+
+* TwitterQueueHandler (daemons/twitterqueuehandler.php)
+
+This script sends queued notices to Twitter for user who have opted to
+set up Twitter bridging.
+
+It's not strictly necessary to run this queue handler, and sites that
+haven't enabled queuing are still able to push notices to Twitter, but
+for larger sites and sites that wish to improve performance, this
+script allows notices to be sent "offline" via a separate process.
+
+The plugin will start this script when you run scripts/startdaemons.sh.
diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php
new file mode 100644
index 000000000..ad3c2e551
--- /dev/null
+++ b/plugins/TwitterBridge/TwitterBridgePlugin.php
@@ -0,0 +1,187 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @copyright 2009 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/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+
+/**
+ * Plugin for sending and importing Twitter statuses
+ *
+ * This class allows users to link their Twitter accounts
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @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://laconi.ca/
+ * @link http://twitter.com/
+ */
+
+class TwitterBridgePlugin extends Plugin
+{
+ /**
+ * Initializer for the plugin.
+ */
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Add Twitter-related paths to the router table
+ *
+ * Hook for RouterInitialized event.
+ *
+ * @param Net_URL_Mapper $m path-to-action mapper
+ *
+ * @return boolean hook return
+ */
+
+ function onRouterInitialized($m)
+ {
+ $m->connect('twitter/authorization',
+ array('action' => 'twitterauthorization'));
+ $m->connect('settings/twitter', array('action' => 'twittersettings'));
+
+ return true;
+ }
+
+ /**
+ * Add the Twitter Settings page to the Connect Settings menu
+ *
+ * @param Action &$action The calling page
+ *
+ * @return boolean hook return
+ */
+ function onEndConnectSettingsNav(&$action)
+ {
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('twittersettings'),
+ _('Twitter'),
+ _('Twitter integration options'),
+ $action_name === 'twittersettings');
+
+ return true;
+ }
+
+ /**
+ * Automatically load the actions and libraries used by the Twitter bridge
+ *
+ * @param Class $cls the class
+ *
+ * @return boolean hook return
+ *
+ */
+ function onAutoload($cls)
+ {
+ switch ($cls) {
+ case 'TwittersettingsAction':
+ case 'TwitterauthorizationAction':
+ include_once INSTALLDIR . '/plugins/TwitterBridge/' .
+ strtolower(mb_substr($cls, 0, -6)) . '.php';
+ return false;
+ case 'TwitterOAuthClient':
+ include_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * Add a Twitter queue item for each notice
+ *
+ * @param Notice $notice the notice
+ * @param array &$transports the list of transports (queues)
+ *
+ * @return boolean hook return
+ */
+ function onStartEnqueueNotice($notice, &$transports)
+ {
+ array_push($transports, 'twitter');
+ return true;
+ }
+
+ /**
+ * broadcast the message when not using queuehandler
+ *
+ * @param Notice &$notice the notice
+ * @param array $queue destination queue
+ *
+ * @return boolean hook return
+ */
+ function onUnqueueHandleNotice(&$notice, $queue)
+ {
+ if (($queue == 'twitter') && ($this->_isLocal($notice))) {
+ broadcast_twitter($notice);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Determine whether the notice was locally created
+ *
+ * @param Notice $notice
+ *
+ * @return boolean locality
+ */
+ function _isLocal($notice)
+ {
+ return ($notice->is_local == Notice::LOCAL_PUBLIC ||
+ $notice->is_local == Notice::LOCAL_NONPUBLIC);
+ }
+
+ /**
+ * Add Twitter bridge daemons to the list of daemons to start
+ *
+ * @param array $daemons the list fo daemons to run
+ *
+ * @return boolean hook return
+ *
+ */
+ function onGetValidDaemons($daemons)
+ {
+ array_push($daemons, INSTALLDIR .
+ '/plugins/TwitterBridge/daemons/twitterqueuehandler.php');
+ array_push($daemons, INSTALLDIR .
+ '/plugins/TwitterBridge/daemons/synctwitterfriends.php');
+
+ if (common_config('twitterimport', 'enabled')) {
+ array_push($daemons, INSTALLDIR
+ . '/plugins/TwitterBridge/daemons/twitterstatusfetcher.php');
+ }
+
+ return true;
+ }
+
+}
diff --git a/scripts/synctwitterfriends.php b/plugins/TwitterBridge/daemons/synctwitterfriends.php
index b30e700a1..ed2bf48a2 100755
--- a/scripts/synctwitterfriends.php
+++ b/plugins/TwitterBridge/daemons/synctwitterfriends.php
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
$shortoptions = 'di::';
$longoptions = array('id::', 'debug');
@@ -32,6 +32,9 @@ END_OF_TRIM_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
require_once INSTALLDIR . '/lib/parallelizingdaemon.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitterbasicauthclient.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
/**
* Daemon to sync local friends with Twitter friends
@@ -44,14 +47,6 @@ require_once INSTALLDIR . '/lib/parallelizingdaemon.php';
* @link http://status.net/
*/
-$helptext = <<<END_OF_TWITTER_HELP
-Batch script for synching local friends with Twitter friends.
-
-END_OF_TWITTER_HELP;
-
-require_once INSTALLDIR . '/scripts/commandline.inc';
-require_once INSTALLDIR . '/lib/parallelizingdaemon.php';
-
class SyncTwitterFriendsDaemon extends ParallelizingDaemon
{
/**
diff --git a/scripts/twitterqueuehandler.php b/plugins/TwitterBridge/daemons/twitterqueuehandler.php
index ce4d824d0..f0e76bb74 100755
--- a/scripts/twitterqueuehandler.php
+++ b/plugins/TwitterBridge/daemons/twitterqueuehandler.php
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
$shortoptions = 'i::';
$longoptions = array('id::');
@@ -30,10 +30,9 @@ Daemon script for pushing new notices to Twitter.
END_OF_ENJIT_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
-
-require_once INSTALLDIR . '/lib/twitter.php';
+require_once INSTALLDIR . '/scripts/commandline.inc';
require_once INSTALLDIR . '/lib/queuehandler.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
class TwitterQueueHandler extends QueueHandler
{
diff --git a/scripts/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
index 3cdf1867a..81bbbc7c5 100755
--- a/scripts/twitterstatusfetcher.php
+++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
// Tune number of processes and how often to poll Twitter
// XXX: Should these things be in config.php?
@@ -36,8 +36,12 @@ Batch script for retrieving Twitter messages from foreign service.
END_OF_TRIM_HELP;
-require_once INSTALLDIR .'/scripts/commandline.inc';
+require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/lib/common.php';
require_once INSTALLDIR . '/lib/daemon.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitterbasicauthclient.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
/**
* Fetcher for statuses from Twitter
@@ -496,8 +500,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon
$avatar->filename = $filename;
$avatar->url = Avatar::url($filename);
- common_debug($this->name() . " - New filename: $avatar->url");
-
$avatar->created = common_sql_now();
$id = $avatar->insert();
@@ -515,9 +517,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon
function fetchAvatar($url, $filename)
{
- $avatar_dir = INSTALLDIR . '/avatar/';
-
- $avatarfile = $avatar_dir . $filename;
+ $avatarfile = Avatar::path($filename);
$out = fopen($avatarfile, 'wb');
if (!$out) {
diff --git a/lib/twitter.php b/plugins/TwitterBridge/twitter.php
index 676c9b20a..1a5248a9b 100644
--- a/lib/twitter.php
+++ b/plugins/TwitterBridge/twitter.php
@@ -23,7 +23,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
define('TWITTER_SERVICE', 1); // Twitter is foreign_service ID 1
-function update_twitter_user($twitter_id, $screen_name)
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitterbasicauthclient.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
+
+function updateTwitter_user($twitter_id, $screen_name)
{
$uri = 'http://twitter.com/' . $screen_name;
$fuser = new Foreign_user();
@@ -115,7 +118,7 @@ function save_twitter_user($twitter_id, $screen_name)
// Only update if Twitter screen name has changed
if ($fuser->nickname != $screen_name) {
- $result = update_twitter_user($twitter_id, $screen_name);
+ $result = updateTwitter_user($twitter_id, $screen_name);
common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' .
"$fuser->id to $screen_name, was $fuser->nickname");
@@ -165,9 +168,10 @@ function broadcast_twitter($notice)
}
function broadcast_oauth($notice, $flink) {
-
$user = $flink->getUser();
$statustxt = format_status($notice);
+ // Convert !groups to #hashes
+ $statustxt = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/', "\\1#\\2", $statustxt);
$token = TwitterOAuthClient::unpackToken($flink->credentials);
$client = new TwitterOAuthClient($token->key, $token->secret);
$status = null;
@@ -222,6 +226,10 @@ function broadcast_basicauth($notice, $flink)
$user->nickname, $user->id);
common_log(LOG_WARNING, $errmsg);
+ $errmsg = sprintf('No data returned by Twitter API when ' .
+ 'trying to send update for %1$s (user id %2$s).',
+ $user->nickname, $user->id);
+ common_log(LOG_WARNING, $errmsg);
return false;
}
@@ -304,3 +312,40 @@ function remove_twitter_link($flink)
}
}
+
+/**
+ * Send a mail message to notify a user that her Twitter bridge link
+ * has stopped working, and therefore has been removed. This can
+ * happen when the user changes her Twitter password, or otherwise
+ * revokes access.
+ *
+ * @param User $user user whose Twitter bridge link has been removed
+ *
+ * @return boolean success flag
+ */
+
+function mail_twitter_bridge_removed($user)
+{
+ common_init_locale($user->language);
+
+ $profile = $user->getProfile();
+
+ $subject = sprintf(_('Your Twitter bridge has been disabled.'));
+
+ $site_name = common_config('site', 'name');
+
+ $body = sprintf(_('Hi, %1$s. We\'re sorry to inform you that your ' .
+ 'link to Twitter has been disabled. We no longer seem to have ' .
+ 'permission to update your Twitter status. (Did you revoke ' .
+ '%3$s\'s access?)' . "\n\n" .
+ 'You can re-enable your Twitter bridge by visiting your ' .
+ "Twitter settings page:\n\n\t%2\$s\n\n" .
+ "Regards,\n%3\$s\n"),
+ $profile->getBestName(),
+ common_local_url('twittersettings'),
+ common_config('site', 'name'));
+
+ common_init_locale();
+ return mail_to_user($user, $subject, $body);
+}
+
diff --git a/actions/twitterauthorization.php b/plugins/TwitterBridge/twitterauthorization.php
index 630ac426f..2a93ff13e 100644
--- a/actions/twitterauthorization.php
+++ b/plugins/TwitterBridge/twitterauthorization.php
@@ -31,9 +31,32 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+
+/**
+ * Class for doing OAuth authentication against Twitter
+ *
+ * Peforms the OAuth "dance" between StatusNet and Twitter -- requests a token,
+ * authorizes it, and exchanges it for an access token. It also creates a link
+ * (Foreign_link) between the StatusNet user and Twitter user and stores the
+ * access token and secret in the link.
+ *
+ * @category Twitter
+ * @package StatusNet
+ * @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://laconi.ca/
+ *
+ */
class TwitterauthorizationAction extends Action
{
-
+ /**
+ * Initialize class members. Looks for 'oauth_token' parameter.
+ *
+ * @param array $args misc. arguments
+ *
+ * @return boolean true
+ */
function prepare($args)
{
parent::prepare($args);
diff --git a/lib/twitterbasicauthclient.php b/plugins/TwitterBridge/twitterbasicauthclient.php
index fd331fbdc..1040d72fb 100644
--- a/lib/twitterbasicauthclient.php
+++ b/plugins/TwitterBridge/twitterbasicauthclient.php
@@ -36,8 +36,14 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
*
* @category Integration
* @package StatusNet
- * @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
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Brenda Wallace <shiny@cpan.org>
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Dan Moore <dan@moore.cx>
+ * @author Evan Prodromou <evan@status.net>
+ * @author mEDI <medi@milaro.net>
+ * @author Sarven Capadisli <csarven@status.net>
+ * @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/
*
*/
diff --git a/lib/twitteroauthclient.php b/plugins/TwitterBridge/twitteroauthclient.php
index bad2b74ca..bad2b74ca 100644
--- a/lib/twitteroauthclient.php
+++ b/plugins/TwitterBridge/twitteroauthclient.php
diff --git a/actions/twittersettings.php b/plugins/TwitterBridge/twittersettings.php
index 89169941e..ca22c9553 100644
--- a/actions/twittersettings.php
+++ b/plugins/TwitterBridge/twittersettings.php
@@ -31,8 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/connectsettingsaction.php';
-require_once INSTALLDIR.'/lib/twitter.php';
+require_once INSTALLDIR . '/lib/connectsettingsaction.php';
+require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
/**
* Settings for Twitter integration
@@ -82,11 +82,6 @@ class TwittersettingsAction extends ConnectSettingsAction
function showContent()
{
- if (!common_config('twitter', 'enabled')) {
- $this->element('div', array('class' => 'error'),
- _('Twitter is not available.'));
- return;
- }
$user = common_current_user();
@@ -157,7 +152,7 @@ class TwittersettingsAction extends ConnectSettingsAction
false);
$this->elementEnd('li');
- if (common_config('twitterbridge','enabled')) {
+ if (common_config('twitterimport','enabled')) {
$this->elementStart('li');
$this->checkbox('noticerecv',
_('Import my Friends Timeline.'),
diff --git a/scripts/checkschema.php b/scripts/checkschema.php
new file mode 100644
index 000000000..bf52abe15
--- /dev/null
+++ b/scripts/checkschema.php
@@ -0,0 +1,30 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, 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_CHECKSCHEMA_HELP
+Gives plugins a chance to update the database schema.
+
+END_OF_CHECKSCHEMA_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+Event::handle('CheckSchema');
diff --git a/scripts/createsim.php b/scripts/createsim.php
index 71ed3bf72..1266a9700 100644
--- a/scripts/createsim.php
+++ b/scripts/createsim.php
@@ -101,7 +101,7 @@ function newSub($i)
$to = User::staticGet('nickname', $tunic);
- if (empty($from)) {
+ if (empty($to)) {
throw new Exception("Can't find user '$tunic'.");
}
diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php
index 8f48e8e6f..99ad41b37 100755
--- a/scripts/getvaliddaemons.php
+++ b/scripts/getvaliddaemons.php
@@ -35,20 +35,26 @@ ENDOFHELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
+$daemons = array();
+
+$daemons[] = INSTALLDIR.'/scripts/pluginqueuehandler.php';
+$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php';
+$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php';
+
if(common_config('xmpp','enabled')) {
- echo "xmppdaemon.php jabberqueuehandler.php publicqueuehandler.php ";
- echo "xmppconfirmhandler.php ";
-}
-if(common_config('twitterbridge','enabled')) {
- echo "twitterstatusfetcher.php ";
-}
-echo "ombqueuehandler.php ";
-if (common_config('twitter', 'enabled')) {
- echo "twitterqueuehandler.php ";
- echo "synctwitterfriends.php ";
+ $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php';
+ $daemons[] = INSTALLDIR.'/scripts/jabberqueuehandler.php';
+ $daemons[] = INSTALLDIR.'/scripts/publicqueuehandler.php';
+ $daemons[] = INSTALLDIR.'/scripts/xmppconfirmhandler.php';
}
-echo "facebookqueuehandler.php ";
-echo "pingqueuehandler.php ";
+
if (common_config('sms', 'enabled')) {
- echo "smsqueuehandler.php ";
+ $daemons[] = INSTALLDIR.'/scripts/smsqueuehandler.php';
+}
+
+if (Event::handle('GetValidDaemons', array(&$daemons))) {
+ foreach ($daemons as $daemon) {
+ print $daemon . ' ';
+ }
+ print "\n";
}
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php
index 678ca24c3..b4e4d9f08 100755
--- a/scripts/maildaemon.php
+++ b/scripts/maildaemon.php
@@ -29,6 +29,7 @@ END_OF_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
require_once(INSTALLDIR . '/lib/mail.php');
+require_once(INSTALLDIR . '/lib/mediafile.php');
require_once('Mail/mimeDecode.php');
# FIXME: we use both Mail_mimeDecode and mailparse
@@ -66,46 +67,32 @@ class MailerDaemon
}
$msg = $this->cleanup_msg($msg);
$msg = common_shorten_links($msg);
- if (mb_strlen($msg) > 140) {
- $this->error($from,_('That\'s too long. '.
- 'Max notice size is 140 chars.'));
+ if (Notice::contentTooLong($msg)) {
+ $this->error($from, sprintf(_('That\'s too long. '.
+ 'Max notice size is %d chars.'),
+ Notice::maxContent()));
}
- $fileRecords = array();
- foreach($attachments as $attachment){
- $mimetype = $this->getUploadedFileType($attachment);
- $stream = stream_get_meta_data($attachment);
- if (!$this->isRespectsQuota($user,filesize($stream['uri']))) {
- die('error() should trigger an exception before reaching here.');
- }
- $filename = $this->saveFile($user, $attachment,$mimetype);
-
- fclose($attachment);
-
- if (empty($filename)) {
- $this->error($from,_('Couldn\'t save file.'));
- }
- $fileRecord = $this->storeFile($filename, $mimetype);
- $fileRecords[] = $fileRecord;
- $fileurl = common_local_url('attachment',
- array('attachment' => $fileRecord->id));
+ $mediafiles = array();
- // not sure this is necessary -- Zach
- $this->maybeAddRedir($fileRecord->id, $fileurl);
+ foreach($attachments as $attachment){
- $short_fileurl = common_shorten_url($fileurl);
- $msg .= ' ' . $short_fileurl;
+ $mf = null;
- if (mb_strlen($msg) > 140) {
- $this->deleteFile($filename);
- $this->error($from,_('Max notice size is 140 chars, including attachment URL.'));
+ try {
+ $mf = MediaFile::fromFileHandle($attachment, $user);
+ } catch(ClientException $ce) {
+ $this->error($from, $ce->getMessage());
}
- // Also, not sure this is necessary -- Zach
- $this->maybeAddRedir($fileRecord->id, $short_fileurl);
+ $msg .= ' ' . $mf->shortUrl();
+
+ array_push($mediafiles, $mf);
+ fclose($attachment);
}
- $err = $this->add_notice($user, $msg, $fileRecords);
+ $err = $this->add_notice($user, $msg, $mediafiles);
+
if (is_string($err)) {
$this->error($from, $err);
return false;
@@ -114,89 +101,6 @@ class MailerDaemon
}
}
- function saveFile($user, $attachment, $mimetype) {
-
- $filename = File::filename($user->getProfile(), "email", $mimetype);
-
- $filepath = File::path($filename);
-
- $stream = stream_get_meta_data($attachment);
- if (copy($stream['uri'], $filepath) && chmod($filepath,0664)) {
- return $filename;
- } else {
- $this->error(null,_('File could not be moved to destination directory.' . $stream['uri'] . ' ' . $filepath));
- }
- }
-
- function storeFile($filename, $mimetype) {
-
- $file = new File;
- $file->filename = $filename;
-
- $file->url = File::url($filename);
-
- $filepath = File::path($filename);
-
- $file->size = filesize($filepath);
- $file->date = time();
- $file->mimetype = $mimetype;
-
- $file_id = $file->insert();
-
- if (!$file_id) {
- common_log_db_error($file, "INSERT", __FILE__);
- $this->error(null,_('There was a database error while saving your file. Please try again.'));
- }
-
- return $file;
- }
-
- function maybeAddRedir($file_id, $url)
- {
- $file_redir = File_redirection::staticGet('url', $url);
-
- if (empty($file_redir)) {
- $file_redir = new File_redirection;
- $file_redir->url = $url;
- $file_redir->file_id = $file_id;
-
- $result = $file_redir->insert();
-
- if (!$result) {
- common_log_db_error($file_redir, "INSERT", __FILE__);
- $this->error(null,_('There was a database error while saving your file. Please try again.'));
- }
- }
- }
-
- function getUploadedFileType($fileHandle) {
- require_once 'MIME/Type.php';
-
- $cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
- $cmd = common_config('attachments', 'filecommand');
-
- $stream = stream_get_meta_data($fileHandle);
- $filetype = MIME_Type::autoDetect($stream['uri']);
- if (in_array($filetype, common_config('attachments', 'supported'))) {
- return $filetype;
- }
- $media = MIME_Type::getMedia($filetype);
- if ('application' !== $media) {
- $hint = sprintf(_(' Try using another %s format.'), $media);
- } else {
- $hint = '';
- }
- $this->error(null,sprintf(
- _('%s is not a supported filetype on this server.'), $filetype) . $hint);
- }
-
- function isRespectsQuota($user,$fileSize) {
- $file = new File;
- $ret = $file->isRespectsQuota($user,$fileSize);
- if (true === $ret) return true;
- $this->error(null,$ret);
- }
-
function error($from, $msg)
{
file_put_contents("php://stderr", $msg . "\n");
@@ -256,15 +160,16 @@ class MailerDaemon
common_log($level, 'MailDaemon: '.$msg);
}
- function add_notice($user, $msg, $fileRecords)
+ function add_notice($user, $msg, $mediafiles)
{
- $notice = Notice::saveNew($user->id, $msg, 'mail');
- if (is_string($notice)) {
- $this->log(LOG_ERR, $notice);
- return $notice;
+ try {
+ $notice = Notice::saveNew($user->id, $msg, 'mail');
+ } catch (Exception $e) {
+ $this->log(LOG_ERR, $e->getMessage());
+ return $e->getMessage();
}
- foreach($fileRecords as $fileRecord){
- $this->attachFile($notice, $fileRecord);
+ foreach($mediafiles as $mf){
+ $mf->attachToNotice($notice);
}
common_broadcast_notice($notice);
$this->log(LOG_INFO,
@@ -272,14 +177,6 @@ class MailerDaemon
return true;
}
- function attachFile($notice, $filerec)
- {
- File_to_post::processNew($filerec->id, $notice->id);
-
- $this->maybeAddRedir($filerec->id,
- common_local_url('file', array('notice' => $notice->id)));
- }
-
function parse_message($fname)
{
$contents = file_get_contents($fname);
diff --git a/scripts/ombqueuehandler.php b/scripts/ombqueuehandler.php
index 8e685f1c8..be33b9821 100755
--- a/scripts/ombqueuehandler.php
+++ b/scripts/ombqueuehandler.php
@@ -57,7 +57,7 @@ class OmbQueueHandler extends QueueHandler
$this->log(LOG_DEBUG, 'Ignoring remote notice ' . $notice->id);
return true;
} else {
- return omb_broadcast_remote_subscribers($notice);
+ return omb_broadcast_notice($notice);
}
}
diff --git a/scripts/pluginqueuehandler.php b/scripts/pluginqueuehandler.php
new file mode 100755
index 000000000..ae807db6a
--- /dev/null
+++ b/scripts/pluginqueuehandler.php
@@ -0,0 +1,58 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, 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__) . '/..'));
+
+$shortoptions = 'i::';
+$longoptions = array('id::');
+
+$helptext = <<<END_OF_OMB_HELP
+Daemon script for letting plugins handle stuff at queue time
+
+ -i --id Identity (default none)
+
+END_OF_OMB_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR . '/lib/queuehandler.php';
+
+class PluginQueueHandler extends QueueHandler
+{
+
+ function transport()
+ {
+ return 'plugin';
+ }
+
+ function handle_notice($notice)
+ {
+ Event::handle('HandleQueuedNotice', array(&$notice));
+ return true;
+ }
+}
+
+if (have_option('i', 'id')) {
+ $id = get_option_value('i', 'id');
+} else {
+ $id = null;
+}
+
+$handler = new PluginQueueHandler($id);
+$handler->runOnce();
diff --git a/actions/twitapinotifications.php b/scripts/showtable.php
index 0653e69ab..eb18a98e2 100644
--- a/actions/twitapinotifications.php
+++ b/scripts/showtable.php
@@ -1,6 +1,7 @@
+#!/usr/bin/env php
<?php
/*
- * StatusNet - the distributed open-source microblogging tool
+ * StatusNet - a distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
@@ -17,24 +18,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-require_once(INSTALLDIR.'/lib/twitterapi.php');
+$helptext = <<<END_OF_SHOWTABLE_HELP
+showtable.php <tablename>
+Shows the structure of a table
-# This naming convention looks real sick
-class TwitapinotificationsAction extends TwitterapiAction
-{
+END_OF_SHOWTABLE_HELP;
- function follow($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
- }
+require_once INSTALLDIR.'/scripts/commandline.inc';
- function leave($args, $apidata)
- {
- parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
- }
+if (count($args) != 1) {
+ show_help();
+}
-} \ No newline at end of file
+$name = $args[0];
+
+$schema = Schema::get();
+
+$td = $schema->getTableDef($name);
+
+print_r($td);
diff --git a/scripts/startdaemons.sh b/scripts/startdaemons.sh
index 298162673..5fb75414d 100755
--- a/scripts/startdaemons.sh
+++ b/scripts/startdaemons.sh
@@ -40,7 +40,7 @@ DAEMONS=`php $DIR/getvaliddaemons.php $ARGSG`
for f in $DAEMONS; do
printf "Starting $f...";
- php $DIR/$f $ARGSD
+ php $f $ARGSD
printf "DONE.\n"
done
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 9e621e725..b2efc07c3 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -316,17 +316,22 @@ class XMPPDaemon extends Daemon
{
$body = trim($pl['body']);
$content_shortened = common_shorten_links($body);
- if (mb_strlen($content_shortened) > 140) {
+ if (Notice::contentTooLong($content_shortened)) {
$from = jabber_normalize_jid($pl['from']);
- $this->from_site($from, "Message too long - maximum is 140 characters, you sent ".mb_strlen($content_shortened));
+ $this->from_site($from, sprintf(_("Message too long - maximum is %d characters, you sent %d"),
+ Notice::maxContent(),
+ mb_strlen($content_shortened)));
return;
}
- $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp');
- if (is_string($notice)) {
- $this->log(LOG_ERR, $notice);
- $this->from_site($user->jabber, $notice);
+
+ try {
+ $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp');
+ } catch (Exception $e) {
+ $this->log(LOG_ERR, $e->getMessage());
+ $this->from_site($user->jabber, $e->getMessage());
return;
}
+
common_broadcast_notice($notice);
$this->log(LOG_INFO,
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
diff --git a/tests/HashTagDetectionTests.php b/tests/HashTagDetectionTests.php
index aeac4a5e3..483d7135e 100644
--- a/tests/HashTagDetectionTests.php
+++ b/tests/HashTagDetectionTests.php
@@ -7,6 +7,7 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('STATUSNET', true);
+define('LACONICA', true);
require_once INSTALLDIR . '/lib/common.php';
diff --git a/tests/LocationTest.php b/tests/LocationTest.php
new file mode 100644
index 000000000..62849eb9f
--- /dev/null
+++ b/tests/LocationTest.php
@@ -0,0 +1,87 @@
+<?php
+
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+ print "This script must be run from the command line\n";
+ exit();
+}
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('STATUSNET', true);
+
+require_once INSTALLDIR . '/lib/common.php';
+
+// Make sure this is loaded
+// XXX: how to test other plugins...?
+
+addPlugin('Geonames');
+
+class LocationTest extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @dataProvider locationNames
+ */
+
+ public function testLocationFromName($name, $language, $location)
+ {
+ $result = Location::fromName($name, $language);
+ $this->assertEquals($result, $location);
+ }
+
+ static public function locationNames()
+ {
+ return array(array('Montreal', 'en', null),
+ array('San Francisco, CA', 'en', null),
+ array('Paris, France', 'en', null),
+ array('Paris, Texas', 'en', null));
+ }
+
+ /**
+ * @dataProvider locationIds
+ */
+
+ public function testLocationFromId($id, $ns, $language, $location)
+ {
+ $result = Location::fromId($id, $ns, $language);
+ $this->assertEquals($result, $location);
+ }
+
+ static public function locationIds()
+ {
+ return array(array(6077243, GeonamesPlugin::NAMESPACE, 'en', null),
+ array(5391959, GeonamesPlugin::NAMESPACE, 'en', null));
+ }
+
+ /**
+ * @dataProvider locationLatLons
+ */
+
+ public function testLocationFromLatLon($lat, $lon, $language, $location)
+ {
+ $result = Location::fromLatLon($lat, $lon, $language);
+ $this->assertEquals($result, $location);
+ }
+
+ static public function locationLatLons()
+ {
+ return array(array(37.77493, -122.41942, 'en', null),
+ array(45.509, -73.588, 'en', null));
+ }
+
+ /**
+ * @dataProvider nameOfLocation
+ */
+
+ public function testLocationGetName($location, $language, $name)
+ {
+ $result = $location->getName($language);
+ $this->assertEquals($result, $name);
+ }
+
+ static public function nameOfLocation()
+ {
+ return array(array(new Location(), 'en', 'Montreal'),
+ array(new Location(), 'fr', 'Montréal'));
+ }
+}
+
diff --git a/tests/URLDetectionTest.php b/tests/URLDetectionTest.php
index 1c3f7cd96..0cc03ccce 100644
--- a/tests/URLDetectionTest.php
+++ b/tests/URLDetectionTest.php
@@ -7,6 +7,7 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('STATUSNET', true);
+define('LACONICA', true);
require_once INSTALLDIR . '/lib/common.php';
@@ -28,69 +29,73 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
array('not a link :: no way',
'not a link :: no way'),
array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
- 'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
+ 'link <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" title="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="external">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
array('http://127.0.0.1',
- '<a href="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
array('127.0.0.1',
- '<a href="http://127.0.0.1/" rel="external">127.0.0.1</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">127.0.0.1</a>'),
array('127.0.0.1:99',
- '<a href="http://127.0.0.1:99/" rel="external">127.0.0.1:99</a>'),
+ '<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="external">127.0.0.1:99</a>'),
array('127.0.0.1/Name:test.php',
- '<a href="http://127.0.0.1/Name:test.php" rel="external">127.0.0.1/Name:test.php</a>'),
+ '<a href="http://127.0.0.1/Name:test.php" title="http://127.0.0.1/Name:test.php" rel="external">127.0.0.1/Name:test.php</a>'),
array('127.0.0.1/~test',
- '<a href="http://127.0.0.1/~test" rel="external">127.0.0.1/~test</a>'),
+ '<a href="http://127.0.0.1/~test" title="http://127.0.0.1/~test" rel="external">127.0.0.1/~test</a>'),
array('127.0.0.1/+test',
- '<a href="http://127.0.0.1/+test" rel="external">127.0.0.1/+test</a>'),
+ '<a href="http://127.0.0.1/+test" title="http://127.0.0.1/+test" rel="external">127.0.0.1/+test</a>'),
array('127.0.0.1/$test',
- '<a href="http://127.0.0.1/$test" rel="external">127.0.0.1/$test</a>'),
+ '<a href="http://127.0.0.1/$test" title="http://127.0.0.1/$test" rel="external">127.0.0.1/$test</a>'),
array('127.0.0.1/\'test',
- '<a href="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
+ '<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
array('127.0.0.1/"test',
- '<a href="http://127.0.0.1/&quot;test" rel="external">127.0.0.1/&quot;test</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">127.0.0.1/</a>&quot;test'),
+ array('127.0.0.1/test"test',
+ '<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="external">127.0.0.1/test</a>&quot;test'),
array('127.0.0.1/-test',
- '<a href="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
+ '<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
array('127.0.0.1/_test',
- '<a href="http://127.0.0.1/_test" rel="external">127.0.0.1/_test</a>'),
+ '<a href="http://127.0.0.1/_test" title="http://127.0.0.1/_test" rel="external">127.0.0.1/_test</a>'),
array('127.0.0.1/!test',
- '<a href="http://127.0.0.1/!test" rel="external">127.0.0.1/!test</a>'),
+ '<a href="http://127.0.0.1/!test" title="http://127.0.0.1/!test" rel="external">127.0.0.1/!test</a>'),
array('127.0.0.1/*test',
- '<a href="http://127.0.0.1/*test" rel="external">127.0.0.1/*test</a>'),
+ '<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="external">127.0.0.1/*test</a>'),
array('127.0.0.1/test%20stuff',
- '<a href="http://127.0.0.1/test%20stuff" rel="external">127.0.0.1/test%20stuff</a>'),
+ '<a href="http://127.0.0.1/test%20stuff" title="http://127.0.0.1/test%20stuff" rel="external">127.0.0.1/test%20stuff</a>'),
array('http://[::1]:99/test.php',
- '<a href="http://[::1]:99/test.php" rel="external">http://[::1]:99/test.php</a>'),
+ '<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="external">http://[::1]:99/test.php</a>'),
array('http://::1/test.php',
- '<a href="http://::1/test.php" rel="external">http://::1/test.php</a>'),
+ '<a href="http://::1/test.php" title="http://::1/test.php" rel="external">http://::1/test.php</a>'),
array('http://::1',
- '<a href="http://::1/" rel="external">http://::1</a>'),
+ '<a href="http://::1/" title="http://::1/" rel="external">http://::1</a>'),
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
- '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>'),
+ '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>'),
array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
- '<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>'),
+ '<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" title="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>'),
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
- '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>'),
+ '<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>'),
array('http://127.0.0.1',
- '<a href="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">http://127.0.0.1</a>'),
array('example.com',
- '<a href="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
array('example.com',
- '<a href="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
array('http://example.com',
- '<a href="http://example.com/" rel="external">http://example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
array('http://example.com.',
- '<a href="http://example.com/" rel="external">http://example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
array('/var/lib/example.so',
'/var/lib/example.so'),
array('example',
'example'),
array('user@example.com',
- '<a href="mailto:user@example.com" rel="external">user@example.com</a>'),
+ '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="external">user@example.com</a>'),
array('user_name+other@example.com',
- '<a href="mailto:user_name+other@example.com" rel="external">user_name+other@example.com</a>'),
+ '<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="external">user_name+other@example.com</a>'),
array('mailto:user@example.com',
- '<a href="mailto:user@example.com" rel="external">mailto:user@example.com</a>'),
+ '<a href="mailto:user@example.com" title="mailto:user@example.com" rel="external">mailto:user@example.com</a>'),
array('mailto:user@example.com?subject=test',
- '<a href="mailto:user@example.com?subject=test" rel="external">mailto:user@example.com?subject=test</a>'),
+ '<a href="mailto:user@example.com?subject=test" title="mailto:user@example.com?subject=test" rel="external">mailto:user@example.com?subject=test</a>'),
+ array('xmpp:user@example.com',
+ '<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="external">xmpp:user@example.com</a>'),
array('#example',
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
array('#example.com',
@@ -98,165 +103,167 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
array('#.net',
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
array('http://example',
- '<a href="http://example/" rel="external">http://example</a>'),
+ '<a href="http://example/" title="http://example/" rel="external">http://example</a>'),
array('http://3xampl3',
- '<a href="http://3xampl3/" rel="external">http://3xampl3</a>'),
+ '<a href="http://3xampl3/" title="http://3xampl3/" rel="external">http://3xampl3</a>'),
array('http://example/',
- '<a href="http://example/" rel="external">http://example/</a>'),
+ '<a href="http://example/" title="http://example/" rel="external">http://example/</a>'),
array('http://example/path',
- '<a href="http://example/path" rel="external">http://example/path</a>'),
+ '<a href="http://example/path" title="http://example/path" rel="external">http://example/path</a>'),
array('http://example.com',
- '<a href="http://example.com/" rel="external">http://example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
array('https://example.com',
- '<a href="https://example.com/" rel="external">https://example.com</a>'),
+ '<a href="https://example.com/" title="https://example.com/" rel="external">https://example.com</a>'),
array('ftp://example.com',
- '<a href="ftp://example.com/" rel="external">ftp://example.com</a>'),
+ '<a href="ftp://example.com/" title="ftp://example.com/" rel="external">ftp://example.com</a>'),
array('ftps://example.com',
- '<a href="ftps://example.com/" rel="external">ftps://example.com</a>'),
+ '<a href="ftps://example.com/" title="ftps://example.com/" rel="external">ftps://example.com</a>'),
array('http://user@example.com',
- '<a href="http://user@example.com/" rel="external">http://user@example.com</a>'),
+ '<a href="http://user@example.com/" title="http://user@example.com/" rel="external">http://user@example.com</a>'),
array('http://user:pass@example.com',
- '<a href="http://user:pass@example.com/" rel="external">http://user:pass@example.com</a>'),
+ '<a href="http://user:pass@example.com/" title="http://user:pass@example.com/" rel="external">http://user:pass@example.com</a>'),
array('http://example.com:8080',
- '<a href="http://example.com:8080/" rel="external">http://example.com:8080</a>'),
+ '<a href="http://example.com:8080/" title="http://example.com:8080/" rel="external">http://example.com:8080</a>'),
array('http://example.com:8080/test.php',
- '<a href="http://example.com:8080/test.php" rel="external">http://example.com:8080/test.php</a>'),
+ '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="external">http://example.com:8080/test.php</a>'),
array('example.com:8080/test.php',
- '<a href="http://example.com:8080/test.php" rel="external">example.com:8080/test.php</a>'),
+ '<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="external">example.com:8080/test.php</a>'),
array('http://www.example.com',
- '<a href="http://www.example.com/" rel="external">http://www.example.com</a>'),
+ '<a href="http://www.example.com/" title="http://www.example.com/" rel="external">http://www.example.com</a>'),
array('http://example.com/',
- '<a href="http://example.com/" rel="external">http://example.com/</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com/</a>'),
array('http://example.com/path',
- '<a href="http://example.com/path" rel="external">http://example.com/path</a>'),
+ '<a href="http://example.com/path" title="http://example.com/path" rel="external">http://example.com/path</a>'),
array('http://example.com/path.html',
- '<a href="http://example.com/path.html" rel="external">http://example.com/path.html</a>'),
+ '<a href="http://example.com/path.html" title="http://example.com/path.html" rel="external">http://example.com/path.html</a>'),
array('http://example.com/path.html#fragment',
- '<a href="http://example.com/path.html#fragment" rel="external">http://example.com/path.html#fragment</a>'),
+ '<a href="http://example.com/path.html#fragment" title="http://example.com/path.html#fragment" rel="external">http://example.com/path.html#fragment</a>'),
array('http://example.com/path.php?foo=bar&bar=foo',
- '<a href="http://example.com/path.php?foo=bar&amp;bar=foo" rel="external">http://example.com/path.php?foo=bar&amp;bar=foo</a>'),
+ '<a href="http://example.com/path.php?foo=bar&amp;bar=foo" title="http://example.com/path.php?foo=bar&amp;bar=foo" rel="external">http://example.com/path.php?foo=bar&amp;bar=foo</a>'),
array('http://example.com.',
- '<a href="http://example.com/" rel="external">http://example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
array('http://müllärör.de',
- '<a href="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" rel="external">http://müllärör.de</a>'),
+ '<a href="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" title="http://m&#xFC;ll&#xE4;r&#xF6;r.de/" rel="external">http://müllärör.de</a>'),
array('http://ﺱﺲﺷ.com',
- '<a href="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" rel="external">http://ﺱﺲﺷ.com</a>'),
+ '<a href="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" title="http://&#xFEB1;&#xFEB2;&#xFEB7;.com/" rel="external">http://ﺱﺲﺷ.com</a>'),
array('http://сделаткартинки.com',
- '<a href="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" rel="external">http://сделаткартинки.com</a>'),
+ '<a href="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" title="http://&#x441;&#x434;&#x435;&#x43B;&#x430;&#x442;&#x43A;&#x430;&#x440;&#x442;&#x438;&#x43D;&#x43A;&#x438;.com/" rel="external">http://сделаткартинки.com</a>'),
array('http://tūdaliņ.lv',
- '<a href="http://t&#x16B;dali&#x146;.lv/" rel="external">http://tūdaliņ.lv</a>'),
+ '<a href="http://t&#x16B;dali&#x146;.lv/" title="http://t&#x16B;dali&#x146;.lv/" rel="external">http://tūdaliņ.lv</a>'),
array('http://brændendekærlighed.com',
- '<a href="http://br&#xE6;ndendek&#xE6;rlighed.com/" rel="external">http://brændendekærlighed.com</a>'),
+ '<a href="http://br&#xE6;ndendek&#xE6;rlighed.com/" title="http://br&#xE6;ndendek&#xE6;rlighed.com/" rel="external">http://brændendekærlighed.com</a>'),
array('http://あーるいん.com',
- '<a href="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" rel="external">http://あーるいん.com</a>'),
+ '<a href="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" title="http://&#x3042;&#x30FC;&#x308B;&#x3044;&#x3093;.com/" rel="external">http://あーるいん.com</a>'),
array('http://예비교사.com',
- '<a href="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" rel="external">http://예비교사.com</a>'),
+ '<a href="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" title="http://&#xC608;&#xBE44;&#xAD50;&#xC0AC;.com/" rel="external">http://예비교사.com</a>'),
array('http://example.com.',
- '<a href="http://example.com/" rel="external">http://example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>.'),
array('http://example.com?',
- '<a href="http://example.com/" rel="external">http://example.com</a>?'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>?'),
array('http://example.com!',
- '<a href="http://example.com/" rel="external">http://example.com</a>!'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>!'),
array('http://example.com,',
- '<a href="http://example.com/" rel="external">http://example.com</a>,'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>,'),
array('http://example.com;',
- '<a href="http://example.com/" rel="external">http://example.com</a>;'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>;'),
array('http://example.com:',
- '<a href="http://example.com/" rel="external">http://example.com</a>:'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>:'),
array('\'http://example.com\'',
- '\'<a href="http://example.com/" rel="external">http://example.com</a>\''),
+ '\'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>\''),
array('"http://example.com"',
- '&quot;<a href="http://example.com/" rel="external">http://example.com</a>&quot;'),
+ '&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>&quot;'),
+ array('"http://example.com/"',
+ '&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com/</a>&quot;'),
array('http://example.com',
- '<a href="http://example.com/" rel="external">http://example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
array('(http://example.com)',
- '(<a href="http://example.com/" rel="external">http://example.com</a>)'),
+ '(<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>)'),
array('[http://example.com]',
- '[<a href="http://example.com/" rel="external">http://example.com</a>]'),
+ '[<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>]'),
array('<http://example.com>',
- '&lt;<a href="http://example.com/" rel="external">http://example.com</a>&gt;'),
+ '&lt;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>&gt;'),
array('http://example.com/path/(foo)/bar',
- '<a href="http://example.com/path/(foo)/bar" rel="external">http://example.com/path/(foo)/bar</a>'),
+ '<a href="http://example.com/path/(foo)/bar" title="http://example.com/path/(foo)/bar" rel="external">http://example.com/path/(foo)/bar</a>'),
array('http://example.com/path/[foo]/bar',
- '<a href="http://example.com/path/[foo]/bar" rel="external">http://example.com/path/[foo]/bar</a>'),
+ '<a href="http://example.com/path/[foo]/bar" title="http://example.com/path/[foo]/bar" rel="external">http://example.com/path/[foo]/bar</a>'),
array('http://example.com/path/foo/(bar)',
- '<a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>'),
+ '<a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>'),
//Not a valid url - urls cannot contain unencoded square brackets
array('http://example.com/path/foo/[bar]',
- '<a href="http://example.com/path/foo/[bar]" rel="external">http://example.com/path/foo/[bar]</a>'),
+ '<a href="http://example.com/path/foo/[bar]" title="http://example.com/path/foo/[bar]" rel="external">http://example.com/path/foo/[bar]</a>'),
array('Hey, check out my cool site http://example.com okay?',
- 'Hey, check out my cool site <a href="http://example.com/" rel="external">http://example.com</a> okay?'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a> okay?'),
array('What about parens (e.g. http://example.com/path/foo/(bar))?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)?'),
array('What about parens (e.g. http://example.com/path/foo/(bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>?'),
array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>.)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>.)?'),
//Not a valid url - urls cannot contain unencoded commas
array('What about parens (e.g. http://example.com/path/(foo,bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" rel="external">http://example.com/path/(foo,bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="external">http://example.com/path/(foo,bar)</a>?'),
array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/((((foo)/bar)" rel="external">http://example.com/path/((((foo)/bar)</a>?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/((((foo)/bar)" title="http://example.com/path/((((foo)/bar)" rel="external">http://example.com/path/((((foo)/bar)</a>?'),
array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/(foo))))/bar" rel="external">http://example.com/path/(foo))))/bar</a>)?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/(foo))))/bar" title="http://example.com/path/(foo))))/bar" rel="external">http://example.com/path/(foo))))/bar</a>)?'),
array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/foo/((((bar)" rel="external">http://example.com/path/foo/((((bar)</a>?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/foo/((((bar)" title="http://example.com/path/foo/((((bar)" rel="external">http://example.com/path/foo/((((bar)</a>?'),
array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
- 'Unbalanced too (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)))?'),
+ 'Unbalanced too (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">http://example.com/path/foo/(bar)</a>)))?'),
array('example.com',
- '<a href="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
array('example.org',
- '<a href="http://example.org/" rel="external">example.org</a>'),
+ '<a href="http://example.org/" title="http://example.org/" rel="external">example.org</a>'),
array('example.co.uk',
- '<a href="http://example.co.uk/" rel="external">example.co.uk</a>'),
+ '<a href="http://example.co.uk/" title="http://example.co.uk/" rel="external">example.co.uk</a>'),
array('www.example.co.uk',
- '<a href="http://www.example.co.uk/" rel="external">www.example.co.uk</a>'),
+ '<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="external">www.example.co.uk</a>'),
array('farm1.images.example.co.uk',
- '<a href="http://farm1.images.example.co.uk/" rel="external">farm1.images.example.co.uk</a>'),
+ '<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="external">farm1.images.example.co.uk</a>'),
array('example.museum',
- '<a href="http://example.museum/" rel="external">example.museum</a>'),
+ '<a href="http://example.museum/" title="http://example.museum/" rel="external">example.museum</a>'),
array('example.travel',
- '<a href="http://example.travel/" rel="external">example.travel</a>'),
+ '<a href="http://example.travel/" title="http://example.travel/" rel="external">example.travel</a>'),
array('example.com.',
- '<a href="http://example.com/" rel="external">example.com</a>.'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.'),
array('example.com?',
- '<a href="http://example.com/" rel="external">example.com</a>?'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>?'),
array('example.com!',
- '<a href="http://example.com/" rel="external">example.com</a>!'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>!'),
array('example.com,',
- '<a href="http://example.com/" rel="external">example.com</a>,'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>,'),
array('example.com;',
- '<a href="http://example.com/" rel="external">example.com</a>;'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>;'),
array('example.com:',
- '<a href="http://example.com/" rel="external">example.com</a>:'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>:'),
array('\'example.com\'',
- '\'<a href="http://example.com/" rel="external">example.com</a>\''),
+ '\'<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>\''),
array('"example.com"',
- '&quot;<a href="http://example.com/" rel="external">example.com</a>&quot;'),
+ '&quot;<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>&quot;'),
array('example.com',
- '<a href="http://example.com/" rel="external">example.com</a>'),
+ '<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>'),
array('(example.com)',
- '(<a href="http://example.com/" rel="external">example.com</a>)'),
+ '(<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>)'),
array('[example.com]',
- '[<a href="http://example.com/" rel="external">example.com</a>]'),
+ '[<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>]'),
array('<example.com>',
- '&lt;<a href="http://example.com/" rel="external">example.com</a>&gt;'),
+ '&lt;<a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>&gt;'),
array('Hey, check out my cool site example.com okay?',
- 'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a> okay?'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a> okay?'),
array('Hey, check out my cool site example.com.I made it.',
- 'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a>.I made it.'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.I made it.'),
array('Hey, check out my cool site example.com.Funny thing...',
- 'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a>.Funny thing...'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.Funny thing...'),
array('Hey, check out my cool site example.com.You will love it.',
- 'Hey, check out my cool site <a href="http://example.com/" rel="external">example.com</a>.You will love it.'),
+ 'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="external">example.com</a>.You will love it.'),
array('What about parens (e.g. example.com/path/foo/(bar))?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>)?'),
array('What about parens (e.g. example.com/path/foo/(bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>?'),
array('What about parens (e.g. example.com/path/foo/(bar).)?',
- 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>.)?'),
+ 'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="external">example.com/path/foo/(bar)</a>.)?'),
array('What about parens (e.g. example.com/path/(foo,bar)?',
- 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" rel="external">example.com/path/(foo,bar)</a>?'),
+ 'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="external">example.com/path/(foo,bar)</a>?'),
array('file.ext',
'file.ext'),
array('file.html',
diff --git a/tests/UserRightsTest.php b/tests/UserRightsTest.php
new file mode 100644
index 000000000..6544ee53d
--- /dev/null
+++ b/tests/UserRightsTest.php
@@ -0,0 +1,59 @@
+<?php
+
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+ print "This script must be run from the command line\n";
+ exit();
+}
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('STATUSNET', true);
+
+require_once INSTALLDIR . '/lib/common.php';
+
+class UserRightsTest extends PHPUnit_Framework_TestCase
+{
+ protected $user = null;
+
+ function setUp()
+ {
+ $this->user = User::register(array('nickname' => 'userrightstestuser'));
+ }
+
+ function tearDown()
+ {
+ $profile = $this->user->getProfile();
+ $this->user->delete();
+ $profile->delete();
+ }
+
+ function testInvalidRole()
+ {
+ $this->assertFalse($this->user->hasRole('invalidrole'));
+ }
+
+ function standardRoles()
+ {
+ return array('admin', 'moderator');
+ }
+
+ /**
+ * @dataProvider standardRoles
+ *
+ */
+
+ function testUngrantedRole($role)
+ {
+ $this->assertFalse($this->user->hasRole($role));
+ }
+
+ /**
+ * @dataProvider standardRoles
+ *
+ */
+
+ function testGrantedRole($role)
+ {
+ $this->user->grantRole($role);
+ $this->assertFalse($this->user->hasRole($role));
+ }
+} \ No newline at end of file
diff --git a/theme/base/css/display.css b/theme/base/css/display.css
index 7706fba48..c8aafe489 100644
--- a/theme/base/css/display.css
+++ b/theme/base/css/display.css
@@ -251,7 +251,7 @@ margin-right:18px;
margin-bottom:11px;
margin-left:18px;
}
-#site_nav_global_primary ul li {
+#site_nav_global_primary li {
display:inline;
margin-left:11px;
}
@@ -468,16 +468,15 @@ margin-bottom:7px;
#form_notice #notice_data-attach {
position:absolute;
top:25px;
+right:10.5%;
cursor:pointer;
}
#form_notice label[for=notice_data-attach] {
text-indent:-9999px;
-left:86%;
width:16px;
height:16px;
}
#form_notice #notice_data-attach {
-left:40.6%;
padding:0;
height:16px;
}
@@ -1296,3 +1295,13 @@ display:none;
.guide {
clear:both;
}
+
+#bookmarklet address {
+display:none;
+}
+#bookmarklet #form_notice {
+width:auto;
+}
+#bookmarklet #wrap {
+min-width:0;
+}
diff --git a/theme/base/images/icons/icons-01.png b/theme/base/images/icons/icons-01.png
new file mode 100644
index 000000000..c4e371330
--- /dev/null
+++ b/theme/base/images/icons/icons-01.png
Binary files differ
diff --git a/theme/default/css/display.css b/theme/default/css/display.css
index 86369cb99..a5f1fd6e4 100644
--- a/theme/default/css/display.css
+++ b/theme/default/css/display.css
@@ -18,7 +18,7 @@ font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size:1em;
}
address {
-margin-right:7.2%;
+margin-right:5.7%;
}
input, textarea, select, option {
@@ -88,7 +88,7 @@ color:#333333;
color:#000000;
}
#form_notice label[for=notice_data-attach] {
-background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -328px;
}
#form_notice #notice_data-attach {
opacity:0;
@@ -150,16 +150,18 @@ background-color:#9BB43E;
#export_data li a {
background-repeat:no-repeat;
-background-position:0 45%;
}
#export_data li a.rss {
-background-image:url(../../base/images/icons/icon_rss.png);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:0 -130px;
}
#export_data li a.atom {
-background-image:url(../../base/images/icons/icon_atom.png);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:0 -64px;
}
#export_data li a.foaf {
-background-image:url(../../base/images/icons/icon_foaf.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:0 1px;
}
.entity_edit a,
@@ -171,7 +173,6 @@ background-image:url(../../base/images/icons/icon_foaf.gif);
.form_group_unblock input.submit,
.entity_nudge p,
.form_make_admin input.submit {
-background-position: 0 40%;
background-repeat: no-repeat;
background-color:transparent;
}
@@ -189,43 +190,48 @@ background-color:#87B4C8;
}
.entity_edit a {
-background-image:url(../../base/images/icons/twotone/green/edit.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -718px;
}
.entity_send-a-message a {
-background-image:url(../../base/images/icons/twotone/green/quote.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -849px;
}
.entity_nudge p,
.form_user_nudge input.submit {
-background-image:url(../../base/images/icons/twotone/green/mail.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -785px;
}
.form_user_block input.submit,
.form_user_unblock input.submit,
.form_group_block input.submit,
.form_group_unblock input.submit {
-background-image:url(../../base/images/icons/twotone/green/shield.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -918px;
}
.form_make_admin input.submit {
-background-image:url(../../base/images/icons/twotone/green/admin.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -983px;
}
/* NOTICES */
.notice .attachment {
-background:transparent url(../../base/images/icons/twotone/green/clip-02.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -394px;
}
#attachments .attachment {
background:none;
}
.notice-options .notice_reply {
-background:transparent url(../../base/images/icons/twotone/green/reply.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -589px;
}
.notice-options form.form_favor input.submit {
-background:transparent url(../../base/images/icons/twotone/green/favourite.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -457px;
}
.notice-options form.form_disfavor input.submit {
-background:transparent url(../../base/images/icons/twotone/green/disfavourite.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -523px;
}
.notice-options .notice_delete {
-background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -655px;
}
.notices div.entry-content,
@@ -262,7 +268,7 @@ background-color:rgba(200, 200, 200, 0.300);
/*END: NOTICES */
#new_group a {
-background:transparent url(../../base/images/icons/twotone/green/news.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -1054px;
}
.pagination .nav_prev a,
@@ -271,10 +277,10 @@ background-repeat:no-repeat;
border-color:#C8D1D5;
}
.pagination .nav_prev a {
-background-image:url(../../base/images/icons/twotone/green/arrow-left.gif);
-background-position:10% 45%;
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:10% -187px;
}
.pagination .nav_next a {
-background-image:url(../../base/images/icons/twotone/green/arrow-right.gif);
-background-position:90% 45%;
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:105% -252px;
}
diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css
index 9fc97180d..6339c9314 100644
--- a/theme/identica/css/display.css
+++ b/theme/identica/css/display.css
@@ -88,7 +88,7 @@ color:#333333;
color:#000000;
}
#form_notice label[for=notice_data-attach] {
-background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -328px;
}
#form_notice #notice_data-attach {
opacity:0;
@@ -150,16 +150,18 @@ background-color:#9BB43E;
#export_data li a {
background-repeat:no-repeat;
-background-position:0 45%;
}
#export_data li a.rss {
-background-image:url(../../base/images/icons/icon_rss.png);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:0 -130px;
}
#export_data li a.atom {
-background-image:url(../../base/images/icons/icon_atom.png);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:0 -64px;
}
#export_data li a.foaf {
-background-image:url(../../base/images/icons/icon_foaf.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:0 1px;
}
.entity_edit a,
@@ -171,7 +173,6 @@ background-image:url(../../base/images/icons/icon_foaf.gif);
.form_group_unblock input.submit,
.entity_nudge p,
.form_make_admin input.submit {
-background-position: 0 40%;
background-repeat: no-repeat;
background-color:transparent;
}
@@ -189,43 +190,48 @@ background-color:#87B4C8;
}
.entity_edit a {
-background-image:url(../../base/images/icons/twotone/green/edit.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -718px;
}
.entity_send-a-message a {
-background-image:url(../../base/images/icons/twotone/green/quote.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -849px;
}
.entity_nudge p,
.form_user_nudge input.submit {
-background-image:url(../../base/images/icons/twotone/green/mail.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -785px;
}
.form_user_block input.submit,
.form_user_unblock input.submit,
.form_group_block input.submit,
.form_group_unblock input.submit {
-background-image:url(../../base/images/icons/twotone/green/shield.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -918px;
}
.form_make_admin input.submit {
-background-image:url(../../base/images/icons/twotone/green/admin.gif);
+background-image:url(../../base/images/icons/icons-01.png);
+background-position: 0 -983px;
}
/* NOTICES */
.notice .attachment {
-background:transparent url(../../base/images/icons/twotone/green/clip-02.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -394px;
}
#attachments .attachment {
background:none;
}
.notice-options .notice_reply {
-background:transparent url(../../base/images/icons/twotone/green/reply.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -589px;
}
.notice-options form.form_favor input.submit {
-background:transparent url(../../base/images/icons/twotone/green/favourite.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -457px;
}
.notice-options form.form_disfavor input.submit {
-background:transparent url(../../base/images/icons/twotone/green/disfavourite.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -523px;
}
.notice-options .notice_delete {
-background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -655px;
}
.notices div.entry-content,
@@ -262,7 +268,7 @@ background-color:rgba(200, 200, 200, 0.300);
/*END: NOTICES */
#new_group a {
-background:transparent url(../../base/images/icons/twotone/green/news.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -1054px;
}
.pagination .nav_prev a,
@@ -271,10 +277,10 @@ background-repeat:no-repeat;
border-color:#CEE1E9;
}
.pagination .nav_prev a {
-background-image:url(../../base/images/icons/twotone/green/arrow-left.gif);
-background-position:10% 45%;
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:10% -187px;
}
.pagination .nav_next a {
-background-image:url(../../base/images/icons/twotone/green/arrow-right.gif);
-background-position:90% 45%;
+background-image:url(../../base/images/icons/icons-01.png);
+background-position:105% -252px;
}
diff --git a/theme/identica/css/ie.css b/theme/identica/css/ie.css
index 97cabc30a..044c32ff1 100644
--- a/theme/identica/css/ie.css
+++ b/theme/identica/css/ie.css
@@ -7,8 +7,14 @@ color:#FFFFFF;
background-color:#D9DADB;
}
#form_notice .form_note + label {
-background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%;
+background:transparent url(../../base/images/icons/icons-01.png) no-repeat 0 -328px;
}
#form_notice #notice_data-attach {
filter: alpha(opacity=0);
}
+.notice-options form.form_favor input.submit {
+background-position:0 -460px;
+}
+.notice-options form.form_disfavor input.submit {
+background-position:0 -526px;
+}
diff --git a/theme/iphone/bg-body.gif b/theme/iphone/bg-body.gif
deleted file mode 100644
index d87e2e8d7..000000000
--- a/theme/iphone/bg-body.gif
+++ /dev/null
Binary files differ
diff --git a/theme/iphone/bg-header.gif b/theme/iphone/bg-header.gif
deleted file mode 100644
index 5154b2e5e..000000000
--- a/theme/iphone/bg-header.gif
+++ /dev/null
Binary files differ
diff --git a/theme/iphone/default-avatar-mini.png b/theme/iphone/default-avatar-mini.png
deleted file mode 100644
index 38b8692b4..000000000
--- a/theme/iphone/default-avatar-mini.png
+++ /dev/null
Binary files differ
diff --git a/theme/iphone/default-avatar-profile.png b/theme/iphone/default-avatar-profile.png
deleted file mode 100644
index f8357d4fc..000000000
--- a/theme/iphone/default-avatar-profile.png
+++ /dev/null
Binary files differ
diff --git a/theme/iphone/default-avatar-stream.png b/theme/iphone/default-avatar-stream.png
deleted file mode 100644
index 6b63baa70..000000000
--- a/theme/iphone/default-avatar-stream.png
+++ /dev/null
Binary files differ
diff --git a/theme/iphone/display.css b/theme/iphone/display.css
deleted file mode 100644
index 1838a8e86..000000000
--- a/theme/iphone/display.css
+++ /dev/null
@@ -1,698 +0,0 @@
-/* CSS Document */
-/* Design & CSS by Marie-Claude Doyon http://www.marieclaudedoyon.com */
-/* Simplified for mobile by Ken Sheppardson http://identi.ca/kshep */
-
-@import url(../../base/css/display.css);
-
-html {}
-body {
- width: 100%;
- padding: 0;
- margin: 0;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 24px;
- min-height: 100%;
- height: 100%;
- color: #193441;
-}
-
-a {
- color: #C15D42;
- text-decoration: none;
-}
-a:hover {
- text-decoration: underline;
-}
-img, img a {
- border: 0;
-}
-h1 {
- font-size: 1.2em;
-}
-
-#wrap {
- margin: 0;
-}
-
-#header {
- width: 100%;
- float: left;
- background-color: #193441;
- margin: 0 0 20px 0;
- padding: 0;
-}
-#logo {
- float: left;
- margin: 10px 0px 0px 10px;
-}
-p#branding {
- margin: 0;
- padding: 6px 0 3px 0;
- color: #fbf2d7;
- font-size: 2em;
- font-weight: bold;
- line-height: 2.5em;
-}
-p#branding a {
- color: #dab134;
-}
-
-#header h1.pagetitle {
- display: none;
- margin: 0;
- padding: 0;
- font-size: 1.2em;
- line-height: 2em;
- color: #d8e2d7;
-}
-
-#header h2.sitename {
- display: none;
- margin: 0;
- padding: 0;
- color: #FCFFF5;
-}
-
-/* ===== Begin Navigation Styling ===== */
-
-/* ----- Navigation ------ */
-#nav {
- float: right;
- margin: 0;
- padding: 0;
- list-style-type: none;
- font-size: 1.2em;
-}
-#nav li {
- display: block;
- float: left;
-}
-#nav li a {
- display: block;
- padding: 9px 15px 12px 0px;
- color: #91AA9D;
-}
-#nav li a:hover {
- text-decoration: underline;
-}
-
-/* ----- Tabs ----- */
-#nav_views {
- clear: both;
- float: left;
- margin: 10px 0px 0px 5px;
- padding: 0;
- bottom: 0;
- list-style-type: none;
- font-size: 1.1em;
- font-weight: bold;
-}
-#nav_views li {
- display: block;
- float: left;
- line-height: 1.3em;
-}
-#nav_views li a {
- display: block;
- margin: 0;
- padding: 4px 12px 3px 12px;
- color: #FCFFF5;
- background-color: #91AA9D;
- border-right: 1px solid #6A8787;
-}
-#nav_views li a:hover {
- text-decoration: none;
-}
-#nav_views li.current a, #nav_views li.current a:hover {
- color: #3F606F;
- background-color: #FCFFF5;
- border-right: 1px solid #6A8787;
-}
-#nav_views li.current a:hover {
- color: #193441;
-}
-#nav_views li a:hover {
- color: #FCFFF5;
- background-color: #3F606F;
- border-right: 1px solid #6A8787;
-}
-
-/* ----- Nav Footer ----- */
-#nav_sub {
- clear: both;
- margin: 18px 10px 0 10px;
- padding: 0;
- list-style-type: none;
- font-size: 1.1em;
- font-weight: bold;
- line-height: 2em;
- border-top: 1px solid #D8E2D7;
-}
-#nav_sub li {
- display: block;
- float: left;
-}
-#nav_sub li a {
- padding: 6px 24px 6px 0;
-}
-#nav_sub li a:hover {
- text-decoration: underline;
-}
-/* ===== End Navigation Styling ===== */
-
-#content {
- clear: left;
- margin: 10px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 1em;
- line-height: 1.1em;
-}
-#content h2 {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 1.1em;
-}
-#content label {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 1.1em;
-}
-
-.instructions {
- clear: both;
- float: left;
- margin: 5px 5px 10px 5px;
-}
-.instructions p, .success, .error {
- font-weight: normal;
- margin: 0;
- padding: 10px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 1.1em;
- line-height: 1.2em;
- border: 1px solid #91AA9D;
- color: #FCFFF5;
-}
-.instructions a, .success a, .error a {
- color: #d8e2d7;
- text-decoration: underline;
-}
-.instructions a:hover, .success a:hover, .error a:hover {
- color: #FCFFF5;
-}
-.success {
- clear: both;
- float: left;
- margin: 5px 5px 10px 5px;
- background-color: #48705b;
-}
-.error {
- clear: both;
- float: left;
- margin: 5px 5px 10px 5px;
- background-color: #ce3728;
-}
-
-/* ----- Stream -----*/
-
-#notices {
- clear: both;
- margin: 0 auto;
- padding: 0;
- list-style-type: none;
- border-top: 1px solid #D8E2D7;
-}
-#notices a:hover {
- text-decoration: underline;
-}
-.notice_single {
- clear: both;
- display: block;
- margin: 0;
- padding: 5px 5px 5px 0;
- min-height: 48px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 1em;
- line-height: 1.4em;
- border-bottom: 1px solid #D8E2D7;
-}
-.notice_single:hover {
- background-color: #F3F8EA;
-}
-.notice_single p {
- display: inline;
- margin: 0;
- padding: 0;
-}
-#notice_delete_form #confirmation_text {
- display: block;
- font-size: 1.1em;
- font-weight: bold;
-}
-input#submit_yes, input#submit_no {
- margin: 18px 10px 0px 0px;
- padding: 4px;
- font-weight: bold;
- color: #FCFFF5;
- background-color: #C15D42;
- cursor: pointer;
- border: 0;
- width: 40px;
-}
-input#submit_yes:hover, input#submit_no:hover {
- background-color: #904632;
-}
-.avatar.stream {
- float: left;
- margin: 0 10px 0 0;
-}
-p.time {
- display: block;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 0.9em;
- line-height: 2em;
-}
-p.time a {
- color: #91AA9D;
-}
-
-/* ----- Profile -----*/
-#profile {
- clear: both;
- float: left;
- padding: 10px 0 0 0;
- border-top: 1px solid #D8E2D7;
- font-family: Georgia, "Times New Roman", Times, serif;
-}
-#profile h1 {
- clear: both;
- float: left;
- margin: 0;
- padding: 0;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 1.2em;
-}
-#profile h2 {
- clear: both;
- float: left;
- margin: 0;
- padding: 1em 0 0.2em 0;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 1.1em;
- text-transform: uppercase;
- color: #91AA9D;
-}
-#profile p {
- clear: both;
- float: left;
- margin: 0 10px 0 0;
- font-size: 1em;
- line-height: 1.4em;
-}
-#profile p.location {
- margin: 0 10px 12px 0;
- font-style: italic;
-}
-#profile p.notice_current {
- font-size: 1.2em;
- line-height: 1.3em;
-}
-#profile_avatar {
- float: left;
- margin-right: 4px;
-}
-#profile_avatar img {
- margin-bottom: 5px;
-}
-.avatar.profile {
- clear: left;
- margin: 0 10px 5px 0;
-}
-.avatar.original {
- float: left;
- margin: 0 10px 18px 0;
-}
-a.nickname {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight: bold;
- font-size: 1.1em;
- padding-right: 3px;
-}
-#profile_information {
- float: left;
-}
-
-.statistics {
- clear: both;
- float: left;
-}
-.statistics h2 {
- clear: both;
- float: left;
- margin: 12px 0 3px 0;
-}
-dl.statistics {
- margin: 0;
-}
-.statistics dt {
- clear: left;
- float: left;
- width: 200px;
-}
-.statistics dd {
- float: left;
-}
-.statistics dt:after {
- content: ":";
-}
-#subscriptions {
- clear: both;
- float: left;
- margin: 18px 0 30px 0;
-}
-#subscriptions_avatars {
- clear: both;
- float: left;
- margin: 6px 0 0 0;
- padding: 0;
- list-style-type: none;
-}
-#subscriptions_avatars li .avatar.mini {
- float: left;
- margin: 0 3px 3px 0;
- padding: 0;
- line-height: 0;
-}
-#subscriptions_viewall {
- clear: left;
-}
-/* ----- End Profile -----*/
-
-/* ----- Begin Subscriptions & Subscribers -----*/
-
-ul.subscriptions, ul.subscribers {
- float: none;
- margin: 0;
- padding: 0;
- list-style-type: none;
- overflow: auto;
-}
-ul.subscriptions li, ul.subscribers li {
- display: block;
- float: left;
- padding: 0;
-}
-/* ----- End Subscriptions & Subscribers -----*/
-
-#pagination {
- margin: 18px auto;
-}
-#nav_pagination {
- margin: 0 0 36px 0;
- padding: 0;
- float: right;
- list-style-type: none;
- font-size: 12px;
- font-weight: bold;
-}
-#nav_pagination li {
- display: block;
- float: left;
- background-color: #91AA9D;
-}
-#nav_pagination li.before {
- margin-right: 1px;
-}
-#nav_pagination li a {
- padding: 6px 15px;
- line-height: 2em;
- background-color: #91AA9D;
- color: #FCFFF5;
-}
-#nav_pagination li a:hover {
- background-color: #3F606F;
- color: #FCFFF5;
- text-decoration: none;
-}
-
-#footer {
- clear: both;
- margin: 10px;
- border-top: 1px solid #D8E2D7;
-}
-#footer p {
- font-size: 0.8em;
- margin-top: 1em;
- line-height: 1.2em;
-}
-#cc {
- float: left;
- margin: 3px 10px 0 0;
-}
-
-/* ===== Begin Forms Styling ===== */
-
-/* ----- Forms General Style ----- */
-form {
- margin: 0 auto;
- padding: 0;
-}
-form {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 1em;
-}
-form label {
- display: block;
- font-size: 1em;
- font-weight: bold;
- line-height: 1.5em;
-}
-form input {
- border: 1px solid #D8E2D7;
- width: 264px;
-}
-input#submit, input.submit {
- display: block;
- margin: 18px 0;
- padding: 4px;
- font-weight: bold;
- color: #FCFFF5;
- background-color: #C15D42;
- cursor: pointer;
- border: 0;
- width: auto;
-}
-input#submit:hover, input.submit:hover {
- background-color: #904632;
-}
-input.checkbox {
- width: auto;
- border: 0;
-}
-textarea, input {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 1em;
- color: #193441;
- padding: 3px;
-}
-textarea:focus, input:focus {
- background-color: #f0f6eb;
-}
-textarea {
- width: 270px;
- border: 1px solid #D8E2D7;
-}
-.input_instructions {
- margin-top: 3px;
- display: block;
- font-size: 1em;
- line-height: 1.2em;
- color: #91aa9d;
- font-family: Verdana, Arial, Helvetica, sans-serif;
-}
-
-/* ----- Status Form ----- */
-#status_form {
- width: 100%;
- margin: 0px 0px 10px 5px;
-}
-#status_form p {
- margin: 0;
- padding: 0;
-}
-#status_label {
- display: none;
- clear: both;
- margin: 0;
- padding: 0 0 3px 0;
- font-size: 1.5em;
- font-weight: bold;
- line-height: 2em;
- color: #91AA9D;
-}
-#status_textarea {
- display: block;
- float: left;
- width: 70%;
- height: 3em;
- margin: 0 0 10px 0;
- padding: 0;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 1.1em;
- color: #193441;
- border: 0;
-}
-#status_submit {
- display: block;
- float: left;
- margin: 0 0 0 4px;
- padding: 1em 10px 1em 10px;
- line-height: 1em;
- width: 10%;
- background-color: #C15D42;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight: bold;
- font-size: 1em;
- color: #FCFFF5;
- cursor: pointer;
- border: 0;
-}
-#status_submit:hover {
- background-color: #904632;
-}
-#counter {
- padding: 1em .5em 1em 5px;
- color: #fff;
- clear: both;
- float: left;
- font-weight: bold;
- text-align: right;
-}
-/* ----- Subscribe Form ----- */
-#subscribe .submit, #unsubscribe .submit, #remotesubscribe .button, #remotesubscribe {
- clear: left;
- margin: 0;
- width: 96px;
- height: 27px;
- font-family: verdana, arial, helvetica, sans-serif;
- font-weight: bold;
- font-size: 12px;
- text-transform: uppercase;
- background-color: #c15d42;
- color: #fcfff5;
- border: 0;
-}
-#remotesubscribe {
- width: 96px;
- height: 22px;
- padding: 5px 0 0 0;
- text-align: center;
-}
-#subscribe .button:hover, #unsubscribe .button:hover {
- background-color: #904632;
- cursor: pointer;
-}
-
-a#remotesubscribe {
- display: block;
-}
-
-/* ----- Login Form -----*/
-input#license {
- width: auto;
- border: 0;
-}
-/* ----- Avatar Form -----*/
-form {
- clear: left;
-}
-
-/* ----- OpenID Form -----*/
-
-input#openid_url {
- background: url(login-bg.gif) no-repeat;
- background-color: #fff;
- background-position: 4px 50%;
- color: #000;
- padding-left: 24px;
-}
-
-/* People lists (search results, maybe subscribers) */
-
-#profiles {
- clear: both;
- margin: 0 auto;
- padding: 0;
- list-style-type: none;
- border-top: 1px solid #D8E2D7;
-}
-#profiles a:hover {
- text-decoration: underline;
-}
-
-.profile_single {
- clear: both;
- display: block;
- margin: 0;
- padding: 5px 5px 5px 0;
- min-height: 48px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 1.2em;
- line-height: 1.4em;
- border-bottom: 1px solid #D8E2D7;
-}
-.profile_single:hover {
- background-color: #F3F8EA;
-}
-
-/* ----- IM Settings Form -----*/
-
-#imsettings p {
- margin: 0;
- padding: 0;
- line-height: 1.3em;
-}
-
-/* ===== End Forms Styling ===== */
-
-/* ===== Tag Cloud Styling ===== */
-
-p.tagcloud {
-text-align: center;
-}
-
-p.tagcloud a {
-line-height:1em;
-vertical-align:middle;
-}
-
-p.tagcloud a.largest {
-font-size: 4em;
-}
-p.tagcloud a.verylarge {
-font-size: 3em;
-}
-
-p.tagcloud a.large {
-font-size: 2em;
-}
-
-p.tagcloud a.medium {
-font-size: 1.5em;
-}
-
-p.tagcloud a.small {
-font-size: 1em;
-}
-
-p.tagcloud a.verysmall {
-font-size: 80%;
-}
-
-p.tagcloud a.smallest {
-font-size: 60%;
-}
-
-a.replybutton {
- border: 1px solid #D8E2D7;
- padding: 0px 10px 0px 10px;
- line-height: 0.8em;
-}
diff --git a/theme/iphone/display.css.dist b/theme/iphone/display.css.dist
deleted file mode 100644
index 395da2e2f..000000000
--- a/theme/iphone/display.css.dist
+++ /dev/null
@@ -1,686 +0,0 @@
-/* CSS Document */
-/* Design & CSS by Marie-Claude Doyon http://www.marieclaudedoyon.com */
-
-html {
- background: url(bg-body.gif) repeat-y top center #d8e2d7;
- }
-body {
- position: absolute;
- width: 100%;
- margin: 0;
- padding: 0;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 10px;
- line-height: 12px;
- min-height: 100%;
- height: 100%;
- color: #193441;
- }
-a {
- color: #C15D42;
- text-decoration: none;
- }
-a:hover {
- text-decoration: underline;
- }
-img, img a {
- border: 0;
- }
-h1 {
- font-size: 14px;
- }
-
-
-#wrap {
- margin: 0 auto;
- padding: 0 20px;
- width: 760px;
- background: url(bg-header.gif) repeat-x #FCFFF5;
- }
-#header {
- position: relative;
- margin: 0 auto;
- width: 540px;
- height: 216px;
- }
-#logo {
- margin-top: 9px;
- }
-p#branding {
- margin: 0;
- padding: 6px 0 3px 0;
- color: #fbf2d7;
- font-size: 21px;
- font-weight: bold;
- line-height: 27px;
- }
-p#branding a {
- color: #dab134;
- }
-
-#header h1.pagetitle {
- margin: 0;
- padding: 0;
- font-size: 15px;
- line-height: 24px;
- color: #d8e2d7;
-}
-
-#header h2.sitename {
- display: none;
- margin: 0;
- padding: 0;
- color: #FCFFF5;
-}
-
-/* ===== Begin Navigation Styling ===== */
-
-/* ----- Navigation ------ */
-#nav {
- float: right;
- margin: 0;
- padding: 0;
- list-style-type: none;
- font-size: 12px;
- }
-#nav li {
- display: block;
- float: left;
- }
-#nav li a {
- display: block;
- padding: 9px 9px 12px 9px;
- color: #91AA9D;
- }
-#nav li a:hover {
- text-decoration: underline;
- }
-
-/* ----- Tabs ----- */
-#nav_views {
- margin: 0 auto;
- padding: 0;
- position: absolute;
- bottom: 0;
- list-style-type: none;
- font-size: 14px;
- font-weight: bold;
- width: 540px;
- /*height: 30px;*/
- }
-#nav_views li {
- display: block;
- float: left;
- line-height: 21px;
- }
-#nav_views li a {
- display: block;
- margin: 0;
- padding: 4px 12px 3px 12px;
- color: #FCFFF5;
- background-color: #91AA9D;
- border-right: 1px solid #6A8787;
- }
-#nav_views li a:hover {
- text-decoration: none;
- }
-#nav_views li.current a, #nav_views li.current a:hover {
- color: #3F606F;
- background-color: #FCFFF5;
- border-right: 1px solid #6A8787;
- }
-#nav_views li.current a:hover {
- color: #193441;
- }
-#nav_views li a:hover {
- color: #FCFFF5;
- background-color: #3F606F;
- border-right: 1px solid #6A8787;
- }
-
-/* ----- Nav Footer ----- */
-#nav_sub {
- clear: both;
- margin: 18px auto 0 auto;
- padding: 0;
- list-style-type: none;
- font-size: 11px;
- font-weight: bold;
- line-height: 21px;
- border-top: 1px solid #D8E2D7;
- width: 540px;
- }
-#nav_sub li {
- display: block;
- float: left;
- }
-#nav_sub li a {
- padding: 6px 24px 6px 0;
- }
-#nav_sub li a:hover {
- text-decoration: underline;
- }
-/* ===== End Navigation Styling ===== */
-
-#content {
- clear: left;
- margin: 40px 0 45px 0;
- padding: 0 110px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 14px;
- line-height: 18px;
- }
-#content h2 {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 15px;
- }
-#content label {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 12px;
- }
-.instructions p, .success, .error {
- font-weight: normal;
- margin: 36px 0 0 0;
- padding: 10px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 13px;
- line-height: 15px;
- border: 1px solid #91AA9D;
- color: #FCFFF5;
- }
-.instructions a, .success a, .error a {
- color: #d8e2d7;
- text-decoration: underline;
- }
-.instructions a:hover, .success a:hover, .error a:hover {
- color: #FCFFF5;
- }
-.success {
- background-color: #48705b;
- }
-.error {
- background-color: #ce3728;
- }
-
-
-/* ----- Stream -----*/
-
-#notices {
- clear: both;
- margin: 0 auto;
- padding: 0;
- list-style-type: none;
- width: 540px;
- border-top: 1px solid #D8E2D7;
- }
-#notices a:hover {
- text-decoration: underline;
- }
-.notice_single {
- clear: both;
- display: block;
- margin: 0;
- padding: 5px 5px 5px 0;
- min-height: 48px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 13px;
- line-height: 16px;
- border-bottom: 1px solid #D8E2D7;
- }
-.notice_single:hover {
- background-color: #F3F8EA;
- }
-.notice_single p {
- display: inline;
- margin: 0;
- padding: 0;
- }
-#notice_delete_form #confirmation_text {
- display: block;
- font-size: 14px;
- font-weight: bold;
- }
-input#submit_yes, input#submit_no {
- margin: 18px 10px 0px 0px;
- padding: 4px;
- font-weight: bold;
- color: #FCFFF5;
- background-color: #C15D42;
- cursor: pointer;
- border: 0;
- width: 40px;
- }
-input#submit_yes:hover, input#submit_no:hover {
- background-color: #904632;
- }
-.avatar.stream {
- float: left;
- margin: 0 10px 0 0;
- }
-p.time {
- display: block;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 10px;
- line-height: 15px;
- }
-p.time a {
- color: #91AA9D;
- }
-
-/* ----- Profile -----*/
-#profile {
- clear: left;
- margin: 0 -110px;
- padding: 10px 0 0 0;
- min-height: 170px;
- border-top: 1px solid #D8E2D7;
- font-family: Georgia, "Times New Roman", Times, serif;
- }
-#profile h1 {
- margin: 0;
- padding: 0;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 14px;
- }
-#profile h2 {
- margin: 0;
- padding: 0;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 11px;
- text-transform: uppercase;
- color: #91AA9D;
- }
-#profile p {
- margin: 0 10px 0 0;
- font-size: 12px;
- line-height: 14px;
- }
-#profile p.location {
- margin: 0 10px 12px 0;
- font-style: italic;
- }
-#profile p.notice_current {
- font-size: 18px;
- line-height: 21px;
- }
-#profile_avatar {
- float: left;
- margin-right: 4px;
- }
-#profile_avatar img {
- margin-bottom: 5px;
- }
-.avatar.profile {
- clear: left;
- margin: 0 10px 5px 0;
- }
-.avatar.original {
- float: left;
- margin: 0 10px 18px 0;
- }
-a.nickname {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight: bold;
- font-size: 12px;
- padding-right: 3px;
- }
-#profile_information {
- float: left;
- position: relative;
- width: 270px;
- height: 200px;
- }
-.statistics {
- margin-top: 18px;
- }
-.statistics h2 {
- margin: 12px 0 3px 0;
- }
-dl.statistics {
- margin: 0;
- font-size: 12px;
- line-height: 14px;
- }
-.statistics dt {
- float: left;
- width: 96px;
-}
-.statistics dd {
- margin-left: 100px;
-}
-.statistics dt:after {
- content: ":";
- }
-#subscriptions {
- float: left;
- margin: 18px 0 30px 0;
- }
-#subscriptions_avatars {
- float: left;
- margin: 6px 0 0 0;
- padding: 0;
- list-style-type: none;
- width: 270px;
- }
-#subscriptions_avatars li .avatar.mini {
- float: left;
- margin: 0 3px 3px 0;
- padding: 0;
- line-height: 0;
- /* border: 1px solid #f00; */
- }
-#subscriptions_viewall {
- clear: left;
- }
-/* ----- End Profile -----*/
-
-/* ----- Begin Subscriptions & Subscribers -----*/
-
-ul.subscriptions, ul.subscribers {
- float: none;
- margin: 0;
- padding: 0;
- list-style-type: none;
- overflow: auto;
- }
-ul.subscriptions li, ul.subscribers li {
- display: block;
- float: left;
- padding: 0;
- }
-/* ----- End Subscriptions & Subscribers -----*/
-
-
-
-#pagination {
- margin: 18px auto;
- width: 540px;
- }
-#nav_pagination {
- margin: 0 0 36px 0;
- padding: 0;
- float: right;
- list-style-type: none;
- font-size: 12px;
- font-weight: bold;
- }
-#nav_pagination li {
- display: block;
- float: left;
- background-color: #91AA9D;
- }
-#nav_pagination li.before {
- margin-right: 1px;
- }
-#nav_pagination li a {
- padding: 6px 15px;
- line-height: 21px;
- background-color: #91AA9D;
- color: #FCFFF5;
- }
-#nav_pagination li a:hover {
- background-color: #3F606F;
- color: #FCFFF5;
- text-decoration: none;
- }
-
-#footer {
- clear: both;
- margin: 0 auto;
- padding: 0 0 36px 0;
- width: 540px;
- border-top: 1px solid #D8E2D7;
- }
-#footer p {
- margin-top: 9px;
- line-height: 12px;
- }
-#cc {
- float: left;
- margin: 3px 10px 0 0;
- }
-
-/* ===== Begin Forms Styling ===== */
-
-/* ----- Forms General Style ----- */
-form {
- margin: 0 auto;
- padding: 0;
- }
-form {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 12px;
- }
-form label {
- display: block;
- font-size: 12px;
- font-weight: bold;
- line-height: 18px;
- }
-form input {
- border: 1px solid #D8E2D7;
- width: 264px;
- }
-input#submit, input.submit {
- display: block;
- margin: 18px 0;
- padding: 4px;
- font-weight: bold;
- color: #FCFFF5;
- background-color: #C15D42;
- cursor: pointer;
- border: 0;
- width: auto;
- }
-input#submit:hover, input.submit:hover {
- background-color: #904632;
- }
-input.checkbox {
- /*width: 14px;
- height: 14px;*/
- width: auto;
- border: 0;
- }
-textarea, input {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 12px;
- color: #193441;
- padding: 3px;
- }
-textarea:focus, input:focus {
- background-color: #f0f6eb;
- }
-textarea {
- width: 270px;
- border: 1px solid #D8E2D7;
- }
-.input_instructions {
- margin-top: 3px;
- display: block;
- font-size: 11px;
- line-height: 15px;
- color: #91aa9d;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- }
-
-/* ----- Status Form ----- */
-#status_form {
- height: 96px;
- /*background-color: #F00;*/
- }
-#status_form p {
- margin: 36px 0 0 0;
- padding: 0;
- }
-#status_label {
- display: block;
- clear: both;
- margin: 0;
- padding: 0 0 3px 0;
- font-size: 18px;
- font-weight: bold;
- line-height: 24px;
- color: #91AA9D;
- }
-#status_textarea {
- display: block;
- float: left;
- width: 463px;
- height: 35px;
- padding: 5px;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 12px;
- color: #193441;
- border: 0;
- }
-#status_submit {
- display: block;
- float: left;
- margin: 1px 0 0 4px;
- width: 63px;
- height: 45px;
- background-color: #C15D42;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight: bold;
- font-size: 14px;
- color: #FCFFF5;
- cursor: pointer;
- border: 0;
- }
-#status_submit:hover {
- background-color: #904632;
- }
-#counter {
- position: absolute;
- top: 140px;
- left: -64px;
- width: 50px;
- font-weight: bold;
- text-align: right;
-}
-/* ----- Subscribe Form ----- */
-#subscribe .submit, #unsubscribe .submit, #remotesubscribe .button, #remotesubscribe {
- clear: left;
- margin: 0;
- width: 96px;
- height: 27px;
- font-family: verdana, arial, helvetica, sans-serif;
- font-weight: bold;
- font-size: 10px;
- text-transform: uppercase;
- background-color: #c15d42;
- color: #fcfff5;
- border: 0;
- }
-#remotesubscribe {
- width: 96px;
- height: 22px;
- padding: 5px 0 0 0;
- text-align: center;
- }
-#subscribe .button:hover, #unsubscribe .button:hover {
- background-color: #904632;
- cursor: pointer;
- }
-
-a#remotesubscribe {
- display: block;
-}
-
-/* ----- Login Form -----*/
-input#license {
- width: auto;
- border: 0;
- }
-/* ----- Avatar Form -----*/
-form {
- clear: left;
-}
-
-/* ----- OpenID Form -----*/
-
-input#openid_url {
- background: url(login-bg.gif) no-repeat;
- background-color: #fff;
- background-position: 4px 50%;
- color: #000;
- padding-left: 24px;
-}
-
-/* People lists (search results, maybe subscribers) */
-
-#profiles {
- clear: both;
- margin: 0 auto;
- padding: 0;
- list-style-type: none;
- width: 540px;
- border-top: 1px solid #D8E2D7;
- /*border: 1px solid #F00;*/
- }
-#profiles a:hover {
- text-decoration: underline;
- }
-
-.profile_single {
- clear: both;
- display: block;
- margin: 0;
- padding: 5px 5px 5px 0;
- min-height: 48px;
- font-family: Georgia, "Times New Roman", Times, serif;
- font-size: 13px;
- line-height: 16px;
- border-bottom: 1px solid #D8E2D7;
- }
-.profile_single:hover {
- background-color: #F3F8EA;
- }
-
-/* ----- IM Settings Form -----*/
-
-#imsettings p {
- margin: 0;
- padding: 0;
- line-height: 15px;
-}
-
-/* ===== End Forms Styling ===== */
-
-/* ===== Tag Cloud Styling ===== */
-
-p.tagcloud {
-text-align: center;
-}
-
-p.tagcloud a {
-line-height:100%;
-vertical-align:middle;
-}
-
-p.tagcloud a.largest {
-font-size: 400%;
-}
-p.tagcloud a.verylarge {
-font-size: 300%;
-}
-
-p.tagcloud a.large {
-font-size: 200%;
-}
-
-p.tagcloud a.medium {
-font-size: 150%;
-}
-
-p.tagcloud a.small {
-font-size: 100%;
-}
-
-p.tagcloud a.verysmall {
-font-size: 80%;
-}
-
-p.tagcloud a.smallest {
-font-size: 60%;
-}
diff --git a/theme/iphone/ie6.css.dist b/theme/iphone/ie6.css.dist
deleted file mode 100644
index 97d9fee3f..000000000
--- a/theme/iphone/ie6.css.dist
+++ /dev/null
@@ -1,63 +0,0 @@
-@charset "UTF-8";
-/* CSS Document */
-body {
- text-align: center;
-}
-input {
- height: 24px;
-}
-#wrap {
- margin: 0 auto;
- padding: 0 20px;
- width: 800px;
- text-align: left;
- background: url(bg-header.gif) repeat-x #FCFFF5;
- }
-#header {
- position: relative;
- margin-left: 108px;
- }
-#nav_views {
- margin: 0;
- }
-#nav_views li {
- line-height: 19px;
- }
-.statistics dd {
- margin-top: -15px;
- clear: both;
- }
-#notices {
- margin: 0;
- }
-.notice_single {
- height: 48px;
- }
-#profile p.notice_current {
- height: 96px;
- }
-
-#subscriptions_avatars li {
- float: left;
- margin: 0;
- padding: 0;
- }
-img.avatar.original, img.avatar.profile {
- clear: none;
- float: left;
-}
-#status_textarea {
- height: 46px;
- }
-
-#nav_pagination li a {
- padding: 6px 15px;
- line-height: 27px;
- }
-#nav_sub {
- position: relative;
- margin-left: 108px;
- }
-#footer {
- margin-left: 108px;
-}
diff --git a/theme/iphone/ie7.css.dist b/theme/iphone/ie7.css.dist
deleted file mode 100644
index bbf52d5cf..000000000
--- a/theme/iphone/ie7.css.dist
+++ /dev/null
@@ -1,20 +0,0 @@
-@charset "UTF-8";
-/* CSS Document */
-
-#statistics dd {
- clear: both;
- }
-
-
-#subscriptions_avatars li {
- float: left;
- }
-img.avatar.original, img.avatar.profile {
- clear: none;
- float: left;
-}
-
-#nav_pagination li a {
- padding: 6px 15px;
- line-height: 27px;
- } \ No newline at end of file
diff --git a/theme/iphone/login-bg.gif b/theme/iphone/login-bg.gif
deleted file mode 100644
index e2d8377db..000000000
--- a/theme/iphone/login-bg.gif
+++ /dev/null
Binary files differ
diff --git a/theme/iphone/logo.png b/theme/iphone/logo.png
deleted file mode 100644
index 3b271814d..000000000
--- a/theme/iphone/logo.png
+++ /dev/null
Binary files differ
diff --git a/theme/readme.txt b/theme/readme.txt
index 151b1fb71..d030f2db4 100644
--- a/theme/readme.txt
+++ b/theme/readme.txt
@@ -1,7 +1,7 @@
/** Howto: create a statusnet theme
*
* @package StatusNet
- * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@status.net>
* @copyright 2009 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/