/** @noinspection PhpUnusedPrivateMethodInspection */ private function send() { $view = new View(); if (empty($_POST['content'])) { $view->setStatus(false); $view->addData(["msg" => $view->translate("Oups! Your post is empty!")]); } else { $table = new Db\Table\Posts(); $videoData = ["video" => json_decode(html_entity_decode($_POST['youtubedata']), true), "content" => $_POST['content']]; $content = $_POST['type'] == "video" ? json_encode($videoData) : $_POST['content']; $res = $table->post(["userid" => $_SESSION['user']->userid, "wall_owner_id" => $_POST['wall_owner_id'], "wall_owner_type" => $_POST['wall_owner_type'], "privacy" => $_POST['privacy'], "content" => $content, "type" => $_POST['type']]); $view->setStatus($res !== false); if ($_POST['type'] == "video") { $view->addData(array_merge($res, ["content" => $videoData])); } else { $view->addData($res); } } $view->sendResponse(); }
/** @noinspection PhpUnusedPrivateMethodInspection */ private function changePrivacy() { if (isset($_POST['privacy']) && is_array($_POST['privacy'])) { $table = new Db\Table\Privacy(); $res = $table->updatePrivacy($_SESSION['user']->userid, $_POST['privacy']); $view = new View(); $view->setStatus($res); if ($res) { $message = $view->translate("Privacy settings changed successfully!"); } else { $message = $view->translate("Sorry, something went wrong, try again"); } $view->addData(['msg' => $message]); $view->sendResponse(); } }