Liferay: Role that can add web content only in certain pages of the site - liferay-6

Is it posible to define a role which can only create/read/update/delete web content in certain pages of the site? For example the role "NewsContent" can only add web content to the news page (and it's subpages).
I couldn't achieve this so far since I don't see anything like this in when adding permissions to a role. I can set the "Add web content" permission to a role but with this permission the users with this role will be able to add web content in all the pages of the site.
I hope that this is posible since this feature is very important for my application.
Thanks in advance!

Do you have Portlets in your application? If so, below solution which is for JSF based portlets can be of help.
As per my understanding "NewsContent" role can only add web content to the news page. So, I guess you have a Portlet which displays news page. In this case, get the role of the user from Liferay DB.
FacesContext context = FacesContext.getCurrentInstance();
javax.faces.context.ExternalContext externalContext = context.getExternalContext();
if(externalContext.isUserInRole("NewsContent"))
{
//Allow this user to do what you want him to do
}
If you are not using JSF based Portlets, you can still make a query to Liferay DB and get the role of the user logged in by querying in USER_, USERS_ROLES and ROLE_ tables.

Go in Control-Panel=>Roles
Select particular role in which you assign the user
select define permission for that role
select site administration
Enable only Manage pages checkbox in site
Now user with that particular role is able to ad web content on a page.
This will resolve your issue.

Related

tiki-wiki: how do i force newly created pages into a category based on the user's group?

I need for certain users to only be able to create pages in certain categories based on their permissions. One reason for this is approvals ("flagged revisions"). If a user can create content outside of any category, then it could show up live on the web site. Even thought it wouldn't initially be linked anywhere directly in an existing page (except other unapproved pages) this can still be a problem.
I can prevent the user from creating a new page in the global scope (apparently this corresponds simply to "edit" permissions as I don't see a special permission for creating new pages), and then I can grant them permission to edit pages in the category their group is authorized to edit. But I can no longer see the "Menu:Wiki:Create a Wiki Page" option, and I can't figure out how to allow the user to create a new page in that category.
I can edit the group and set the "Default category assigned to uncategorized objects edited by a user with this default group" to the desired category. When I do that, a user in that group now has a "Create a Wiki Page" option show up in the Menu:Wiki sub-menu, but clicking on that does not bring up a new page for editing; instead if just brings up a list of existing wiki pages, without the option to create a new one!
If I create a link to the new page from an existing page, I am unable to edit it in any way. Clicking the link takes me to a page which indicates that the page does not exist, but which does not provide any way to edit it. Putting the title of the page directly in the URL, as in tiki-editpage.php?page=New+Page+Name brings up a "You do not have permission to edit this page" error page. Since any new page created by the user should have the category they have permission to edit, this does not make sense unless the category isn't set until after the initial edit permission check occurs, which creates a catch-22!
How do I let the user create a new page in any of the categories they have permissions to edit in?
If Categories are not the best tool for the task that's okay too. I don't really understand the difference between Categories and Structures with regards to which is better for what I'm trying to accomplish, however it seems Categories are the more "native" feature, which is why I am trying to use them.

How to hide a page based on the logged-in user in CQ5?

I want to hide a page in navigation component based on the logged in user. I have two approaches in mind. Set permissions on the page's node in CRX-DE; denying it for all users; and then allowing it for specific groups. I have been trying it; not found much success. Else; I can get the id of the logged in user in the jsp and based on the user group; I can set the page's property 'Hide in Navigation' . But I am not able to find how to set that property in jsp. Please suggest.
Edit:
I am using the default authentication.I wanted to hide a page from navigation in the default 'list' component. If I use CUG; the users belonging to that group will still be able to see that particular page's link in the list component; and would be asked for login on clicking on that page.I want the link itself to be hidden if the user belonged to a particular group
Thanks.
If you are using the default authentication features in AEM (like Geometrixx), which rely on users that exist in AEM, you can use Closed User Groups. CUG allows you to set what users or groups can or cannot see a specific page. You can see where to set CUGs in the page properties dialog for each page. I'm pretty sure CUG settings inherit down the page hierarchy as well.
Using the JCR permissions for this is a good deal more complex, because it's such a low-level architectural thing. However, for more complex solutions, sometimes it's a necessary part of the equation.
I agree with ryanluka that going for JCR permissions should be avoided when the problem can be solved by much simpler approach. I modified the list.jsp of the default list component. Extracted the login user's id using Userpropertiesutil; and based on the group; wrote the code in jQuery to remove that particular page's div from list component.

Administrator has no admin bar for specific pages

I have an issue with a dotnetnuke 7 site, where the administrator cannot edit a minority of the pages.
When logged in and on such a page, the edit page menu missing.
When on the page management view, there are only options to view or make homepage. On clicking, properties are not shown.
What could be causing this?
Cheers, mark
I've seen in the past where the Administrator Role Id is incorrectly defined in the database.
Unfortunately there isn't a UI way to change this, you'll need to go into the DB to see what Role ID is defined. I believe AdministratorRoleID is stored either in the Portals table, or in the PortalSettings or PortalLocalization table. Check the # and see if that matches the ID of the Administrators role for that portal.
It could also be a CSS issue if it only affects some pages. Can you try changing the skin on those pages to the default skin and try again...
Just noticed this old question, so I thought that I'd update with what the actual problem was.
We imported pages using a direct to database program - we naturally assumed that the site administrator could, as a default be able to edit pages within their own site.
As it turns out, DNN actually creates correct access rights to each page as they are created, and rights are added and removed as required. This means that if you create pages you must directly create access rights for the correct site administrator.
Kind Regards, Mark, IA

How to dynamically hide/remove some menus from navigation?

I'm working on a wordpress plugin which inserts some pages using wp_insert_post() on activation. These pages are then used for different purposes (user account dashboard, edit account info, change password, login, logout, etc...).
Issue is all these pages get some menus which are displayed to all frontend users which is not correct because a non logged-in user for example should not see logout menu or any menu to a private page until authenticated. Now, I'm stucked at how to do just that. Any idea ?
I stress that the plugin login process is seperated from WP login
Wordpress can not assign restrictions and roles to specific pages, posts or terms by default.
You could create two separated menues and add a custom logic to your template.
if(is_user_logged_in())
{
wp_nav_menu('foo');
}
else
{
wp_nav_menu('bar');
}

Expressionengine 2 Login screen on Front Page

I would like to create a login screen for registered members on front page of the site without using members module. As I can see I can create a member and assign login credentials at back-end ( I don't have member module). Basically the idea is:
visiting: www.domain.com will give you login screen. When logged in it will redirect you or open new page.
I'm not looking to buy a module or extension. If something already exist I will be happy to use it.
Can anyone help?
You "don't have the members module"? How is that possible - it comes with the default install! So, something does already exist - it's called the Login Form tag.
So is the question how to create a login form on the front end of the site, or how to keep non-logged in users from viewing a specific template?
If it's the latter you can set access privileges at the template level. Look for the "Access" link by each template in the Template Manager, click that and you'll see your member groups and an option for what template to display if they aren't logged in. Typically that's a login template using the Login Form tags mentioned earlier.