Use our Attribute::class when rendering update_confirm

This commit is contained in:
2025-01-16 12:47:55 +11:00
parent 293f1ab9ce
commit 30f964b849
5 changed files with 43 additions and 17 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Classes\LDAP;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use App\Classes\LDAP\Schema\AttributeType;
@@ -259,6 +260,16 @@ class Attribute implements \Countable, \ArrayAccess
->with('new',$new);
}
public function render_item_old(int $key): ?string
{
return Arr::get($this->old_values,$key);
}
public function render_item_new(int $key): ?string
{
return Arr::get($this->values,$key);
}
/**
* Set the objectclasses that require this attribute
*

View File

@@ -3,6 +3,7 @@
namespace App\Classes\LDAP\Attribute;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;
use App\Classes\LDAP\Attribute;
use App\Traits\MD5Updates;
@@ -22,4 +23,14 @@ final class Password extends Attribute
->with('old',$old)
->with('new',$new);
}
public function render_item_old(int $key): ?string
{
return Arr::get($this->oldValues,$key) ? str_repeat('x',8) : NULL;
}
public function render_item_new(int $key): ?string
{
return Arr::get($this->values,$key) ? str_repeat('x',8) : NULL;
}
}

View File

@@ -32,7 +32,7 @@ class Entry extends Model
parent::discardChanges();
// If we are discharging changes, we need to reset our $objects;
$this->objects = $this->getAttributesAsObjects($this->attributes);
$this->objects = $this->getAttributesAsObjects();
return $this;
}
@@ -112,7 +112,7 @@ class Entry extends Model
// We only set our objects on DN entries (otherwise we might get into a recursion loop if this is the schema DN)
if ($this->dn && (! in_array($this->dn,Arr::get($this->attributes,'subschemasubentry',[])))) {
$this->objects = $this->getAttributesAsObjects($this->attributes);
$this->objects = $this->getAttributesAsObjects();
} else {
$this->objects = collect();
@@ -157,11 +157,11 @@ class Entry extends Model
* @param array $attributes
* @return Collection
*/
protected function getAttributesAsObjects(array $attributes): Collection
public function getAttributesAsObjects(): Collection
{
$result = collect();
foreach ($attributes as $attribute => $value) {
foreach ($this->attributes as $attribute => $value) {
// If the attribute name has language tags
$matches = [];
if (preg_match('/^([a-zA-Z]+)(;([a-zA-Z-;]+))+/',$attribute,$matches)) {
@@ -271,7 +271,7 @@ class Entry extends Model
{
// In case we havent built our objects yet (because they werent available while determining the schema DN)
if ((! $this->objects->count()) && $this->attributes)
$this->objects = $this->getAttributesAsObjects($this->attributes);
$this->objects = $this->getAttributesAsObjects();
return $this->objects;
}