diff --git a/app/Console/Commands/Purge.php b/app/Console/Commands/Purge.php index bce2303912..427ff5cd32 100644 --- a/app/Console/Commands/Purge.php +++ b/app/Console/Commands/Purge.php @@ -26,7 +26,7 @@ class Purge extends Command * * @var string */ - protected $signature = 'snipeit:purge'; + protected $signature = 'snipeit:purge {--force=false}'; /** * The console command description. @@ -52,8 +52,8 @@ class Purge extends Command */ public function handle() { - - if ($this->confirm("\n****************************************************\nTHIS WILL PURGE ALL SOFT-DELETED ITEMS IN YOUR SYSTEM. \nThere is NO undo. This WILL permanently destroy \nALL of your deleted data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) { + $force = $this->option('force'); + if (($this->confirm("\n****************************************************\nTHIS WILL PURGE ALL SOFT-DELETED ITEMS IN YOUR SYSTEM. \nThere is NO undo. This WILL permanently destroy \nALL of your deleted data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) || $force == 'true') { /** * Delete assets diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index af20d05bb0..231274ad84 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -516,4 +516,29 @@ class SettingsController extends Controller } } + + + /** + * Purges soft-deletes + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return View + */ + public function postPurge() + { + if (!config('app.lock_passwords')) { + if (Input::get('confirm_purge')=='DELETE') { + Artisan::call('snipeit:purge',['--force'=>'true','--no-interaction'=>true]); + $output = Artisan::output(); + return View::make('settings/purge') + ->with('output', $output)->with('success', trans('admin/settings/message.purge.success')); + } else { + return Redirect::back()->with('error', trans('admin/settings/message.purge.validation_failed')); + } + + } else { + return Redirect::back()->with('error', trans('general.feature_disabled')); + } + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index adcec80c64..76010b7a5b 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -433,9 +433,13 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi # Admin Settings Routes (for categories, maufactureres, etc) Route::group([ 'prefix' => 'settings'], function () { + + # Settings Route::group([ 'prefix' => 'app' ], function () { + Route::post('purge', ['as' => 'purge', 'uses' => 'SettingsController@postPurge']); + Route::get('/', [ 'as' => 'app', 'uses' => 'SettingsController@getIndex' ]); Route::get('edit', [ 'as' => 'edit/settings', 'uses' => 'SettingsController@getEdit' ]); Route::post('edit', 'SettingsController@postEdit'); @@ -472,6 +476,8 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth','authorize:admi Route::post('create', 'CompaniesController@postCreate'); }); + + # Manufacturers Route::group([ 'prefix' => 'manufacturers' ], function () { diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index 030afbe082..8da79011cc 100755 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -10,6 +10,8 @@ return array( 'backups' => 'Backups', 'barcode_type' => 'Barcode Type', 'barcode_settings' => 'Barcode Settings', + 'confirm_purge' => 'Confirm Purge', + 'confirm_purge_help' => 'Enter the text "DELETE" in the box below to purge your deleted records. This action cannot be undone.', 'custom_css' => 'Custom CSS', 'custom_css_help' => 'Enter any custom CSS overrides you would like to use. Do not include the <style></style> tags.', 'default_currency' => 'Default Currency', @@ -76,6 +78,7 @@ return array( 'labels_per_page' => 'Labels per page', 'label_dimensions' => 'Label dimensions (inches)', 'page_padding' => 'Page margins (inches)', + 'purge' => 'Purge Deleted Records', 'labels_display_bgutter' => 'Label bottom gutter', 'labels_display_sgutter' => 'Label side gutter', 'labels_fontsize' => 'Label font size', diff --git a/resources/lang/en/admin/settings/message.php b/resources/lang/en/admin/settings/message.php index a95761510d..736d5c3e9e 100755 --- a/resources/lang/en/admin/settings/message.php +++ b/resources/lang/en/admin/settings/message.php @@ -13,5 +13,10 @@ return array( 'generated' => 'A new backup file was successfully created.', 'file_not_found' => 'That backup file could not be found on the server.', ), + 'purge' => array( + 'error' => 'An error has occurred while purging. ', + 'validation_failed' => 'Your purge confirmation is incorrect. Please type the word "DELETE" in the confirmation box.', + 'success' => 'Deleted records successfully purged.' + ), ); diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.php index 2722107a38..6cc7653d0a 100755 --- a/resources/views/settings/index.blade.php +++ b/resources/views/settings/index.blade.php @@ -174,10 +174,46 @@ - + + + + - - - +
+
+
+
+

{{ trans('admin/settings/general.purge') }}

+
+ {{ Form::open(['method' => 'POST', 'route' => ['purge'], 'class' => 'form-horizontal', 'role' => 'form' ]) }} + + {{ Form::hidden('_token', csrf_token()) }} +
+

{{ trans('admin/settings/general.confirm_purge_help') }}

+ + + +
+ {{ Form::label('confirm_purge', trans('admin/settings/general.confirm_purge')) }} +
+
+ @if (config('app.lock_passwords')===true) + {{ Form::text('confirm_purge', Input::old('confirm_purge'), array('class' => 'form-control', 'disabled'=>'disabled')) }} + @else + {{ Form::text('confirm_purge', Input::old('confirm_purge'), array('class' => 'form-control')) }} + @endif + + {!! $errors->first('ldap_version', ':message') !!} +
+ + +
+ + +
+
+
@stop diff --git a/resources/views/settings/purge.blade.php b/resources/views/settings/purge.blade.php new file mode 100644 index 0000000000..f42388a441 --- /dev/null +++ b/resources/views/settings/purge.blade.php @@ -0,0 +1,30 @@ +@extends('layouts/default') + +{{-- Page title --}} +@section('title') + {{ trans('admin/settings/general.purge') }} +@parent +@stop + +@section('header_right') + + {{ trans('general.back') }} +@stop + + +{{-- Page content --}} +@section('content') + + +
+
+
+
+ {!! nl2br($output) !!} +
+
+
+
+ + +@stop