Customize permissions for Site Administrator role in Life ray?
Asked Answered
I

2

3

I want to customize the Site Administrator Role permissions i.e, I need to enable a feature for creating the users for site administration under respective site. How can I achieve that? Do I need to achieve it with Hook OR need to create EXT? OR any other simpler way to achieve that? I need to enable the user creation and assign permission for Site Administrator under respective site. I don't want to crate users by Super admin.

Ignitron answered 2/3, 2015 at 15:18 Comment(0)
D
3

Maybe you can create a custom portlet, put it in control panel, in which only the Site Administrators, filling a form, can create users that you assign directly as members of current site.

PRO: I think you can achieve your task.

CON:

  • You have to spend time to develop, it's not a "solution in a few clicks".
  • It is not a Permissions customization.

References: "Beginning Liferay Development" It's a usefull guide that explain, using all Liferay best practice, how to develop a complete portlet, the "famous" KnowledgeBasePortlet. I suggest you to read it all, but the important points for your problem are:

  • Setting Permissions, to permit only to Site Administrator to create Users
  • Adding Portlet to Control Panel

NB: As you will see (Creating Entity Actions), the KnowledgeBasePortlet creates two custom Entities, you don't need to do it: the entities you need already exist. Use that chapter just to learn how call the methods to add/edit/delete that entities, you will have to do the same but with the User entity through the UserLocalServiceUtil.

Dynamism answered 9/3, 2015 at 13:56 Comment(3)
yes, I need references 1) From where do I need to start? 2) Can I achieve it with hooks / do I need to create new portlet ?Ignitron
I edited the answer, however you have not to create an hook, just a simple portlet.Dynamism
As you suggested I have created a portlet and add it to the control panel under "site_administration.users". Now how can it possible to import the create and edit user screens in to the portlet OR do I need to create the add and edit user screens? Any suggestion pleaseIgnitron
A
3

I'm not sure I'm understanding what you need (sorry, I try to hypotesize).

If you already have different websites and you need to create programmatically all site admin users (one shot), you need to create a portlet (and deploy it as control panel portlet). Your portlet should have just an interface to invoke a method... and your method just need to

If you prefer your portlet can expose this methos to Liferay not uy UI, but using Liferay cron job. You just need to add a declaration inside your liferay-portlet.xml pointing to your code: watch this simple guide

Differently, if you want an automatic way to add a user everytime you create a site by interface you can use an hook and override the entity creation event on DB. Websites are in Group table, so you can add a servlet.service.events.post Event Handler to a Service Event. There you can call your code: read this useful post

I hope it can be useful for you.

Alkahest answered 10/3, 2015 at 11:5 Comment(3)
What interface should I need to add in my portlet and how to invoke a method. Please help I am trying this from two days but no use. PleaseIgnitron
I don't want to create users programatically. I need to create from UI. I have created a portlet and deployed in contrl pane. The portlet have basic from with user details and with save button. On clicking of the save button the user details should need to save in existing user table. I have added a question in forum, liferay.com/community/forums/-/message_boards/message/51162704. Please help meIgnitron
As I wrote (and linked) in my reply, and as already suggested in the forum, you should use: UserLocalServiceUtil.addUser()Alkahest

© 2022 - 2024 — McMap. All rights reserved.