2023-03-01 22:54:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\LDAP\Attribute;
|
|
|
|
|
2023-04-02 12:07:15 +00:00
|
|
|
use Illuminate\Contracts\View\View;
|
2023-03-01 22:54:30 +00:00
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
use App\Classes\LDAP\Attribute;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents an attribute whose values are schema related
|
|
|
|
*/
|
|
|
|
abstract class Schema extends Attribute
|
|
|
|
{
|
|
|
|
protected bool $internal = TRUE;
|
|
|
|
|
|
|
|
protected static function _get(string $filename,string $string,string $key): ?string
|
|
|
|
{
|
|
|
|
$array = Cache::remember($filename,86400,function() use ($filename) {
|
|
|
|
try {
|
|
|
|
$f = fopen($filename,'r');
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = collect();
|
|
|
|
|
|
|
|
while (! feof($f)) {
|
|
|
|
$line = trim(fgets($f));
|
|
|
|
|
|
|
|
if (! $line OR preg_match('/^#/',$line))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
$fields = explode(':',$line);
|
|
|
|
|
|
|
|
$result->put($x=Arr::get($fields,0),[
|
|
|
|
'title'=>Arr::get($fields,1,$x),
|
|
|
|
'ref'=>Arr::get($fields,2),
|
|
|
|
'desc'=>Arr::get($fields,3,__('No description available, can you help with one?')),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
fclose($f);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
});
|
|
|
|
|
|
|
|
return Arr::get(($array ? $array->get($string) : []),$key);
|
|
|
|
}
|
2023-04-02 12:07:15 +00:00
|
|
|
|
2024-01-19 23:36:30 +00:00
|
|
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
2023-04-02 12:07:15 +00:00
|
|
|
{
|
|
|
|
// @note Schema attributes cannot be edited
|
|
|
|
return view('components.attribute.internal')
|
|
|
|
->with('o',$this);
|
|
|
|
}
|
2023-03-01 22:54:30 +00:00
|
|
|
}
|