Sourcecode in Site/objectFunctions.js:
1: function evalPreferences(param, modifier) {
2: if (!evalEmail(param.email))
3: throw new Exception("emailInvalid");
4: this.title = stripTags(param.title);
5: this.email = param.email;
6: if (this.online && !param.online)
7: this.lastoffline = new Date();
8: this.online = param.online ? 1 : 0;
9: this.enableping = param.enableping ? 1 : 0;
10:
11: // store new preferences
12: var prefs = new HopObject();
13: for (var i in param) {
14: if (i.startsWith("preferences_"))
15: prefs[i.substring(12)] = param[i];
16: }
17: prefs.days = !isNaN(parseInt(param.preferences_days, 10)) ? parseInt(param.preferences_days, 10) : 3;
18: prefs.discussions = param.preferences_discussions ? 1 : 0;
19: prefs.usercontrib = param.preferences_usercontrib ? 1 : 0;
20: prefs.archive = param.preferences_archive ? 1 : 0;
21: // store selected locale
22: if (param.locale) {
23: var loc = param.locale.split("_");
24: prefs.language = loc[0];
25: prefs.country = loc.length == 2 ? loc[1] : null;
26: }
27: prefs.timezone = param.timezone;
28: prefs.longdateformat = param.longdateformat;
29: prefs.shortdateformat = param.shortdateformat;
30:
31: // layout
32: this.layout = param.layout ? this.layouts.get(param.layout) : null;
33:
34: // e-mail notification
35: var n = parseInt(param.notify_create, 10);
36: prefs.notify_create = (modifier == this.creator && !isNaN(n) ? n : null);
37: n = parseInt(param.notify_update, 10);
38: prefs.notify_update = (modifier == this.creator && !isNaN(n) ? n : null);
39: n = parseInt(param.notify_upload,10);
40: prefs.notify_upload = (modifier == this.creator && !isNaN(n) ? n : null);
41:
42: // store preferences
43: this.preferences.setAll(prefs);
44: // call the evalPreferences method of every module
45: for (var i in app.modules)
46: this.applyModuleMethod(app.modules[i], "evalPreferences", param);
47:
48:
49: // reset cached locale, timezone and dateSymbols
50: this.cache.locale = null;
51: this.cache.timezone = null;
52: this.cache.dateSymbols = null;
53:
54: this.modifytime = new Date();
55: this.modifier = modifier;
56: return new Message("update");
57: }
|