Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Reza Vafatabar
Subscribing to a blog entry
November 6, 2012 6:50 PM
Answer

Reza Vafatabar

Rank: New Member

Posts: 4

Join Date: September 20, 2012

Recent Posts

Hi all,

I want to subscribe a user in to a specific blog.
I found this code from Liferay source:
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
BlogsEntryLocalServiceUtil.subscribe(user.getUserId(), themeDisplay.getScopeGroupId());

but it doesn't solve my problem because it subscribe user to the current theme.
What I have is the blog Id and the User Id.

How can I get the scope group id of the blog by just having the blog Id or BlogEntry object?
Pavel Savinov
RE: Subscribing to a blog entry
November 6, 2012 10:52 PM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

Hi.

You can use getGroupId() of your BlogsEntry object.
1BlogsEntry blogsEntry; /* your blog entry object */
2BlogsEntryLocalServiceUtil.subscribe(user.getUserId(), blogEntry.getGroupId());
Ketan Patel
RE: Subscribing to a blog entry
November 6, 2012 11:31 PM
Answer

Ketan Patel

Rank: Junior Member

Posts: 70

Join Date: May 4, 2012

Recent Posts

Hi!

As per my knowledge and understanding there is nothing like a Scope Group Id of blog.

you can get the blog group id through blogEntry.getGroupId();

themeDisplay.getScopeGroupId(); returns the id of the group the page you are viewing is in. it should be the same as themeDisplay.getLayout().getGroupId()

Thanks,
Ketan
Reza Vafatabar
RE: Subscribing to a blog entry
November 6, 2012 11:56 PM
Answer

Reza Vafatabar

Rank: New Member

Posts: 4

Join Date: September 20, 2012

Recent Posts

Thanks for the replies guys.

Ketan:
I tried this solution with no luck.
I think the problem is that I want to subscribe another user to the blog and not the current user.

I want to write a portlet which admin can use to subscribe other users to the blog.
So if I use ThemeDisplay, it will give me the scope of the admin and not other users.

Pavel:
I tried your solution as well and it works with no error but other users ( who has been subscribed to the blog using this portlet by admin ) haven't received a subscribe email and when they login the "Subscribe" link in the blog still there and didn't change to "Unsubscribe"

I really need to resolve this issue so please help!

Reza
Pavel Savinov
RE: Subscribing to a blog entry
November 7, 2012 12:58 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

Do you mean that when you´ve invoked subscribe method for one user all other users were unsubscribed?
Reza Vafatabar
RE: Subscribing to a blog entry
November 7, 2012 1:26 AM
Answer

Reza Vafatabar

Rank: New Member

Posts: 4

Join Date: September 20, 2012

Recent Posts

No, I just mean that invoking this method doesn't subscribe the user to the blog.

Admin is invoking the portlet ( method ) in the control panel to subscribing another user ( user A not himself ) to a blog.
but it doesn't do the job.
Reza Vafatabar
RE: Subscribing to a blog entry
November 8, 2012 6:33 PM
Answer

Reza Vafatabar

Rank: New Member

Posts: 4

Join Date: September 20, 2012

Recent Posts

Please give me a solution on this?
Pawel Kruszewski
RE: Subscribing to a blog entry
July 8, 2014 11:22 AM
Answer

Pawel Kruszewski

Rank: New Member

Posts: 3

Join Date: April 9, 2009

Recent Posts

Hi there,

for other users that were looking for a good solution like me:
1
2        SubscriptionLocalServiceUtil.addSubscription(
3                userId,
4                groupId,
5                BlogsEntry.class.getName(),
6                groupId);


groupId - is a groupId of a Site where you want your user to be subscribed to blogs.

Greets,
Pawel