0

I want to get the following article setup to work on one of my Joomla 3 sites: - Users of the user group A can create, view and edit only their own artile(s) - Users of the user group B can create, view and edit their own article(s) as well as the articles from the **user group A

I found a solution suitable for Joomla 2.5, but I can't seem to get it to work on my Joomla 3 site: Allow Users to View ONLY articles they Author - the reply from "rcarey"

I checked Joomla 3's ACL tutorial as well, but couldn't find anything usefull for my issue.

Is there any way how to solve this please?

Thanks for any ideas/hints.

1 Answer 1

0

No way doing so without coding.

But if you know a little bit about how Joomla works, or just google for it you can use this plugin to create override of specific Joomla core method without modifying the core itself.

What you want to do here is override articles getListQuery() to something like:

class ContentModelArticles extends ContentModelArticlesBase
{
    protected function getListQuery(){
        $db = JFactory::getDbo();
        $query = parent::getListQuery();

        /*
         * $group that can see all the posts
         */
        $group = 10;
        if(!in_array($group,JFactory::getUser()->getAuthorisedGroups())){
            $query->where($db->qn('created_by').' = '.$db->q(JFactory::getUser()->id));
        }
        return $query;
    }
}

That will do it.

6
  • Hi Alexandr, thanks for your quick reply - much appreciated. The implementation of a custom plugin is something I haven't really done before. I played with (hacked..:) ) some of the core .php files before, did some overrides as well. And that's why I rather like to use an override (using your plugin ) than to modify the core files. My PHP knowledge is really on a noob level, so here's my noob question: Should I replace the public function onAfterRoute() with the protected function getListQuery() in your plugin's code? Thanks again for any advice
    – AnDrej_B
    Apr 17, 2017 at 11:08
  • No, I've updated example at github.com/alex7r/overrideany/blob/master/README.md#example But in a few words: you should change initial and target file. And place proper class definition (see example) and your function protected function getListQuery() to the target file. If you still face issues, you can create an issue at github, it will be more handy to solve coding problems there. )
    – Alexandr
    Apr 17, 2017 at 14:12
  • Thanks. I'll give it a go and will reach out to you on github if needed. And post my finding here afterwards, of course - for the fellow struggling DEVs...:)
    – AnDrej_B
    Apr 18, 2017 at 14:07
  • Hello Alexandr, I added a new issue on your plugin's Github page - fyi.
    – AnDrej_B
    Apr 25, 2017 at 14:12
  • Just updated the issue and provided code of solution
    – Alexandr
    Apr 28, 2017 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.