3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Model\Item;
11 class Pinned extends BaseModule
13 public static function rawContent(array $parameters = [])
16 throw new \Friendica\Network\HTTPException\ForbiddenException();
19 if (empty($parameters['item'])) {
20 throw new \Friendica\Network\HTTPException\BadRequestException();
23 $itemId = intval($parameters['item']);
25 $pinned = !Item::getPinned($itemId, local_user());
27 Item::setPinned($itemId, local_user(), $pinned);
29 // See if we've been passed a return path to redirect to
30 $returnPath = $_REQUEST['return'] ?? '';
31 if (!empty($returnPath)) {
32 $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand';
33 self::getApp()->internalRedirect($returnPath . $rand);
36 // the json doesn't really matter, it will either be 0 or 1
37 echo json_encode((int)$pinned);