From 2cacf35072c21987ad58b9885746cf3f06934c30 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 15 Jun 2022 16:00:40 +0200 Subject: [PATCH] Fix migration, add planel config, only enable/disable registration --- TODO_LIST.md | 23 +++++++--- fuel/app/classes/controller/admin.php | 13 ------ .../classes/controller/admin/libraries.php | 15 ------- fuel/app/classes/controller/admin/users.php | 21 +++++++++ fuel/app/classes/controller/login.php | 7 ++- fuel/app/classes/controller/register.php | 7 ++- fuel/app/classes/controller/security.php | 1 + .../classes/controller/settings/libraries.php | 2 +- fuel/app/classes/model/user.php | 2 +- fuel/app/config/migrations.php | 19 ++++---- fuel/app/config/panel.php | 25 +++++++++++ fuel/app/config/routes.php | 3 +- fuel/app/migrations/001_create_library.php | 30 +++++++++++++ .../002_create_library_permission.php | 28 ++++++++++++ fuel/app/migrations/003_create_movie.php | 44 +++++++++++++++++++ fuel/app/migrations/004_create_permission.php | 21 +++++++++ fuel/app/migrations/005_create_season.php | 32 ++++++++++++++ fuel/app/migrations/006_create_server.php | 35 +++++++++++++++ fuel/app/migrations/007_create_tvshow.php | 41 +++++++++++++++++ fuel/app/migrations/008_create_user.php | 29 ++++++++++++ .../migrations/009_create_user_download.php | 27 ++++++++++++ .../migrations/010_create_user_history.php | 2 +- fuel/app/views/admin/users.php | 2 +- fuel/app/views/login/index.php | 2 + 24 files changed, 380 insertions(+), 51 deletions(-) create mode 100644 fuel/app/classes/controller/admin/users.php create mode 100644 fuel/app/config/panel.php create mode 100644 fuel/app/migrations/001_create_library.php create mode 100644 fuel/app/migrations/002_create_library_permission.php create mode 100644 fuel/app/migrations/003_create_movie.php create mode 100644 fuel/app/migrations/004_create_permission.php create mode 100644 fuel/app/migrations/005_create_season.php create mode 100644 fuel/app/migrations/006_create_server.php create mode 100644 fuel/app/migrations/007_create_tvshow.php create mode 100644 fuel/app/migrations/008_create_user.php create mode 100644 fuel/app/migrations/009_create_user_download.php diff --git a/TODO_LIST.md b/TODO_LIST.md index a381468..0b48de9 100644 --- a/TODO_LIST.md +++ b/TODO_LIST.md @@ -21,7 +21,17 @@ - [x] List last Movies - [x] List last TvShow - [ ] Search - - [x] By Name + - [x] By Movie Name + - [x] By TvShows Name + - [x] By Episode Name +- [ ] Panel Configuration + - [x] Enable/Disabled registration + - [ ] Force user to use token on registration + - [ ] Enable/Disable Queue to limit connection + - [ ] Enable/Disable Guest account with limited permissions + - [ ] Enable/Disable Achievements + - [ ] Allow user to add his self Plex Server + - [ ] Enable/Disable Sub-accounts - [ ] Movies - [x] Title - [x] Description @@ -51,7 +61,7 @@ - [X] Add server - [X] Edit server - [X] Disable Server - - [X] Delete server + - [ ] Delete server - [ ] Check state and latence (cron) - [ ] Management Libraries - [x] List libraries @@ -66,12 +76,13 @@ - [ ] Netflix [OTHER] - [ ] Cache - [ ] Cache Libraries [OTHER] - - [x] Cache Media MetaData [OTHER] + - [x] Cache Media MetaData - [ ] Cache SQL request [OTHER] + - [ ] Migrate Cache to redis for performance - [ ] Streaming - [ ] Implement Video Player that stay when we change of page [OTHER] -- [ ] Management PlexServer - - [ ] Stream directly from PlexServer or use the site like a web-proxy [OTHER] +- [x] Management PlexServer + - [x] Stream directly from PlexServer or use the site like a web-proxy - [ ] Management User - [ ] Add sub-account [OTHER] - [ ] Edit sub-account [OTHER] @@ -79,7 +90,7 @@ - [ ] List of session [OTHER] - [ ] Ban IP [OTHER] - [ ] Delete Account [OTHER] - - [ ] Limit acces to ip [OTHER] + - [ ] Limit access by ip [OTHER] - [ ] Management Permission - [ ] Limit Quality [OTHER] - [ ] Limit number streaming [OTHER] diff --git a/fuel/app/classes/controller/admin.php b/fuel/app/classes/controller/admin.php index 12f2496..7df8c3d 100755 --- a/fuel/app/classes/controller/admin.php +++ b/fuel/app/classes/controller/admin.php @@ -47,17 +47,4 @@ class Controller_Admin extends Controller_Security $this->template->body = $body; } - - public function action_users() - { - $this->template->js_bottom = ['plex_alert.js']; - - $body = View::forge('admin/users'); - - $users = Model_User::find_all(); - - $body->set('users', $users); - - $this->template->body = $body; - } } diff --git a/fuel/app/classes/controller/admin/libraries.php b/fuel/app/classes/controller/admin/libraries.php index 0fb4545..b82a074 100644 --- a/fuel/app/classes/controller/admin/libraries.php +++ b/fuel/app/classes/controller/admin/libraries.php @@ -17,19 +17,4 @@ class Controller_Admin_Libraries extends Controller_Admin $this->template->body = $body; } - - public function action_permissions() - { - - $body = View::forge('admin/libraries/permissions'); - - $library_id = $this->param('library_id'); - - $permissions = Model_Permission::find_all(); - - $body->set('permissions', $permissions); - $body->set('user', Session::get('user')); - - $this->template->body = $body; - } } \ No newline at end of file diff --git a/fuel/app/classes/controller/admin/users.php b/fuel/app/classes/controller/admin/users.php new file mode 100644 index 0000000..5ae72d2 --- /dev/null +++ b/fuel/app/classes/controller/admin/users.php @@ -0,0 +1,21 @@ +template->js_bottom = ['plex_alert.js']; + + $body = View::forge('admin/users'); + + $users = Model_User::find_all(); + + $body->set('users', $users); + + $this->template->body = $body; + } +} \ No newline at end of file diff --git a/fuel/app/classes/controller/login.php b/fuel/app/classes/controller/login.php index dbd43b2..f81f1d5 100755 --- a/fuel/app/classes/controller/login.php +++ b/fuel/app/classes/controller/login.php @@ -30,10 +30,15 @@ class Controller_Login extends Controller { $view = View::forge('login/index'); $start_js = Asset::js('jquery.min.js'); + + $panel = Config::load('panel', true); + + $view->set('registration', (bool)$panel['registration']); + try { - $config = Config::load('db', true); if (Input::method() === 'POST') { + $config = Config::load('db', true); $login = Input::post('email'); $password = Input::post('password'); diff --git a/fuel/app/classes/controller/register.php b/fuel/app/classes/controller/register.php index 4645f4f..7ba0f89 100755 --- a/fuel/app/classes/controller/register.php +++ b/fuel/app/classes/controller/register.php @@ -18,6 +18,11 @@ class Controller_Register extends Controller if(!$lock) Response::redirect('/install'); + $panel = Config::load('panel', true); + + if(!$panel['registration']) + Response::redirect('/login'); + $user = Session::get('user'); if($user) @@ -45,7 +50,7 @@ class Controller_Register extends Controller if (Input::post('password') !== Input::post('confirm_password')) throw new FuelException('Your password are not identical'); - if(Model_User::EmailAlreadyUse(Input::post('email'))) + if(Model_User::EmailAlreadyUsed(Input::post('email'))) throw new FuelException('Email already use!'); $config = Config::load('db', true); diff --git a/fuel/app/classes/controller/security.php b/fuel/app/classes/controller/security.php index c68a307..6dfb427 100644 --- a/fuel/app/classes/controller/security.php +++ b/fuel/app/classes/controller/security.php @@ -19,6 +19,7 @@ if(!$user) Response::redirect('/login'); } + public function action_index() { // DO NOTHING diff --git a/fuel/app/classes/controller/settings/libraries.php b/fuel/app/classes/controller/settings/libraries.php index feab7bc..97b9974 100644 --- a/fuel/app/classes/controller/settings/libraries.php +++ b/fuel/app/classes/controller/settings/libraries.php @@ -37,7 +37,7 @@ class Controller_Settings_Libraries extends Controller_Settings $permissions = Model_Permission::find_by('disable', 0); - $library_permissions = Model_Library_Permission::find_by('library_id', $library_id); + $library_permissions = Model_Library_Permission::find_by('library_id', $library_id) ?: []; $temp = []; diff --git a/fuel/app/classes/model/user.php b/fuel/app/classes/model/user.php index 7dd516d..20bef99 100755 --- a/fuel/app/classes/model/user.php +++ b/fuel/app/classes/model/user.php @@ -20,7 +20,7 @@ class Model_User extends Model_Overwrite 'disable', ); - public static function EmailAlreadyUse($email) + public static function EmailAlreadyUsed($email) { $result = self::find(function ($query) use ($email){ return $query diff --git a/fuel/app/config/migrations.php b/fuel/app/config/migrations.php index 0de3b57..6086c67 100644 --- a/fuel/app/config/migrations.php +++ b/fuel/app/config/migrations.php @@ -6,19 +6,18 @@ return array( array( 'default' => array( - 0 => '001_create_configurations', - 1 => '002_create_library', - 2 => '003_create_library_permission', - 3 => '004_create_movie', - 4 => '005_create_permission', - 5 => '006_create_season', - 6 => '007_create_server', - 7 => '008_create_tvshow', - 8 => '009_create_user', + 0 => '001_create_library', + 1 => '002_create_library_permission', + 2 => '003_create_movie', + 3 => '004_create_permission', + 4 => '005_create_season', + 5 => '006_create_server', + 6 => '007_create_tvshow', + 7 => '008_create_user', + 8 => '009_create_user_download', 9 => '010_create_user_history', 10 => '011_create_user_permission', 11 => '012_create_user_settings', - 12 => '013_create_user_download', ), ), 'module' => diff --git a/fuel/app/config/panel.php b/fuel/app/config/panel.php new file mode 100644 index 0000000..7a7623f --- /dev/null +++ b/fuel/app/config/panel.php @@ -0,0 +1,25 @@ + true, + + // Force use to have an invite code when register + 'invitation' => false, + + // Limit the number of user connected to server + 'queue' => false, + 'max_connected' => 0, // need queue true + + // Alow anyone to use guest account with retricted permissions + // No download and no watching + 'guest' => false, + + // Enable/Disabled the achievements + 'achievements' => false, + + // Allow anyone to add plex server + 'add_server' => true, + + // Allow user to create sub-account + 'sub_accounts' => true, +]; \ No newline at end of file diff --git a/fuel/app/config/routes.php b/fuel/app/config/routes.php index 4650d3d..1d53a65 100755 --- a/fuel/app/config/routes.php +++ b/fuel/app/config/routes.php @@ -13,5 +13,6 @@ return array( 'movie/:movie_id/video/\:/transcode/:transcode/session/:session/:index/:base' => 'movie/stream', 'movie/:movie_id/download' => 'movie/download', 'movie/:movie_id' => 'movie/index', - 'settings/libraries/premissions/:library_id' => 'settings/libraries/permissions' + 'settings/libraries/premissions/:library_id' => 'settings/libraries/permissions', + 'admin/users/premissions/:user_id' => 'admin/users/permissions' ); diff --git a/fuel/app/migrations/001_create_library.php b/fuel/app/migrations/001_create_library.php new file mode 100644 index 0000000..3a0fbf5 --- /dev/null +++ b/fuel/app/migrations/001_create_library.php @@ -0,0 +1,30 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'server_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'plex_key' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'name' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'type' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'updatedAt' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'createdAt' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'scannedAt' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintServerLibrary ON ' . \DB::table_prefix('library') . '(`server_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintServerLibrary ON ' . \DB::table_prefix('library'))->execute(); + + \DBUtil::drop_table('library'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/002_create_library_permission.php b/fuel/app/migrations/002_create_library_permission.php new file mode 100644 index 0000000..9d90979 --- /dev/null +++ b/fuel/app/migrations/002_create_library_permission.php @@ -0,0 +1,28 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'permission_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'library_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'value' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintPermissionLibrariesPermission ON ' . \DB::table_prefix('library_permission') . '(`permission_id`)')->execute(); + \DB::query('CREATE INDEX constraintLibraryLibrariesPermission ON ' . \DB::table_prefix('library_permission') . '(`library_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintPermissionLibrariesPermission ON ' . \DB::table_prefix('library_permission'))->execute(); + \DB::query('DROP INDEX constraintLibraryLibrariesPermission ON ' . \DB::table_prefix('library_permission'))->execute(); + + \DBUtil::drop_table('library_permission'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/003_create_movie.php b/fuel/app/migrations/003_create_movie.php new file mode 100644 index 0000000..9bab534 --- /dev/null +++ b/fuel/app/migrations/003_create_movie.php @@ -0,0 +1,44 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'library_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'season_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'type' => array('type' => 'varchar', 'null' => false, 'constraint' => 20), + 'number' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'studio' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'originalTitle' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'summary' => array('type' => 'text', 'null' => true), + 'rating' => array('type' => 'varchar', 'null' => true, 'constraint' => 4), + 'year' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'duration' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'originallyAvailableAt' => array('type' => 'varchar', 'null' => true, 'constraint' => 11), + 'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintMovieLibrary ON ' . \DB::table_prefix('movie') . '(`library_id`)')->execute(); + \DB::query('CREATE INDEX constraintMovieSeason ON ' . \DB::table_prefix('movie') . '(`season_id`)')->execute(); + \DB::query('CREATE INDEX searchTitle ON ' . \DB::table_prefix('movie') . '(`title` DESC)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintMovieLibrary ON ' . \DB::table_prefix('movie'))->execute(); + \DB::query('DROP INDEX constraintMovieSeason ON ' . \DB::table_prefix('movie'))->execute(); + \DB::query('DROP INDEX searchTitle ON ' . \DB::table_prefix('movie'))->execute(); + + \DBUtil::drop_table('movie'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/004_create_permission.php b/fuel/app/migrations/004_create_permission.php new file mode 100644 index 0000000..a72ec39 --- /dev/null +++ b/fuel/app/migrations/004_create_permission.php @@ -0,0 +1,21 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'name' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'parameters' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + } + + public function down() + { + \DBUtil::drop_table('permission'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/005_create_season.php b/fuel/app/migrations/005_create_season.php new file mode 100644 index 0000000..f6dc200 --- /dev/null +++ b/fuel/app/migrations/005_create_season.php @@ -0,0 +1,32 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'tv_show_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'number' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'leafCount' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintSeasonTvShow ON ' . \DB::table_prefix('season') . '(`tv_show_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintSeasonTvShow ON ' . \DB::table_prefix('season'))->execute(); + + \DBUtil::drop_table('season'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/006_create_server.php b/fuel/app/migrations/006_create_server.php new file mode 100644 index 0000000..c837764 --- /dev/null +++ b/fuel/app/migrations/006_create_server.php @@ -0,0 +1,35 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'https' => array('type' => 'int', 'null' => false, 'constraint' => 1), + 'url' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'port' => array('type' => 'int', 'null' => true, 'constraint' => 2), + 'token' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'lastcheck' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'name' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'plateforme' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'platformVersion' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'version' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'online' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintServerUser ON ' . \DB::table_prefix('server') . '(`user_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintServerUser ON ' . \DB::table_prefix('server'))->execute(); + + \DBUtil::drop_table('server'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/007_create_tvshow.php b/fuel/app/migrations/007_create_tvshow.php new file mode 100644 index 0000000..5c9ee95 --- /dev/null +++ b/fuel/app/migrations/007_create_tvshow.php @@ -0,0 +1,41 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'library_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'studio' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'contentRating' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'summary' => array('type' => 'text', 'null' => true), + 'rating' => array('type' => 'varchar', 'null' => true, 'constraint' => 4), + 'year' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'banner' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'theme' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'originallyAvailableAt' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'leafCount' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintTvShowLibrary ON ' . \DB::table_prefix('tvshow') . '(`library_id`)')->execute(); + \DB::query('CREATE INDEX searchTitle ON ' . \DB::table_prefix('tvshow') . '(`title` DESC)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintTvShowLibrary ON ' . \DB::table_prefix('tvshow'))->execute(); + \DB::query('DROP INDEX searchTitle ON ' . \DB::table_prefix('tvshow'))->execute(); + + \DBUtil::drop_table('tvshow'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/008_create_user.php b/fuel/app/migrations/008_create_user.php new file mode 100644 index 0000000..d41baa4 --- /dev/null +++ b/fuel/app/migrations/008_create_user.php @@ -0,0 +1,29 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'username' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'email' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'password' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'admin' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + 'lastlogin' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'parent_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintUserUser ON ' . \DB::table_prefix('user') . '(`parent_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintUserUser ON ' . \DB::table_prefix('user'))->execute(); + + \DBUtil::drop_table('user'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/009_create_user_download.php b/fuel/app/migrations/009_create_user_download.php new file mode 100644 index 0000000..73ddd6b --- /dev/null +++ b/fuel/app/migrations/009_create_user_download.php @@ -0,0 +1,27 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'movie_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'date' => array('type' => 'int', 'null' => false, 'constraint' => 11), + ), array('id')); + + \DB::query('CREATE INDEX constraintDownloadUser ON ' . \DB::table_prefix('user_download') . '(`user_id`)')->execute(); + \DB::query('CREATE INDEX constraintDownloadMovie ON ' . \DB::table_prefix('user_download') . '(`movie_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintDownloadUser ON ' . \DB::table_prefix('user_download'))->execute(); + \DB::query('DROP INDEX constraintDownloadMovie ON ' . \DB::table_prefix('user_download'))->execute(); + + \DBUtil::drop_table('user_download'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/010_create_user_history.php b/fuel/app/migrations/010_create_user_history.php index 21f4169..becaf4e 100644 --- a/fuel/app/migrations/010_create_user_history.php +++ b/fuel/app/migrations/010_create_user_history.php @@ -13,7 +13,7 @@ class Create_user_history 'watching_time' => array('type' => 'int', 'null' => false, 'constraint' => 11), 'ended_time' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 11), 'is_ended' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), - 'date' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + 'date' => array('type' => 'int', 'null' => false, 'constraint' => 11), ), array('id')); \DB::query('CREATE INDEX constraintUserUserHistory ON ' . \DB::table_prefix('user_history') . '(`user_id`)')->execute(); diff --git a/fuel/app/views/admin/users.php b/fuel/app/views/admin/users.php index 3a21a15..4f1936d 100644 --- a/fuel/app/views/admin/users.php +++ b/fuel/app/views/admin/users.php @@ -9,7 +9,7 @@