requireUser(); if(!empty($videos)) { $vids = explode(',', $videos); foreach($vids as $vid) { $id = explode("_", $vid); $items = []; $video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1])); if($video) { if(!$video->canBeViewedBy($this->getUser() ?? NULL)) { continue; } $items[] = $video->getApiStructure(); } } return (object) [ "count" => count($items), "items" => $items ]; } else { if ($owner_id > 0) $user = (new UsersRepo)->get($owner_id); else $this->fail(1, "Not implemented"); if(!$user->getPrivacyPermission('videos.read', $this->getUser())) { $this->fail(20, "Access denied: this user chose to hide his videos"); } $videos = (new VideosRepo)->getByUser($user, $offset + 1, $count); $videosCount = (new VideosRepo)->getUserVideosCount($user); $items = []; foreach ($videos as $video) { if(!$video->canBeViewedBy($this->getUser() ?? NULL)) { $this->fail(8, "Access denied"); } $items[] = $video->getApiStructure(); } return (object) [ "count" => $videosCount, "items" => $items ]; } } }