parent
80a329afc2
commit
3fc6b55757
@ -41,12 +41,14 @@ class LDIF extends Export
|
|||||||
|
|
||||||
// Display Attributes
|
// Display Attributes
|
||||||
foreach ($o->getObjects() as $ao) {
|
foreach ($o->getObjects() as $ao) {
|
||||||
foreach ($ao->values as $value) {
|
foreach ($ao->values as $tag => $tagvalues) {
|
||||||
$result .= $this->multiLineDisplay(
|
foreach ($tagvalues as $value) {
|
||||||
Str::isAscii($value)
|
$result .= $this->multiLineDisplay(
|
||||||
? sprintf('%s: %s',$ao->name,$value)
|
Str::isAscii($value)
|
||||||
: sprintf('%s:: %s',$ao->name,base64_encode($value))
|
? sprintf('%s: %s',$ao->name.($tag ? ';'.$tag : ''),$value)
|
||||||
,$this->br);
|
: sprintf('%s:: %s',$ao->name.($tag ? ';'.$tag : ''),base64_encode($value))
|
||||||
|
,$this->br);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,34 +179,34 @@ class Entry extends Model
|
|||||||
$result = collect();
|
$result = collect();
|
||||||
$entry_oc = Arr::get($this->attributes,'objectclass',[]);
|
$entry_oc = Arr::get($this->attributes,'objectclass',[]);
|
||||||
|
|
||||||
foreach ($this->attributes as $attribute => $values) {
|
foreach ($this->attributes as $attrtag => $values) {
|
||||||
// If the attribute name has tags
|
// If the attribute name has tags
|
||||||
$matches = [];
|
$matches = [];
|
||||||
if (preg_match('/^([a-zA-Z]+)(;([a-zA-Z-;]+))+/',$attribute,$matches)) {
|
if (preg_match('/^([a-zA-Z]+);+([a-zA-Z-;]+)/',$attrtag,$matches)) {
|
||||||
$attribute = $matches[1];
|
$attribute = $matches[1];
|
||||||
|
$tags = $matches[2];
|
||||||
// If the attribute doesnt exist we'll create it
|
|
||||||
$o = Arr::get(
|
|
||||||
$result,
|
|
||||||
$attribute,
|
|
||||||
Factory::create(
|
|
||||||
$this->dn,
|
|
||||||
$attribute,
|
|
||||||
Arr::get($this->original,$attribute,[]),
|
|
||||||
$entry_oc,
|
|
||||||
));
|
|
||||||
$o->setLangTag($matches[3],$values);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$o = Factory::create($this->dn,$attribute,Arr::get($this->original,$attribute,[]),$entry_oc);
|
$attribute = $attrtag;
|
||||||
|
$tags = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $result->has($attribute)) {
|
$orig = Arr::get($this->original,$attrtag,[]);
|
||||||
// Store our new values to know if this attribute has changed
|
|
||||||
$o->values = collect($values);
|
|
||||||
|
|
||||||
$result->put($attribute,$o);
|
// If the attribute doesnt exist we'll create it
|
||||||
}
|
$o = Arr::get(
|
||||||
|
$result,
|
||||||
|
$attribute,
|
||||||
|
Factory::create(
|
||||||
|
$this->dn,
|
||||||
|
$attribute,
|
||||||
|
[$tags=>$orig],
|
||||||
|
$entry_oc,
|
||||||
|
));
|
||||||
|
|
||||||
|
$o->values = $o->values->merge([$tags=>$values]);
|
||||||
|
|
||||||
|
$result->put($attribute,$o);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sort = collect(config('pla.attr_display_order',[]))->map(fn($item)=>strtolower($item));
|
$sort = collect(config('pla.attr_display_order',[]))->map(fn($item)=>strtolower($item));
|
||||||
@ -274,6 +274,35 @@ class Entry extends Model
|
|||||||
->filter(fn($item)=>$item->is_internal);
|
->filter(fn($item)=>$item->is_internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify the language tags (RFC 3866) used by this entry
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getLangTags(): Collection
|
||||||
|
{
|
||||||
|
return $this->getObjects()
|
||||||
|
->map(fn($item)=>$item
|
||||||
|
->values
|
||||||
|
->keys()
|
||||||
|
->filter(fn($item)=>preg_match('/lang-[A-Za-z0-9-]+;?/',$item)))
|
||||||
|
->filter(fn($item)=>$item->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Of all the items with lang tags, which ones have more than 1 lang tag
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getLangMultiTags(): Collection
|
||||||
|
{
|
||||||
|
return $this->getLangTags()
|
||||||
|
->map(fn($item)=>$item->values()
|
||||||
|
->map(fn($item)=>explode(';',$item))
|
||||||
|
->filter(fn($item)=>count($item) > 1))
|
||||||
|
->filter(fn($item)=>$item->count());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an attribute as an object
|
* Get an attribute as an object
|
||||||
*
|
*
|
||||||
@ -299,6 +328,28 @@ class Entry extends Model
|
|||||||
return $this->objects;
|
return $this->objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find other attribute tags used by this entry
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getOtherTags(): Collection
|
||||||
|
{
|
||||||
|
return $this->getObjects()
|
||||||
|
->map(fn($item)=>$item
|
||||||
|
->values
|
||||||
|
->keys()
|
||||||
|
->filter(fn($item)=>
|
||||||
|
$item && collect(explode(';',$item))->filter(
|
||||||
|
fn($item)=>
|
||||||
|
(! preg_match('/^lang-[A-Za-z0-9-]+$/',$item))
|
||||||
|
&& (! preg_match('/^binary$/',$item))
|
||||||
|
)
|
||||||
|
->count())
|
||||||
|
)
|
||||||
|
->filter(fn($item)=>$item->count());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of attributes without any values
|
* Return a list of attributes without any values
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<div class="alert alert-danger p-0" style="font-size: .80em;">
|
||||||
|
<table class="table table-borderless table-danger p-0 m-0">
|
||||||
|
<tr>
|
||||||
|
<td class="align-top" style="width: 5%;"><i class="fas fa-fw fa-2x fa-exclamation-triangle"></i></td>
|
||||||
|
<td>Unable to display this attribute as it has attribute tags [<strong>{!! $tags->join('</strong>, <strong>') !!}</strong>].<br>
|
||||||
|
You can manage it with an LDIF import.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
@ -1,23 +1,29 @@
|
|||||||
<!-- $o=KrbTicketFlags::class -->
|
<!-- $o=KrbTicketFlags::class -->
|
||||||
<x-attribute.layout :edit="$edit ?? FALSE" :new="$new ?? FALSE" :o="$o">
|
<x-attribute.layout :edit="$edit ?? FALSE" :new="$new ?? FALSE" :o="$o">
|
||||||
@foreach(($o->values->count() ? $o->values : ($new ? [0] : NULL)) as $value)
|
<!-- krbticketflags cannot handle multivalue tags -->
|
||||||
@if($edit)
|
@if($o->values->keys()->count() <= 1)
|
||||||
<div id="32"></div>
|
@foreach((count($o->values->first()) ? $o->values->first() : ($new ? [0] : NULL)) as $value)
|
||||||
<div id="16"></div>
|
@if($edit)
|
||||||
|
<div id="32"></div>
|
||||||
|
<div id="16"></div>
|
||||||
|
|
||||||
<div class="input-group has-validation mb-3">
|
<div class="input-group has-validation mb-3">
|
||||||
<input type="hidden" @class(['form-control','is-invalid'=>($e=$errors->get($o->name_lc.'.'.$loop->index)),'mb-1','border-focus'=>$o->values->contains($value)]) name="{{ $o->name_lc }}[]" value="{{ $value }}" @readonly(true)>
|
<input type="hidden" @class(['form-control','is-invalid'=>($e=$errors->get($o->name_lc.'.'.$loop->index)),'mb-1','border-focus'=>$o->values->contains($value)]) name="{{ $o->name_lc }}[]" value="{{ $value }}" @readonly(true)>
|
||||||
|
|
||||||
<div class="invalid-feedback pb-2">
|
<div class="invalid-feedback pb-2">
|
||||||
@if($e)
|
@if($e)
|
||||||
{{ join('|',$e) }}
|
{{ join('|',$e) }}
|
||||||
@endif
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@else
|
||||||
@else
|
{{ $value }}
|
||||||
{{ $value }}
|
@endif
|
||||||
@endif
|
@endforeach
|
||||||
@endforeach
|
|
||||||
|
@else
|
||||||
|
<x-alert.attribute_tags_cant_manage :tags="$o->values->keys()"/>
|
||||||
|
@endif
|
||||||
</x-attribute.layout>
|
</x-attribute.layout>
|
||||||
|
|
||||||
@section($o->name_lc.'-scripts')
|
@section($o->name_lc.'-scripts')
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
<x-attribute :o="$o->getObject('entryuuid')" :na="__('Unknown')"/>
|
<x-attribute :o="$o->getObject('entryuuid')" :na="__('Unknown')"/>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@if(($x=$o->getLangTags())->count())
|
||||||
|
<tr class="mt-1">
|
||||||
|
<td class="p-0 pe-2">Tags</td>
|
||||||
|
<th class="p-0">{{ $x->flatMap(fn($item)=>$item->values())->unique()->join(', ') }}</th>
|
||||||
|
</tr>
|
||||||
|
@endif
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user