Handle no attribute tags at an Attribute::class level, added form/disabled components
This commit is contained in:
@@ -19,6 +19,7 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
|
||||
// Is this attribute an internal attribute
|
||||
protected(set) bool $is_internal = FALSE;
|
||||
protected(set) bool $no_attr_tags = FALSE;
|
||||
|
||||
// MIN/MAX number of values
|
||||
protected(set) int $min_values_count = 0;
|
||||
@@ -34,9 +35,9 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
// The DN this object is in
|
||||
protected(set) string $dn;
|
||||
// The old values for this attribute - helps with isDirty() to determine if there is an update pending
|
||||
protected(set) Collection $values_old;
|
||||
private Collection $_values_old;
|
||||
// Current Values
|
||||
protected Collection $values;
|
||||
private Collection $_values;
|
||||
// The objectclasses of the entry that has this attribute
|
||||
protected(set) Collection $oc;
|
||||
|
||||
@@ -153,7 +154,10 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
// Used in Object Classes
|
||||
'used_in' => $this->schema?->used_in_object_classes ?: collect(),
|
||||
// The current attribute values
|
||||
'values' => $this->values,
|
||||
'values' => $this->no_attr_tags ? collect($this->_values->first()) : $this->_values,
|
||||
// The original attribute values
|
||||
'values_old' => $this->no_attr_tags ? collect($this->_values_old->first()) : $this->_values_old,
|
||||
|
||||
|
||||
default => throw new \Exception('Unknown key:' . $key),
|
||||
};
|
||||
@@ -163,8 +167,11 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
{
|
||||
switch ($key) {
|
||||
case 'values':
|
||||
if (is_null($values)) throw new \Exception('values is null?');
|
||||
$this->values = $values;
|
||||
$this->_values = $values;
|
||||
break;
|
||||
|
||||
case 'values_old':
|
||||
$this->_values_old = $values;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -28,6 +28,11 @@ class Factory
|
||||
'entrydn' => Internal\DN::class,
|
||||
'entryuuid' => Internal\UUID::class,
|
||||
'etag' => Internal\Etag::class,
|
||||
'krblastfailedauth' => Attribute\NoAttrTags\Generic::class,
|
||||
'krblastpwdchange' => Attribute\NoAttrTags\Generic::class,
|
||||
'krblastsuccessfulauth' => Attribute\NoAttrTags\Generic::class,
|
||||
'krbpasswordexpiration' => Attribute\NoAttrTags\Generic::class,
|
||||
'krbloginfailedcount' => Attribute\NoAttrTags\Generic::class,
|
||||
'krbprincipalkey' => KrbPrincipalKey::class,
|
||||
'krbticketflags' => KrbTicketFlags::class,
|
||||
'gidnumber' => GidNumber::class,
|
||||
|
@@ -9,4 +9,5 @@ use App\Classes\LDAP\Attribute;
|
||||
*/
|
||||
final class GidNumber extends Attribute
|
||||
{
|
||||
protected(set) bool $no_attr_tags = FALSE;
|
||||
}
|
@@ -12,15 +12,7 @@ use App\Classes\LDAP\Attribute;
|
||||
abstract class Internal extends Attribute
|
||||
{
|
||||
protected(set) bool $is_internal = TRUE;
|
||||
|
||||
public function __get(string $key): mixed
|
||||
{
|
||||
return match ($key) {
|
||||
// Internal items shouldnt have language tags, so our values should only have 1 key
|
||||
'values'=>collect($this->values->first()),
|
||||
default => parent::__get($key),
|
||||
};
|
||||
}
|
||||
protected(set) bool $no_attr_tags = TRUE;
|
||||
|
||||
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||
{
|
||||
|
@@ -15,6 +15,8 @@ final class KrbPrincipalKey extends Attribute
|
||||
{
|
||||
use MD5Updates;
|
||||
|
||||
protected(set) bool $no_attr_tags = TRUE;
|
||||
|
||||
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||
{
|
||||
return view('components.attribute.krbprincipalkey')
|
||||
|
@@ -13,6 +13,8 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
final class KrbTicketFlags extends Attribute
|
||||
{
|
||||
protected(set) bool $no_attr_tags = TRUE;
|
||||
|
||||
private const DISALLOW_POSTDATED = 0x00000001;
|
||||
private const DISALLOW_FORWARDABLE = 0x00000002;
|
||||
private const DISALLOW_TGT_BASED = 0x00000004;
|
||||
|
13
app/Classes/LDAP/Attribute/NoAttrTags/Generic.php
Normal file
13
app/Classes/LDAP/Attribute/NoAttrTags/Generic.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\LDAP\Attribute\NoAttrTags;
|
||||
|
||||
use App\Classes\LDAP\Attribute;
|
||||
|
||||
/**
|
||||
* Represents an Attribute that doesnt have Lang Tags
|
||||
*/
|
||||
class Generic extends Attribute
|
||||
{
|
||||
protected(set) bool $no_attr_tags = TRUE;
|
||||
}
|
@@ -12,6 +12,8 @@ use App\Classes\LDAP\Attribute;
|
||||
*/
|
||||
final class ObjectClass extends Attribute
|
||||
{
|
||||
protected(set) bool $no_attr_tags = TRUE;
|
||||
|
||||
// The schema ObjectClasses for this objectclass of a DN
|
||||
protected Collection $oc_schema;
|
||||
|
||||
@@ -21,7 +23,7 @@ final class ObjectClass extends Attribute
|
||||
* @param string $dn DN this attribute is used in
|
||||
* @param string $name Name of the attribute
|
||||
* @param array $values Current Values
|
||||
* @param array $oc The objectclasses that the DN of this attribute has
|
||||
* @param array $oc The objectclasses that the DN of this attribute has (ignored for objectclasses)
|
||||
*/
|
||||
public function __construct(string $dn,string $name,array $values,array $oc=[])
|
||||
{
|
||||
@@ -29,7 +31,7 @@ final class ObjectClass extends Attribute
|
||||
|
||||
$this->oc_schema = config('server')
|
||||
->schema('objectclasses')
|
||||
->filter(fn($item)=>$this->values->merge($this->values_old)->unique()->contains($item->name));
|
||||
->filter(fn($item)=>$this->values_old->contains($item->name));
|
||||
}
|
||||
|
||||
public function __get(string $key): mixed
|
||||
|
@@ -15,6 +15,9 @@ use App\Traits\MD5Updates;
|
||||
final class Password extends Attribute
|
||||
{
|
||||
use MD5Updates;
|
||||
|
||||
protected(set) bool $no_attr_tags = TRUE;
|
||||
|
||||
private const password_helpers = 'Classes/LDAP/Attribute/Password';
|
||||
public const commands = 'App\\Classes\\LDAP\\Attribute\\Password\\';
|
||||
|
||||
|
@@ -14,6 +14,7 @@ use App\Classes\LDAP\Attribute;
|
||||
abstract class Schema extends Attribute
|
||||
{
|
||||
protected bool $internal = TRUE;
|
||||
protected(set) bool $no_attr_tags = TRUE;
|
||||
|
||||
protected static function _get(string $filename,string $string,string $key): ?string
|
||||
{
|
||||
@@ -52,15 +53,6 @@ abstract class Schema extends Attribute
|
||||
__('No description available, can you help with one?'));
|
||||
}
|
||||
|
||||
public function __get(string $key): mixed
|
||||
{
|
||||
return match ($key) {
|
||||
// Schema items shouldnt have language tags, so our values should only have 1 key
|
||||
'values'=>collect($this->values->first()),
|
||||
default => parent::__get($key),
|
||||
};
|
||||
}
|
||||
|
||||
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||
{
|
||||
// @note Schema attributes cannot be edited
|
||||
|
Reference in New Issue
Block a user