public static function removeLinks(MLArray $link_ids) { $links_array = $link_ids->mkArray(); (new SelectQuery(TPlaylistSongLinks::_NAME))->where(TPlaylistSongLinks::LINK_ID, $links_array)->innerJoin(TPlaylists::_NAME, TPlaylists::ID, TPlaylistSongLinks::PLAYLIST_ID)->select(TPlaylists::USER_ID)->eachRow(function ($row) { if ($row[TPlaylists::USER_ID] != self::$me->getId()) { throw new UnauthorizedException("Sorry, but you trying to delete tracks from other user's playlist"); } }); (new DeleteQuery(TPlaylistSongLinks::_NAME))->where(TPlaylistSongLinks::LINK_ID, $links_array)->update(); }
public static function doPost(JsonResponse $response, $link_id) { Playlist::removeLinks(MLArray::split(",", $link_id)); }