1: <?php
2:
3: namespace Budabot\Core;
4:
5: use Exception;
6:
7: require_once 'SettingHandler.class.php';
8:
9: class OptionsSettingHandler extends SettingHandler {
10:
11: public function __construct(DBRow $row) {
12: parent::__construct($row);
13: }
14:
15: 16: 17:
18: function getDescription() {
19: $msg = "For this setting you must choose one of the options from the list below.\n\n";
20: return $msg;
21: }
22:
23: 24: 25:
26: function save($newValue) {
27: $options = explode(";", $this->row->options);
28: if ($this->row->intoptions != '') {
29: $intoptions = explode(";", $this->row->intoptions);
30: if (in_array($newValue, $intoptions)) {
31: return $newValue;
32: } else {
33: throw new Exception("This is not a correct option for this setting.");
34: }
35: } else {
36: if (in_array($newValue, $options)) {
37: return $newValue;
38: } else {
39: throw new Exception("This is not a correct option for this setting.");
40: }
41: }
42: }
43: }
44: