Skip to content

A free open source IT asset/license management system

Added ability to purge soft-deletes from admin

snipe49c09dd35630
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] [<[email protected]>]
+ * @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 &lt;style&gt;&lt;/style&gt; 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 @@
</tbody>
</table>
</div>
- </div>
-
-</div>
-</div>
+ </div>
+ </div>
+ </div>
</div>
+ <div class="row">
+ <div class="col-md-8 col-md-offset-2">
+ <div class="box box-danger">
+ <div class="box-header">
+ <h3 class="box-title"><i class="fa fa-warning"></i> {{ trans('admin/settings/general.purge') }}</h3>
+ </div>
+ {{ Form::open(['method' => 'POST', 'route' => ['purge'], 'class' => 'form-horizontal', 'role' => 'form' ]) }}
+ <!-- CSRF Token -->
+ {{ Form::hidden('_token', csrf_token()) }}
+ <div class="box-body">
+ <p>{{ trans('admin/settings/general.confirm_purge_help') }}</p>
+
+
+
+ <div class="col-md-3{{ $errors->has('confirm_purge') ? 'error' : '' }}">
+ {{ Form::label('confirm_purge', trans('admin/settings/general.confirm_purge')) }}
+ </div>
+ <div class="col-md-9{{ $errors->has('confirm_purge') ? 'error' : '' }}">
+ @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', '<span class="alert-msg">:message</span>') !!}
+ </div>
+
+
+ </div>
+ <div class="box-footer text-right">
+ <button type="submit" class="btn btn-danger">{{ trans('admin/settings/general.purge') }}</button>
+ </div> <!-- /box body -->
+ </form>
+ </div>
+ </div>
+ </div>
+
@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')
+<a href="{{ URL::previous() }}" class="btn btn-primary pull-right">
+ {{ trans('general.back') }}</a>
+@stop
+
+
+{{-- Page content --}}
+@section('content')
+
+
+<div class="row">
+ <div class="col-md-9">
+ <div class="box box-default">
+ <div class="box-body">
+ {!! nl2br($output) !!}
+ </div>
+</div>
+</div>
+</div>
+
+
+@stop