isReadOnly() now takes arguments

Add an array of arguments to isReadOnly() method of actions, to let
them change their results depending on what actions are called.
Primarily used by the 'api' action. Ideally in the future that will be
multiple actions. But this might still be useful.
This commit is contained in:
Evan Prodromou 2009-04-13 15:49:26 -04:00
parent 4237407cd9
commit e9e75fc9d5
46 changed files with 54 additions and 52 deletions

View File

@ -25,7 +25,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class AllAction extends ProfileAction
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -134,8 +134,8 @@ class ApiAction extends Action
'favorites/favorites');
$fullname = "$this->api_action/$this->api_method";
// If the site is "private", all API methods except laconica/config
// If the site is "private", all API methods except laconica/config
// need authentication
if (common_config('site', 'private')) {
return $fullname != 'laconica/config' || false;
@ -180,11 +180,11 @@ class ApiAction extends Action
}
}
function isReadOnly()
function isReadOnly($args)($args)
{
# NOTE: before handle(), can't use $this->arg
$apiaction = $_REQUEST['apiaction'];
$method = $_REQUEST['method'];
$apiaction = $args['apiaction'];
$method = $args['method'];
list($cmdtext, $fmt) = explode('.', $method);
static $write_methods = array(
@ -207,5 +207,4 @@ class ApiAction extends Action
return false;
}
}

View File

@ -98,7 +98,7 @@ class AvatarbynicknameAction extends Action
common_redirect($url, 302);
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -108,7 +108,7 @@ class DocAction extends Action
return ucfirst($this->title);
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -85,7 +85,7 @@ class FavoritedAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -50,7 +50,7 @@ class FeaturedAction extends Action
{
var $page = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -25,7 +25,7 @@ define('BOTH', 0);
class FoafAction extends Action
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -59,7 +59,7 @@ class GroupbyidAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -48,7 +48,7 @@ class GroupmembersAction extends Action
{
var $page = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -57,7 +57,7 @@ class groupRssAction extends Rss10Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -51,7 +51,7 @@ class GroupsAction extends Action
var $page = null;
var $profile = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -27,7 +27,7 @@ class InviteAction extends Action
var $subbed = null;
var $sent = null;
function isReadOnly()
function isReadOnly($args)
{
return false;
}

View File

@ -55,7 +55,7 @@ class LoginAction extends Action
* @return boolean false
*/
function isReadOnly()
function isReadOnly($args)
{
return false;
}

View File

@ -52,7 +52,7 @@ class LogoutAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return false;
}

View File

@ -74,7 +74,7 @@ class MicrosummaryAction extends Action
print $user->nickname . ': ' . $notice->content;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -92,7 +92,7 @@ class NoticesearchrssAction extends Rss10Action
return null;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -124,7 +124,7 @@ class NudgeAction extends Action
}
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -84,7 +84,7 @@ class OpensearchAction extends Action
$this->endXML();
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -56,7 +56,7 @@ class PublicAction extends Action
var $page = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -102,7 +102,7 @@ class PublicrssAction extends Rss10Action
// nop
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -47,7 +47,7 @@ define('TAGS_PER_PAGE', 100);
class PublictagcloudAction extends Action
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -54,7 +54,7 @@ class PublicxrdsAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -196,7 +196,7 @@ class RepliesAction extends Action
$this->elementEnd('div');
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -83,7 +83,7 @@ class RepliesrssAction extends Rss10Action
return ($avatar) ? $avatar->url : null;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -52,7 +52,7 @@ class RequesttokenAction extends Action
*
* @return boolean false
*/
function isReadOnly()
function isReadOnly($args)
{
return false;
}

View File

@ -58,7 +58,7 @@ class ShowfavoritesAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -60,7 +60,7 @@ class ShowgroupAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -177,7 +177,7 @@ class ShowmessageAction extends MailboxAction
return '';
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -106,7 +106,7 @@ class ShownoticeAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -56,7 +56,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class ShowstreamAction extends ProfileAction
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -130,7 +130,7 @@ class SubscribersList extends ProfileList
$bf->show();
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -79,7 +79,7 @@ class SupAction extends Action
return $updates;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -87,7 +87,7 @@ class TagAction extends Action
$this->page, 'tag', array('tag' => $this->tag));
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -65,7 +65,7 @@ class TagrssAction extends Rss10Action
return $c;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -142,7 +142,7 @@ class TwitapisearchjsonAction extends TwitterapiAction
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -50,7 +50,7 @@ class UserbyidAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -52,7 +52,7 @@ class UsergroupsAction extends Action
var $page = null;
var $profile = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -96,7 +96,7 @@ class UserrssAction extends Rss10Action
parent::initRss($limit);
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -52,7 +52,7 @@ class XrdsAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -128,7 +128,7 @@ function main()
// XXX: find somewhere for this little block to live
if (common_config('db', 'mirror') && $action_obj->isReadOnly()) {
if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) {
if (is_array(common_config('db', 'mirror'))) {
// "load balancing", ha ha
$arr = common_config('db', 'mirror');

View File

@ -791,9 +791,12 @@ class Action extends HTMLOutputter // lawsuit
*
* MAY override
*
* @param array $args other arguments
*
* @return boolean is read only action?
*/
function isReadOnly()
function isReadOnly($args)($args)
{
return false;
}

View File

@ -93,7 +93,7 @@ class ErrorAction extends Action
return $this->message;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -76,7 +76,7 @@ class GalleryAction extends Action
return true;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -67,7 +67,7 @@ class PeopleSearchResults extends ProfileList
return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -47,7 +47,7 @@ class PersonalAction extends Action
var $user = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}

View File

@ -51,7 +51,7 @@ class SearchAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}