3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Model\Item;
7 use Friendica\Network\HTTPException;
8 use Friendica\Util\Strings;
11 * Performs a like and optionally redirects to a return path
13 class Like extends BaseModule
15 public static function rawContent()
17 if (!local_user() && !remote_user()) {
18 throw new HTTPException\ForbiddenException();
21 $verb = Strings::escapeTags(trim($_GET['verb']));
27 $app = self::getApp();
29 // @TODO: Replace with parameter from router
30 $itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0);
32 if (!Item::performLike($itemId, $verb)) {
33 throw new HTTPException\BadRequestException();
36 // Decide how to return. If we were called with a 'return' argument,
37 // then redirect back to the calling page. If not, just quietly end
38 $returnPath = defaults($_REQUEST, 'return', '');
40 if (!empty($returnPath)) {
41 $rand = '_=' . time();
42 if (strpos($returnPath, '?')) {
48 $app->internalRedirect($returnPath . $rand);