View | Details | Raw Unified | Return to bug 41829
Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py (-21 / +4 lines)
 Lines 683-700   def _create(self): Link Here 
683
		# evaluate extended attributes
683
		# evaluate extended attributes
684
		ocs = set()
684
		ocs = set()
685
		for prop in getattr(m, 'extended_udm_attributes', []):
685
		for prop in getattr(m, 'extended_udm_attributes', []):
686
			univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'simpleLdap._create: prop.objClass = %s, prop.name = %s'% (prop.objClass, prop.name))
686
			univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'simpleLdap._create: info[%s]:%r = %r'% (prop.name, self.has_key(prop.name), self.info.get(prop.name)))
687
			if not self.info.get(prop.name):
687
			if self.has_key(prop.name) and self.info.get(prop.name):
688
				continue
689
			univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'simpleLdap._create: prop.name: info[%s] = %s'% (prop.name, self.info.get(prop.name)))
690
691
			# do not add object class and value if syntax is boolean and checkbox is disabled
692
			if prop.syntax == 'boolean' and self.info.get(prop.name) == '0':
693
				al = [x for x in al if x[0].lower() != prop.ldapMapping.lower()]
694
				continue
695
696
			# in all other cases add object class
697
			if self.has_key(prop.name):
698
				ocs.add(prop.objClass)
688
				ocs.add(prop.objClass)
699
689
700
		# add object classes of (especially extended) options
690
		# add object classes of (especially extended) options
 Lines 805-818   def _ldap_object_classes(self, ml): Link Here 
805
		for prop in getattr(m, 'extended_udm_attributes', []):
795
		for prop in getattr(m, 'extended_udm_attributes', []):
806
			univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'simpleLdap._modify: extended attribute=%r  oc=%r'% (prop.name, prop.objClass))
796
			univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'simpleLdap._modify: extended attribute=%r  oc=%r'% (prop.name, prop.objClass))
807
797
808
			if self.__ea_value_is_set(prop.name):
798
			if self.has_key(prop.name) and self.info.get(prop.name):
809
				required_ocs |= set([prop.objClass])
799
				required_ocs |= set([prop.objClass])
810
				continue
800
				continue
811
801
812
			if prop.deleteObjClass:
802
			if prop.deleteObjClass:
813
				unneeded_ocs |= set([prop.objClass])
803
				unneeded_ocs |= set([prop.objClass])
814
804
815
			# if the value is unset (or a boolean attribute with value == 0) we need to remove the attribute completely
805
			# if the value is unset we need to remove the attribute completely
816
			if self.oldattr.get(prop.ldapMapping):
806
			if self.oldattr.get(prop.ldapMapping):
817
				ml = [x for x in ml if x[0].lower() != prop.ldapMapping.lower()]
807
				ml = [x for x in ml if x[0].lower() != prop.ldapMapping.lower()]
818
				ml.append((prop.ldapMapping, self.oldattr.get(prop.ldapMapping), ''))
808
				ml.append((prop.ldapMapping, self.oldattr.get(prop.ldapMapping), ''))
 Lines 868-880   def _ldap_object_classes(self, ml): Link Here 
868
858
869
		return ml
859
		return ml
870
860
871
	def __ea_value_is_set(self, name):
872
		if not self.has_key(name):
873
			return False
874
		if self.descriptions[name].syntax == 'boolean' and self.info.get(name) == '0':
875
			return False
876
		return self.info.get(name)
877
878
	def _move_in_subordinates(self, olddn):
861
	def _move_in_subordinates(self, olddn):
879
		result = self.lo.search(base=self.lo.base, filter=filter_format('(&(objectclass=person)(secretary=%s))', [olddn]), attr=['dn'])
862
		result = self.lo.search(base=self.lo.base, filter=filter_format('(&(objectclass=person)(secretary=%s))', [olddn]), attr=['dn'])
880
		for subordinate, attr in result:
863
		for subordinate, attr in result:
(-)a/management/univention-directory-manager-modules/modules/univention/admin/mapping.py (+11 lines)
 Lines 149-154   def mapBase64(value): Link Here 
149
			univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'ERROR in mapBase64: %s' % e)
149
			univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'ERROR in mapBase64: %s' % e)
150
	return ""
150
	return ""
151
151
152
def BooleanListToString(list):
153
	v = univention.admin.mapping.ListToString(list)
154
	if v == '0':
155
		return ''
156
	return v
157
158
def BooleanUnMap(value):
159
	if value == '0':
160
		return ''
161
	return value
162
152
class mapping:
163
class mapping:
153
	def __init__(self):
164
	def __init__(self):
154
		self._map={}
165
		self._map={}
(-)a/management/univention-directory-manager-modules/modules/univention/admin/modules.py (-1 / +6 lines)
 Lines 320-328   def update_extended_attributes(lo, module, position): Link Here 
320
		if attrs.get('univentionUDMPropertyMultivalue', [''])[0] == '1':
320
		if attrs.get('univentionUDMPropertyMultivalue', [''])[0] == '1':
321
			multivalue = 1
321
			multivalue = 1
322
			map_method = None
322
			map_method = None
323
			unmap_method = None
323
		else:
324
		else:
324
			multivalue = 0
325
			multivalue = 0
325
			map_method = univention.admin.mapping.ListToString
326
			map_method = univention.admin.mapping.ListToString
327
			unmap_method = None
328
			if propertySyntaxString == 'boolean':
329
				map_method = univention.admin.mapping.BooleanListToString
330
				unmap_method = univention.admin.mapping.BooleanUnMap
326
			# single value ==> use only first value
331
			# single value ==> use only first value
327
			propertyDefault = propertyDefault[0]
332
			propertyDefault = propertyDefault[0]
328
333
 Lines 362-368   def update_extended_attributes(lo, module, position): Link Here 
362
367
363
		# add LDAP mapping
368
		# add LDAP mapping
364
		if attrs['univentionUDMPropertyLdapMapping'][0].lower() != 'objectClass'.lower():
369
		if attrs['univentionUDMPropertyLdapMapping'][0].lower() != 'objectClass'.lower():
365
			module.mapping.register(pname, attrs['univentionUDMPropertyLdapMapping'][0], None, map_method)
370
			module.mapping.register(pname, attrs['univentionUDMPropertyLdapMapping'][0], unmap_method, map_method)
366
		else:
371
		else:
367
			module.mapping.register(pname, attrs['univentionUDMPropertyLdapMapping'][0], univention.admin.mapping.nothing, univention.admin.mapping.nothing)
372
			module.mapping.register(pname, attrs['univentionUDMPropertyLdapMapping'][0], univention.admin.mapping.nothing, univention.admin.mapping.nothing)
368
373

Return to bug 41829