...
 
Commits (12)
......@@ -167,6 +167,19 @@ class DateAttribute extends Attribute
$display = $this->renderInputField('date', $this->getHtmlId(), $attributes);
return $this->renderAcl($display);
}
function renderTemplateInput (): string
{
$id = $this->getHtmlId();
$attributes = [
'value' => '{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}'
];
if ($this->isSubAttribute) {
$attributes['class'] = 'subattribute';
}
$display = $this->renderInputField('text', $id, $attributes);
return $this->renderAcl($display);
}
}
/*!
......
......@@ -468,12 +468,12 @@ class Attribute
function check ()
{
global $config;
$value = $this->getValue();
if ($this->isRequired() && !$this->disabled && (($value === "") || ($value === []))) {
$currentValue = $this->getValue();
if ($this->isRequired() && !$this->disabled && (($currentValue === "") || ($currentValue === []))) {
return msgPool::required($this->getLabel());
} elseif (($this->unique !== FALSE) && !$this->disabled) {
$value = $this->computeLdapValue();
if (($value === "") || ($value === [])) {
$ldapValue = $this->computeLdapValue();
if (($ldapValue === "") || ($ldapValue === [])) {
return;
}
$ldap = $config->get_ldap_link();
......@@ -486,10 +486,10 @@ class Attribute
}
}
$ldap->cd($base);
if (is_array($value)) {
$filter = '(|('.$this->getLdapName().'='.join(')('.$this->getLdapName().'=', array_map('ldap_escape_f', $value)).'))';
if (is_array($ldapValue)) {
$filter = '(|('.$this->getLdapName().'='.join(')('.$this->getLdapName().'=', array_map('ldap_escape_f', $ldapValue)).'))';
} else {
$filter = '('.$this->getLdapName().'='.ldap_escape_f($value).')';
$filter = '('.$this->getLdapName().'='.ldap_escape_f($ldapValue).')';
}
$infos = pluglist::pluginInfos(get_class($this->plugin));
if ($this->uniqueFilter === NULL) {
......@@ -596,17 +596,17 @@ class Attribute
{
if ($this->visible) {
if ($readOnly) {
$value = $this->getValue();
if (is_array($value)) {
$currentValue = $this->getValue();
if (is_array($currentValue)) {
$input = '{literal}'.implode('<br/>', array_map(
function ($v)
{
return htmlentities($v, ENT_COMPAT, 'UTF-8');
},
$value
$currentValue
)).'{/literal}';
} else {
$input = '{literal}'.htmlentities($value, ENT_COMPAT, 'UTF-8').'{/literal}';
$input = '{literal}'.htmlentities($currentValue, ENT_COMPAT, 'UTF-8').'{/literal}';
}
} elseif ($this->isTemplate()) {
$input = $this->renderTemplateInput();
......@@ -756,10 +756,10 @@ class Attribute
if ($newvalue === NULL) {
$this->resetToDefault();
} elseif ($source['FIELD'] == 'dn') {
$value = $this->getInitialValue();
$value = preg_replace('/'.preg_quote($oldvalue, '/').'$/', $newvalue, $value, -1, $count);
$initialValue = $this->getInitialValue();
$initialValue = preg_replace('/'.preg_quote($oldvalue, '/').'$/', $newvalue, $initialValue, -1, $count);
if ($count > 0) {
$this->setValue($value);
$this->setValue($initialValue);
}
} elseif ($this->getInitialValue() == $oldvalue) {
$this->setValue($newvalue);
......
......@@ -549,7 +549,9 @@ class UsersGroupsRolesAttribute extends ObjectsAttribute
protected function fillDisplayValueFrom ($i, $attrs)
{
if (!isset($attrs[$this->display_attr])) {
if ($this->isTemplate() && ($attrs === NULL)) {
$this->displays[$i] = $this->value[$i];
} elseif (!isset($attrs[$this->display_attr])) {
unset($this->value[$i]);
} else {
$cn = $attrs['cn'][0];
......
......@@ -200,14 +200,12 @@ class simplePlugin implements SimpleTab
}
/* Ensure that we've a valid acl_category set */
if (empty($this->acl_category)) {
if (isset($plInfo['plCategory'])) {
$c = key($plInfo['plCategory']);
if (is_numeric($c)) {
$c = $plInfo['plCategory'][0];
}
$this->acl_category = $c.'/';
if (empty($this->acl_category) && isset($plInfo['plCategory'])) {
$c = key($plInfo['plCategory']);
if (is_numeric($c)) {
$c = $plInfo['plCategory'][0];
}
$this->acl_category = $c.'/';
}
/* Check if this entry was opened in read only mode */
......@@ -1335,7 +1333,7 @@ class simplePlugin implements SimpleTab
}
}
/* Some of them have post-filling hook */
foreach ($this->attributesInfo as $section => $sectionInfo) {
foreach ($this->attributesInfo as $sectionInfo) {
foreach ($sectionInfo['attrs'] as $attr) {
$attr->fillLdapValueHook($this->attrs);
}
......
......@@ -31,7 +31,7 @@ class dashboard extends simplePlugin
'plObjectType' => [
'dashboard' => [
'name' => _('Dashboard'),
'tabClass' => 'tabs_dashboard',
'tabClass' => 'dashboardTabs',
'mainAttr' => FALSE
]
],
......
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2011-2016 FusionDirectory
Copyright (C) 2011-2019 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -18,7 +18,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tabs_dashboard extends simpleTabs_noSpecial
class dashboardTabs extends simpleTabs_noSpecial
{
function __construct ($type, $dn, $copied_object = NULL)
{
......
......@@ -39,23 +39,14 @@ class GroupMembersAttribute extends ObjectsAttribute
protected function fillDisplayValueFrom ($i, $attrs)
{
if ($attrs) {
$code = FALSE;
$objectType = '';
if (is_array($attrs)) {
foreach (ogroup::$objectTypes as $code => $objectType) {
foreach (ogroup::$objectTypes as $key => $value) {
try {
if (objects::isOfType($attrs, $objectType)) {
$infos = objects::infos($objectType);
$this->types[$i] = $code;
$this->displays[$i] = $attrs[$infos['nameAttr']][0];
if (strtolower($objectType) == 'user') {
if (isset($attrs['description'][0])) {
$this->displays[$i] .= ' ['.$attrs['uid'][0].' - '.$attrs['description'][0].']';
} else {
$this->displays[$i] .= ' ['.$attrs['uid'][0].']';
}
} elseif (isset($attrs['description'][0])) {
$this->displays[$i] .= ' ['.$attrs['description'][0].']';
}
break;
if (objects::isOfType($attrs, $value)) {
$code = $key;
$objectType = $value;
}
} catch (NonExistingObjectTypeException $e) {
continue;
......@@ -64,19 +55,19 @@ class GroupMembersAttribute extends ObjectsAttribute
} else {
$objectType = $attrs->getTemplatedType();
$code = array_search(strtolower($objectType), array_map('strtolower', ogroup::$objectTypes));
if ($code !== FALSE) {
$infos = objects::infos($objectType);
$this->types[$i] = $code;
$this->displays[$i] = $attrs[$infos['nameAttr']][0];
if (strtolower($objectType) == 'user') {
if (isset($attrs['description'][0])) {
$this->displays[$i] .= ' ['.$attrs['uid'][0].' - '.$attrs['description'][0].']';
} else {
$this->displays[$i] .= ' ['.$attrs['uid'][0].']';
}
} elseif (isset($attrs['description'][0])) {
$this->displays[$i] .= ' ['.$attrs['description'][0].']';
}
if ($code !== FALSE) {
$infos = objects::infos($objectType);
$this->types[$i] = $code;
$this->displays[$i] = $attrs[$infos['nameAttr']][0];
if (strtolower($objectType) == 'user') {
if (isset($attrs['description'][0])) {
$this->displays[$i] .= ' ['.$attrs['uid'][0].' - '.$attrs['description'][0].']';
} else {
$this->displays[$i] .= ' ['.$attrs['uid'][0].']';
}
} elseif (isset($attrs['description'][0])) {
$this->displays[$i] .= ' ['.$attrs['description'][0].']';
}
}
if (!isset($this->displays[$i])) {
......
......@@ -33,7 +33,7 @@ class configInLdap extends simplePlugin
'configuration' => [
'name' => _('FusionDirectory configuration'),
'filter' => 'objectClass=fusionDirectoryConf',
'tabClass' => 'tabs_configInLdap',
'tabClass' => 'configInLdapTabs',
'icon' => 'geticon.php?context=categories&icon=settings&size=16',
'mainAttr' => FALSE,
'ou' => preg_replace('/^[^,]+,/', '', CONFIGRDN)
......
......@@ -19,7 +19,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tabs_configInLdap extends simpleTabs
class configInLdapTabs extends simpleTabs
{
function save ()
{
......
......@@ -43,7 +43,7 @@ class setup
new setupStepLanguage($this),
new setupStepChecks($this),
new setupStepLdap($this),
new setupStepConfig_before_init($this),
new setupStepConfigBeforeInit($this),
new setupStepMigrate($this),
new setupStepFinish($this),
];
......
......@@ -20,7 +20,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class setupStepConfig_before_init extends setupStep
class setupStepConfigBeforeInit extends setupStep
{
function update_strings ()
{
......