Allowing another user to delete/unpublish posts

Phoca Guestbook - creating guestbooks in Joomla! CMS
mm_dancer
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 08 Sep 2012, 06:27

Allowing another user to delete/unpublish posts

Post by mm_dancer »

I would like to make another user able to delete or unpublish posts so they can help me monitor the guestbook. I tried setting this user to an administrator and even a super admin and neither made the delete/unpublish options appear. The only line of code I can find that deals with this is

Code: Select all

if ($this->tmpl['administrator'] != 0) {
			$gbPosts.='<a href="'.JRoute::_('index.php?option=com_phocaguestbook&view=phocaguestbook&id='.$this->id.'&Itemid='.JRequest::getVar('Itemid', 0, '', 'int').'&controller=phocaguestbook&task=delete&mid='.$values->id.'&limitstart='.$this->pagination->limitstart).'" onclick="return confirm(\''.JText::_( 'Delete Message' ).'\');">'.JHTML::_('image', 'components/com_phocaguestbook/assets/images/icon-trash.gif', JText::_( 'Delete' )).'</a>';
			
			$gbPosts.='<a href="'.JRoute::_('index.php?option=com_phocaguestbook&view=phocaguestbook&id='.$this->id.'&Itemid='.JRequest::getVar('Itemid', 0, '', 'int').'&controller=phocaguestbook&task=unpublish&mid='.$values->id.'&limitstart='.$this->pagination->limitstart).'">'.JHTML::_('image', 'components/com_phocaguestbook/assets/images/icon-unpublish.gif', JText::_( 'Unpublish' )).'</a>';
		}
I have very little exposure to php, but can usually make some sense of what is written. I can't figure out what the 'administrator' is referring to as setting another user to an admin did not help.

Ideally I'd like this user to be set as a Editor and be able to delete posts, while other users set as Authors cannot
Thanks,
mm_dancer
dip
Phoca Member
Phoca Member
Posts: 43
Joined: 09 Apr 2012, 16:33
Location: Russia

Re: Allowing another user to delete/unpublish posts

Post by dip »

Hi. I think you found components/com_phocaguestbook/views/guestbook/tmpl/views/guestbook/tmpl/default.php. But you can customize just 1 function in components/com_phocaguestbook/helpers/phocaguestbook.php
In code find "public function canAdmin()" and add new check.
"$user->usertype" return to you the role of the user. Just check it and return "true" if role is manager.
mm_dancer
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 08 Sep 2012, 06:27

Re: Allowing another user to delete/unpublish posts

Post by mm_dancer »

That line of code doesn't seem to appear in components/com_phocaguestbook/helpers/phocaguestbook.php

I tried going into components/com_phocaguestbook/controllers/phocaguestbook.php and changing
if (strtolower($user->usertype) == strtolower('super administrator') || strtolower($user->usertype) == strtolower('administrator'))
to:
if (strtolower($user->usertype) == strtolower('super administrator') || strtolower($user->usertype) == strtolower('administrator')|| strtolower($user->usertype) == strtolower('editor'))

but that doesn't work either
dip
Phoca Member
Phoca Member
Posts: 43
Joined: 09 Apr 2012, 16:33
Location: Russia

Re: Allowing another user to delete/unpublish posts

Post by dip »

What verson joomla and phoca gb in use?
Post Reply