Page 1 of 1
[SOLVED] - Show form ONLY for admin and super-admin
Posted: 02 Oct 2011, 22:56
by zorta
Hi guys,
i'm looking for a solution to an issue.
i'm using joomla 1.5.23 with phocaguestbook 1.4.2 and i need to show form only for admin and super-admin. control panel only allows to see the form for all registered user (in other words, everyone except guest/anonymous).
i really don't know where put my hands!
best regards
Re: Show form ONLY for admin and super-admin
Posted: 04 Oct 2011, 18:10
by Morl99
Any particular reason to use 1.4.2 instead of 1.4.4.? You will have to change the code a bit to achieve what you want. The changes should be small, do you have any php/coding skills and the possibility to create a test/development-server to try it out? I will give you a hand if so...
Re: Show form ONLY for admin and super-admin
Posted: 04 Oct 2011, 23:42
by zorta
hi morl99,
thx for your reply.
why i'm using 1.4.2? i don't wanna update and encounter any risk of non-working module. as i ever say "when a thing is working, don't touch it!"
btw, i've a server for testing (local too), and i'm a specialized in php programming. but i dont' know where is the code of interest.
i'll appreciate your help and i'm really thank you.
tell me what to do!
Re: Show form ONLY for admin and super-admin
Posted: 05 Oct 2011, 12:43
by Morl99
I am not suggesting to perform a major update of joomla, just catch up with the latest stable for your joomla release, which is the 1.4.4. A reason for not doing this, is if you already have a different hack in place... But updating will be harder after we are finished with this hack...
If you are an experienced php programmer, you will probably have an easy time changing this.
The form display is controlled here: views/phocaguestbook/tmpl/default.php at about line 217 there is a
Code: Select all
if ($this->tmpl['show_form'] == 1) {
you could check if the user is admin or sa (see
here for reference)
Jan already uses a check for admin (or maybe only superadmin, I am not sure right now, I know I hacked this once...) at line 198
Code: Select all
if ($this->tmpl['administrator'] != 0)
That var should be > 0 if the user is an admin.
Hope this was helpful, if you run into trouble, feel free to describe your problems here.
edit:
I checked it, and I was right, it is super admin and admin, in the view.html.php it is written:
Code: Select all
$tmpl['administrator'] = 0;
if (strtolower($user->usertype) == strtolower('super administrator') ||
strtolower($user->usertype) == strtolower('administrator')) {
$tmpl['administrator'] = 1;
}
Re: Show form ONLY for admin and super-admin
Posted: 05 Oct 2011, 14:00
by zorta
works fine!!!!!
thank you mate, your advice has been invaluable!
this is the fix i've made:
[joomla! 1.5.23 - phoca guestbook 1.4.2]
file: components/com_phocaguestbook/views/phocaguestbook/tmpl/default.php at line 210 about:
before
Code: Select all
if ($this->tmpl['show_form'] == 1)
display form for everyone (except guest)
after
Code: Select all
if ($this->tmpl['show_form'] == 1 && $this->tmpl['administrator'] > 0)
display form ONLY for admin and super-admin (var $this->tmpl['administrator'] is 1 when admin or s-admin)
i'll change discussion's title in SOLVED!
thank you again!
Re: [SOLVED] - Show form ONLY for admin and super-admin
Posted: 05 Oct 2011, 14:24
by Morl99
I am glad that this fix worked for you

You are welcome!