function item_post(App $a) {
$uid = DI::userSession()->getLocalUserId();
- if (!DI::userSession()->isAuthenticated() || !$uid) {
+ if (!$uid) {
throw new HTTPException\ForbiddenException();
}
* after it's been previewed
*/
if (!$preview && !empty($_REQUEST['post_id_random'])) {
- if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
+ if (DI::session()->get('post-random') == $_REQUEST['post_id_random']) {
Logger::warning('duplicate post');
item_post_return(DI::baseUrl(), $return_path);
} else {
- $_SESSION['post-random'] = $_REQUEST['post_id_random'];
+ DI::session()->set('post-random', $_REQUEST['post_id_random']);
}
}
Item::deleteForUser(['id' => $item], $uid);
}
- $json = ['success' => 1];
- System::jsonExit($json);
+ System::jsonExit(['success' => 1]);
}
function item_edit(int $uid, array $request, bool $preview, string $return_path)
{
$post = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $request['post_id'], 'uid' => $uid]);
if (!DBA::isResult($post)) {
- DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.'));
if ($return_path) {
+ DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.'));
DI::baseUrl()->redirect($return_path);
}
throw new HTTPException\NotFoundException(DI::l10n()->t('Unable to locate original post.'));
}
if (empty($toplevel_item)) {
- DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.'));
if ($return_path) {
+ DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.'));
DI::baseUrl()->redirect($return_path);
}
throw new HTTPException\NotFoundException(DI::l10n()->t('Unable to locate original post.'));
$post_id = Item::insert($post);
if (!$post_id) {
- DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.'));
if ($return_path) {
+ DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.'));
DI::baseUrl()->redirect($return_path);
}
System::jsonExit(['preview' => '']);
}
- DI::sysmsg()->addNotice(DI::l10n()->t('Empty post discarded.'));
if ($return_path) {
+ DI::sysmsg()->addNotice(DI::l10n()->t('Empty post discarded.'));
DI::baseUrl()->redirect($return_path);
}