Esempio n. 1
0
 /** @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();
 }
Esempio n. 2
0
 /**
  * @param $albumid
  * @param bool $newsfeed_post
  * @param array $uploader_data
  * @return array|bool|mixed
  */
 public function uploadImage($albumid, $newsfeed_post = false, $uploader_data = [])
 {
     if (isset($_FILES) && isset($_FILES['file']) && $albumid > 0) {
         $uploader = new Uploader();
         $file = $uploader->upload($albumid . sha1($_SESSION['user']->userhash . time()) . rand());
         if (empty($uploader_data)) {
             list($owner_id, $owner_type) = [$_SESSION['user']->userid, null];
         } else {
             list($owner_id, $owner_type) = $uploader_data;
         }
         $imageid = $this->insert(["owner_id" => $owner_id, "owner_type" => $owner_type, "albumid" => $albumid, "filename" => $file, "caption" => !empty($_POST['content']) ? $_POST['content'] : ""]);
         if ($newsfeed_post) {
             $posts = new Posts();
             return $posts->post(["wall_owner_id" => $_POST['wall_owner_id'], "wall_owner_type" => $_POST['wall_owner_type'], "wall_id" => $_POST['wall_id'], "privacy" => $_POST['privacy'], "userid" => $owner_id, "content" => $imageid, "type" => "image"]);
         }
         return ["filename" => $file, "imageid" => $imageid];
     }
     return false;
 }