-
Notifications
You must be signed in to change notification settings - Fork 3
/
preferences.php
41 lines (35 loc) · 1.37 KB
/
preferences.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
<?php
require_once 'config.php';
$tpl->success = null;
if (isset($_POST['prefSave'])) {
try {
Prefs::setRegion(filter_input(INPUT_POST, 'region', FILTER_VALIDATE_INT));
switch ($_POST['marketMode']) {
case 'sell':
Prefs::setMarketMode('sell','sell','sell');
break;
case 'buy':
Prefs::setMarketMode('buy','sell','sell');
break;
case 'adv':
Prefs::setMarketMode(
($_POST['offerItem'] === 'buy' ? 'buy' : 'sell'),
($_POST['reqItems'] === 'buy' ? 'buy' : 'sell'),
($_POST['matItems'] === 'buy' ? 'buy' : 'sell'));
break;
default:
throw new Exception('Invalid Form Data');
}
$tpl->success = Prefs::save();
} catch (Exception $e) {
$tpl->success = false;
$tpl->msg = $e->getMessage();
}
}
// Set radio button default
if (array(Prefs::get('marketOffer'), Prefs::get('marketReq'), Prefs::get('marketMat')) === array('sell','sell','sell')) {
$tpl->radio = 'sell'; }
else if (array(Prefs::get('marketOffer'), Prefs::get('marketReq'), Prefs::get('marketMat')) === array('buy','sell','sell')) {
$tpl->radio = 'buy'; }
else { $tpl->radio = 'adv'; }
$tpl->display('preferences.html');