Implement DN Entry rename
This commit is contained in:
parent
339ba7258a
commit
f1316d698d
@ -48,7 +48,7 @@ Entry Editing:
|
||||
- [ ] JpegPhoto Create/Delete
|
||||
- [ ] Binary attribute upload
|
||||
- [ ] If removing an objectClass, remove all attributes that only that objectclass provided
|
||||
- [ ] Rename an entry
|
||||
- [ ] Move an entry
|
||||
- [ ] Group membership selection
|
||||
- [ ] Attribute tag creation
|
||||
|
||||
|
@ -29,7 +29,7 @@ class HomeController extends Controller
|
||||
{
|
||||
private const LOGKEY = 'CHc';
|
||||
|
||||
private const INTERNAL_POST = ['_auto_value','_key','_rdn','_rdn_value','_step','_template','_token','_userpassword_hash'];
|
||||
private const INTERNAL_POST = ['_auto_value','_key','_rdn','_rdn_new','_rdn_value','_step','_template','_token','_userpassword_hash'];
|
||||
|
||||
/**
|
||||
* Create a new object in the LDAP server
|
||||
@ -307,6 +307,31 @@ class HomeController extends Controller
|
||||
->with('o',$o);
|
||||
}
|
||||
|
||||
public function entry_rename(Request $request): \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
{
|
||||
$from_dn = Crypt::decryptString($request->post('dn'));
|
||||
Log::info(sprintf('%s:Renaming [%s] to [%s]',self::LOGKEY,$from_dn,$request->post('_rdn_new')));
|
||||
|
||||
$o = config('server')->fetch($from_dn);
|
||||
|
||||
if (! $o)
|
||||
return back()
|
||||
->withInput()
|
||||
->with('note',__('DN doesnt exist'));
|
||||
|
||||
try {
|
||||
$o->rename($request->post('_rdn_new'));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return Redirect::to('/')
|
||||
->with('failed',$e->getMessage());
|
||||
}
|
||||
|
||||
return Redirect::to('/')
|
||||
->withInput(['_key'=>Crypt::encryptString('*dn|'.$o->getDN())])
|
||||
->with('success',sprintf('%s: %s',__('Entry renamed'),$from_dn));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a DN entry
|
||||
*
|
||||
@ -505,8 +530,8 @@ class HomeController extends Controller
|
||||
// Setup
|
||||
$cmd = NULL;
|
||||
$dn = NULL;
|
||||
$key = $request->get('_key',old('_key'))
|
||||
? Crypt::decryptString($request->get('_key',old('_key')))
|
||||
$key = ($x=$request->get('_key',old('_key')))
|
||||
? Crypt::decryptString($x)
|
||||
: NULL;
|
||||
|
||||
// Determine if our key has a command
|
||||
@ -518,9 +543,9 @@ class HomeController extends Controller
|
||||
$dn = ($m[2] !== '_NOP') ? $m[2] : NULL;
|
||||
}
|
||||
|
||||
} elseif (old('dn',$request->get('_key'))) {
|
||||
} elseif ($x=old('dn',$request->get('_key'))) {
|
||||
$cmd = 'dn';
|
||||
$dn = Crypt::decryptString(old('dn',$request->get('_key')));
|
||||
$dn = Crypt::decryptString($x);
|
||||
}
|
||||
|
||||
return ['cmd'=>$cmd,'dn'=>$dn];
|
||||
|
@ -6,7 +6,7 @@
|
||||
@php($clone=FALSE)
|
||||
<span class="p-0 m-0">
|
||||
@if($o->is_rdn)
|
||||
<button class="btn btn-sm btn-outline-focus mt-3" disabled><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</button>
|
||||
<span id="entry-rename" class="btn btn-sm btn-outline-focus mt-3" data-bs-toggle="modal" data-bs-target="#page-modal"><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</span>
|
||||
@elseif($edit && $o->can_addvalues)
|
||||
@switch(get_class($o))
|
||||
@case(Certificate::class)
|
||||
@ -26,7 +26,7 @@
|
||||
@break
|
||||
|
||||
@case(ObjectClass::class)
|
||||
<span type="button" @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-bs-toggle="modal" data-bs-target="#new_objectclass-modal"><i class="fas fa-fw fa-plus"></i> @lang('Add Objectclass')</span>
|
||||
<span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-bs-toggle="modal" data-bs-target="#new_objectclass-modal"><i class="fas fa-fw fa-plus"></i> @lang('Add Objectclass')</span>
|
||||
|
||||
<!-- NEW OBJECT CLASS -->
|
||||
<div class="modal fade" id="new_objectclass-modal" tabindex="-1" aria-labelledby="new_objectclass-label" aria-hidden="true" data-bs-backdrop="static">
|
||||
|
@ -281,6 +281,25 @@
|
||||
})
|
||||
break;
|
||||
|
||||
case 'entry-rename':
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '{{ url('modal/rename') }}/'+dn,
|
||||
dataType: 'html',
|
||||
cache: false,
|
||||
beforeSend: function() {
|
||||
that.empty().append('<span class="p-3"><i class="fas fa-3x fa-spinner fa-pulse"></i></span>');
|
||||
},
|
||||
success: function(data) {
|
||||
that.empty().html(data);
|
||||
},
|
||||
error: function(e) {
|
||||
if (e.status !== 412)
|
||||
alert('That didnt work? Please try again....');
|
||||
},
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
switch ($(item.relatedTarget).attr('name')) {
|
||||
case 'entry-userpassword-check':
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
@section('main-content')
|
||||
<x-success/>
|
||||
<x-failed/>
|
||||
|
||||
<div class="card card-solid mb-3">
|
||||
<div class="card-body">
|
||||
|
40
resources/views/modals/entry-rename.blade.php
Normal file
40
resources/views/modals/entry-rename.blade.php
Normal file
@ -0,0 +1,40 @@
|
||||
<div class="modal-header bg-dark text-white">
|
||||
<h1 class="modal-title fs-5">
|
||||
<strong>@lang('Rename') <strong>{{ $x=Crypt::decryptString($dn) }}</strong>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<form id="entry-rename-form" method="POST" action="{{ url('entry/rename') }}">
|
||||
<div class="modal-body">
|
||||
@csrf
|
||||
<input type="hidden" name="dn" value="{{ $dn }}">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<label for="rdn" class="form-label">@lang('New RDN')</label>
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" id="rdn" name="_rdn_new" class="form-control w-25" placeholder="{{ $rdn=collect(explode(',',$x))->first() }}" value="{{ $rdn }}">
|
||||
<span class="input-group-text" id="label">{{ collect(explode(',',$x))->skip(1)->join(',') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<x-modal.close/>
|
||||
<button id="entry-rename" type="submit" class="btn btn-sm btn-primary" disabled>@lang('Rename')</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var rdn = '{{ $rdn }}';
|
||||
|
||||
// Complete the RDN
|
||||
$('#rdn').on('input',function(item) {
|
||||
rdn = $(this).val();
|
||||
|
||||
$('button[id=entry-rename]').attr('disabled',! rdn.includes('='));
|
||||
})
|
||||
});
|
||||
</script>
|
@ -49,6 +49,7 @@ Route::controller(HomeController::class)->group(function() {
|
||||
Route::post('entry/password/check/','entry_password_check');
|
||||
Route::post('entry/attr/add/{id}','entry_attr_add');
|
||||
Route::post('entry/objectclass/add','entry_objectclass_add');
|
||||
Route::post('entry/rename','entry_rename');
|
||||
Route::post('entry/update/commit','entry_update');
|
||||
Route::post('entry/update/pending','entry_pending_update');
|
||||
|
||||
@ -56,6 +57,7 @@ Route::controller(HomeController::class)->group(function() {
|
||||
|
||||
Route::view('modal/delete/{dn}','modals.entry-delete');
|
||||
Route::view('modal/export/{dn}','modals.entry-export');
|
||||
Route::view('modal/rename/{dn}','modals.entry-rename');
|
||||
Route::view('modal/userpassword-check/{dn}','modals.entry-userpassword-check');
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user