1 <?php
2 /**
3 * XLRstats : Real Time Player Stats (http://www.xlrstats.com)
4 * (CC) BY-NC-SA 2005-2013, Mark Weirath, Özgür Uysal
5 *
6 * Licensed under the Creative Commons BY-NC-SA 3.0 License
7 * Redistributions of files must retain the above copyright notice.
8 *
9 * @link http://www.xlrstats.com
10 * @license Creative Commons BY-NC-SA 3.0 License (http://creativecommons.org/licenses/by-nc-sa/3.0/)
11 * @package app.Plugin.Dashboard.Model
12 * @since XLRstats v3.0
13 * @version 0.1
14 */
15
16 App::uses('DashboardAppModel', 'Dashboard.Model');
17
18 /**
19 * Class Option
20 */
21 class Option extends DashboardAppModel {
22
23 /**
24 * This is not a stats model, but a web front configuration model
25 *
26 * @var bool
27 */
28 public $b3Database = false;
29
30 /**
31 * Model name
32 *
33 * @var string
34 */
35 public $name = 'Option';
36
37 /**
38 * DB table
39 *
40 * @var string
41 */
42 public $useTable = 'options';
43
44 /**
45 * Prefix
46 *
47 * @var string
48 */
49 public $tablePrefix = '';
50
51 /**
52 * Validation rules
53 *
54 * @var array
55 */
56 public $validate = array(
57 'name' => array (
58 'rule' => array('minLength', '5'),
59 'message' => 'FATAL: variable name is too short (at least 5 characters).'
60 )
61 );
62
63 //-------------------------------------------------------------------
64
65 /**
66 * Stores xlrstats global options in application configuration
67 */
68 public function load() {
69 $settings = $this->find('all');
70
71 foreach ($settings as $variable) {
72 Configure::write('options.' . $variable['Option']['name'], $variable['Option']['value']);
73 }
74 }
75
76 //-------------------------------------------------------------------
77
78 /**
79 * Returns an array of locked server options
80 *
81 * @return array
82 */
83 public function lockedOptions() {
84 $data = $this->find('all', array(
85 'fields' => 'Option.name',
86 'conditions' => 'Option.locked',
87 ));
88 $options = array();
89 foreach ($data as $option) {
90 $options[] = $option['Option']['name'];
91 }
92 return $options;
93 }
94
95 }
96