diff --git a/app/Classes/LDAP/Attribute.php b/app/Classes/LDAP/Attribute.php index 1459f068..a8d013b5 100644 --- a/app/Classes/LDAP/Attribute.php +++ b/app/Classes/LDAP/Attribute.php @@ -331,7 +331,7 @@ class Attribute implements \Countable, \ArrayAccess * @param bool $updated Has the entry been updated (uses rendering highlights)) * @return View */ - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { if ($this->is_internal) // @note Internal attributes cannot be edited @@ -352,6 +352,7 @@ class Attribute implements \Countable, \ArrayAccess ->with('edit',$edit) ->with('old',$old) ->with('new',$new) + ->with('template',$template) ->with('updated',$updated); } diff --git a/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php b/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php index 65734233..e738611d 100644 --- a/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php +++ b/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php @@ -15,7 +15,7 @@ final class JpegPhoto extends Binary { use MD5Updates; - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { return view('components.attribute.binary.jpegphoto') ->with('o',$this) diff --git a/app/Classes/LDAP/Attribute/Internal/Timestamp.php b/app/Classes/LDAP/Attribute/Internal/Timestamp.php index 845197ef..5486846d 100644 --- a/app/Classes/LDAP/Attribute/Internal/Timestamp.php +++ b/app/Classes/LDAP/Attribute/Internal/Timestamp.php @@ -12,7 +12,7 @@ use App\Ldap\Entry; */ final class Timestamp extends Internal { - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { // @note Internal attributes cannot be edited return view('components.attribute.internal.timestamp') diff --git a/app/Classes/LDAP/Attribute/KrbPrincipalKey.php b/app/Classes/LDAP/Attribute/KrbPrincipalKey.php index 7c88b0bd..ec07e9df 100644 --- a/app/Classes/LDAP/Attribute/KrbPrincipalKey.php +++ b/app/Classes/LDAP/Attribute/KrbPrincipalKey.php @@ -17,7 +17,7 @@ final class KrbPrincipalKey extends Attribute protected(set) bool $no_attr_tags = TRUE; - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { return view('components.attribute.krbprincipalkey') ->with('o',$this) diff --git a/app/Classes/LDAP/Attribute/KrbTicketFlags.php b/app/Classes/LDAP/Attribute/KrbTicketFlags.php index 80b62cae..5f6e11fe 100644 --- a/app/Classes/LDAP/Attribute/KrbTicketFlags.php +++ b/app/Classes/LDAP/Attribute/KrbTicketFlags.php @@ -50,7 +50,7 @@ final class KrbTicketFlags extends Attribute return $helpers; } - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { return view('components.attribute.krbticketflags') ->with('o',$this) diff --git a/app/Classes/LDAP/Attribute/ObjectClass.php b/app/Classes/LDAP/Attribute/ObjectClass.php index 5536fb04..8f850dc9 100644 --- a/app/Classes/LDAP/Attribute/ObjectClass.php +++ b/app/Classes/LDAP/Attribute/ObjectClass.php @@ -70,7 +70,7 @@ final class ObjectClass extends Attribute ->contains($value); } - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { return view('components.attribute.objectclass') ->with('o',$this) diff --git a/app/Classes/LDAP/Attribute/Password.php b/app/Classes/LDAP/Attribute/Password.php index 6c7cff45..7a35f4d2 100644 --- a/app/Classes/LDAP/Attribute/Password.php +++ b/app/Classes/LDAP/Attribute/Password.php @@ -80,13 +80,14 @@ final class Password extends Attribute return ($helpers=static::helpers())->has($id) ? new ($helpers->get($id)) : NULL; } - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { return view('components.attribute.password') ->with('o',$this) ->with('edit',$edit) ->with('old',$old) ->with('new',$new) + ->with('template',$template) ->with('updated',$updated) ->with('helpers',static::helpers()->map(fn($item,$key)=>['id'=>$key,'value'=>$key])->sort()); } diff --git a/app/Classes/LDAP/Attribute/RDN.php b/app/Classes/LDAP/Attribute/RDN.php index 64bb62f8..be62c5e8 100644 --- a/app/Classes/LDAP/Attribute/RDN.php +++ b/app/Classes/LDAP/Attribute/RDN.php @@ -35,7 +35,7 @@ final class RDN extends Attribute ]); } - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { return view('components.attribute.rdn') ->with('o',$this); diff --git a/app/Classes/LDAP/Attribute/Schema.php b/app/Classes/LDAP/Attribute/Schema.php index 30ba55dd..5f2adef8 100644 --- a/app/Classes/LDAP/Attribute/Schema.php +++ b/app/Classes/LDAP/Attribute/Schema.php @@ -53,11 +53,4 @@ abstract class Schema extends Attribute $key, __('No description available, can you help with one?')); } - - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View - { - // @note Schema attributes cannot be edited - return view('components.attribute.internal') - ->with('o',$this); - } } \ No newline at end of file diff --git a/app/Classes/LDAP/Attribute/Schema/Generic.php b/app/Classes/LDAP/Attribute/Schema/Generic.php index bf3df008..18b91804 100644 --- a/app/Classes/LDAP/Attribute/Schema/Generic.php +++ b/app/Classes/LDAP/Attribute/Schema/Generic.php @@ -12,7 +12,7 @@ use App\Ldap\Entry; */ class Generic extends Schema { - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { // @note Schema attributes cannot be edited return view('components.attribute.schema.generic') diff --git a/app/Classes/LDAP/Attribute/Schema/Mechanisms.php b/app/Classes/LDAP/Attribute/Schema/Mechanisms.php index be402a51..d0c34519 100644 --- a/app/Classes/LDAP/Attribute/Schema/Mechanisms.php +++ b/app/Classes/LDAP/Attribute/Schema/Mechanisms.php @@ -34,7 +34,7 @@ final class Mechanisms extends Schema return parent::_get(config_path('ldap_supported_saslmechanisms.txt'),$string,$key); } - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { // @note Schema attributes cannot be edited return view('components.attribute.schema.mechanisms') diff --git a/app/Classes/LDAP/Attribute/Schema/OID.php b/app/Classes/LDAP/Attribute/Schema/OID.php index 166fd8be..c1bcf269 100644 --- a/app/Classes/LDAP/Attribute/Schema/OID.php +++ b/app/Classes/LDAP/Attribute/Schema/OID.php @@ -35,7 +35,7 @@ final class OID extends Schema return parent::_get(config_path('ldap_supported_oids.txt'),$string,$key); } - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View { // @note Schema attributes cannot be edited return view('components.attribute.schema.oid') diff --git a/app/Classes/Template.php b/app/Classes/Template.php index 89544c8b..1a4be7ee 100644 --- a/app/Classes/Template.php +++ b/app/Classes/Template.php @@ -4,6 +4,7 @@ namespace App\Classes; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; class Template { @@ -30,6 +31,7 @@ class Template public function __get(string $key): mixed { return match ($key) { + 'name' => Str::replaceEnd('.json','',$this->file), 'attributes' => collect(array_map('strtolower',array_keys(Arr::get($this->template,$key)))), 'objectclasses' => collect(array_map('strtolower',Arr::get($this->template,$key))), 'enabled' => Arr::get($this->template,$key,FALSE) && (! $this->invalid), diff --git a/app/View/Components/Attribute.php b/app/View/Components/Attribute.php index 30ed1ac4..bdd66f0a 100644 --- a/app/View/Components/Attribute.php +++ b/app/View/Components/Attribute.php @@ -18,13 +18,14 @@ class Attribute extends Component /** * Create a new component instance. */ - public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE) + public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,string $template=NULL) { $this->o = $o; $this->edit = $edit; $this->old = $old; $this->new = $new; $this->updated = $updated; + $this->template = $template; } /** @@ -36,7 +37,7 @@ class Attribute extends Component { return $this->o ? $this->o - ->render(edit: $this->edit,old: $this->old,new: $this->new,updated: $this->updated) + ->render(edit: $this->edit,old: $this->old,new: $this->new,template: $this->template,updated: $this->updated) : __('Unknown'); } } \ No newline at end of file diff --git a/resources/views/components/attribute/password.blade.php b/resources/views/components/attribute/password.blade.php index 22b1e799..d8fb87bc 100644 --- a/resources/views/components/attribute/password.blade.php +++ b/resources/views/components/attribute/password.blade.php @@ -4,7 +4,7 @@ @foreach(($o->tagValues($langtag)->count() ? $o->tagValues($langtag) : [$langtag => NULL]) as $key => $value) @if($edit)