def setupPermissions(self, access_idents):
        action_map_perm = {
            "import_users": "user.create",
            "export_users": "user.view",
            "export_groups": "group.view",
            "open_filemanager": "file.browse",
            "exec_creategroupwizard": "group.create",
            "exec_createuserwizard": "user.create",
            "exec_accessmanager": "access.granter",
        }
        for action_key, acc_ident in action_map_perm.items():
            if not access_idents.count(acc_ident):
                self.action(action_key).setDisabled(True)
            else:
                self.action(action_key).setDisabled(False)

        if accesstools.check_permission_multi_or(("user.modify", "user.view"), False) == False:
            # No access to users allowed
            self.closeUserEdits(accesstools.check_permission("user.self.modify", False))

        if accesstools.check_permission_multi_or(("group.modify", "group.view"), False) == False:
            # No access to users allowed
            self.closeGroupEdits()

        if accesstools.check_permission("file.browse", False) == False:
            # No access to users allowed
            self.removeTabByWidget(self.filemanager)
    def editUser(self, uid):
        # Check if the user has propper permissions and present a nice message if not
        # This is ofcourse also checked on the server side.
        may_open = False
        if uid == cm.get_binded_user() and accesstools.check_permission("user.self.modify", False):
            may_open = True
        elif accesstools.check_permission_multi_or(("user.modify", "user.view")):
            may_open = True

        if may_open == False:
            return

        if self.useredits.has_key(uid):
            self.tabwidget.setCurrentWidget(self.useredits[uid])
            return
        import usereditwdg as usered

        useredit = usered.UserEditWdg(uid, self.tabwidget)
        self.useredits[useredit] = uid
        self.useredits[uid] = useredit
        tab_title = useredit.led_firstname.text() + " " + useredit.led_lastname.text()

        usericon = paths.path_to("art/student.svg")
        if os.path.exists(paths.path_to("art/%s.svg") % userdef.usertype_as_text(useredit.user_info["usertype_id"])):
            usericon = paths.path_to("art/%s.svg") % userdef.usertype_as_text(useredit.user_info["usertype_id"])
        self.tabwidget.addTab(useredit, QtGui.QIcon(qt4tools.svg2pixmap(usericon, 32, 32)), tab_title)
        self.tabwidget.setCurrentWidget(useredit)
	def editMemberships(self):
		# Check if the user has propper permissions and present a nice message if not
		# This is ofcourse also checked on the server side.
		if not accesstools.check_permission_multi_or(('membership.create','membership.remove')):
			return

		mimedata = self.groupmodel.generateMimeData(self.trv_grouplist.selectedIndexes())
		groups = pickle.loads(mimedata['application/x-skolesysgroups-pyobj'])
		if not len(groups):
			# No users selected
			return
		
		import addremovegroupuserswdg as memberships
		m = memberships.AddRemoveGroupUsersWdg(groups,self)
		m.exec_()
    def editGroup(self, groupname, displayed_name):
        # Check if the user has propper permissions and present a nice message if not
        # This is ofcourse also checked on the server side.
        if not accesstools.check_permission_multi_or(("group.modify", "group.view")):
            return
        if self.groupedits.has_key(groupname):
            self.tabwidget.setCurrentWidget(self.groupedits[groupname])
            return
        import groupeditwdg as grouped

        groupedit = grouped.GroupEditWdg(groupname, self.tabwidget)
        self.groupedits[groupedit] = groupname
        self.groupedits[groupname] = groupedit
        tab_title = QtCore.QString.fromUtf8(
            displayed_name
        )  # groupedit.led_firstname.text()+" "+groupedit.led_lastname.text()
        self.tabwidget.addTab(
            groupedit, QtGui.QIcon(qt4tools.svg2pixmap(paths.path_to("art/group.svg"), 16, 16)), tab_title
        )
        self.tabwidget.setCurrentWidget(groupedit)