View | Details | Raw Unified | Return to bug 33344 | Differences between
and this patch

Collapse All | Expand All

(-)js/udm/ReferencingObjects.js (+115 lines)
Line 0    Link Here 
1
/*
2
 * Copyright 2011-2016 Univention GmbH
3
 *
4
 * http://www.univention.de/
5
 *
6
 * All rights reserved.
7
 *
8
 * The source code of this program is made available
9
 * under the terms of the GNU Affero General Public License version 3
10
 * (GNU AGPL V3) as published by the Free Software Foundation.
11
 *
12
 * Binary versions of this program provided by Univention to you as
13
 * well as other copyrighted, protected or trademarked materials like
14
 * Logos, graphics, fonts, specific documentations and configurations,
15
 * cryptographic keys etc. are subject to a license agreement between
16
 * you and Univention and not subject to the GNU AGPL V3.
17
 *
18
 * In the case you use this program under the terms of the GNU AGPL V3,
19
 * the program is provided in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
 * GNU Affero General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU Affero General Public
25
 * License with the Debian GNU/Linux or Univention distribution in file
26
 * /usr/share/common-licenses/AGPL-3; if not, see
27
 * <http://www.gnu.org/licenses/>.
28
 */
29
/*global define console*/
30
31
define([
32
	"dojo/_base/declare",
33
	"dojo/_base/lang",
34
	"dojo/_base/array",
35
	"dojo/on",
36
	"dojo/topic",
37
	"umc/widgets/Button",
38
	"umc/tools",
39
	"umc/app",
40
	"umc/widgets/ContainerWidget",
41
], function(declare, lang, array, on, topic, Button, tools, app, ContainerWidget) {
42
	return declare("umc.modules.udm.ReferencingObjects", [ ContainerWidget, ], {
43
		// summary:
44
		//		Provides a list of buttons opening a given object
45
46
		name: '',
47
48
		value: null,
49
50
		disabled: false,
51
52
		// the widget's class name as CSS class
53
		baseClass: 'umcLinkList',
54
55
		_setValueAttr: function(value) {
56
			if (value instanceof Object) {
57
				this._set('value', value);
58
				this.destroyDescendants();
59
				array.forEach( value, lang.hitch( this, function( item ) {
60
					this._addReferencingObjectLink(item);
61
				}));
62
			} else {
63
				console.log('ReferencingObjects: not an object');
64
			};
65
		},
66
67
		_addReferencingObjectLink: function(item) {
68
69
			//  make sure that the item has all necessary properties
70
			if (!array.every(['module', 'id', 'objectType'], function(ikey) {
71
				if (!(ikey in item)) {
72
					console.log('ReferencingObjects: attribute module is missing');
73
					return false;
74
				}
75
				return true;
76
			})) {
77
				// item has not all necessary properties -> stop here
78
				return false;
79
			}
80
81
			// perpare information to open the referenced UDM object
82
			var moduleProps = {
83
				flavor : item.flavor,
84
				module : item.module,
85
				openObject: {
86
					objectDN : item.id,
87
					objectType : item.objectType
88
				}
89
			};
90
91
			// create new button
92
			var btn = new Button( {
93
				name : 'close',
94
				label : item.label,
95
				iconClass: tools.getIconClass( item.icon, 20, null, "background-size: contain" ),
96
				callback: function() {
97
					// open referenced UDM object
98
					if (app.getModule(moduleProps.module, moduleProps.flavor)) {
99
						topic.publish("/umc/modules/open", moduleProps.module, moduleProps.flavor, moduleProps);
100
					} else if (app.getModule(moduleProps.module, 'navigation')) {  // udm module
101
						topic.publish("/umc/modules/open", moduleProps.module, 'navigation', moduleProps);
102
					} else {
103
						topic.publish("/umc/modules/open", moduleProps.module, moduleProps.flavor, moduleProps);
104
					}
105
				}
106
			} );
107
108
			this.addChild( btn );
109
		},
110
111
		isValid: function() {
112
			return true;
113
		}
114
	});
115
});
(-)python/udm/__init__.py (+1 lines)
 Lines 481-486    Link Here 
481
						props['$labelObjectType$'] = module.title
481
						props['$labelObjectType$'] = module.title
482
						props['$flags$'] = obj.oldattr.get('univentionObjectFlag', [])
482
						props['$flags$'] = obj.oldattr.get('univentionObjectFlag', [])
483
						props['$operations$'] = module.operations
483
						props['$operations$'] = module.operations
484
						props['$references$'] = module.get_references(ldap_dn)
484
						result.append(props)
485
						result.append(props)
485
					else:
486
					else:
486
						MODULE.process('The LDAP object for the LDAP DN %s could not be found' % ldap_dn)
487
						MODULE.process('The LDAP object for the LDAP DN %s could not be found' % ldap_dn)
(-)python/udm/udm_ldap.py (-29 / +9 lines)
 Lines 55-60    Link Here 
55
from .syntax import widget, default_value
55
from .syntax import widget, default_value
56
56
57
from ldap import LDAPError, NO_SUCH_OBJECT
57
from ldap import LDAPError, NO_SUCH_OBJECT
58
from ldap.filter import filter_format
58
59
59
try:
60
try:
60
	import univention.admin.license
61
	import univention.admin.license
 Lines 638-644    Link Here 
638
			if mod is not None and self.name == mod.name and self.is_policy_module():
639
			if mod is not None and self.name == mod.name and self.is_policy_module():
639
				layout = copy.copy(layout)
640
				layout = copy.copy(layout)
640
				tab = udm_layout.Tab(_('Referencing objects'), _('Objects referencing this policy object'),
641
				tab = udm_layout.Tab(_('Referencing objects'), _('Objects referencing this policy object'),
641
					layout=['_view_referencing_objects']
642
					layout=['$references$']
642
				)
643
				)
643
				layout.append(tab)
644
				layout.append(tab)
644
645
 Lines 695-728    Link Here 
695
			if iprop['id'] in inLayout:
696
			if iprop['id'] in inLayout:
696
				properties.append(iprop)
697
				properties.append(iprop)
697
698
698
		if ldap_dn:
699
			# hack reference list for policies into items
700
			if self.is_policy_module():
701
				# create syntax object
702
				syntax = udm_syntax.LDAP_Search(
703
					filter='(&(objectClass=univentionPolicyReference)(univentionPolicyReference=%s))' % ldap_dn,
704
					viewonly=True)
705
706
				# create item
707
				item = {
708
					'id': '_view_referencing_objects',
709
					'label': '',
710
					'description': '',
711
					'syntax': syntax.name,
712
					'size': syntax.size,
713
					'required': False,
714
					'editable': False,
715
					'options': [],
716
					'readonly': False,
717
					'searchable': False,
718
					'multivalue': True,
719
					'identifies': False,
720
				}
721
722
				# read UCR configuration
723
				item.update(widget(syntax, item))
724
				properties.append(item)
725
726
		return properties
699
		return properties
727
700
728
	@property
701
	@property
 Lines 771-776    Link Here 
771
			item.update(widget(prop.syntax, item))
744
			item.update(widget(prop.syntax, item))
772
			props.append(item)
745
			props.append(item)
773
		props.append({'id': '$options$', 'type': 'WidgetGroup', 'widgets': self.get_options()})
746
		props.append({'id': '$options$', 'type': 'WidgetGroup', 'widgets': self.get_options()})
747
		props.append({'id': '$references$', 'type': 'umc/modules/udm/ReferencingObjects', 'readonly': True})
774
748
775
		return props
749
		return props
776
750
 Lines 874-879    Link Here 
874
848
875
		return policies
849
		return policies
876
850
851
	def get_references(self, dn):
852
		if self.is_policy_module():  # TODO: move into the handlers/policies/*.py
853
			search_filter = filter_format("(&(objectClass=univentionPolicyReference)(univentionPolicyReference=%s))", (dn,))
854
			return read_syntax_choices(udm_syntax.LDAP_Search(filter=search_filter, viewonly=True))
855
		return []
856
877
	def types4superordinate(self, flavor, superordinate):
857
	def types4superordinate(self, flavor, superordinate):
878
		"""List of object types for the given superordinate"""
858
		"""List of object types for the given superordinate"""
879
		types = getattr(self.module, 'wizardtypesforsuper')
859
		types = getattr(self.module, 'wizardtypesforsuper')

Return to bug 33344