From 42e0f21580549fea56631deac1549ba39f2cb07d Mon Sep 17 00:00:00 2001 From: Robert Gaggl Date: Sun, 1 Dec 2002 19:26:40 +0000 Subject: [PATCH] merged need_for_speed branch --- antville_mysql.sql | 22 +-- code/Comment/comment.hac | 8 +- code/Comment/delete.hac | 2 +- code/Comment/edit.hac | 2 +- code/Comment/macros.js | 2 +- code/Comment/objectFunctions.js | 12 -- code/Comment/reply.skin | 2 +- code/Comment/securityFunctions.js | 13 +- code/Comment/toplevel.skin | 3 +- code/Day/main.hac | 6 +- code/Day/objectFunctions.js | 12 -- code/Day/renderFunctions.js | 10 +- code/File/delete.hac | 2 +- code/File/edit.hac | 2 +- code/File/macros.js | 4 +- code/File/securityFunction.js | 9 +- code/FileMgr/create.hac | 2 +- code/FileMgr/main.hac | 2 +- code/FileMgr/objectFunctions.js | 4 +- code/FileMgr/renderFunctions.js | 5 +- code/FileMgr/securityFunctions.js | 9 +- code/Global/macros.js | 33 ++-- code/Global/objectFunctions.js | 261 ++++++++++++++++---------- code/Global/renderFunctions.js | 35 ++-- code/Global/roles.js | 82 ++------ code/Global/securityFunctions.js | 18 +- code/HopObject/macros.js | 17 +- code/HopObject/objectFunctions.js | 55 +++--- code/HopObject/securityFunctions.js | 27 ++- code/Image/delete.hac | 2 +- code/Image/edit.hac | 2 +- code/Image/macros.js | 5 +- code/Image/main.hac | 2 - code/Image/objectFunctions.js | 14 +- code/Image/securityFunction.js | 9 +- code/Image/type.properties | 2 +- code/ImageMgr/create.hac | 2 +- code/ImageMgr/main.hac | 2 +- code/ImageMgr/objectFunctions.js | 4 +- code/ImageMgr/renderFunctions.js | 5 +- code/ImageMgr/securityFunctions.js | 9 +- code/MemberMgr/login.hac | 2 +- code/MemberMgr/logout.hac | 2 +- code/MemberMgr/macros.js | 20 +- code/MemberMgr/main.hac | 2 +- code/MemberMgr/objectFunctions.js | 18 +- code/MemberMgr/register.skin | 11 +- code/MemberMgr/securityFunctions.js | 5 +- code/Membership/delete.hac | 2 +- code/Membership/edit.hac | 2 +- code/Membership/macros.js | 8 +- code/Membership/objectFunctions.js | 8 +- code/Poll/delete.hac | 2 +- code/Poll/edit.hac | 4 +- code/Poll/edit.skin | 6 +- code/Poll/info.skin | 1 - code/Poll/listitem.skin | 6 +- code/Poll/macros.js | 27 +-- code/Poll/main.hac | 2 +- code/Poll/main.skin | 4 +- code/Poll/objectFunctions.js | 51 ++--- code/Poll/results.hac | 2 +- code/Poll/results.skin | 2 +- code/Poll/securityFunctions.js | 43 ++--- code/Poll/toggle.hac | 2 +- code/PollMgr/create.hac | 4 +- code/PollMgr/main.hac | 2 +- code/PollMgr/objectFunctions.js | 13 +- code/PollMgr/renderFunctions.js | 9 +- code/PollMgr/securityFunctions.js | 9 +- code/Root/actions.js | 11 +- code/Root/bloggerapi.js | 4 +- code/Root/main.hac | 19 +- code/Root/main.skin | 2 +- code/Root/objectFunctions.js | 8 +- code/Root/page.skin | 2 +- code/Root/rss.hac | 12 +- code/Root/sysmgr_macros.js | 34 +++- code/Root/type.properties | 6 +- code/Site/actions.js | 30 ++- code/Site/delete.hac | 2 +- code/Site/edit.hac | 2 +- code/Site/getfile.hac | 2 +- code/Site/macros.js | 131 ++++++------- code/Site/main.hac | 2 +- code/Site/mostread.hac | 5 +- code/Site/objectFunctions.js | 77 ++------ code/Site/referrers.hac | 2 +- code/Site/renderFunctions.js | 26 +-- code/Site/search.hac | 12 +- code/Site/securityFunctions.js | 76 ++------ code/Site/subscribe.hac | 4 +- code/Site/sysmgr_macros.js | 16 +- code/Site/type.properties | 1 + code/Site/unsubscribe.hac | 2 +- code/Skin/delete.hac | 2 +- code/Skin/objectFunctions.js | 15 -- code/Skin/securityFunctions.js | 7 +- code/SkinMgr/diff.hac | 67 +++++++ code/SkinMgr/edit.hac | 2 +- code/SkinMgr/macros.js | 6 +- code/SkinMgr/main.hac | 2 +- code/SkinMgr/main.skin | 2 + code/SkinMgr/objectFunctions.js | 4 +- code/SkinMgr/securityFunctions.js | 7 +- code/Story/comment.hac | 9 +- code/Story/delete.hac | 2 +- code/Story/edit.hac | 12 +- code/Story/embed.skin | 2 + code/Story/listitem.skin | 2 +- code/Story/macros.js | 58 +++--- code/Story/main.hac | 16 +- code/Story/main.skin | 2 +- code/Story/objectFunctions.js | 58 +++--- code/Story/securityFunction.js | 51 ++--- code/StoryMgr/create.hac | 8 +- code/StoryMgr/main.hac | 2 +- code/StoryMgr/objectFunctions.js | 2 +- code/StoryMgr/renderFunctions.js | 11 +- code/StoryMgr/securityFunctions.js | 9 +- code/SysMgr/cleanupFunctions.js | 8 +- code/SysMgr/objectFunctions.js | 25 ++- code/SysMgr/renderFunctions.js | 24 +-- code/SysMgr/securityFunctions.js | 21 +-- code/SysMgr/setup.skin | 12 ++ code/SysMgr/sites.hac | 2 +- code/Topic/macros.js | 6 +- code/Topic/main.skin | 3 - code/Topic/objectFunctions.js | 10 - code/Topic/renderFunctions.js | 16 +- code/TopicMgr/macros.js | 13 +- code/TopicMgr/main.hac | 2 +- code/TopicMgr/type.properties | 2 +- code/User/macros.js | 2 +- code/User/objectFunctions.js | 34 +--- code/User/sysmgr_macros.js | 21 +-- code/messages.de | 4 +- code/messages.en | 6 +- code/messages.it | 4 +- code/messages.nl | 4 +- code/shortcutmgr/main.hac | 6 +- code/shortcutmgr/securityFunctions.js | 7 +- 142 files changed, 919 insertions(+), 1147 deletions(-) delete mode 100644 code/Poll/info.skin delete mode 100644 code/Skin/objectFunctions.js create mode 100644 code/SkinMgr/diff.hac create mode 100644 code/Story/embed.skin delete mode 100644 code/Topic/objectFunctions.js diff --git a/antville_mysql.sql b/antville_mysql.sql index 88086a95..a5b5dfae 100644 --- a/antville_mysql.sql +++ b/antville_mysql.sql @@ -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 diff --git a/code/Comment/comment.hac b/code/Comment/comment.hac index 09c1d0f2..f655ede3 100644 --- a/code/Comment/comment.hac +++ b/code/Comment/comment.hac @@ -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()); } diff --git a/code/Comment/delete.hac b/code/Comment/delete.hac index dacd5459..d594bdb6 100644 --- a/code/Comment/delete.hac +++ b/code/Comment/delete.hac @@ -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()); } diff --git a/code/Comment/edit.hac b/code/Comment/edit.hac index 99999f74..293f9354 100644 --- a/code/Comment/edit.hac +++ b/code/Comment/edit.hac @@ -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()); } diff --git a/code/Comment/macros.js b/code/Comment/macros.js index af24e18a..58d7a555 100644 --- a/code/Comment/macros.js +++ b/code/Comment/macros.js @@ -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"); diff --git a/code/Comment/objectFunctions.js b/code/Comment/objectFunctions.js index 9b4fa904..44ad7502 100644 --- a/code/Comment/objectFunctions.js +++ b/code/Comment/objectFunctions.js @@ -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 diff --git a/code/Comment/reply.skin b/code/Comment/reply.skin index 9a78e958..1ac88bbc 100644 --- a/code/Comment/reply.skin +++ b/code/Comment/reply.skin @@ -3,5 +3,5 @@
<% comment.createtime format="short" prefix="on " %><% comment.creator as="link" prefix=", " suffix=" answered:"%>
<% comment.content part="title" %>
<% comment.content part="text" suffix="
" %> -
<% comment.editlink prefix="... " suffix="  " %><% comment.deletelink prefix="... " %>
+
<% comment.link text="link me" %>  <% comment.editlink prefix="... " suffix="  " %><% comment.deletelink prefix="... " %>
diff --git a/code/Comment/securityFunctions.js b/code/Comment/securityFunctions.js index 1b3e8807..70dca42e 100644 --- a/code/Comment/securityFunctions.js +++ b/code/Comment/securityFunctions.js @@ -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; } diff --git a/code/Comment/toplevel.skin b/code/Comment/toplevel.skin index 7b463b00..1812a723 100644 --- a/code/Comment/toplevel.skin +++ b/code/Comment/toplevel.skin @@ -2,6 +2,7 @@
<% comment.createtime format="short" prefix="on " %><% comment.creator as="link" prefix=", " suffix=" posted:"%>
<% comment.content part="title" %>
<% comment.content part="text" suffix="
" %> -
<% comment.replylink text="reply to this comment" suffix="  " %><% comment.editlink prefix="... " suffix="  " %><% comment.deletelink prefix="... " %>
+
<% comment.link text="link me" %><% comment.editlink prefix="... " suffix="  " %><% comment.deletelink prefix="... " %>
<% comment.comments %> +
<% this.replylink text="post your answer!" prefix="
... " %>
\ No newline at end of file diff --git a/code/Day/main.hac b/code/Day/main.hac index 12e9537e..331944c6 100644 --- a/code/Day/main.hac +++ b/code/Day/main.hac @@ -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"); \ No newline at end of file +path.site.renderSkin("page"); diff --git a/code/Day/objectFunctions.js b/code/Day/objectFunctions.js index 73bcf710..4941452e 100644 --- a/code/Day/objectFunctions.js +++ b/code/Day/objectFunctions.js @@ -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!) */ diff --git a/code/Day/renderFunctions.js b/code/Day/renderFunctions.js index cdb9ed1b..2c76d814 100644 --- a/code/Day/renderFunctions.js +++ b/code/Day/renderFunctions.js @@ -15,12 +15,9 @@ function renderStorylist() { sp.text = "newer stories"; res.data.prevpage = renderSkinAsString("prevpagelink",sp); } - res.data.storylist = ""; - for (var i=0;i= 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_" 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"; - return(result); + if (str.length<30) + return str; + var wrapped = new java.lang.StringBuffer(); + for (var i=0; i"); + } + 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" + content + ""); + 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 + ""); } diff --git a/code/Global/roles.js b/code/Global/roles.js index 2eee04da..5fc689fc 100644 --- a/code/Global/roles.js +++ b/code/Global/roles.js @@ -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"); -} \ No newline at end of file +} diff --git a/code/Global/securityFunctions.js b/code/Global/securityFunctions.js index 0379b42f..44ee1555 100644 --- a/code/Global/securityFunctions.js +++ b/code/Global/securityFunctions.js @@ -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; -} \ No newline at end of file +} diff --git a/code/HopObject/macros.js b/code/HopObject/macros.js index 84f6e090..89d527ad 100644 --- a/code/HopObject/macros.js +++ b/code/HopObject/macros.js @@ -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 */ diff --git a/code/HopObject/objectFunctions.js b/code/HopObject/objectFunctions.js index fc4fbabb..59480c97 100644 --- a/code/HopObject/objectFunctions.js +++ b/code/HopObject/objectFunctions.js @@ -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); +} \ No newline at end of file diff --git a/code/HopObject/securityFunctions.js b/code/HopObject/securityFunctions.js index ee00ad83..6b239729 100644 --- a/code/HopObject/securityFunctions.js +++ b/code/HopObject/securityFunctions.js @@ -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()); } } diff --git a/code/Image/delete.hac b/code/Image/delete.hac index 169426d9..95f10caf 100644 --- a/code/Image/delete.hac +++ b/code/Image/delete.hac @@ -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()); } diff --git a/code/Image/edit.hac b/code/Image/edit.hac index 3a27de83..2cac0000 100644 --- a/code/Image/edit.hac +++ b/code/Image/edit.hac @@ -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()); } diff --git a/code/Image/macros.js b/code/Image/macros.js index 4f27e0d7..b510e76e 100644 --- a/code/Image/macros.js +++ b/code/Image/macros.js @@ -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(); diff --git a/code/Image/main.hac b/code/Image/main.hac index 79daa783..50d8bab9 100644 --- a/code/Image/main.hac +++ b/code/Image/main.hac @@ -1,5 +1,3 @@ -autoLogin(); - res.data.title = this.site.title; res.data.body = this.renderSkinAsString("main"); diff --git a/code/Image/objectFunctions.js b/code/Image/objectFunctions.js index 03247698..d8f170cb 100644 --- a/code/Image/objectFunctions.js +++ b/code/Image/objectFunctions.js @@ -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); } diff --git a/code/Image/securityFunction.js b/code/Image/securityFunction.js index 4a6c3c2e..ce2ee47b 100644 --- a/code/Image/securityFunction.js +++ b/code/Image/securityFunction.js @@ -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; } \ No newline at end of file diff --git a/code/Image/type.properties b/code/Image/type.properties index 288b58b7..427b6cfc 100644 --- a/code/Image/type.properties +++ b/code/Image/type.properties @@ -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) diff --git a/code/ImageMgr/create.hac b/code/ImageMgr/create.hac index 9d02d275..c7b5d1df 100644 --- a/code/ImageMgr/create.hac +++ b/code/ImageMgr/create.hac @@ -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()); } diff --git a/code/ImageMgr/main.hac b/code/ImageMgr/main.hac index 4d5c8f86..c81f1c36 100644 --- a/code/ImageMgr/main.hac +++ b/code/ImageMgr/main.hac @@ -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()); } diff --git a/code/ImageMgr/objectFunctions.js b/code/ImageMgr/objectFunctions.js index 9a7e3841..6c24996a 100644 --- a/code/ImageMgr/objectFunctions.js +++ b/code/ImageMgr/objectFunctions.js @@ -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")); } /** diff --git a/code/ImageMgr/renderFunctions.js b/code/ImageMgr/renderFunctions.js index c9b32cd9..b180ac9a 100644 --- a/code/ImageMgr/renderFunctions.js +++ b/code/ImageMgr/renderFunctions.js @@ -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 eMail: -<% input type="text" name="email" %>
-<% input type="checkbox" name="publishemail" %>if you select this the eMail-address above might appear public. +<% input type="text" name="email" %> -Link:* +publish eMail: +<% input type="checkbox" name="publishemail" %>
If you select this the eMail-address your entered above will be visible to Administrators.
+ + +Personal URL: <% input type="text" name="url" %>
-If you enter an eMail-address or a URL here, your Username will appear as link. +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 mailto:-link)   diff --git a/code/MemberMgr/securityFunctions.js b/code/MemberMgr/securityFunctions.js index c1e67abe..30307fd3 100644 --- a/code/MemberMgr/securityFunctions.js +++ b/code/MemberMgr/securityFunctions.js @@ -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; } diff --git a/code/Membership/delete.hac b/code/Membership/delete.hac index db064dbc..41c81a23 100644 --- a/code/Membership/delete.hac +++ b/code/Membership/delete.hac @@ -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()); } diff --git a/code/Membership/edit.hac b/code/Membership/edit.hac index ab663a8b..0f36c9e7 100644 --- a/code/Membership/edit.hac +++ b/code/Membership/edit.hac @@ -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()); } diff --git a/code/Membership/macros.js b/code/Membership/macros.js index c3d1b670..6bb32b5c 100644 --- a/code/Membership/macros.js +++ b/code/Membership/macros.js @@ -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(); -} \ No newline at end of file +} diff --git a/code/Membership/objectFunctions.js b/code/Membership/objectFunctions.js index e086728a..91879040 100644 --- a/code/Membership/objectFunctions.js +++ b/code/Membership/objectFunctions.js @@ -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(); } diff --git a/code/Poll/delete.hac b/code/Poll/delete.hac index 02dc0bbb..c31eea4b 100644 --- a/code/Poll/delete.hac +++ b/code/Poll/delete.hac @@ -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()); } diff --git a/code/Poll/edit.hac b/code/Poll/edit.hac index ec536d06..dd0ac127 100644 --- a/code/Poll/edit.hac +++ b/code/Poll/edit.hac @@ -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 diff --git a/code/Poll/edit.skin b/code/Poll/edit.skin index 4794b365..fdf3fcdd 100644 --- a/code/Poll/edit.skin +++ b/code/Poll/edit.skin @@ -3,10 +3,6 @@ - - - @@ -15,7 +11,7 @@ +

created by <% poll.creator %> on <% poll.createtime format="short" %>.

Title:
-<% poll.title as="editor" width="24" style="formTitle" %>
Question:
<% poll.question as="editor" width="30" height="3" style="formText" %>

<% input type="button" name="save" value="save" %> <% input type="button" value="add choice" %> <% input type="button" name="cancel" value="cancel" %> -

<% poll.info %>

diff --git a/code/Poll/info.skin b/code/Poll/info.skin deleted file mode 100644 index 3dd69b92..00000000 --- a/code/Poll/info.skin +++ /dev/null @@ -1 +0,0 @@ -created by <% poll.creator %> on <% poll.createtime format="short" %>. \ No newline at end of file diff --git a/code/Poll/listitem.skin b/code/Poll/listitem.skin index 6cf7c45b..6c72be0f 100644 --- a/code/Poll/listitem.skin +++ b/code/Poll/listitem.skin @@ -3,8 +3,8 @@ <% poll.creator as="link" %>, <% poll.createtime format="short" %> (<% poll.total no="votes" one="vote" more="votes" %>) -<% poll.title suffix="
" %>
<% poll.question limit="200" suffix=" ..." %> +<% poll.question %>   -<% poll.viewlink prefix="... " suffix="
" %><% poll.editlink prefix="... " suffix="
" %><% poll.closelink prefix="... " suffix="
" %><% poll.deletelink prefix="... " %> +<% poll.viewlink prefix="... " suffix="
" %><% poll.link to="results" text="results" prefix="... " suffix="
" %><% poll.editlink prefix="... " suffix="
" %><% poll.closelink prefix="... " suffix="
" %><% poll.deletelink prefix="... " %> - \ No newline at end of file + diff --git a/code/Poll/macros.js b/code/Poll/macros.js index 1015501f..f1db9f6a 100644 --- a/code/Poll/macros.js +++ b/code/Poll/macros.js @@ -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")); -} diff --git a/code/Poll/main.hac b/code/Poll/main.hac index 12062855..4536490d 100644 --- a/code/Poll/main.hac +++ b/code/Poll/main.hac @@ -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()); } diff --git a/code/Poll/main.skin b/code/Poll/main.skin index 310617a6..976a08d5 100644 --- a/code/Poll/main.skin +++ b/code/Poll/main.skin @@ -1,4 +1,4 @@ -

<% poll.question %>

+<% poll.question %> @@ -6,7 +6,7 @@ +

created by <% poll.creator %> on <% poll.createtime format="short" %>.

diff --git a/code/Poll/objectFunctions.js b/code/Poll/objectFunctions.js index d8e87d31..510a8f14 100644 --- a/code/Poll/objectFunctions.js +++ b/code/Poll/objectFunctions.js @@ -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; i0; i--) { + var ch = this.get(i-1); + this.remove(ch); + } + for (var i=0; i<% poll.question %>

+<% poll.question %> <% poll.results no="votes" one="vote" more="votes" %> diff --git a/code/Poll/securityFunctions.js b/code/Poll/securityFunctions.js index eae034eb..e4382597 100644 --- a/code/Poll/securityFunctions.js +++ b/code/Poll/securityFunctions.js @@ -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; -} - +} \ No newline at end of file diff --git a/code/Poll/toggle.hac b/code/Poll/toggle.hac index 50161ffe..f4472aaa 100644 --- a/code/Poll/toggle.hac +++ b/code/Poll/toggle.hac @@ -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()); } diff --git a/code/PollMgr/create.hac b/code/PollMgr/create.hac index d3ff3cad..12fd6ffa 100644 --- a/code/PollMgr/create.hac +++ b/code/PollMgr/create.hac @@ -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 diff --git a/code/PollMgr/main.hac b/code/PollMgr/main.hac index 11ad94b1..321f98d0 100644 --- a/code/PollMgr/main.hac +++ b/code/PollMgr/main.hac @@ -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()); } diff --git a/code/PollMgr/objectFunctions.js b/code/PollMgr/objectFunctions.js index 2d2b11c7..5618f5e0 100644 --- a/code/PollMgr/objectFunctions.js +++ b/code/PollMgr/objectFunctions.js @@ -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
Public accessible weblogs: <% root.sitecounter %>
Last updated weblogs:
    -<% sitelist limit="25" %> +<% sitelist limit="25" %>
diff --git a/code/Root/objectFunctions.js b/code/Root/objectFunctions.js index dba9d76c..78259212 100644 --- a/code/Root/objectFunctions.js +++ b/code/Root/objectFunctions.js @@ -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; } diff --git a/code/Root/page.skin b/code/Root/page.skin index 280b8371..30fd3673 100644 --- a/code/Root/page.skin +++ b/code/Root/page.skin @@ -39,7 +39,7 @@
<% response.body %>
- - +

  <% poll.link to="results" text="view results" %> -

<% poll.info %>

  );" nowrap="nowrap"><% image name="/pixel" width="2" %>
<% now format="EEEE,' 'dd.MM.yyyy,' 'h:mm a" suffix="
" %> +
<% now format="long" suffix="
" %> <% root.loginstatus %>
<% image name="/pixel" width="198" %>
<% root.link to="main" text="home" prefix="... " %>
diff --git a/code/Root/rss.hac b/code/Root/rss.hac index 0a011bad..d47fce4b 100644 --- a/code/Root/rss.hac +++ b/code/Root/rss.hac @@ -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 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) \ No newline at end of file +manage = mountpoint(sysmgr) +members = mountpoint(membermgr) \ No newline at end of file diff --git a/code/Site/actions.js b/code/Site/actions.js index ad58d859..b1c87645 100644 --- a/code/Site/actions.js +++ b/code/Site/actions.js @@ -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; } diff --git a/code/Site/delete.hac b/code/Site/delete.hac index de491373..0e96eac8 100644 --- a/code/Site/delete.hac +++ b/code/Site/delete.hac @@ -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()); } diff --git a/code/Site/edit.hac b/code/Site/edit.hac index b4772342..284322c4 100644 --- a/code/Site/edit.hac +++ b/code/Site/edit.hac @@ -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()); } diff --git a/code/Site/getfile.hac b/code/Site/getfile.hac index af8c060f..793d0e64 100644 --- a/code/Site/getfile.hac +++ b/code/Site/getfile.hac @@ -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()); } \ No newline at end of file diff --git a/code/Site/macros.js b/code/Site/macros.js index 197a82cf..73c27e14 100644 --- a/code/Site/macros.js +++ b/code/Site/macros.js @@ -14,8 +14,7 @@ function title_macro(param) { else res.write("[untitled]"); 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 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 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 '" + - 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"; + res.data.body += "" + getMessage("error","searchNothingFound",query) + ""; 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 += "
"; diff --git a/code/Site/securityFunctions.js b/code/Site/securityFunctions.js index b45bba54..355fa4c9 100644 --- a/code/Site/securityFunctions.js +++ b/code/Site/securityFunctions.js @@ -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; -} diff --git a/code/Site/subscribe.hac b/code/Site/subscribe.hac index d3f77564..f8685dca 100644 --- a/code/Site/subscribe.hac +++ b/code/Site/subscribe.hac @@ -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()); \ No newline at end of file diff --git a/code/Site/sysmgr_macros.js b/code/Site/sysmgr_macros.js index 3f66e125..c8415cb3 100644 --- a/code/Site/sysmgr_macros.js +++ b/code/Site/sysmgr_macros.js @@ -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("TRUSTED"); - if (!parseInt(this.online)) + if (!this.online) res.write("PRIVATE"); else res.write("PUBLIC"); - if (this.isBlocked()) + if (this.blocked) res.write("BLOCKED"); } @@ -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"); } diff --git a/code/Site/type.properties b/code/Site/type.properties index a0bc88d6..6da9b9ad 100644 --- a/code/Site/type.properties +++ b/code/Site/type.properties @@ -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 \ No newline at end of file diff --git a/code/Site/unsubscribe.hac b/code/Site/unsubscribe.hac index bed1651d..23da3754 100644 --- a/code/Site/unsubscribe.hac +++ b/code/Site/unsubscribe.hac @@ -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")); } diff --git a/code/Skin/delete.hac b/code/Skin/delete.hac index fe775348..9edf7e18 100644 --- a/code/Skin/delete.hac +++ b/code/Skin/delete.hac @@ -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()); } diff --git a/code/Skin/objectFunctions.js b/code/Skin/objectFunctions.js deleted file mode 100644 index 1b12b4a9..00000000 --- a/code/Skin/objectFunctions.js +++ /dev/null @@ -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); -} diff --git a/code/Skin/securityFunctions.js b/code/Skin/securityFunctions.js index 607dbaf2..15ea043e 100644 --- a/code/Skin/securityFunctions.js +++ b/code/Skin/securityFunctions.js @@ -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; } diff --git a/code/SkinMgr/diff.hac b/code/SkinMgr/diff.hac new file mode 100644 index 00000000..f0edd296 --- /dev/null +++ b/code/SkinMgr/diff.hac @@ -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 ("

Diffs for "+req.data.proto+"/"+req.data.name+"

"); + +// 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 ("     "); + res.writeln (" Lines removed from original skin"); + res.write ("     "); + 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 ("
");
+for (var i=0; i"+encode(orig[j])+"\r\n");
+       }
+       if (d.inserted) {
+          for (var j=d.line1; j"+encode(mod[j])+"\r\n");
+       }
+       i = d.line1 + d.inserted -1;
+       d = d.link;
+    } else {
+       res.write ((i+1)+"     "+encode(mod[i])+"\r\n");
+    }
+}
+res.write ("
"); diff --git a/code/SkinMgr/edit.hac b/code/SkinMgr/edit.hac index f227c6df..06cbfd31 100644 --- a/code/SkinMgr/edit.hac +++ b/code/SkinMgr/edit.hac @@ -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()); } diff --git a/code/SkinMgr/macros.js b/code/SkinMgr/macros.js index f87c9bf0..86875450 100644 --- a/code/SkinMgr/macros.js +++ b/code/SkinMgr/macros.js @@ -21,8 +21,12 @@ function skinstatus_macro(param) { if (s.creator) { res.write("customized by " + s.creator.name); res.write(" ... "); + openLink(this.href("diff")+"?proto="+param.proto+"&name="+param.name); + res.write("diff"); + closeLink(); + res.write(" ... "); openLink(s.href("delete")); - res.write("remove skin"); + res.write("reset"); closeLink(); } else res.write("not customized"); diff --git a/code/SkinMgr/main.hac b/code/SkinMgr/main.hac index 54cce46d..03fae0db 100644 --- a/code/SkinMgr/main.hac +++ b/code/SkinMgr/main.hac @@ -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()); } diff --git a/code/SkinMgr/main.skin b/code/SkinMgr/main.skin index 36599dbe..5d14e184 100644 --- a/code/SkinMgr/main.skin +++ b/code/SkinMgr/main.skin @@ -38,6 +38,8 @@ Defines the look of the topic manager. This skin is used to display a story (it's embedded in the following three skins).
  • <% skinmgr.link to="edit" urlparam="proto=story&name=preview" text="preview" %> (<% skinmgr.skinstatus proto="story" name="preview" %>)
    This skin is used to display a story on a frontpage (either the frontpage of your weblog or the frontpage of a single day).
  • +
  • <% skinmgr.link to="edit" urlparam="proto=story&name=embed" text="embed" %> (<% skinmgr.skinstatus proto="story" name="embed" %>)
    +This skin will be used to display a story when you embed it in a skin using the <% story %>-macro.
  • <% skinmgr.link to="edit" urlparam="proto=story&name=main" text="full story" %> (<% skinmgr.skinstatus proto="story" name="main" %>)
    This skin is used to display a story in the way you defined it in the "display"-skin plus its comments.
  • <% skinmgr.link to="edit" urlparam="proto=story&name=comment" text="display on comment-page" %> (<% skinmgr.skinstatus proto="story" name="comment" %>)
    diff --git a/code/SkinMgr/objectFunctions.js b/code/SkinMgr/objectFunctions.js index 7e6a2133..a530095b 100644 --- a/code/SkinMgr/objectFunctions.js +++ b/code/SkinMgr/objectFunctions.js @@ -60,9 +60,9 @@ function saveSkin(proto,name,source,creator) { function deleteSkin(s) { if (this.get(s.proto).remove(s)) - return (getMsg("confirm","skinDelete")); + return (getMessage("confirm","skinDelete")); else - return (getMsg("error","skinDelete")); + return (getMessage("error","skinDelete")); } /** diff --git a/code/SkinMgr/securityFunctions.js b/code/SkinMgr/securityFunctions.js index 0d5471eb..7b70977b 100644 --- a/code/SkinMgr/securityFunctions.js +++ b/code/SkinMgr/securityFunctions.js @@ -5,10 +5,7 @@ */ function isDenied(usr) { - var membership = this._parent.isUserMember(usr); - if (!membership) - return (getMsg("error","userNoMember")); - else if ((membership.level & MAY_EDIT_SKINS) == 0) - return (getMsg("error","skinEditDenied")); + if ((req.data.memberlevel & MAY_EDIT_SKINS) == 0) + return "skinEditDenied"; return null; } diff --git a/code/Story/comment.hac b/code/Story/comment.hac index 16028161..16b45e41 100644 --- a/code/Story/comment.hac +++ b/code/Story/comment.hac @@ -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(this.href()); } @@ -25,4 +31,5 @@ res.data.body = this.renderSkinAsString("comment"); path.site.renderSkin("page"); +// increment read-counter this.incrementReadCounter(); \ No newline at end of file diff --git a/code/Story/delete.hac b/code/Story/delete.hac index bc9a078f..1cb59c94 100644 --- a/code/Story/delete.hac +++ b/code/Story/delete.hac @@ -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()); } diff --git a/code/Story/edit.hac b/code/Story/edit.hac index 196a2bf8..2ab5dc38 100644 --- a/code/Story/edit.hac +++ b/code/Story/edit.hac @@ -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.isEditDenied(session.user); if (deny) { - res.message = deny; + res.message = getMessage("error",deny); res.redirect(this.site.href()); } @@ -12,9 +18,11 @@ if (!session.data.referrer && req.data.http_referer) if (req.data.set) { this.toggleOnline(req.data.set); + if (req.data.http_referer) + res.redirect(req.data.http_referer); res.redirect(this.site.stories.href()); } else if (req.data.submit == "cancel" || req.data.cancel) { - if (!this.isOnline()) + if (!this.online) var url = this.site.stories.href(); else var url = session.data.referrer ? session.data.referrer : this.site.stories.href(); diff --git a/code/Story/embed.skin b/code/Story/embed.skin new file mode 100644 index 00000000..76e367e0 --- /dev/null +++ b/code/Story/embed.skin @@ -0,0 +1,2 @@ +<% story.content part="title" suffix="
    " %>
    +<% story.content part="text" limit="100" clipping=" ..." %><% story.link text="[read more]" prefix=" " to="main" %><% story.editlink prefix=" ... " %>
    \ No newline at end of file diff --git a/code/Story/listitem.skin b/code/Story/listitem.skin index c213adb4..4478e1cf 100644 --- a/code/Story/listitem.skin +++ b/code/Story/listitem.skin @@ -5,6 +5,6 @@
  • <% story.title suffix="
    " %>
    <% story.text limit="200" suffix=" ..." %>
     <% story.editlink prefix="... " suffix="
    " %><% story.viewlink prefix="... " suffix="
    " %><% story.onlinelink prefix="... " suffix="
    " %><% story.deletelink prefix="... " %>
    <% story.editlink prefix="... " suffix="
    " %><% story.viewlink prefix="... " suffix="
    " %><% story.onlinelink mode="toggle" prefix="... " suffix="
    " %><% story.deletelink prefix="... " %>
    \ No newline at end of file diff --git a/code/Story/macros.js b/code/Story/macros.js index a0bc2d0b..61c38c97 100644 --- a/code/Story/macros.js +++ b/code/Story/macros.js @@ -17,7 +17,7 @@ function content_macro(param) { param.value = this.getContentPart(param.part); param.name = "content_" + param.part; delete(param.part); - if (!param.height || parseInt(param.height) == 1) { + if (!param.height || parseInt(param.height,10) == 1) { param.value = encodeForm(param.value ? param.value : ""); renderInputText(param); } else @@ -35,15 +35,15 @@ function content_macro(param) { var part = this.getRenderedContentPart (param.part); if (!part && param.fallback) part = this.getRenderedContentPart (param.fallback); - if (param.part == "title" && param.as == "link" && !part) { - part = this.getRenderedContentPart ("text"); - param.limit = "20"; - } if (param.as == "link") { if (this._prototype != "comment") openLink(this.href()); else openLink(this.story.href()+"#"+this._id); + if (!part && param.part == "title") { + part = this.getRenderedContentPart ("text"); + param.limit = "20"; + } } if (!param.limit) res.write(part); @@ -81,9 +81,9 @@ function online_macro(param) { var options = new Array("offline","online in topic","online in weblog"); renderDropDownBox("online",options,this.online); } else { - if (!this.isOnline()) + if (!this.online) res.write("offline"); - else if (parseInt(this.online,10) < 2) { + else if (this.online < 2) { res.write("online in "); openLink(this.site.topics.get(this.topic).href()); res.write(this.topic); @@ -160,7 +160,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); @@ -176,7 +176,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")); if (param.image && this.site.images.get(param.image)) this.site.renderImage(this.site.images.get(param.image),param); @@ -192,14 +192,16 @@ function deletelink_macro(param) { */ function onlinelink_macro(param) { - if (!this.isEditDenied(session.user)) { + if (session.user && !this.isEditDenied(session.user)) { + if (this.online && param.mode != "toggle") + return; param.linkto = "edit"; - param.urlparam = "set=" + (this.isOnline() ? "offline" : "online"); + param.urlparam = "set=" + (this.online ? "offline" : "online"); openMarkupElement("a",this.createLinkParam(param)); if (param.image && this.site.images.get(param.image)) this.site.renderImage(this.site.images.get(param.image),param); else - res.write(this.isOnline() ? "set offline" : "set online"); + res.write(this.online ? "set offline" : "set online"); closeMarkupElement("a"); } } @@ -209,7 +211,7 @@ function onlinelink_macro(param) { */ function viewlink_macro(param) { - if (this.isViewDenied(session.user)) + if (session.user && this.isViewDenied(session.user)) return; openLink(this.href()); if (param.image && this.site.images.get(param.image)) @@ -224,7 +226,7 @@ function viewlink_macro(param) { */ function commentlink_macro(param) { - if (!this.hasDiscussions()) + if (!this.discussions) return; openLink(this.href(param.to ? param.to : "comment")); res.write(param.text ? param.text : "place your comment"); @@ -241,7 +243,7 @@ function commentlink_macro(param) { */ function commentcounter_macro(param) { - if (!this.hasDiscussions()) + if (!this.discussions) return; var commentCnt = this.comments.count(); if (!param.linkto) @@ -272,7 +274,7 @@ function commentcounter_macro(param) { function comments_macro(param) { var s = this.story ? this.story : this; - if (!s.hasDiscussions()) + if (!s.discussions) return; this.comments.prefetchChildren(); for (var i=0;i -
    <% story.commentlink text="place your comment!" %>  <% story.editlink prefix="... " suffix="  " %>
    +
    <% story.commentlink text="place your comment!" %>  <% story.editlink prefix="... " %>  <% story.onlinelink prefix="... " %>
    <% story.comments %> diff --git a/code/Story/objectFunctions.js b/code/Story/objectFunctions.js index ce04ab46..048a281f 100644 --- a/code/Story/objectFunctions.js +++ b/code/Story/objectFunctions.js @@ -103,14 +103,6 @@ function toggleOnline(newStatus) { return true; } -/** - * function returns true/false whether story is online or not - */ - -function isOnline() { - this.online; -} - /** * function evaluates comment and adds it if ok * @param Obj Object containing properties needed for creation of comment @@ -172,9 +164,9 @@ function deleteComment(currComment) { if (p == null) p = currComment.story; if (p.remove(currComment) && this.comments.remove(currComment)) - return(getMsg("confirm","commentDelete")); + return(getMessage("confirm","commentDelete")); else - return(getMsg("error","commentDelete")); + return(getMessage("error","commentDelete")); } /** @@ -187,17 +179,21 @@ function getRenderedContentPart (name) { var partLastRendered = this.cache["lastRendered_"+name]; if (partLastRendered <= this.modifytime || partLastRendered <= this.cache.modifytime) { + // enable caching; some macros (eg. poll, shortcut, storylist) + // will set this to false to prevent caching of a contentpart + // containing them [rg] + req.data.cachePart = true; // cached version of text is too old, so we cache it again var part = this.getContentPart (name); if (!part) return ""; var s = createSkin(format(activateLinks(part))); this.allowTextMacros(s); - if (!s.containsMacro("poll") && !s.containsMacro("shortcut") && !s.containsMacro("storylist")) - this.cache["lastRendered_"+name] = new Date(); this.cache["rendered_"+name] = this.renderSkinAsString(s); + if (req.data.cachePart) + this.cache["lastRendered_"+name] = new Date(); } - return (doWikiStuff(this.cache["rendered_"+name])); + return (this.cache["rendered_"+name]); } /** @@ -241,18 +237,6 @@ function setContent (cnt) { this.rawcontent = raw.toLowerCase(); } -/** - * incrementing the read counter for this story - * every 10 reads the cached value is made persistent - */ -function incrementReadCounter() { - this.cache.reads++; - if (this.cache.reads == 10) { - this.reads += this.cache.reads; - this.cache.reads = 0; - } -} - /** * function deletes all childobjects of a story (recursive!) */ @@ -284,11 +268,21 @@ function convertContentToXML () { } /** - * function returns true if discussions are enabled - * for this story + * function records the access to a story-object + * by incrementing the counter of the Object representing + * this story in app.data.readLog which will be stored + * in database by scheduler */ - -function hasDiscussions() { - this.discussions; -} - +function incrementReadCounter() { + // check if app.data.readLog already contains + // an Object representing this story + if (!app.data.readLog.containsKey(String(this._id))) { + var logObj = new Object(); + logObj.site = this.site.alias; + logObj.story = this._id; + logObj.reads = this.reads + 1; + app.data.readLog.put(String(this._id),logObj); + } else + app.data.readLog.get(String(this._id)).reads++; + return; +} \ No newline at end of file diff --git a/code/Story/securityFunction.js b/code/Story/securityFunction.js index 1ef0ff7b..964043c9 100644 --- a/code/Story/securityFunction.js +++ b/code/Story/securityFunction.js @@ -5,14 +5,14 @@ */ function isPostDenied(usr) { - if (usr.isSysAdmin()) + if (usr.sysadmin) return null; - if (!this.site.isOnline() && !this.site.isUserMember(usr)) - return (getMsg("error","siteNotPublic")); - else if (!this.site.hasDiscussions()) - return (getMsg("error","siteNoDiscussion")); - else if (!this.hasDiscussions()) - return (getMsg("error","storyNoDiscussion")); + if (!this.site.online && !req.data.memberlevel) + return "siteNotPublic"; + else if (!this.site.discussions) + return "siteNoDiscussion"; + else if (!this.discussions) + return "storyNoDiscussion"; return null; } @@ -23,13 +23,8 @@ function isPostDenied(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 (this.creator != usr && (req.data.memberlevel & MAY_DELETE_ANYSTORY) == 0) + return "storyDeleteDenied"; return null; } @@ -41,13 +36,10 @@ function isDeleteDenied(usr) { function isEditDenied(usr) { 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; } @@ -61,15 +53,12 @@ function isEditDenied(usr) { function isViewDenied(usr) { if (this.site.isNotPublic(usr)) - return (getMsg("error","siteNotPublic")); - else if (!this.isOnline() && 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","storyViewDenied")); - else if (this.editableby == 1 && (membership.level & MAY_ADD_STORY) == 0) - return (getMsg("error","storyViewDenied")); + return "siteNotPublic"; + else if (!this.online && this.creator != usr) { + if (this.editableby == null && (req.data.memberlevel & MAY_EDIT_ANYSTORY) == 0) + return "storyViewDenied"; + else if (this.editableby == 1 && (req.data.memberlevel & MAY_ADD_STORY) == 0) + return "storyViewDenied"; } return null; } @@ -99,4 +88,4 @@ function allowTextMacros(s) { s.allowMacro("storylist"); s.allowMacro("fakemail"); return; -} \ No newline at end of file +} diff --git a/code/StoryMgr/create.hac b/code/StoryMgr/create.hac index c0bf3aae..0e8a1736 100644 --- a/code/StoryMgr/create.hac +++ b/code/StoryMgr/create.hac @@ -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.isDenied(session.user); if (deny) { - res.message = deny; + res.message = getMessage("error",deny); res.redirect(this.href()); } diff --git a/code/StoryMgr/main.hac b/code/StoryMgr/main.hac index b11f8a81..252ba353 100644 --- a/code/StoryMgr/main.hac +++ b/code/StoryMgr/main.hac @@ -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()); } diff --git a/code/StoryMgr/objectFunctions.js b/code/StoryMgr/objectFunctions.js index 1cecc3d7..fbc7f977 100644 --- a/code/StoryMgr/objectFunctions.js +++ b/code/StoryMgr/objectFunctions.js @@ -43,7 +43,7 @@ function evalNewStory(s,param,creator) { } else { s.modifytime = s.createtime = new Date(); } - s.editableby = !isNaN(parseInt(param.editableby)) ? parseInt(param.editableby,10) : null; + s.editableby = !isNaN(parseInt(param.editableby,10)) ? parseInt(param.editableby,10) : null; s.discussions = (param.discussions_array || param.discussions == null ? 1 : 0); if (s.createtime) { // create day of story with respect to site-timezone diff --git a/code/StoryMgr/renderFunctions.js b/code/StoryMgr/renderFunctions.js index b445b377..0393b6c6 100644 --- a/code/StoryMgr/renderFunctions.js +++ b/code/StoryMgr/renderFunctions.js @@ -24,21 +24,21 @@ function renderStorylist(idx,show) { res.data.prevpage = renderSkinAsString("prevpagelink",sp); } - res.data.storylist = ""; + var storylist = new java.lang.StringBuffer(); while (cnt < max && idx < size) { var render = true; var st = this.get(idx); - if (show == "offline" && st.isOnline()) + if (show == "offline" && st.online) render = false; else if (show == "mystories" && st.creator != session.user) render = false; if (render) { var sp = new Object(); sp.story = st.renderSkinAsString("listitem"); - if (st.isOnline()) - res.data.storylist += this.renderSkinAsString("onlinestory",sp); + if (st.online) + storylist.append(this.renderSkinAsString("onlinestory",sp)); else - res.data.storylist += this.renderSkinAsString("offlinestory",sp); + storylist.append(this.renderSkinAsString("offlinestory",sp)); cnt++; } idx++; @@ -49,5 +49,6 @@ function renderStorylist(idx,show) { sp.text = "older stories"; res.data.nextpage = renderSkinAsString("nextpagelink",sp); } + res.data.storylist = storylist.toString(); return; } \ No newline at end of file diff --git a/code/StoryMgr/securityFunctions.js b/code/StoryMgr/securityFunctions.js index 1c04f5b5..f9ebf303 100644 --- a/code/StoryMgr/securityFunctions.js +++ b/code/StoryMgr/securityFunctions.js @@ -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","storyAddDenied")); - } + if (!this._parent.usercontrib && (req.data.memberlevel & MAY_ADD_STORY) == 0) + return "storyAddDenied"; return null; } diff --git a/code/SysMgr/cleanupFunctions.js b/code/SysMgr/cleanupFunctions.js index 84a7bc12..3abba586 100644 --- a/code/SysMgr/cleanupFunctions.js +++ b/code/SysMgr/cleanupFunctions.js @@ -53,7 +53,7 @@ function blockPrivateSites() { for (var i=0;i0;i--) { var site = root.get(i-1); // if site is trusted, we do nothing - if (site.isTrusted()) + if (site.trusted) continue; var idleFor = new Date() - site.lastupdate; @@ -141,7 +141,7 @@ function deleteInactiveSites() { var recipient = site.email ? site.email : site.creator.email; warning.addTo(recipient); warning.setFrom(root.sys_email); - warning.setSubject(getMsg("mailsubject","deleteWarning",site.title)); + warning.setSubject(getMessage("mailsubject","deleteWarning",site.title)); var sp = new Object(); sp.site = site.alias; sp.url = site.href(); diff --git a/code/SysMgr/objectFunctions.js b/code/SysMgr/objectFunctions.js index b07d384b..26519c2f 100644 --- a/code/SysMgr/objectFunctions.js +++ b/code/SysMgr/objectFunctions.js @@ -15,7 +15,7 @@ function searchSites(show,sort,order,keywords) { sql += "WHERE SITE_ISTRUSTED=1 "; if (keywords) { // additional keywords are given, so we're using them - var kArray = keywords.split(" "); + var kArray = stripTags(keywords).split(" "); for (var i in kArray) { var k = kArray[i]; sql += sql.length > 0 ? "AND " : "WHERE "; @@ -61,7 +61,7 @@ function searchUsers(show,sort,order,keywords) { sql += "USER_EMAIL LIKE '%" + keywords + "%' "; } else { // doing normal keyword-search - var kArray = keywords.split(" "); + var kArray = stripTags(keywords).split(" "); for (var i in kArray) { var k = kArray[i]; sql += sql.length > 0 ? "AND " : "WHERE "; @@ -100,7 +100,7 @@ function searchSyslog(show,order,keywords) { sql += "WHERE SYSLOG_TYPE = 'system' "; if (keywords) { // additional keywords are given, so we're using them - var kArray = keywords.split(" "); + var kArray = stripTags(keywords).split(" "); for (var i in kArray) { var k = kArray[i]; sql += sql.length > 0 ? "AND " : "WHERE "; @@ -156,12 +156,11 @@ function updateUser(param,admin) { else if (u == admin) result = getError("accountModifyOwn"); else { - result = getConfirm("save"); // check if this is an attempt to remove the last sysadmin var sysadmin = parseInt(param.sysadmin,10); var trust = parseInt(param.trusted,10); var block = parseInt(param.blocked,10); - if (this.sysadmins.size() == 1 && !sysadmin) + if (u.sysadmin && this.sysadmins.size() == 1) result = getError("adminDeleteLast"); else { //logging @@ -169,7 +168,7 @@ function updateUser(param,admin) { this.syslogs.add(new syslog("user",u.name,"granted sysadmin-rights",admin)); else if (sysadmin < u.sysadmin) this.syslogs.add(new syslog("user",u.name,"revoked sysadmin-rights",admin)); - u.sysadmin = parseInt(param.sysadmin,10); + u.sysadmin = sysadmin; } if (trust > u.trusted) this.syslogs.add(new syslog("user",u.name,"granted trust",admin)); @@ -181,6 +180,7 @@ function updateUser(param,admin) { this.syslogs.add(new syslog("user",u.name,"unblocked user",admin)); u.trusted = trust; u.blocked = block; + result = getConfirm("save"); } return (result); } @@ -194,6 +194,7 @@ function evalSystemSetup(param,admin) { var result; root.sys_title = param.sys_title; root.sys_url = evalURL(param.sys_url); + root.sys_frontSite = param.sys_frontSite ? param.sys_frontSite : null; // check system email if (!param.sys_email) result = getError("systemEmailMissing"); @@ -208,6 +209,17 @@ function evalSystemSetup(param,admin) { newLoc = java.util.Locale.getDefault(); root.sys_country = newLoc.getCountry(); root.sys_language = newLoc.getLanguage(); + + // long dateformat + var patterns = getDefaultDateFormats(); + var ldf = patterns[parseInt(param.longdateformat,10)]; + root.longdateformat = ldf ? ldf : null; + + // short dateformat + var patterns = getDefaultDateFormats("short"); + var sdf = patterns[parseInt(param.shortdateformat,10)]; + root.shortdateformat = sdf ? sdf : null; + root.cache.locale = null; // allow file root.sys_allowFiles = param.sys_allowFiles ? true : false; @@ -215,6 +227,7 @@ function evalSystemSetup(param,admin) { var limitArray = new Array(null,"trusted","sysAdmin"); root.sys_limitNewSites = param.sys_limitNewSites ? parseInt(param.sys_limitNewSites,10) : null; root.sys_minMemberAge = param.sys_minMemberAge ? parseInt(param.sys_minMemberAge,10) : null; + root.sys_minMemberSince = param.sys_minMemberSince ? parseTimestamp(param.sys_minMemberSince,"yyyy-MM-dd HH:mm") : null; root.sys_waitAfterNewSite = param.sys_waitAfterNewSite ? parseInt(param.sys_waitAfterNewSite,10) : null; // auto-cleanup root.sys_enableAutoCleanup = param.sys_enableAutoCleanup ? true : false; diff --git a/code/SysMgr/renderFunctions.js b/code/SysMgr/renderFunctions.js index 64221435..6ba2c532 100644 --- a/code/SysMgr/renderFunctions.js +++ b/code/SysMgr/renderFunctions.js @@ -11,7 +11,7 @@ function renderPageNavigation(collection,url,pageIdx) { var itmsPerPage = 20; var totalPages = Math.ceil(size/itmsPerPage); // init property - res.data.pagenav = ""; + var pagenav = new java.lang.StringBuffer(); // check if the passed page-index is correct if (isNaN (pageIdx)|| pageIdx > Math.ceil(size/itmsPerPage) || pageIdx < 0) pageIdx = 0; @@ -25,23 +25,24 @@ function renderPageNavigation(collection,url,pageIdx) { return; // build the navigation-bar if (pageIdx > 0) - res.data.pagenav += "prev "; + pagenav.append("prev "); var offset = Math.floor(pageIdx/10)*10; if (offset > 0) - res.data.pagenav += "[..] "; + pagenav.append("[..] "); for (var i=0;i<10;i++) { var page = offset+i; if (page >= totalPages) break; if (page == pageIdx) - res.data.pagenav += "[" + (page+1) + "] "; + pagenav.append("[" + (page+1) + "] "); else - res.data.pagenav += "[" + (page+1) + "] "; + pagenav.append("[" + (page+1) + "] "); } if (page < totalPages-1) - res.data.pagenav += "[..] "; + pagenav.append("[..] "); if (pageIdx < totalPages-1) - res.data.pagenav += "next"; + pagenav.append("next"); + res.data.pagenav = pagenav.toString(); return; } @@ -70,16 +71,17 @@ function renderList(collection,reqItem,reqAction,pageIdx) { var start = pageIdx*itmsPerPage; var stop = Math.min(start+itmsPerPage,size); - res.data.list = ""; + var list = new java.lang.StringBuffer(); for (var i=start;i<% root.sys_url as="editor" size="20" %>
    This URL will be used by Antville in the footer of various confirmation mails. You should set it to the URL of the frontpage of your Antville-Installation. +Frontpage Weblog: +<% root.sys_frontSite as="editor" size="20" %>
    If you enter the alias of a public weblog here the frontpage of this antville-installation will display the selected weblog instead of the default frontpage. + + eMail: <% root.sys_email as="editor" size="20" %>
    Antville will use this eMail-address to send various confirmation mail (e.g. when a user registers within the frontpage) @@ -23,6 +27,14 @@ <% root.localechooser %>
    This defines the language of Antville's confirm- and error-messages. If you select a language that Antville doesn't know, it will display all messages in english. Whatever language you specify here will also be the default for every new weblog created here. +Long dateformat: +<% root.longdateformat as="chooser" width="20" %> + + +Short dateformat: +<% root.shortdateformat as="chooser" width="20" %> + + Allow files: <% root.sys_allowFiles as="editor" %>
    Enabling this means that users can upload files. diff --git a/code/SysMgr/sites.hac b/code/SysMgr/sites.hac index 3add35b4..4685a5d1 100644 --- a/code/SysMgr/sites.hac +++ b/code/SysMgr/sites.hac @@ -11,7 +11,7 @@ else if (req.data.remove && req.data.item) { var result = root.deleteSite(site); res.message = result.message; } else - res.message = getMsg("error","delete",req.data.item); + res.message = getMessage("error","delete",req.data.item); res.redirect(res.data.action + "?page=" + req.data.page); } else if (req.data.save) { var result = this.updateSite(req.data,session.user); diff --git a/code/Topic/macros.js b/code/Topic/macros.js index bc284054..f07ce294 100644 --- a/code/Topic/macros.js +++ b/code/Topic/macros.js @@ -4,10 +4,7 @@ */ function addstory_macro () { - var membership = path.site.isUserMember(session.user); - if (!membership) - return; - if ((membership.level & MAY_ADD_STORY) == 0) + if ((req.data.memberlevel & MAY_ADD_STORY) == 0) return; var param = new Object(); param.link = path.site.stories.href("create")+"?topic="+this.groupname; @@ -18,6 +15,7 @@ function addstory_macro () { * Get related topics, i.e. topics that contain stories that * link back to this topic. * but avoiding self-referential backlinks + * DEPRECATED since the wiki-functionality was dropped! */ function relatedtopics_macro (param) { diff --git a/code/Topic/main.skin b/code/Topic/main.skin index 7640c5ec..f2e376e8 100644 --- a/code/Topic/main.skin +++ b/code/Topic/main.skin @@ -18,9 +18,6 @@ <% topic.addstory %> - -<% topic.relatedtopics prefix="
    Stories/Comments linking to this topic:
    " %> - diff --git a/code/Topic/objectFunctions.js b/code/Topic/objectFunctions.js deleted file mode 100644 index 0f73c5a1..00000000 --- a/code/Topic/objectFunctions.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * function checks if story is published in topic - * overwrites isStoryOnline-function of day - * @param Obj story to check - * @return Boolean true if online, false if not - */ - -function isStoryOnline(st) { - return st.online; -} diff --git a/code/Topic/renderFunctions.js b/code/Topic/renderFunctions.js index 418131fa..6834e9d7 100644 --- a/code/Topic/renderFunctions.js +++ b/code/Topic/renderFunctions.js @@ -13,28 +13,22 @@ function renderStorylist(idx) { var size = this.size(); if (idx < 0 || isNaN (idx)|| idx > size-1) idx = 0; - var cnt = 0; - var max = Math.min (10, size); + var max = Math.min (idx+10, size); if (idx > 0) { var sp = new Object(); sp.url = this.href() + "?start=" + Math.max(0, idx-10); sp.text = "previous page"; res.data.prevpage = renderSkinAsString("prevpagelink",sp); } - res.data.storylist = ""; - while (cnt < max && idx < size) { - var st = this.get(idx); - if (st.isOnline()) { - res.data.storylist += st.renderSkinAsString("preview"); - cnt++; - } - idx++; - } + var storylist = new java.lang.StringBuffer(); + while (idx < max) + storylist.append(this.get(idx++).renderSkinAsString("preview")); if (idx < size) { var sp = new Object(); sp.url = this.href() + "?start=" + idx; sp.text = "next page"; res.data.nextpage = renderSkinAsString("nextpagelink",sp); } + res.data.storylist = storylist.toString(); return; } diff --git a/code/TopicMgr/macros.js b/code/TopicMgr/macros.js index 184d79ba..0771faff 100644 --- a/code/TopicMgr/macros.js +++ b/code/TopicMgr/macros.js @@ -6,19 +6,8 @@ function topiclist_macro(param) { return; for (var i=0;i 0 _children.order = TEXT_CREATETIME desc _children.group = TEXT_TOPIC _children.group.prototype = topic diff --git a/code/User/macros.js b/code/User/macros.js index e14932e0..3dc534f5 100644 --- a/code/User/macros.js +++ b/code/User/macros.js @@ -53,7 +53,7 @@ function publishemail_macro(param) { if (param.as == "editor") renderInputCheckbox(this.createInputParam("publishemail",param)); else - res.write(this.isEmailPublic() ? "yes" : "no"); + res.write(this.publishemail ? "yes" : "no"); } /** diff --git a/code/User/objectFunctions.js b/code/User/objectFunctions.js index 79284033..31eaac25 100644 --- a/code/User/objectFunctions.js +++ b/code/User/objectFunctions.js @@ -7,7 +7,7 @@ function sendConfirmationMail(sender) { var mail = new Mail(); mail.setFrom(sender); mail.addTo(this.email); - mail.setSubject(getMsg("mailsubject","registration",root.getSysTitle())); + mail.setSubject(getMessage("mailsubject","registration",root.getSysTitle())); var mailParam = new Object(); mailParam.name = this.name; mailParam.password = this.password; @@ -16,38 +16,6 @@ function sendConfirmationMail(sender) { } -/** - * check if user is blocked - */ - -function isBlocked() { - this.blocked; -} - -/** - * check if user is trusted - */ - -function isTrusted() { - this.trusted; -} - -/** - * check if user is sysAdmin - */ - -function isSysAdmin() { - this.sysadmin; -} - -/** - * check if email is public - */ - -function isEmailPublic() { - this.publishemail; -} - /** * function for sorting member-objects by the lastupdate-timestamp * of the according site diff --git a/code/User/sysmgr_macros.js b/code/User/sysmgr_macros.js index 34dc82b0..c2d235bf 100644 --- a/code/User/sysmgr_macros.js +++ b/code/User/sysmgr_macros.js @@ -26,11 +26,11 @@ function sysmgr_statusflags_macro(param) { // this macro is allowed just for sysadmins if (!isUserSysAdmin()) return; - if (this.isTrusted()) + if (this.trusted) res.write("TRUSTED"); - if (this.isSysAdmin()) + if (this.sysadmin) res.write("SYSADMIN"); - if (this.isBlocked()) + if (this.blocked) res.write("BLOCKED"); } @@ -96,10 +96,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"); } /** @@ -112,10 +111,9 @@ 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"); } /** @@ -128,8 +126,7 @@ function sysmgr_sysadmin_macro(param) { return; if (param.as == "editor") { var options = new Array("no","yes"); - var selectedIndex = parseInt(this.sysadmin,10); - renderDropDownBox("sysadmin",options,selectedIndex); + renderDropDownBox("sysadmin",options,this.sysadmin); } else - res.write(this.isSysAdmin() ? "yes" : "no"); + res.write(this.sysadmin ? "yes" : "no"); } \ No newline at end of file diff --git a/code/messages.de b/code/messages.de index 5ecd1f0a..1c5e4846 100644 --- a/code/messages.de +++ b/code/messages.de @@ -32,9 +32,7 @@ error.imageDirNoExist = Das Verzeichnis f error.accountBlocked = Dein Konto wurde gesperrt! error.loginTypo = Anmeldung fehlgeschlagen! Hast Du Dich vertippt? // FIXME -error.emailMissing1 = Bitte trag' Deine eMail-Adresse ein! -// difference between emailMissing1 and emailMissing1? -error.emailMissing2 = Bitte trag' eine gültige eMail-Adresse ein! +error.emailMissing = Bitte trag' Deine eMail-Adresse ein! error.emailInvalid = Die eMail-Adresse, die Du angegeben hast, ist ungültig! error.emailNoAccounts = Keine Konten zu dieser eMail-Adresse gefunden! error.emailSend = Beim Versuch, die eMail abzuschicken ist ein Fehler aufgetreten! diff --git a/code/messages.en b/code/messages.en index 59a85f76..afa793aa 100644 --- a/code/messages.en +++ b/code/messages.en @@ -32,9 +32,7 @@ error.imageAddDenied = Sorry, you need to be a member of this weblog to add imag error.accountBlocked = Sorry pal, your account was disabled. Best you contact the maintainer of this site. error.loginTypo = Unfortunately, your login failed. Maybe a typo? error.loginBefore = Please login before. -error.emailMissing1 = Please enter your e-mail address. -// difference between emailMissing1 and emailMissing1? -error.emailMissing2 = Please enter your email-address. +error.emailMissing = Please enter your e-mail address. error.emailInvalid = Could not process the e-mail address. Are you sure it is correct? error.emailNoAccounts = Sorry, but this is an unregistered e-mail address. Maybe a typo? error.emailSend = Whoa, an error occurred while trying to send the e-mail. Maybe you should try again. @@ -47,7 +45,7 @@ error.memberExisting = Sorry, there is already a member with this name. Please e error.accountOldPwd = Oops, your old password is incorrect. Please re-enter it. error.resultNoUser = Sorry, your input did not match any registered user. error.userAlreadyMember = This user is already a member of this weblog. -error.userNoMember = Sorry, you're not a member of this weblog +error.shortcutEditDenied = You are not allowed to edit shortcuts. error.adminDelete = Sorry, I cannot remove an admin account. error.siteCreate = Sorry, I was not able to create your weblog. Maybe you should try again... error.siteCreateOnlyAdmins = Sorry, weblogs can be created by administrators only. diff --git a/code/messages.it b/code/messages.it index f9b2d8f4..ab952ea3 100644 --- a/code/messages.it +++ b/code/messages.it @@ -32,9 +32,7 @@ error.imageDirNoExist = Il directory per le figure non esiste o error.accountBlocked = Il tuo profilo é bloccato! error.loginTypo = Login scorretto! Prova ancora! // FIXME -error.emailMissing1 = Immettere il tuo indirizzo email! -// difference between emailMissing1 and emailMissing1? -error.emailMissing2 = Per favore specificare un indirizzo email valido! +error.emailMissing = Immettere il tuo indirizzo email! error.emailInvalid = L'indirizzo email specificato non é valido! error.emailNoAccounts = Non esiste nessun profile con questo indirizzo email! error.emailSend = Mandando un email é sucesso un errore ! diff --git a/code/messages.nl b/code/messages.nl index 0530f857..99e3d8d6 100644 --- a/code/messages.nl +++ b/code/messages.nl @@ -32,9 +32,7 @@ error.imageDirNoExist = Oeps, kan niet schrijven naar het opgegeven directory va error.accountBlocked = Sorry, maar uw account is geblokkeerd. Neem contact op met de eigenaar van deze site. error.loginTypo = Helaas is het inloggen mislukt. Misschien een typfout? // FIXME -error.emailMissing1 = Voer uw e-mail adres in. -// difference between emailMissing1 and emailMissing1? -error.emailMissing2 = Voer uw e-mail adres in. +error.emailMissing = Voer uw e-mail adres in. error.emailInvalid = Geen geldig e-mail adres. Weet u zeker dat het correct is? error.emailNoAccounts = Sorry, maar dit is een ongeregistreerd e-mail adres. Misschien een typfout? error.emailSend = Het bericht kon niet verzonden worden. Probeer het nog eens. diff --git a/code/shortcutmgr/main.hac b/code/shortcutmgr/main.hac index d44340b6..a4efb6f0 100644 --- a/code/shortcutmgr/main.hac +++ b/code/shortcutmgr/main.hac @@ -1,8 +1,8 @@ checkIfLoggedIn(this.href(req.action)); -var denied = this.isDenied(session.user); -if (denied) { - res.message = denied; +var deny = this.isDenied(session.user); +if (deny) { + res.message = getMessage("error",deny); res.redirect(path.site.href()); } diff --git a/code/shortcutmgr/securityFunctions.js b/code/shortcutmgr/securityFunctions.js index 8cdd8fc0..5037f620 100644 --- a/code/shortcutmgr/securityFunctions.js +++ b/code/shortcutmgr/securityFunctions.js @@ -6,10 +6,7 @@ */ function isDenied(usr) { - if (!this._parent.userMayContrib()) { - var membership = this._parent.isUserMember(usr); - if (!membership) - return (getMsg("error","userNoMember")); - } + if (!this._parent.usercontrib && !req.data.memberlevel) + return "shortcutEditDenied"; return null; }