2001-06-18 08:57:33 +00:00
|
|
|
/**
|
2002-06-26 17:06:45 +00:00
|
|
|
* function saves new properties of site
|
2001-12-10 23:46:24 +00:00
|
|
|
* @param Obj Object containing the form values
|
2002-06-26 17:06:45 +00:00
|
|
|
* @param Obj User-Object modifying this site
|
2001-12-13 18:25:00 +00:00
|
|
|
* @return Obj Object containing two properties:
|
|
|
|
* - error (boolean): true if error happened, false if everything went fine
|
|
|
|
* - message (String): containing a message to user
|
2001-06-18 08:57:33 +00:00
|
|
|
*/
|
|
|
|
|
2001-12-13 18:25:00 +00:00
|
|
|
function evalPreferences(param,modifier) {
|
2002-06-12 17:19:47 +00:00
|
|
|
if (!checkEmail(param.email))
|
|
|
|
return (getError("emailInvalid"));
|
2002-02-06 18:06:57 +00:00
|
|
|
this.title = stripTags(param.title);
|
2001-12-10 23:46:24 +00:00
|
|
|
this.tagline = param.tagline;
|
2001-12-13 18:25:00 +00:00
|
|
|
this.email = param.email;
|
2001-12-10 23:46:24 +00:00
|
|
|
this.bgcolor = param.bgcolor;
|
|
|
|
this.textfont = param.textfont;
|
|
|
|
this.textsize = param.textsize;
|
|
|
|
this.textcolor = param.textcolor;
|
|
|
|
this.linkcolor = param.linkcolor;
|
|
|
|
this.alinkcolor = param.alinkcolor;
|
|
|
|
this.vlinkcolor = param.vlinkcolor;
|
|
|
|
this.titlefont = param.titlefont;
|
|
|
|
this.titlesize = param.titlesize;
|
|
|
|
this.titlecolor = param.titlecolor;
|
|
|
|
this.smallfont = param.smallfont;
|
|
|
|
this.smallsize = param.smallsize;
|
|
|
|
this.smallcolor = param.smallcolor;
|
2002-12-01 19:26:40 +00:00
|
|
|
this.days = !isNaN(parseInt(param.days,10)) ? parseInt(param.days,10) : 3;
|
2002-06-26 17:06:45 +00:00
|
|
|
if (this.online && !param.online)
|
2002-03-27 11:24:36 +00:00
|
|
|
this.lastoffline = new Date();
|
2002-12-01 19:26:40 +00:00
|
|
|
this.online = param.online ? 1 : 0;
|
|
|
|
this.discussions = param.discussions ? 1 : 0;
|
|
|
|
this.usercontrib = param.usercontrib ? 1 : 0;
|
|
|
|
this.archive = param.archive ? 1 : 0;
|
|
|
|
this.enableping = param.enableping ? 1 : 0;
|
2001-12-10 23:46:24 +00:00
|
|
|
// store selected locale in this.language and this.country
|
|
|
|
var locs = java.util.Locale.getAvailableLocales();
|
|
|
|
var newLoc = locs[parseInt(param.locale,10)];
|
|
|
|
if (!newLoc)
|
|
|
|
newLoc = java.util.Locale.getDefault();
|
|
|
|
this.country = newLoc.getCountry();
|
|
|
|
this.language = newLoc.getLanguage();
|
2002-05-27 18:50:48 +00:00
|
|
|
// store selected timezone in this.timezone
|
|
|
|
var timezones = java.util.TimeZone.getAvailableIDs();
|
|
|
|
var newZone = timezones[parseInt(param.timezone,10)];
|
2002-12-01 19:26:40 +00:00
|
|
|
this.timezone = newZone ? newZone : null;
|
|
|
|
|
2002-10-21 09:22:07 +00:00
|
|
|
// reset cached locale, timezone and dateSymbols
|
2002-05-27 18:50:48 +00:00
|
|
|
this.cache.locale = null;
|
|
|
|
this.cache.timezone = null;
|
2002-10-21 09:22:07 +00:00
|
|
|
this.cache.dateSymbols = null;
|
2001-12-10 23:46:24 +00:00
|
|
|
|
|
|
|
// long dateformat
|
2003-03-03 12:15:15 +00:00
|
|
|
var ldf = LONGDATEFORMATS[parseInt(param.longdateformat,10)];
|
2001-12-10 23:46:24 +00:00
|
|
|
this.longdateformat = ldf ? ldf : null;
|
|
|
|
|
|
|
|
// short dateformat
|
2003-03-03 12:15:15 +00:00
|
|
|
var sdf = SHORTDATEFORMATS[parseInt(param.shortdateformat,10)];
|
2002-12-01 19:26:40 +00:00
|
|
|
this.shortdateformat = sdf ? sdf : null;
|
2001-12-10 23:46:24 +00:00
|
|
|
|
|
|
|
this.modifytime = new Date();
|
|
|
|
this.modifier = modifier;
|
2002-06-12 17:19:47 +00:00
|
|
|
return (getConfirm("update"));
|
2001-06-18 08:57:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-06-26 17:06:45 +00:00
|
|
|
* function creates the directory that will contain the images of this site
|
2001-06-18 08:57:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
function createImgDirectory() {
|
|
|
|
var dir = new File(getProperty("imgPath") + this.alias + "/");
|
|
|
|
return (dir.mkdir());
|
2001-07-01 19:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function checks if language and country were specified
|
2002-06-26 17:06:45 +00:00
|
|
|
* for this site. if so, it returns the specified Locale-object
|
|
|
|
* otherwise it calls getLocale() for root
|
2001-07-01 19:27:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
function getLocale() {
|
2002-05-27 18:50:48 +00:00
|
|
|
var locale = this.cache.locale;
|
|
|
|
if (locale)
|
|
|
|
return locale;
|
2001-12-10 23:46:24 +00:00
|
|
|
if (this.language)
|
2002-05-27 18:50:48 +00:00
|
|
|
locale = new java.util.Locale(this.language,this.country ? this.country : "");
|
2001-07-01 19:27:28 +00:00
|
|
|
else
|
2002-06-26 17:06:45 +00:00
|
|
|
locale = root.getLocale();
|
2002-05-27 18:50:48 +00:00
|
|
|
this.cache.locale =locale;
|
|
|
|
return locale;
|
|
|
|
}
|
|
|
|
|
2003-01-02 18:58:25 +00:00
|
|
|
/**
|
|
|
|
* function returns the (already cached) DateFormatSymbols according
|
|
|
|
* to the locale defined for a site
|
|
|
|
*/
|
2002-10-21 09:22:07 +00:00
|
|
|
function getDateSymbols() {
|
|
|
|
var symbols = this.cache.dateSymbols;
|
|
|
|
if (symbols)
|
|
|
|
return symbols;
|
|
|
|
this.cache.dateSymbols = new java.text.DateFormatSymbols(this.getLocale());
|
|
|
|
return this.cache.dateSymbols;
|
|
|
|
}
|
|
|
|
|
2003-01-02 18:58:25 +00:00
|
|
|
/**
|
|
|
|
* function returns the (already cached) TimeZone-Object
|
|
|
|
* according to site-preferences
|
|
|
|
*/
|
2002-05-27 18:50:48 +00:00
|
|
|
function getTimeZone() {
|
|
|
|
var timezone = this.cache.timezone;
|
|
|
|
if (timezone)
|
|
|
|
return timezone;
|
|
|
|
if (this.timezone)
|
|
|
|
timezone = java.util.TimeZone.getTimeZone(this.timezone);
|
|
|
|
else
|
|
|
|
timezone = java.util.TimeZone.getDefault();
|
|
|
|
this.cache.timezone =timezone;
|
|
|
|
return timezone;
|
2001-07-09 20:01:48 +00:00
|
|
|
}
|
2001-12-10 23:46:24 +00:00
|
|
|
|
2001-12-12 15:18:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* helper function to sort story reads
|
|
|
|
* @param Obj story a to be compared with story b
|
|
|
|
* @param Obj story b to be compared with story a
|
|
|
|
* @return Integer -1: a>b; 1: a<b; 0: a=b
|
|
|
|
*/
|
|
|
|
function sortMostReads(s1, s2) {
|
2003-03-10 11:57:53 +00:00
|
|
|
var s1reads = s1.reads + s1.cache.reads;
|
|
|
|
var s2reads = s2.reads + s2.cache.reads;
|
|
|
|
if (s1reads > s2reads)
|
|
|
|
return(-1);
|
|
|
|
else if (s1reads < s2reads)
|
|
|
|
return(1);
|
|
|
|
else
|
|
|
|
return(0);
|
2001-12-12 15:18:53 +00:00
|
|
|
}
|
2001-12-16 18:06:47 +00:00
|
|
|
|
2002-03-27 11:24:36 +00:00
|
|
|
/**
|
2002-06-26 17:06:45 +00:00
|
|
|
* function deletes all assets of a site (recursive!)
|
2002-03-27 11:24:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
function deleteAll() {
|
|
|
|
this.members.deleteAll();
|
|
|
|
this.images.deleteAll();
|
2002-06-26 17:06:45 +00:00
|
|
|
this.files.deleteAll();
|
2002-03-27 11:24:36 +00:00
|
|
|
this.skins.deleteAll();
|
2002-05-15 23:23:49 +00:00
|
|
|
this.stories.deleteAll();
|
2002-03-27 11:24:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-04-29 12:02:37 +00:00
|
|
|
/**
|
|
|
|
* send notification to weblogs.com
|
2002-06-26 17:06:45 +00:00
|
|
|
* that this site was updated
|
2002-04-29 12:02:37 +00:00
|
|
|
* @return Object with properties error and message
|
|
|
|
*/
|
|
|
|
|
2002-04-29 10:35:58 +00:00
|
|
|
function ping() {
|
2003-03-10 11:57:53 +00:00
|
|
|
var title = this.title ? this.title : this.alias;
|
2002-04-29 15:09:27 +00:00
|
|
|
|
2003-03-10 11:57:53 +00:00
|
|
|
// we're doing it the xml-rpc way
|
|
|
|
// (specs at http://newhome.weblogs.com/directory/11)
|
|
|
|
var xr = new Remote("http://rpc.weblogs.com/RPC2");
|
|
|
|
var ping = xr.weblogUpdates.ping(title, this.href());
|
2002-08-30 13:41:39 +00:00
|
|
|
if (!ping.result)
|
|
|
|
return;
|
2003-03-10 11:57:53 +00:00
|
|
|
var result = new Object();
|
|
|
|
result.error = ping.result.flerror;
|
|
|
|
result.message = ping.result.message;
|
|
|
|
|
|
|
|
if (result.error)
|
|
|
|
app.log("Error when notifying weblogs.com for updated site \"" + this.alias + "\": " + result.message);
|
|
|
|
|
|
|
|
// lastping is always set to now to prevent blogs
|
|
|
|
// hanging in the scheduler if a fatal error occurs
|
|
|
|
this.lastping = new Date();
|
|
|
|
return(result);
|
|
|
|
}
|
2003-03-10 12:12:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* href URL postprocessor. If a virtual host mapping is defined
|
|
|
|
* for this site's alias, use it. Otherwise, use normal site URL.
|
|
|
|
*/
|
|
|
|
function processHref(href) {
|
|
|
|
var vhost = getProperty("vhost."+this.alias);
|
|
|
|
if (vhost)
|
|
|
|
return vhost+href;
|
|
|
|
else
|
2003-04-11 12:48:44 +00:00
|
|
|
return getProperty("defaulthost")+"/"+this.alias+href;
|
2003-03-10 12:12:06 +00:00
|
|
|
}
|
|
|
|
|