Location: PHPKode > projects > @1 File Store > control/folders/index.php
<?
require_once("const.php");

$SQL="SELECT `".DB_PREFIX."folders`.* FROM `".DB_PREFIX."folders`";
if(!$mysql->query($SQL)) { exit($mysql->error); }
$flist=array();
while(!$mysql->EOF) {
	$flist[$mysql->field('id')]=$mysql->arr;
	$mysql->movenext();
}

$flist2 = $flist;
$grps = array();
foreach ($flist as $kflist => $vflist) {
	$fid = $vflist['id'];
	$SQL2="SELECT id, folder_id, group_id FROM `".DB_PREFIX."access_list` WHERE folder_id='".$fid."'";
	if(!$mysql->query($SQL2)) { exit($mysql->error); }
	while(!$mysql->EOF) {
		$grps[]=$mysql->arr;
		$mysql->movenext();
	}
}

foreach ($flist2 as $kflist2 => $vflist2) {
	foreach ($grps as $kgrps => $vgrps) {
		if ($vgrps['folder_id'] == $vflist2['id']) {
			$flist[$kflist2]['grp_id']=$vgrps['group_id'];
		}
	}
}

$flist3 = $flist;
$flist2 = $flist;
foreach ($flist2 as $kflist2 => $vflist2) {
	if (isset($vflist2['grp_id'])) {
		if ($vflist2['admin_only']=='Y') {
			$flist[$kflist2]['grp_id'] = '-1';
		}
	}
}

$flist2 = $flist;
foreach ($flist2 as $kflist2 => $vflist2) {
	if (!isset($vflist2['grp_id'])) {
		if ($vflist2['admin_only']=='N') {
			$flist[$kflist2]['grp_id'] = '0';
		}
	}
}

$flist2 = $flist;
foreach ($flist2 as $kflist2 => $vflist2) {
	if (!isset($vflist2['grp_id'])) {
		if ($vflist2['admin_only']=='Y') {
			$flist[$kflist2]['grp_id'] = '-2';
		}
	}
}

$flist3 = $flist;
$grpids = array();
foreach ($flist3 as $kflist3 => $vflist3) {
	$grpid = $vflist3['id'];
	$sqlgrpid="SELECT * FROM `".DB_PREFIX."access_list` WHERE folder_id='".$grpid."'";
	if(!$mysql->query($sqlgrpid)) { exit($mysql->error); }
	while(!$mysql->EOF) {
		if (!isset($l)) { $l=''; }
		if ($mysql->field('folder_id') == $l) {
			$grpids[$mysql->field('folder_id')][]=$mysql->field('group_id');
		} else {
			$grpids[$mysql->field('folder_id')]=array($mysql->field('group_id'));
		}
		$l = $mysql->field('folder_id');
		$mysql->movenext();
	}
}

$sqlg="SELECT id, group_name FROM `".DB_PREFIX."user_groups`";
if(!$mysql->query($sqlg)) { exit($mysql->error); }
while(!$mysql->EOF) {
	$grplist[$mysql->field('id')]=$mysql->field('group_name');
	$mysql->movenext();
}

$flist4 = $flist;
foreach ($flist4 as $kflist4 => $vflist4) {
	foreach ($grpids as $kgrpids => $vgrpids) {
		if ($kflist4 == $kgrpids) {
			$flist[$kflist4]['grps']=implode(', ', $vgrpids);
		}
	}
}

$flist5 = $flist;
foreach ($flist5 as $kflist5 => $vflist5) {
	if (array_key_exists('grps', $vflist5)) {
		$g = explode(', ', $vflist5['grps']);
		$i = explode(', ', $vflist5['grps']);
		$h = $vflist5['grps'];
		$z = array();

		foreach ($grplist as $kgrplist => $vgrplist) {
			foreach ($g as $kg => $vg) {
				if ($vg == $kgrplist) {
					$z[$kg] = str_replace(strval($vg), strval($vgrplist), $i[$kg]);
					$flist[$kflist5]['grpsname']=implode(', ',$z);
				}
				
			} 
		}
	} else {
		$z = '';
		$flist[$kflist5]['grpsname']=' - ';
	}
}

$flist6 = $flist;
foreach ($flist6 as $kflist6 => $vflist6) {
	$exp = explode(', ', $flist[$kflist6]['grpsname']);
	sort($exp);
	$imp = implode(', ',$exp);
	unset($flist[$kflist6]['grpsname']);
	$flist[$kflist6]['grpsname'] = $imp;
}

$smarty->assign("fl", $flist);
$smarty->assign("datasheet", "folders_list");

$smarty->assign("listdata", $tree->get_smarty());
$smarty->display("control/index.tpl");
?>
Return current item: @1 File Store