From 2a25ff89886ccea5345b6efac6db731be1048d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Tue, 25 Sep 2018 10:54:49 +0200 Subject: [PATCH] :sparkles: feat(attributes) Add a generic ObjectLinkAttribute class issue #5896 --- include/simpleplugin/class_Attribute.inc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc index 2629af792..77e938a53 100644 --- a/include/simpleplugin/class_Attribute.inc +++ b/include/simpleplugin/class_Attribute.inc @@ -894,4 +894,25 @@ class DisplayAttribute extends DisplayLDAPAttribute $this->setInLdap(FALSE); } } -?> + +/*! \brief This class allow to display a link to an object which dn is stored in the attribute + */ +class ObjectLinkAttribute extends DisplayLDAPAttribute +{ + protected $type; + + function __construct ($label, $description, $ldapName, $required, $type, $defaultValue = "", $acl = "") + { + parent::__construct ($label, $description, $ldapName, $required, $defaultValue, $acl); + $this->type = $type; + } + + function renderFormInput () + { + try { + return objects::link($this->value, $this->type); + } catch (NonExistingLdapNodeException $e) { + return '<a><img src="geticon.php?context=status&icon=dialog-warning&size=16" alt="warning" class="center"/> '.sprintf(_('Invalid: %s'), $this->value).'</a>'; + } + } +} -- GitLab