<?php
$_comments = loadBundle("fr.webcrafted.comments");
$_minecraft = loadBundle("fr.webcrafted.minecraft");
$_pages = loadBundle("fr.webcrafted.pages");
$_partners = loadBundle("fr.webcrafted.partners");
$_widgets = loadBundle("fr.webcrafted.widgets");
$pages = $_pages->getPages(true);
$serverdata = $_minecraft->getServer();
$lastcomments = $_comments->getLastComments();
$partners = $_partners->getPartners();
$widgets = $_widgets->getWidgets(false);
$admin = false;

if(!empty($serverdata))
	$serverdata = array(
		"ip"			=> Configure::read("server_ip"),
		"port"			=> $serverdata["port"],
		"players"		=> count($serverdata["players"]),
		"maxPlayers"	=> $serverdata["maxPlayers"],
		"state"			=> true,
	);
else
	$serverdata = array(
		"ip"			=> Configure::read("server_ip"),
		"port"			=> Configure::read("server_port"),
		"state"			=> false,
	);

if(
	$_users->hasPermission("webcrafted.admin.*")
	OR $_users->hasPermission("webcrafted.admin.server")
	OR $_users->hasPermission("webcrafted.admin.console")
	OR $_users->hasPermission("webcrafted.admin.posts")
	OR $_users->hasPermission("webcrafted.admin.pages")
	OR $_users->hasPermission("webcrafted.admin.users")
	OR $_users->hasPermission("webcrafted.admin.groups")
	OR $_users->hasPermission("webcrafted.admin.partners")
	OR $_users->hasPermission("webcrafted.admin.shop")
	OR $_users->hasPermission("webcrafted.admin.options"))
	$admin = true;

set(array(
	"page" => array(
		"name" => Configure::read("name"),
		"slogan" => Configure::read("slogan"),
		"description" => Configure::read("description"),
		"keywords" => Configure::read("keywords"),
	),
	"options" => array(
		"jsonapi_use" => Configure::read("jsonapi_use"),
		"shop_use" => Configure::read("shop_use"),
	),
	"lastcomments" => $lastcomments,
	"serverdata" => $serverdata,
	"pages" => $pages,
	"partners" => $partners,
	"widgets" => $widgets,
	"admin" => $admin,
));
