Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Q2A Core by

I've added a field to the posts table to have some questions only visibile to particular users. I need to find the proper way to modify queries retrieving all questions to never show those questions to user that should not see them. I tried to modify the method qa_db_posts_basic_selectspec since it is the one called to build question list (and i'd like to modify as litlle file as possible!) but I could not find how to add my WHERE clause without generating SQL errors...

Here's what I tried to add at the end of qa_db_posts_basic_selectspec :

$selectspec['source'].=" WHERE ISNULL(^posts.private_owner) ";

(where clause will get a bit more complicated than that, bus as long as this simple thing doesn't get through, it doesn't matter!)

Q2A version: 1.4.2

1 Answer

+1 vote
selected by
Best answer

If it's an option to migrate, Q2A 1.5 will make your life much easier, since you can use the qa_postmetas table for any extra information you want, and then wrap qa_db_posts_basic_selectspec(...) via a plugin override to join this meta information. You could probably do the whole thing via a plugin.

Thanks Gidreen! Migrating to Q2a 1.5 isn't an option at this point, but I could however put my information in another table and join  it if its easier then adding a specific WHERE clause to existing select specs. This would also make it easier I guess to move to 1.5 when we have the time to do so!
I think the postmeta table works much better than adding a new field... did you ever see the expert question plugin?  It does basically what I think you are looking for, though I'm not sure how efficient it is overall.
Yes, adding a JOIN ... ON ... clause to $selectspec['source'] is safer, since it won't interfere with the WHERE clauses added later on by other code.
Indeed! Thanks to all!