Sourcecode in StoryMgr/objectFunctions.js:
1: function evalNewStory(param, creator) {
2: var s = new Story(creator, param.http_remotehost);
3: // collect content
4: var content = extractContent(param);
5: // if all story parts are null, return with error-message
6: if (!content.exists)
7: throw new Exception("textMissing");
8: s.setContent(content.value);
9: // let's keep the title property
10: s.title = content.value.title;
11: // check if the create date is set in the param object
12: if (param.createtime) {
13: try {
14: s.createtime = param.createtime.toDate("yyyy-MM-dd HH:mm", this._parent.getTimeZone());
15: } catch (error) {
16: throw new Exception("timestampParse", param.createtime);
17: }
18: }
19: s.editableby = !isNaN(parseInt(param.editableby, 10)) ?
20: parseInt(param.editableby, 10) : EDITABLEBY_ADMINS;
21: s.discussions = param.discussions ? 1 : 0;
22: // create day of story with respect to site-timezone
23: s.day = formatTimestamp(s.createtime, "yyyyMMdd");
24:
25: // check name of topic (if specified)
26: if (param.topic) {
27: // FIXME: this should be solved more elegantly
28: if (String.URLPATTERN.test(param.topic))
29: throw new Exception("topicNoSpecialChars");
30: if (this._parent.topics[param.topic] || this._parent.topics[param.topic + "_action"])
31: throw new Exception("topicReservedWord");
32: s.topic = param.topic;
33: } else if (param.addToTopic)
34: s.topic = param.addToTopic;
35: // check the online-status of the story
36: if (param.publish)
37: s.online = param.addToFront ? 2 : 1;
38: else
39: s.online = 0;
40: // store the story
41: if (!this.add(s))
42: throw new Exception("storyCreate");
43: // send e-mail notification
44: if (s.site.isNotificationEnabled())
45: s.site.sendNotification("create", s);
46: var result = new Message("storyCreate", null, s);
47: result.id = s._id;
48: if (s.online) {
49: s.site.lastupdate = s.modifytime;
50: result.url = s.href();
51: } else
52: result.url = this.href();
53: return result;
54: }
|