diff --git a/app/Classes/LDAP/Attribute.php b/app/Classes/LDAP/Attribute.php index 0e2c9380..e717f7f4 100644 --- a/app/Classes/LDAP/Attribute.php +++ b/app/Classes/LDAP/Attribute.php @@ -242,6 +242,10 @@ class Attribute implements \Countable, \ArrayAccess if ($this->required()->count()) $result->put(__('required'),sprintf('%s: %s',__('Required Attribute by ObjectClass(es)'),$this->required()->join(', '))); + // If this attribute is a dynamic attribute + if ($this->isDynamic()) + $result->put(__('dynamic'),__('These are dynamic values present as a result of another attribute')); + return $result->toArray(); } @@ -257,6 +261,19 @@ class Attribute implements \Countable, \ArrayAccess || ($a->diff($b)->count() !== 0); } + /** + * Are these values as a result of a dynamic attribute + * + * @return bool + */ + public function isDynamic(): bool + { + return $this->schema->used_in_object_classes + ->keys() + ->intersect($this->schema->heirachy($this->oc)) + ->count() === 0; + } + /** * Work out if this attribute is an RDN attribute * diff --git a/app/Classes/LDAP/Schema/AttributeType.php b/app/Classes/LDAP/Schema/AttributeType.php index b4463ef6..cd397069 100644 --- a/app/Classes/LDAP/Schema/AttributeType.php +++ b/app/Classes/LDAP/Schema/AttributeType.php @@ -486,6 +486,28 @@ final class AttributeType extends Base { return $this->used_in_object_classes; } + /** + * For a list of objectclasses return all parent objectclasses as well + * + * @param Collection $ocs + * @return Collection + */ + public function heirachy(Collection $ocs): Collection + { + $result = collect(); + + foreach ($ocs as $oc) { + $schema = config('server') + ->schema('objectclasses',$oc) + ->getParents(TRUE) + ->pluck('name'); + + $result = $result->merge($schema)->push($oc); + } + + return $result; + } + /** * @return bool * @deprecated use $this->forced_as_may @@ -555,15 +577,9 @@ final class AttributeType extends Base { public function validation(array $array): ?array { // For each item in array, we need to get the OC hierarchy - $heirachy = collect($array) + $heirachy = $this->heirachy(collect($array) ->flatten() - ->filter() - ->map(fn($item)=>config('server') - ->schema('objectclasses',$item) - ->getSupClasses() - ->push($item)) - ->flatten() - ->unique(); + ->filter()); // Get any config validation $validation = collect(Arr::get(config('ldap.validation'),$this->name_lc,[])); diff --git a/app/View/Components/AttributeType.php b/app/View/Components/AttributeType.php index 965ff5b1..364b4a8e 100644 --- a/app/View/Components/AttributeType.php +++ b/app/View/Components/AttributeType.php @@ -13,15 +13,17 @@ class AttributeType extends Component { private LDAPAttribute $o; private bool $new; + private bool $edit; private string $langtag; /** * Create a new component instance. */ - public function __construct(LDAPAttribute $o,bool $new=FALSE,string $langtag=Entry::TAG_NOTAG) + public function __construct(LDAPAttribute $o,bool $new=FALSE,bool $edit=FALSE,string $langtag=Entry::TAG_NOTAG) { $this->o = $o; $this->new = $new; + $this->edit = $edit; $this->langtag = $langtag; } @@ -33,6 +35,7 @@ class AttributeType extends Component return view('components.attribute-type') ->with('o',$this->o) ->with('new',$this->new) + ->with('edit',$this->edit) ->with('langtag',$this->langtag); } } \ No newline at end of file diff --git a/public/css/custom.css b/public/css/custom.css index d61392fa..f7f8c16f 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -2,7 +2,7 @@ attribute#userPassword .select2-container--bootstrap-5 .select2-selection { font-size: inherit; width: 9em; - border: #444054 1px solid; + border: var(--bs-gray-500) 1px solid; background-color: #f0f0f0; } diff --git a/resources/views/components/attribute-type.blade.php b/resources/views/components/attribute-type.blade.php index feb96553..4a5c6f3c 100644 --- a/resources/views/components/attribute-type.blade.php +++ b/resources/views/components/attribute-type.blade.php @@ -15,7 +15,7 @@ - + diff --git a/resources/views/components/attribute.blade.php b/resources/views/components/attribute.blade.php index 68d6867b..19a16d65 100644 --- a/resources/views/components/attribute.blade.php +++ b/resources/views/components/attribute.blade.php @@ -1,10 +1,10 @@ - +
- @foreach(Arr::get(old($o->name_lc,[$langtag=>($new ?? FALSE) ? [NULL] : $o->tagValues($langtag)]),$langtag) as $key => $value) - @if(($edit ?? FALSE) && ! $o->is_rdn) + @foreach(Arr::get(old($o->name_lc,[$langtag=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value) + @if($edit && (! $o->is_rdn))
- ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! ($tv=$o->tagValuesOld($langtag))->contains($value)]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ $value }}" placeholder="{{ ! is_null($x=$tv->get($loop->index)) ? $x : '['.__('NEW').']' }}" @readonly(! ($new ?? FALSE))> + ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! ($tv=$o->tagValuesOld($langtag))->contains($value)]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ $value }}" placeholder="{{ ! is_null($x=$tv->get($loop->index)) ? $x : '['.__('NEW').']' }}" @readonly(! $new) @disabled($o->isDynamic())>
@if($e) diff --git a/resources/views/components/attribute/binary/jpegphoto.blade.php b/resources/views/components/attribute/binary/jpegphoto.blade.php index ee5a2929..9c9c0151 100644 --- a/resources/views/components/attribute/binary/jpegphoto.blade.php +++ b/resources/views/components/attribute/binary/jpegphoto.blade.php @@ -1,6 +1,6 @@ - + @foreach($o->tagValuesOld() as $key => $value) diff --git a/resources/views/components/attribute/krbprincipalkey.blade.php b/resources/views/components/attribute/krbprincipalkey.blade.php index f1925b62..d060dbe3 100644 --- a/resources/views/components/attribute/krbprincipalkey.blade.php +++ b/resources/views/components/attribute/krbprincipalkey.blade.php @@ -1,6 +1,6 @@ - + @foreach($o->tagValuesOld($langtag) as $key => $value) @if($edit)
diff --git a/resources/views/components/attribute/krbticketflags.blade.php b/resources/views/components/attribute/krbticketflags.blade.php index 80418109..c1aba459 100644 --- a/resources/views/components/attribute/krbticketflags.blade.php +++ b/resources/views/components/attribute/krbticketflags.blade.php @@ -1,5 +1,5 @@ - + @foreach(Arr::get(old($o->name_lc,[$langtag=>$o->tagValues($langtag)]),$langtag,[]) as $key => $value) @if($edit)
diff --git a/resources/views/components/attribute/objectclass.blade.php b/resources/views/components/attribute/objectclass.blade.php index 07a9f2f7..65d72828 100644 --- a/resources/views/components/attribute/objectclass.blade.php +++ b/resources/views/components/attribute/objectclass.blade.php @@ -1,10 +1,10 @@ - @foreach(Arr::get(old($o->name_lc,[$langtag=>($new ?? FALSE) ? [NULL] : $o->tagValues($langtag)]),$langtag) as $key => $value) + @foreach(Arr::get(old($o->name_lc,[$langtag=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value) @if($edit) @else - {{ $o->render_item_old($langtag.'.'.$key) }} + {{ $o->render_item_old($key) }} @if ($o->isStructural($value)) @lang('structural') diff --git a/resources/views/components/attribute/password.blade.php b/resources/views/components/attribute/password.blade.php index 412f0229..4fe12c61 100644 --- a/resources/views/components/attribute/password.blade.php +++ b/resources/views/components/attribute/password.blade.php @@ -1,6 +1,6 @@ - + @foreach($o->tagValuesOld($langtag) as $key => $value) @if($edit)
diff --git a/resources/views/components/attribute/rdn.blade.php b/resources/views/components/attribute/rdn.blade.php index 58efd85d..dbd48861 100644 --- a/resources/views/components/attribute/rdn.blade.php +++ b/resources/views/components/attribute/rdn.blade.php @@ -1,5 +1,5 @@ - + @foreach(($o->values->count() ? $o->values : ['']) as $value) @if($edit)
diff --git a/resources/views/components/attribute/usercertificate.blade.php b/resources/views/components/attribute/usercertificate.blade.php index 41e37457..c0e991df 100644 --- a/resources/views/components/attribute/usercertificate.blade.php +++ b/resources/views/components/attribute/usercertificate.blade.php @@ -1,11 +1,11 @@ - + @foreach($o->tagValuesOld('binary') as $key => $value) @if($edit)
- +
@if($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)) diff --git a/resources/views/components/attribute/widget/options.blade.php b/resources/views/components/attribute/widget/options.blade.php index f33b42ba..290b11e2 100644 --- a/resources/views/components/attribute/widget/options.blade.php +++ b/resources/views/components/attribute/widget/options.blade.php @@ -244,6 +244,7 @@ @default + @if($o->isDynamic()) @break @endif @php($clone=TRUE) (! $new)]) id="{{ $o->name }}-addnew"> @lang('Add Value') diff --git a/resources/views/components/form/disabled/datetime.blade.php b/resources/views/components/form/disabled/datetime.blade.php index f1777a3a..1a5a0460 100644 --- a/resources/views/components/form/disabled/datetime.blade.php +++ b/resources/views/components/form/disabled/datetime.blade.php @@ -1,5 +1,5 @@ - + @foreach(Arr::get(old($o->name_lc,[$langtag=>$o->tagValues($langtag)]),$langtag,[]) as $value)
diff --git a/resources/views/components/form/disabled/input.blade.php b/resources/views/components/form/disabled/input.blade.php index a37acd0e..8722b243 100644 --- a/resources/views/components/form/disabled/input.blade.php +++ b/resources/views/components/form/disabled/input.blade.php @@ -1,5 +1,5 @@ - + @foreach(Arr::get(old($o->name_lc,[$langtag=>$o->tagValues($langtag)]),$langtag,[]) as $value)