antville/code/Site/securityFunctions.js

77 lines
1.7 KiB
JavaScript
Raw Normal View History

/**
* check if site is online
* @param Obj Userobject
* @param Int Permission-Level
* @return String String indicating that site is not public (or null if public)
*/
function isNotPublic(usr,level) {
2002-12-01 19:26:40 +00:00
if (!this.online) {
if (usr && usr.sysadmin)
return null;
else if (level != null)
return null;
2002-12-01 19:26:40 +00:00
return "siteNotPublic";
}
2001-09-05 21:15:45 +00:00
return null;
}
2001-06-18 08:57:33 +00:00
/**
* check if user is allowed to edit the preferences of this site
* @param Obj Userobject
* @param Int Permission-Level
* @return String Reason for denial (or null if allowed)
2001-06-18 08:57:33 +00:00
*/
function isEditDenied(usr,level) {
2002-12-01 19:26:40 +00:00
if (usr.sysadmin)
return null;
if ((level & MAY_EDIT_PREFS) == 0)
2002-12-01 19:26:40 +00:00
return "siteEditDenied";
2001-09-05 21:15:45 +00:00
return null;
2001-06-28 18:09:37 +00:00
}
/**
* check if user is allowed to delete the site
* (only SysAdmins or the creator of a site are allowed to delete it!)
* @param Obj Userobject
* @return String Reason for denial (or null if allowed)
*/
function isDeleteDenied(usr) {
2002-12-01 19:26:40 +00:00
if (!usr.sysadmin && usr != this.creator)
return "siteDeleteDenied";
return null;
}
2001-07-01 19:27:28 +00:00
/**
* function checks if user is allowed to sign up
* @param Obj Userobject
* @param Int Permission-Level
* @return String Reason for denial (or null if allowed)
2001-07-01 19:27:28 +00:00
*/
function isSubscribeDenied(usr,level) {
if (level != null)
2002-12-01 19:26:40 +00:00
return "subscriptionExist";
else if (!this.online)
return "siteNotPublic";
2001-09-05 21:15:45 +00:00
return null;
2001-07-01 19:27:28 +00:00
}
/**
* check if user is allowed to unsubscribe
* @param Obj Userobject
* @return String Reason for denial (or null if allowed)
*/
function isUnsubscribeDenied(usr,level) {
if (level == null)
2002-12-01 19:26:40 +00:00
return "subscriptionNoExist";
else if (level > SUBSCRIBER)
2002-12-01 19:26:40 +00:00
return "unsubscribeDenied";
return null;
}
2001-07-01 19:27:28 +00:00