1
1
Fork 0

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]],