2009-06-30 10:46:00 +00:00
|
|
|
<?php
|
2021-12-08 12:26:12 +00:00
|
|
|
|
|
|
|
namespace App\Classes\LDAP;
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2023-03-31 04:55:08 +00:00
|
|
|
use Illuminate\Contracts\View\View;
|
2023-02-19 09:25:32 +00:00
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
2023-03-02 03:41:38 +00:00
|
|
|
use App\Classes\LDAP\Schema\AttributeType;
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
/**
|
2021-12-08 12:26:12 +00:00
|
|
|
* Represents an attribute of an LDAP Object
|
2009-06-30 10:46:00 +00:00
|
|
|
*/
|
2024-01-09 06:44:50 +00:00
|
|
|
class Attribute implements \Countable, \ArrayAccess
|
2021-12-08 12:26:12 +00:00
|
|
|
{
|
2023-02-19 09:25:32 +00:00
|
|
|
// Attribute Name
|
|
|
|
protected string $name;
|
|
|
|
|
2023-03-02 07:21:53 +00:00
|
|
|
protected ?AttributeType $schema = NULL;
|
2023-03-02 03:41:38 +00:00
|
|
|
|
2021-12-08 12:26:12 +00:00
|
|
|
/*
|
2009-07-01 06:09:17 +00:00
|
|
|
# Source of this attribute definition
|
|
|
|
protected $source;
|
2021-12-08 12:26:12 +00:00
|
|
|
*/
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2023-02-19 09:25:32 +00:00
|
|
|
// Current and Old Values
|
|
|
|
protected Collection $values;
|
|
|
|
|
2023-03-01 22:54:30 +00:00
|
|
|
// Is this attribute an internal attribute
|
2023-03-02 07:21:53 +00:00
|
|
|
protected bool $is_internal = FALSE;
|
2023-03-02 03:41:38 +00:00
|
|
|
|
|
|
|
// Is this attribute the RDN?
|
|
|
|
protected bool $is_rdn = FALSE;
|
|
|
|
|
2023-03-27 05:19:37 +00:00
|
|
|
// Objectclasses that require this attribute
|
2023-03-02 03:41:38 +00:00
|
|
|
protected Collection $required_by;
|
2023-03-01 22:54:30 +00:00
|
|
|
|
2023-03-02 03:55:06 +00:00
|
|
|
// MIN/MAX number of values
|
|
|
|
protected int $min_values_count = 0;
|
|
|
|
protected int $max_values_count = 0;
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2023-03-27 05:19:37 +00:00
|
|
|
// RFC3866 Language Tags
|
|
|
|
protected Collection $lang_tags;
|
|
|
|
|
2024-01-09 06:44:50 +00:00
|
|
|
// The old values for this attribute - helps with isDirty() to determine if there is an update pending
|
|
|
|
protected Collection $oldValues;
|
|
|
|
|
2023-03-02 03:55:06 +00:00
|
|
|
/*
|
2009-06-30 10:46:00 +00:00
|
|
|
# Has the attribute been modified
|
2009-07-01 06:09:17 +00:00
|
|
|
protected $modified = false;
|
|
|
|
# Is the attribute being deleted because of an object class removal
|
|
|
|
protected $forcedelete = false;
|
2009-06-30 10:46:00 +00:00
|
|
|
# Is the attribute visible
|
2009-07-01 06:09:17 +00:00
|
|
|
protected $visible = false;
|
|
|
|
protected $forcehide = false;
|
2009-06-30 10:46:00 +00:00
|
|
|
# Is the attribute modifiable
|
2009-07-01 06:09:17 +00:00
|
|
|
protected $readonly = false;
|
|
|
|
# LDAP attribute type MUST/MAY
|
|
|
|
protected $ldaptype = null;
|
|
|
|
# Attribute property type (eg password, select, multiselect)
|
|
|
|
protected $type = '';
|
|
|
|
# Attribute value to keep unique
|
|
|
|
protected $unique = false;
|
2009-06-30 10:46:00 +00:00
|
|
|
|
|
|
|
# Display parameters
|
2009-07-01 06:09:17 +00:00
|
|
|
protected $display = '';
|
|
|
|
protected $icon = '';
|
|
|
|
protected $hint = '';
|
|
|
|
# Helper details
|
|
|
|
protected $helper = array();
|
|
|
|
protected $helpervalue = array();
|
|
|
|
# Onchange details
|
|
|
|
protected $onchange = array();
|
|
|
|
# Show spacer after this attribute is rendered
|
|
|
|
protected $spacer = false;
|
|
|
|
protected $verify = false;
|
|
|
|
|
|
|
|
# Component size
|
|
|
|
protected $size = 0;
|
|
|
|
# Value max length
|
|
|
|
protected $maxlength = 0;
|
|
|
|
# Text Area sizings
|
|
|
|
protected $cols = 0;
|
|
|
|
protected $rows = 0;
|
|
|
|
|
|
|
|
# Public for sorting
|
|
|
|
public $page = 1;
|
|
|
|
public $order = 255;
|
|
|
|
public $ordersort = 255;
|
|
|
|
|
|
|
|
# Schema Aliases for this attribute (stored in lowercase)
|
|
|
|
protected $aliases = array();
|
|
|
|
|
|
|
|
# Configuration for automatically generated values
|
|
|
|
protected $autovalue = array();
|
|
|
|
protected $postvalue = array();
|
2021-12-08 12:26:12 +00:00
|
|
|
*/
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2023-02-19 09:25:32 +00:00
|
|
|
public function __construct(string $name,array $values)
|
|
|
|
{
|
2021-12-08 12:26:12 +00:00
|
|
|
$this->name = $name;
|
2023-02-19 09:25:32 +00:00
|
|
|
$this->values = collect($values);
|
2023-03-27 05:19:37 +00:00
|
|
|
$this->lang_tags = collect();
|
2023-09-02 10:50:54 +00:00
|
|
|
$this->required_by = collect();
|
2024-01-19 23:36:30 +00:00
|
|
|
$this->oldValues = collect($values);
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2023-03-02 07:21:53 +00:00
|
|
|
// No need to load our schema for internal attributes
|
|
|
|
if (! $this->is_internal)
|
2024-01-21 07:15:23 +00:00
|
|
|
$this->schema = (new Server)->schema('attributetypes',$name);
|
2023-03-02 03:41:38 +00:00
|
|
|
|
2021-12-08 12:26:12 +00:00
|
|
|
/*
|
2009-07-01 06:09:17 +00:00
|
|
|
# Should this attribute be hidden
|
|
|
|
if ($server->isAttrHidden($this->name))
|
|
|
|
$this->forcehide = true;
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Should this attribute value be read only
|
|
|
|
if ($server->isAttrReadOnly($this->name))
|
|
|
|
$this->readonly = true;
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Should this attribute value be unique
|
|
|
|
if ($server->isAttrUnique($this->name))
|
|
|
|
$this->unique = true;
|
2021-12-08 12:26:12 +00:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2023-03-01 22:54:30 +00:00
|
|
|
public function __get(string $key): mixed
|
|
|
|
{
|
2023-03-02 03:41:38 +00:00
|
|
|
return match ($key) {
|
2023-09-02 10:28:04 +00:00
|
|
|
// List all the attributes
|
|
|
|
'attributes' => $this->attributes(),
|
2023-03-02 03:41:38 +00:00
|
|
|
// Can this attribute have more values
|
2023-03-02 03:55:06 +00:00
|
|
|
'can_addvalues' => $this->schema && (! $this->schema->is_single_value) && ((! $this->max_values_count) || ($this->values->count() < $this->max_values_count)),
|
2023-03-02 03:41:38 +00:00
|
|
|
// Schema attribute description
|
|
|
|
'description' => $this->schema ? $this->schema->{$key} : NULL,
|
|
|
|
// Attribute hints
|
|
|
|
'hints' => $this->hints(),
|
2023-04-11 22:17:57 +00:00
|
|
|
// Can this attribute be edited
|
|
|
|
'is_editable' => $this->schema ? $this->schema->{$key} : NULL,
|
2023-03-02 03:41:38 +00:00
|
|
|
// Is this an internal attribute
|
|
|
|
'is_internal' => isset($this->{$key}) && $this->{$key},
|
2023-03-31 04:55:08 +00:00
|
|
|
// Is this attribute the RDN
|
|
|
|
'is_rdn' => $this->is_rdn,
|
2023-03-02 03:41:38 +00:00
|
|
|
// We prefer the name as per the schema if it exists
|
|
|
|
'name' => $this->schema ? $this->schema->{$key} : $this->{$key},
|
|
|
|
// Attribute name in lower case
|
|
|
|
'name_lc' => strtolower($this->name),
|
2024-01-19 23:36:30 +00:00
|
|
|
// Old Values
|
|
|
|
'old_values' => $this->oldValues,
|
2023-03-31 04:55:08 +00:00
|
|
|
// Attribute values
|
|
|
|
'values' => $this->values,
|
2023-03-02 03:41:38 +00:00
|
|
|
|
|
|
|
default => throw new \Exception('Unknown key:' . $key),
|
|
|
|
};
|
2023-03-01 22:54:30 +00:00
|
|
|
}
|
|
|
|
|
2024-01-19 23:36:30 +00:00
|
|
|
public function __set(string $key,mixed $values): void
|
|
|
|
{
|
|
|
|
switch ($key) {
|
|
|
|
case 'value':
|
|
|
|
$this->values = collect($values);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-02 10:28:04 +00:00
|
|
|
public function __toString(): string
|
|
|
|
{
|
2024-01-19 23:36:30 +00:00
|
|
|
return $this->name;
|
2023-09-02 10:28:04 +00:00
|
|
|
}
|
|
|
|
|
2024-01-10 21:59:40 +00:00
|
|
|
public function addValue(string $value): void
|
|
|
|
{
|
|
|
|
$this->values->push($value);
|
|
|
|
}
|
|
|
|
|
2024-01-09 06:44:50 +00:00
|
|
|
public function count(): int
|
|
|
|
{
|
|
|
|
return $this->values->count();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetExists(mixed $offset): bool
|
|
|
|
{
|
|
|
|
return ! is_null($this->values->get($offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetGet(mixed $offset): mixed
|
|
|
|
{
|
|
|
|
return $this->values->get($offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetSet(mixed $offset, mixed $value): void
|
|
|
|
{
|
|
|
|
// We cannot set new values using array syntax
|
|
|
|
}
|
|
|
|
|
|
|
|
public function offsetUnset(mixed $offset): void
|
|
|
|
{
|
|
|
|
// We cannot clear values using array syntax
|
|
|
|
}
|
|
|
|
|
2023-03-02 03:41:38 +00:00
|
|
|
/**
|
|
|
|
* Return the hints about this attribute, ie: RDN, Required, etc
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function hints(): array
|
|
|
|
{
|
|
|
|
$result = collect();
|
|
|
|
|
|
|
|
// Is this Attribute an RDN
|
|
|
|
if ($this->is_rdn)
|
|
|
|
$result->put(__('rdn'),__('This attribute is required for the RDN'));
|
|
|
|
|
|
|
|
// If this attribute name is an alias for the schema attribute name
|
|
|
|
// @todo
|
|
|
|
|
|
|
|
// objectClasses requiring this attribute
|
|
|
|
// eg: $result->put('required','Required by objectClasses: a,b');
|
|
|
|
if ($this->required_by->count())
|
|
|
|
$result->put(__('required'),sprintf('%s: %s',__('Required Attribute by ObjectClass(es)'),$this->required_by->join(',')));
|
|
|
|
|
2023-03-27 05:19:37 +00:00
|
|
|
// This attribute has language tags
|
|
|
|
if ($this->lang_tags->count())
|
|
|
|
$result->put(__('language tags'),sprintf('%s: %d',__('This Attribute has Language Tags'),$this->lang_tags->count()));
|
|
|
|
|
2023-03-02 03:41:38 +00:00
|
|
|
return $result->toArray();
|
|
|
|
}
|
|
|
|
|
2024-01-09 06:44:50 +00:00
|
|
|
/**
|
|
|
|
* Determine if this attribute has changes
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isDirty(): bool
|
|
|
|
{
|
|
|
|
if ($this->oldValues->count() !== $this->values->count())
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return $this->values->diff($this->oldValues)->count() !== 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function oldValues(array $array): void
|
|
|
|
{
|
|
|
|
$this->oldValues = collect($array);
|
|
|
|
}
|
|
|
|
|
2023-04-02 12:07:15 +00:00
|
|
|
/**
|
|
|
|
* Display the attribute value
|
|
|
|
*
|
|
|
|
* @param bool $edit
|
2024-01-19 23:36:30 +00:00
|
|
|
* @param bool $old
|
|
|
|
* @param bool $new
|
2023-04-02 12:07:15 +00:00
|
|
|
* @return View
|
|
|
|
*/
|
2024-01-19 23:36:30 +00:00
|
|
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
2023-03-31 04:55:08 +00:00
|
|
|
{
|
|
|
|
return view('components.attribute')
|
2024-01-19 23:36:30 +00:00
|
|
|
->with('o',$this)
|
2023-03-31 04:55:08 +00:00
|
|
|
->with('edit',$edit)
|
2024-01-19 23:36:30 +00:00
|
|
|
->with('old',$old)
|
|
|
|
->with('new',$new);
|
2023-03-31 04:55:08 +00:00
|
|
|
}
|
|
|
|
|
2023-03-02 03:41:38 +00:00
|
|
|
/**
|
|
|
|
* Set the objectclasses that require this attribute
|
|
|
|
*
|
|
|
|
* @param Collection $oc
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function required_by(Collection $oc): Collection
|
|
|
|
{
|
|
|
|
return $this->required_by = ($this->schema
|
|
|
|
? $oc->intersect($this->schema->required_by_object_classes)
|
|
|
|
: collect());
|
|
|
|
}
|
|
|
|
|
2023-03-27 05:19:37 +00:00
|
|
|
/**
|
|
|
|
* If this attribute has RFC3866 Language Tags, this will enable those values to be captured
|
|
|
|
*
|
|
|
|
* @param string $tag
|
|
|
|
* @param array $value
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setLangTag(string $tag,array $value): void
|
|
|
|
{
|
|
|
|
$this->lang_tags->put($tag,$value);
|
|
|
|
}
|
|
|
|
|
2023-03-02 03:41:38 +00:00
|
|
|
public function setRDN(): void
|
|
|
|
{
|
|
|
|
$this->is_rdn = TRUE;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
/**
|
|
|
|
* Return the name of the attribute.
|
|
|
|
*
|
|
|
|
* @param boolean $lower - Return the attribute in normal or lower case (default lower)
|
|
|
|
* @param boolean $real - Return the real attribute name (with ;binary, or just the name)
|
|
|
|
* @return string Attribute name
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getName($lower=true,$real=false) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->name);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($real)
|
|
|
|
return $lower ? strtolower($this->name) : $this->name;
|
|
|
|
else
|
|
|
|
return $lower ? strtolower($this->real_attr_name()) : $this->real_attr_name();
|
|
|
|
}
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getValues() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->values);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->values;
|
|
|
|
}
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getOldValues() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->oldvalues);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->oldvalues;
|
|
|
|
}
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getValueCount() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->values);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return count($this->values);
|
|
|
|
}
|
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
public function getSource() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->source);
|
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
return $this->source;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
/**
|
|
|
|
* Autovalue is called after the attribute is initialised, and thus the values from the ldap server will be set.
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
public function autoValue($new_val) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($this->values)
|
|
|
|
return;
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$this->values = $new_val;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function initValue($new_val) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($this->values || $this->oldvalues) {
|
|
|
|
debug_dump(array('new_val'=>$new_val,'this'=>$this));
|
|
|
|
debug_dump_backtrace('new and/or old values are set',1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->values = $new_val;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function clearValue() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$this->values = array();
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
public function setOldValue($val) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
$this->oldvalues = $val;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function setValue($new_val) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($this->values) {
|
2009-07-05 12:13:17 +00:00
|
|
|
if ($this->values == $new_val)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ($this->oldvalues) {
|
2009-07-01 06:09:17 +00:00
|
|
|
debug_dump($this);
|
|
|
|
debug_dump_backtrace('old values are set',1);
|
|
|
|
} else
|
|
|
|
$this->oldvalues = $this->values;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($new_val == $this->values)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$this->values = $new_val;
|
|
|
|
$this->justModified();
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function addValue($new_val,$i=-1) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($i < 0)
|
|
|
|
$i = $this->getValueCount();
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$old_val = $this->getValue($i);
|
2009-07-01 06:09:17 +00:00
|
|
|
if (is_null($old_val) || ($old_val != $new_val))
|
|
|
|
$this->justModified();
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->values[$i] = $new_val;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function delValue($i=-1) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($i < 0)
|
|
|
|
$this->setValue(array());
|
|
|
|
|
|
|
|
if (! $this->hasBeenModified())
|
|
|
|
$this->oldvalues = $this->values;
|
|
|
|
|
|
|
|
if (isset($this->values[$i])) {
|
|
|
|
unset($this->values[$i]);
|
|
|
|
$this->values = array_values($this->values);
|
|
|
|
$this->justModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
public function justModified() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->modified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasBeenModified() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->modified);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
return $this->modified;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function isForceDelete() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->forcedelete);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->forcedelete;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setForceDelete() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$this->forcedelete = true;
|
|
|
|
$this->oldvalues = $this->values;
|
|
|
|
$this->values = array();
|
|
|
|
$this->justModified();
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
public function isRequired() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($this->getMinValueCount() > 0)
|
2009-06-30 10:46:00 +00:00
|
|
|
return true;
|
2009-07-01 06:09:17 +00:00
|
|
|
elseif ($this->ldaptype == 'must')
|
2009-06-30 10:46:00 +00:00
|
|
|
return true;
|
2009-07-01 06:09:17 +00:00
|
|
|
elseif ($this->isRDN())
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isMay() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (($this->ldaptype == 'may') && ! $this->isRequired())
|
|
|
|
return true;
|
|
|
|
else
|
2009-06-30 10:46:00 +00:00
|
|
|
return false;
|
2009-07-01 06:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setType($type) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$this->type = strtolower($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getType() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->type);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLDAPtype($type) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$this->ldaptype = strtolower($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLDAPtype() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->ldaptype);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->ldaptype;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setProperties($properties) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
foreach ($properties as $index => $value) {
|
|
|
|
if ($index == 'maxvalnb') {
|
|
|
|
$this->setMaxValueCount($value);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
} elseif ($index == 'minvalnb') {
|
|
|
|
$this->setMinValueCount($value);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
} elseif ($index == 'maxlength') {
|
|
|
|
$this->setMinValueCount($value);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
} elseif ($index == 'hidden') {
|
|
|
|
$this->visible = $value;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
} elseif (in_array($index,array('cols','rows'))) {
|
|
|
|
# @todo To be implemented
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($this->$index))
|
|
|
|
$this->$index = $value;
|
|
|
|
else {
|
|
|
|
debug_dump($this);
|
|
|
|
debug_dump_backtrace(sprintf('Unknown property (%s) with value (%s) for (%s)',$index,$value,$this->getName()),1);
|
|
|
|
}
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRequired() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($this->getMinValueCount() <= 0)
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->setMinValueCount(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOptional() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->setMinValueCount(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isReadOnly() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->readonly);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
return $this->readonly;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setReadOnly() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->readonly = true;
|
|
|
|
}
|
|
|
|
|
2010-02-24 11:20:26 +00:00
|
|
|
public function isMultiple() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
public function isVisible() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->visible && (! $this->forcehide);
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function hide() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function show() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->visible = true;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function haveFriendlyName() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $_SESSION[APPCONFIG]->haveFriendlyName($this);
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getFriendlyName() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->display);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if ($this->display)
|
|
|
|
return $this->display;
|
2009-06-30 11:46:44 +00:00
|
|
|
else
|
2009-07-01 06:09:17 +00:00
|
|
|
return $_SESSION[APPCONFIG]->getFriendlyName($this);
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setDescription($description) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->description = $description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->description);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
return $this->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIcon($icon) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->icon = $icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->icon);
|
|
|
|
|
2009-07-08 06:14:50 +00:00
|
|
|
return $this->icon ? sprintf('%s/%s',IMGDIR,$this->icon) : '';
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getHint() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->hint);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
return $this->hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHint($hint) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->hint = $hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMaxLength() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->maxlength);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
return $this->maxlength;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMaxLength($maxlength) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->maxlength = $maxlength;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSize() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->size);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
return $this->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSize($size) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$this->size = $size;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getSpacer() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->spacer);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->spacer;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getPage() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->page);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->page;
|
|
|
|
}
|
|
|
|
public function setPage($page) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$this->page = $page;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getOnChange() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->onchange);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->onchange;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getHelper() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->helper);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->helper;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getHelperValue() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->helpervalue);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->helpervalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getVerify() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->verify);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->verify;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture all the LDAP details we are interested in
|
|
|
|
*
|
|
|
|
* @param sattr Schema Attribute
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
private function setLDAPdetails($sattr) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# By default, set this as a MAY attribute, later processing should make it a MUST attribute if it is.
|
|
|
|
if (! $this->ldaptype)
|
|
|
|
$this->ldaptype = 'may';
|
|
|
|
|
|
|
|
# Store our Aliases
|
|
|
|
foreach ($sattr->getAliases() as $alias)
|
|
|
|
array_push($this->aliases,strtolower($alias));
|
|
|
|
|
|
|
|
if ($sattr->getIsSingleValue())
|
|
|
|
$this->setMaxValueCount(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of aliases for this Attribute (as defined by the schema)
|
|
|
|
* This list will be lowercase.
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getAliases() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->aliases);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->aliases;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAutoValue() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->autovalue);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->autovalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPostValue() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->postvalue);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $this->postvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPostValue($postvalue) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$this->postvalue = $postvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setXML($values) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Mostly all the time, this should be an array
|
|
|
|
if (is_array($values))
|
|
|
|
foreach ($values as $index => $value)
|
|
|
|
switch ($index) {
|
|
|
|
# Helpers should be accompanied with a <post> attribute.
|
|
|
|
case 'helper':
|
2009-08-30 02:11:18 +00:00
|
|
|
if (! isset($values['post']) && ! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
|
2009-07-01 06:09:17 +00:00
|
|
|
system_message(array(
|
|
|
|
'title'=>sprintf('%s [<i>%s</i>]',_('Missing [post] setting in XML file'),$index),
|
|
|
|
'body'=>_('[helper] needs an accompanying [post] action.'),
|
|
|
|
'type'=>'warn'));
|
|
|
|
|
|
|
|
if (isset($value['value']) && ! is_array($value['value']) && preg_match('/^=php\.(\w+)\((.*)\)$/',$value['value'],$matches)) {
|
|
|
|
$this->helpervalue['function'] = $matches[1];
|
|
|
|
$this->helpervalue['args'] = $matches[2];
|
|
|
|
|
|
|
|
unset ($value['value']);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($value as $i => $detail) {
|
|
|
|
if (! in_array($i,array('default','display','id','value'))) {
|
2009-08-30 02:11:18 +00:00
|
|
|
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
|
|
|
|
system_message(array(
|
|
|
|
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$i),
|
|
|
|
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown XML type setting for helper will be ignored.'),$detail),
|
|
|
|
'type'=>'warn'));
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
unset($value[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->$index = $value;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'hidden': $value ? $this->visible = false : $this->visible = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'spacer': $value ? $this->$index = true : $this->$index = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
# Essentially, we ignore type, it is used to select an Attribute type in the Factory. But we'll generated a warning if there is an unknown type.
|
|
|
|
case 'type':
|
2009-08-30 02:11:18 +00:00
|
|
|
if (! in_array($value,array('password','multiselect','select','textarea')) && ! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
|
2009-07-01 06:09:17 +00:00
|
|
|
system_message(array(
|
|
|
|
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$index),
|
|
|
|
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown XML type setting will be ignored.'),$value),
|
|
|
|
'type'=>'warn'));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'post':
|
|
|
|
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$value,$matches)) {
|
|
|
|
$this->postvalue['function'] = $matches[1];
|
|
|
|
$this->postvalue['args'] = $matches[2];
|
|
|
|
|
|
|
|
} else
|
2009-08-30 02:11:18 +00:00
|
|
|
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
|
|
|
|
system_message(array(
|
|
|
|
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$index),
|
|
|
|
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown XML type setting will be ignored.'),$value),
|
|
|
|
'type'=>'warn'));
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
case 'value':
|
|
|
|
if (is_array($value))
|
2012-09-05 10:02:14 +00:00
|
|
|
foreach ($value as $x => $y) {
|
2011-05-01 01:39:54 +00:00
|
|
|
if (! $this->haveMoreValues()) {
|
|
|
|
system_message(array(
|
|
|
|
'title'=>_('Automatically removed attribute values from template'),
|
|
|
|
'body'=>sprintf('%s <small>[%s]</small>',_('Template defines more values than can be accepted by attribute.'),$this->getName(true)),
|
|
|
|
'type'=>'warn'));
|
|
|
|
|
|
|
|
$this->clearValue();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else
|
2012-09-05 10:02:14 +00:00
|
|
|
$this->addValue($x,$y);
|
2011-05-01 01:39:54 +00:00
|
|
|
}
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
# Check to see if the value is auto generated.
|
|
|
|
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$value,$matches)) {
|
|
|
|
$this->autovalue['function'] = $matches[1];
|
|
|
|
$this->autovalue['args'] = $matches[2];
|
|
|
|
|
|
|
|
# We'll add a hint too
|
|
|
|
if (! $this->hint)
|
|
|
|
$this->hint = _('Automatically determined');
|
|
|
|
|
|
|
|
} else
|
2011-05-01 01:39:54 +00:00
|
|
|
$this->addValue($value);
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
# Queries
|
|
|
|
case 'ordersort':
|
|
|
|
|
|
|
|
# Creation/Editing Templates
|
|
|
|
case 'cols':
|
|
|
|
case 'default':
|
|
|
|
case 'display':
|
|
|
|
case 'hint':
|
|
|
|
case 'icon':
|
|
|
|
case 'maxlength':
|
|
|
|
case 'onchange':
|
|
|
|
case 'order':
|
|
|
|
case 'page':
|
|
|
|
case 'readonly':
|
|
|
|
case 'rows':
|
|
|
|
case 'size':
|
2009-07-05 12:13:17 +00:00
|
|
|
case 'values':
|
2009-07-01 06:09:17 +00:00
|
|
|
case 'verify': $this->$index = $value;
|
|
|
|
break;
|
|
|
|
|
2010-01-30 01:24:46 +00:00
|
|
|
case 'max':
|
|
|
|
if ($this->getMaxValueCount() == -1)
|
|
|
|
$this->setMaxValueCount($value);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
default:
|
2009-08-30 02:11:18 +00:00
|
|
|
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_template_warning'))
|
|
|
|
system_message(array(
|
|
|
|
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$index),
|
|
|
|
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown attribute setting will be ignored.'),serialize($value)),
|
|
|
|
'type'=>'warn'));
|
2009-07-01 06:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
elseif (is_string($values) && (strlen($values) > 0))
|
|
|
|
$this->values = array($values);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the values removed in an attribute.
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getRemovedValues() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2011-04-28 14:19:53 +00:00
|
|
|
return array_diff($this->getOldValues(),$this->getValues());
|
2009-07-01 06:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the values removed in an attribute.
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
public function getAddedValues() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2011-04-28 14:19:53 +00:00
|
|
|
return array_diff($this->getValues(),$this->getOldValues());
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-07-01 06:09:17 +00:00
|
|
|
* Prunes off anything after the ";" in an attr name. This is useful for
|
|
|
|
* attributes that may have ";binary" appended to their names. With
|
|
|
|
* real_attr_name(), you can more easily fetch these attributes' schema
|
|
|
|
* with their "real" attribute name.
|
|
|
|
*
|
|
|
|
* @param string $attr_name The name of the attribute to examine.
|
|
|
|
* @return string
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
private function real_attr_name() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name);
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
return preg_replace('/;.*$/U','',$this->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does this attribute need supporting JS
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
public function needJS($type=null) {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (is_null($type)) {
|
|
|
|
foreach (array('focus','blur','validate') as $type)
|
|
|
|
if ($this->needJS($type))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} elseif ($type == 'focus') {
|
|
|
|
# We dont have any focus javascript routines.
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} elseif ($type == 'blur') {
|
|
|
|
if ($this->onchange || $this->isRequired())
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} elseif ($type == 'validate') {
|
|
|
|
if ($this->isRequired())
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else
|
|
|
|
debug_dump_backtrace(sprintf('Unknown JS request %s',$type),1);
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
2021-12-08 12:26:12 +00:00
|
|
|
*/
|
|
|
|
}
|