Page 1 of 1

Code Help please

Posted: Mon Apr 11, 2005 8:26 pm
by Noonster

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

Re: Code Help please

Posted: Mon Apr 11, 2005 8:31 pm
by plbeane94
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.

Posted: Mon Apr 11, 2005 8:39 pm
by Noonster
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

Posted: Tue Apr 12, 2005 9:33 am
by Noonster
Anyone ??

Thanks
Darren

Posted: Tue Apr 12, 2005 3:38 pm
by espicom
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.

php

Posted: Tue Apr 12, 2005 3:51 pm
by arod-1
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.

Posted: Wed Apr 13, 2005 7:52 am
by Noonster
Thanks for the help above
- I will look into it when i get home tonight.

Re: php

Posted: Wed Apr 13, 2005 12:08 pm
by Noonster
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