/
settings.php
86 lines (69 loc) · 2.74 KB
/
settings.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
84
85
86
<?php
require 'includes/init.inc.php';
require 'includes/template.inc.php';
// Load models used by all actions on the page
load_models('Group', 'Product');
// Determine the product
$product = $Product->getProductFromURL($_GET['product']);
// Load template engine and set some variables
$template = new Template($product['theme'], $Config->get('theme'), $product['url']);
$template->set(array(
'page_id' => 'settings',
'page_title' => $product['name'].' settings @ '. $Config->get('site_name').' moxie',
'page_type' => 'settings',
'css' => $template->cssString('global'),
'site_name' => $Config->get('site_name'),
'product_name' => $product['name']
));
// Action-specific logic
switch ($_GET['extra']) {
case 'info':
// Check if we have POST data to save
if (isset($_POST['name'])) {
$errors = array();
//$errors['url'] = 'Not unique';
if (empty($errors)) {
$fields = array('name', 'description', 'url');
$data = $Product->filterData($_POST, $fields);
$Product->update($product['id'], $data);
// Update our product data for templates
$product = $data;
// Update product URL for templates
$template->product_url = $product['url'];
// Clear POST data
$_POST = array();
$template->set(array(
'success_message' => 'Changes saved.',
'product_name' => $product['name'],
'page_title' => $product['name'].' settings @ '. $Config->get('site_name').' moxie',
));
}
else {
// There were errors
$template->set(array(
'error_message' => 'There were some problems. Please see the specific errors below.',
'errors' => $errors
));
}
}
$template->set(array(
'page_name' => 'product information',
'product' => $product
));
$template->render('layout/header', 'settings/info', 'layout/footer');
break;
case 'permissions':
$groups = $Group->getGroupsForUser(1);
$Group->addPermissionsToGroups($groups);
pr($groups);
$Group->sumPermissions($groups);
$template->set(array(
'page_name' => 'manage permissions'
));
$template->render('layout/header', 'settings/permissions', 'layout/footer');
break;
default:
$template->render('layout/header', 'settings/settings', 'layout/footer');
break;
}
?>