summaryrefslogtreecommitdiffstats
path: root/modules-available/main/page.inc.php
blob: baea8350e8409d2d1c375228aa95f73c5d8d118a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

class Page_Main extends Page
{

	protected function doPreprocess()
	{
		User::load();
	}

	protected function doRender()
	{
		if (!User::isLoggedIn()) {
			Render::addTemplate('page-main-guest', array(
				'register' => (Database::queryFirst('SELECT userid FROM user LIMIT 1') === false)
			));
			return;
		}
		// Logged in here
		
		Render::addTemplate('page-main', array(
			'user' => User::getName(),
			'now' => time(),
		));

		// Warnings
		$needSetup = false;
		foreach (Hook::load('main-warning') as $hook) {
			if (Permission::moduleHasPermissions($hook->moduleId)
					&& User::hasPermission('.' . $hook->moduleId . '.*')) {
				include $hook->file;
			}
		}

		// Update warning state
		Property::setNeedsSetup($needSetup ? 1 : 0);
	}

	protected function doAjax()
	{
		User::isLoggedIn();
		die('Status: DB running');
	}

}