merged need_for_speed branch
This commit is contained in:
parent
578ae4537b
commit
42e0f21580
142 changed files with 919 additions and 1147 deletions
|
|
@ -30,9 +30,8 @@ create table AV_ACCESSLOG (
|
|||
# Indexes on table AV_ACCESSLOG
|
||||
#---------------------------
|
||||
|
||||
create index IDX_ACCESSLOG_F_SITE on AV_ACCESSLOG (ACCESSLOG_F_SITE);
|
||||
create index IDX_ACCESSLOG_F_TEXT on AV_ACCESSLOG (ACCESSLOG_F_TEXT);
|
||||
create index IDX_ACCESSLOG_DATE on AV_ACCESSLOG (ACCESSLOG_DATE);
|
||||
create index IDX_ACCESSLOG_MIXED on AV_ACCESSLOG (ACCESSLOG_F_SITE,ACCESSLOG_DATE);
|
||||
|
||||
#----------------------------
|
||||
# Table structure for AV_CHOICE
|
||||
|
|
@ -105,11 +104,8 @@ create table AV_IMAGE (
|
|||
# Indexes on table AV_IMAGE
|
||||
#----------------------------
|
||||
|
||||
CREATE INDEX IDX_IMAGE_F_SITE ON AV_IMAGE (IMAGE_F_SITE);
|
||||
CREATE INDEX IDX_IMAGE_ALIAS ON AV_IMAGE (IMAGE_ALIAS(20));
|
||||
CREATE INDEX IDX_IMAGE_F_IMAGE_PARENT ON AV_IMAGE (IMAGE_F_IMAGE_PARENT);
|
||||
CREATE INDEX IDX_IMAGE_F_IMAGE_THUMB ON AV_IMAGE (IMAGE_F_IMAGE_THUMB);
|
||||
CREATE INDEX IDX_IMAGE_F_USER_CREATOR ON AV_IMAGE (IMAGE_F_USER_CREATOR);
|
||||
CREATE INDEX IDX_IMAGE_MIXED ON AV_IMAGE (IMAGE_F_SITE,IMAGE_ALIAS(20),IMAGE_F_IMAGE_PARENT);
|
||||
|
||||
#----------------------------
|
||||
# records for table AV_IMAGE
|
||||
|
|
@ -204,9 +200,7 @@ create table AV_SKIN (
|
|||
# Indexes on table AV_SKIN
|
||||
#----------------------------
|
||||
|
||||
CREATE INDEX IDX_SKIN_F_SITE ON AV_SKIN (SKIN_F_SITE);
|
||||
CREATE INDEX IDX_SKIN_PROTOTYPE ON AV_SKIN (SKIN_PROTOTYPE(10));
|
||||
CREATE INDEX IDX_SKIN_NAME ON AV_SKIN (SKIN_NAME(20));
|
||||
CREATE INDEX IDX_SKIN_MIXED ON AV_SKIN (SKIN_F_SITE,SKIN_PROTOTYPE(10),SKIN_NAME(10));
|
||||
|
||||
#----------------------------
|
||||
# Table structure for AV_SYSLOG
|
||||
|
|
@ -257,14 +251,14 @@ create table AV_TEXT (
|
|||
# Indexes on table AV_TEXT
|
||||
#----------------------------
|
||||
|
||||
CREATE INDEX IDX_TEXT_F_SITE ON AV_TEXT (TEXT_F_SITE);
|
||||
CREATE INDEX IDX_TEXT_TOPIC ON AV_TEXT (TEXT_TOPIC);
|
||||
CREATE INDEX IDX_TEXT_DAY ON AV_TEXT (TEXT_DAY);
|
||||
CREATE INDEX IDX_TEXT_PROTOTYPE ON AV_TEXT (TEXT_PROTOTYPE);
|
||||
CREATE INDEX IDX_TEXT_F_TEXT_STORY ON AV_TEXT (TEXT_F_TEXT_STORY);
|
||||
CREATE INDEX IDX_TEXT_F_TEXT_PARENT ON AV_TEXT (TEXT_F_TEXT_PARENT);
|
||||
CREATE INDEX IDX_TEXT_ISONLINE ON AV_TEXT (TEXT_ISONLINE);
|
||||
CREATE INDEX IDX_TEXT_F_USER_CREATOR ON AV_TEXT (TEXT_F_USER_CREATOR);
|
||||
CREATE INDEX IDX_TEXT_MIXED_ALL ON AV_TEXT (TEXT_F_SITE,TEXT_MODIFYTIME,TEXT_ISONLINE,TEXT_PROTOTYPE,TEXT_ID);
|
||||
CREATE INDEX IDX_TEXT_MIXED_TOPIC ON AV_TEXT (TEXT_F_SITE,TEXT_TOPIC);
|
||||
CREATE INDEX IDX_TEXT_MIXED_DAY ON AV_TEXT (TEXT_F_SITE,TEXT_DAY);
|
||||
CREATE INDEX IDX_TEXT_MIXED_STORIES ON AV_TEXT (TEXT_F_SITE,TEXT_PROTOTYPE,TEXT_ISONLINE,TEXT_CREATETIME,TEXT_ID,TEXT_DAY);
|
||||
|
||||
|
||||
#----------------------------
|
||||
# Table structure for AV_USER
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
if (!session.user && (req.data.submit == "save" || req.data.save))
|
||||
rescueText(req.data);
|
||||
|
||||
checkIfLoggedIn(this.href(req.action));
|
||||
|
||||
if (session.data.rescuedText)
|
||||
restoreRescuedText();
|
||||
|
||||
var deny = this.isPostDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.story.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDeleteDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.story.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.story.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
function replylink_macro(param) {
|
||||
if (this.site.hasDiscussions() && !isUserBlocked() && req.action == "main") {
|
||||
if (this.site.discussions && req.action == "main") {
|
||||
openLink(this.href("comment"));
|
||||
if (!param.image)
|
||||
res.write(param.text ? param.text : "reply");
|
||||
|
|
|
|||
|
|
@ -1,15 +1,3 @@
|
|||
/**
|
||||
* function returns true/false whether comment is online or not
|
||||
* @param Boolean true if comment is online, false if offline
|
||||
*/
|
||||
|
||||
function isOnline() {
|
||||
if (parseInt(this.online,10))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function evaluates changes to posting
|
||||
* @param Obj Object containing the properties needed for creating a reply
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
<div class="commentDate"><% comment.createtime format="short" prefix="on " %><% comment.creator as="link" prefix=", " suffix=" answered:"%></div>
|
||||
<div class="commentTitle"><% comment.content part="title" %></div>
|
||||
<% comment.content part="text" suffix="<br />" %>
|
||||
<div class="small"><% comment.editlink prefix="... " suffix=" " %><% comment.deletelink prefix="... " %></div>
|
||||
<div class="small"><% comment.link text="link me" %> <% comment.editlink prefix="... " suffix=" " %><% comment.deletelink prefix="... " %></div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
*/
|
||||
|
||||
function isPostDenied(usr) {
|
||||
if (usr.isSysAdmin())
|
||||
if (usr.sysadmin)
|
||||
return null;
|
||||
if (!this.site.isOnline() && !this.site.isUserMember(usr))
|
||||
return (getMsg("error","siteNotPublic"));
|
||||
if (!this.site.online && !req.data.memberlevel)
|
||||
return "siteNotPublic";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -19,10 +19,7 @@ function isPostDenied(usr) {
|
|||
*/
|
||||
|
||||
function isEditDenied(usr) {
|
||||
if (this.creator != usr) {
|
||||
var membership = this.site.isUserMember(usr);
|
||||
if (!membership || (membership.level & MAY_EDIT_ANYCOMMENT) == 0)
|
||||
return (getMsg("error","commentEditDenied"));
|
||||
}
|
||||
if (this.creator != usr && (req.data.memberlevel & MAY_EDIT_ANYCOMMENT) == 0)
|
||||
return "commentEditDenied";
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<div class="commentDate"><% comment.createtime format="short" prefix="on " %><% comment.creator as="link" prefix=", " suffix=" posted:"%></div>
|
||||
<div class="commentTitle"><% comment.content part="title" %></div>
|
||||
<% comment.content part="text" suffix="<br />" %>
|
||||
<div class="small"><% comment.replylink text="reply to this comment" suffix=" " %><% comment.editlink prefix="... " suffix=" " %><% comment.deletelink prefix="... " %></div>
|
||||
<div class="small"><% comment.link text="link me" %><% comment.editlink prefix="... " suffix=" " %><% comment.deletelink prefix="... " %></div>
|
||||
|
||||
<% comment.comments %>
|
||||
<div class="reply"><span class="small"><% this.replylink text="post your answer!" prefix="<br>... " %></span></div>
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
var deny = path.site.isNotPublic(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.site.members.href("login"));
|
||||
}
|
||||
|
||||
if (!path.site.showArchive())
|
||||
if (!path.site.archive)
|
||||
res.redirect(path.site.href());
|
||||
|
||||
this.renderStorylist(parseInt(req.data.start,10));
|
||||
|
|
@ -13,4 +13,4 @@ res.data.title = path.site.title;
|
|||
|
||||
res.data.body = this.renderSkinAsString("main");
|
||||
|
||||
path.site.renderSkin("page");
|
||||
path.site.renderSkin("page");
|
||||
|
|
|
|||
|
|
@ -1,15 +1,3 @@
|
|||
/**
|
||||
* function checks if story is published in site
|
||||
* @param Obj story to check
|
||||
* @return Boolean true if online, false if not
|
||||
*/
|
||||
|
||||
function isStoryOnline(st) {
|
||||
if (parseInt(st.online,10) == 2)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* function deletes all childobjects of a day (recursive!)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@ function renderStorylist() {
|
|||
sp.text = "newer stories";
|
||||
res.data.prevpage = renderSkinAsString("prevpagelink",sp);
|
||||
}
|
||||
res.data.storylist = "";
|
||||
for (var i=0;i<this.size();i++) {
|
||||
var st = this.get(i);
|
||||
if (this.isStoryOnline(st))
|
||||
res.data.storylist += st.renderSkinAsString("preview");
|
||||
}
|
||||
var storylist = new java.lang.StringBuffer();
|
||||
for (var i=0;i<this.size();i++)
|
||||
storylist.append(this.get(i).renderSkinAsString("preview"));
|
||||
// assigning link to previous page to res.data.prevpage
|
||||
if (dayIdx < path.site.size()-1) {
|
||||
var sp = new Object();
|
||||
|
|
@ -28,5 +25,6 @@ function renderStorylist() {
|
|||
sp.text = "older stories";
|
||||
res.data.nextpage = renderSkinAsString("nextpagelink",sp);
|
||||
}
|
||||
res.data.storylist = storylist.toString();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.files.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.files.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ function url_macro(param) {
|
|||
*/
|
||||
|
||||
function editlink_macro(param) {
|
||||
if (!this.isEditDenied(session.user)) {
|
||||
if (session.user && !this.isEditDenied(session.user)) {
|
||||
openLink(this.href("edit"));
|
||||
res.write(param.text ? param.text : "edit");
|
||||
closeLink();
|
||||
|
|
@ -57,7 +57,7 @@ function editlink_macro(param) {
|
|||
*/
|
||||
|
||||
function deletelink_macro(param) {
|
||||
if (!this.isEditDenied(session.user)) {
|
||||
if (session.user && !this.isEditDenied(session.user)) {
|
||||
openLink(this.href("delete"));
|
||||
if (param.image && this.site.images.get(param.image))
|
||||
this.site.renderImage(this.site.images.get(param.image),param);
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@
|
|||
*/
|
||||
|
||||
function isEditDenied(usr) {
|
||||
if (this.creator != usr) {
|
||||
var membership = this.site.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if ((membership.level & MAY_EDIT_ANYFILE) == 0)
|
||||
return (getMsg("error","fileEditDenied"));
|
||||
}
|
||||
if (this.creator != usr && (req.data.memberlevel & MAY_EDIT_ANYFILE) == 0)
|
||||
return ("fileEditDenied");
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var parent = getParent();
|
|||
|
||||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(parent.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ function deleteFile(currFile) {
|
|||
var f = new File(getProperty("filePath") + currFile.site.alias, currFile.name);
|
||||
f.remove();
|
||||
if (this.remove(currFile))
|
||||
return (getMsg("confirm","fileDelete"));
|
||||
return (getMessage("confirm","fileDelete"));
|
||||
else
|
||||
return (getMsg("error","fileDelete"));
|
||||
return (getMessage("error","fileDelete"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,14 +20,15 @@ function renderFilelist(idx) {
|
|||
sp.text = "previous files";
|
||||
res.data.prevpage = renderSkinAsString("prevpagelink",sp);
|
||||
}
|
||||
res.data.filelist = "";
|
||||
var filelist = new java.lang.StringBuffer();
|
||||
for (var i=idx; i<max; i++)
|
||||
res.data.filelist += this.get(i).renderSkinAsString("preview");
|
||||
filelist.append(this.get(i).renderSkinAsString("preview"));
|
||||
if (i < size) {
|
||||
var sp = new Object();
|
||||
sp.url = this.href() + "?start=" + i;
|
||||
sp.text = "more files";
|
||||
res.data.nextpage = renderSkinAsString("nextpagelink",sp);
|
||||
}
|
||||
res.data.filelist = filelist.toString();
|
||||
return;
|
||||
}
|
||||
|
|
@ -5,12 +5,7 @@
|
|||
*/
|
||||
|
||||
function isDenied(usr) {
|
||||
if (!this._parent.userMayContrib()) {
|
||||
var membership = this._parent.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if ((membership.level & MAY_ADD_FILE) == 0)
|
||||
return (getMsg("error","fileAddDenied"));
|
||||
}
|
||||
if (!this._parent.usercontrib && (req.data.memberlevel & MAY_ADD_FILE) == 0)
|
||||
return "fileAddDenied";
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,7 @@
|
|||
* macro renders the current timestamp
|
||||
*/
|
||||
function now_macro(param) {
|
||||
var now = new Date();
|
||||
if (path.site)
|
||||
res.write(formatTimestamp(now,param.format));
|
||||
else if (param.format) {
|
||||
var sdf = new java.text.SimpleDateFormat(param.format);
|
||||
var result = tryEval("sdf.format(now)");
|
||||
if (result.error)
|
||||
return ("[error: wrong date-format]");
|
||||
return (result.value);
|
||||
} else
|
||||
res.write(now.format("yyyy.MM.dd HH:mm"));
|
||||
return(formatTimestamp(new Date(),param.format));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -44,11 +34,9 @@ function image_macro(param) {
|
|||
if (!img)
|
||||
return;
|
||||
var imgObj = img.obj;
|
||||
var url = imgObj.getStaticUrl();
|
||||
|
||||
// return different display according to param.as
|
||||
if (param.as == "url")
|
||||
return(url);
|
||||
return(imgObj.getStaticUrl());
|
||||
else if (param.as == "thumbnail") {
|
||||
if (!param.linkto)
|
||||
param.linkto = url;
|
||||
|
|
@ -61,7 +49,6 @@ function image_macro(param) {
|
|||
}
|
||||
delete(param.name);
|
||||
delete(param.as);
|
||||
|
||||
// render image tag
|
||||
if (param.linkto) {
|
||||
openLink(param.linkto);
|
||||
|
|
@ -171,8 +158,8 @@ function story_macro(param) {
|
|||
return;
|
||||
var story = site.allstories.get(storyPath[1] ? storyPath[1] : param.id);
|
||||
if (!story)
|
||||
return(getMsg("error","storyNoExist",param.id));
|
||||
story.renderSkin(param.useskin ? param.useskin : "preview");
|
||||
return(getMessage("error","storyNoExist",param.id));
|
||||
story.renderSkin(param.useskin ? param.useskin : "embed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -181,6 +168,8 @@ function story_macro(param) {
|
|||
* Renders a poll (optionally as link or results)
|
||||
*/
|
||||
function poll_macro(param) {
|
||||
// disable caching of any contentPart containing this macro
|
||||
req.data.cachePart = false;
|
||||
var parts = param.id.split("/");
|
||||
if (parts.length == 2)
|
||||
var site = root.get(parts[0]);
|
||||
|
|
@ -190,7 +179,7 @@ function poll_macro(param) {
|
|||
return;
|
||||
var poll = site.polls.get(parts[1] ? parts[1] : param.id);
|
||||
if (!poll)
|
||||
return(getMsg("error","pollNoExist",param.id));
|
||||
return(getMessage("error","pollNoExist",param.id));
|
||||
var deny = poll.isVoteDenied(session.user);
|
||||
if (poll.closed || param.as == "results")
|
||||
poll.renderSkin("results");
|
||||
|
|
@ -234,13 +223,13 @@ function sitelist_macro(param) {
|
|||
var sp = new Object();
|
||||
sp.url = root.href("list") + "?start=" + Math.max(0, idx-max);
|
||||
sp.text = "previous weblogs";
|
||||
renderSkinAsString("prevpagelink",sp);
|
||||
renderSkin("prevpagelink",sp);
|
||||
renderMarkupElement("br");
|
||||
}
|
||||
var cnt = 0;
|
||||
while (cnt < max && idx < size) {
|
||||
var w = collection.get(idx++);
|
||||
if (!w.isBlocked() && w.isOnline()) {
|
||||
if (!w.blocked && w.online) {
|
||||
w.renderSkin("preview");
|
||||
cnt++;
|
||||
}
|
||||
|
|
@ -315,6 +304,8 @@ function input_macro(param) {
|
|||
* function renders a shortcut
|
||||
*/
|
||||
function shortcut_macro(param) {
|
||||
// disable caching of any contentPart containing this macro
|
||||
req.data.cachePart = false;
|
||||
if (param && param.name) {
|
||||
var sc = path.site.shortcuts.get(param.name);
|
||||
if (sc)
|
||||
|
|
@ -335,6 +326,8 @@ function shortcut_macro(param) {
|
|||
*/
|
||||
|
||||
function storylist_macro(param) {
|
||||
// disable caching of any contentPart containing this macro
|
||||
req.data.cachePart = false;
|
||||
var site = param.of ? root.get(param.of) : path.site;
|
||||
if (!site)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -11,26 +11,6 @@ function checkEmail(address) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* function checks if req.data.date[Year|Month|Date|Hours|Minutes] is valid
|
||||
* if correct, creates dateobject and returns it
|
||||
* otherwise false
|
||||
*/
|
||||
|
||||
function checkDate() {
|
||||
if (req.data.dateYear && req.data.dateMonth && req.data.dateDate && req.data.dateHours && req.data.dateMinutes) {
|
||||
var ts = new Date();
|
||||
ts.setYear(parseInt(req.data.dateYear));
|
||||
ts.setMonth(parseInt(req.data.dateMonth));
|
||||
ts.setDate(parseInt(req.data.dateDate));
|
||||
ts.setHours(parseInt(req.data.dateHours));
|
||||
ts.setMinutes(parseInt(req.data.dateMinutes));
|
||||
ts.setSeconds(0);
|
||||
return (ts);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* function checks if the string passed contains special characters like
|
||||
* spaces, brackets etc.
|
||||
|
|
@ -103,12 +83,6 @@ function activateLinks (str) {
|
|||
l1.ignoreCase = true;
|
||||
l1.global = true;
|
||||
str = str.replace(l1, "$1" + pre + "$2" + mid + "$2" + post + "$3");
|
||||
|
||||
// because of caching of text i had to disable the following
|
||||
// it's now done in text_macro() of comment and story
|
||||
// and in title_macro() of story
|
||||
// do Wiki style substitution
|
||||
// return (doWikiStuff (str));
|
||||
return (str);
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +119,7 @@ function autoLogin() {
|
|||
else {
|
||||
if (session.login(name,u.password)) {
|
||||
u.lastVisit = new Date();
|
||||
res.message = getMsg("confirm","welcome",new Array(path.site ? path.site.title : root.getSysTitle(),session.user.name));
|
||||
res.message = getMessage("confirm","welcome",new Array(path.site ? path.site.title : root.getSysTitle(),session.user.name));
|
||||
} else
|
||||
return;
|
||||
}
|
||||
|
|
@ -243,8 +217,10 @@ function getDefaultDateFormats(version) {
|
|||
|
||||
/**
|
||||
* This is a simple logger that creates a DB entry for
|
||||
* each request that contains an HTTP referrer. This is
|
||||
* done by direct DB interface due to performance reasons.
|
||||
* each request that contains an HTTP referrer.
|
||||
* due to performance-reasons this is not written directly
|
||||
* into database but instead written to app.data.accessLog (=Vector)
|
||||
* and written to database by the scheduler once a minute
|
||||
*/
|
||||
|
||||
function logAccess() {
|
||||
|
|
@ -259,29 +235,17 @@ function logAccess() {
|
|||
var siteHref = site.href().toLowerCase();
|
||||
if (referrer.toLowerCase().indexOf(siteHref.substring(0,siteHref.length-1)) >= 0)
|
||||
return;
|
||||
|
||||
var storyID = path.story ? path.story._id : null;
|
||||
|
||||
// we're doing this with direct db access here
|
||||
// (there's no need to do it with prototypes):
|
||||
var c = getDBConnection("antville");
|
||||
var dbError = c.getLastError();
|
||||
if (dbError) {
|
||||
app.log("Error establishing DB connection: " + dbError);
|
||||
return;
|
||||
}
|
||||
var query = "insert into AV_ACCESSLOG (ACCESSLOG_F_SITE,ACCESSLOG_F_TEXT,"+
|
||||
"ACCESSLOG_REFERRER,ACCESSLOG_IP,ACCESSLOG_BROWSER) values (" +
|
||||
site._id + "," + storyID + ",'" + referrer + "','" + req.data.http_remotehost +
|
||||
"','" + req.data.http_browser + "')";
|
||||
c.executeCommand(query);
|
||||
var dbError = c.getLastError();
|
||||
if (dbError) {
|
||||
app.log("Error executing SQL query: " + dbError);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
var logObj = new Object();
|
||||
logObj.storyID = path.story ? path.story._id : null;
|
||||
logObj.siteID = site._id;
|
||||
logObj.referrer = referrer;
|
||||
logObj.remoteHost = req.data.http_remotehost;
|
||||
logObj.browser = req.data.http_browser;
|
||||
|
||||
// log to app.data.accessLog
|
||||
app.data.accessLog.add(logObj);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -290,10 +254,7 @@ function logAccess() {
|
|||
* (and probably other services, soon), this
|
||||
* function can be called via the scheduler.
|
||||
*/
|
||||
|
||||
function pingUpdatedSites() {
|
||||
// var period = 1000 * 60 * 60; // one hour
|
||||
|
||||
var c = getDBConnection("antville");
|
||||
var dbError = c.getLastError();
|
||||
if (dbError) {
|
||||
|
|
@ -301,7 +262,7 @@ function pingUpdatedSites() {
|
|||
return;
|
||||
}
|
||||
|
||||
var query = "select SITE_ID from AV_SITE where SITE_ISONLINE = 1 and SITE_ENABLEPING = 1 and (SITE_LASTUPDATE > SITE_LASTPING or SITE_LASTPING is null)";
|
||||
var query = "select SITE_ALIAS from AV_SITE where SITE_ISONLINE = 1 and SITE_ENABLEPING = 1 and (SITE_LASTUPDATE > SITE_LASTPING or SITE_LASTPING is null)";
|
||||
var rows = c.executeRetrieval(query);
|
||||
var dbError = c.getLastError();
|
||||
if (dbError) {
|
||||
|
|
@ -310,9 +271,8 @@ function pingUpdatedSites() {
|
|||
}
|
||||
|
||||
while (rows.next()) {
|
||||
var id = rows.getColumnItem("SITE_ID");
|
||||
var site = root.get(id.toString());
|
||||
app.log("Notifying weblogs.com for updated site '" + site.alias + "' (id " + id + ")");
|
||||
var site = root.get(rows.getColumnItem("SITE_ALIAS"));
|
||||
app.log("Notifying weblogs.com for updated site '" + site.alias + "' (id " + site._id + ")");
|
||||
site.ping();
|
||||
}
|
||||
|
||||
|
|
@ -341,42 +301,33 @@ function parseTimestamp (time, format) {
|
|||
* function formats a date to a string. It checks if a site object is
|
||||
* in the request path and if so uses its locale and timezone.
|
||||
*
|
||||
* @param ts Date to be formatted
|
||||
* @param format The format string
|
||||
* @return The date formatted as string
|
||||
* @param Object Date to be formatted
|
||||
* @param String The format string
|
||||
* @return String The date formatted as string
|
||||
*/
|
||||
function formatTimestamp(ts,dformat) {
|
||||
// date format parsing is quite expensive, but date formats
|
||||
// are not thread safe, so what we do is to cache them per request
|
||||
// in the response object using "timeformat_<format>" as key.
|
||||
var sdf = res.data["timeformat_"];
|
||||
// in the response object
|
||||
var sdf = res.data["timeformat"];
|
||||
var fmt = "yyyy/MM/dd HH:mm";
|
||||
if (path.site) {
|
||||
if (dformat == "short")
|
||||
fmt = path.site.shortdateformat ? path.site.shortdateformat : "dd.MM HH:mm";
|
||||
else if (dformat == "long")
|
||||
fmt = path.site.longdateformat ? path.site.longdateformat : "yyyy/MM/dd HH:mm";
|
||||
else if (dformat)
|
||||
fmt = dformat;
|
||||
} else {
|
||||
if (dformat)
|
||||
fmt = dformat;
|
||||
}
|
||||
var obj = path.site ? path.site : root;
|
||||
if (dformat == "short")
|
||||
fmt = obj.shortdateformat ? obj.shortdateformat : "dd.MM HH:mm";
|
||||
else if (dformat == "long")
|
||||
fmt = obj.longdateformat ? obj.longdateformat : "yyyy/MM/dd HH:mm";
|
||||
else if (dformat)
|
||||
fmt = dformat;
|
||||
|
||||
if (!sdf) {
|
||||
var locale = path.site ? path.site.getLocale() : root.getLocale();
|
||||
sdf = new java.text.SimpleDateFormat(fmt, locale);
|
||||
if (path.site)
|
||||
sdf.setTimeZone(path.site.getTimeZone());
|
||||
res.data["timeformat_"] = sdf;
|
||||
res.data["timeformat"] = sdf;
|
||||
} else if (fmt != sdf.toPattern()) {
|
||||
sdf.applyPattern(fmt);
|
||||
}
|
||||
|
||||
var result = tryEval("sdf.format(ts)");
|
||||
if (result.error)
|
||||
return (getMsg("error","wrongDateFormat"));
|
||||
return (result.value);
|
||||
var result = sdf.format(ts);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -390,14 +341,10 @@ function scheduler() {
|
|||
// notify updated sites
|
||||
pingUpdatedSites();
|
||||
countUsers();
|
||||
/*
|
||||
var patch = tryEval("root.system_patch()");
|
||||
if (patch.value) {
|
||||
app.log("---------- [ANTVILLE PATCH] ----------");
|
||||
app.log("still not finished, next run in " + patch.value + " millis");
|
||||
return (patch.value);
|
||||
}
|
||||
*/
|
||||
// write the log-entries in app.data.accessLog into DB
|
||||
writeAccessLog();
|
||||
// store the readLog in app.data.readLog into DB
|
||||
writeReadLog();
|
||||
return (60000);
|
||||
}
|
||||
|
||||
|
|
@ -426,7 +373,7 @@ function cloneObject(obj) {
|
|||
* @return String rendered message
|
||||
*/
|
||||
|
||||
function getMsg(msgClass,msgName,value) {
|
||||
function getMessage(msgClass,msgName,value) {
|
||||
// create array containing languages to search for message
|
||||
var languages = new Array();
|
||||
if (path && path.site && path.site.language)
|
||||
|
|
@ -446,7 +393,7 @@ function getMsg(msgClass,msgName,value) {
|
|||
param.value1 = value;
|
||||
else if (value && value.length > 0) {
|
||||
for (var i in value)
|
||||
param["value" + (parseInt(i)+1)] = value[i];
|
||||
param["value" + (parseInt(i,10)+1)] = value[i];
|
||||
}
|
||||
return (renderSkinAsString(createSkin(message),param));
|
||||
}
|
||||
|
|
@ -469,7 +416,7 @@ function getMsg(msgClass,msgName,value) {
|
|||
|
||||
function createResultObj(msgClass,msgName,value,error) {
|
||||
var result = new Object();
|
||||
result.message = getMsg(msgClass,msgName,value);
|
||||
result.message = getMessage(msgClass,msgName,value);
|
||||
result.error = error;
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -530,6 +477,12 @@ function onStart() {
|
|||
app.data.macros = new Packages.helma.util.SystemProperties (macroHelpFile.getAbsolutePath());
|
||||
//eval(macroHelpFile.readAll());
|
||||
app.log("loaded macro help file");
|
||||
// creating the vector for referrer-logging
|
||||
// with an initial capacity of 500 and an increment of 150
|
||||
app.data.accessLog = new java.util.Vector(500,125);
|
||||
// creating the hashtable for storyread-counting
|
||||
// with an initial capacity of 500 and an increment of 150
|
||||
app.data.readLog = new java.util.Hashtable(500,125);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -571,10 +524,16 @@ function clipText(text, limit, clipping) {
|
|||
*/
|
||||
|
||||
function softwrap(str) {
|
||||
var result = "";
|
||||
for (var i=0; i<str.length; i=i+30)
|
||||
result += str.substring(i, i+30) + "<wbr />";
|
||||
return(result);
|
||||
if (str.length<30)
|
||||
return str;
|
||||
var wrapped = new java.lang.StringBuffer();
|
||||
for (var i=0; i<str.length; i=i+30) {
|
||||
var strPart = str.substring(i, i+30);
|
||||
wrapped.append(strPart);
|
||||
if (strPart.length == 30 && strPart.indexOf(" ") < 0)
|
||||
wrapped.append("<wbr />");
|
||||
}
|
||||
return (wrapped.toString());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -598,8 +557,7 @@ function fixRssText(str) {
|
|||
*/
|
||||
|
||||
function countUsers() {
|
||||
app.log("1, 2, 3... counting users");
|
||||
app.data.activeUsers = new Array()
|
||||
app.data.activeUsers = new Array();
|
||||
var l = app.getActiveUsers();
|
||||
for (var i in l)
|
||||
app.data.activeUsers[app.data.activeUsers.length] = l[i];
|
||||
|
|
@ -611,3 +569,108 @@ function countUsers() {
|
|||
}
|
||||
app.data.activeUsers.sort();
|
||||
}
|
||||
|
||||
/**
|
||||
* function swaps app.data.accessLog, loops over the objects
|
||||
* contained in Vector and inserts records for every log-entry
|
||||
* in AV_ACCESSLOG
|
||||
*/
|
||||
function writeAccessLog() {
|
||||
if (app.data.accessLog.size() == 0)
|
||||
return;
|
||||
// first of all swap app.data.accessLog
|
||||
var size = app.data.accessLog.size();
|
||||
var newSize = Math.max(Math.round(size*1.25),500);
|
||||
var newIncrement = Math.max(Math.round(size/4),125);
|
||||
var log = app.data.accessLog;
|
||||
app.data.accessLog = new java.util.Vector(newSize,newIncrement);
|
||||
// open database-connection
|
||||
var c = getDBConnection("antville");
|
||||
var dbError = c.getLastError();
|
||||
if (dbError) {
|
||||
app.log("Error establishing DB connection: " + dbError);
|
||||
return;
|
||||
}
|
||||
// loop over log-vector
|
||||
var query;
|
||||
for (var i=0;i<log.size();i++) {
|
||||
var logObj = log.get(i);
|
||||
query = "insert into AV_ACCESSLOG (ACCESSLOG_F_SITE,ACCESSLOG_F_TEXT," +
|
||||
"ACCESSLOG_REFERRER,ACCESSLOG_IP,ACCESSLOG_BROWSER) values (" +
|
||||
logObj.siteID + "," + logObj.storyID + ",'" + logObj.referrer + "','" + logObj.remoteHost +
|
||||
"','" + logObj.browser + "')";
|
||||
c.executeCommand(query);
|
||||
if (dbError) {
|
||||
app.log("Error executing SQL query: " + dbError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
app.log("wrote " + i + " referrers into database");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* function swaps app.data.readLog, loops over the logObjects
|
||||
* contained in the Hashtable and updates the read-counter
|
||||
* of all stories
|
||||
*/
|
||||
function writeReadLog() {
|
||||
if (app.data.readLog.size() == 0)
|
||||
return;
|
||||
// first of all swap app.data.readLog
|
||||
var size = app.data.readLog.size();
|
||||
var newSize = Math.max(Math.round(size*1.25),500);
|
||||
var newIncrement = Math.max(Math.round(size/4),125);
|
||||
var log = app.data.readLog;
|
||||
app.data.readLog = new java.util.Hashtable(newSize,newIncrement);
|
||||
// loop over Hashtable
|
||||
var reads = log.elements();
|
||||
while (reads.hasMoreElements()) {
|
||||
var el = reads.nextElement();
|
||||
var site = root.get(el.site);
|
||||
if (!site)
|
||||
continue;
|
||||
var story = site.allstories.get(String(el.story));
|
||||
if (!story)
|
||||
continue;
|
||||
story.reads = el.reads;
|
||||
}
|
||||
app.log("updated read-counter of " + log.size() + " stories in database");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* rescue story/comment by copying all necessary properties to
|
||||
* session.data.rescuedText. this will be copied back to
|
||||
* req.data by restoreRescuedText() after successful login
|
||||
* @param Object req.data
|
||||
*/
|
||||
function rescueText(param) {
|
||||
session.data.rescuedText = new Object();
|
||||
for (var i in param) {
|
||||
if (i.indexOf("content_") == 0)
|
||||
session.data.rescuedText[i] = param[i];
|
||||
}
|
||||
session.data.rescuedText.discussions = param.discussions;
|
||||
session.data.rescuedText.topic = param.topic;
|
||||
session.data.rescuedText.discussions_array = param.discussions_array;
|
||||
session.data.rescuedText.submit = param.submit;
|
||||
session.data.rescuedText.save = param.save;
|
||||
session.data.rescuedText.topicidx = param.topicidx;
|
||||
session.data.rescuedText.online = param.online;
|
||||
session.data.rescuedText.editableby = param.editableby;
|
||||
session.data.rescuedText.createtime = param.createtime;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* restore rescued Text in session.data by copying
|
||||
* all properties back to req.data
|
||||
*/
|
||||
function restoreRescuedText() {
|
||||
// copy story-parameters back to req.data
|
||||
for (var i in session.data.rescuedText)
|
||||
req.data[i] = session.data.rescuedText[i];
|
||||
session.data.rescuedText = null;
|
||||
return;
|
||||
}
|
||||
|
|
@ -82,9 +82,7 @@ function renderMarkupPart(name, attr) {
|
|||
function renderImage(img, param) {
|
||||
if (!param.title)
|
||||
param.title = img.alttext ? img.alttext : "";
|
||||
param.src = getProperty("imgUrl");
|
||||
param.src += img.site ? img.site.alias + "/" : "";
|
||||
param.src += img.filename + "." + img.fileext;
|
||||
param.src = img.getStaticUrl();
|
||||
if (!param.width)
|
||||
param.width = img.width;
|
||||
if (!param.height)
|
||||
|
|
@ -308,22 +306,21 @@ function doWikiStuff (src) {
|
|||
* @param attr Object containing the element's attributes as properties
|
||||
*/
|
||||
function renderMarkupElementAsString(name, content, attr) {
|
||||
if (!content)
|
||||
content = "";
|
||||
// temporary mapping of class attribute
|
||||
// (due to backwards-compatibility)
|
||||
if (!attr["class"]) {
|
||||
attr["class"] = attr.style;
|
||||
delete attr.style;
|
||||
}
|
||||
var attributes = "";
|
||||
// creating the attribute string
|
||||
for (var i in attr) {
|
||||
if (!attr[i])
|
||||
continue;
|
||||
attributes += " " + i + "=\"" + attr[i] + "\"";
|
||||
}
|
||||
return("<" + name + attributes + ">" + content + "</" + name + ">");
|
||||
if (!content)
|
||||
content = "";
|
||||
// temporary mapping of class attribute
|
||||
// (due to backwards-compatibility)
|
||||
if (!attr["class"]) {
|
||||
attr["class"] = attr.style;
|
||||
delete attr.style;
|
||||
}
|
||||
var attributes = new java.lang.StringBuffer();
|
||||
for (var i in attr) {
|
||||
if (!attr[i])
|
||||
continue;
|
||||
attributes.append(" " + i + "=\"" + attr[i] + "\"");
|
||||
}
|
||||
return("<" + name + attributes.toString() + ">" + content + "</" + name + ">");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,79 +25,23 @@ ROLES = new Array("Subscriber","Contributor","Content Manager","Admin");
|
|||
/**
|
||||
* function returns an integer indicating contributor-role
|
||||
*/
|
||||
|
||||
function getContributorLvl() {
|
||||
var lvl = 0;
|
||||
lvl |= MAY_ADD_STORY;
|
||||
lvl |= MAY_ADD_COMMENT;
|
||||
lvl |= MAY_ADD_IMAGE;
|
||||
lvl |= MAY_ADD_FILE;
|
||||
lvl |= MAY_VIEW_STATS;
|
||||
return (lvl);
|
||||
}
|
||||
CONTRIBUTOR = MAY_ADD_STORY | MAY_ADD_COMMENT |
|
||||
MAY_ADD_IMAGE | MAY_ADD_FILE |
|
||||
MAY_VIEW_STATS;
|
||||
|
||||
/**
|
||||
* function returns an integer indicating contentmanager-role
|
||||
*/
|
||||
|
||||
function getContentManagerLvl() {
|
||||
var lvl = getContributorLvl();
|
||||
lvl |= MAY_VIEW_ANYSTORY;
|
||||
lvl |= MAY_EDIT_ANYSTORY;
|
||||
lvl |= MAY_DELETE_ANYSTORY;
|
||||
lvl |= MAY_EDIT_ANYCOMMENT;
|
||||
lvl |= MAY_DELETE_ANYCOMMENT;
|
||||
lvl |= MAY_EDIT_ANYIMAGE;
|
||||
lvl |= MAY_DELETE_ANYIMAGE;
|
||||
lvl |= MAY_EDIT_ANYFILE;
|
||||
lvl |= MAY_DELETE_ANYFILE;
|
||||
return (lvl);
|
||||
}
|
||||
CONTENTMANAGER = CONTRIBUTOR | MAY_VIEW_ANYSTORY | MAY_EDIT_ANYSTORY |
|
||||
MAY_DELETE_ANYSTORY | MAY_EDIT_ANYCOMMENT |
|
||||
MAY_DELETE_ANYCOMMENT | MAY_EDIT_ANYIMAGE |
|
||||
MAY_DELETE_ANYIMAGE | MAY_EDIT_ANYFILE |
|
||||
MAY_DELETE_ANYFILE;
|
||||
|
||||
/**
|
||||
* function returns an integer indicating admin-role
|
||||
*/
|
||||
|
||||
function getAdminLvl() {
|
||||
var lvl = getContentManagerLvl();
|
||||
lvl |= MAY_EDIT_PREFS;
|
||||
lvl |= MAY_EDIT_SKINS;
|
||||
lvl |= MAY_EDIT_MEMBERS;
|
||||
return (lvl);
|
||||
}
|
||||
|
||||
/**
|
||||
* function returns true if passed level matches
|
||||
* the level of contributors
|
||||
*/
|
||||
|
||||
function isContributor(lvl) {
|
||||
if (lvl == getContributorLvl())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* function returns true if passed level matches
|
||||
* the level of content managers
|
||||
*/
|
||||
|
||||
function isContentManager(lvl) {
|
||||
if (lvl == getContentManagerLvl())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* function returns true if passed level matches
|
||||
* the level of admins
|
||||
*/
|
||||
|
||||
function isAdmin(lvl) {
|
||||
if (lvl == getAdminLvl())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
ADMIN = CONTENTMANAGER | MAY_EDIT_PREFS | MAY_EDIT_SKINS | MAY_EDIT_MEMBERS;
|
||||
|
||||
/**
|
||||
* function returns the level of the membership in cleartext
|
||||
|
|
@ -105,12 +49,12 @@ function isAdmin(lvl) {
|
|||
*/
|
||||
|
||||
function getRole(lvl) {
|
||||
if (lvl == getContributorLvl())
|
||||
if (lvl == CONTRIBUTOR)
|
||||
return ("Contributor");
|
||||
else if (lvl == getContentManagerLvl())
|
||||
else if (lvl == CONTENTMANAGER)
|
||||
return ("Content Manager");
|
||||
else if (lvl == getAdminLvl())
|
||||
else if (lvl == ADMIN)
|
||||
return ("Admin");
|
||||
else
|
||||
return ("Subscriber");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,3 @@
|
|||
/**
|
||||
* function checks if the current session is authenticated
|
||||
* and if the user has been blocked
|
||||
* @return Boolean true when blocked, false otherwise
|
||||
*/
|
||||
|
||||
function isUserBlocked() {
|
||||
if (session.user)
|
||||
return (session.user.isBlocked());
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* function checks if the current session is authenticated
|
||||
* and if the user is trusted
|
||||
|
|
@ -18,7 +6,7 @@ function isUserBlocked() {
|
|||
|
||||
function isUserTrusted() {
|
||||
if (session.user)
|
||||
return (session.user.isTrusted())
|
||||
return (session.user.trusted)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -30,6 +18,6 @@ function isUserTrusted() {
|
|||
|
||||
function isUserSysAdmin() {
|
||||
if (session.user)
|
||||
return (session.user.isSysAdmin());
|
||||
return (session.user.sysadmin);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,18 +15,15 @@ function skin_macro(param) {
|
|||
* macro creates an html link
|
||||
*/
|
||||
function link_macro(param) {
|
||||
if (param.checkdeny == "true") {
|
||||
if (this.isDenied(session.user))
|
||||
return("");
|
||||
}
|
||||
var content = param.text ? param.text : param.to;
|
||||
param = this.createLinkParam(param);
|
||||
openMarkupElement("a", param);
|
||||
res.write(content);
|
||||
closeMarkupElement("a");
|
||||
if (param.checkdeny == "true" && this.isDenied(session.user))
|
||||
return;
|
||||
var content = param.text ? param.text : param.to;
|
||||
param = this.createLinkParam(param);
|
||||
openMarkupElement("a", param);
|
||||
res.write(content);
|
||||
closeMarkupElement("a");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro renders the time the object was created
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
*/
|
||||
function getNavigationName () {
|
||||
var proto = this.__prototype__;
|
||||
var proto = this._prototype;
|
||||
if (proto == "site")
|
||||
return "Home";
|
||||
else if (proto == "topicmgr")
|
||||
|
|
@ -40,28 +40,31 @@ function createInputParam(propName, param) {
|
|||
* be passed to function that renders the link element
|
||||
*/
|
||||
function createLinkParam(param) {
|
||||
var url = param.to ? param.to : param.linkto;
|
||||
if (!url || url == "main")
|
||||
param.href = this.href();
|
||||
else if (url.indexOf("://") > -1 || url.substring(0, 10) == "javascript")
|
||||
param.href = url;
|
||||
else {
|
||||
// check if link points to a subcollection
|
||||
if (url.indexOf("/") > -1)
|
||||
param.href = this.href() + url;
|
||||
else
|
||||
param.href = this.href(url);
|
||||
}
|
||||
if (param.urlparam)
|
||||
param.href += "?" + param.urlparam;
|
||||
if (param.anchor)
|
||||
param.href += "#" + param.anchor;
|
||||
delete param.to;
|
||||
delete param.linkto;
|
||||
delete param.urlparam;
|
||||
delete param.anchor;
|
||||
delete param.text;
|
||||
delete param.prefix;
|
||||
delete param.suffix;
|
||||
return(param);
|
||||
}
|
||||
var url = param.to ? param.to : param.linkto;
|
||||
if (!url || url == "main") {
|
||||
if (this._prototype != "comment")
|
||||
param.href = this.href();
|
||||
else
|
||||
param.href = this.story.href() + "#" + this._id;
|
||||
} else if (url.indexOf("://") > -1 || url.indexOf("javascript") == 0)
|
||||
param.href = url;
|
||||
else {
|
||||
// check if link points to a subcollection
|
||||
if (url.indexOf("/") > -1)
|
||||
param.href = this.href() + url;
|
||||
else
|
||||
param.href = this.href(url);
|
||||
}
|
||||
if (param.urlparam)
|
||||
param.href += "?" + param.urlparam;
|
||||
if (param.anchor)
|
||||
param.href += "#" + param.anchor;
|
||||
delete param.to;
|
||||
delete param.linkto;
|
||||
delete param.urlparam;
|
||||
delete param.anchor;
|
||||
delete param.text;
|
||||
delete param.prefix;
|
||||
delete param.suffix;
|
||||
return(param);
|
||||
}
|
||||
|
|
@ -5,15 +5,30 @@
|
|||
|
||||
function onRequest() {
|
||||
autoLogin();
|
||||
// defining skinpath
|
||||
if (path.site)
|
||||
// defining skinpath, membershipLevel
|
||||
req.data.memberlevel = 0;
|
||||
// if root.sys_frontSite is set and the site is online
|
||||
// we put it into path.site to ensure that the mirrored
|
||||
// weblog works as expected
|
||||
if (!path.site && root.sys_frontSite) {
|
||||
var s = root.get(root.sys_frontSite);
|
||||
if (s && s.online)
|
||||
path.site = root.get(root.sys_frontSite);
|
||||
}
|
||||
if (path.site) {
|
||||
res.skinpath = new Array(path.site.skins);
|
||||
if (path.site && path.site.isBlocked())
|
||||
res.redirect(root.href("blocked"));
|
||||
if (isUserBlocked()) {
|
||||
if (session.user) {
|
||||
var m = path.site.members.get(session.user.name);
|
||||
if (m)
|
||||
req.data.memberlevel = m.level;
|
||||
}
|
||||
if (path.site.blocked)
|
||||
res.redirect(root.href("blocked"));
|
||||
}
|
||||
if (session.user && session.user.blocked) {
|
||||
// user was blocked recently, so log out
|
||||
session.logout();
|
||||
res.message = getMsg("error","accountBlocked");
|
||||
res.message = getMessage("error","accountBlocked");
|
||||
res.redirect(path.site ? path.site.href() : root.href());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.images.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.images.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ function url_macro(param) {
|
|||
*/
|
||||
|
||||
function editlink_macro(param) {
|
||||
if (!this.isEditDenied(session.user)) {
|
||||
if (session.user && !this.isEditDenied(session.user)) {
|
||||
openLink(this.href("edit"));
|
||||
if (param.image && this.site.images.get(param.image))
|
||||
this.site.renderImage(this.site.images.get(param.image),param);
|
||||
|
|
@ -70,7 +70,7 @@ function editlink_macro(param) {
|
|||
*/
|
||||
|
||||
function deletelink_macro(param) {
|
||||
if (!this.isEditDenied(session.user)) {
|
||||
if (session.user && !this.isEditDenied(session.user)) {
|
||||
openLink(this.href("delete"));
|
||||
if (param.image && this.site.images.get(param.image))
|
||||
this.site.renderImage(this.site.images.get(param.image),param);
|
||||
|
|
@ -90,6 +90,7 @@ function show_macro(param) {
|
|||
// if we have a thumbnail, display that
|
||||
if (param.what == "thumbnail" && this.thumbnail)
|
||||
img = this.thumbnail;
|
||||
param.src = img.getStaticUrl();
|
||||
openLink(this.href());
|
||||
renderImage(img, param);
|
||||
closeLink();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
autoLogin();
|
||||
|
||||
res.data.title = this.site.title;
|
||||
|
||||
res.data.body = this.renderSkinAsString("main");
|
||||
|
|
|
|||
|
|
@ -126,11 +126,15 @@ function popupUrl() {
|
|||
|
||||
/**
|
||||
* returns the url to the static image
|
||||
* [rg] static url is now cached in this.cache.staticUrl
|
||||
*/
|
||||
function getStaticUrl() {
|
||||
var url = getProperty("imgUrl");
|
||||
if (this.site)
|
||||
url += this.site.alias + "/";
|
||||
url += this.filename + "." + this.fileext;
|
||||
return(url);
|
||||
if (!this.cache.staticUrl) {
|
||||
var url = getProperty("imgUrl");
|
||||
if (this.site)
|
||||
url += this.site.alias + "/";
|
||||
url += this.filename + "." + this.fileext;
|
||||
this.cache.staticUrl = url;
|
||||
}
|
||||
return(this.cache.staticUrl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@
|
|||
*/
|
||||
|
||||
function isEditDenied(usr) {
|
||||
if (this.creator != usr) {
|
||||
var membership = this.site.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if ((membership.level & MAY_EDIT_ANYIMAGE) == 0)
|
||||
return (getMsg("error","imageEditDenied"));
|
||||
}
|
||||
if (this.creator != usr && (req.data.memberlevel & MAY_EDIT_ANYIMAGE) == 0)
|
||||
return ("imageEditDenied");
|
||||
return null;
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ _db = antville
|
|||
_table = AV_IMAGE
|
||||
|
||||
_id = IMAGE_ID
|
||||
_parent = parent, site.images[named]
|
||||
_parent = parent, site.images
|
||||
|
||||
# object references
|
||||
site = object (site)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var parent = getParent();
|
|||
|
||||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(parent.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,9 +103,9 @@ function deleteImage(currImg) {
|
|||
}
|
||||
// then, remove the image-object
|
||||
if (this.remove(currImg))
|
||||
return (getMsg("confirm","imageDelete"));
|
||||
return (getMessage("confirm","imageDelete"));
|
||||
else
|
||||
return (getMsg("error","imageDelete"));
|
||||
return (getMessage("error","imageDelete"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,14 +20,15 @@ function renderImagelist(idx) {
|
|||
sp.text = "previous images";
|
||||
res.data.prevpage = renderSkinAsString("prevpagelink",sp);
|
||||
}
|
||||
res.data.imagelist = "";
|
||||
var imagelist = new java.lang.StringBuffer();
|
||||
for (var i=idx; i<max; i++)
|
||||
res.data.imagelist += this.get(i).renderSkinAsString("preview");
|
||||
imagelist.append(this.get(i).renderSkinAsString("preview"));
|
||||
if (i < size) {
|
||||
var sp = new Object();
|
||||
sp.url = this.href() + "?start=" + i;
|
||||
sp.text = "more images";
|
||||
res.data.nextpage = renderSkinAsString("nextpagelink",sp);
|
||||
}
|
||||
res.data.imagelist = imagelist.toString();
|
||||
return;
|
||||
}
|
||||
|
|
@ -5,12 +5,7 @@
|
|||
*/
|
||||
|
||||
function isDenied(usr) {
|
||||
if (!this._parent.userMayContrib()) {
|
||||
var membership = this._parent.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if ((membership.level & MAY_ADD_IMAGE) == 0)
|
||||
return (getMsg("error","imageAddDenied"));
|
||||
}
|
||||
if (!this._parent.usercontrib && (req.data.memberlevel & MAY_ADD_IMAGE) == 0)
|
||||
return "imageAddDenied";
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var parent = getParent();
|
||||
|
||||
res.message = getMsg("confirm","introLogin");
|
||||
res.message = getMessage("confirm","introLogin");
|
||||
|
||||
if (req.data.submit == "login" || req.data.login) {
|
||||
var result = this.evalLogin(req.data.name,req.data.password);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
if (session.user) {
|
||||
res.message = getMsg("confirm","logout",session.user.name);
|
||||
res.message = getMessage("confirm","logout",session.user.name);
|
||||
session.logout();
|
||||
session.data.referrer = null;
|
||||
res.setCookie ("avUsr", "");
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@
|
|||
*/
|
||||
|
||||
function membership_macro(param) {
|
||||
var ms = this.get(session.user.name);
|
||||
if (!ms)
|
||||
if (!req.data.memberlevel)
|
||||
return;
|
||||
res.write(getRole(ms.level));
|
||||
res.write(getRole(req.data.memberlevel));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -16,10 +15,7 @@ function membership_macro(param) {
|
|||
*/
|
||||
|
||||
function subscribelink_macro(param) {
|
||||
if (!path.site)
|
||||
return;
|
||||
var ms = this.get(session.user.name);
|
||||
if (ms)
|
||||
if (!path.site || req.data.memberlevel)
|
||||
return;
|
||||
openLink(path.site.href("subscribe"));
|
||||
res.write(param.text ? param.text : "sign up");
|
||||
|
|
@ -46,17 +42,19 @@ function subscriptionslink_macro(param) {
|
|||
function memberlist_macro(param) {
|
||||
var currLvl;
|
||||
var sp = new Object();
|
||||
sp.list = "";
|
||||
var memberlist = new java.lang.StringBuffer();
|
||||
for (var i=0;i<this.size();i++) {
|
||||
var m = this.get(i);
|
||||
if (m.level != currLvl) {
|
||||
sp.list = memberlist.toString();
|
||||
this.renderSkin("membergroup",sp);
|
||||
sp.list = "";
|
||||
sp.group = getRole(parseInt(m.level,10)); // m.getLvl();
|
||||
memberlist = new java.lang.StringBuffer();
|
||||
sp.group = getRole(m.level);
|
||||
currLvl = m.level;
|
||||
}
|
||||
sp.list += m.renderSkinAsString("preview");
|
||||
memberlist.append(m.renderSkinAsString("preview"));
|
||||
}
|
||||
sp.list = memberlist.toString();
|
||||
this.renderSkin("membergroup",sp);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditMembersDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ function evalLogin(username,password) {
|
|||
var result;
|
||||
// check if login is successful
|
||||
if (session.login(username, password)) {
|
||||
if (isUserBlocked()) {
|
||||
session.logout();
|
||||
return(getError("accountBlocked"));
|
||||
}
|
||||
// login successful
|
||||
// login was successful
|
||||
session.user.lastVisit = new Date();
|
||||
if (req.data.remember) {
|
||||
// user allowed us to set permanent cookies for auto-login
|
||||
|
|
@ -43,7 +39,7 @@ function evalRegistration(param) {
|
|||
var result;
|
||||
// check if email-address is valid
|
||||
if (!param.email)
|
||||
result = getError("emailMissing1");
|
||||
result = getError("emailMissing");
|
||||
else if (!checkEmail(param.email))
|
||||
result = getError("emailInvalid");
|
||||
|
||||
|
|
@ -82,7 +78,7 @@ function evalRegistration(param) {
|
|||
if (path.site) {
|
||||
var welcomeWhere = path.site.title;
|
||||
// if user registered within a public site, we add this site to favorites
|
||||
if (path.site.isOnline())
|
||||
if (path.site.online)
|
||||
this.addMembership(newUser);
|
||||
} else
|
||||
var welcomeWhere = root.getSysTitle();
|
||||
|
|
@ -139,7 +135,7 @@ function updateUser(param) {
|
|||
function sendPwd(email) {
|
||||
var result;
|
||||
if (!email)
|
||||
result = getError("emailMissing2");
|
||||
result = getError("emailMissing");
|
||||
else {
|
||||
var sqlClause = "select USER_NAME,USER_PASSWORD from AV_USER where USER_EMAIL = '" + email + "'";
|
||||
var dbConn = getDBConnection("antville");
|
||||
|
|
@ -160,7 +156,7 @@ function sendPwd(email) {
|
|||
var mail = new Mail();
|
||||
mail.setFrom(root.sys_email);
|
||||
mail.addTo(email);
|
||||
mail.setSubject(getMsg("mailsubject","sendPwd"));
|
||||
mail.setSubject(getMessage("mailsubject","sendPwd"));
|
||||
var mailParam = new Object();
|
||||
var now = new Date();
|
||||
mailParam.timestamp = formatTimestamp(now);
|
||||
|
|
@ -246,7 +242,7 @@ function evalNewMembership(uname,creator) {
|
|||
var mail = new Mail();
|
||||
mail.setFrom(path.site.email ? path.site.email : creator.email);
|
||||
mail.setTo(u.email);
|
||||
mail.setSubject(getMsg("mailsubject","newMember",path.site.title));
|
||||
mail.setSubject(getMessage("mailsubject","newMember",path.site.title));
|
||||
var skinParam = new Object();
|
||||
skinParam.site = path.site.title;
|
||||
skinParam.creator = creator.name;
|
||||
|
|
@ -309,4 +305,4 @@ function deleteAll() {
|
|||
this.remove(member);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,16 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="small" valign="top" nowrap="nowrap">eMail:</td>
|
||||
<td><% input type="text" name="email" %><br>
|
||||
<span class="small"><% input type="checkbox" name="publishemail" %>if you select this the eMail-address above might appear public.</span></td>
|
||||
<td><% input type="text" name="email" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="small" valign="top" nowrap="nowrap">Link:*</td>
|
||||
<td class="small" valign="top" nowrwap="nowrap">publish eMail:</td>
|
||||
<td><span class="small"><% input type="checkbox" name="publishemail" %><br>If you select this the eMail-address your entered above will be visible to Administrators.</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="small" valign="top" nowrap="nowrap">Personal URL:</td>
|
||||
<td><% input type="text" name="url" %><br>
|
||||
<span class="small">If you enter an eMail-address or a URL here, your Username will appear as link.</span></td>
|
||||
<span class="small">If you enter an eMail-address or URL here, your username will appear as link in the stories or comments you created (eMail-addresses will appear as <i>mailto:</i>-link)</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap="nowrap"> </td>
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
*/
|
||||
|
||||
function isEditMembersDenied(usr) {
|
||||
var membership = this.get(usr.name);
|
||||
if (!membership || (membership.level & MAY_EDIT_MEMBERS) == 0)
|
||||
return (getMsg("error","memberEditDenied"));
|
||||
if ((req.data.memberlevel & MAY_EDIT_MEMBERS) == 0)
|
||||
return ("memberEditDenied");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = path.membermgr.isEditMembersDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.membermgr.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this._parent.isEditMembersDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ function username_macro(param) {
|
|||
*/
|
||||
|
||||
function email_macro(param) {
|
||||
if (this.user.isEmailPublic())
|
||||
if (this.user.publishemail)
|
||||
return (this.user.email);
|
||||
return ("**********");
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ function level_macro(param) {
|
|||
// renderDropDownBox("level",options,null,"-- select --");
|
||||
renderDropDownBox("level", ROLES, null, "-- select --");
|
||||
} else
|
||||
res.write(getRole(parseInt(this.level,10)));
|
||||
res.write(getRole(this.level));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -60,7 +60,7 @@ function sitetitle_macro(param) {
|
|||
*/
|
||||
|
||||
function deletelink_macro(param) {
|
||||
if (this.level == getAdminLvl())
|
||||
if (this.level == ADMIN)
|
||||
return;
|
||||
openLink(this.href("delete"));
|
||||
res.write(param.text ? param.text : "remove");
|
||||
|
|
@ -77,4 +77,4 @@ function unsubscribelink_macro(param) {
|
|||
openLink(this.site.href("unsubscribe"));
|
||||
res.write(param.text ? param.text : "unsubscribe");
|
||||
closeLink();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ function updateMembership(lvl,modifier) {
|
|||
if (this.user == modifier)
|
||||
return (getError("memberEditSelfDenied"));
|
||||
if (lvl == 1)
|
||||
this.level = getContributorLvl();
|
||||
this.level = CONTRIBUTOR;
|
||||
else if (lvl == 2)
|
||||
this.level = getContentManagerLvl();
|
||||
this.level = CONTENTMANAGER;
|
||||
else if (lvl == 3)
|
||||
this.level = getAdminLvl();
|
||||
this.level = ADMIN;
|
||||
else
|
||||
this.level = 0;
|
||||
this.modifytime = new Date();
|
||||
|
|
@ -36,7 +36,7 @@ function sendConfirmationMail(fromEmail) {
|
|||
var mail = new Mail();
|
||||
mail.setFrom(fromEmail);
|
||||
mail.addTo(this.user.email);
|
||||
mail.setSubject(getMsg("mailsubject","statusChange",this.site.title));
|
||||
mail.setSubject(getMessage("mailsubject","statusChange",this.site.title));
|
||||
mail.setText(this.renderSkinAsString("mailbody"));
|
||||
mail.send();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDeleteDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(session.data.referrer ? path.site.members.href("login") : this.href());
|
||||
}
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ if (req.data.submit == "cancel" || req.data.cancel) {
|
|||
res.message = result.message;
|
||||
session.data.referrer = null;
|
||||
if (!result.error)
|
||||
res.redirect(result.url);
|
||||
res.redirect(path.site.polls.href());
|
||||
}
|
||||
|
||||
var len = 0
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@
|
|||
<table border="0" cellspacing="0" cellpadding="3">
|
||||
<form method="post" action="<% response.action %>">
|
||||
<tr>
|
||||
<td nowrap="nowrap"><span class="small">Title:</span><br />
|
||||
<% poll.title as="editor" width="24" style="formTitle" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap="nowrap"><span class="small">Question:</span><br />
|
||||
<% poll.question as="editor" width="30" height="3" style="formText" %></td>
|
||||
</tr>
|
||||
|
|
@ -15,7 +11,7 @@
|
|||
|
||||
<tr>
|
||||
<td nowrap="nowrap"><br /><% input type="button" name="save" value="save" %> <% input type="button" value="add choice" %> <% input type="button" name="cancel" value="cancel" %>
|
||||
<p class="small"><% poll.info %></p></td>
|
||||
<p class="small">created by <% poll.creator %> on <% poll.createtime format="short" %>.</p></td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
created by <% poll.creator %> on <% poll.createtime format="short" %>.
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
<td colspan="3" class="small"><% poll.creator as="link" %>, <% poll.createtime format="short" %> (<% poll.total no="votes" one="vote" more="votes" %>)</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><span class="storyTitle"><% poll.title suffix="<br />" %></span><% poll.question limit="200" suffix=" ..." %></td>
|
||||
<td><b><% poll.question %></b></td>
|
||||
<td width="10" nowrap="nowrap"> </td>
|
||||
<td align="right" class="small" nowrap="nowrap"><% poll.viewlink prefix="... " suffix="<br />" %><% poll.editlink prefix="... " suffix="<br />" %><% poll.closelink prefix="... " suffix="<br />" %><% poll.deletelink prefix="... " %></td>
|
||||
<td align="right" class="small" nowrap="nowrap"><% poll.viewlink prefix="... " suffix="<br />" %><% poll.link to="results" text="results" prefix="... " suffix="<br />" %><% poll.editlink prefix="... " suffix="<br />" %><% poll.closelink prefix="... " suffix="<br />" %><% poll.deletelink prefix="... " %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -119,15 +119,12 @@ function results_macro(param2) {
|
|||
|
||||
function total_macro(param) {
|
||||
var n = this.votes.size();
|
||||
if (n == 0) {
|
||||
if (n == 0)
|
||||
n += " " + (param.no ? param.no : "votes");
|
||||
}
|
||||
else if (n == 1) {
|
||||
else if (n == 1)
|
||||
n += " " + (param.one ? param.one : "vote");
|
||||
}
|
||||
else {
|
||||
else
|
||||
n += " " + (param.more ? param.more : "votes");
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +145,7 @@ function modifytime_macro(param) {
|
|||
*/
|
||||
|
||||
function editlink_macro(param) {
|
||||
if (!this.isEditDenied(session.user)) {
|
||||
if (session.user && !this.isEditDenied(session.user)) {
|
||||
openLink(this.href("edit"));
|
||||
res.write(param.text ? param.text : "edit");
|
||||
closeLink();
|
||||
|
|
@ -162,7 +159,7 @@ function editlink_macro(param) {
|
|||
*/
|
||||
|
||||
function deletelink_macro(param) {
|
||||
if (!this.isDeleteDenied(session.user)) {
|
||||
if (session.user && !this.isDeleteDenied(session.user)) {
|
||||
openLink(this.href("delete"));
|
||||
res.write(param.text ? param.text : "delete");
|
||||
closeLink();
|
||||
|
|
@ -175,7 +172,7 @@ function deletelink_macro(param) {
|
|||
*/
|
||||
|
||||
function viewlink_macro(param) {
|
||||
if (this.isViewDenied(session.user))
|
||||
if (session.user && this.isViewDenied(session.user))
|
||||
return;
|
||||
if (this.closed || this.isVoteDenied(session.user)) {
|
||||
var url = this.href("results");
|
||||
|
|
@ -196,7 +193,7 @@ function viewlink_macro(param) {
|
|||
*/
|
||||
|
||||
function closelink_macro(param) {
|
||||
if (!this.isDeleteDenied(session.user)) {
|
||||
if (session.user && !this.isDeleteDenied(session.user)) {
|
||||
var str = this.closed ? "re-open" : "close";
|
||||
openLink(this.href("toggle"));
|
||||
res.write(param.text ? param.text : str);
|
||||
|
|
@ -214,13 +211,3 @@ function state_macro(param) {
|
|||
return(param.text + formatTimestamp(this.modifytime, param.format));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro renders some details about the poll
|
||||
*/
|
||||
|
||||
function info_macro(param) {
|
||||
if (this.creator)
|
||||
return(this.renderSkinAsString("info"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var deny = this.isVoteDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.polls.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<p class="storyTitle"><% poll.question %></p>
|
||||
<b><% poll.question %></b>
|
||||
<table border="0" cellspacing="2" cellpadding="2">
|
||||
<form method="post" action="<% response.action %>">
|
||||
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<tr>
|
||||
<td colspan="2"><br /><input type="submit" name="submit" value="vote"> <span class="small"><% poll.link to="results" text="view results" %></span>
|
||||
<p class="small"><% poll.info %></p></td>
|
||||
<p class="small">created by <% poll.creator %> on <% poll.createtime format="short" %>.</p></td>
|
||||
</tr>
|
||||
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,3 @@
|
|||
/**
|
||||
* function returns true if a poll is online
|
||||
* otherwise false.
|
||||
* @return Boolean
|
||||
*/
|
||||
|
||||
function isOnline() {
|
||||
if (parseInt(this.online,10))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check if poll is ok. if true, save modified poll
|
||||
* @param Object the req.data object coming in from the action
|
||||
|
|
@ -34,33 +21,25 @@ function evalPoll(param, creator) {
|
|||
}
|
||||
}
|
||||
if (param.title && param.question && creator && choiceCnt > 1) {
|
||||
var online = parseInt(param.online,10);
|
||||
var editableby = parseInt(param.editableby,10);
|
||||
|
||||
this.title = param.title;
|
||||
this.question = param.question;
|
||||
this.modifytime = new Date();
|
||||
|
||||
for (var i=this.size(); i>0; i--) {
|
||||
var ch = this.get(i-1);
|
||||
this.remove(ch);
|
||||
}
|
||||
|
||||
for (var i=0; i<param.choice_array.length; i++) {
|
||||
var title = param.choice_array[i];
|
||||
if (!title)
|
||||
continue;
|
||||
var newChoice = new choice();
|
||||
newChoice.poll = this;
|
||||
newChoice.title = title;
|
||||
newChoice.createtime = new Date();
|
||||
newChoice.modifytime = new Date();
|
||||
this.add(newChoice);
|
||||
}
|
||||
|
||||
for (var i=this.size(); i>0; i--) {
|
||||
var ch = this.get(i-1);
|
||||
this.remove(ch);
|
||||
}
|
||||
for (var i=0; i<param.choice_array.length; i++) {
|
||||
var title = param.choice_array[i];
|
||||
if (!title)
|
||||
continue;
|
||||
var newChoice = new choice();
|
||||
newChoice.poll = this;
|
||||
newChoice.title = title;
|
||||
newChoice.createtime = new Date();
|
||||
newChoice.modifytime = new Date();
|
||||
this.add(newChoice);
|
||||
}
|
||||
result = getConfirm("pollCreate");
|
||||
result.url = path.site.polls.href();
|
||||
result.id = this._id;
|
||||
} else
|
||||
result = getError("pollMissingValues");
|
||||
return(result);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var deny = this.isViewDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<p class="storyTitle"><% poll.question %></p>
|
||||
<b><% poll.question %></b>
|
||||
|
||||
<% poll.results no="votes" one="vote" more="votes" %>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@
|
|||
*/
|
||||
|
||||
function isViewDenied(usr) {
|
||||
if (this.site.isNotPublic(usr))
|
||||
return (getMsg("error","siteNotPublic"));
|
||||
return null;
|
||||
return (this.site.isNotPublic(usr));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -19,11 +17,11 @@ function isViewDenied(usr) {
|
|||
|
||||
function isVoteDenied(usr) {
|
||||
if (this.site.isNotPublic(usr))
|
||||
return (getMsg("error","siteNotPublic"));
|
||||
return ("siteNotPublic");
|
||||
if (!usr)
|
||||
return (getMsg("error","loginBefore"));
|
||||
return ("loginBefore");
|
||||
if (this.closed)
|
||||
return (getMsg("error","pollClosed"));
|
||||
return ("pollClosed");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -35,10 +33,10 @@ function isVoteDenied(usr) {
|
|||
*/
|
||||
|
||||
function isPostDenied(usr) {
|
||||
if (!this.site.isOnline() && !this.site.isUserMember(usr))
|
||||
return (getMsg("error","siteNotPublic"));
|
||||
else if (!this.site.hasDiscussions())
|
||||
return (getMsg("error","siteNoDiscussion"));
|
||||
if (!this.site.online && !req.data.memberlevel)
|
||||
return ("siteNotPublic");
|
||||
else if (!this.site.discussions)
|
||||
return ("siteNoDiscussion");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -50,16 +48,13 @@ function isPostDenied(usr) {
|
|||
*/
|
||||
|
||||
function isEditDenied(usr) {
|
||||
if (this.votes.size() > 0)
|
||||
return (getMsg("error","pollEditDenied"));
|
||||
if (this.votes.size() > 0)
|
||||
return ("pollEditDenied");
|
||||
if (this.creator != usr) {
|
||||
var membership = this.site.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if (this.editableby == null && (membership.level & MAY_EDIT_ANYSTORY) == 0)
|
||||
return (getMsg("error","storyEditDenied"));
|
||||
else if (this.editableby == 1 && (membership.level & MAY_ADD_STORY) == 0)
|
||||
return (getMsg("error","storyEditDenied"));
|
||||
if (this.editableby == null && (req.data.memberlevel & MAY_EDIT_ANYSTORY) == 0)
|
||||
return ("storyEditDenied");
|
||||
else if (this.editableby == 1 && (req.data.memberlevel & MAY_ADD_STORY) == 0)
|
||||
return ("storyEditDenied");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -73,12 +68,8 @@ function isEditDenied(usr) {
|
|||
|
||||
function isDeleteDenied(usr) {
|
||||
if (this.creator != usr) {
|
||||
var membership = this.site.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if ((membership.level & MAY_DELETE_ANYSTORY) == 0)
|
||||
return (getMsg("error","storyDeleteDenied"));
|
||||
if (!req.data.memberlevel || (membership.level & MAY_DELETE_ANYSTORY) == 0)
|
||||
return ("storyDeleteDenied");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDeleteDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(session.data.referrer ? path.site.members.href("login") : this.href());
|
||||
}
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ if (req.data.submit == "cancel" || req.data.cancel) {
|
|||
res.message = result.message;
|
||||
session.data.referrer = null;
|
||||
if (!result.error)
|
||||
res.redirect(result.url);
|
||||
res.redirect(this.href());
|
||||
}
|
||||
|
||||
var len = 0
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(session.data.referrer ? path.site.members.href("login") : path.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,8 @@ function evalNewPoll(param, creator) {
|
|||
choiceCnt++;
|
||||
}
|
||||
}
|
||||
if (param.title && param.question && creator && choiceCnt > 1) {
|
||||
if (param.question && creator && choiceCnt > 1) {
|
||||
var newPoll = new poll();
|
||||
var online = parseInt(param.online,10);
|
||||
var editableby = parseInt(param.editableby,10);
|
||||
|
||||
newPoll.site = this._parent;
|
||||
newPoll.title = param.title;
|
||||
newPoll.question = param.question;
|
||||
|
|
@ -36,7 +33,7 @@ function evalNewPoll(param, creator) {
|
|||
for (var i=0; i<param.choice_array.length; i++) {
|
||||
var title = param.choice_array[i];
|
||||
if (!title)
|
||||
continue;
|
||||
continue;
|
||||
var newChoice = new choice();
|
||||
newChoice.poll = newPoll;
|
||||
newChoice.title = title;
|
||||
|
|
@ -45,12 +42,6 @@ function evalNewPoll(param, creator) {
|
|||
newPoll.add(newChoice);
|
||||
}
|
||||
result = getConfirm("pollCreate");
|
||||
if (newPoll.online) {
|
||||
this._parent.lastupdate = newPoll.createtime;
|
||||
result.url = newPoll.href();
|
||||
} else
|
||||
result.url = this.href();
|
||||
result.id = newPoll._id;
|
||||
result.error = false;
|
||||
} else
|
||||
result = getError("pollMissing");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ function renderPollList(idx,show) {
|
|||
res.data.prevpage = renderSkinAsString("prevpagelink",sp);
|
||||
}
|
||||
|
||||
res.data.pollList = "";
|
||||
var plist = new java.lang.StringBuffer();
|
||||
var sp = new Object();
|
||||
while (cnt < max && idx < size) {
|
||||
var render = true;
|
||||
var st = this.get(idx);
|
||||
|
|
@ -33,12 +34,11 @@ function renderPollList(idx,show) {
|
|||
else if (show == "mypolls" && st.creator != session.user)
|
||||
render = false;
|
||||
if (render) {
|
||||
var sp = new Object();
|
||||
sp.poll = st.renderSkinAsString("listitem");
|
||||
if (st.closed)
|
||||
res.data.pollList += this.renderSkinAsString("closedpoll",sp);
|
||||
plist.append(this.renderSkinAsString("closedpoll",sp));
|
||||
else
|
||||
res.data.pollList += this.renderSkinAsString("openpoll",sp);
|
||||
plist.append(this.renderSkinAsString("openpoll",sp));
|
||||
cnt++;
|
||||
}
|
||||
idx++;
|
||||
|
|
@ -49,5 +49,6 @@ function renderPollList(idx,show) {
|
|||
sp.text = "more polls";
|
||||
res.data.nextpage = renderSkinAsString("nextpagelink",sp);
|
||||
}
|
||||
res.data.pollList = plist.toString();
|
||||
return;
|
||||
}
|
||||
|
|
@ -6,12 +6,7 @@
|
|||
*/
|
||||
|
||||
function isDenied(usr) {
|
||||
if (!this._parent.userMayContrib()) {
|
||||
var membership = this._parent.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if ((membership.level & MAY_ADD_STORY) == 0)
|
||||
return (getMsg("error","pollAddDenied"));
|
||||
}
|
||||
if (!this._parent.usercontrib && (req.data.memberlevel & MAY_ADD_STORY) == 0)
|
||||
return "pollAddDenied";
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,10 @@
|
|||
*/
|
||||
|
||||
function safescripts_action() {
|
||||
if (req.lastModified)
|
||||
res.notModified();
|
||||
else {
|
||||
res.contentType = "text/javascript";
|
||||
res.lastModified = new Date();
|
||||
this.renderSkin("safescripts");
|
||||
}
|
||||
res.digest();
|
||||
res.contentType = "text/javascript";
|
||||
this.renderSkin("safescripts");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ function checkAccessPermission (blogid, postid, username, password) {
|
|||
throwError ("User "+username+" does not exist on this server");
|
||||
if (user.password != password)
|
||||
throwError ("Authentication failed for user "+username);
|
||||
if (user.isBlocked())
|
||||
if (user.blocked)
|
||||
throwError ("Sorry, you can't post to this weblog");
|
||||
if (!blogid && !postid)
|
||||
throwError ("Invalide blog or post id: "+blogid);
|
||||
|
|
@ -68,7 +68,7 @@ function checkAccessPermission (blogid, postid, username, password) {
|
|||
var blog = this.get (blogid.toString());
|
||||
if (!blog)
|
||||
throwError ("Weblog "+blogid+" not found on this server");
|
||||
if (!blog.userMayContrib()) {
|
||||
if (!blog.usercontrib) {
|
||||
var status = blog.members.get (username);
|
||||
if (!status || (status.level & MAY_ADD_STORY) == 0)
|
||||
throwError ("You don't have permission to post to this weblog");
|
||||
|
|
|
|||
|
|
@ -3,13 +3,18 @@ res.data.title = root.getSysTitle();
|
|||
// check if this installation is already configured
|
||||
// if not, we display the welcome-page as frontpage
|
||||
if (!root.sys_issetup) {
|
||||
if (!root.users.size())
|
||||
if (!root.users.size()) {
|
||||
res.data.body = this.renderSkinAsString("welcome");
|
||||
else
|
||||
root.renderSkin("page");
|
||||
return;
|
||||
} else
|
||||
res.redirect(this.manage.href("setup"));
|
||||
} else
|
||||
res.data.body = this.renderSkinAsString("main");
|
||||
}
|
||||
|
||||
root.renderSkin("page");
|
||||
|
||||
logAccess();
|
||||
if (path.site) {
|
||||
path.site.main_action();
|
||||
} else {
|
||||
res.data.body = root.renderSkinAsString("main");
|
||||
root.renderSkin("page");
|
||||
logAccess();
|
||||
}
|
||||
|
|
@ -9,5 +9,5 @@ Number of weblogs hosted here: <% root.sitecounter count="all" %><br />
|
|||
Public accessible weblogs: <% root.sitecounter %><br />
|
||||
Last updated weblogs:
|
||||
<ul>
|
||||
<% sitelist limit="25" %>
|
||||
<% sitelist limit="25" %>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function createNewSite(title,alias,creator) {
|
|||
newSite.usersignup = 1;
|
||||
newSite.archive = 1;
|
||||
newSite.blocked = 0;
|
||||
newSite.trusted = (creator.isTrusted() ? 1 : 0);
|
||||
newSite.trusted = creator.trusted;
|
||||
newSite.bgcolor = "ffffff";
|
||||
newSite.textfont = "Verdana, Helvetica, Arial, sans-serif";
|
||||
newSite.textsize = "13px";
|
||||
|
|
@ -72,7 +72,7 @@ function createNewSite(title,alias,creator) {
|
|||
newSite.createImgDirectory()
|
||||
if (this.add(newSite)) {
|
||||
// create membership-object for connecting user <-> site with admin-rights
|
||||
newSite.members.addMembership(creator,getAdminLvl());
|
||||
newSite.members.addMembership(creator,ADMIN);
|
||||
return (newSite);
|
||||
} else
|
||||
return null;
|
||||
|
|
@ -148,13 +148,13 @@ function searchSites (query, sid) {
|
|||
|
||||
function getLocale() {
|
||||
var locale = this.cache.locale;
|
||||
if (locale)
|
||||
if (locale)
|
||||
return locale;
|
||||
if (this.sys_language)
|
||||
locale = new java.util.Locale(this.sys_language,this.sys_country ? this.sys_country : "");
|
||||
else
|
||||
locale = java.util.Locale.getDefault();
|
||||
this.cache.locale =locale;
|
||||
this.cache.locale = locale;
|
||||
return locale;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
<br /><% response.body %></td>
|
||||
<td width="20" nowrap="nowrap"> </td>
|
||||
<td width="2" style="background-image: url(<% image name="/dot" as="url" %>);" nowrap="nowrap"><% image name="/pixel" width="2" %></td>
|
||||
<td width="198" align="right" valign="top" nowrap="nowrap"><div class="statuslight"><% now format="EEEE,' 'dd.MM.yyyy,' 'h:mm a" suffix="<br />" %>
|
||||
<td width="198" align="right" valign="top" nowrap="nowrap"><div class="statuslight"><% now format="long" suffix="<br />" %>
|
||||
<% root.loginstatus %></div>
|
||||
<div class="sep"><% image name="/pixel" width="198" %></div>
|
||||
<div class="statusdark"><% root.link to="main" text="home" prefix="... " %><br />
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ var max = req.data.max ? parseInt(req.data.max) : 25;
|
|||
max = Math.min(max, size, 50);
|
||||
|
||||
var param = new Object();
|
||||
var items = "";
|
||||
var resources = "";
|
||||
var items = new java.lang.StringBuffer();
|
||||
var resources = new java.lang.StringBuffer();
|
||||
|
||||
for (var i=0; i<max; i++) {
|
||||
var site = this.get(i);
|
||||
|
|
@ -22,8 +22,8 @@ for (var i=0; i<max; i++) {
|
|||
param.date = site.lastupdate.format("dd.MM.yyyy, HH:mm'h CET'");
|
||||
param.isodate = site.lastupdate.format(isoDateFormat);
|
||||
param.year = site.lastupdate.getYear();
|
||||
items += site.renderSkinAsString("rssItem", param);
|
||||
resources += site.renderSkinAsString("rssResource", param);
|
||||
items.append(site.renderSkinAsString("rssItem", param));
|
||||
resources.append(site.renderSkinAsString("rssResource", param));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ param.title = systitle;
|
|||
param.email = translateToEntities(root.sys_email);
|
||||
param.year = now.getYear();
|
||||
param.lastupdate = now.format(isoDateFormat);
|
||||
param.items = items;
|
||||
param.resources = resources;
|
||||
param.items = items.toString();
|
||||
param.resources = resources.toString();
|
||||
|
||||
this.renderSkin("rss", param);
|
||||
|
|
|
|||
|
|
@ -256,11 +256,43 @@ function sys_deleteAfterWarning_macro(param) {
|
|||
}
|
||||
|
||||
/**
|
||||
* macro rendering a dropdown containing all
|
||||
* macro rendering a dropdown containing all available locales
|
||||
*/
|
||||
|
||||
function localechooser_macro(param) {
|
||||
if (!isUserSysAdmin())
|
||||
return;
|
||||
renderLocaleChooser(this.getLocale());
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* macro renders a chooser for the longdateformat
|
||||
*/
|
||||
function longdateformat_macro(param) {
|
||||
if (!isUserSysAdmin())
|
||||
return;
|
||||
this.renderDateformatChooser("long");
|
||||
}
|
||||
|
||||
/**
|
||||
* macro renders a chooser for the shortdateformat
|
||||
*/
|
||||
function shortdateformat_macro(param) {
|
||||
if (!isUserSysAdmin())
|
||||
return;
|
||||
this.renderDateformatChooser("short");
|
||||
}
|
||||
|
||||
/**
|
||||
* macro renders the alias of the frontpage weblog defined
|
||||
*/
|
||||
function sys_frontSite_macro(param) {
|
||||
if (!isUserSysAdmin())
|
||||
return;
|
||||
if (param.as == "editor")
|
||||
renderInputText(this.createInputParam("sys_frontSite",param));
|
||||
else
|
||||
res.write (root.sys_frontSite);
|
||||
return;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ _children.foreign = SITE_ID
|
|||
_children.accessname = SITE_ALIAS
|
||||
_children.order = SITE_LASTUPDATE desc
|
||||
|
||||
# collections
|
||||
public = collection(site)
|
||||
public.filter = SITE_ISONLINE > 0 AND SITE_ISBLOCKED = 0
|
||||
public.order = SITE_TITLE asc
|
||||
|
|
@ -10,8 +11,6 @@ public.order = SITE_TITLE asc
|
|||
users = collection(user)
|
||||
users.accessname=USER_NAME
|
||||
|
||||
members = mountpoint(membermgr)
|
||||
|
||||
storiesByID = collection(story)
|
||||
storiesByID.filter = TEXT_PROTOTYPE = 'story' AND TEXT_ISONLINE > 0
|
||||
|
||||
|
|
@ -20,4 +19,5 @@ images.accessname = IMAGE_ALIAS
|
|||
images.filter = IMAGE_F_SITE is null and IMAGE_F_IMAGE_PARENT is null
|
||||
|
||||
# mountpoint for system manager
|
||||
manage = mountpoint(sysmgr)
|
||||
manage = mountpoint(sysmgr)
|
||||
members = mountpoint(membermgr)
|
||||
|
|
@ -3,16 +3,12 @@
|
|||
*/
|
||||
|
||||
function stylesheet_action() {
|
||||
var skin = this.skins.fetchSkin("site", "style");
|
||||
// we also check if the prefs have been changed, lately:
|
||||
var sitemod = this.isModified();
|
||||
if (skin.isModified() || sitemod) {
|
||||
res.contentType = "text/css";
|
||||
res.lastModified = sitemod ? this.modifytime : skin.modifytime;
|
||||
this.renderSkin("style");
|
||||
}
|
||||
else
|
||||
res.notModified();
|
||||
res.dependsOn(this.modifytime);
|
||||
res.dependsOn(app.skinfiles["site"]["stylesheet"]);
|
||||
res.digest();
|
||||
res.contentType = "text/css";
|
||||
this.renderSkin("style");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -21,14 +17,12 @@ function stylesheet_action() {
|
|||
*/
|
||||
|
||||
function javascript_action() {
|
||||
var skin = this.skins.fetchSkin("site", "javascript");
|
||||
if (skin.isModified()) {
|
||||
res.contentType = "text/javascript";
|
||||
res.lastModified = skin.modifytime;
|
||||
this.renderSkin("javascript");
|
||||
}
|
||||
else
|
||||
res.notModified();
|
||||
res.dependsOn(this.modifytime);
|
||||
res.dependsOn(app.skinfiles["site"]["javascript"]);
|
||||
res.digest();
|
||||
res.contentType = "text/javascript";
|
||||
this.renderSkin("javascript");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDeleteDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isEditDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ if (f) {
|
|||
res.contentType = f.mimetype;
|
||||
res.redirect(getProperty("fileUrl") + this.alias + "/" + f.name);
|
||||
} else {
|
||||
res.message = getMsg("error","fileNotFound",req.data.name);
|
||||
res.message = getMessage("error","fileNotFound",req.data.name);
|
||||
res.redirect(this.href());
|
||||
}
|
||||
|
|
@ -14,8 +14,7 @@ function title_macro(param) {
|
|||
else
|
||||
res.write("<i>[untitled]</i>");
|
||||
closeLink();
|
||||
}
|
||||
else
|
||||
} else
|
||||
res.write(this.title);
|
||||
}
|
||||
}
|
||||
|
|
@ -248,7 +247,7 @@ function hasdiscussions_macro(param) {
|
|||
if (param.as == "editor")
|
||||
renderInputCheckbox(this.createInputParam("discussions",param));
|
||||
else
|
||||
res.write(parseInt(this.discussions,10) ? "yes" : "no");
|
||||
res.write(this.discussions ? "yes" : "no");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -259,7 +258,7 @@ function usermaycontrib_macro(param) {
|
|||
if (param.as == "editor")
|
||||
renderInputCheckbox(this.createInputParam("usercontrib",param));
|
||||
else
|
||||
res.write(parseInt(this.usercontrib,10) ? "yes" : "no");
|
||||
res.write(this.usercontrib ? "yes" : "no");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -281,7 +280,7 @@ function showarchive_macro(param) {
|
|||
if (param.as == "editor")
|
||||
renderInputCheckbox(this.createInputParam("archive",param));
|
||||
else
|
||||
res.write(parseInt(this.archive,10) ? "yes" : "no");
|
||||
res.write(this.archive ? "yes" : "no");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -292,7 +291,7 @@ function enableping_macro(param) {
|
|||
if (param.as == "editor")
|
||||
renderInputCheckbox(this.createInputParam("enableping",param));
|
||||
else
|
||||
res.write(parseInt(this.enableping,10) ? "yes" : "no");
|
||||
res.write(this.enableping ? "yes" : "no");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -345,13 +344,12 @@ function navigation_macro(param) {
|
|||
}
|
||||
if (!session.user)
|
||||
return;
|
||||
var membership = this.isUserMember(session.user);
|
||||
if (!param["for"] || param["for"] == "contributors") {
|
||||
if (this.userMayContrib() || (membership && membership.level >= getContributorLvl()))
|
||||
if (this.usercontrib || req.data.memberlevel >= CONTRIBUTOR)
|
||||
this.renderSkin("contribnavigation");
|
||||
}
|
||||
if (!param["for"] || param["for"] == "admins") {
|
||||
if (membership && membership.level == getAdminLvl())
|
||||
if (req.data.memberlevel >= ADMIN)
|
||||
this.renderSkin("adminnavigation");
|
||||
}
|
||||
return;
|
||||
|
|
@ -375,35 +373,37 @@ function storylist_macro(param) {
|
|||
function calendar_macro(param) {
|
||||
// do nothing if there is not a single story :-))
|
||||
// or if archive of this site is disabled
|
||||
if (!this.allstories.size() || !this.showArchive())
|
||||
if (!this.allstories.size() || !this.archive)
|
||||
return;
|
||||
// define variables needed in this function
|
||||
var calParam = new Object();
|
||||
calParam.calendar = "";
|
||||
var dayParam = new Object();
|
||||
var weekParam = new Object();
|
||||
// init stringBuffers
|
||||
var weekBuf = new java.lang.StringBuffer();
|
||||
var calBuf = new java.lang.StringBuffer();
|
||||
|
||||
// create new calendar-object
|
||||
var cal = java.util.Calendar.getInstance(this.getTimeZone(), this.getLocale());
|
||||
var symbols = this.getDateSymbols();
|
||||
|
||||
// render header-row of calendar
|
||||
var firstDayOfWeek = cal.getFirstDayOfWeek();
|
||||
var week = "";
|
||||
var weekdays = symbols.getShortWeekdays();
|
||||
for (var i=0;i<7;i++) {
|
||||
dayParam.day = weekdays[(i+firstDayOfWeek-1)%7+1];
|
||||
week += this.renderSkinAsString("calendardayheader", dayParam);
|
||||
weekBuf.append(this.renderSkinAsString("calendardayheader", dayParam));
|
||||
}
|
||||
weekParam.week = week;
|
||||
calParam.calendar = this.renderSkinAsString("calendarweek",weekParam);
|
||||
weekParam.week = weekBuf.toString();
|
||||
calBuf.append(this.renderSkinAsString("calendarweek",weekParam));
|
||||
|
||||
cal.set(java.util.Calendar.DATE,1);
|
||||
// check whether there's a day or a story in path
|
||||
// if so, use it to determine the month to render
|
||||
if (path.story)
|
||||
var today = path.story.day;
|
||||
var today = path.story.day.toString();
|
||||
else if (path.day)
|
||||
var today = path.day.groupname;
|
||||
var today = path.day.groupname.toString();
|
||||
if (today) {
|
||||
// instead of using the global parseTimestamp-function
|
||||
// we do it manually here to avoid that a day like 20021001
|
||||
|
|
@ -411,7 +411,6 @@ function calendar_macro(param) {
|
|||
cal.set(java.util.Calendar.YEAR,parseInt(today.substring(0,4),10));
|
||||
cal.set(java.util.Calendar.MONTH,parseInt(today.substring(4,6),10)-1);
|
||||
}
|
||||
|
||||
// nr. of empty days in rendered calendar before the first day of month appears
|
||||
var pre = (7-firstDayOfWeek+cal.get(java.util.Calendar.DAY_OF_WEEK)) % 7;
|
||||
var days = cal.getActualMaximum(java.util.Calendar.DATE);
|
||||
|
|
@ -430,7 +429,7 @@ function calendar_macro(param) {
|
|||
var firstDayIndex = -1;
|
||||
|
||||
for (var i=0;i<weeks;i++) {
|
||||
weekParam.week = "";
|
||||
weekBuf = new java.lang.StringBuffer();
|
||||
for (var j=0;j<7;j++) {
|
||||
dayParam.useskin = "calendarday";
|
||||
if ((i == 0 && j < pre) || daycnt > days)
|
||||
|
|
@ -455,14 +454,16 @@ function calendar_macro(param) {
|
|||
dayParam.useskin = "calendarselday";
|
||||
daycnt++;
|
||||
}
|
||||
weekParam.week += this.renderSkinAsString(dayParam.useskin, dayParam);
|
||||
weekBuf.append(this.renderSkinAsString(dayParam.useskin, dayParam));
|
||||
}
|
||||
calParam.calendar += this.renderSkinAsString("calendarweek",weekParam);
|
||||
weekParam.week = weekBuf.toString();
|
||||
calBuf.append(this.renderSkinAsString("calendarweek",weekParam));
|
||||
}
|
||||
// set day to last day of month and try to render next month
|
||||
// check what the last day of the month is
|
||||
calParam.back = this.renderLinkToPrevMonth(firstDayIndex,currMonth+"01",monthNames);
|
||||
calParam.forward = this.renderLinkToNextMonth(lastDayIndex,currMonth+"31",monthNames);
|
||||
calParam.calendar = calBuf.toString();
|
||||
this.renderSkin("calendar",calParam);
|
||||
}
|
||||
|
||||
|
|
@ -506,7 +507,7 @@ function membercounter_macro(param) {
|
|||
* of this site
|
||||
*/
|
||||
function history_macro(param) {
|
||||
if (this.isNotPublic(session.user) && !this.isUserMember(session.user))
|
||||
if (this.isNotPublic(session.user) && !req.data.memberlevel)
|
||||
return;
|
||||
if (!param.show)
|
||||
param.show = 5;
|
||||
|
|
@ -514,7 +515,7 @@ function history_macro(param) {
|
|||
var i = 0;
|
||||
while (cnt < param.show && this.allcontent.get(i)) {
|
||||
var item = this.allcontent.get(i++);
|
||||
if (!item.story || (item.story.isOnline() && item.story.hasDiscussions())) {
|
||||
if (!item.story || (item.story.online && item.story.discussions)) {
|
||||
item.renderSkin("historyview");
|
||||
cnt++;
|
||||
}
|
||||
|
|
@ -556,24 +557,15 @@ function timezonechooser_macro(param) {
|
|||
* to a story together with the read counter et al.
|
||||
*/
|
||||
function listMostRead_macro() {
|
||||
var str = "";
|
||||
var storyList = this.mostread.list();
|
||||
storyList.sort(this.sortMostReads);
|
||||
var len = storyList.length;
|
||||
var max = 25;
|
||||
var lim = Math.min(max, len);
|
||||
var param = new Object();
|
||||
for (var i=0; i<lim; i++) {
|
||||
var s = storyList[i];
|
||||
if (s.cache.reads > 0) {
|
||||
s.reads += s.cache.reads;
|
||||
s.cache.reads = 0;
|
||||
}
|
||||
param.reads = s.reads; // + s.cache.reads;
|
||||
param.rank = i+1;
|
||||
str += s.renderSkinAsString("mostread", param);
|
||||
}
|
||||
return(str);
|
||||
var param = new Object();
|
||||
var size = this.mostread.size();
|
||||
for (var i=0; i<size; i++) {
|
||||
var s = this.mostread.get(i);
|
||||
param.reads = s.reads;
|
||||
param.rank = i+1;
|
||||
s.renderSkin("mostread", param);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -582,36 +574,31 @@ function listMostRead_macro() {
|
|||
* to a url together with the read counter et al.
|
||||
*/
|
||||
function listReferrers_macro() {
|
||||
var str = "";
|
||||
var c = getDBConnection("antville");
|
||||
var dbError = c.getLastError();
|
||||
if (dbError)
|
||||
return (getMsg("error","database",dbError));
|
||||
// we're doing this with direct db access here
|
||||
// (there's no need to do it with prototypes):
|
||||
var d = new Date(new Date() - 1000 * 60 * 60 * 24); // 24 hours ago
|
||||
var query = "select ACCESSLOG_REFERRER, count(*) as \"COUNT\" from AV_ACCESSLOG "+
|
||||
"where ACCESSLOG_F_SITE = " + this._id + " and ACCESSLOG_DATE > '" +
|
||||
d.format("yyyy-MM-dd HH:mm:ss") + "' group by ACCESSLOG_REFERRER "+
|
||||
"order by \"COUNT\" desc, ACCESSLOG_REFERRER asc;";
|
||||
var rows = c.executeRetrieval(query);
|
||||
var dbError = c.getLastError();
|
||||
if (dbError)
|
||||
return (getMsg("error","database",dbError));
|
||||
var param = new Object();
|
||||
while (rows.next()) {
|
||||
param.count = rows.getColumnItem("COUNT");
|
||||
// these two lines are necessary only for hsqldb connections:
|
||||
// 2002-06-08: but oops! this does NOT work with mysql, again...
|
||||
// (so i commented them out as i think hsqldb is abandoned, anyway)
|
||||
// if (param.count == 0);
|
||||
// continue;
|
||||
param.referrer = rows.getColumnItem("ACCESSLOG_REFERRER");
|
||||
param.text = param.referrer.length > 50 ? param.referrer.substring(0, 50) + "..." : param.referrer;
|
||||
str += this.renderSkinAsString("referrerItem", param);
|
||||
}
|
||||
rows.release();
|
||||
return(str);
|
||||
var c = getDBConnection("antville");
|
||||
var dbError = c.getLastError();
|
||||
if (dbError)
|
||||
return (getMessage("error","database",dbError));
|
||||
// we're doing this with direct db access here
|
||||
// (there's no need to do it with prototypes):
|
||||
var d = new Date();
|
||||
d.setDate(d.getDate()-1); // 24 hours ago
|
||||
var query = "select ACCESSLOG_REFERRER, count(*) as \"COUNT\" from AV_ACCESSLOG " +
|
||||
"where ACCESSLOG_F_SITE = " + this._id + " and ACCESSLOG_DATE > '" +
|
||||
d.format("yyyy-MM-dd HH:mm:ss") + "' group by ACCESSLOG_REFERRER "+
|
||||
"order by \"COUNT\" desc, ACCESSLOG_REFERRER asc;";
|
||||
var rows = c.executeRetrieval(query);
|
||||
var dbError = c.getLastError();
|
||||
if (dbError)
|
||||
return (getMessage("error","database",dbError));
|
||||
var skinParam = new Object();
|
||||
while (rows.next()) {
|
||||
skinParam.count = rows.getColumnItem("COUNT");
|
||||
skinParam.referrer = rows.getColumnItem("ACCESSLOG_REFERRER");
|
||||
skinParam.text = skinParam.referrer.length > 50 ? skinParam.referrer.substring(0, 50) + "..." : skinParam.referrer;
|
||||
this.renderSkin("referrerItem", skinParam);
|
||||
}
|
||||
rows.release();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -641,7 +628,7 @@ function searchbox_macro(param) {
|
|||
* function renders the months of the archive
|
||||
*/
|
||||
function monthlist_macro(param) {
|
||||
if (!this.stories.size() || !this.showArchive())
|
||||
if (!this.stories.size() || !this.archive)
|
||||
return;
|
||||
var size = param.limit ? Math.min(this.size(),param.limit) : this.size();
|
||||
for (var i=0;i<size;i++) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var deny = this.isNotPublic(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
session.data.referrer = this.href();
|
||||
res.redirect(this.members.href("login"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
var deny = this.isNotPublic(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.members.href("login"));
|
||||
}
|
||||
|
||||
res.data.title = this.title;
|
||||
|
||||
res.data.head = this.renderSkinAsString("javascript");
|
||||
res.data.head += this.renderSkinAsString("style");
|
||||
|
||||
res.data.body = this.renderSkinAsString("mostread");
|
||||
|
||||
this.renderSkin("page");
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
function evalPreferences(param,modifier) {
|
||||
var result;
|
||||
if (!checkEmail(param.email))
|
||||
return (getError("emailInvalid"));
|
||||
this.title = stripTags(param.title);
|
||||
|
|
@ -27,14 +26,14 @@ function evalPreferences(param,modifier) {
|
|||
this.smallfont = param.smallfont;
|
||||
this.smallsize = param.smallsize;
|
||||
this.smallcolor = param.smallcolor;
|
||||
this.days = parseInt(param.days,10);
|
||||
this.days = !isNaN(parseInt(param.days,10)) ? parseInt(param.days,10) : 3;
|
||||
if (this.online && !param.online)
|
||||
this.lastoffline = new Date();
|
||||
this.online = param.online ? parseInt(param.online,10) : 0;
|
||||
this.discussions = param.discussions ? parseInt(param.discussions,10) : 0;
|
||||
this.usercontrib = param.usercontrib ? parseInt(param.usercontrib,10) : 0;
|
||||
this.archive = param.archive ? parseInt(param.archive,10) : 0;
|
||||
this.enableping = param.enableping ? parseInt(param.enableping,10) : 0;
|
||||
this.online = param.online ? 1 : 0;
|
||||
this.discussions = param.discussions ? 1 : 0;
|
||||
this.usercontrib = param.usercontrib ? 1 : 0;
|
||||
this.archive = param.archive ? 1 : 0;
|
||||
this.enableping = param.enableping ? 1 : 0;
|
||||
// store selected locale in this.language and this.country
|
||||
var locs = java.util.Locale.getAvailableLocales();
|
||||
var newLoc = locs[parseInt(param.locale,10)];
|
||||
|
|
@ -45,10 +44,8 @@ function evalPreferences(param,modifier) {
|
|||
// store selected timezone in this.timezone
|
||||
var timezones = java.util.TimeZone.getAvailableIDs();
|
||||
var newZone = timezones[parseInt(param.timezone,10)];
|
||||
if (!newZone)
|
||||
this.timezone = null;
|
||||
else
|
||||
this.timezone =newZone;
|
||||
this.timezone = newZone ? newZone : null;
|
||||
|
||||
// reset cached locale, timezone and dateSymbols
|
||||
this.cache.locale = null;
|
||||
this.cache.timezone = null;
|
||||
|
|
@ -61,8 +58,8 @@ function evalPreferences(param,modifier) {
|
|||
|
||||
// short dateformat
|
||||
var patterns = getDefaultDateFormats("short");
|
||||
var ldf = patterns[parseInt(param.shortdateformat,10)];
|
||||
this.shortdateformat = ldf ? ldf : null;
|
||||
var sdf = patterns[parseInt(param.shortdateformat,10)];
|
||||
this.shortdateformat = sdf ? sdf : null;
|
||||
|
||||
this.modifytime = new Date();
|
||||
this.modifier = modifier;
|
||||
|
|
@ -70,24 +67,6 @@ function evalPreferences(param,modifier) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* function returns true if discussions are enabled
|
||||
* for this site
|
||||
*/
|
||||
|
||||
function hasDiscussions() {
|
||||
this.discussions;
|
||||
}
|
||||
|
||||
/**
|
||||
* function returns true if site is online
|
||||
* otherwise false
|
||||
*/
|
||||
|
||||
function isOnline() {
|
||||
this.online;
|
||||
}
|
||||
|
||||
/**
|
||||
* function creates the directory that will contain the images of this site
|
||||
*/
|
||||
|
|
@ -153,17 +132,6 @@ function sortMostReads(s1, s2) {
|
|||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* function checks if story is online in site
|
||||
* @param Obj story to check
|
||||
* @return Boolean true if online, false if not
|
||||
*/
|
||||
|
||||
function isStoryOnline(st) {
|
||||
st.online;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function deletes all assets of a site (recursive!)
|
||||
*/
|
||||
|
|
@ -177,16 +145,6 @@ function deleteAll() {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if site is trusted
|
||||
* @return Boolean true in case site is trusted, false otherwise
|
||||
*/
|
||||
|
||||
function isTrusted() {
|
||||
this.trusted;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* send notification to weblogs.com
|
||||
* that this site was updated
|
||||
|
|
@ -207,7 +165,7 @@ function ping() {
|
|||
result.message = ping.result.message;
|
||||
|
||||
if (result.error)
|
||||
app.__app__.logEvent("Error when notifying weblogs.com for updated site #" + this._id + ": " + result.message);
|
||||
app.log("Error when notifying weblogs.com for updated site \"" + this.alias + "\": " + result.message);
|
||||
|
||||
// this is the easy post url method (maybe faster?)
|
||||
// var ping = getURL("http://newhome.weblogs.com/pingSiteForm?name=" + this.title + "&url=" + this.href());
|
||||
|
|
@ -217,16 +175,3 @@ function ping() {
|
|||
this.lastping = new Date();
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function returns true if the site prefs were modified
|
||||
* lately, otherwise it returns false.
|
||||
* @return Boolean
|
||||
*/
|
||||
|
||||
function isModified() {
|
||||
if (req.lastModified && req.lastModified > this.modifytime)
|
||||
return(false);
|
||||
return(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var deny = this.isNotPublic(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.members.href("login"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
|
||||
function renderLinkToPrevMonth(firstDayIndex,currentMonth,monthNames) {
|
||||
|
||||
var l = this.size();
|
||||
if (l == 0 || l <= firstDayIndex)
|
||||
return (" ");
|
||||
|
|
@ -78,7 +77,7 @@ function renderStorylist(day) {
|
|||
}
|
||||
}
|
||||
}
|
||||
var days = parseInt(this.days,10) ? parseInt(this.days,10) : 2;
|
||||
var days = this.days ? this.days : 2;
|
||||
days = Math.min (days, 14); // render 14 days max
|
||||
this.prefetchChildren(idx, days);
|
||||
|
||||
|
|
@ -93,24 +92,12 @@ function renderStorylist(day) {
|
|||
sp.text = "newer stories";
|
||||
res.data.prevpage = renderSkinAsString("prevpagelink",sp);
|
||||
}
|
||||
days = Math.min(days++,this.size());
|
||||
var dayCnt = 0;
|
||||
res.data.storylist = "";
|
||||
while (dayCnt < days && idx < size) {
|
||||
days = Math.min(idx + days++,this.size());
|
||||
var storylist = new java.lang.StringBuffer();
|
||||
while (idx < days) {
|
||||
var day = this.get(idx++);
|
||||
// init var for incrementing daycounter
|
||||
var count = false;
|
||||
for (var i=0;i<day.size();i++) {
|
||||
var st = day.get(i);
|
||||
if (this.isStoryOnline(st)) {
|
||||
res.data.storylist += st.renderSkinAsString("preview");
|
||||
count = true;
|
||||
}
|
||||
}
|
||||
// only increment daycounter if day contains a story
|
||||
// that is online in site
|
||||
if (count)
|
||||
dayCnt++;
|
||||
for (var i=0;i<day.size();i++)
|
||||
storylist.append(day.get(i).renderSkinAsString("preview"));
|
||||
}
|
||||
if (idx < size) {
|
||||
var sp = new Object();
|
||||
|
|
@ -119,5 +106,6 @@ function renderStorylist(day) {
|
|||
sp.text = "older stories";
|
||||
res.data.nextpage = renderSkinAsString("nextpagelink",sp);
|
||||
}
|
||||
res.data.storylist = storylist.toString();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var deny = this.isNotPublic(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
session.data.referrer = this.href();
|
||||
res.redirect(this.members.href("login"));
|
||||
}
|
||||
|
|
@ -19,23 +19,23 @@ if (req.data.q) {
|
|||
var result = root.searchSites (query, this._id);
|
||||
var found = result.length;
|
||||
if (found == 0)
|
||||
res.data.body += "<i>" + getMsg("error","searchNothingFound",query) + "</i>";
|
||||
res.data.body += "<i>" + getMessage("error","searchNothingFound",query) + "</i>";
|
||||
else {
|
||||
var start = 0;
|
||||
var end = found;
|
||||
|
||||
if (found == 1)
|
||||
res.data.body += getMsg("confirm","resultOne",query);
|
||||
res.data.body += getMessage("confirm","resultOne",query);
|
||||
else if (found <= 10)
|
||||
res.data.body += getMsg("confirm","resultMany",new Array(encodeForm(query),found));
|
||||
res.data.body += getMessage("confirm","resultMany",new Array(encodeForm(query),found));
|
||||
else {
|
||||
if (req.data.start)
|
||||
start = Math.min (found-1, parseInt (req.data.start));
|
||||
if (isNaN (start))
|
||||
start = 0;
|
||||
end = Math.min (found, start+10);
|
||||
res.data.body += getMsg("confirm","resultMany",new Array(encodeForm(query),found));
|
||||
res.data.body += getMsg("confirm","resultDisplay",new Array(start+1,end));
|
||||
res.data.body += getMessage("confirm","resultMany",new Array(encodeForm(query),found));
|
||||
res.data.body += getMessage("confirm","resultDisplay",new Array(start+1,end));
|
||||
}
|
||||
|
||||
res.data.body += "<br />";
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
*/
|
||||
|
||||
function isNotPublic(usr) {
|
||||
if (!this.isOnline()) {
|
||||
if (usr && usr.isSysAdmin())
|
||||
if (!this.online) {
|
||||
if (usr && usr.sysadmin)
|
||||
return null;
|
||||
else if (usr && this.isUserMember(usr))
|
||||
else if (req.data.memberlevel)
|
||||
return null;
|
||||
return (getMsg("error","siteNotPublic"));
|
||||
return "siteNotPublic";
|
||||
}
|
||||
return null;
|
||||
|
||||
|
|
@ -23,11 +23,10 @@ function isNotPublic(usr) {
|
|||
*/
|
||||
|
||||
function isEditDenied(usr) {
|
||||
if (usr.isSysAdmin())
|
||||
if (usr.sysadmin)
|
||||
return null;
|
||||
var membership = this.isUserMember(usr);
|
||||
if (!membership || (membership.level & MAY_EDIT_PREFS) == 0)
|
||||
return (getMsg("error","siteEditDenied"));
|
||||
if ((req.data.memberlevel & MAY_EDIT_PREFS) == 0)
|
||||
return "siteEditDenied";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -39,23 +38,11 @@ function isEditDenied(usr) {
|
|||
*/
|
||||
|
||||
function isDeleteDenied(usr) {
|
||||
if (!usr.isSysAdmin() && usr != this.creator)
|
||||
return (getMsg("error","siteDeleteDenied"));
|
||||
if (!usr.sysadmin && usr != this.creator)
|
||||
return "siteDeleteDenied";
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* function checks if user is a member of this site
|
||||
* @param Obj Userobject
|
||||
* @return Obj null in case user is not a member, otherwise member-object
|
||||
*/
|
||||
|
||||
function isUserMember(usr) {
|
||||
if (!usr)
|
||||
return null;
|
||||
return (this.members.get(usr.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* function checks if user is allowed to sign up
|
||||
* @param Obj Userobject
|
||||
|
|
@ -63,10 +50,10 @@ function isUserMember(usr) {
|
|||
*/
|
||||
|
||||
function isSubscribeDenied(usr) {
|
||||
if (this.isUserMember(usr))
|
||||
return (getMsg("error","subscriptionExist"));
|
||||
else if (!this.isOnline())
|
||||
return (getMsg("error","siteNotPublic"));
|
||||
if (req.data.memberlevel)
|
||||
return "subscriptionExist";
|
||||
else if (!this.online)
|
||||
return "siteNotPublic";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -77,39 +64,10 @@ function isSubscribeDenied(usr) {
|
|||
*/
|
||||
|
||||
function isUnsubscribeDenied(usr) {
|
||||
var membership = this.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","subscriptionNoExist"));
|
||||
else if (membership.level > 0)
|
||||
return (getMsg("error","unsubscribeDenied",getRole(membership.level)));
|
||||
if (req.data.memberlevel)
|
||||
return "subscriptionNoExist";
|
||||
else if (req.data.memberlevel > 0)
|
||||
return "unsubscribeDenied";
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* function checks if normal users are allowed to
|
||||
* contribute to this site
|
||||
* @return Boolean true if members may contribute, false if not
|
||||
*/
|
||||
|
||||
function userMayContrib() {
|
||||
this.usercontrib;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function checks if archive of site is enabled
|
||||
* @return Boolean true if archive is enabled, false if not
|
||||
*/
|
||||
|
||||
function showArchive() {
|
||||
this.archive;
|
||||
}
|
||||
|
||||
/**
|
||||
* function checks if site is blocked
|
||||
* @return Boolean true if site is blocked, otherwise false
|
||||
*/
|
||||
|
||||
function isBlocked() {
|
||||
this.blocked;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isSubscribeDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.href());
|
||||
}
|
||||
|
||||
// create a new member-object and add it to membership-mountpoint
|
||||
this.members.addMembership(session.user);
|
||||
res.message = getMsg("confirm","subscriptionCreate",this.title);
|
||||
res.message = getMessage("confirm","subscriptionCreate",this.title);
|
||||
res.redirect(this.href());
|
||||
|
|
@ -26,13 +26,13 @@ function sysmgr_statusflags_macro(param) {
|
|||
// this macro is allowed just for sysadmins
|
||||
if (!isUserSysAdmin())
|
||||
return;
|
||||
if (this.isTrusted())
|
||||
if (this.trusted)
|
||||
res.write("<span class=\"flagltgreen\" nowrap>TRUSTED</span>");
|
||||
if (!parseInt(this.online))
|
||||
if (!this.online)
|
||||
res.write("<span class=\"flagred\" nowrap>PRIVATE</span>");
|
||||
else
|
||||
res.write("<span class=\"flagdkgreen\" nowrap>PUBLIC</span>");
|
||||
if (this.isBlocked())
|
||||
if (this.blocked)
|
||||
res.write("<span class=\"flagblack\" nowrap>BLOCKED</span>");
|
||||
}
|
||||
|
||||
|
|
@ -94,10 +94,9 @@ function sysmgr_trusted_macro(param) {
|
|||
return;
|
||||
if (param.as == "editor") {
|
||||
var options = new Array("no","yes");
|
||||
var selectedIndex = parseInt(this.trusted,10);
|
||||
renderDropDownBox("trusted",options,selectedIndex);
|
||||
renderDropDownBox("trusted",options,this.trusted);
|
||||
} else
|
||||
res.write(this.isTrusted() ? "yes" : "no");
|
||||
res.write(this.trusted ? "yes" : "no");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,8 +109,7 @@ function sysmgr_blocked_macro(param) {
|
|||
return;
|
||||
if (param.as == "editor") {
|
||||
var options = new Array("no","yes");
|
||||
var selectedIndex = parseInt(this.blocked,10);
|
||||
renderDropDownBox("blocked",options,selectedIndex);
|
||||
renderDropDownBox("blocked",options,this.blocked);
|
||||
} else
|
||||
res.write(this.isBlocked() ? "yes" : "no");
|
||||
res.write(this.blocked ? "yes" : "no");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,3 +88,4 @@ mostread.local = SITE_ID
|
|||
mostread.foreign = TEXT_F_SITE
|
||||
mostread.filter = TEXT_PROTOTYPE = 'story' AND TEXT_ISONLINE > 0
|
||||
mostread.order = TEXT_READS desc
|
||||
mostread.maxSize = 25
|
||||
|
|
@ -3,7 +3,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isUnsubscribeDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.members.href("subscriptions"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDeleteDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(this.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
/**
|
||||
* This function returns true if a skin was created or modified
|
||||
* lately, otherwise it returns false.
|
||||
* @return Boolean
|
||||
*/
|
||||
|
||||
function isModified() {
|
||||
if (this && req.lastModified) {
|
||||
// checking for both createtime and modifytime since
|
||||
// modifytime was not set in previous versions:
|
||||
if (this.createtime && !this.modifytime || req.lastModified > this.modifytime)
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
|
@ -5,11 +5,8 @@
|
|||
*/
|
||||
|
||||
function isDeleteDenied(usr) {
|
||||
var membership = this.site.isUserMember(usr);
|
||||
if (!membership)
|
||||
return (getMsg("error","userNoMember"));
|
||||
else if ((membership.level & MAY_EDIT_SKINS) == 0)
|
||||
return (getMsg("error","skinDeleteDenied"));
|
||||
if ((req.data.memberlevel & MAY_EDIT_SKINS) == 0)
|
||||
return "skinDeleteDenied";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
67
code/SkinMgr/diff.hac
Normal file
67
code/SkinMgr/diff.hac
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.site.href());
|
||||
}
|
||||
|
||||
if (!req.data.proto || !req.data.name ||
|
||||
!this[req.data.proto] ||
|
||||
!this[req.data.proto][req.data.name] ||
|
||||
!app.skinfiles[req.data.proto])
|
||||
{
|
||||
res.writeln ("Invalid Parameters. No Diff.");
|
||||
return;
|
||||
}
|
||||
|
||||
// get the modified and original skins
|
||||
var modifiedSkin = this[req.data.proto][req.data.name].skin;
|
||||
var originalSkin = app.skinfiles[req.data.proto][req.data.name];
|
||||
|
||||
if (originalSkin == null || modifiedSkin == null) {
|
||||
res.writeln ("Invalid Parameters. No Diff.");
|
||||
return;
|
||||
}
|
||||
|
||||
res.writeln ("<h3>Diffs for "+req.data.proto+"/"+req.data.name+"</h3>");
|
||||
|
||||
// split the strings into arrays of lines
|
||||
var orig = originalSkin.split(new RegExp("\r\n|\r|\n"));
|
||||
var mod = modifiedSkin.split(new RegExp("\r\n|\r|\n"));
|
||||
|
||||
// create the Diff object
|
||||
var diff = new Packages.helma.util.Diff (orig, mod);
|
||||
|
||||
// get the diff.
|
||||
var d = diff.diff ();
|
||||
|
||||
// print an short explanation of the output format
|
||||
if (d) {
|
||||
res.write ("<span style=\"background: #FF3333\"> </span> ");
|
||||
res.writeln (" Lines removed from original skin");
|
||||
res.write ("<span style=\"background: #33CC33\"> </span> ");
|
||||
res.writeln (" Lines added to modified skin");
|
||||
} else {
|
||||
res.writeln ("No visible changes between original and modified skin.");
|
||||
}
|
||||
|
||||
// run through the modified skin. for each line that is changed,
|
||||
// print the deleted lines from the original version and the new
|
||||
// lines in the modified version.
|
||||
res.write ("<pre>");
|
||||
for (var i=0; i<mod.length; i++) {
|
||||
if (d && i == d.line1) {
|
||||
if (d.deleted) {
|
||||
for (var j=d.line0; j<d.line0+d.deleted; j++)
|
||||
res.write ((j+1)+" DEL <span style=\"background: #FF3333\">"+encode(orig[j])+"</span>\r\n");
|
||||
}
|
||||
if (d.inserted) {
|
||||
for (var j=d.line1; j<d.line1+d.inserted; j++)
|
||||
res.write ((j+1)+" INS <span style=\"background: #33CC33\">"+encode(mod[j])+"</span>\r\n");
|
||||
}
|
||||
i = d.line1 + d.inserted -1;
|
||||
d = d.link;
|
||||
} else {
|
||||
res.write ((i+1)+" <span>"+encode(mod[i])+"</span>\r\n");
|
||||
}
|
||||
}
|
||||
res.write ("</pre>");
|
||||
|
|
@ -2,7 +2,7 @@ checkIfLoggedIn(this.href(req.action));
|
|||
|
||||
var deny = this.isDenied(session.user);
|
||||
if (deny) {
|
||||
res.message = deny;
|
||||
res.message = getMessage("error",deny);
|
||||
res.redirect(path.site.href());
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue