diff --git a/Changelog b/Changelog index 76ef85f96..1ac0eeba5 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-04-18 DariusIII + * Chg: Add ReleasesController * Chg: Add MgrPosterController * Chg: Add TmuxController * Chg: Add AjaxController, update utils-admin.js diff --git a/app/Http/Controllers/Admin/ReleasesController.php b/app/Http/Controllers/Admin/ReleasesController.php new file mode 100644 index 000000000..875d7e8d3 --- /dev/null +++ b/app/Http/Controllers/Admin/ReleasesController.php @@ -0,0 +1,119 @@ +setAdminPrefs(); + + $title = 'Release List'; + + $pager = $this->smarty->fetch('pager.tpl'); + $this->smarty->assign('pager', $pager); + + $releaseList = Release::getReleasesRange(); + $this->smarty->assign('releaselist', $releaseList); + + $content = $this->smarty->fetch('release-list.tpl'); + + $this->smarty->assign( + [ + 'title' => $title, + 'content' => $content, + ] + ); + + $this->adminrender(); + } + + /** + * @param \Illuminate\Http\Request $request + * + * @throws \Exception + */ + public function edit(Request $request) + { + $this->setAdminPrefs(); + +// Set the current action. + $action = ($request->input('action') ?? 'view'); + + switch ($action) { + case 'submit': + Release::updateRelease( + $request->input('id'), + $request->input('name'), + $request->input('searchname'), + $request->input('fromname'), + $request->input('category'), + $request->input('totalpart'), + $request->input('grabs'), + $request->input('size'), + $request->input('postdate'), + $request->input('adddate'), + $request->input('videos_id'), + $request->input('tv_episodes_id'), + $request->input('imdbid'), + $request->input('anidbid') + ); + + $release = Release::getByGuid($request->input('guid')); + $this->smarty->assign('release', $release); + + return redirect('details/'.$release['guid']); + break; + + case 'view': + default: + $title = 'Release Edit'; + $id = $request->input('id'); + $release = Release::getByGuid($id); + $this->smarty->assign('release', $release); + break; + } + + $this->smarty->assign('yesno_ids', [1, 0]); + $this->smarty->assign('yesno_names', ['Yes', 'No']); + $this->smarty->assign('catlist', Category::getForSelect(false)); + + $content = $this->smarty->fetch('release-edit.tpl'); + + $this->smarty->assign( + [ + 'title' => $title, + 'content' => $content, + ] + ); + + $this->adminrender(); + } + + /** + * @param $id + * + * @return \Illuminate\Http\RedirectResponse + * @throws \Exception + */ + public function destroy($id) + { + if ($id) { + $releases = new Releases(['Settings' => $this->pdo]); + $releases->deleteMultiple($id); + } + + return redirect()->back(); + } +} diff --git a/app/Models/Release.php b/app/Models/Release.php index 6485bba3f..01f77f3ed 100644 --- a/app/Models/Release.php +++ b/app/Models/Release.php @@ -325,13 +325,11 @@ class Release extends Model * Used for admin page release-list. * * - * @param $start - * @param $num - * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[] + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|mixed */ - public static function getReleasesRange($start, $num) + public static function getReleasesRange() { - $range = Cache::get(md5($start.$num)); + $range = Cache::get('range'); if ($range !== null) { return $range; } @@ -353,15 +351,12 @@ class Release extends Model ->selectRaw('CONCAT(cp.title, ' > ', c.title) AS category_name') ->leftJoin('categories as c', 'c.id', '=', 'releases.categories_id') ->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid') - ->orderBy('releases.postdate', 'desc'); - if ($start !== false) { - $query->limit($num)->offset($start); - } + ->orderByDesc('releases.postdate'); - $range = $query->get(); + $range = $query->paginate(config('nntmux.items_per_page')); $expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium')); - Cache::put(md5($start.$num), $range, $expiresAt); + Cache::put('range', $range, $expiresAt); return $range; } diff --git a/public/oldadmin/release-delete.php b/public/oldadmin/release-delete.php deleted file mode 100644 index 6a99bd59a..000000000 --- a/public/oldadmin/release-delete.php +++ /dev/null @@ -1,16 +0,0 @@ -has('id')) { - $releases = new Releases(['Settings' => $page->pdo]); - $releases->deleteMultiple(request()->input('id')); -} - -$referrer = request()->server('HTTP_REFERER'); - -header('Location: '.$referrer); diff --git a/public/oldadmin/release-edit.php b/public/oldadmin/release-edit.php deleted file mode 100644 index 48b5be22b..000000000 --- a/public/oldadmin/release-edit.php +++ /dev/null @@ -1,57 +0,0 @@ -setAdminPrefs(); -$releases = new Releases(['Settings' => $page->pdo]); -$id = 0; - -// Set the current action. -$action = (request()->input('action') ?? 'view'); - -switch ($action) { - case 'submit': - Release::updateRelease( - request()->input('id'), - request()->input('name'), - request()->input('searchname'), - request()->input('fromname'), - request()->input('category'), - request()->input('totalpart'), - request()->input('grabs'), - request()->input('size'), - request()->input('postdate'), - request()->input('adddate'), - request()->input('videos_id'), - request()->input('tv_episodes_id'), - request()->input('imdbid'), - request()->input('anidbid') - ); - - $release = Release::getByGuid(request()->input('guid')); - $page->smarty->assign('release', $release); - - header('Location:'.WWW_TOP.'/../details/'.$release['guid']); - break; - - case 'view': - default: - $page->title = 'Release Edit'; - $id = request()->input('id'); - $release = Release::getByGuid($id); - $page->smarty->assign('release', $release); - break; -} - -$page->smarty->assign('yesno_ids', [1, 0]); -$page->smarty->assign('yesno_names', ['Yes', 'No']); -$page->smarty->assign('catlist', Category::getForSelect(false)); - -$page->content = $page->smarty->fetch('release-edit.tpl'); -$page->adminrender(); diff --git a/public/oldadmin/release-files.php b/public/oldadmin/release-files.php deleted file mode 100644 index ee808b89a..000000000 --- a/public/oldadmin/release-files.php +++ /dev/null @@ -1,46 +0,0 @@ -setAdminPrefs(); - -$pdo = new DB(); -$nzb = new NZB(); - -if (request()->has('id')) { - $rel = Release::getByGuid(request()->input('id')); - if (! $rel) { - $page->show404(); - } - - $nzbpath = $nzb->getNZBPath(request()->input('id'), Settings::settingValue('..nzbpath')); - - if (! file_exists($nzbpath)) { - $page->show404(); - } - - ob_start(); - @readgzfile($nzbpath); - $nzbfile = ob_get_contents(); - ob_end_clean(); - - $ret = $nzb->nzbFileList($nzbfile); - - $page->smarty->assign('rel', $rel); - $page->smarty->assign('files', $ret); - - $page->title = 'File List'; - $page->meta_title = 'View Nzb file list'; - $page->meta_keywords = 'view,nzb,file,list,description,details'; - $page->meta_description = 'View Nzb File List'; - - $page->content = $page->smarty->fetch('release-files.tpl'); - $page->adminrender(); -} diff --git a/public/oldadmin/release-list.php b/public/oldadmin/release-list.php deleted file mode 100644 index 3fe705902..000000000 --- a/public/oldadmin/release-list.php +++ /dev/null @@ -1,32 +0,0 @@ -setAdminPrefs(); - -$page->title = 'Release List'; - -$releasecount = Release::getReleasesCount(); - -$offset = request()->input('offset') ?? 0; - -$page->smarty->assign([ - 'pagertotalitems' => $releasecount, - 'pagerquerysuffix' => '#results', - 'pageroffset' => $offset, - 'pageritemsperpage' => config('nntmux.items_per_page'), - 'pagerquerybase' => WWW_TOP.'/release-list.php?offset=', -]); - -$pager = $page->smarty->fetch('pager.tpl'); -$page->smarty->assign('pager', $pager); - -$releaselist = Release::getReleasesRange($offset, config('nntmux.items_per_page')); -$page->smarty->assign('releaselist', $releaselist); - -$page->content = $page->smarty->fetch('release-list.tpl'); -$page->adminrender(); diff --git a/resources/views/themes/Charisma/console.tpl b/resources/views/themes/Charisma/console.tpl index fe719c3a1..4d50b00f7 100755 --- a/resources/views/themes/Charisma/console.tpl +++ b/resources/views/themes/Charisma/console.tpl @@ -135,7 +135,7 @@ {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Charisma/games.tpl b/resources/views/themes/Charisma/games.tpl index c0c4a5e5f..a97b7ede7 100755 --- a/resources/views/themes/Charisma/games.tpl +++ b/resources/views/themes/Charisma/games.tpl @@ -145,7 +145,7 @@ ago {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Charisma/music.tpl b/resources/views/themes/Charisma/music.tpl index 033ad309c..8e19215af 100755 --- a/resources/views/themes/Charisma/music.tpl +++ b/resources/views/themes/Charisma/music.tpl @@ -116,7 +116,7 @@ Posted {$mpostdate[$m@index]|timeago} ago {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Charisma/viewnzb.tpl b/resources/views/themes/Charisma/viewnzb.tpl index eca93fb60..9a029281a 100755 --- a/resources/views/themes/Charisma/viewnzb.tpl +++ b/resources/views/themes/Charisma/viewnzb.tpl @@ -16,10 +16,10 @@ {$release.grabs} Grab{if $release.grabs != 1}s{/if} / {$failed} Failed Download{if $failed != 1}s{/if}{/if} {if isset($isadmin)} Edit Delete {/if} {if $movie && $release.videos_id <= 0 && $movie.imdbid > 0} diff --git a/resources/views/themes/Charisma/viewseries.tpl b/resources/views/themes/Charisma/viewseries.tpl index a4df42098..fd92be39a 100755 --- a/resources/views/themes/Charisma/viewseries.tpl +++ b/resources/views/themes/Charisma/viewseries.tpl @@ -219,10 +219,10 @@ {if isset($isadmin)}
Edit Delete {/if} diff --git a/resources/views/themes/Gamma/console.tpl b/resources/views/themes/Gamma/console.tpl index 001d9080e..e835674ca 100755 --- a/resources/views/themes/Gamma/console.tpl +++ b/resources/views/themes/Gamma/console.tpl @@ -179,10 +179,10 @@ title="View similar nzbs">Similar {if isset($isadmin)} Edit Delete {/if}
diff --git a/resources/views/themes/Gamma/games.tpl b/resources/views/themes/Gamma/games.tpl index ec2789478..d862b108d 100755 --- a/resources/views/themes/Gamma/games.tpl +++ b/resources/views/themes/Gamma/games.tpl @@ -187,8 +187,8 @@ {/if} {if isset($isadmin)} - Delete - Edit + Delete + Edit {/if} {if isset($result.genre) && $result.genre != ""} diff --git a/resources/views/themes/Gamma/viewnzb.tpl b/resources/views/themes/Gamma/viewnzb.tpl index 42f0e27a7..3ac08bb49 100755 --- a/resources/views/themes/Gamma/viewnzb.tpl +++ b/resources/views/themes/Gamma/viewnzb.tpl @@ -43,8 +43,8 @@
Admin :
- Edit - Delete + Edit + Delete
{/if} diff --git a/resources/views/themes/Gentele/console.tpl b/resources/views/themes/Gentele/console.tpl index 0555df40c..4990eb185 100755 --- a/resources/views/themes/Gentele/console.tpl +++ b/resources/views/themes/Gentele/console.tpl @@ -135,7 +135,7 @@ {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Gentele/games.tpl b/resources/views/themes/Gentele/games.tpl index c0c4a5e5f..a97b7ede7 100755 --- a/resources/views/themes/Gentele/games.tpl +++ b/resources/views/themes/Gentele/games.tpl @@ -145,7 +145,7 @@ ago {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Gentele/music.tpl b/resources/views/themes/Gentele/music.tpl index 679c9cfd1..91f9fe68b 100755 --- a/resources/views/themes/Gentele/music.tpl +++ b/resources/views/themes/Gentele/music.tpl @@ -129,7 +129,7 @@ Posted {$mpostdate[$m@index]|timeago} ago {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Gentele/viewnzb.tpl b/resources/views/themes/Gentele/viewnzb.tpl index 845a3a118..08d0c363f 100755 --- a/resources/views/themes/Gentele/viewnzb.tpl +++ b/resources/views/themes/Gentele/viewnzb.tpl @@ -19,10 +19,10 @@ {$failed} Failed Download{if $failed != 1}s{/if}{/if} {if isset($isadmin)} Edit Delete {/if} {if $movie && $release.videos_id <= 0 } diff --git a/resources/views/themes/Omicron/console.tpl b/resources/views/themes/Omicron/console.tpl index 24b0032ca..9ba37abc1 100755 --- a/resources/views/themes/Omicron/console.tpl +++ b/resources/views/themes/Omicron/console.tpl @@ -137,7 +137,7 @@ {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Omicron/games.tpl b/resources/views/themes/Omicron/games.tpl index dbd63d800..4cdda427b 100755 --- a/resources/views/themes/Omicron/games.tpl +++ b/resources/views/themes/Omicron/games.tpl @@ -145,7 +145,7 @@ ago {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Omicron/music.tpl b/resources/views/themes/Omicron/music.tpl index 77bab76df..fdabad78d 100755 --- a/resources/views/themes/Omicron/music.tpl +++ b/resources/views/themes/Omicron/music.tpl @@ -116,7 +116,7 @@ Posted {$mpostdate[$m@index]|timeago} ago {if isset($isadmin)} Edit{/if}
diff --git a/resources/views/themes/Omicron/viewnzb.tpl b/resources/views/themes/Omicron/viewnzb.tpl index 5bb95bb3c..cc1634d71 100755 --- a/resources/views/themes/Omicron/viewnzb.tpl +++ b/resources/views/themes/Omicron/viewnzb.tpl @@ -16,10 +16,10 @@ {$release.grabs} Grab{if $release.grabs != 1}s{/if} / {$failed} Failed Download{if $failed != 1}s{/if}{/if} {if isset($isadmin)} Edit Delete {/if} {if $movie && $release.videos_id <= 0 && $movie.imdbid > 0} diff --git a/resources/views/themes/Omicron/viewseries.tpl b/resources/views/themes/Omicron/viewseries.tpl index 734bc76ee..66e4053f5 100755 --- a/resources/views/themes/Omicron/viewseries.tpl +++ b/resources/views/themes/Omicron/viewseries.tpl @@ -219,10 +219,10 @@ {if isset($isadmin)}
Edit Delete {/if} diff --git a/resources/views/themes/admin/failrel-list.tpl b/resources/views/themes/admin/failrel-list.tpl index d604c6521..b0c702866 100644 --- a/resources/views/themes/admin/failrel-list.tpl +++ b/resources/views/themes/admin/failrel-list.tpl @@ -28,8 +28,8 @@ {$release.adddate|date_format} {$release.grabs} - {if $release.guid}view |{/if} - delete + {if $release.guid}view |{/if} + delete {/foreach} diff --git a/resources/views/themes/admin/release-files.tpl b/resources/views/themes/admin/release-files.tpl deleted file mode 100644 index c2d6c2c03..000000000 --- a/resources/views/themes/admin/release-files.tpl +++ /dev/null @@ -1,25 +0,0 @@ -
-

{$title}

- -

For {$rel.searchname|escape:'htmlall'}

- - - - - - - - - - - {foreach from=$binaries item=binary} - - - - - - - {/foreach} - -
#filenamesizedate
{$binary.relpart}{$binary.filename}{$binary.size|fsize_format:"MB"}{$binary.date|date_format}
-
\ No newline at end of file diff --git a/resources/views/themes/admin/release-list.tpl b/resources/views/themes/admin/release-list.tpl index 72b8a850e..98bdc546f 100644 --- a/resources/views/themes/admin/release-list.tpl +++ b/resources/views/themes/admin/release-list.tpl @@ -27,7 +27,7 @@ {$release.postdate|date_format} {$release.adddate|date_format} {$release.grabs} - delete + delete {/foreach} diff --git a/routes/web.php b/routes/web.php index 2ef0bacbb..43bd04ae1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -268,5 +268,11 @@ Route::prefix('admin')->group(function () { Route::post('posters-edit', 'MgrPosterController@edit'); Route::get('poster-delete/{id}', 'MgrPosterController@destroy'); Route::post('poster-delete/{id}', 'MgrPosterController@destroy'); + Route::get('release-list', 'ReleasesController@index'); + Route::post('release-list', 'ReleasesController@index'); + Route::get('release-edit', 'ReleasesController@edit'); + Route::post('release-edit', 'ReleasesController@edit'); + Route::get('release-delete/{id}', 'ReleasesController@destroy'); + Route::post('release-delete/{id}', 'ReleasesController@destroy'); }); });