how to avoid an author can modify his article

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

how to avoid an author can modify his article

Post by newart » Sun Oct 21, 2007 12:23 pm

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!  :)
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: how to avoid an author can modify his article

Post by Opie » Sun Oct 21, 2007 6:10 pm

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.
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: how to avoid an author can modify his article

Post by newart » Mon Oct 22, 2007 7:59 pm

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?  ;)
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: how to avoid an author can modify his article

Post by Opie » Mon Oct 22, 2007 8:07 pm

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;
      }
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: how to avoid an author can modify his article

Post by newart » Mon Oct 22, 2007 8:29 pm

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)...
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: how to avoid an author can modify his article

Post by Opie » Mon Oct 22, 2007 8:33 pm

I knew there was a table that explained each level.  I just couldn't remember which one.
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: how to avoid an author can modify his article

Post by newart » Tue Oct 23, 2007 6:13 am

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.
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: how to avoid an author can modify his article

Post by Opie » Tue Oct 23, 2007 1:17 pm

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;
      }
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: how to avoid an author can modify his article

Post by newart » Tue Oct 23, 2007 5:34 pm

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!
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com

User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: how to avoid an author can modify his article

Post by newart » Tue Oct 23, 2007 6:22 pm

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!  :)
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: how to avoid an author can modify his article

Post by Opie » Tue Oct 23, 2007 6:28 pm

I forgot to change the 'gid' number :-[  You might check 'gid' number you first used.
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: how to avoid an author can modify his article

Post by newart » Wed Oct 24, 2007 11:02 am

yesterday used by 20 too - it was the same
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: how to avoid an author can modify his article

Post by Opie » Wed Oct 24, 2007 1:18 pm

newart wrote:yesterday used by 20 too - it was the same
As long as your satisfied, then that is all that matters. ;)

Good luck.
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
newart
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 216
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: how to avoid an author can modify his article

Post by newart » Wed Oct 24, 2007 4:13 pm

yep thanx  :D you're great!
former Q&T WorkGroup Joomla member - Italian Translation Team Member
http://www.eon-project.com


Post Reply