Page 1 of 1

Administrator not authorized to publish messages?

Posted: 22 Jun 2010, 19:35
by leej22
Hello,

I modified Phoca Guestbook (v 1.4.1) as shown here: viewtopic.php?f=2&t=4033
so that posts could be published from front end (as well as unpublished/deleted) It looks great...however, when I log in front end with an administrator account I get message "You are not authorized to unpublish the item" or "You are not authorized to delete..etc"

However when I login with super administrator info (front end) I can publish/delete the posts. Course whole point here is to allow someone with only administrator access to handle publishing of posts in the guestbook. Any idea what I need to change? Not sure why administrator can't do this, I thought the codes from above thread allowed for administrator AND super administrator?

Thanks,

Emilee

Re: Administrator not authorized to publish messages?

Posted: 22 Jun 2010, 23:28
by leej22
I have realized the problem with this so here is fix, in case someone else runs into this again:

In this thread:
viewtopic.php?f=2&t=3864
Someone explains that the code....

Code: Select all

if (strtolower($user->usertype) == strtolower('super administrator') || $user->usertype == strtolower('administrator')) {
is wrong because the "$user->usertype" phrase is written incorrectly for administrator. Basically it has no strtolower() around it. It should say strtolower($user->usertype) == all thru (with the parentheses and strtolower in front).

These codes seem to missing all thru the guestbook, and its actually that way in the Documentation for Phoca Guestbook, under FAQs where they tell you how to make so other users can unpublish and delete the posts in the front end. I was wondering why that didn't work for me...it didn't even work for administrator let alone new users I was trying to add.

So in following places check for the if (strtolower($user->usertype) == etc. strings and modify...
components\com_phocaguestbook\views\phocaguestbook\view.html.php (SEE function display)
components\com_phocaguestbook\controllers\phocaguestbook.php (SEE function remove AND function unpublish)

Also here:
components\com_phocaguestbook\models\phocaguestbook.php (SEE function buildQuery AND function countItem)
But note the format there is different...its...

Code: Select all

    if ($user->usertype == "Super Administrator" || $user->usertype == "Administrator")
so just add the needed part like if you want to allow publishers to handle messages, it would be

Code: Select all

    if ($user->usertype == "Super Administrator" || $user->usertype == "Administrator" || $user->usertype == "Publisher")
And if you use this guide: viewtopic.php?f=2&t=4033
to allow users to also PUBLISH the messages from frontend... You have to change all those $user->usertype parts because they are incorrect in that guide also. :)

Emilee

Re: Administrator not authorized to publish messages?

Posted: 24 Jun 2010, 11:37
by Jan
Ok

Re: Administrator not authorized to publish messages?

Posted: 26 Jun 2010, 21:40
by Jan
It was fixed to:
if (strtolower($user->usertype) == strtolower('super administrator') || strtolower($user->usertype) == strtolower('administrator')) {
Should work now.