2007-06-23 14:53:39 +00:00
|
|
|
|
// The Antville Project
|
|
|
|
|
|
// http://code.google.com/p/antville
|
|
|
|
|
|
//
|
2011-02-23 16:24:32 +00:00
|
|
|
|
// Copyright 2007-2011 by Tobi Schäfer.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Copyright 2001–2007 Robert Gaggl, Hannes Wallnöfer, Tobi Schäfer,
|
|
|
|
|
|
// Matthias & Michael Platzer, Christoph Lincke.
|
2007-06-23 14:53:39 +00:00
|
|
|
|
//
|
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the ``License'');
|
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
//
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
//
|
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
|
// distributed under the License is distributed on an ``AS IS'' BASIS,
|
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
//
|
|
|
|
|
|
// $Revision$
|
2011-03-23 13:35:02 +00:00
|
|
|
|
// $Author$
|
|
|
|
|
|
// $Date$
|
2007-06-23 14:53:39 +00:00
|
|
|
|
// $URL$
|
|
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
* @fileOverview Defines the extensions of Helma’s built-in
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* HopObject prototype.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2012-05-19 13:02:27 +00:00
|
|
|
|
app.addRepository('modules/helma/Aspects');
|
2012-05-13 17:05:12 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {HopObject} collection
|
2014-07-04 15:10:47 +02:00
|
|
|
|
* @param {Object} options Optional flags, e.g. to force or prevent any
|
2010-01-10 14:40:36 +00:00
|
|
|
|
* conditional checks of individual prototype’s remove() methods
|
2009-11-02 16:16:41 +00:00
|
|
|
|
*/
|
2010-01-10 14:40:36 +00:00
|
|
|
|
HopObject.remove = function(options) {
|
2008-05-15 12:58:26 +00:00
|
|
|
|
var item;
|
2010-01-10 14:40:36 +00:00
|
|
|
|
while (this.size() > 0) {
|
|
|
|
|
|
item = this.get(0);
|
2008-05-15 12:58:26 +00:00
|
|
|
|
if (item.constructor.remove) {
|
2010-01-10 14:40:36 +00:00
|
|
|
|
item.constructor.remove.call(item, options);
|
2010-01-10 16:29:37 +00:00
|
|
|
|
} else if (!options) {
|
|
|
|
|
|
item.remove();
|
2009-12-13 22:29:21 +00:00
|
|
|
|
} else {
|
2014-07-04 15:10:47 +02:00
|
|
|
|
throw Error("Missing static " + item.constructor.name +
|
2010-01-10 14:40:36 +00:00
|
|
|
|
".remove() method");
|
2008-05-15 12:58:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {String} name
|
|
|
|
|
|
* @param {HopObject} collection
|
|
|
|
|
|
*/
|
2008-05-02 18:06:05 +00:00
|
|
|
|
HopObject.getFromPath = function(name, collection) {
|
2008-12-15 14:20:48 +00:00
|
|
|
|
if (name) {
|
|
|
|
|
|
var site;
|
|
|
|
|
|
if (name.contains("/")) {
|
|
|
|
|
|
var parts = name.split("/");
|
|
|
|
|
|
site = root.get(parts[0]);
|
|
|
|
|
|
name = parts[1];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
site = res.handlers.site;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (site && site.getPermission("main")) {
|
|
|
|
|
|
return site[collection].get(name);
|
|
|
|
|
|
}
|
2008-05-02 18:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-05-12 13:50:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
* Debugging method to detect direct constructor calls which
|
2012-05-12 13:50:41 +00:00
|
|
|
|
* should be replaced with static add() method.
|
|
|
|
|
|
*/
|
2012-05-12 16:31:43 +00:00
|
|
|
|
HopObject.confirmConstructor = function(ref) {
|
|
|
|
|
|
var KEY = '__confirmedConstructors__';
|
2012-05-12 13:50:41 +00:00
|
|
|
|
if (!res.meta[KEY]) {
|
2012-05-12 16:31:43 +00:00
|
|
|
|
res.meta[KEY] = {};
|
2012-05-12 13:50:41 +00:00
|
|
|
|
}
|
2012-05-12 16:31:43 +00:00
|
|
|
|
var confirmed = res.meta[KEY];
|
|
|
|
|
|
if (typeof ref === 'function') {
|
|
|
|
|
|
confirmed[ref.name] = true;
|
2012-05-12 13:50:41 +00:00
|
|
|
|
} else {
|
2012-05-12 16:31:43 +00:00
|
|
|
|
ref = (ref || this).constructor.name;
|
|
|
|
|
|
if (!confirmed[ref]) {
|
2014-07-04 15:10:47 +02:00
|
|
|
|
app.logger.warn('Calling unconfirmed constructor for ' +
|
2012-05-12 16:31:43 +00:00
|
|
|
|
ref + ' prototype – please check!');
|
2012-05-12 13:50:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Helma’s built-in HopObject with Antville’s extensions.
|
|
|
|
|
|
* @name HopObject
|
|
|
|
|
|
* @constructor
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
*/
|
2007-09-14 00:16:06 +00:00
|
|
|
|
HopObject.prototype.onRequest = function() {
|
2008-10-02 18:11:14 +00:00
|
|
|
|
// Checking if we are on the correct host to prevent at least some XSS issues
|
2014-07-04 15:10:47 +02:00
|
|
|
|
if (req.action !== "notfound" && req.action !== "error" &&
|
|
|
|
|
|
this.href().contains("://") &&
|
|
|
|
|
|
!this.href().toLowerCase().startsWith(req.servletRequest.scheme +
|
|
|
|
|
|
"://" + req.servletRequest.serverName.toLowerCase())) {
|
2008-10-02 18:11:14 +00:00
|
|
|
|
res.redirect(this.href(req.action === "main" ? String.EMPTY : req.action));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-10-11 23:03:17 +00:00
|
|
|
|
User.autoLogin();
|
2007-10-01 21:52:25 +00:00
|
|
|
|
res.handlers.membership = User.getMembership();
|
2014-07-04 15:10:47 +02:00
|
|
|
|
|
2007-10-11 23:03:17 +00:00
|
|
|
|
if (User.getCurrentStatus() === User.BLOCKED) {
|
2009-12-13 22:29:21 +00:00
|
|
|
|
session.data.status = 403;
|
2014-07-04 15:10:47 +02:00
|
|
|
|
session.data.error = gettext("Your account has been blocked.") + String.SPACE +
|
2009-12-13 22:29:21 +00:00
|
|
|
|
gettext("Please contact an administrator for further information.");
|
2010-01-10 14:40:36 +00:00
|
|
|
|
User.logout();
|
2009-12-13 22:29:21 +00:00
|
|
|
|
res.redirect(root.href("error"));
|
2007-10-01 21:52:25 +00:00
|
|
|
|
}
|
2014-07-04 15:10:47 +02:00
|
|
|
|
|
|
|
|
|
|
if (res.handlers.site.status === Site.BLOCKED &&
|
2007-10-16 21:36:41 +00:00
|
|
|
|
!User.require(User.PRIVILEGED)) {
|
2009-12-13 22:29:21 +00:00
|
|
|
|
session.data.status = 403;
|
2010-01-10 14:40:36 +00:00
|
|
|
|
session.data.error = gettext("The site you requested has been blocked.") +
|
2009-12-13 22:29:21 +00:00
|
|
|
|
String.SPACE + gettext("Please contact an administrator for further information.");
|
|
|
|
|
|
res.redirect(root.href("error"));
|
2007-10-16 21:36:41 +00:00
|
|
|
|
}
|
2014-07-04 15:10:47 +02:00
|
|
|
|
|
2012-05-12 16:31:43 +00:00
|
|
|
|
HopObject.confirmConstructor(Layout);
|
2012-05-13 18:22:05 +00:00
|
|
|
|
res.handlers.layout = res.handlers.site.layout || new Layout;
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
res.skinpath = res.handlers.layout.getSkinPath();
|
|
|
|
|
|
|
2007-09-30 23:59:13 +00:00
|
|
|
|
if (!this.getPermission(req.action)) {
|
2008-05-08 17:05:51 +00:00
|
|
|
|
if (!session.user) {
|
2008-05-12 17:37:17 +00:00
|
|
|
|
User.setLocation(root.href() + req.path);
|
2008-05-08 17:05:51 +00:00
|
|
|
|
res.message = gettext("Please login first.");
|
|
|
|
|
|
res.redirect(res.handlers.site.members.href("login"));
|
|
|
|
|
|
}
|
2008-05-12 17:37:17 +00:00
|
|
|
|
User.getLocation();
|
2007-09-30 23:59:13 +00:00
|
|
|
|
res.status = 401;
|
2009-12-13 22:29:21 +00:00
|
|
|
|
res.data.title = gettext("{0} 401 Error", root.title);
|
2014-07-04 15:10:47 +02:00
|
|
|
|
res.data.body = root.renderSkinAsString("$Root#error", {error:
|
2009-12-13 22:29:21 +00:00
|
|
|
|
gettext("You are not allowed to access this part of the site.")});
|
|
|
|
|
|
res.handlers.site.renderSkin("Site#page");
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
session.data.error = null;
|
2007-09-30 23:59:13 +00:00
|
|
|
|
res.stop();
|
|
|
|
|
|
}
|
2007-11-23 17:57:59 +00:00
|
|
|
|
|
2008-01-19 17:36:33 +00:00
|
|
|
|
res.meta.values = {};
|
|
|
|
|
|
res.handlers.site.renderSkinAsString("Site#values");
|
2007-09-14 00:16:06 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-14 00:16:06 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @returns Boolean
|
|
|
|
|
|
*/
|
2007-10-15 23:29:03 +00:00
|
|
|
|
HopObject.prototype.getPermission = function() {
|
|
|
|
|
|
return true;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-10-15 23:29:03 +00:00
|
|
|
|
|
2010-04-26 00:22:20 +00:00
|
|
|
|
// Marking some prototype names used in res.message of HopObject.delete_action()
|
|
|
|
|
|
markgettext("Comment");
|
|
|
|
|
|
markgettext("File");
|
|
|
|
|
|
markgettext("Image");
|
|
|
|
|
|
markgettext("Membership");
|
|
|
|
|
|
markgettext("Poll");
|
|
|
|
|
|
markgettext("Story");
|
|
|
|
|
|
|
2007-09-21 13:54:30 +00:00
|
|
|
|
HopObject.prototype.delete_action = function() {
|
|
|
|
|
|
if (req.postParams.proceed) {
|
2008-04-16 18:03:41 +00:00
|
|
|
|
try {
|
2008-01-13 01:39:01 +00:00
|
|
|
|
var parent = this._parent;
|
2014-07-04 15:10:47 +02:00
|
|
|
|
var url = this.constructor.remove.call(this, req.postParams) ||
|
2010-01-10 14:40:36 +00:00
|
|
|
|
parent.href();
|
2010-04-26 00:22:20 +00:00
|
|
|
|
res.message = gettext("{0} was successfully deleted.", gettext(this._prototype));
|
2008-05-12 17:37:17 +00:00
|
|
|
|
res.redirect(User.getLocation() || url);
|
2008-04-16 18:03:41 +00:00
|
|
|
|
} catch(ex) {
|
2007-09-21 13:54:30 +00:00
|
|
|
|
res.message = ex;
|
|
|
|
|
|
app.log(ex);
|
2008-04-16 18:03:41 +00:00
|
|
|
|
}
|
2007-09-21 13:54:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
res.data.action = this.href(req.action);
|
2009-12-13 22:29:21 +00:00
|
|
|
|
res.data.title = gettext("Confirm Deletion");
|
2008-04-21 20:46:29 +00:00
|
|
|
|
res.data.body = this.renderSkinAsString("$HopObject#confirm", {
|
2010-02-06 15:13:39 +00:00
|
|
|
|
text: this.getConfirmText()
|
2007-09-21 13:54:30 +00:00
|
|
|
|
});
|
2008-01-13 01:39:01 +00:00
|
|
|
|
res.handlers.site.renderSkin("Site#page");
|
2007-09-21 13:54:30 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-21 13:54:30 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
|
*/
|
2007-09-14 00:16:06 +00:00
|
|
|
|
HopObject.prototype.touch = function() {
|
2007-09-14 23:25:23 +00:00
|
|
|
|
return this.map({
|
2007-09-14 00:16:06 +00:00
|
|
|
|
modified: new Date,
|
|
|
|
|
|
modifier: session.user
|
|
|
|
|
|
});
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-14 00:16:06 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
*/
|
2008-05-15 12:58:26 +00:00
|
|
|
|
HopObject.prototype.log = function() {
|
2008-05-15 13:02:50 +00:00
|
|
|
|
var entry = new LogEntry(this, "main");
|
2008-06-15 17:42:49 +00:00
|
|
|
|
app.data.entries.push(entry);
|
2008-05-15 12:58:26 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {String} action
|
|
|
|
|
|
*/
|
2007-10-15 23:29:03 +00:00
|
|
|
|
HopObject.prototype.notify = function(action) {
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
var self = this;
|
2007-10-15 23:29:03 +00:00
|
|
|
|
var site = res.handlers.site;
|
2014-07-04 15:10:47 +02:00
|
|
|
|
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
var getPermission = function(scope, mode, status) {
|
2014-07-04 15:10:47 +02:00
|
|
|
|
if (scope === Admin.NONE || mode === Site.NOBODY ||
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
status === Site.BLOCKED) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
var scopes = [Admin.REGULAR, Admin.TRUSTED];
|
|
|
|
|
|
if (scopes.indexOf(status) < scopes.indexOf(scope)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!Membership.require(mode)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2014-07-04 15:10:47 +02:00
|
|
|
|
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
// Helper method for debugging
|
|
|
|
|
|
var renderMatrix = function() {
|
|
|
|
|
|
var buf = ['<table border=1 cellspacing=0>'];
|
|
|
|
|
|
for each (var scope in Admin.getNotificationScopes()) {
|
|
|
|
|
|
for each (var mode in Site.getNotificationModes()) {
|
|
|
|
|
|
for each (var status in Site.getStatus()) {
|
|
|
|
|
|
var perm = getPermission(scope.value, mode.value, status.value);
|
|
|
|
|
|
buf.push('<tr style="');
|
|
|
|
|
|
perm && buf.push('color: blue;');
|
2014-07-04 15:10:47 +02:00
|
|
|
|
if (scope.value === root.notificationScope && mode.value ===
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
site.notificationMode && status.value === site.status) {
|
|
|
|
|
|
buf.push(' background-color: yellow;');
|
|
|
|
|
|
}
|
|
|
|
|
|
buf.push('">');
|
|
|
|
|
|
buf.push('<td>', scope.value, '</td>');
|
|
|
|
|
|
buf.push('<td>', status.value, '</td>');
|
|
|
|
|
|
buf.push('<td>', mode.value, '</td>');
|
|
|
|
|
|
buf.push('<td>', perm, '</td>');
|
|
|
|
|
|
buf.push('</tr>');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
buf.push('</table>');
|
|
|
|
|
|
res.write(buf.join(""));
|
2007-10-15 23:29:03 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
|
2007-10-15 23:29:03 +00:00
|
|
|
|
switch (action) {
|
|
|
|
|
|
case "comment":
|
|
|
|
|
|
action = "create"; break;
|
|
|
|
|
|
}
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
|
2008-05-12 15:06:20 +00:00
|
|
|
|
var currentMembership = res.handlers.membership;
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
site.members.forEach(function() {
|
|
|
|
|
|
var membership = res.handlers.membership = this;
|
|
|
|
|
|
if (getPermission(root.notificationScope, site.notificationMode, site.status)) {
|
2014-07-04 15:10:47 +02:00
|
|
|
|
sendMail(membership.creator.email, gettext("[{0}] Notification of site changes",
|
2010-05-24 13:32:40 +00:00
|
|
|
|
root.title), self.renderSkinAsString("$HopObject#notify_" + action));
|
2007-10-15 23:29:03 +00:00
|
|
|
|
}
|
* Refactored Admin prototype by reducing interface, eliminating lenghty help texts and leaving out meaningless features
* Moved SITENOTIFICATIONPERIOD constant, health property as well as getFormOptions(), commitEntries(), commitRequests(), purgeReferrers(), invokeCallbacks(), updateHealth(), exportImport(), updateDomains(), queue() and dequeue() methods from Root to Admin prototype
* Renamed Admin.purgeDatabase() method to Admin.purgeSites() and added code for automatic blocking/deletion of restricted/abandoned sites
* Renamed Root.getScopes() method to Admin.getNotificationScopes()
* Renamed User.getScopes() method to Admin.getCreationScopes()
* Added Admin.getPhaseOutModes() method
* Removed obsolete code
* Fixed and renamed Admin.privateSites to Admin.restrictedSites collection
* Finally added simple and reasonable quota implementation
* Fixed gettext_macro() and ngettext_macro() with check for necessary arguments
* Removed sender argument from global sendMail() method – instead, the root.replyTo property is used
* Fixed some i18n messages
* Moved code setting res.handlers.layout before permission check in HopObject.onRequest() to prevent broken layout in error screen
* Completely rewrote HopObject.notify() method (hopefully fixing issue 49)
* Check free disk space before invoking create_action() of Files and Images prototypes
* Modified output of Membership.toString() method
* Fixed some linebreaks in Membership.skin
* Added option to set session.data.error for additonal information in $Root#error skin
* Slightly modified output of $Root#health skin
* Replaced Root.phaseOutInactiveSites and Root.phaseOutPrivateSites with Root.phaseOutMode
* Removed qualifyingDate property from Root
* Renamed Root.qualifyingPeriod property to Root.probationPeriod
* Removed autoCleanupEnabled and autoCleanupStartTime properties from Root
* Added replyTo property to Root
* Rewrote Root.getCreationPermission() method
* Added #notify_blocking and #notify_deletion skins to $Site.skin
* Replaced Site.notifiedOfBlocking and Site.notifiedOfDeletion properties with Site.notified
* Added Site.diskspace_macro() returning the free disk space in MB
* Fixed bug in Site.main_action() causing erroneous display of deletion warning
2010-01-15 21:32:11 +00:00
|
|
|
|
});
|
2008-05-12 15:06:20 +00:00
|
|
|
|
res.handlers.membership = currentMembership;
|
2007-10-15 23:29:03 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-14 00:16:06 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @returns {Tag[]}
|
|
|
|
|
|
*/
|
2008-01-09 22:21:40 +00:00
|
|
|
|
HopObject.prototype.getTags = function() {
|
2009-09-30 09:48:23 +00:00
|
|
|
|
var tags = [];
|
2008-01-09 22:21:40 +00:00
|
|
|
|
if (typeof this.tags === "object") {
|
2009-09-30 09:48:23 +00:00
|
|
|
|
this.tags.list().forEach(function(item) {
|
|
|
|
|
|
item.tag && tags.push(item.tag.name);
|
2008-01-09 22:21:40 +00:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2009-09-30 09:48:23 +00:00
|
|
|
|
return tags;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2008-01-09 22:21:40 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Tag[]|String} tags
|
|
|
|
|
|
*/
|
2008-01-09 22:21:40 +00:00
|
|
|
|
HopObject.prototype.setTags = function(tags) {
|
|
|
|
|
|
if (typeof this.tags !== "object") {
|
|
|
|
|
|
return String.EMPTY;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!tags) {
|
|
|
|
|
|
tags = [];
|
|
|
|
|
|
} else if (tags.constructor === String) {
|
|
|
|
|
|
tags = tags.split(/\s*,\s*/);
|
|
|
|
|
|
}
|
2014-07-04 15:10:47 +02:00
|
|
|
|
|
2008-01-09 22:21:40 +00:00
|
|
|
|
var diff = {};
|
|
|
|
|
|
var tag;
|
|
|
|
|
|
for (var i in tags) {
|
2008-05-10 10:33:17 +00:00
|
|
|
|
// Trim and remove troublesome characters (like ../.. etc.)
|
|
|
|
|
|
// We call getAccessName with a virgin HopObject to allow most names
|
|
|
|
|
|
tag = tags[i] = this.getAccessName.call(new HopObject, File.getName(tags[i]));
|
2008-01-09 22:21:40 +00:00
|
|
|
|
if (tag && diff[tag] == null) {
|
|
|
|
|
|
diff[tag] = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.tags.forEach(function() {
|
|
|
|
|
|
if (!this.tag) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
diff[this.tag.name] = (tags.indexOf(this.tag.name) < 0) ? this : 0;
|
|
|
|
|
|
});
|
2014-07-04 15:10:47 +02:00
|
|
|
|
|
2008-01-09 22:21:40 +00:00
|
|
|
|
for (var tag in diff) {
|
|
|
|
|
|
switch (diff[tag]) {
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
// Do nothing (tag already exists)
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
// Add tag to story
|
|
|
|
|
|
this.addTag(tag);
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
// Remove tag
|
|
|
|
|
|
this.removeTag(diff[tag]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2008-01-09 22:21:40 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2008-01-09 22:21:40 +00:00
|
|
|
|
HopObject.prototype.addTag = function(name) {
|
2012-05-12 13:50:41 +00:00
|
|
|
|
TagHub.add(name, this, session.user);
|
2008-01-09 22:21:40 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2008-01-09 22:21:40 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {String} tag
|
|
|
|
|
|
*/
|
2008-01-09 22:21:40 +00:00
|
|
|
|
HopObject.prototype.removeTag = function(tag) {
|
|
|
|
|
|
var parent = tag._parent;
|
|
|
|
|
|
if (parent.size() === 1) {
|
|
|
|
|
|
parent.remove();
|
|
|
|
|
|
}
|
|
|
|
|
|
tag.remove();
|
|
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2008-01-09 22:21:40 +00:00
|
|
|
|
|
2012-05-19 12:41:24 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2012-05-19 12:41:24 +00:00
|
|
|
|
* @param {Object} values
|
|
|
|
|
|
*/
|
|
|
|
|
|
HopObject.prototype.map = function(values) {
|
|
|
|
|
|
for (var i in values) {
|
|
|
|
|
|
this[i] = values[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2008-04-15 22:02:29 +00:00
|
|
|
|
HopObject.prototype.skin_macro = function(param, name) {
|
2008-04-16 18:03:41 +00:00
|
|
|
|
if (!name) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2008-04-15 22:02:29 +00:00
|
|
|
|
if (name.contains("#")) {
|
|
|
|
|
|
this.renderSkin(name);
|
|
|
|
|
|
} else {
|
2008-06-04 10:19:17 +00:00
|
|
|
|
var prototype = this._prototype || "Global";
|
|
|
|
|
|
this.renderSkin(prototype + "#" + name);
|
2008-04-15 22:02:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2007-09-08 17:20:59 +00:00
|
|
|
|
HopObject.prototype.input_macro = function(param, name) {
|
|
|
|
|
|
param.name = name;
|
2007-09-22 21:48:33 +00:00
|
|
|
|
param.id = name;
|
2007-09-08 17:20:59 +00:00
|
|
|
|
param.value = this.getFormValue(name);
|
|
|
|
|
|
return html.input(param);
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-08 17:20:59 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2007-09-21 13:54:30 +00:00
|
|
|
|
HopObject.prototype.textarea_macro = function(param, name) {
|
|
|
|
|
|
param.name = name;
|
2007-09-22 21:48:33 +00:00
|
|
|
|
param.id = name;
|
2007-09-21 13:54:30 +00:00
|
|
|
|
param.value = this.getFormValue(name);
|
|
|
|
|
|
return html.textArea(param);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2007-09-21 13:54:30 +00:00
|
|
|
|
HopObject.prototype.select_macro = function(param, name) {
|
|
|
|
|
|
param.name = name;
|
2007-09-22 21:48:33 +00:00
|
|
|
|
param.id = name;
|
2007-09-21 13:54:30 +00:00
|
|
|
|
var options = this.getFormOptions(name);
|
|
|
|
|
|
if (options.length < 2) {
|
|
|
|
|
|
param.disabled = "disabled";
|
|
|
|
|
|
}
|
|
|
|
|
|
return html.dropDown(param, options, this.getFormValue(name));
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-21 13:54:30 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2007-09-08 17:20:59 +00:00
|
|
|
|
HopObject.prototype.checkbox_macro = function(param, name) {
|
|
|
|
|
|
param.name = name;
|
|
|
|
|
|
param.id = name;
|
2007-09-21 13:54:30 +00:00
|
|
|
|
var options = this.getFormOptions(name);
|
|
|
|
|
|
if (options.length < 2) {
|
|
|
|
|
|
param.disabled = "disabled";
|
|
|
|
|
|
}
|
2007-10-06 10:26:30 +00:00
|
|
|
|
param.value = String((options[1] || options[0]).value);
|
2007-09-08 17:20:59 +00:00
|
|
|
|
param.selectedValue = String(this.getFormValue(name));
|
2007-09-14 23:25:23 +00:00
|
|
|
|
var label = param.label;
|
|
|
|
|
|
delete param.label;
|
|
|
|
|
|
html.checkBox(param);
|
|
|
|
|
|
if (label) {
|
|
|
|
|
|
html.element("label", label, {"for": name});
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-08 17:20:59 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2007-10-04 18:48:35 +00:00
|
|
|
|
HopObject.prototype.radiobutton_macro = function(param, name) {
|
|
|
|
|
|
param.name = name;
|
|
|
|
|
|
param.id = name;
|
|
|
|
|
|
var options = this.getFormOptions(name);
|
|
|
|
|
|
if (options.length < 2) {
|
|
|
|
|
|
param.disabled = "disabled";
|
|
|
|
|
|
}
|
|
|
|
|
|
param.value = String(options[0].value);
|
|
|
|
|
|
param.selectedValue = String(this.getFormValue(name));
|
|
|
|
|
|
var label = param.label;
|
|
|
|
|
|
delete param.label;
|
|
|
|
|
|
html.radioButton(param);
|
|
|
|
|
|
if (label) {
|
|
|
|
|
|
html.element("label", label, {"for": name});
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-10-04 18:48:35 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} name
|
|
|
|
|
|
*/
|
2007-09-22 21:48:33 +00:00
|
|
|
|
HopObject.prototype.upload_macro = function(param, name) {
|
|
|
|
|
|
param.name = name;
|
|
|
|
|
|
param.id = name;
|
|
|
|
|
|
param.value = this.getFormValue(name);
|
2008-04-15 15:01:20 +00:00
|
|
|
|
renderSkin("$Global#upload", param);
|
2007-09-22 21:48:33 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-22 21:48:33 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {HopObject} [handler]
|
|
|
|
|
|
*/
|
2007-10-11 23:03:17 +00:00
|
|
|
|
HopObject.prototype.macro_macro = function(param, handler) {
|
|
|
|
|
|
var ctor = this.constructor;
|
|
|
|
|
|
if ([Story, Image, File, Poll].indexOf(ctor) > -1) {
|
2012-04-21 14:55:15 +00:00
|
|
|
|
res.write('<span class="macro-code">');
|
2007-10-11 23:03:17 +00:00
|
|
|
|
res.encode("<% ");
|
|
|
|
|
|
res.write(handler || ctor.name.toLowerCase());
|
|
|
|
|
|
res.write(String.SPACE);
|
2008-05-12 11:33:53 +00:00
|
|
|
|
res.write(quote(this.name || this._id));
|
2007-10-11 23:03:17 +00:00
|
|
|
|
res.encode(" %>");
|
2012-04-21 14:55:15 +00:00
|
|
|
|
res.write('</span>');
|
2007-10-11 23:03:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-10-11 23:03:17 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
*/
|
2007-10-15 23:29:03 +00:00
|
|
|
|
HopObject.prototype.kind_macro = function() {
|
|
|
|
|
|
var type = this.constructor.name.toLowerCase();
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
default:
|
|
|
|
|
|
res.write(gettext(type));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-10-15 23:29:03 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {String} name
|
|
|
|
|
|
* @returns {Number|String}
|
|
|
|
|
|
*/
|
2007-09-08 17:20:59 +00:00
|
|
|
|
HopObject.prototype.getFormValue = function(name) {
|
|
|
|
|
|
if (req.isPost()) {
|
|
|
|
|
|
return req.postParams[name];
|
|
|
|
|
|
} else {
|
2007-09-30 23:59:13 +00:00
|
|
|
|
var value = this[name] || req.queryParams[name] || String.EMPTY;
|
2007-09-08 17:20:59 +00:00
|
|
|
|
return value instanceof HopObject ? value._id : value;
|
|
|
|
|
|
}
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-08 17:20:59 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @returns {Object[]}
|
|
|
|
|
|
*/
|
|
|
|
|
|
HopObject.prototype.getFormOptions = function() {
|
2007-09-08 17:20:59 +00:00
|
|
|
|
return [{value: true, display: "enabled"}];
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-06-23 14:53:39 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @returns {HopObject}
|
2010-04-02 12:45:27 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} property
|
2009-11-02 16:16:41 +00:00
|
|
|
|
*/
|
2010-04-02 12:45:27 +00:00
|
|
|
|
HopObject.prototype.self_macro = function(param, property) {
|
|
|
|
|
|
return property ? this[property] : this;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-29 00:58:04 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
*/
|
2007-09-29 00:58:04 +00:00
|
|
|
|
HopObject.prototype.type_macro = function() {
|
|
|
|
|
|
return res.write(this.constructor.name);
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-29 00:58:04 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} url
|
|
|
|
|
|
* @param {String} text
|
|
|
|
|
|
*/
|
2007-09-08 17:20:59 +00:00
|
|
|
|
HopObject.prototype.link_macro = function(param, url, text) {
|
2010-04-25 17:31:44 +00:00
|
|
|
|
if (url && text) {
|
|
|
|
|
|
var action = url.split(/#|\?/)[0];
|
|
|
|
|
|
if (this.getPermission(action)) {
|
|
|
|
|
|
renderLink.call(global, param, url, text, this);
|
2010-01-10 14:40:36 +00:00
|
|
|
|
}
|
2010-04-25 17:31:44 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
res.write("[Insufficient link parameters]");
|
2007-09-14 00:16:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-06-23 14:53:39 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} format
|
|
|
|
|
|
*/
|
2007-09-08 17:20:59 +00:00
|
|
|
|
HopObject.prototype.created_macro = function(param, format) {
|
2008-12-11 18:08:51 +00:00
|
|
|
|
if (this.isPersistent()) {
|
|
|
|
|
|
format || (format = param.format);
|
2008-10-02 18:11:14 +00:00
|
|
|
|
res.write(formatDate(this.created, format));
|
2007-09-29 00:58:04 +00:00
|
|
|
|
}
|
2008-12-11 18:08:51 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-06-23 14:53:39 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} format
|
|
|
|
|
|
*/
|
2007-09-08 17:20:59 +00:00
|
|
|
|
HopObject.prototype.modified_macro = function(param, format) {
|
2008-12-11 18:08:51 +00:00
|
|
|
|
if (this.isPersistent()) {
|
|
|
|
|
|
format || (format = param.format);
|
2008-04-22 15:20:10 +00:00
|
|
|
|
res.write(formatDate(this.modified, format));
|
2007-09-29 00:58:04 +00:00
|
|
|
|
}
|
2008-12-11 18:08:51 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-06-23 14:53:39 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} mode
|
|
|
|
|
|
*/
|
2007-09-29 00:58:04 +00:00
|
|
|
|
HopObject.prototype.creator_macro = function(param, mode) {
|
|
|
|
|
|
if (!this.creator || this.isTransient()) {
|
2007-06-23 14:53:39 +00:00
|
|
|
|
return;
|
2007-09-29 00:58:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
mode || (mode = param.as);
|
|
|
|
|
|
if (mode === "link" && this.creator.url) {
|
|
|
|
|
|
html.link({href: this.creator.url}, this.creator.name);
|
|
|
|
|
|
} else if (mode === "url") {
|
2007-06-23 14:53:39 +00:00
|
|
|
|
res.write(this.creator.url);
|
2007-09-29 00:58:04 +00:00
|
|
|
|
} else {
|
2007-06-23 14:53:39 +00:00
|
|
|
|
res.write(this.creator.name);
|
2007-09-29 00:58:04 +00:00
|
|
|
|
} return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-06-23 14:53:39 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} mode
|
|
|
|
|
|
*/
|
2007-09-29 00:58:04 +00:00
|
|
|
|
HopObject.prototype.modifier_macro = function(param, mode) {
|
|
|
|
|
|
if (!this.modifier || this.isTransient()) {
|
2007-06-23 14:53:39 +00:00
|
|
|
|
return;
|
2007-09-29 00:58:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
mode || (mode = param.as);
|
|
|
|
|
|
if (mode === "link" && this.modifier.url) {
|
|
|
|
|
|
html.link({href: this.modifier.url}, this.modifier.name);
|
|
|
|
|
|
} else if (mode === "url") {
|
2007-06-23 14:53:39 +00:00
|
|
|
|
res.write(this.modifier.url);
|
2007-09-29 00:58:04 +00:00
|
|
|
|
} else {
|
2007-06-23 14:53:39 +00:00
|
|
|
|
res.write(this.modifier.name);
|
2007-09-29 00:58:04 +00:00
|
|
|
|
}
|
2007-06-23 14:53:39 +00:00
|
|
|
|
return;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-14 00:16:06 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @returns {String}
|
|
|
|
|
|
*/
|
2007-09-30 23:59:13 +00:00
|
|
|
|
HopObject.prototype.getTitle = function() {
|
2010-01-10 14:40:36 +00:00
|
|
|
|
return this.title || gettext(this.__name__.capitalize());
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-06-23 14:53:39 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @returns {String}
|
|
|
|
|
|
*/
|
2007-09-08 17:20:59 +00:00
|
|
|
|
HopObject.prototype.toString = function() {
|
2010-02-06 15:13:39 +00:00
|
|
|
|
return this.constructor.name + " #" + this._id;
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|
2007-09-08 17:20:59 +00:00
|
|
|
|
|
2009-11-02 16:16:41 +00:00
|
|
|
|
/**
|
2014-07-04 15:10:47 +02:00
|
|
|
|
*
|
2009-11-02 16:16:41 +00:00
|
|
|
|
* @param {String} text
|
|
|
|
|
|
* @param {Object} param
|
|
|
|
|
|
* @param {String} action
|
|
|
|
|
|
* @returns {String}
|
|
|
|
|
|
*/
|
|
|
|
|
|
HopObject.prototype.link_filter = function(text, param, action) {
|
2008-01-05 17:57:39 +00:00
|
|
|
|
action || (action = ".");
|
2008-03-27 15:10:31 +00:00
|
|
|
|
res.push();
|
2009-11-02 16:16:41 +00:00
|
|
|
|
renderLink(param, action, text, this);
|
2008-03-27 15:10:31 +00:00
|
|
|
|
return res.pop();
|
2008-04-21 13:57:01 +00:00
|
|
|
|
}
|