Sourcecode in Root/objectFunctions.js:
1: function evalNewSite(title, alias, creator) {
2: // check alias
3: if (!alias)
4: throw new Exception("siteAliasMissing");
5: else if (this.get(alias))
6: throw new Exception("siteAliasExisting");
7: else if (!alias.isClean())
8: throw new Exception("siteAliasNoSpecialChars");
9: else if (alias.length > 30)
10: throw new Exception("siteAliasTooLong");
11: else if (this[alias] || this[alias + "_action"])
12: throw new Exception("siteAliasReserved");
13: // check if title is missing
14: if (!title)
15: throw new Exception("siteTitleMissing");
16: // create new Site
17: var newSite = new Site(title, alias, creator);
18: // create an initial layout object that is a child layout
19: // of the currently active root layout
20: var initLayout = new Layout(newSite, newSite.title, creator);
21: initLayout.alias = newSite.alias;
22: initLayout.setParentLayout(res.handlers.layout);
23: if (!this.add(newSite))
24: throw new Exception("siteCreate");
25: newSite.layouts.add(initLayout);
26: newSite.layouts.setDefaultLayout(initLayout.alias);
27: // add the creator to the admins of the new Site
28: newSite.members.add(new Membership(creator, ADMIN));
29: root.manage.syslogs.add(new SysLog("site", newSite.alias, "added site", creator));
30: return new Message("siteCreate", null, newSite);
31: }
|