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

Commit 1f8451f4 authored by Brion Vibber's avatar Brion Vibber

Merge branch 'testing' into 0.9.x

parents 857db1fa 2be04e2a
......@@ -56,7 +56,7 @@ class FoafGroupAction extends Action
return false;
}
$local = Local_group::staticGet('nickname', $nickname);
$local = Local_group::staticGet('nickname', $this->nickname);
if (!$local) {
$this->clientError(_('No such group.'), 404);
......@@ -126,7 +126,8 @@ class FoafGroupAction extends Action
while ($members->fetch()) {
$member_uri = common_local_url('userbyid', array('id'=>$members->id));
$member_details[$member_uri] = array(
'nickname' => $members->nickname
'nickname' => $members->nickname,
'is_admin' => false,
);
$this->element('member', array('rdf:resource' => $member_uri));
}
......
......@@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @link http://status.net/
*/
class GroupblockAction extends Action
class GroupblockAction extends RedirectingAction
{
var $profile = null;
var $group = null;
......@@ -117,9 +117,7 @@ class GroupblockAction extends Action
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('no')) {
common_redirect(common_local_url('groupmembers',
array('nickname' => $this->group->nickname)),
303);
$this->returnToArgs();
} elseif ($this->arg('yes')) {
$this->blockProfile();
} elseif ($this->arg('blockto')) {
......@@ -196,23 +194,20 @@ class GroupblockAction extends Action
$this->serverError(_("Database error blocking user from group."));
return false;
}
$this->returnToArgs();
}
// Now, gotta figure where we go back to
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} elseif (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
}
if ($action) {
common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('groupmembers',
array('nickname' => $this->group->nickname)),
303);
}
/**
* If we reached this form without returnto arguments, default to
* the top of the group's member list.
*
* @return string URL
*/
function defaultReturnTo()
{
return common_local_url('groupmembers',
array('nickname' => $this->group->nickname));
}
function showScripts()
......
......@@ -205,8 +205,7 @@ class GroupMemberListItem extends ProfileListItem
!$this->profile->isAdmin($this->group)) {
$this->out->elementStart('li', 'entity_make_admin');
$maf = new MakeAdminForm($this->out, $this->profile, $this->group,
array('action' => 'groupmembers',
'nickname' => $this->group->nickname));
$this->returnToArgs());
$maf->show();
$this->out->elementEnd('li');
}
......@@ -220,8 +219,7 @@ class GroupMemberListItem extends ProfileListItem
if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
$this->out->elementStart('li', 'entity_block');
$bf = new GroupBlockForm($this->out, $this->profile, $this->group,
array('action' => 'groupmembers',
'nickname' => $this->group->nickname));
$this->returnToArgs());
$bf->show();
$this->out->elementEnd('li');
}
......@@ -244,6 +242,23 @@ class GroupMemberListItem extends ProfileListItem
$aAttrs['rel'] = 'nofollow';
}
}
/**
* Fetch necessary return-to arguments for the profile forms
* to return to this list when they're done.
*
* @return array
*/
protected function returnToArgs()
{
$args = array('action' => 'groupmembers',
'nickname' => $this->group->nickname);
$page = $this->out->arg('page');
if ($page) {
$args['param-page'] = $page;
}
return $args;
}
}
/**
......
......@@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @link http://status.net/
*/
class MakeadminAction extends Action
class MakeadminAction extends RedirectingAction
{
var $profile = null;
var $group = null;
......@@ -148,20 +148,19 @@ class MakeadminAction extends Action
$this->group->getBestName());
}
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} else if (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
}
$this->returnToArgs();
}
if ($action) {
common_redirect(common_local_url($action, $args), 303);
} else {
common_redirect(common_local_url('groupmembers',
array('nickname' => $this->group->nickname)),
303);
}
/**
* If we reached this form without returnto arguments, default to
* the top of the group's member list.
*
* @return string URL
*/
function defaultReturnTo()
{
return common_local_url('groupmembers',
array('nickname' => $this->group->nickname));
}
}
......@@ -157,9 +157,13 @@ class SubscribersListItem extends SubscriptionListItem
$user = common_current_user();
if (!empty($user) && $this->owner->id == $user->id) {
$bf = new BlockForm($this->out, $this->profile,
array('action' => 'subscribers',
'nickname' => $this->owner->nickname));
$returnto = array('action' => 'subscribers',
'nickname' => $this->owner->nickname);
$page = $this->out->arg('page');
if ($page) {
$returnto['param-page'] = $page;
}
$bf = new BlockForm($this->out, $this->profile, $returnto);
$bf->show();
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -41,7 +41,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @link http://status.net/
*/
class ProfileFormAction extends Action
class ProfileFormAction extends RedirectingAction
{
var $profile = null;
......@@ -101,29 +101,6 @@ class ProfileFormAction extends Action
}
}
/**
* Return to the calling page based on hidden arguments
*
* @return void
*/
function returnToArgs()
{
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} else if (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
}
if ($action) {
common_redirect(common_local_url($action, $args), 303);
} else {
$this->clientError(_("No return-to arguments."));
}
}
/**
* handle a POST request
*
......
<?php
/**
* Superclass for actions that redirect to a given return-to page on completion.
*
* PHP version 5
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2009-2010, 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 Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Brion Vibber <brion@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
/**
* Superclass for actions that redirect to a given return-to page on completion.
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Brion Vibber <brion@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class RedirectingAction extends Action
{
/**
* Redirect browser to the page our hidden parameters requested,
* or if none given, to the url given by $this->defaultReturnTo().
*
* To be called only after successful processing.
*
* @fixme rename this -- it obscures Action::returnToArgs() which
* returns a list of arguments, and is a bit confusing.
*
* @return void
*/
function returnToArgs()
{
// Now, gotta figure where we go back to
$action = false;
$args = array();
$params = array();
foreach ($this->args as $k => $v) {
if ($k == 'returnto-action') {
$action = $v;
} else if (substr($k, 0, 15) == 'returnto-param-') {
$params[substr($k, 15)] = $v;
} elseif (substr($k, 0, 9) == 'returnto-') {
$args[substr($k, 9)] = $v;
}
}
if ($action) {
common_redirect(common_local_url($action, $args, $params), 303);
} else {
$url = $this->defaultReturnToUrl();
}
common_redirect($url, 303);
}
/**
* If we reached this form without returnto arguments, where should
* we go? May be overridden by subclasses to a reasonable destination
* for that action; default implementation throws an exception.
*
* @return string URL
*/
function defaultReturnTo()
{
$this->clientError(_("No return-to arguments."));
}
}
......@@ -862,7 +862,14 @@ function common_xml_safe_str($str)
function common_tag_link($tag)
{
$canonical = common_canonical_tag($tag);
$url = common_local_url('tag', array('tag' => $canonical));
if (common_config('singleuser', 'enabled')) {
// regular TagAction isn't set up in 1user mode
$url = common_local_url('showstream',
array('nickname' => common_config('singleuser', 'nickname'),
'tag' => $canonical));
} else {
$url = common_local_url('tag', array('tag' => $canonical));
}
$xs = new XMLStringer();
$xs->elementStart('span', 'tag');
$xs->element('a', array('href' => $url,
......@@ -1272,12 +1279,38 @@ function common_mtrand($bytes)
return $enc;
}
/**
* Record the given URL as the return destination for a future
* form submission, to be read by common_get_returnto().
*
* @param string $url
*
* @fixme as a session-global setting, this can allow multiple forms
* to conflict and overwrite each others' returnto destinations if
* the user has multiple tabs or windows open.
*
* Should refactor to index with a token or otherwise only pass the
* data along its intended path.
*/
function common_set_returnto($url)
{
common_ensure_session();
$_SESSION['returnto'] = $url;
}
/**
* Fetch a return-destination URL previously recorded by
* common_set_returnto().
*
* @return mixed URL string or null
*
* @fixme as a session-global setting, this can allow multiple forms
* to conflict and overwrite each others' returnto destinations if
* the user has multiple tabs or windows open.
*
* Should refactor to index with a token or otherwise only pass the
* data along its intended path.
*/
function common_get_returnto()
{
common_ensure_session();
......
......@@ -458,7 +458,7 @@ class GeonamesPlugin extends Plugin
}
if (!$result->isOk()) {
throw new Exception("HTTP error code " . $result->code);
throw new Exception("HTTP error code " . $result->getStatus());
}
$body = $result->getBody();
......
......@@ -234,24 +234,6 @@ class MobileProfilePlugin extends WAP20Plugin
}
function onStartShowHeadElements($action)
{
// @fixme nothing appears to set a serveMobile on any action,
// so this is useless and spews errors. Is this supposed to be
// checking $this?
//if (!$action->serveMobile) {
// return true;
//}
$action->showTitle();
$action->showShortcutIcon();
$action->showStylesheets();
$action->showFeeds();
$action->showDescription();
$action->extraHead();
}
function onStartShowStatusNetStyles($action)
{
if (!$this->serveMobile) {
......
#!/usr/bin/env php
<?php
/*
* StatusNet - a distributed open-source microblogging tool
* Copyright (C) 2010 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__) . '/..'));
$longoptions = array('dry-run', 'start=', 'end=');
$helptext = <<<END_OF_HELP
fixup_blocks.php [options]
Finds profile blocks where the unsubscription didn't complete,
and removes the offending subscriptions.
--dry-run look but don't touch
END_OF_HELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
/**
* Fetch subscriptions that should be disallowed by a block
*/
function get_blocked_subs()
{
$query = "SELECT subscription.* " .
"FROM subscription " .
"INNER JOIN profile_block " .
"ON blocker=subscribed " .
"AND blocked=subscriber";
$subscription = new Subscription();
$subscription->query($query);
return $subscription;
}
$dry = have_option('dry-run');
$sub = get_blocked_subs();
$count = $sub->N;
while ($sub->fetch()) {
$subber = Profile::staticGet('id', $sub->subscriber);
$subbed = Profile::staticGet('id', $sub->subscribed);
if (!$subber || !$subbed) {
print "Bogus entry! $sub->subscriber subbed to $sub->subscribed\n";
continue;
}
print "$subber->nickname ($subber->id) blocked but subbed to $subbed->nickname ($subbed->id)";
if ($dry) {
print ": skipping; dry run\n";
} else {
Subscription::cancel($subber, $subbed);
print ": removed\n";
}
}
print "\n";
if ($dry && $count > 0) {
print "Be sure to run without --dry-run to remove the bad entries!\n";
} else {
print "done.\n";
}
#!/usr/bin/env php
<?php
/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2010, 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 Installation
* @package Installation
*
* @author Brion Vibber <brion@status.net>
* @license GNU Affero General Public License http://www.gnu.org/licenses/
* @version 0.9.x
* @link http://status.net
*/
if (php_sapi_name() !== 'cli') {
exit(1);
}
define('INSTALLDIR', dirname(dirname(__FILE__)));
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib');
require_once INSTALLDIR . '/lib/installer.php';
require_once 'Console/Getopt.php';
class CliInstaller extends Installer
{
public $verbose = true;
/**
* Go for it!
* @return boolean success
*/
function main()
{
if (!$this->checkPrereqs()) {
return false;
}
if ($this->prepare()) {
return $this->handle();
} else {
$this->showHelp();
return false;
}
}
/**
* Get our input parameters...
* @return boolean success
*/
function prepare()
{
$shortoptions = 'qvh';
$longoptions = array('quiet', 'verbose', 'help', 'skip-config');
$map = array(
'-s' => 'server',
'--server' => 'server',
'-p' => 'path',
'--path' => 'path',
'--sitename' => 'sitename',
'--fancy' => 'fancy',
'--dbtype' => 'dbtype',
'--host' => 'host',
'--database' => 'database',
'--username' => 'username',
'--password' => 'password',
'--admin-nick' => 'adminNick',
'--admin-pass' => 'adminPass',
'--admin-email' => 'adminEmail',
'--admin-updates' => 'adminUpdates'
);
foreach ($map as $arg => $target) {
if (substr($arg, 0, 2) == '--') {
$longoptions[] = substr($arg, 2) . '=';
} else {
$shortoptions .= substr($arg, 1) . ':';
}
}
$parser = new Console_Getopt();
$result = $parser->getopt($_SERVER['argv'], $shortoptions, $longoptions);
if (PEAR::isError($result)) {
$this->warning($result->getMessage());
return false;
}
list($options, $args) = $result;
// defaults
$this->dbtype = 'mysql';
$this->adminUpdates = true;
$this->verbose = true;
foreach ($options as $option) {
$arg = $option[0];
if (isset($map[$arg])) {
$var = $map[$arg];
$this->$var = $option[1];
if ($var == 'adminUpdates' || $arg == '--fancy') {
$this->$var = ($option[1] != 'false') && ($option[1] != 'no');
}
} else if ($arg == '--skip-config') {
$this->skipConfig = true;
} else if ($arg == 'q' || $arg == '--quiet') {
$this->verbose = false;
} else if ($arg == 'v' || $arg == '--verbose') {
$this->verbose = true;
} else if ($arg == 'h' || $arg == '--help') {
// will go back to show help
return false;
}
}
$fail = false;
if (empty($this->server)) {
$this->updateStatus("You must specify a web server for the site.", true);
// path is optional though
$fail = true;
}