From 7e6870db914d4e905fc7ae833b69404fd3ea0d3d Mon Sep 17 00:00:00 2001 From: zach Date: Tue, 22 Jul 2008 17:20:56 -0400 Subject: [PATCH] base class is_readonly() now returns false by default darcs-hash:20080722212056-ca946-e4bd9eef8e3d8991414932e9fc7b8c9a31f818c0.gz --- actions/avatar.php | 4 ---- actions/confirmaddress.php | 4 ---- actions/finishaddopenid.php | 4 ---- actions/finishremotesubscribe.php | 4 ---- actions/foaf.php | 4 ++++ actions/login.php | 4 ++++ actions/logout.php | 5 +++++ actions/newnotice.php | 6 +----- actions/postnotice.php | 4 ---- actions/publicxrds.php | 4 ++++ actions/recoverpassword.php | 4 ---- actions/register.php | 4 ---- actions/requesttoken.php | 5 +++++ actions/subscribe.php | 4 ---- actions/twitapidirect_messages.php | 15 +++++++++++++++ actions/twitapifavorites.php | 13 +++++++++++++ actions/twitapihelp.php | 4 ++++ actions/twitapinotifications.php | 1 - actions/unsubscribe.php | 4 ---- actions/updateprofile.php | 4 ---- actions/userauthorization.php | 4 ---- actions/userbyid.php | 5 +++++ actions/xrds.php | 4 ++++ lib/action.php | 2 +- lib/gallery.php | 4 ++++ lib/rssaction.php | 4 ++++ lib/searchaction.php | 4 ++++ lib/settingsaction.php | 4 ---- lib/stream.php | 4 ++++ 29 files changed, 81 insertions(+), 55 deletions(-) diff --git a/actions/avatar.php b/actions/avatar.php index b1697f97bb..ebfbd72952 100644 --- a/actions/avatar.php +++ b/actions/avatar.php @@ -23,10 +23,6 @@ require_once(INSTALLDIR.'/lib/settingsaction.php'); class AvatarAction extends SettingsAction { - function is_readonly() { - return false; - } - function get_instructions() { return _('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.'); } diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php index 66a41d9d7d..3cffda8710 100644 --- a/actions/confirmaddress.php +++ b/actions/confirmaddress.php @@ -21,10 +21,6 @@ if (!defined('LACONICA')) { exit(1); } class ConfirmaddressAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); if (!common_logged_in()) { diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php index af96635d62..54d81b0b4e 100644 --- a/actions/finishaddopenid.php +++ b/actions/finishaddopenid.php @@ -31,10 +31,6 @@ class FinishaddopenidAction extends Action { $this->try_login(); } } - - function is_readonly() { - return false; - } function try_login() { diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index bce2447ac7..ba5156a204 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -23,10 +23,6 @@ require_once(INSTALLDIR.'/lib/omb.php'); class FinishremotesubscribeAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); diff --git a/actions/foaf.php b/actions/foaf.php index 8de4c75028..c64617e5f0 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -25,6 +25,10 @@ define('BOTH', 0); class FoafAction extends Action { + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); diff --git a/actions/login.php b/actions/login.php index 0f2dec1a41..aa25a0cec5 100644 --- a/actions/login.php +++ b/actions/login.php @@ -21,6 +21,10 @@ if (!defined('LACONICA')) { exit(1); } class LoginAction extends Action { + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); if (common_is_real_login()) { diff --git a/actions/logout.php b/actions/logout.php index fb61689ee8..f00fa0ba7f 100644 --- a/actions/logout.php +++ b/actions/logout.php @@ -22,6 +22,11 @@ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/lib/openid.php'); class LogoutAction extends Action { + + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); if (!common_logged_in()) { diff --git a/actions/newnotice.php b/actions/newnotice.php index 487396e4e1..711b77e0a9 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -20,11 +20,7 @@ if (!defined('LACONICA')) { exit(1); } class NewnoticeAction extends Action { - - function is_readonly() { - return false; - } - + function handle($args) { parent::handle($args); # XXX: Ajax! diff --git a/actions/postnotice.php b/actions/postnotice.php index 3b5a4ee153..ab12277bbd 100644 --- a/actions/postnotice.php +++ b/actions/postnotice.php @@ -21,10 +21,6 @@ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/lib/omb.php'); -function is_readonly() { - return false; -} - class PostnoticeAction extends Action { function handle($args) { parent::handle($args); diff --git a/actions/publicxrds.php b/actions/publicxrds.php index 29c8e13145..951434c878 100644 --- a/actions/publicxrds.php +++ b/actions/publicxrds.php @@ -25,6 +25,10 @@ require_once(INSTALLDIR.'/lib/openid.php'); class PublicxrdsAction extends Action { + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); diff --git a/actions/recoverpassword.php b/actions/recoverpassword.php index 0d85163d74..9c34ff3d84 100644 --- a/actions/recoverpassword.php +++ b/actions/recoverpassword.php @@ -25,10 +25,6 @@ define(MAX_RECOVERY_TIME, 24 * 60 * 60); class RecoverpasswordAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); if (common_logged_in()) { diff --git a/actions/register.php b/actions/register.php index 0d6338797c..6ac2830595 100644 --- a/actions/register.php +++ b/actions/register.php @@ -21,10 +21,6 @@ if (!defined('LACONICA')) { exit(1); } class RegisterAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); diff --git a/actions/requesttoken.php b/actions/requesttoken.php index 0e233ff179..09ce5a6425 100644 --- a/actions/requesttoken.php +++ b/actions/requesttoken.php @@ -22,6 +22,11 @@ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/lib/omb.php'); class RequesttokenAction extends Action { + + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); try { diff --git a/actions/subscribe.php b/actions/subscribe.php index 7ce50dac8c..e292fdd6be 100644 --- a/actions/subscribe.php +++ b/actions/subscribe.php @@ -21,10 +21,6 @@ if (!defined('LACONICA')) { exit(1); } class SubscribeAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index e7f3e12666..9a84082e6d 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -23,6 +23,21 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); class Twitapidirect_messagesAction extends TwitterapiAction { + + function is_readonly() { + + static $write_methods = array( 'direct_messages', + 'sent'); + + $cmdtext = explode('.', $this->arg('method')); + + if (in_array($cmdtext[0], $write_methods)) { + return false; + } + + return true; + } + function direct_messages($args, $apidata) { parent::handle($args); common_server_error("API method under construction.", $code=501); diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php index a4afa732a0..4de5676034 100644 --- a/actions/twitapifavorites.php +++ b/actions/twitapifavorites.php @@ -23,6 +23,19 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); class TwitapifavoritesAction extends TwitterapiAction { + function is_readonly() { + + static $write_methods = array('favorites'); + + $cmdtext = explode('.', $this->arg('method')); + + if (in_array($cmdtext[0], $write_methods)) { + return false; + } + + return true; + } + function favorites($args, $apidata) { parent::handle($args); common_server_error("API method under construction.", $code=501); diff --git a/actions/twitapihelp.php b/actions/twitapihelp.php index e07c9b6672..7695190fca 100644 --- a/actions/twitapihelp.php +++ b/actions/twitapihelp.php @@ -23,6 +23,10 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); class TwitapihelpAction extends TwitterapiAction { + function is_readonly() { + return true; + } + /* 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 diff --git a/actions/twitapinotifications.php b/actions/twitapinotifications.php index 45a33427bc..95fe550b12 100644 --- a/actions/twitapinotifications.php +++ b/actions/twitapinotifications.php @@ -24,7 +24,6 @@ require_once(INSTALLDIR.'/lib/twitterapi.php'); # This naming convention looks real sick class TwitapinotificationsAction extends TwitterapiAction { - function follow($args, $apidata) { parent::handle($args); common_server_error("API method under construction.", $code=501); diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php index 69d5139073..3863a3a5e3 100644 --- a/actions/unsubscribe.php +++ b/actions/unsubscribe.php @@ -19,10 +19,6 @@ class UnsubscribeAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); if (!common_logged_in()) { diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 72246dab88..7e604f6b10 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -22,10 +22,6 @@ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/lib/omb.php'); class UpdateprofileAction extends Action { - - function is_readonly() { - return false; - } function handle($args) { parent::handle($args); diff --git a/actions/userauthorization.php b/actions/userauthorization.php index b02fe96cee..6ae3434a6d 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -23,10 +23,6 @@ require_once(INSTALLDIR.'/lib/omb.php'); define('TIMESTAMP_THRESHOLD', 300); class UserauthorizationAction extends Action { - - function is_readonly() { - return false; - } function handle($args) { parent::handle($args); diff --git a/actions/userbyid.php b/actions/userbyid.php index 7b95d07259..c42cad0836 100644 --- a/actions/userbyid.php +++ b/actions/userbyid.php @@ -20,6 +20,11 @@ if (!defined('LACONICA')) { exit(1); } class UserbyidAction extends Action { + + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); $id = $this->trimmed('id'); diff --git a/actions/xrds.php b/actions/xrds.php index 70a18a6b9b..1d516aab72 100644 --- a/actions/xrds.php +++ b/actions/xrds.php @@ -23,6 +23,10 @@ require_once(INSTALLDIR.'/lib/omb.php'); class XrdsAction extends Action { + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); $nickname = $this->trimmed('nickname'); diff --git a/lib/action.php b/lib/action.php index 1dca596eb8..1d3614ae1d 100644 --- a/lib/action.php +++ b/lib/action.php @@ -27,7 +27,7 @@ class Action { // lawsuit } function is_readonly() { - return true; + return false; } function arg($key, $def=NULL) { diff --git a/lib/gallery.php b/lib/gallery.php index 4f3c18ff91..c6f1585b4b 100644 --- a/lib/gallery.php +++ b/lib/gallery.php @@ -25,6 +25,10 @@ define('AVATARS_PER_PAGE', 80); class GalleryAction extends Action { + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); $nickname = $this->arg('nickname'); diff --git a/lib/rssaction.php b/lib/rssaction.php index e8a3aca70b..76859a876a 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -25,6 +25,10 @@ class Rss10Action extends Action { # This will contain the details of each feed item's author and be used to generate SIOC data. var $creators = array(); + + function is_readonly() { + return true; + } function handle($args) { parent::handle($args); diff --git a/lib/searchaction.php b/lib/searchaction.php index 729cfe6d40..46779bf7ac 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -21,6 +21,10 @@ if (!defined('LACONICA')) { exit(1); } class SearchAction extends Action { + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); $this->show_form(); diff --git a/lib/settingsaction.php b/lib/settingsaction.php index 0e39a74597..a71c9e9bc3 100644 --- a/lib/settingsaction.php +++ b/lib/settingsaction.php @@ -21,10 +21,6 @@ if (!defined('LACONICA')) { exit(1); } class SettingsAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); if (!common_logged_in()) { diff --git a/lib/stream.php b/lib/stream.php index a595958e44..fefd77a461 100644 --- a/lib/stream.php +++ b/lib/stream.php @@ -21,6 +21,10 @@ if (!defined('LACONICA')) { exit(1); } class StreamAction extends Action { + function is_readonly() { + return true; + } + function handle($args) { parent::handle($args); } -- 2.39.5