Page 1 of 1

how to avoid an author can modify his article

Posted: Sun Oct 21, 2007 12:23 pm
by newart
In the new 1.5 joomla I'd like to have authors that cannot modify any article.

How-to-do?

Normally I use the standard joomla but in this case I have to hack, sorry... well, What part of the line code I have to hack?

Thanks in advance for your help!  :)

Re: how to avoid an author can modify his article

Posted: Sun Oct 21, 2007 6:10 pm
by Opie
Just a thought and I'm not certain it is plausible.  Could you limit the editing via the templates to editors and above?  I'm also not certain how this would be accomplished.

Re: how to avoid an author can modify his article

Posted: Mon Oct 22, 2007 7:59 pm
by newart
by logic you can simply delete the modify icons in such a way that you cannot see a link for modifying an article but in this case you have to think that all guests cannot do anything...  :-\ or simply you have to hack that icon link to be viewable only for up to authors level... but in this case the problem is, you cannot see it but you can do it -  :P I don't like that solution... and you?  ;)

Re: how to avoid an author can modify his article

Posted: Mon Oct 22, 2007 8:07 pm
by Opie
newart wrote:by logic you can simply delete the modify icons in such a way that you cannot see a link for modifying an article but in this case you have to think that all guests cannot do anything...  :-\ or simply you have to hack that icon link to be viewable only for up to authors level... but in this case the problem is, you cannot see it but you can do it -  :P I don't like that solution... and you?  ;)
I didn't say it was a great idea. ;)

How about this file components/com_content/views/article/view.html.php around line 170.  The number would probably need to be higher than 19.  There is probably a better solution.  Hopefully, someone else can point it out.

Code: Select all

      // Make sure you are logged in and have the necessary access rights
      if ($user->get('gid') < [b][color=red]19[/color][/b]) {
         JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
         return;
      }

Re: how to avoid an author can modify his article

Posted: Mon Oct 22, 2007 8:29 pm
by newart
yes, maybe a solution, here is the DB table of
jos_core_acl_aro_groups

id  parent_id  name  lft  rgt  value 
      17 0 ROOT 1 22 ROOT
      28 17 USERS 2 21 USERS
      29 28 Public Frontend 3 12 Public Frontend
      18 29 Registered 4 11 Registered
      19 18 Author 5 10 Author
      20 19 Editor 6 9 Editor
      21 20 Publisher 7 8 Publisher
      30 28 Public Backend 13 20 Public Backend
      23 30 Manager 14 19 Manager
      24 23 Administrator 15 18 Administrator
      25 24 Super Administrator 16 17 Super Administrator

in this case the GID numbers for authors is 19 (I hope is the right value)...

Re: how to avoid an author can modify his article

Posted: Mon Oct 22, 2007 8:33 pm
by Opie
I knew there was a table that explained each level.  I just couldn't remember which one.

Re: how to avoid an author can modify his article

Posted: Tue Oct 23, 2007 6:13 am
by newart
Thank you very much Opie!

what done and just tested: if ($user->get('gid') < gets 20
in this case the author can view the modify icon but cannot modify anything, linked to an error page: the 403 one for a denied access. The problem arising is that now he cannot insert any new article... I have the priority to avoid errors or problems when an author modifies something so the solution is to sacrifice the new article insert feature. I have no choise!

Thank you very much for your solution. Anyway if there are other tips or solutions please post here, I think that problem is a common one as long as joomla hasn't a good ACL.

Re: how to avoid an author can modify his article

Posted: Tue Oct 23, 2007 1:17 pm
by Opie
You might change the if statement I pointed to earlier to check the $article->id.  If it is greater than 0 it should already be an article, so you would want to exit out of the function.  Something like this may work:

Code: Select all

      // Make sure you are logged in and have the necessary access rights
      if ($user->get('gid') < 19 && $article->id > 0) {
         JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
         return;
      }

Re: how to avoid an author can modify his article

Posted: Tue Oct 23, 2007 5:34 pm
by newart
Opie wrote:You might change the if statement I pointed to earlier to check the $article->id.  If it is greater than 0 it should already be an article, so you would want to exit out of the function.  Something like this may work:

Code: Select all

      // Make sure you are logged in and have the necessary access rights
      if ($user->get('gid') < 19 && $article->id > 0) {
         JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
         return;
      }




good idea, tomorrow I'll test it!

Re: how to avoid an author can modify his article

Posted: Tue Oct 23, 2007 6:22 pm
by newart
I know I cannot wait for a minute - just tested but when you enter as an author all is working normally (setted gid at 20 or 19). So I deleted the new piece of code in favour of the first one.

Thank you very much for your idea anyway!  :)

Re: how to avoid an author can modify his article

Posted: Tue Oct 23, 2007 6:28 pm
by Opie
I forgot to change the 'gid' number :-[  You might check 'gid' number you first used.

Re: how to avoid an author can modify his article

Posted: Wed Oct 24, 2007 11:02 am
by newart
yesterday used by 20 too - it was the same

Re: how to avoid an author can modify his article

Posted: Wed Oct 24, 2007 1:18 pm
by Opie
newart wrote:yesterday used by 20 too - it was the same
As long as your satisfied, then that is all that matters. ;)

Good luck.

Re: how to avoid an author can modify his article

Posted: Wed Oct 24, 2007 4:13 pm
by newart
yep thanx  :D you're great!