diff --git a/fuel/app/classes/controller/rest/install.php b/fuel/app/classes/controller/rest/install.php index c2f0ae9..172a01d 100755 --- a/fuel/app/classes/controller/rest/install.php +++ b/fuel/app/classes/controller/rest/install.php @@ -213,7 +213,7 @@ class Controller_Rest_Install extends Controller_Rest 'plex_key' => array('constraint' => 36, 'type' => 'varchar'), 'type' => array('constraint' => 20, 'type' => 'varchar'), 'number' => array('constraint' => 11, 'type' => 'int', 'null' => true), - 'studio' => array('constraint' => 36, 'type' => 'varchar', 'null' => true), + 'studio' => array('constraint' => 255, 'type' => 'varchar', 'null' => true), 'title' => array('constraint' => 255, 'type' => 'varchar'), 'originalTitle' => array('constraint' => 255, 'type' => 'varchar', 'null' => true), 'summary' => array('type' => 'text', 'null' => true), diff --git a/fuel/app/classes/controller/rest/movie.php b/fuel/app/classes/controller/rest/movie.php index b8cf7f1..0877334 100644 --- a/fuel/app/classes/controller/rest/movie.php +++ b/fuel/app/classes/controller/rest/movie.php @@ -17,12 +17,13 @@ class Controller_Rest_Movie extends Controller_Rest if (!$movie_id) throw new FuelException('No movie id'); + /** @var Model_Movie $movie */ $movie = Model_Movie::find_by_pk($movie_id); if (!$movie) throw new FuelException('No movie found'); - if(!Model_Permission::isGranted('RIGHT_WATCH_DISABLED', $movie)) + if (!Model_Permission::isGranted('RIGHT_WATCH_DISABLED', $movie->getLibrary())) throw new FuelException('You dont have the permission to watch in this library!'); $user_settings = Model_Setting::find_one_by('user_id', Session::get('user')->id); diff --git a/fuel/app/classes/model/movie.php b/fuel/app/classes/model/movie.php index 9b7b3a3..2c302f9 100644 --- a/fuel/app/classes/model/movie.php +++ b/fuel/app/classes/model/movie.php @@ -66,6 +66,9 @@ class Model_Movie extends Model_Overwrite return $this->_tv_show; } + /** + * @return Model_Library|null + */ public function getLibrary() { if(!$this->_library) { @@ -428,7 +431,9 @@ class Model_Movie extends Model_Overwrite ->and_where('library_id', $library_id) ->and_where_close() ; - })[0] ?: Model_Movie::forge(); + }); + + $movie = $movie !== null ? $movie[0] : Model_Movie::forge(); if($library === null && $season === null) throw new FuelException('Missing Parameters for the movie'); diff --git a/fuel/app/classes/model/season.php b/fuel/app/classes/model/season.php index 9800e89..affd550 100644 --- a/fuel/app/classes/model/season.php +++ b/fuel/app/classes/model/season.php @@ -133,7 +133,9 @@ class Model_Season extends Model_Overwrite ->select('*') ->where('plex_key', $XMLseason['@attributes']['ratingKey']) ->and_where('tv_show_id', $tvshow_id); - })[0] ?: Model_Season::forge(); + }); + + $season = $season !== null ? $season[0] : Model_Season::forge(); $season->set([ 'tv_show_id' => $tvshow->id, diff --git a/fuel/app/classes/model/tvshow.php b/fuel/app/classes/model/tvshow.php index 514dc97..563d76d 100644 --- a/fuel/app/classes/model/tvshow.php +++ b/fuel/app/classes/model/tvshow.php @@ -164,7 +164,9 @@ class Model_Tvshow extends Model_Overwrite ->select('*') ->where('plex_key', $subsection['@attributes']['ratingKey']) ->and_where('library_id', $library_id); - })[0] ?: Model_Tvshow::forge(); + }); + + $tvshow = $tvshow !== null ? $tvshow[0] : Model_Tvshow::forge(); $tvshow->set([ 'library_id' => $library->id, @@ -226,7 +228,7 @@ class Model_Tvshow extends Model_Overwrite $seasons = Format::forge($curl->response()->body, 'xml')->to_array(); - if (isset($seasons['Directory'])) + if ($seasons !== null && isset($seasons['Directory'])) return Model_Season::BrowseSeason($server, $seasons['Directory'], $tvshow); } catch (Exception $exception) { throw new FuelException($exception->getMessage(),$exception->getCode()); diff --git a/fuel/app/views/home/index.php b/fuel/app/views/home/index.php index e15216b..627eed0 100755 --- a/fuel/app/views/home/index.php +++ b/fuel/app/views/home/index.php @@ -11,8 +11,7 @@