summaryrefslogtreecommitdiff
path: root/src/views/pages/users.php
blob: 9c12ee78e946c08297dd4548f808a883c405df61 (plain)
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
<?php global $mm;

global $illegal_names;
$illegal_names = array('', 'new');
global $username, $uid;// We will use these to pass the username to sub-views.

$page_parts = explode('/', PAGE);
if (isset($page_parts[1])) {
	$username = $page_parts[1];
	if ($username == '') {
		unset($username);
	}
}

if (isset($username)) { // URI: "users/*"
	// We'll be handing this off to another view.
	if ($username === 'new') {
		include(VIEWPATH.'/pages/users/new.php');
		exit();
	}
	
	$uid = $mm->getUID($username);
	if ($mm->getStatus($uid)===3) $uid = false; // ignore groups.
	
	if ($uid===false) {
		include(VIEWPATH.'/pages/users/404.php');
	} else {
		include(VIEWPATH.'/pages/users/individual.php');
	}
} else { // URI: "users"
	$method = $_SERVER['REQUEST_METHOD'];
	switch ($method) {
	case 'PUT':
	case 'POST':
		// We're POSTing a new user
		include(VIEWPATH.'/pages/users/create.php');
		break;
	case 'HEAD': // fall-through to GET
	case 'GET':
		// We're GETing an existing user
		include(VIEWPATH.'/pages/users/index.php');
		break;
	}
}