Added parameter to rawContent

This commit is contained in:
Michael 2019-11-05 19:16:26 +00:00
parent 30e02beb46
commit abe6724629
36 changed files with 51 additions and 64 deletions

View File

@ -32,7 +32,7 @@ abstract class BaseModule extends BaseObject
* Extend this method if the module is supposed to return communication data,
* e.g. from protocol implementations.
*/
public static function rawContent()
public static function rawContent($parameters)
{
// echo '';
// exit;

View File

@ -11,7 +11,7 @@ use Friendica\BaseModule;
*/
class AccountManagementControlDocument extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$output = [
'version' => 1,

View File

@ -6,9 +6,9 @@ use Friendica\Module\BaseAdminModule;
class PhpInfo extends BaseAdminModule
{
public static function rawContent()
public static function rawContent($parameters)
{
parent::rawContent();
parent::rawContent($parameters);
phpinfo();
exit();

View File

@ -20,7 +20,7 @@ class Attach extends BaseModule
/**
* @brief Return to user an attached file given the id
*/
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();
if ($a->argc != 2) {

View File

@ -35,7 +35,7 @@ abstract class BaseAdminModule extends BaseModule
}
}
public static function rawContent()
public static function rawContent($parameters)
{
if (!is_site_admin()) {
return '';

View File

@ -18,7 +18,7 @@ use Friendica\Util\Proxy;
*/
class Hovercard extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$contact_url = $_REQUEST['url'] ?? '';

View File

@ -17,7 +17,7 @@ use Friendica\Util\Strings;
*/
class Fetch extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();

View File

@ -22,7 +22,7 @@ class SaveTag extends BaseModule
}
}
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();
$logger = $a->getLogger();

View File

@ -14,7 +14,7 @@ use Friendica\Protocol\ActivityPub;
*/
class Followers extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();

View File

@ -14,7 +14,7 @@ use Friendica\Protocol\ActivityPub;
*/
class Following extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();

View File

@ -88,7 +88,7 @@ class Friendica extends BaseModule
]);
}
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();

View File

@ -19,7 +19,7 @@ use Friendica\Util\Network;
*/
class Inbox extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();

View File

@ -16,7 +16,7 @@ use Friendica\Network\HTTPException;
*/
class Ignore extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
/** @var L10n $l10n */
$l10n = self::getClass(L10n::class);

View File

@ -13,7 +13,7 @@ use Friendica\Util\Strings;
*/
class Like extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
if (!Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException();

View File

@ -7,7 +7,7 @@ use Friendica\Core\Renderer;
class Manifest extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();
$config = $app->getConfig();

View File

@ -22,7 +22,7 @@ class NodeInfo extends BaseModule
}
}
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();

View File

@ -21,7 +21,7 @@ class Notify extends BaseModule
}
}
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();

View File

@ -15,7 +15,7 @@ use Friendica\Protocol\ActivityPub;
*/
class Objects extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();

View File

@ -16,7 +16,7 @@ class OpenSearch extends BaseModule
/**
* @throws \Exception
*/
public static function rawContent()
public static function rawContent($parameters)
{
header('Content-type: application/opensearchdescription+xml');

View File

@ -14,7 +14,7 @@ use Friendica\Protocol\ActivityPub;
*/
class Outbox extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();

View File

@ -51,7 +51,7 @@ class Profile extends BaseModule
}
}
public static function rawContent()
public static function rawContent($parameters)
{
if (ActivityPub::isRequest()) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);

View File

@ -12,7 +12,7 @@ use Friendica\Network\HTTPException\BadRequestException;
*/
class PublicRSAKey extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();

View File

@ -11,7 +11,7 @@ use Friendica\Util\XML;
*/
class ReallySimpleDiscovery extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
header('Content-Type: text/xml');

View File

@ -9,7 +9,7 @@ use Friendica\BaseModule;
*/
class RobotsTxt extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$allDisalloweds = [
'/settings/',

View File

@ -31,7 +31,7 @@ class Acl extends BaseModule
const TYPE_PRIVATE_MESSAGE = 'm';
const TYPE_ANY_CONTACT = 'a';
public static function rawContent()
public static function rawContent($parameters)
{
if (!local_user()) {
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this module.'));

View File

@ -59,7 +59,7 @@ class UserExport extends BaseSettingsModule
* to the browser which then offers a save / open dialog
* to the user.
**/
public static function rawContent()
public static function rawContent($parameters)
{
$args = self::getClass(Arguments::class);
if ($args->getArgc() == 3) {

View File

@ -12,7 +12,7 @@ use Friendica\Core\System;
*/
class Smilies extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();

View File

@ -4,29 +4,23 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Model\Item;
use Friendica\Core\System;
/**
* Toggle starred items
*/
class Starred extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$a = self::getApp();
$starred = 0;
$itemId = null;
if (!local_user()) {
exit();
}
// @TODO: Replace with parameter from router
if ($a->argc > 1) {
$itemId = intval($a->argv[1]);
}
if (!$itemId) {
exit();
if (empty($parameters['item'])) {
exit;
} else {
$itemId = intval($parameters['item']);
}
$item = Item::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]);
@ -34,27 +28,18 @@ class Starred extends BaseModule
exit();
}
if (!intval($item['starred'])) {
$starred = 1;
}
$starred = !$item['starred'];
Item::update(['starred' => $starred], ['id' => $itemId]);
// See if we've been passed a return path to redirect to
$returnPath = $_REQUEST['return'] ?? '';
if ($returnPath) {
$rand = '_=' . time();
if (strpos($returnPath, '?')) {
$rand = "&$rand";
} else {
$rand = "?$rand";
}
$a->internalRedirect($returnPath . $rand);
if (!empty($returnPath)) {
$rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand';
self::getApp()->internalRedirect($returnPath . $rand);
}
// the json doesn't really matter, it will either be 0 or 1
echo json_encode($starred);
exit();
System::jsonExit($starred);
}
}

View File

@ -17,7 +17,7 @@ class Statistics extends BaseModule
}
}
public static function rawContent()
public static function rawContent($parameters)
{
$config = self::getApp()->getConfig();
$logger = self::getApp()->getLogger();

View File

@ -10,7 +10,7 @@ use Friendica\Util\Strings;
*/
class Theme extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
header("Content-Type: text/css");

View File

@ -10,7 +10,7 @@ use Friendica\Core\Theme;
*/
class ThemeDetails extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
if (!empty($_REQUEST['theme'])) {
$theme = $_REQUEST['theme'];

View File

@ -13,7 +13,7 @@ use Friendica\Util\Crypto;
*/
class HostMeta extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();
$config = $app->getConfig();

View File

@ -11,7 +11,7 @@ use Friendica\Model\Search;
*/
class XSocialRelay extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();
$config = $app->getConfig();

View File

@ -17,7 +17,7 @@ use Friendica\Util\Strings;
*/
class Xrd extends BaseModule
{
public static function rawContent()
public static function rawContent($parameters)
{
$app = self::getApp();

View File

@ -34,7 +34,7 @@
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1323);
define('DB_UPDATE_VERSION', 1324);
}
return [
@ -1384,7 +1384,8 @@ return [
"iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
"hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide an item from the user"],
"ignored" => ["type" => "boolean", "comment" => "Ignore this thread if set"]
"ignored" => ["type" => "boolean", "comment" => "Ignore this thread if set"],
"pinned" => ["type" => "boolean", "comment" => "The item is pinned on the profile page"]
],
"indexes" => [
"PRIMARY" => ["uid", "iid"]

View File

@ -179,8 +179,9 @@ return [
'/{type}/{customize}/{name}' => [Module\Photo::class, [R::GET]],
],
'/pretheme' => [Module\ThemeDetails::class, [R::GET]],
'/probe' => [Module\Debug\Probe::class, [R::GET]],
'/pinned/{item:\d+}' => [Module\Pinned::class, [R::GET]],
'/pretheme' => [Module\ThemeDetails::class, [R::GET]],
'/probe' => [Module\Debug\Probe::class, [R::GET]],
'/profile' => [
'/{nickname}' => [Module\Profile::class, [R::GET]],