Rev 239 | Rev 257 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 239 | Rev 250 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | protected $values = array(); |
24 | protected $values = array(); |
25 | protected $dirty = true; |
25 | protected $dirty = true; |
26 | 26 | ||
27 | public function prepareConfigKey($name, $description, $init_value, $protected, $visible) { |
27 | public function prepareConfigKey($name, $description, $init_value, $protected, $visible) { |
28 | if (strlen($name) > 50) { |
28 | if (strlen($name) > 50) { |
29 | throw new Exception("Config key name '$name' is too long. (max 50)."); |
29 | throw new OIDplusException("Config key name '$name' is too long. (max 50)."); |
30 | } |
30 | } |
31 | if (strlen($description) > 255) { |
31 | if (strlen($description) > 255) { |
32 | throw new Exception("Description for config key '$name' is too long (max 255)."); |
32 | throw new OIDplusException("Description for config key '$name' is too long (max 255)."); |
33 | } |
33 | } |
34 | $this->buildConfigArray(); |
34 | $this->buildConfigArray(); |
35 | if (!isset($this->values[$name])) { |
35 | if (!isset($this->values[$name])) { |
36 | OIDplus::db()->query("insert into ".OIDPLUS_TABLENAME_PREFIX."config (name, description, value, protected, visible) values (?, ?, ?, ?, ?)", array($name, $description, $init_value, $protected, $visible)); |
36 | OIDplus::db()->query("insert into ".OIDPLUS_TABLENAME_PREFIX."config (name, description, value, protected, visible) values (?, ?, ?, ?, ?)", array($name, $description, $init_value, $protected, $visible)); |
37 | $this->values[$name] = $init_value; |
37 | $this->values[$name] = $init_value; |
Line 92... | Line 92... | ||
92 | public function setValue($name, $value) { |
92 | public function setValue($name, $value) { |
93 | // Check for valid values |
93 | // Check for valid values |
94 | 94 | ||
95 | if ($name == 'system_title') { |
95 | if ($name == 'system_title') { |
96 | if (empty($value)) { |
96 | if (empty($value)) { |
97 | throw new Exception("Please enter a value for the system title."); |
97 | throw new OIDplusException("Please enter a value for the system title."); |
98 | 98 | ||
99 | } |
99 | } |
100 | } |
100 | } |
101 | if (($name == 'global_cc') || ($name == 'admin_email')) { |
101 | if (($name == 'global_cc') || ($name == 'admin_email')) { |
102 | if (!empty($value) && !oidplus_valid_email($value)) { |
102 | if (!empty($value) && !OIDplus::mailUtils()->validMailAddress($value)) { |
103 | throw new Exception("This is not a correct email address"); |
103 | throw new OIDplusException("This is not a correct email address"); |
104 | } |
104 | } |
105 | } |
105 | } |
106 | if ($name == 'ra_min_password_length') { |
106 | if ($name == 'ra_min_password_length') { |
107 | if (!is_numeric($value) || ($value < 1)) { |
107 | if (!is_numeric($value) || ($value < 1)) { |
108 | throw new Exception("Please enter a valid password length."); |
108 | throw new OIDplusException("Please enter a valid password length."); |
109 | } |
109 | } |
110 | } |
110 | } |
111 | 111 | ||
112 | if ($name == 'objecttypes_enabled') { |
112 | if ($name == 'objecttypes_enabled') { |
113 | # TODO: when objecttypes_enabled is changed at the admin control panel, we need to do a reload of the page, so that jsTree will be updated. Is there anything we can do? |
113 | # TODO: when objecttypes_enabled is changed at the admin control panel, we need to do a reload of the page, so that jsTree will be updated. Is there anything we can do? |
114 | 114 | ||
115 | $ary = explode(';',$value); |
115 | $ary = explode(';',$value); |
116 | $uniq_ary = array_unique($ary); |
116 | $uniq_ary = array_unique($ary); |
117 | 117 | ||
118 | if (count($ary) != count($uniq_ary)) { |
118 | if (count($ary) != count($uniq_ary)) { |
119 | throw new Exception("Please check your input. Some object types are double."); |
119 | throw new OIDplusException("Please check your input. Some object types are double."); |
120 | } |
120 | } |
121 | 121 | ||
122 | foreach ($ary as $ot_check) { |
122 | foreach ($ary as $ot_check) { |
123 | $ns_found = false; |
123 | $ns_found = false; |
124 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
124 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
Line 132... | Line 132... | ||
132 | $ns_found = true; |
132 | $ns_found = true; |
133 | break; |
133 | break; |
134 | } |
134 | } |
135 | } |
135 | } |
136 | if (!$ns_found) { |
136 | if (!$ns_found) { |
137 | throw new Exception("Please check your input. Namespace \"$ot_check\" is not found"); |
137 | throw new OIDplusException("Please check your input. Namespace \"$ot_check\" is not found"); |
138 | } |
138 | } |
139 | } |
139 | } |
140 | } |
140 | } |
141 | 141 | ||
142 | // Give plugins the possibility to stop the process (e.g. if the value is invalid) |
142 | // Give plugins the possibility to stop the process (e.g. if the value is invalid) |