Jump to content


[Tutorial] Admin Permissions in MKPortal


1 reply to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 23 May 2006 - 01:47 AM

Forum Admin

$mkportals->member['g_access_cp'] is set in /mkportal/include/***/***_driverf.php. It is set according to which Forum group is the default Admin group.

For example in ipb_driverf.php you can see that the value for $mkportals->member['g_access_cp'] is set to "1". This is a global value.

if($mkportals->member['mgroup'] == 4) {
	$mkportals->member['g_access_cp'] = 1;
}
------------
Portal Admin

$mklib->member['g_access_cpa'] is a permissions value that corresponds to the "Can Manage MKPortal?" setting in Portal CP > Permissions. This is also a global value.

"$mklib->member['g_access_cpa']" is called in functions.php (function read_member). It reads the Portal permissions for each forum usergroup that are stored in the database table mkp_pgroups.

The default value of "$mklib->member['g_access_cpa']" for all usergroups is "0" except for Forum Admin which is blank '' since there is no mkp_pgroups database row for Forum Admin.


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#2 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 23 May 2006 - 01:50 AM

Usage Examples



Example: Show message to everyone except Forum and Portal Admins.
	if( !$mkportals->member['g_access_cp'] && !$mklib->member['g_access_cpa'] ) {
		$content = "Hello World!";
	}
This code says "if the user does not have permissions to access the Forum CP and the user does not have permissions to access the Portal CP then display the message "Hello World!". So everyone will see the message except Forum and Portal Admins. If you removed the code "&& !$mklib->member['g_access_cpa']" then the message would also display to Portal Admins."



Example: Conversely you can display a message only to Forum Admins with this code...
	if( $mkportals->member['g_access_cp'] ) {
		$content = "Hello World!";
	}
This code says "if the user does have permissions to access the Forum CP then display the message "Hello World!". So only Forum Admins will the message. If you used the code "$mklib->member['g_access_cpa']" instead of "$mkportals->member['g_access_cp']" then the message would only display to Portal Admins.


In these examples I only display the message "Hello World!" but you could perform any action in a similar way.


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users