Skip to content

Commit 28f4869

Browse files
committed
Attribute is no longer iterable - cant be used now that we manage attribute tags
1 parent cf53528 commit 28f4869

File tree

3 files changed

+17
-39
lines changed

3 files changed

+17
-39
lines changed

app/Classes/LDAP/Attribute.php

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Represents an attribute of an LDAP Object
1414
*/
15-
class Attribute implements \Countable, \ArrayAccess, \Iterator
15+
class Attribute implements \Countable, \ArrayAccess
1616
{
1717
// Attribute Name
1818
protected string $name;
@@ -181,44 +181,19 @@ public function __toString(): string
181181

182182
/* INTERFACE */
183183

184-
public function current(): mixed
185-
{
186-
return $this->values->get($this->counter);
187-
}
188-
189-
public function next(): void
190-
{
191-
$this->counter++;
192-
}
193-
194-
public function key(): mixed
195-
{
196-
return $this->counter;
197-
}
198-
199-
public function valid(): bool
200-
{
201-
return $this->values->has($this->counter);
202-
}
203-
204-
public function rewind(): void
205-
{
206-
$this->counter = 0;
207-
}
208-
209184
public function count(): int
210185
{
211-
return $this->values->count();
186+
return $this->_values->dot()->count();
212187
}
213188

214189
public function offsetExists(mixed $offset): bool
215190
{
216-
return ! is_null($this->values->has($offset));
191+
return $this->_values->dot()->has($offset);
217192
}
218193

219194
public function offsetGet(mixed $offset): mixed
220195
{
221-
return $this->values->get($offset);
196+
return $this->_values->dot()->get($offset);
222197
}
223198

224199
public function offsetSet(mixed $offset, mixed $value): void
@@ -323,12 +298,12 @@ public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
323298

324299
public function render_item_old(string $dotkey): ?string
325300
{
326-
return Arr::get($this->_values_old->dot(),$dotkey);
301+
return Arr::get($this->values_old->dot(),$dotkey);
327302
}
328303

329304
public function render_item_new(string $dotkey): ?string
330305
{
331-
return Arr::get($this->_values->dot(),$dotkey);
306+
return Arr::get($this->values->dot(),$dotkey);
332307
}
333308

334309
/**

app/Http/Controllers/HomeController.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,22 @@ public function entry_pending_update(EntryRequest $request): \Illuminate\Http\Re
267267
// We need to process and encrypt the password
268268
if ($request->userpassword) {
269269
$passwords = [];
270-
foreach ($request->userpassword as $key => $value) {
270+
$po = $o->getObject('userpassword');
271+
foreach (Arr::dot($request->userpassword) as $dotkey => $value) {
271272
// If the password is still the MD5 of the old password, then it hasnt changed
272-
if (($old=Arr::get($o->userpassword,$key)) && ($value === md5($old))) {
273-
array_push($passwords,$old);
273+
if (($old=Arr::get($po,$dotkey)) && ($value === md5($old))) {
274+
$passwords[$dotkey] = $value;
274275
continue;
275276
}
276277

277278
if ($value) {
278-
$type = Arr::get($request->userpassword_hash,$key);
279-
array_push($passwords,Password::hash_id($type)->encode($value));
279+
$type = Arr::get($request->userpassword_hash,$dotkey);
280+
$passwords[$dotkey] = Password::hash_id($type)
281+
->encode($value);
280282
}
281283
}
282-
$o->userpassword = $passwords;
284+
285+
$o->userpassword = Arr::undot($passwords);
283286
}
284287

285288
if (! $o->getDirty())

app/Traits/MD5Updates.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ trait MD5Updates
1111
{
1212
public function isDirty(): bool
1313
{
14-
foreach ($this->values->diff($this->values_old) as $key => $value)
15-
if (md5(Arr::get($this->values_old,$key)) !== $value)
14+
foreach ($this->values_old->dot()->keys()->merge($this->values->dot()->keys())->unique() as $dotkey)
15+
if (md5(Arr::get($this->values_old->dot(),$dotkey)) !== Arr::get($this->values->dot(),$dotkey))
1616
return TRUE;
1717

1818
return FALSE;

0 commit comments

Comments
 (0)