Mercurial > psgxs
comparison configuration.js @ 13:447db2e8c622
Better access mode handling.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 08 Sep 2010 12:04:14 +0200 |
parents | 44889cfb2f8c |
children | 06abc804e2ab |
comparison
equal
deleted
inserted
replaced
12:9a6b8b3357c6 | 13:447db2e8c622 |
---|---|
24 config.superOwner = ['you@example.com']; | 24 config.superOwner = ['you@example.com']; |
25 config.version = '0.1'; | 25 config.version = '0.1'; |
26 config.os = 'GNU/Linux'; | 26 config.os = 'GNU/Linux'; |
27 config.allowCreateNode = [/@example\.com$/]; // value is an array of RegExp JIDs. If only super-owner should be able to create nodes, use []. | 27 config.allowCreateNode = [/@example\.com$/]; // value is an array of RegExp JIDs. If only super-owner should be able to create nodes, use []. |
28 | 28 |
29 config.access = 'open'; // values include open, whitelist (by members) and authorize (owners of the node receive notification). presence and roster aren’t implemented yet. | |
30 | |
29 config.activated = [ | 31 config.activated = [ |
30 //'access-authorize', | |
31 //'access-open', | |
32 //'access-presence', // Impossible à utiliser dans un component | |
33 //'access-roster', // Impossible à utiliser dans un component | |
34 'access-whitelist', | |
35 'auto-create', | 32 'auto-create', |
36 //'auto-subscribe', // Impossible à utiliser dans un component | 33 //'auto-subscribe', // Impossible à utiliser dans un component |
37 //'collections', //TODO | 34 //'collections', //TODO |
38 'config-node', | 35 'config-node', |
39 'create-and-configure', | 36 'create-and-configure', |
214 if (typeof i == 'string' && feature == config.activated[i]) | 211 if (typeof i == 'string' && feature == config.activated[i]) |
215 return true; | 212 return true; |
216 return false; | 213 return false; |
217 }; | 214 }; |
218 | 215 |
219 if (config.enabled('access-whitelist')) { | 216 config.enable = function(feature) { |
217 config.activated.push(feature); | |
218 } | |
219 | |
220 config.disable = function(feature) { | |
221 if (typeof feature == 'string') | |
222 config.activated.splice(config.activated.indexOf(feature), 1); | |
223 else if (typeof feature == 'function') { | |
224 for (var i in config.activated) | |
225 if (feature(config.activated[i])) | |
226 config.disable(config.activated[i]); | |
227 } | |
228 } | |
229 | |
230 if (config.access == 'whitelist') { | |
231 config.disable(/access-.+/); | |
232 config.enable('access-whitelist'); | |
220 config.service_configuration.node_config['pubsub#access_model'].value = 'whitelist'; | 233 config.service_configuration.node_config['pubsub#access_model'].value = 'whitelist'; |
221 config.service_configuration['publish-options']['pubsub#access_model'].value = 'whitelist'; | 234 config.service_configuration['publish-options']['pubsub#access_model'].value = 'whitelist'; |
222 } else if (config.enabled('access-authorize')) { | 235 } else if (config.access == 'authorize')) { |
236 config.disable(/access-.+/); | |
237 config.enable('access-authorize'); | |
223 config.service_configuration.node_config['pubsub#access_model'].value = 'authorize'; | 238 config.service_configuration.node_config['pubsub#access_model'].value = 'authorize'; |
224 config.service_configuration['publish-options']['pubsub#access_model'].value = 'authorize'; | 239 config.service_configuration['publish-options']['pubsub#access_model'].value = 'authorize'; |
225 } else if (config.enabled('access-open')) { | 240 } else if (config.access == 'open')) { |
241 config.disable(/access-.+/); | |
242 config.enable('access-open'); | |
226 config.service_configuration.node_config['pubsub#access_model'].value = 'open'; | 243 config.service_configuration.node_config['pubsub#access_model'].value = 'open'; |
227 config.service_configuration['publish-options']['pubsub#access_model'].value = 'open'; | 244 config.service_configuration['publish-options']['pubsub#access_model'].value = 'open'; |
228 } | 245 } |