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

Collapse All | Expand All

(-)umc/js/udm/ReferencingObjects.js (+113 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
				array.forEach( value, lang.hitch( this, function( item ) {
58
					this._addReferencingObjectLink(item);
59
				}));
60
			} else {
61
				console.log('ReferencingObjects: not an object');
62
			};
63
		},
64
65
		_addReferencingObjectLink: function(item) {
66
67
			//  make sure that the item has all necessary properties
68
			if (!array.every(['module', 'id', 'objectType'], function(ikey) {
69
				if (!(ikey in item)) {
70
					console.log('ReferencingObjects: attribute module is missing');
71
					return false;
72
				}
73
				return true;
74
			})) {
75
				// item has not all necessary properties -> stop here
76
				return false;
77
			}
78
79
			// perpare information to open the referenced UDM object
80
			var moduleProps = {
81
				flavor : item.flavor,
82
				module : item.module,
83
				openObject: {
84
					objectDN : item.id,
85
					objectType : item.objectType
86
				}
87
			};
88
89
			// create new button
90
			var btn = new Button( {
91
				name : 'close',
92
				label : item.label,
93
				iconClass: tools.getIconClass( item.icon, 20, null, "background-size: contain" ),
94
				callback: function() {
95
					// open referenced UDM object
96
					if (app.getModule(moduleProps.module, moduleProps.flavor)) {
97
						topic.publish("/umc/modules/open", moduleProps.module, moduleProps.flavor, moduleProps);
98
					} else if (app.getModule(moduleProps.module, 'navigation')) {  // udm module
99
						topic.publish("/umc/modules/open", moduleProps.module, 'navigation', moduleProps);
100
					} else {
101
						topic.publish("/umc/modules/open", moduleProps.module, moduleProps.flavor, moduleProps);
102
					}
103
				}
104
			} );
105
106
			this.addChild( btn );
107
		},
108
109
		isValid: function() {
110
			return true;
111
		}
112
	});
113
});
(-)umc/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)
(-)umc/python/udm/udm_ldap.py (-19 / +10 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 698-726    Link Here 
698
		if ldap_dn:
699
		if ldap_dn:
699
			# hack reference list for policies into items
700
			# hack reference list for policies into items
700
			if self.is_policy_module():
701
			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
702
706
				# create item
703
				# create item
707
				item = {
704
				item = {
708
					'id': '_view_referencing_objects',
705
					'id': '$references$',
709
					'label': '',
706
					'type': 'umc/modules/udm/ReferencingObjects',
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
				}
707
				}
721
708
722
				# read UCR configuration
723
				item.update(widget(syntax, item))
724
				properties.append(item)
709
				properties.append(item)
725
710
726
		return properties
711
		return properties
 Lines 874-879    Link Here 
874
859
875
		return policies
860
		return policies
876
861
862
	def get_references(self, dn):
863
		if self.is_policy_module():  # TODO: move into the handlers/policies/*.py
864
			search_filter = filter_format("(&(objectClass=univentionPolicyReference)(univentionPolicyReference=%s))", (dn,))
865
			return read_syntax_choices(udm_syntax.LDAP_Search(filter=search_filter, viewonly=True))
866
		return []
867
877
	def types4superordinate(self, flavor, superordinate):
868
	def types4superordinate(self, flavor, superordinate):
878
		"""List of object types for the given superordinate"""
869
		"""List of object types for the given superordinate"""
879
		types = getattr(self.module, 'wizardtypesforsuper')
870
		types = getattr(self.module, 'wizardtypesforsuper')

Return to bug 33344