2019-02-08 13:44:52 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Classes and functions for the template engine.
|
|
|
|
*
|
|
|
|
* @author The phpLDAPadmin development team
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents an attribute of a template.
|
|
|
|
*
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
* @subpackage Templates
|
|
|
|
*/
|
|
|
|
class Attribute {
|
|
|
|
# Attribute Name
|
|
|
|
public $name;
|
|
|
|
# Source of this attribute definition
|
|
|
|
protected $source;
|
|
|
|
|
|
|
|
# Current and Old Values
|
|
|
|
protected $oldvalues = array();
|
|
|
|
protected $values = array();
|
|
|
|
|
|
|
|
# MIN/MAX number of values
|
|
|
|
protected $min_value_count = -1;
|
|
|
|
protected $max_value_count = -1;
|
|
|
|
|
|
|
|
# Is the attribute internal
|
|
|
|
protected $internal = false;
|
|
|
|
# Has the attribute been modified
|
|
|
|
protected $modified = false;
|
|
|
|
# Is the attribute being deleted because of an object class removal
|
|
|
|
protected $forcedelete = false;
|
|
|
|
# Is the attribute visible
|
|
|
|
protected $visible = false;
|
|
|
|
protected $forcehide = false;
|
|
|
|
# Is the attribute modifiable
|
|
|
|
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;
|
|
|
|
|
|
|
|
# Display parameters
|
|
|
|
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;
|
|
|
|
public $rdn = false;
|
|
|
|
|
|
|
|
# Schema Aliases for this attribute (stored in lowercase)
|
|
|
|
protected $aliases = array();
|
|
|
|
|
|
|
|
# Configuration for automatically generated values
|
|
|
|
protected $autovalue = array();
|
|
|
|
protected $postvalue = array();
|
|
|
|
|
|
|
|
public function __construct($name,$values,$server_id,$source=null) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$server = $_SESSION[APPCONFIG]->getServer($server_id);
|
|
|
|
|
|
|
|
$sattr = $server->getSchemaAttribute($name);
|
|
|
|
if ($sattr) {
|
|
|
|
$this->name = $sattr->getName(false);
|
|
|
|
$this->setLDAPdetails($sattr);
|
|
|
|
|
|
|
|
} else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->name = $name;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->source = $source;
|
|
|
|
|
|
|
|
# XML attributes are shown by default
|
|
|
|
switch ($source) {
|
|
|
|
case 'XML': $this->show();
|
|
|
|
$this->setXML($values);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (! isset($values['values']))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_dump_backtrace('no index "values"', 1);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->initValue($values['values']);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Should this attribute be hidden
|
|
|
|
if ($server->isAttrHidden($this->name))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
$this->forcehide = TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
# Should this attribute value be read only
|
|
|
|
if ($server->isAttrReadOnly($this->name))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
$this->readonly = TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
# Should this attribute value be unique
|
|
|
|
if ($server->isAttrUnique($this->name))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
$this->unique = TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05: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
|
|
|
|
*/
|
|
|
|
public function getName($lower=true,$real=false) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs, $this->name);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($real)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return $lower ? strtolower($this->name) : $this->name;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return $lower ? strtolower($this->real_attr_name()) : $this->real_attr_name();
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getValues() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->values);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->values;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOldValues() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->oldvalues);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->oldvalues;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValueCount() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs, $this->values);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return count($this->values);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSource() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->source);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->source;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Autovalue is called after the attribute is initialised, and thus the values from the ldap server will be set.
|
2019-02-12 14:52:01 -05:00
|
|
|
* @param $new_val
|
2019-02-08 13:44:52 -05:00
|
|
|
*/
|
|
|
|
public function autoValue($new_val) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($this->values)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->values = $new_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function initValue($new_val) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function clearValue() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->values = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOldValue($val) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->oldvalues = $val;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setValue($new_val) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($this->values) {
|
|
|
|
if ($this->values == $new_val)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($this->oldvalues) {
|
|
|
|
debug_dump($this);
|
|
|
|
debug_dump_backtrace('old values are set',1);
|
|
|
|
} else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->oldvalues = $this->values;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($new_val == $this->values)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->values = $new_val;
|
|
|
|
$this->justModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addValue($new_val,$i=-1) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($i < 0)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$i = $this->getValueCount();
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$old_val = $this->getValue($i);
|
|
|
|
if (is_null($old_val) || ($old_val != $new_val))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->justModified();
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->values[$i] = $new_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delValue($i=-1) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($i < 0)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->setValue(array());
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if (! $this->hasBeenModified())
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->oldvalues = $this->values;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if (isset($this->values[$i])) {
|
|
|
|
unset($this->values[$i]);
|
|
|
|
$this->values = array_values($this->values);
|
|
|
|
$this->justModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValue($i) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if (isset($this->values[$i]))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return $this->values[$i];
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getOldValue($i) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if (isset($this->oldvalues[$i]))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return $this->oldvalues[$i];
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getMinValueCount() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->min_value_count);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->min_value_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMinValueCount($min) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->min_value_count = $min;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMaxValueCount() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->max_value_count);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->max_value_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMaxValueCount($max) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->max_value_count = $max;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function haveMoreValues() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($this->getMaxValueCount() < 0 || ($this->getValueCount() < $this->getMaxValueCount()))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function justModified() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->modified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasBeenModified() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->modified);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->modified;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isForceDelete() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->forcedelete);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->forcedelete;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setForceDelete() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->forcedelete = true;
|
|
|
|
$this->oldvalues = $this->values;
|
|
|
|
$this->values = array();
|
|
|
|
$this->justModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isInternal() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->internal);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->internal;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setInternal() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->internal = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isRequired() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($this->getMinValueCount() > 0)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
elseif ($this->ldaptype == 'must')
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
elseif ($this->isRDN())
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function isMay() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if (($this->ldaptype == 'may') && ! $this->isRequired())
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setType($type) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->type = strtolower($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getType() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->type);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLDAPtype($type) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->ldaptype = strtolower($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLDAPtype() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->ldaptype);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->ldaptype;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setProperties($properties) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05: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))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->$index = $value;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else {
|
|
|
|
debug_dump($this);
|
|
|
|
debug_dump_backtrace(sprintf('Unknown property (%s) with value (%s) for (%s)',$index,$value,$this->getName()),1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRequired() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($this->getMinValueCount() <= 0)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->setMinValueCount(1);
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setOptional() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->setMinValueCount(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isReadOnly() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->readonly);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->readonly;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setReadOnly() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->readonly = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isMultiple() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isVisible() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->visible && (! $this->forcehide);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hide() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function show() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->visible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function haveFriendlyName() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $_SESSION[APPCONFIG]->haveFriendlyName($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFriendlyName() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->display);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($this->display)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return $this->display;
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
return $_SESSION[APPCONFIG]->getFriendlyName($this);
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setDescription($description) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->description = $description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->description);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIcon($icon) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->icon = $icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->icon);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->icon ? sprintf('%s/%s',IMGDIR,$this->icon) : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHint() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->hint);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHint($hint) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->hint = $hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMaxLength() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->maxlength);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->maxlength;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMaxLength($maxlength) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->maxlength = $maxlength;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSize() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->size);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSize($size) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->size = $size;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSpacer() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->spacer);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->spacer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPage() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->page);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->page;
|
|
|
|
}
|
|
|
|
public function setPage($page) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->page = $page;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOnChange() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->onchange);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->onchange;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHelper() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->helper);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->helper;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHelperValue() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->helpervalue);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->helpervalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getVerify() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->verify);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->verify;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRDN($rdn) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->rdn = $rdn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return if this attribute is an RDN attribute
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function isRDN() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs, $this->rdn);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->rdn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture all the LDAP details we are interested in
|
|
|
|
*
|
|
|
|
* @param sattr Schema Attribute
|
|
|
|
*/
|
|
|
|
private function setLDAPdetails($sattr) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
# By default, set this as a MAY attribute, later processing should make it a MUST attribute if it is.
|
|
|
|
if (! $this->ldaptype)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->ldaptype = 'may';
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
# Store our Aliases
|
|
|
|
foreach ($sattr->getAliases() as $alias)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-12 15:23:38 -05:00
|
|
|
$this->aliases[] = strtolower($alias);
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if ($sattr->getIsSingleValue())
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->setMaxValueCount(1);
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of aliases for this Attribute (as defined by the schema)
|
|
|
|
* This list will be lowercase.
|
|
|
|
*/
|
|
|
|
public function getAliases() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->aliases);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->aliases;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAutoValue() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->autovalue);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->autovalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPostValue() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->postvalue);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return $this->postvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPostValue($postvalue) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->postvalue = $postvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setXML($values) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
# Mostly all the time, this should be an array
|
|
|
|
if (is_array($values))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
foreach ($values as $index => $value)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
switch ($index)
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
# Helpers should be accompanied with a <post> attribute.
|
|
|
|
case 'helper':
|
2019-02-12 14:57:50 -05:00
|
|
|
if ( ! isset($values['post']) && ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning'))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
system_message(array(
|
2019-02-12 14:57:50 -05:00
|
|
|
'title' => sprintf('%s [<i>%s</i>]', _('Missing [post] setting in XML file'), $index),
|
|
|
|
'body' => _('[helper] needs an accompanying [post] action.'),
|
|
|
|
'type' => 'warn'));
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
2019-02-12 14:57:50 -05:00
|
|
|
if (isset($value['value']) && ! is_array($value['value']) && preg_match('/^=php\.(\w+)\((.*)\)$/', $value['value'], $matches))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->helpervalue['function'] = $matches[1];
|
|
|
|
$this->helpervalue['args'] = $matches[2];
|
|
|
|
|
|
|
|
unset ($value['value']);
|
|
|
|
}
|
|
|
|
|
2019-02-12 14:57:50 -05:00
|
|
|
foreach ($value as $i => $detail)
|
|
|
|
{
|
|
|
|
if ( ! in_array($i, array('default', 'display', 'id', 'value')))
|
|
|
|
{
|
|
|
|
if ( ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning'))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
system_message(array(
|
2019-02-12 14:57:50 -05:00
|
|
|
'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'));
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
unset($value[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->$index = $value;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2019-02-12 14:57:50 -05:00
|
|
|
case 'hidden':
|
|
|
|
$value ? $this->visible = FALSE : $this->visible = TRUE;
|
2019-02-08 13:44:52 -05:00
|
|
|
break;
|
|
|
|
|
2019-02-12 14:57:50 -05:00
|
|
|
case 'spacer':
|
|
|
|
$value ? $this->$index = TRUE : $this->$index = FALSE;
|
2019-02-08 13:44:52 -05:00
|
|
|
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':
|
2019-02-12 14:57:50 -05:00
|
|
|
if ( ! in_array($value, array('password', 'multiselect', 'select', 'textarea')) && ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning'))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
system_message(array(
|
2019-02-12 14:57:50 -05:00
|
|
|
'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'));
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'post':
|
2019-02-12 14:57:50 -05:00
|
|
|
if (preg_match('/^=php\.(\w+)\((.*)\)$/', $value, $matches))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->postvalue['function'] = $matches[1];
|
|
|
|
$this->postvalue['args'] = $matches[2];
|
|
|
|
|
|
|
|
} else
|
2019-02-12 14:57:50 -05:00
|
|
|
if ( ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning'))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
system_message(array(
|
2019-02-12 14:57:50 -05:00
|
|
|
'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'));
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
case 'value':
|
|
|
|
if (is_array($value))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
foreach ($value as $x => $y)
|
|
|
|
{
|
|
|
|
if ( ! $this->haveMoreValues())
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
system_message(array(
|
2019-02-12 14:57:50 -05:00
|
|
|
'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'));
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
$this->clearValue();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
$this->addValue($x, $y);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
2019-02-12 14:57:50 -05:00
|
|
|
} else
|
2019-02-08 13:44:52 -05:00
|
|
|
# Check to see if the value is auto generated.
|
2019-02-12 14:57:50 -05:00
|
|
|
if (preg_match('/^=php\.(\w+)\((.*)\)$/', $value, $matches))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->autovalue['function'] = $matches[1];
|
|
|
|
$this->autovalue['args'] = $matches[2];
|
|
|
|
|
|
|
|
# We'll add a hint too
|
2019-02-12 14:57:50 -05:00
|
|
|
if ( ! $this->hint)
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->hint = _('Automatically determined');
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
} else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->addValue($value);
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
# Queries
|
|
|
|
case 'ordersort':
|
|
|
|
|
2019-02-12 14:57:50 -05:00
|
|
|
# Creation/Editing Templates
|
2019-02-08 13:44:52 -05:00
|
|
|
case 'cols':
|
|
|
|
case 'default':
|
|
|
|
case 'display':
|
|
|
|
case 'hint':
|
|
|
|
case 'icon':
|
|
|
|
case 'maxlength':
|
|
|
|
case 'onchange':
|
|
|
|
case 'order':
|
|
|
|
case 'page':
|
|
|
|
case 'readonly':
|
|
|
|
case 'rows':
|
|
|
|
case 'size':
|
|
|
|
case 'values':
|
2019-02-12 14:57:50 -05:00
|
|
|
case 'verify':
|
|
|
|
$this->$index = $value;
|
2019-02-08 13:44:52 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'max':
|
|
|
|
if ($this->getMaxValueCount() == -1)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->setMaxValueCount($value);
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
default:
|
2019-02-12 14:57:50 -05:00
|
|
|
if ( ! $_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning'))
|
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
system_message(array(
|
2019-02-12 14:57:50 -05:00
|
|
|
'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'));
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
elseif (is_string($values) && (strlen($values) > 0))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
$this->values = array($values);
|
2019-02-12 14:57:50 -05:00
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the values removed in an attribute.
|
|
|
|
*/
|
|
|
|
public function getRemovedValues() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return array_diff($this->getOldValues(),$this->getValues());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the values removed in an attribute.
|
|
|
|
*/
|
|
|
|
public function getAddedValues() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return array_diff($this->getValues(),$this->getOldValues());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function real_attr_name() {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 1, __FILE__, __LINE__, __METHOD__, $fargs, $this->name);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return preg_replace('/;.*$/U','',$this->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does this attribute need supporting JS
|
2019-02-12 14:52:01 -05:00
|
|
|
* @param null $type
|
|
|
|
* @return bool
|
2019-02-08 13:44:52 -05:00
|
|
|
*/
|
|
|
|
public function needJS($type=null) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
if (is_null($type)) {
|
|
|
|
foreach (array('focus','blur','validate') as $type)
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
2019-02-08 13:44:52 -05:00
|
|
|
if ($this->needJS($type))
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} elseif ($type == 'focus') {
|
|
|
|
# We dont have any focus javascript routines.
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} elseif ($type == 'blur') {
|
|
|
|
if ($this->onchange || $this->isRequired())
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
} elseif ($type == 'validate') {
|
|
|
|
if ($this->isRequired())
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
|
|
|
|
} else
|
2019-02-12 14:57:50 -05:00
|
|
|
{
|
|
|
|
debug_dump_backtrace(sprintf('Unknown JS request %s', $type), 1);
|
|
|
|
}
|
2019-02-08 13:44:52 -05:00
|
|
|
}
|
|
|
|
}
|
2019-02-12 14:52:01 -05:00
|
|
|
|