I am working on getting a version of Serendipity 1.5-beta1 running which supports self registration of multiple users. I have already written or modified several plugins to do what I want, but I am stuck right now.
I'm having a hard time figuring out how to hook into the default display of Entires on the blog index page and have it only display entries by members of a specific Group.
Any pointers, insights, hints, or code snippets appreciated.
Thanks
Clint
help with plugin to display only posts by specific UserGroup
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: help with plugin to display only posts by specific UserGroup
Hi!
For that, you would need to add the specific ACL parts to the main SQL query. You could have a look at the entryproperties plugin, it does a similar query already to only displays entries for all groups that a user is member of on which he has read privileges on a blog entries' category.
You would need to write a SQL subquery/join that combines the blog entries on the authorid column, and filters out only those, that have a group membership that intersects with the authorgroups of the currently logged in user.
However, I personally wouldn't do it this way; I would try to create categories that match your usergroups, and then simply forward the user to the category overview page of his primary group membership. This way, you'd have proper read+write privileges of blog categories, and wouldn't need to write any SQL code...
HTH,
Garvin
For that, you would need to add the specific ACL parts to the main SQL query. You could have a look at the entryproperties plugin, it does a similar query already to only displays entries for all groups that a user is member of on which he has read privileges on a blog entries' category.
You would need to write a SQL subquery/join that combines the blog entries on the authorid column, and filters out only those, that have a group membership that intersects with the authorgroups of the currently logged in user.
However, I personally wouldn't do it this way; I would try to create categories that match your usergroups, and then simply forward the user to the category overview page of his primary group membership. This way, you'd have proper read+write privileges of blog categories, and wouldn't need to write any SQL code...
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: help with plugin to display only posts by specific UserGroup
Garvin,
Thanks for the info. What I want is for the blog index and subsequent pages to only feature posts by a specific group but anyone can see them. On our site any registered user will be able to have a blog but only a select group of bloggers will have their entries show up on the main page. It's somewhat reminiscent of how daily kos does things.
I agree, that I need a subquery/join, but I don't need to restrict viewing by the authorgroup of the current user. In the most basic sense I need to add something like this to the where clause of the default query.
I'm just not sure how to get that into the default query.
Regular user's posts will be accessible via links in sidebar plugins I have already written.
I won't need near the functionality of the entryproperties plugin, but I'll have a good look at it to see if I can find a chunk that will do what I need.
Thanks for the info. What I want is for the blog index and subsequent pages to only feature posts by a specific group but anyone can see them. On our site any registered user will be able to have a blog but only a select group of bloggers will have their entries show up on the main page. It's somewhat reminiscent of how daily kos does things.
.garvinhicking wrote:Hi!
You would need to write a SQL subquery/join that combines the blog entries on the authorid column, and filters out only those, that have a group membership that intersects with the authorgroups of the currently logged in user.
I agree, that I need a subquery/join, but I don't need to restrict viewing by the authorgroup of the current user. In the most basic sense I need to add something like this to the where clause of the default query.
Code: Select all
//very simplistic but the basic idea of what I want to do
where ... AND (serendipity_authorgroups.authorid = serendipity_entries.authorid AND serendipity_authorgroups.groupid = 5)
// 5 is the id of the group which will have it's posts featured.
Regular user's posts will be accessible via links in sidebar plugins I have already written.
I won't need near the functionality of the entryproperties plugin, but I'll have a good look at it to see if I can find a chunk that will do what I need.
Last edited by perlnerd on Tue Dec 08, 2009 2:47 pm, edited 1 time in total.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: help with plugin to display only posts by specific UserGroup
Hi!
Hm, in that case, I'd really suggest you make use of the existing category views to group entries. Making it based on usergroups is possible, but really a lot of work
So it would be easier to create a plugin that automatically selects a specific category for a blogposting, basted on the usergroup membership?!
As for the plugin, you need to hook into the event 'frontend_fetchentries' and add to $eventData['and']. That's a variable that holds a SQL string that is added to the "WHERE" part. Have a look into include/functions_entries.inc.php, serendipity_fetchEntries() where $cond is filled and used.
(The entryproperties plugin actually does it in a similar fashion, so that's a good plugin to look into for you, right now)
HTH,
Garvin
Hm, in that case, I'd really suggest you make use of the existing category views to group entries. Making it based on usergroups is possible, but really a lot of work
So it would be easier to create a plugin that automatically selects a specific category for a blogposting, basted on the usergroup membership?!
As for the plugin, you need to hook into the event 'frontend_fetchentries' and add to $eventData['and']. That's a variable that holds a SQL string that is added to the "WHERE" part. Have a look into include/functions_entries.inc.php, serendipity_fetchEntries() where $cond is filled and used.
(The entryproperties plugin actually does it in a similar fashion, so that's a good plugin to look into for you, right now)
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: help with plugin to display only posts by specific UserGroup
Thanks Garvin,
Ok, what I want to do is a little (a lot?) more difficult than I had anticipated. It looks like I could create a category that only the featured bloggers can write to, and then only display that category on the main index (using serendipity_event_startcat).
We weren't going to have categories on the blog, but one for the featured bloggers and one for everyone else would be fine. Is there a way to force a blog post to a specific category?
Clint
Ok, what I want to do is a little (a lot?) more difficult than I had anticipated. It looks like I could create a category that only the featured bloggers can write to, and then only display that category on the main index (using serendipity_event_startcat).
We weren't going to have categories on the blog, but one for the featured bloggers and one for everyone else would be fine. Is there a way to force a blog post to a specific category?
Clint
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: help with plugin to display only posts by specific UserGroup
Hi!
You could also hide the sidebar category plugin, and could edit the entries.tpl template to remove all references to categories, then all would appear as being not category related?
You can force a blog post to a category, have a look at the serendipity_event_entrycheck plugin. You could borrow from that code to make it fix a category to a specific one (i.e. dependant on the user author group).
HTH,
Garvin
You could also hide the sidebar category plugin, and could edit the entries.tpl template to remove all references to categories, then all would appear as being not category related?
You can force a blog post to a category, have a look at the serendipity_event_entrycheck plugin. You could borrow from that code to make it fix a category to a specific one (i.e. dependant on the user author group).
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: help with plugin to display only posts by specific UserGroup
Yes, exactly. Now that I think about it this is definitely the way to go. Serendipity is so powerful, that it was making this more difficult than it needed to be. Thanks so much for the nudge in the right direction.garvinhicking wrote:You could also hide the sidebar category plugin, and could edit the entries.tpl template to remove all references to categories, then all would appear as being not category related?
I'll have a look at that plugin. I think I'll just have the regular users not have any category and the special users will have the option of choosing their special category or none at all.garvinhicking wrote:You can force a blog post to a category, have a look at the serendipity_event_entrycheck plugin. You could borrow from that code to make it fix a category to a specific one (i.e. dependant on the user author group).
Thanks again.
Clint
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: help with plugin to display only posts by specific UserGroup
Hi!
No problem, I'm glad that the category solution seems a doable approach to be. If you face any trouble with that route, let me know, and we'll try to work out the kinks together.
Best regards,
Garvin
No problem, I'm glad that the category solution seems a doable approach to be. If you face any trouble with that route, let me know, and we'll try to work out the kinks together.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/