diff --git a/Changelog b/Changelog index e170a305d..a7a23ca55 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2018-04-15 DariusIII + * Chg: Update Profile and Forum controllers 2018-04-13 DariusIII * Chg: Add deleteTopic route and function * Chg: Add NfoController and route diff --git a/app/Http/Controllers/ForumController.php b/app/Http/Controllers/ForumController.php index ae5ee0dc8..3890e1dea 100644 --- a/app/Http/Controllers/ForumController.php +++ b/app/Http/Controllers/ForumController.php @@ -125,4 +125,38 @@ class ForumController extends BasePageController return redirect('forum'); } + + public function edit(Request $request) + { + $this->setPrefs(); + + if ($request->has('id') && ! empty($request->input('addMessage'))) { + $parent = Forumpost::getPost($request->input('id')); + Forumpost::editPost($request->input('id'), $request->input('addMessage'), Auth::id()); + if ((int) $parent['parentid'] !== 0) { + header('/forumpost/'.$parent['parentid'].'#last'); + } else { + header('/forumpost/'.$request->input('id')); + } + } + + $result = Forumpost::getPost($request->input('id')); + + $meta_title = 'Edit forum Post'; + $meta_keywords = 'edit, view,forum,post,thread'; + $meta_description = 'Edit forum post'; + + $this->smarty->assign('result', $result); + + $content = $this->smarty->fetch('post_edit.tpl'); + $this->smarty->assign( + [ + 'content' => $content, + 'meta_title' => $meta_title, + 'meta_keywords' => $meta_keywords, + 'meta_description' => $meta_description, + ] + ); + $this->pagerender(); + } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 0e12d3d6e..95961fb00 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Mail\AccountDeleted; use App\Models\User; use Blacklight\NZBGet; use Blacklight\SABnzbd; @@ -14,6 +15,7 @@ use App\Models\ReleaseComment; use Blacklight\utility\Utility; use App\Models\UserExcludedCategory; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Mail; class ProfileController extends BasePageController { @@ -284,4 +286,28 @@ class ProfileController extends BasePageController ); $this->pagerender(); } + + /** + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @throws \Exception + */ + public function destroy(Request $request) + { + $this->setPrefs(); + $userId = $request->input('id'); + + if ($userId !== null && $this->userdata->role->id !== User::ROLE_ADMIN && (int) $userId === Auth::id()) { + Mail::to(Settings::settingValue('site.main.email'))->send(new AccountDeleted($userId)); + Auth::logout(); + User::deleteUser($userId); + return redirect('login'); + } + + if ($this->userdata->role->id === User::ROLE_ADMIN) { + return redirect('profile'); + } + + return view('errors.badboy'); + } } diff --git a/composer.lock b/composer.lock index b8515e1e3..394e97c13 100644 --- a/composer.lock +++ b/composer.lock @@ -1,7 +1,7 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "cc6d1b861446c6eb8b7e3be5c4278713", @@ -312,8 +312,7 @@ "Gemfile.lock", "*.md" ] - }, - "time": "2016-06-06T17:37:52+00:00" + } }, { "name": "bower-asset/autosize", @@ -342,8 +341,7 @@ "form", "textarea", "ui" - ], - "time": "2017-05-19T15:36:30+00:00" + ] }, { "name": "bower-asset/bootstrap", @@ -392,8 +390,7 @@ "mobile-first", "responsive", "web" - ], - "time": "2016-07-25T15:51:55+00:00" + ] }, { "name": "bower-asset/bootstrap-3.x", @@ -442,8 +439,7 @@ "mobile-first", "responsive", "web" - ], - "time": "2016-07-25T15:51:55+00:00" + ] }, { "name": "bower-asset/bootstrap-datepicker", @@ -472,8 +468,7 @@ }, "license": [ "Apache-2.0" - ], - "time": "2016-08-05T09:50:13+00:00" + ] }, { "name": "bower-asset/bootstrap-hover-dropdown", @@ -503,8 +498,7 @@ "dropdowns", "hover", "twitter" - ], - "time": "2015-12-01T23:35:57+00:00" + ] }, { "name": "bower-asset/bootstrap-progressbar", @@ -538,8 +532,7 @@ }, "license": [ "MIT" - ], - "time": "2015-05-15T18:56:17+00:00" + ] }, { "name": "bower-asset/bootswatch", @@ -670,8 +663,7 @@ "modal", "popup", "ui" - ], - "time": "2016-05-10T22:21:33+00:00" + ] }, { "name": "bower-asset/datatables", @@ -719,8 +711,7 @@ "jquery", "library", "table" - ], - "time": "2017-08-31T13:52:17+00:00" + ] }, { "name": "bower-asset/fancybox", @@ -786,8 +777,7 @@ "tests", "examples" ] - }, - "time": "2015-01-26T21:19:01+00:00" + } }, { "name": "bower-asset/flexboxgrid", @@ -823,8 +813,7 @@ "css", "flexbox", "grid" - ], - "time": "2016-08-14T16:43:18+00:00" + ] }, { "name": "bower-asset/font-awesome", @@ -869,8 +858,7 @@ "src", "build.xml" ] - }, - "time": "2015-07-20T20:04:00+00:00" + } }, { "name": "bower-asset/icheck", @@ -920,8 +908,7 @@ "replacement", "skins", "ui" - ], - "time": "2014-03-03T17:36:28+00:00" + ] }, { "name": "bower-asset/jquery", @@ -984,8 +971,7 @@ "javascript", "jquery", "library" - ], - "time": "2016-05-20T17:24:43+00:00" + ] }, { "name": "bower-asset/jquery-3.2.x", @@ -1052,8 +1038,7 @@ "scroll", "scrolltop", "scrolltotop" - ], - "time": "2017-08-31T15:51:29+00:00" + ] }, { "name": "bower-asset/jquery-migrate-1.4.x", @@ -1072,8 +1057,7 @@ "type": "bower-asset-library", "extra": { "bower-asset-main": "jquery-migrate.js" - }, - "time": "2016-04-15T06:38:34+00:00" + } }, { "name": "bower-asset/jquery-migrate-3.0.x", @@ -1092,8 +1076,7 @@ "type": "bower-asset-library", "extra": { "bower-asset-main": "jquery-migrate.js" - }, - "time": "2016-06-10T14:28:59+00:00" + } }, { "name": "bower-asset/jquery.nicescroll", @@ -1123,8 +1106,7 @@ "demo", "package.json" ] - }, - "time": "2016-03-01T20:38:24+00:00" + } }, { "name": "bower-asset/material-design-iconic-font", @@ -1163,8 +1145,7 @@ "font", "icons", "material" - ], - "time": "2015-11-08T04:50:28+00:00" + ] }, { "name": "bower-asset/materialize", @@ -1223,8 +1204,7 @@ "responsive", "sass", "ux" - ], - "time": "2017-04-15T01:39:28+00:00" + ] }, { "name": "bower-asset/pace", @@ -1270,8 +1250,7 @@ "progress", "progress", "spinner" - ], - "time": "2014-11-06T16:31:34+00:00" + ] }, { "name": "bower-asset/pnotify", @@ -1323,8 +1302,7 @@ "license": [ "Apache-2.0" ], - "description": "JavaScript notification plugin.", - "time": "2017-07-31T21:50:29+00:00" + "description": "JavaScript notification plugin." }, { "name": "bower-asset/respond", @@ -1348,8 +1326,7 @@ "test" ] }, - "description": "Fast and lightweight polyfill for min/max-width CSS3 Media Queries (for IE 6-8, and more)", - "time": "2013-12-19T04:44:31+00:00" + "description": "Fast and lightweight polyfill for min/max-width CSS3 Media Queries (for IE 6-8, and more)" }, { "name": "bower-asset/responsive-tables-js", @@ -1379,8 +1356,7 @@ "jquery", "responsive", "table" - ], - "time": "2015-10-08T14:18:04+00:00" + ] }, { "name": "bower-asset/select2", @@ -1448,8 +1424,7 @@ "scrolling", "slimscroll", "ui" - ], - "time": "2016-06-11T09:19:14+00:00" + ] }, { "name": "bower-asset/tinymce-builded", diff --git a/public/pages/profile_delete.php b/public/pages/profile_delete.php deleted file mode 100644 index 9acd4a80f..000000000 --- a/public/pages/profile_delete.php +++ /dev/null @@ -1,24 +0,0 @@ -show403(); -} - -$userId = request()->input('id'); - -if ($userId !== null && $page->userdata->role->id !== User::ROLE_ADMIN && (int) $userId === Auth::id()) { - Mail::to(Settings::settingValue('site.main.email'))->send(new AccountDeleted($userId)); - Auth::logout(); - User::deleteUser($userId); - header('Location:'.WWW_TOP.'/login'); -} elseif ($page->userdata->role->id === User::ROLE_ADMIN) { - redirect(WWW_TOP.'profile'); -} else { - $page->showBadBoy(); -} diff --git a/routes/web.php b/routes/web.php index 773015ff8..f00998545 100644 --- a/routes/web.php +++ b/routes/web.php @@ -125,13 +125,9 @@ Route::get('profileedit', 'ProfileController@edit'); Route::post('profileedit', 'ProfileController@edit'); -Route::get('/profile_delete', function () { - redirect('/profile_delete'); -})->middleware('auth'); +Route::get('/profile_delete', 'ProfileController@destroy'); -Route::post('/profile_delete', function () { - redirect('/login'); -})->middleware('guest'); +Route::post('/profile_delete', 'ProfileController@destroy'); Route::get('search', 'SearchController@search');