Dynamically remove portlet when a user is not logged in in liferay 6.1? - liferay-6

I use the following code to add portlet in my jsp page:
themeDisplay.getLayoutTypePortlet().addPortletId(themeDisplay.getUserId (),portletId_1, "column-2", -1, false);
Then, in other jsp page, which in the same portlet (different from the one be removed above), I remove the portmetId_1 in the adding code above:
themeDisplay.getLayoutTypePortlet().removePortletId(themeDisplay.getUserId(), portletId);
Both the adding and removing portlet code worked fine if the user was logged in with the admin role (or any roles that have removing portlet rights). This is not what I wanted because my site is kind of news and users are not required to log in. If users are not logged in, or logged in with a normal user role, then the removing portlet code does not work at all.
How can I get the removing portlet code work without requiring users to log in with appropriate roles?

Related

AEM page properties dialog not showing the tabs for author users

In the AEM page trying to add a new tab for the page properties dialog. The new added elements are showing and those are working fine when I logged in as a administrator, but when I logged in a authoring user, in the page properties the newly added tab is showing as empty. Tried all other alternatives and checked the permissions too. Any help on this is really appreciated.
Give Read permission to content-authors group for etc/cloudservices, it will resolve this issue.

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');
}

AuthenticationHandler: sling always redirecting to gemotrix login page

I am implementing login functionality for my site using Custom AuthenticationHandler. When I give credentials and submit the form the AuthenticationHandler is always redirecting to geometrix site and asking geometrix credentials.
Even I tried deactivating geometrix in my author instance, after login into my site again it is redirecting to felix console site.
How to restrict other than my application pages ?
Any help is highly appreciable.
You can change your default login page from felix console
http://localhost:4503/system/console/configMgr
Configure Day CQ Login Selector Authentication Handler, set the default login page to the path of your custom login page
I guess the Day CQ Root Mapping servlet redirects you to it's configured rootmapping target.
Have at look at
/libs/cq/core/config.publish/com.day.cq.commons.servlets.RootMappingServlet
inside crxde.
The rootmapping servlet's config targets to /content.html which is resolved to /content. redirect that to your content or if it has to coexist, then create an additional JcrResourceResolverFactoryImpl config.
Just create a config.publish/org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl
node below your application in apps
/apps/<yourappp>/config.publish/org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl with jcr:primaryType sling:OsgiConfig and add a resource.resolver.mapping to your like the following samples demonstrates.
resource.resolver.mapping="[/-/,/content/intranet/-/intranet-/, ....]" />

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

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.

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.