Sourcecode in Story/objectFunctions.js:
1: function evalStory(param, modifier) {
2: // collect content
3: var content = extractContent(param, this.content.getAll());
4: // if all story parts are null, return with error-message
5: if (!content.exists)
6: throw new Exception("textMissing");
7: // check if the createtime is set in param
8: if (param.createtime) {
9: try {
10: var ctime = param.createtime.toDate("yyyy-MM-dd HH:mm");
11: } catch (err) {
12: throw new Exception("timestampParse", param.createtime);
13: }
14: }
15: // check name of topic (if specified)
16: var topicName = null;
17: if (param.topic) {
18: // FIXME: this should be solved more elegantly
19: if (String.URLPATTERN.test(param.topic))
20: throw new Exception("topicNoSpecialChars");
21: if (this.site.topics[param.topic] || this.site.topics[param.topic + "_action"])
22: throw new Exception("topicReservedWord");
23: topicName = param.topic;
24: } else if (param.addToTopic)
25: topicName = param.addToTopic;
26:
27: // store the new values of the story
28: if (param.publish) {
29: var newStatus = param.addToFront ? 2 : 1;
30: if (!this.online || content.isMajorUpdate)
31: this.site.lastupdate = new Date();
32: this.online = newStatus;
33: } else
34: this.online = 0;
35: if (content.isMajorUpdate)
36: this.modifytime = new Date();
37: this.setContent(content.value);
38: this.topic = topicName;
39: // let's keep the title property
40: this.title = content.value.title;
41: // re-create day of story with respect to site-timezone
42: if (ctime && ctime != this.createtime) {
43: this.createtime = ctime;
44: this.day = ctime.format("yyyyMMdd", this.site.getLocale(), this.site.getTimeZone());
45: }
46: if (modifier == this.creator)
47: this.editableby = !isNaN(param.editableby) ?
48: parseInt(param.editableby, 10) : EDITABLEBY_ADMINS;
49: this.discussions = param.discussions ? 1 : 0;
50: this.modifier = modifier;
51: this.ipaddress = param.http_remotehost;
52:
53: // send e-mail notification
54: if (this.site.isNotificationEnabled() && newStatus != 0) {
55: // status changes from offline to online
56: // (this is bad because somebody could send a bunch
57: // of e-mails simply by toggling the online status.)
58: //if (this.online == 0)
59: // this.sendNotification("story", "create");
60: // major update of an already online story
61: if (this.online != 0 && content.isMajorUpdate)
62: this.site.sendNotification("update", this);
63: }
64: var result = new Message("storyUpdate");
65: result.url = this.online > 0 ? this.href() : this.site.stories.href();
66: result.id = this._id;
67: return result;
68: }
|