Code Help please

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
Noonster
Registered User
Posts: 37
Joined: Thu Jan 20, 2005 9:45 pm
Location: East Yorkshire, UK
Contact:

Code Help please

Post by Noonster » Mon Apr 11, 2005 8:26 pm

Code: Select all

	if ( $poster_id != ANONYMOUS )

	{
		if ( $userdata['user_level'] != ADMIN )
		{
			$poster_name = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $poster_id) . '"' . $style_color . '>' . $poster_name . '</a>';
		}
		else
		{
			$poster_name = '<a href="' . $phpbb_root_path . "admin/admin_users.$phpEx?mode=edit&" . POST_USERS_URL . "=" . $poster_id . "&sid=" . $userdata['session_id'] . '"' . $style_color . '>' . $poster_name . '</a>';

		}
	}
^^ The above code makes it so when an admin clicks a persons username from in the viewtopic it takes them to their profile in the admin panel.

I have the Junior admins mod installed so now junior admins can view profiles in the admin panel but NOT by clicking on a username like the admins can.

How would i edit the above code to allow junior admins (code is MAIN_MOD) to be able to click the username in the viewtopic like the admin can and it link to the admin panel??

Your help is much appreciated as always

Cheers
Darren

plbeane94
Registered User
Posts: 118
Joined: Thu Mar 31, 2005 1:04 am
Contact:

Re: Code Help please

Post by plbeane94 » Mon Apr 11, 2005 8:31 pm

Noonster wrote:

Code: Select all

	if ( $poster_id != ANONYMOUS )

	{
		if ( $userdata['user_level'] != ADMIN )
		{
			$poster_name = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $poster_id) . '"' . $style_color . '>' . $poster_name . '</a>';
		}
		else
		{
			$poster_name = '<a href="' . $phpbb_root_path . "admin/admin_users.$phpEx?mode=edit&" . POST_USERS_URL . "=" . $poster_id . "&sid=" . $userdata['session_id'] . '"' . $style_color . '>' . $poster_name . '</a>';

		}
	}
^^ The above code makes it so when an admin clicks a persons username from in the viewtopic it takes them to their profile in the admin panel.

I have the Junior admins mod installed so now junior admins can view profiles in the admin panel but NOT by clicking on a username like the admins can.

How would i edit the above code to allow junior admins (code is MAIN_MOD) to be able to click the username in the viewtopic like the admin can and it link to the admin panel??

Your help is much appreciated as always

Cheers
Darren

Code: Select all

	if ( $poster_id != ANONYMOUS )

	{
		if ( $userdata['user_level'] != ADMIN, JUNIOR ADMINS )
		{
			$poster_name = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $poster_id) . '"' . $style_color . '>' . $poster_name . '</a>';
		}
		else
		{
			$poster_name = '<a href="' . $phpbb_root_path . "admin/admin_users.$phpEx?mode=edit&" . POST_USERS_URL . "=" . $poster_id . "&sid=" . $userdata['session_id'] . '"' . $style_color . '>' . $poster_name . '</a>';

		}
	}
That MIGHT just do it, I'm not 100% sure, so ask another person if it's right before you change it. I don't wanna screw up your forum.

Noonster
Registered User
Posts: 37
Joined: Thu Jan 20, 2005 9:45 pm
Location: East Yorkshire, UK
Contact:

Post by Noonster » Mon Apr 11, 2005 8:39 pm

Thanks for trying mate but unfortunatly that didnt work....
From what i can see you only changed this line

Code: Select all

if ( $userdata['user_level'] != ADMIN, JUNIOR ADMINS )
I even tried editing it to read

Code: Select all

if ( $userdata['user_level'] != ADMIN, MAIN_MOD )
But neither of the above worked.

Thanks again for trying
- Hopefully somone will have the answer.

Cheers
Darren

Noonster
Registered User
Posts: 37
Joined: Thu Jan 20, 2005 9:45 pm
Location: East Yorkshire, UK
Contact:

Post by Noonster » Tue Apr 12, 2005 9:33 am

Anyone ??

Thanks
Darren

espicom
Registered User
Posts: 17905
Joined: Wed Dec 22, 2004 1:14 am
Location: Woodstock, IL

Post by espicom » Tue Apr 12, 2005 3:38 pm

I have the Junior admins mod installed


And, as such, your question should be asked of the people who came up with that MOD, since it pertains entirely to it.
Jeff
Fixing 1016/1030/1034 Errors | (obsolete link) | MySQL 4.1/5.x Client Error | phpBBv2 Logo in ACP
Support requests via PM are ignored!
"To be fully alive is to feel that everything is possible." - Eric Hoffer

arod-1
Registered User
Posts: 1327
Joined: Mon Sep 20, 2004 1:33 pm

php

Post by arod-1 » Tue Apr 12, 2005 3:51 pm

this snipett:

Code: Select all

 if ( $userdata['user_level'] != ADMIN, JUNIOR ADMINS ) 
is syntactically wrong for php. i am not familiar with this specific mod, but a correct php syntax will read something like:

Code: Select all

 if ( $userdata['user_level'] != ADMIN && $userdata['user_level'] != JUNIOR_ADMIN) 
or something like (a little more pleasing aesthetically):

Code: Select all

switch ($userdata['user_level']) {
    case ADMIN:
    case JUNIOR_ADMIN:
// do the admin thing here
        break;
    default:
// do the not-admin thing here
}
(the 2 above snippets assume the meta-value is "JUNIOR_ADMIN". as i said, i dont have the mod myself, so you have to put the correct value there...)

the most pleasing form will look something like:

Code: Select all

if (is_admin($userdata) {
} else {
}
and then write a nice little function that checks to see whether a user is an admin.

Noonster
Registered User
Posts: 37
Joined: Thu Jan 20, 2005 9:45 pm
Location: East Yorkshire, UK
Contact:

Post by Noonster » Wed Apr 13, 2005 7:52 am

Thanks for the help above
- I will look into it when i get home tonight.

Noonster
Registered User
Posts: 37
Joined: Thu Jan 20, 2005 9:45 pm
Location: East Yorkshire, UK
Contact:

Re: php

Post by Noonster » Wed Apr 13, 2005 12:08 pm

arod-1 wrote:

Code: Select all

 if ( $userdata['user_level'] != ADMIN && $userdata['user_level'] != JUNIOR_ADMIN) 


Brilliant i just used that but put MAIN_MOD instead of JUNIOR_ADMIN as thats the code for it and it works.

Fantastic :D
Thanks alot for that.

Cheers
Darren

Locked

Return to “2.0.x Support Forum”