Skip to content

Commit 5d23cbf

Browse files
committed
If a user doesnt have permission to see an entries attributes - but can see the entry, disable edit and dont attempt to render. Further, if they cant see the objectclasses, dont make additional attributes available
1 parent b9ae269 commit 5d23cbf

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

app/Http/Controllers/HomeController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ public function frame(Request $request,?Collection $old=NULL): \Illuminate\View\
397397
->with('o',$o)
398398
->with('page_actions',collect([
399399
'copy'=>FALSE,
400-
'create'=>TRUE,
401-
'delete'=>TRUE,
402-
'edit'=>TRUE,
403-
'export'=>TRUE,
400+
'create'=>($x=($o->getObjects()->except('entryuuid')->count() > 0)),
401+
'delete'=>$x,
402+
'edit'=>$x,
403+
'export'=>$x,
404404
])),
405405

406406
'import' => $view,

app/Ldap/Entry.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function getAvailableAttributes(): Collection
274274
{
275275
$result = collect();
276276

277-
foreach ($this->getObject('objectclass')->values as $oc)
277+
foreach (($this->getObject('objectclass')?->values ?: []) as $oc)
278278
$result = $result->merge(config('server')->schema('objectclasses',$oc)->attributes);
279279

280280
return $result;
@@ -439,9 +439,10 @@ public function hasAttribute(int|string $key): bool
439439
*/
440440
public function icon(): string
441441
{
442-
$objectclasses = $this->getObject('objectclass')
443-
->tagValues()
444-
->map(fn($item)=>strtolower($item));
442+
$objectclasses = ($x=$this->getObject('objectclass'))
443+
? $x->tagValues()
444+
->map(fn($item)=>strtolower($item))
445+
: collect();
445446

446447
// Return icon based upon objectClass value
447448
if ($objectclasses->intersect([

resources/views/frames/dn.blade.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,14 @@
8888
<div class="card-header border-bottom-0">
8989
<div class="btn-actions-pane-right">
9090
<div role="group" class="btn-group-sm nav btn-group">
91-
@foreach($langtags->prepend(Entry::TAG_NOTAG)->push('+') as $tag)
92-
<a data-bs-toggle="tab" href="#tab-lang-{{ $tag ?: '_default' }}" class="btn btn-outline-light border-dark-subtle @if(! $loop->index) active @endif @if($loop->last)ndisabled @endif">
91+
@php
92+
$langtags->prepend(Entry::TAG_NOTAG);
93+
if (isset($page_actions) && $page_actions->get('edit'))
94+
$langtags->push('+');
95+
@endphp
96+
97+
@foreach($langtags as $tag)
98+
<a data-bs-toggle="tab" href="#tab-lang-{{ $tag ?: '_default' }}" @class(['btn','btn-outline-light','border-dark-subtle','active'=>!$loop->index])>
9399
@switch($tag)
94100
@case(Entry::TAG_NOTAG)
95101
<i class="fas fa-fw fa-border-none" data-bs-toggle="tooltip" data-bs-custom-class="custom-tooltip" title="@lang('No Lang Tag')"></i>

0 commit comments

Comments
 (0)