We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit e9e75fc9 authored by Evan Prodromou's avatar Evan Prodromou

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.
parent 4237407c
...@@ -25,7 +25,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; ...@@ -25,7 +25,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class AllAction extends ProfileAction class AllAction extends ProfileAction
{ {
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -134,8 +134,8 @@ class ApiAction extends Action ...@@ -134,8 +134,8 @@ class ApiAction extends Action
'favorites/favorites'); 'favorites/favorites');
$fullname = "$this->api_action/$this->api_method"; $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 // need authentication
if (common_config('site', 'private')) { if (common_config('site', 'private')) {
return $fullname != 'laconica/config' || false; return $fullname != 'laconica/config' || false;
...@@ -180,11 +180,11 @@ class ApiAction extends Action ...@@ -180,11 +180,11 @@ class ApiAction extends Action
} }
} }
function isReadOnly() function isReadOnly($args)($args)
{ {
# NOTE: before handle(), can't use $this->arg $apiaction = $args['apiaction'];
$apiaction = $_REQUEST['apiaction']; $method = $args['method'];
$method = $_REQUEST['method'];
list($cmdtext, $fmt) = explode('.', $method); list($cmdtext, $fmt) = explode('.', $method);
static $write_methods = array( static $write_methods = array(
...@@ -207,5 +207,4 @@ class ApiAction extends Action ...@@ -207,5 +207,4 @@ class ApiAction extends Action
return false; return false;
} }
} }
...@@ -98,7 +98,7 @@ class AvatarbynicknameAction extends Action ...@@ -98,7 +98,7 @@ class AvatarbynicknameAction extends Action
common_redirect($url, 302); common_redirect($url, 302);
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -108,7 +108,7 @@ class DocAction extends Action ...@@ -108,7 +108,7 @@ class DocAction extends Action
return ucfirst($this->title); return ucfirst($this->title);
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -85,7 +85,7 @@ class FavoritedAction extends Action ...@@ -85,7 +85,7 @@ class FavoritedAction extends Action
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -50,7 +50,7 @@ class FeaturedAction extends Action ...@@ -50,7 +50,7 @@ class FeaturedAction extends Action
{ {
var $page = null; var $page = null;
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -25,7 +25,7 @@ define('BOTH', 0); ...@@ -25,7 +25,7 @@ define('BOTH', 0);
class FoafAction extends Action class FoafAction extends Action
{ {
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -59,7 +59,7 @@ class GroupbyidAction extends Action ...@@ -59,7 +59,7 @@ class GroupbyidAction extends Action
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -48,7 +48,7 @@ class GroupmembersAction extends Action ...@@ -48,7 +48,7 @@ class GroupmembersAction extends Action
{ {
var $page = null; var $page = null;
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -57,7 +57,7 @@ class groupRssAction extends Rss10Action ...@@ -57,7 +57,7 @@ class groupRssAction extends Rss10Action
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -51,7 +51,7 @@ class GroupsAction extends Action ...@@ -51,7 +51,7 @@ class GroupsAction extends Action
var $page = null; var $page = null;
var $profile = null; var $profile = null;
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -27,7 +27,7 @@ class InviteAction extends Action ...@@ -27,7 +27,7 @@ class InviteAction extends Action
var $subbed = null; var $subbed = null;
var $sent = null; var $sent = null;
function isReadOnly() function isReadOnly($args)
{ {
return false; return false;
} }
......
...@@ -55,7 +55,7 @@ class LoginAction extends Action ...@@ -55,7 +55,7 @@ class LoginAction extends Action
* @return boolean false * @return boolean false
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return false; return false;
} }
......
...@@ -52,7 +52,7 @@ class LogoutAction extends Action ...@@ -52,7 +52,7 @@ class LogoutAction extends Action
* *
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return false; return false;
} }
......
...@@ -74,7 +74,7 @@ class MicrosummaryAction extends Action ...@@ -74,7 +74,7 @@ class MicrosummaryAction extends Action
print $user->nickname . ': ' . $notice->content; print $user->nickname . ': ' . $notice->content;
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -92,7 +92,7 @@ class NoticesearchrssAction extends Rss10Action ...@@ -92,7 +92,7 @@ class NoticesearchrssAction extends Rss10Action
return null; return null;
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -124,7 +124,7 @@ class NudgeAction extends Action ...@@ -124,7 +124,7 @@ class NudgeAction extends Action
} }
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -84,7 +84,7 @@ class OpensearchAction extends Action ...@@ -84,7 +84,7 @@ class OpensearchAction extends Action
$this->endXML(); $this->endXML();
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -56,7 +56,7 @@ class PublicAction extends Action ...@@ -56,7 +56,7 @@ class PublicAction extends Action
var $page = null; var $page = null;
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -102,7 +102,7 @@ class PublicrssAction extends Rss10Action ...@@ -102,7 +102,7 @@ class PublicrssAction extends Rss10Action
// nop // nop
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -47,7 +47,7 @@ define('TAGS_PER_PAGE', 100); ...@@ -47,7 +47,7 @@ define('TAGS_PER_PAGE', 100);
class PublictagcloudAction extends Action class PublictagcloudAction extends Action
{ {
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -54,7 +54,7 @@ class PublicxrdsAction extends Action ...@@ -54,7 +54,7 @@ class PublicxrdsAction extends Action
* *
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -196,7 +196,7 @@ class RepliesAction extends Action ...@@ -196,7 +196,7 @@ class RepliesAction extends Action
$this->elementEnd('div'); $this->elementEnd('div');
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -83,7 +83,7 @@ class RepliesrssAction extends Rss10Action ...@@ -83,7 +83,7 @@ class RepliesrssAction extends Rss10Action
return ($avatar) ? $avatar->url : null; return ($avatar) ? $avatar->url : null;
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -52,7 +52,7 @@ class RequesttokenAction extends Action ...@@ -52,7 +52,7 @@ class RequesttokenAction extends Action
* *
* @return boolean false * @return boolean false
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return false; return false;
} }
......
...@@ -58,7 +58,7 @@ class ShowfavoritesAction extends Action ...@@ -58,7 +58,7 @@ class ShowfavoritesAction extends Action
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -60,7 +60,7 @@ class ShowgroupAction extends Action ...@@ -60,7 +60,7 @@ class ShowgroupAction extends Action
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -177,7 +177,7 @@ class ShowmessageAction extends MailboxAction ...@@ -177,7 +177,7 @@ class ShowmessageAction extends MailboxAction
return ''; return '';
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -106,7 +106,7 @@ class ShownoticeAction extends Action ...@@ -106,7 +106,7 @@ class ShownoticeAction extends Action
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -56,7 +56,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; ...@@ -56,7 +56,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class ShowstreamAction extends ProfileAction class ShowstreamAction extends ProfileAction
{ {
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -130,7 +130,7 @@ class SubscribersList extends ProfileList ...@@ -130,7 +130,7 @@ class SubscribersList extends ProfileList
$bf->show(); $bf->show();
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -79,7 +79,7 @@ class SupAction extends Action ...@@ -79,7 +79,7 @@ class SupAction extends Action
return $updates; return $updates;
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -87,7 +87,7 @@ class TagAction extends Action ...@@ -87,7 +87,7 @@ class TagAction extends Action
$this->page, 'tag', array('tag' => $this->tag)); $this->page, 'tag', array('tag' => $this->tag));
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -65,7 +65,7 @@ class TagrssAction extends Rss10Action ...@@ -65,7 +65,7 @@ class TagrssAction extends Rss10Action
return $c; return $c;
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -142,7 +142,7 @@ class TwitapisearchjsonAction extends TwitterapiAction ...@@ -142,7 +142,7 @@ class TwitapisearchjsonAction extends TwitterapiAction
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -50,7 +50,7 @@ class UserbyidAction extends Action ...@@ -50,7 +50,7 @@ class UserbyidAction extends Action
* *
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -52,7 +52,7 @@ class UsergroupsAction extends Action ...@@ -52,7 +52,7 @@ class UsergroupsAction extends Action
var $page = null; var $page = null;
var $profile = null; var $profile = null;
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -96,7 +96,7 @@ class UserrssAction extends Rss10Action ...@@ -96,7 +96,7 @@ class UserrssAction extends Rss10Action
parent::initRss($limit); parent::initRss($limit);
} }
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -52,7 +52,7 @@ class XrdsAction extends Action ...@@ -52,7 +52,7 @@ class XrdsAction extends Action
* *
* @return boolean true * @return boolean true
*/ */
function isReadOnly() function isReadOnly($args)
{ {
return true; return true;
} }
......
...@@ -128,7 +128,7 @@ function main() ...@@ -128,7 +128,7 @@ function main()
// XXX: find somewhere for this little block to live // 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'))) { if (is_array(common_config('db', 'mirror'))) {
// "load balancing", ha ha // "load balancing", ha ha
$arr = common_config('db', 'mirror'); $arr = common_config('db', 'mirror');
......
...@@ -791,9 +791,12 @@ class Action extends HTMLOutputter // lawsuit ...@@ -791,9 +791,12 @@ class Action extends HTMLOutputter // lawsuit
* *
* MAY override * MAY override
* *