git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

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';
class AllAction extends ProfileAction
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -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;
}
}
......@@ -98,7 +98,7 @@ class AvatarbynicknameAction extends Action
common_redirect($url, 302);
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -108,7 +108,7 @@ class DocAction extends Action
return ucfirst($this->title);
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -85,7 +85,7 @@ class FavoritedAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -50,7 +50,7 @@ class FeaturedAction extends Action
{
var $page = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -25,7 +25,7 @@ define('BOTH', 0);
class FoafAction extends Action
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -59,7 +59,7 @@ class GroupbyidAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -48,7 +48,7 @@ class GroupmembersAction extends Action
{
var $page = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -57,7 +57,7 @@ class groupRssAction extends Rss10Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -51,7 +51,7 @@ class GroupsAction extends Action
var $page = null;
var $profile = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -27,7 +27,7 @@ class InviteAction extends Action
var $subbed = null;
var $sent = null;
function isReadOnly()
function isReadOnly($args)
{
return false;
}
......
......@@ -55,7 +55,7 @@ class LoginAction extends Action
* @return boolean false
*/
function isReadOnly()
function isReadOnly($args)
{
return false;
}
......
......@@ -52,7 +52,7 @@ class LogoutAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return false;
}
......
......@@ -74,7 +74,7 @@ class MicrosummaryAction extends Action
print $user->nickname . ': ' . $notice->content;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -92,7 +92,7 @@ class NoticesearchrssAction extends Rss10Action
return null;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -124,7 +124,7 @@ class NudgeAction extends Action
}
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -84,7 +84,7 @@ class OpensearchAction extends Action
$this->endXML();
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -56,7 +56,7 @@ class PublicAction extends Action
var $page = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -102,7 +102,7 @@ class PublicrssAction extends Rss10Action
// nop
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -47,7 +47,7 @@ define('TAGS_PER_PAGE', 100);
class PublictagcloudAction extends Action
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -54,7 +54,7 @@ class PublicxrdsAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -196,7 +196,7 @@ class RepliesAction extends Action
$this->elementEnd('div');
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -83,7 +83,7 @@ class RepliesrssAction extends Rss10Action
return ($avatar) ? $avatar->url : null;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -52,7 +52,7 @@ class RequesttokenAction extends Action
*
* @return boolean false
*/
function isReadOnly()
function isReadOnly($args)
{
return false;
}
......
......@@ -58,7 +58,7 @@ class ShowfavoritesAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -60,7 +60,7 @@ class ShowgroupAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -177,7 +177,7 @@ class ShowmessageAction extends MailboxAction
return '';
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -106,7 +106,7 @@ class ShownoticeAction extends Action
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -56,7 +56,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class ShowstreamAction extends ProfileAction
{
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -130,7 +130,7 @@ class SubscribersList extends ProfileList
$bf->show();
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -79,7 +79,7 @@ class SupAction extends Action
return $updates;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -87,7 +87,7 @@ class TagAction extends Action
$this->page, 'tag', array('tag' => $this->tag));
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -65,7 +65,7 @@ class TagrssAction extends Rss10Action
return $c;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -142,7 +142,7 @@ class TwitapisearchjsonAction extends TwitterapiAction
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -50,7 +50,7 @@ class UserbyidAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -52,7 +52,7 @@ class UsergroupsAction extends Action
var $page = null;
var $profile = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -96,7 +96,7 @@ class UserrssAction extends Rss10Action
parent::initRss($limit);
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -52,7 +52,7 @@ class XrdsAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -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');
......
......@@ -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;
}
......
......@@ -93,7 +93,7 @@ class ErrorAction extends Action
return $this->message;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -76,7 +76,7 @@ class GalleryAction extends Action
return true;
}
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -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;
}
......
......@@ -47,7 +47,7 @@ class PersonalAction extends Action
var $user = null;
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
......@@ -51,7 +51,7 @@ class SearchAction extends Action
*
* @return boolean true
*/
function isReadOnly()
function isReadOnly($args)
{
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment