-
Notifications
You must be signed in to change notification settings - Fork 24
/
edit_account.php
39 lines (29 loc) · 1.07 KB
/
edit_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
<?php
require_once(__DIR__ . '/global.php');
UserTools::preventCSRF();
$current_user = User::require_login();
$account = $current_user->getCurrentAccount();
if (is_null($account) || $account->getUserRole($current_user) != Account::ROLE_ADMIN) {
header('Location: ' . UserConfig::$USERSROOTURL . '/manage_account.php');
exit;
}
$template_info = StartupAPI::getTemplateInfo();
$errors = array();
$new_account_name = NULL;
$selected_plan_slug = NULL;
if (array_key_exists('account_name', $_POST)) {
$new_account_name = trim($_POST['account_name']);
if (empty($new_account_name)) {
$errors['edit-account']['name'][] = "Account name can't be empty";
} else {
$account->setName($new_account_name);
}
if (count($errors['edit-account']) == 0) {
header('Location: ' . UserConfig::$USERSROOTURL . '/manage_account.php#message=updated');
exit;
}
}
$template_info['errors'] = $errors;
$template_info['PAGE']['SECTION'] = 'account';
$template_info['account_name'] = $account->getName();
StartupAPI::$template->display('@startupapi/account/edit_account.html.twig', $template_info);