diff --git a/include/class_objects.inc b/include/class_objects.inc index f73b179d71dc69149d859f0a372b74e7b14d05fe..a01114b53399261cdcb6fc240933f9b1296286c5 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -229,9 +229,9 @@ class objects /* !\brief This method returns a list of all available templates for the given type */ - static function getTemplates($type) + static function getTemplates($type, $requiredPermissions = 'r') { - global $config; + global $config, $ui; $infos = self::infos($type); @@ -244,7 +244,13 @@ class objects $ldap->search('(objectClass=fdTemplate)', array('cn')); if ($ldap->count() != 0) { while ($attrs = $ldap->fetch()) { - $templates[$ldap->getDN()] = $attrs['cn'][0]." - ".LDAP::fix($key); + $dn = $ldap->getDN(); + if ($requiredPermissions != '') { + if (!preg_match('/'.$requiredPermissions.'/', $ui->get_permissions($dn, $infos['aclCategory'].'/'.'template'))) { + continue; + } + } + $templates[$dn] = $attrs['cn'][0]." - ".LDAP::fix($key); } } }