Merge remote-tracking branch 'upstream/develop' into post-thread-user
This commit is contained in:
@@ -115,19 +115,15 @@ HELP;
|
||||
}
|
||||
|
||||
if ($k != '' && substr($l, 0, 7) == 'msgstr ') {
|
||||
if ($ink) {
|
||||
$ink = false;
|
||||
$out .= '$a->strings["' . $k . '"] = ';
|
||||
}
|
||||
|
||||
if ($inv) {
|
||||
$out .= '"' . $v . '"';
|
||||
}
|
||||
|
||||
$v = substr($l, 8, $len - 10);
|
||||
$v = preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $v);
|
||||
|
||||
$inv = true;
|
||||
if ($v != '') {
|
||||
$out .= '$a->strings["' . $k . '"] = "' . $v . '"';
|
||||
} else {
|
||||
$k = '';
|
||||
$ink = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($k != "" && substr($l, 0, 7) == 'msgstr[') {
|
||||
@@ -147,11 +143,13 @@ HELP;
|
||||
|
||||
$match = [];
|
||||
preg_match("|\[([0-9]*)\] (.*)|", $l, $match);
|
||||
$out .= "\t"
|
||||
. preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[1])
|
||||
. ' => '
|
||||
. preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[2])
|
||||
. ",\n";
|
||||
if ($match[2] !== '""') {
|
||||
$out .= "\t"
|
||||
. preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[1])
|
||||
. ' => '
|
||||
. preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $match[2])
|
||||
. ",\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (substr($l, 0, 6) == 'msgid_') {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module;
|
||||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
@@ -34,9 +34,10 @@ use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
* Performs a like and optionally redirects to a return path
|
||||
* Performs an activity (like, dislike, announce, attendyes, attendno, attendmaybe)
|
||||
* and optionally redirects to a return path
|
||||
*/
|
||||
class Like extends BaseModule
|
||||
class Activity extends BaseModule
|
||||
{
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
@@ -44,16 +45,12 @@ class Like extends BaseModule
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
$verb = Strings::escapeTags(trim($_GET['verb']));
|
||||
|
||||
if (!$verb) {
|
||||
$verb = 'like';
|
||||
if (empty($parameters['id']) || empty($parameters['verb'])) {
|
||||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
$app = DI::app();
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
$itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0);
|
||||
$verb = $parameters['verb'];
|
||||
$itemId = $parameters['id'];
|
||||
|
||||
if (in_array($verb, ['announce', 'unannounce'])) {
|
||||
$item = Post::selectFirst(['network'], ['id' => $itemId]);
|
||||
@@ -66,22 +63,27 @@ class Like extends BaseModule
|
||||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
// Decide how to return. If we were called with a 'return' argument,
|
||||
// then redirect back to the calling page. If not, just quietly end
|
||||
$returnPath = $_REQUEST['return'] ?? '';
|
||||
|
||||
if (!empty($returnPath)) {
|
||||
// See if we've been passed a return path to redirect to
|
||||
$return_path = $_REQUEST['return'] ?? '';
|
||||
if (!empty($return_path)) {
|
||||
$rand = '_=' . time();
|
||||
if (strpos($returnPath, '?')) {
|
||||
if (strpos($return_path, '?')) {
|
||||
$rand = "&$rand";
|
||||
} else {
|
||||
$rand = "?$rand";
|
||||
}
|
||||
|
||||
DI::baseUrl()->redirect($returnPath . $rand);
|
||||
DI::baseUrl()->redirect($return_path . $rand);
|
||||
}
|
||||
|
||||
System::jsonExit(['status' => 'OK']);
|
||||
$return = [
|
||||
'status' => 'ok',
|
||||
'item_id' => $itemId,
|
||||
'verb' => $verb,
|
||||
'state' => 1,
|
||||
];
|
||||
|
||||
System::jsonExit($return);
|
||||
}
|
||||
|
||||
private static function performDiasporaReshare(int $itemId)
|
||||
@@ -41,18 +41,17 @@ class Ignore extends BaseModule
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
$args = DI::args();
|
||||
$dba = DI::dba();
|
||||
|
||||
$message_id = intval($args->get(2));
|
||||
|
||||
if (empty($message_id) || !is_int($message_id)) {
|
||||
if (empty($parameters['id'])) {
|
||||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
$thread = Post::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $message_id]);
|
||||
$itemId = intval($parameters['id']);
|
||||
|
||||
$dba = DI::dba();
|
||||
|
||||
$thread = Post::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $itemId]);
|
||||
if (!$dba->isResult($thread)) {
|
||||
throw new HTTPException\BadRequestException();
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// Numeric values are needed for the json output further below
|
||||
@@ -61,11 +60,11 @@ class Ignore extends BaseModule
|
||||
switch ($thread['uid'] ?? 0) {
|
||||
// if the thread is from the current user
|
||||
case local_user():
|
||||
$dba->update('thread', ['ignored' => $ignored], ['iid' => $message_id]);
|
||||
$dba->update('thread', ['ignored' => $ignored], ['iid' => $itemId]);
|
||||
break;
|
||||
// 0 (null will get transformed to 0) => it's a public post
|
||||
case 0:
|
||||
$dba->update('user-item', ['ignored' => $ignored], ['iid' => $message_id, 'uid' => local_user()], true);
|
||||
$dba->update('user-item', ['ignored' => $ignored], ['iid' => $itemId, 'uid' => local_user()], true);
|
||||
break;
|
||||
// Throws a BadRequestException and not a ForbiddenException on purpose
|
||||
// Avoids harvesting existing, but forbidden IIDs (security issue)
|
||||
@@ -86,7 +85,13 @@ class Ignore extends BaseModule
|
||||
DI::baseUrl()->redirect($return_path . $rand);
|
||||
}
|
||||
|
||||
// the json doesn't really matter, it will either be 0 or 1
|
||||
System::jsonExit($ignored);
|
||||
$return = [
|
||||
'status' => 'ok',
|
||||
'item_id' => $itemId,
|
||||
'verb' => 'ignore',
|
||||
'state' => $ignored,
|
||||
];
|
||||
|
||||
System::jsonExit($return);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ class Temporal
|
||||
* @return int Age in years
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getAgeByTimezone($dob, $owner_tz = '')
|
||||
public static function getAgeByTimezone($dob, $owner_tz = ''): int
|
||||
{
|
||||
if (!intval($dob)) {
|
||||
return 0;
|
||||
@@ -381,7 +381,7 @@ class Temporal
|
||||
|
||||
$interval = $birthdate->diff($currentDate);
|
||||
|
||||
return $interval->format('%y');
|
||||
return (int) $interval->format('%y');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user