• customize folder permissions

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #4270  by blindrood
 
I would like to do simillar change described in http://forum.openkm.com/viewtopic.php?f=4&t=3072
but with folder permissions
I would like to allow to change folder permissions only for admin and author of this folder

So I found place where I Should do this
at TabFolder.java there is this code
Code: Select all
	public void setProperties(GWTFolder folder) {
		this.folder.set(folder);
		security.setPath(folder.getPath());
		security.GetGrands();
		if ((folder.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE) {
			security.setChangePermision(true);
		} else {
			security.setChangePermision(false);
		}
	}
as I understand I should change if statement to something like
Code: Select all
if(Main.get().workspaceUserProperties.getWorkspace().isAdmin() || something.isAuthor() )
but I didn't figure out what this 'something' should be
any help?


EDIT
ok so I found this
Code: Select all
if ( folder.getAuthor().compareTo(Main.get().workspaceUserProperties.getUser() == 0 || Main.get().workspaceUserProperties.getWorkspace().isAdmin() )
is that correct?
 #4273  by jllort
 
The security is controled in ToolBar.java not in TabFolder.java, all permissions are controled there.

The author ir right
Code: Select all
folder.getAuthor()
And if is in admin role too
Code: Select all
Main.get().workspaceUserProperties.getWorkspace().isAdmin()
Take a look all methods checkToolButtomPermissions ( folders, mails, documents, etc... ), here is the place where you must do the changes
Code: Select all
public void checkToolButtomPermissions(GWTFolder folder, GWTFolder folderParent, int originPanel)
In OpenKM we'll change it, adding more roles by default that will solve this problems.
 #4284  by blindrood
 
I'm trying to find where in this method I should change it but can't find.

I want to give permission of using Update button at security tab on folders for its author and admin
and i can't see where in checkToolButtomPermissions method i can do such change.
 #4289  by jllort
 
That's other question. Then you must take a look at Document.java class into package es.git.openkm.frontend.widget.properties

There's the button you're looking for.
 #4293  by blindrood
 
Actually I did some digging and I can't agree with You.

this button is created at SecurityScrollTable class

This class is never used at Document.java
But it is used at TabFolder.java (as I meant at first post) as object called 'security'

This button is activated using setEnabled method
which is used in setChangePermission method of SecurityScrollTable class
which is modified by SetProperties method of TabFolder class

so I changed code of SetProperties method to avoid giving access to this button for other users

I have to persist with my way and it actually works but I'm still not sure if it's not breaking any other code.

of course I might be wrong :) (or there is still some misunderstanding of my problem)
 #4300  by jllort
 
Upss I had I bad day when I wrote it :) really I might revise my own code and not use my memory by default , sorry.


1- You're right ( securityScrollTable is where's the button )

here there's two interesting methods
Code: Select all
	public void setVisibleButtons(boolean visible){
		button.setVisible(visible);
	}

and 

	public void setChangePermision(boolean permission) {
		button.setEnabled(permission);
	}
Don't worry for set visible is used to disable change permission is trash view for example.

In tabDocument is where you must make some changes if you want to change button to documents:
Code: Select all
if ((doc.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE && !doc.isCheckedOut() && !doc.isLocked()) {
			security.setChangePermision(true);
		} else {
			security.setChangePermision(false);
		}
here must be added in conditional the test if users is same as owner.

Must be something like this
Code: Select all
if (((doc.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE || 
			 Main.get().workspaceUserProperties.getUser().equals(doc.getAuthor()) ) 
			 && !doc.isCheckedOut() && !doc.isLocked()) {
			security.setChangePermision(true);
		} else {
			security.setChangePermision(false);
		}
The question is mantaining that when a node is checkout or locked can not be changed the permissions.

The tabFolder is similar to change button permission:
Code: Select all
if ((folder.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE) {
			security.setChangePermision(true);
		} else {
			security.setChangePermision(false);
		}
to
Code: Select all
if ((folder.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE || || 
			 Main.get().workspaceUserProperties.getUser().equals(folder.getAuthor()) {
			security.setChangePermision(true);
		} else {
			security.setChangePermision(false);
		}
In both change could be some problem if after creating folder or document write permissions to author are deleted. Simply OpenKM then when you'll try to change permission will fire some error.

Hope it help you
 #4342  by blindrood
 
Thanks for the code. It is working fine.

I'm still making more permission changes

I managed to enable remove/rename button only for Author and it works at mainmenu and topmenu but other users still have those rights by using contextmenu

How can I change the code for this?
 #4350  by jllort
 
This sure must be changed in ToolBar.java

In toolbar.java in concentrate the security evaluation. There are three methods ( folder, document, mail ), take look there specially where is assigned the enabledelete() and disabledelete()
 #4365  by blindrood
 
I can not find specific code for context menu at ToolBar.java
keyword 'enabledelete' appears only few times
once for folder (I made changes)
once for document (I made changes)
once for mail (I disabled mail as it is not useful, for now at least)
once for evaluateShowIcons (I'm not sure what id does yet)
and once for definition of this method

I just don't understand why it works for toolbar buttons but not for context menu
 #4367  by jllort
 
it's the same case.

You must modify folder, document or mail method in concordance to enable or disable button with your new security logic ( similar if case than other ).
 #4372  by jllort
 
OK for it you must edit TaxonomyMenu from package com.openkm.frontend.client.widget.taxonomy and take a look the method
Code: Select all
 public void checkMenuOptionPermissions(GWTFolder folder, GWTFolder folderParent) 
 #4378  by blindrood
 
Thanks for this information
I customized this method and context menu works correctly but only for folders
and as I can see, method for documents
Code: Select all
public void checkMenuOptionPermissions(GWTDocument doc, GWTFolder folder)
is empty ;-)
So now my question is: where is code for documents context menu? It surely works somehow :)


EDIT:
found it :D
es.git.openkm.frontend.client.widget.filebrowser.menu.TaxonomyMenu
Permissions works now as I wanted to :D
thankyou very much for help :)
 #4395  by jllort
 
There's other taxonomyMenu but in filebrowser package ( look for taxonomyMenu.java and you'll get two classes CTRL+SHIFT+R in eclipse )

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.