From 72090af5dc10cd3fc2d6e5ff5ad0a4c323a4bed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Mon, 19 Nov 2018 14:12:39 +0100 Subject: [PATCH] :sparkles: feat(objects) Support returning non-link from objects::link Used in invitations plugin issue #5924 --- include/class_objects.inc | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/include/class_objects.inc b/include/class_objects.inc index 2b9db93ba..e93415b0c 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -316,21 +316,23 @@ class objects return $tabObject; } - static function link ($dn, $type, $subaction = '', $text = NULL, $icon = TRUE) + static function link ($dn, $type, $subaction = '', $text = NULL, $icon = TRUE, $link = TRUE) { global $config; $infos = static::infos($type); - if (!isset($infos['management'])) { - throw new NoManagementClassException('Asked for link for type "'.$type.'" but it does not have a management class'); - } - $pInfos = pluglist::pluginInfos($infos['management']); - $index = $pInfos['INDEX']; - $action = 'edit'; - if ($subaction != '') { - $action .= '_'.$subaction; + if ($link) { + if (!isset($infos['management'])) { + throw new NoManagementClassException('Asked for link for type "'.$type.'" but it does not have a management class'); + } + $pInfos = pluglist::pluginInfos($infos['management']); + $index = $pInfos['INDEX']; + $action = 'edit'; + if ($subaction != '') { + $action .= '_'.$subaction; + } + $href = "main.php?plug=$index&reset=1&act=listing_$action&dn=".urlencode($dn); } - $href = "main.php?plug=$index&reset=1&act=listing_$action&dn=".urlencode($dn); if ($text === NULL) { $ldap = $config->get_ldap_link(); @@ -348,11 +350,17 @@ class objects $text = $text[$infos['nameAttr']][0]; } + $text = htmlentities($text, ENT_COMPAT, 'UTF-8'); + if ($icon && isset($infos['icon'])) { $text = '<img alt="'.$infos['name'].'" title="'.$dn.'" src="'.htmlentities($infos['icon'], ENT_COMPAT, 'UTF-8').'" class="center"/> '.$text; } - return '<a href="'.$href.'">'.$text.'</a>'; + if ($link) { + $text = '<a href="'.$href.'">'.$text.'</a>'; + } + + return $text; } static function create ($type) -- GitLab