diff --git a/fuel/app/classes/controller/rest/browse.php b/fuel/app/classes/controller/rest/browse.php index d520267..84da274 100644 --- a/fuel/app/classes/controller/rest/browse.php +++ b/fuel/app/classes/controller/rest/browse.php @@ -6,7 +6,19 @@ use Fuel\Core\Session; class Controller_Rest_Browse extends Controller_Rest { - public function get_servers() + public function get_server() + { + $servers = Model_Server::find(array( + 'select' => array('id','name', 'url', 'port', 'token'), + 'where' => array( + 'id' => Input::get('server_id'), + ) + )); + + $this->response($servers); + } + + public function get_servers() { $servers = Model_Server::find(array( 'select' => array('id','name'), diff --git a/fuel/app/classes/controller/rest/settings.php b/fuel/app/classes/controller/rest/settings.php index d8f0b20..a07b1ec 100644 --- a/fuel/app/classes/controller/rest/settings.php +++ b/fuel/app/classes/controller/rest/settings.php @@ -18,20 +18,20 @@ class Controller_Rest_Settings extends Controller_Rest public function post_server() { try { + $server_id = Input::post('server_id'); $url = Input::post('url'); - - //@TODO CHECK AND REMOVE HTTP AND HTTPS - $port = Input::post('port'); $token = Input::post('token'); + //@TODO CHECK AND REMOVE HTTP AND HTTPS + $curl = Request::forge('http://' . $url . ($port ? ':' . $port : '') . '/?X-Plex-Token=' . $token, 'curl'); $result = $curl->execute(); if(!$result) throw new FuelException('Can not connect to your server!'); - $server = Model_Server::forge(); + $server = $server_id === null ? Model_Server::forge() : Model_Server::find_by_pk($server_id); $server->set([ 'user_id' => Session::get('user')->id, 'url' => $url, diff --git a/fuel/app/classes/controller/settings.php b/fuel/app/classes/controller/settings.php index 2ef432c..f4cecb8 100644 --- a/fuel/app/classes/controller/settings.php +++ b/fuel/app/classes/controller/settings.php @@ -41,7 +41,6 @@ class Controller_Settings extends Controller_Template $servers = Model_Server::find(function($query) use($user_id) { $query ->where('user_id', $user_id) - ->and_where('disable', 0) ; }); diff --git a/fuel/app/views/modal/modal.php b/fuel/app/views/modal/modal.php index 3fa057d..4b544d0 100755 --- a/fuel/app/views/modal/modal.php +++ b/fuel/app/views/modal/modal.php @@ -8,6 +8,7 @@