Compare commits

..

No commits in common. "a7be4e00b47829a88ae48889cc02f8621a5f4e86" and "66537dcec8293aa93ad1635daaf8c64a59323dcd" have entirely different histories.

10 changed files with 25 additions and 36 deletions

View File

@ -226,15 +226,12 @@ class Attribute implements \Countable, \ArrayAccess
/**
* Return the hints about this attribute, ie: RDN, Required, etc
*
* @return Collection
* @return array
*/
public function hints(): Collection
public function hints(): array
{
$result = collect();
if ($this->is_internal)
return $result;
// Is this Attribute an RDN
if ($this->is_rdn)
$result->put(__('rdn'),__('This attribute is required for the RDN'));
@ -249,7 +246,7 @@ class Attribute implements \Countable, \ArrayAccess
if ($this->isDynamic())
$result->put(__('dynamic'),__('These are dynamic values present as a result of another attribute'));
return $result;
return $result->toArray();
}
/**

View File

@ -6,7 +6,6 @@ use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
use App\Classes\LDAP\Attribute;
use App\Ldap\Entry;
/**
* Represents an ObjectClass Attribute
@ -75,7 +74,6 @@ final class ObjectClass extends Attribute
return view('components.attribute.objectclass')
->with('o',$this)
->with('edit',$edit)
->with('langtag',Entry::TAG_NOTAG)
->with('old',$old)
->with('new',$new);
}

View File

@ -24,11 +24,11 @@ final class RDN extends Attribute
};
}
public function hints(): Collection
public function hints(): array
{
return collect([
return [
'required' => __('RDN is required')
]);
];
}
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View

View File

@ -66,7 +66,6 @@ class LDIF extends Import
$m = [];
preg_match('/^([a-zA-Z0-9;-]+)(:+)\s+(.*)$/',$line,$m);
dump(['m'=>$m,'line'=>$line]);
switch (Arr::get($m,1)) {
case 'changetype':
@ -157,7 +156,7 @@ class LDIF extends Import
return $result;
}
public function xreadEntry() {
public function readEntry() {
static $haveVersion = FALSE;
if ($lines = $this->nextLines()) {
@ -219,7 +218,7 @@ class LDIF extends Import
default:
if (! $server->dnExists($dn))
return $this->error(_('Unknown change type'),$lines);
return $this->error(_('Unkown change type'),$lines);
}
} else

View File

@ -97,6 +97,7 @@ class APIController extends Controller
/**
* Return the required and additional attributes for an object class
*
* @param Request $request
* @param string $objectclass
* @return array
*/

View File

@ -93,12 +93,10 @@ class HomeController extends Controller
return $request->noheader
? view(sprintf('components.attribute.widget.%s',$id))
->with('o',Factory::create(dn: $dn,attribute: $id,values: [],oc: $request->objectclasses))
->with('o',Factory::create($dn,$id,[],$request->objectclasses))
->with('value',$request->value)
->with('langtag',Entry::TAG_NOTAG)
->with('loop',$xx)
: new AttributeType(Factory::create($dn,$id,[],$request->objectclasses),new: TRUE,edit: TRUE)
->render();
: new AttributeType(Factory::create($dn,$id,[],$request->objectclasses),TRUE)->render();
}
public function entry_create(EntryAddRequest $request): \Illuminate\Http\RedirectResponse

View File

@ -422,22 +422,22 @@ class Entry extends Model
/**
* Return this list of user attributes
*
* @param string $tag If null return all tags
* @param string|null $tag If null return all tags
* @return Collection
*/
public function getVisibleAttributes(string $tag=''): Collection
public function getVisibleAttributes(?string $tag=NULL): Collection
{
static $cache = [];
static $cache = NULL;
if (! Arr::get($cache,$tag ?: '_all_')) {
if (is_null($cache)) {
$ot = $this->getOtherTags();
$cache[$tag ?: '_all_'] = $this->objects
->filter(fn($item)=>(! $item->is_internal) && ((! $item->no_attr_tags) || (! $tag) || ($tag === Entry::TAG_NOTAG)))
->filter(fn($item)=>(! $tag) || $ot->has($item->name_lc) || count($item->tagValues($tag)) > 0);
$cache = $this->objects
->filter(fn($item)=>! $item->is_internal)
->filter(fn($item)=>is_null($tag) || $ot->has($item->name_lc) || count($item->tagValues($tag)) > 0);
}
return $cache[$tag ?: '_all_'];
return $cache;
}
public function hasAttribute(int|string $key): bool

View File

@ -2,8 +2,6 @@
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use App\Classes\LDAP\Attribute as LDAPAttribute;
@ -34,13 +32,13 @@ class Attribute extends Component
/**
* Get the view / contents that represent the component.
*
* @return View|string
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render(): View|string
public function render()
{
return $this->o
? $this->o
->render(edit: $this->edit,old: $this->old,new: $this->new)
->render($this->edit,$this->old,$this->new)
: $this->na;
}
}

View File

@ -2,6 +2,7 @@
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
@ -29,7 +30,7 @@ class AttributeType extends Component
/**
* Get the view / contents that represent the component.
*/
public function render(): View
public function render(): View|Closure|string
{
return view('components.attribute-type')
->with('o',$this->o)

View File

@ -46,9 +46,6 @@
if (added_oc.indexOf(item) !== -1)
return;
// Add our new OC to the list of OCs
oc.push(item);
// Add attribute to the page
$.ajax({
method: 'POST',
@ -149,7 +146,7 @@
if (x.length) {
x.remove();
// Add this to the must attrs list, because its been rendered
// Add this to the must attrs list, because its been rendered
} else {
attrs.push(mayitem);
}