forked from StartupAPI/users
/
manage_account.php
83 lines (69 loc) · 1.79 KB
/
manage_account.php
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
require_once(dirname(__FILE__).'/config.php');
require_once(dirname(__FILE__).'/User.php');
if (!UserConfig::$useAccounts) {
header('Location: '.UserConfig::$DEFAULTLOGOUTRETURN);
exit;
}
$user = User::require_login();
$accounts = Account::getUserAccounts($user);
$manageable_accounts = array();
foreach ($accounts as $account) {
if ($account->getUserRole() == Account::ROLE_ADMIN) {
$manageable_accounts[] = $account;
}
}
$managed_account = null;
if (array_key_exists('account', $_GET)) {
foreach ($manageable_accounts as $account) {
if ($account->getID() == $_GET['account']) {
$managed_account = $account;
break;
}
}
}
if (is_null($managed_account)) {
header('Location: '.UserConfig::$DEFAULTLOGOUTRETURN);
exit;
}
require_once(UserConfig::$header);
?>
<h2>Account Info (<?php echo $managed_account->getName() ?>)</h2>
<div id="plan">
<p>Subscription plan: <b><?php echo $managed_account->getPlan()->getName() ?></b>
</div>
<?php
if (!$managed_account->getPlan()->isIndividual() && $managed_account->getUserRole() == Account::ROLE_ADMIN) {
?>
<div id="members">
<h2>Account Members</h2>
<ul>
<?php
$members = $managed_account->getUsers();
foreach ($members as $member) {
?><li><?php echo $member->getName(); ?></li><?php
}
?>
</ul>
</div>
<?php
}
if (count($manageable_accounts) > 1) {
?>
<h2>Other accounts</h2>
<p>Click on account name to open it:</p>
<ul>
<?php
foreach ($manageable_accounts as $account)
{
if ($account->isTheSameAs($managed_account)) {
?><li><b><?php echo UserTools::escape($account->getName())?></b></li><?php
} else {
?><li><a href="<?php echo UserConfig::$USERSROOTURL ?>/manage_account.php?account=<?php echo $account->getID()?>"><?php echo UserTools::escape($account->getName())?></a></li><?php
}
}
?>
</ul>
<?php
}
require_once(UserConfig::$footer);