diff --git a/app/Classes/LDAP/Attribute.php b/app/Classes/LDAP/Attribute.php index c757adb8..b76239c3 100644 --- a/app/Classes/LDAP/Attribute.php +++ b/app/Classes/LDAP/Attribute.php @@ -7,6 +7,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; use App\Classes\LDAP\Schema\AttributeType; +use App\Classes\Template; use App\Exceptions\InvalidUsage; use App\Ldap\Entry; @@ -326,10 +327,10 @@ class Attribute implements \Countable, \ArrayAccess * @param bool $old Use old value * @param bool $new Enable adding values * @param bool $updated Has the entry been updated (uses rendering highlights)) - * @param string|null $template + * @param Template|null $template * @return View */ - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $template=NULL): View { if ($this->is_internal) // @note Internal attributes cannot be edited diff --git a/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php b/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php index e738611d..ca4ac18d 100644 --- a/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php +++ b/app/Classes/LDAP/Attribute/Binary/JpegPhoto.php @@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute\Binary; use Illuminate\Contracts\View\View; use App\Classes\LDAP\Attribute\Binary; -use App\Ldap\Entry; +use App\Classes\Template; use App\Traits\MD5Updates; /** @@ -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,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $template=NULL): View { return view('components.attribute.binary.jpegphoto') ->with('o',$this) diff --git a/app/Classes/LDAP/Attribute/CertificateList.php b/app/Classes/LDAP/Attribute/CertificateList.php index 8a56beaf..8701243a 100644 --- a/app/Classes/LDAP/Attribute/CertificateList.php +++ b/app/Classes/LDAP/Attribute/CertificateList.php @@ -2,9 +2,6 @@ namespace App\Classes\LDAP\Attribute; -use Carbon\Carbon; -use Illuminate\Support\Arr; - use App\Classes\LDAP\Attribute; use App\Traits\MD5Updates; diff --git a/app/Classes/LDAP/Attribute/Factory.php b/app/Classes/LDAP/Attribute/Factory.php index a4ee42e4..29dd58cf 100644 --- a/app/Classes/LDAP/Attribute/Factory.php +++ b/app/Classes/LDAP/Attribute/Factory.php @@ -3,7 +3,6 @@ namespace App\Classes\LDAP\Attribute; use Illuminate\Support\Arr; -use Illuminate\Support\Facades\Log; use App\Classes\LDAP\Attribute; diff --git a/app/Classes/LDAP/Attribute/Internal/Timestamp.php b/app/Classes/LDAP/Attribute/Internal/Timestamp.php index 5486846d..136080f7 100644 --- a/app/Classes/LDAP/Attribute/Internal/Timestamp.php +++ b/app/Classes/LDAP/Attribute/Internal/Timestamp.php @@ -5,14 +5,14 @@ namespace App\Classes\LDAP\Attribute\Internal; use Illuminate\Contracts\View\View; use App\Classes\LDAP\Attribute\Internal; -use App\Ldap\Entry; +use App\Classes\Template; /** * Represents an attribute whose values are timestamps */ final class Timestamp extends Internal { - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 ec07e9df..5f7e3749 100644 --- a/app/Classes/LDAP/Attribute/KrbPrincipalKey.php +++ b/app/Classes/LDAP/Attribute/KrbPrincipalKey.php @@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute; use Illuminate\Contracts\View\View; use App\Classes\LDAP\Attribute; -use App\Ldap\Entry; +use App\Classes\Template; use App\Traits\MD5Updates; /** @@ -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,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 5f6e11fe..37547e87 100644 --- a/app/Classes/LDAP/Attribute/KrbTicketFlags.php +++ b/app/Classes/LDAP/Attribute/KrbTicketFlags.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Collection; use App\Classes\LDAP\Attribute; -use App\Ldap\Entry; +use App\Classes\Template; /** * Represents an attribute whose value is a Kerberos Ticket Flag @@ -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,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 8f850dc9..4dd1ea41 100644 --- a/app/Classes/LDAP/Attribute/ObjectClass.php +++ b/app/Classes/LDAP/Attribute/ObjectClass.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Collection; use App\Classes\LDAP\Attribute; -use App\Ldap\Entry; +use App\Classes\Template; /** * Represents an ObjectClass Attribute @@ -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,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 7a35f4d2..be7f8399 100644 --- a/app/Classes/LDAP/Attribute/Password.php +++ b/app/Classes/LDAP/Attribute/Password.php @@ -7,7 +7,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; use App\Classes\LDAP\Attribute; -use App\Ldap\Entry; +use App\Classes\Template; use App\Traits\MD5Updates; /** @@ -80,7 +80,7 @@ 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,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $template=NULL): View { return view('components.attribute.password') ->with('o',$this) diff --git a/app/Classes/LDAP/Attribute/RDN.php b/app/Classes/LDAP/Attribute/RDN.php index be62c5e8..1995a0d6 100644 --- a/app/Classes/LDAP/Attribute/RDN.php +++ b/app/Classes/LDAP/Attribute/RDN.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Collection; use App\Classes\LDAP\Attribute; -use App\Ldap\Entry; +use App\Classes\Template; /** * Represents the RDN for an Entry @@ -35,7 +35,7 @@ final class RDN extends Attribute ]); } - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 5f2adef8..162cb9c6 100644 --- a/app/Classes/LDAP/Attribute/Schema.php +++ b/app/Classes/LDAP/Attribute/Schema.php @@ -2,12 +2,10 @@ namespace App\Classes\LDAP\Attribute; -use Illuminate\Contracts\View\View; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Cache; use App\Classes\LDAP\Attribute; -use App\Ldap\Entry; /** * Represents an attribute whose values are schema related diff --git a/app/Classes/LDAP/Attribute/Schema/Generic.php b/app/Classes/LDAP/Attribute/Schema/Generic.php index 18b91804..77709e87 100644 --- a/app/Classes/LDAP/Attribute/Schema/Generic.php +++ b/app/Classes/LDAP/Attribute/Schema/Generic.php @@ -5,14 +5,14 @@ namespace App\Classes\LDAP\Attribute\Schema; use Illuminate\Contracts\View\View; use App\Classes\LDAP\Attribute\Schema; -use App\Ldap\Entry; +use App\Classes\Template; /** * Represents a Generic Schema Attribute */ class Generic extends Schema { - public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 d0c34519..6721390d 100644 --- a/app/Classes/LDAP/Attribute/Schema/Mechanisms.php +++ b/app/Classes/LDAP/Attribute/Schema/Mechanisms.php @@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute\Schema; use Illuminate\Contracts\View\View; use App\Classes\LDAP\Attribute\Schema; -use App\Ldap\Entry; +use App\Classes\Template; /** * Represents a Mechanisms Attribute @@ -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,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 c1bcf269..42d59410 100644 --- a/app/Classes/LDAP/Attribute/Schema/OID.php +++ b/app/Classes/LDAP/Attribute/Schema/OID.php @@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute\Schema; use Illuminate\Contracts\View\View; use App\Classes\LDAP\Attribute\Schema; -use App\Ldap\Entry; +use App\Classes\Template; /** * Represents an OID Attribute @@ -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,?string $template=NULL): View + public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $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 97468e81..f1c38ed5 100644 --- a/app/Classes/Template.php +++ b/app/Classes/Template.php @@ -20,6 +20,8 @@ class Template $this->file = $file; try { + // @todo Load in the proper attribute objects and objectclass objects + // @todo Make sure we have a structural objectclass, or make the template invalid $this->template = json_decode($td->get($file),null,512,JSON_OBJECT_AS_ARRAY|JSON_THROW_ON_ERROR); } catch (\JsonException $e) { @@ -46,9 +48,4 @@ class Template { return array_key_exists($key,$this->template); } - - public function __toString(): string - { - return $this->invalid ? '' : Arr::get($this->template,'title','No Template Name'); - } } \ No newline at end of file diff --git a/app/View/Components/Attribute.php b/app/View/Components/Attribute.php index 94694fc0..50ba0775 100644 --- a/app/View/Components/Attribute.php +++ b/app/View/Components/Attribute.php @@ -6,6 +6,7 @@ use Illuminate\Contracts\View\View; use Illuminate\View\Component; use App\Classes\LDAP\Attribute as LDAPAttribute; +use App\Classes\Template; class Attribute extends Component { @@ -14,12 +15,12 @@ class Attribute extends Component public bool $new; public bool $old; public bool $updated; - public bool $template; + public ?Template $template; /** * Create a new component instance. */ - public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,string $template=NULL) + public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,bool $updated=FALSE,?Template $template=NULL) { $this->o = $o; $this->edit = $edit; @@ -38,7 +39,12 @@ class Attribute extends Component { return $this->o ? $this->o - ->render(edit: $this->edit,old: $this->old,new: $this->new,template: $this->template,updated: $this->updated) + ->render( + edit: $this->edit, + old: $this->old, + new: $this->new, + updated: $this->updated, + template: $this->template) : __('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 6e6de066..de11ae20 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)
- + ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! $o->tagValuesOld($langtag)->contains($value),'bg-success-subtle'=>$updated]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ Arr::get(old($o->name_lc),$langtag.'.'.$loop->index,$value ? md5($value) : '') }}" @readonly(! $new)>
diff --git a/resources/views/fragment/template/dn.blade.php b/resources/views/fragment/template/dn.blade.php index db69f9e6..fc0961a3 100644 --- a/resources/views/fragment/template/dn.blade.php +++ b/resources/views/fragment/template/dn.blade.php @@ -9,7 +9,7 @@ @php($up=(session()->pull('updated') ?: collect())) @foreach($o->getVisibleAttributes()->filter(fn($item)=>$template->attributes->map('strtolower')->contains($item->name_lc)) as $ao) - + @endforeach
diff --git a/resources/views/frames/create.blade.php b/resources/views/frames/create.blade.php index 2454da57..fb919d6d 100644 --- a/resources/views/frames/create.blade.php +++ b/resources/views/frames/create.blade.php @@ -66,7 +66,7 @@ @foreach($o->getVisibleAttributes() as $ao) - + @endforeach @if(! $template) diff --git a/resources/views/frames/dn.blade.php b/resources/views/frames/dn.blade.php index e8438d8a..5d039073 100644 --- a/resources/views/frames/dn.blade.php +++ b/resources/views/frames/dn.blade.php @@ -75,8 +75,8 @@
- @foreach($o->templates as $template => $name) -
$loop->index === 0]) id="template-{{$template}}" role="tabpanel"> - @include('fragment.template.dn',['template'=>$o->template($template)]) + @foreach($o->templates as $template) +
$loop->index === 0]) id="template-{{ $template->name }}" role="tabpanel"> + @include('fragment.template.dn',['template'=>$template])
@endforeach