3 namespace Friendica\Module;
5 use Friendica\BaseModule;
7 use Friendica\Model\Item;
12 class Pinned extends BaseModule
14 public static function rawContent(array $parameters = [])
17 throw new \Friendica\Network\HTTPException\ForbiddenException();
20 if (empty($parameters['item'])) {
21 throw new \Friendica\Network\HTTPException\BadRequestException();
24 $itemId = intval($parameters['item']);
26 $pinned = !Item::getPinned($itemId, local_user());
28 Item::setPinned($itemId, local_user(), $pinned);
30 // See if we've been passed a return path to redirect to
31 $returnPath = $_REQUEST['return'] ?? '';
32 if (!empty($returnPath)) {
33 $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand';
34 DI::baseUrl()->redirect($returnPath . $rand);
37 // the json doesn't really matter, it will either be 0 or 1
38 echo json_encode((int)$pinned);