summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/page.inc.php
blob: 97886bd25471010135d7051b49116bda188ea406 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php

class Page_Locations extends Page
{

	private static function loadPage()
	{
		$page = Request::any('page', 'locations', 'string');
		if (!in_array($page, ['locations', 'subnets', 'details', 'cleanup'])) {
			Message::addError('main.invalid-action', $page);
			Util::redirect('?do=Main');
		}
		require_once Page::getModule()->getDir() . '/pages/' . $page . '.inc.php';
	}

	/*
	 * Action handling
	 */

	protected function doPreprocess()
	{
		User::load();
		if (!User::isLoggedIn()) {
			Message::addError('main.no-permission');
			Util::redirect('?do=Main');
		}
		self::loadPage();
		if (Request::isPost()) {
			$action = Request::post('action');
			if (!SubPage::doPreprocess($action)) {
				Message::addError('main.invalid-action', $action);
			}
			Util::redirect('?do=locations');
		}
	}

	/*
	 * Rendering normal pages
	 */

	protected function doRender()
	{
		$getAction = Request::get('action', false, 'string');
		if (!SubPage::doRender($getAction)) {
			Message::addError('main.invalid-action', $getAction);
			Util::redirect('?do=locations');
		}
	}

	/*
	 * Ajax
	 */

	protected function doAjax()
	{
		User::load();
		if (!User::isLoggedIn()) {
			die('Unauthorized');
		}
		self::loadPage();
		$action = Request::any('action');
		if (!SubPage::doAjax($action)) {
			die('Invalid action ' . $action);
		}
	}

}