<?php
define('THIS_SCRIPT', 'boardpermission');
require_once 'global.php';
$lang = load_lang($lang, 'boardpermission' );

if ($action == 'myinfo'){
	$gettitle = $lang['strings1'];
}else{
	$gettitle = $lang['strings2'];
}
$stats = $gettitle;

if ($boardid == 0){
	$arrNavMenu = array(
		0=>array('linktitle'=>$gettitle,'linkurl'=>'')
	);
	head(1,0,0,$arrNavMenu);
}else{
	head();
}

if ($action != 'myinfo' && $userid !=0){
	if($groupsetting == 0 && $master == false){
		showmsg($lang['strings3']);
	}
}
if ($orders == '' || !is_numeric($orders)){
	$orders = 1;
}
$myper_1 = $myper_2 = $myper_3 = false;

if ($action == 'myinfo'){
	$query=$db->query("Select uc_userid,uc_setting From {$dv}useraccess Where uc_boardid='$boardid' And uc_userid='$userid'");
	if ($groups = $db->fetch_array($query)){
		$myper_1 = true;
		$groupname[0] = $lang['strings4'];
		$groupsetting[0] = $groups['uc_setting'];
	}
	if ($myper_1 == false){
		$query=$db->query("Select pid,psetting From {$dv}boardpermission Where boardid='$boardid' and groupid='$usergroupid'");
		if ($groups = $db->fetch_array($query)){
			$myper_2 = true;
			$groupname[0] = $lang['strings5'];
			$groupsetting[0] = $groups['psetting'];
		}
	}
	if ($myper_1 == false || $myper_2 == false){
		$query=$db->query("Select usergroupid,groupsetting,usertitle From {$dv}usergroups Where usergroupid='$usergroupid'");
		if ($groups = $db->fetch_array($query)){
			$myper_3 = true;
			$groupname[0] = $groups['usertitle'].$lang['strings6'];
			$groupsetting[0] = $groups['groupsetting'];
		}
	}
}else{
	$query=$db->query("select usergroupid,title,usertitle,groupsetting,orders,minarticle,titlepic,grouppic,parentgid,issetting from {$dv}usergroups order by usergroupid");
	$i = 0;
	while($groups = $db->fetch_array($query)){
		$groupname[$i] = $groups['usertitle'];
		$myquery=$db->query("select pid,boardid,groupid,psetting from {$dv}boardpermission where boardid='$boardid' and groupid='$groups[usergroupid]'");
		if ($mygroups = $db->fetch_array($myquery)){
			$groupsetting[$i] = $mygroups['psetting'];
		}else{
			$groupsetting[$i] = $groups['groupsetting'];
		}
		$i++;
	}
}
function yesorno($thiskey){
	global $lang;
	if ($thiskey == 1){
		return $lang['tpl.str73'];
	}else{
		return "<font color=red>".$lang['tpl.str74']."</font>";
	}
}
require_once printout('boardpermission');
footer();
?>