dynamic rights.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3847 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 18 years ago
parent 99062c0c9e
commit 6074264267

@ -57,14 +57,9 @@
<dd><input type="text" id="address" name="address" value="#[address]#" /></dd>
<dt>Rights:</dt>
<dd>
<input type="checkbox" id="proxy" name="proxyRight"#(proxyRight)#:: checked="checked"#(/proxyRight)# /><label for="proxy">Proxy</label><br />
<input type="checkbox" id="admin" name="adminRight"#(adminRight)#:: checked="checked"#(/adminRight)# /><label for="admin">Admin</label><br />
<input type="checkbox" id="share" name="uploadRight"#(uploadRight)#:: checked="checked"#(/uploadRight)# /><label for="share">Fileshare-Upload</label><br />
<input type="checkbox" id="dwnld" name="downloadRight"#(downloadRight)#:: checked="checked"#(/downloadRight)# /><label for="dwnld">Fileshare-Download</label><br />
<input type="checkbox" id="blog" name="blogRight"#(blogRight)#:: checked="checked"#(/blogRight)# /><label for="blog">Blog</label><br />
<input type="checkbox" id="wiki" name="wikiAdminRight"#(wikiAdminRight)#:: checked="checked"#(/wikiAdminRight)# /><label for="wiki">Wiki Admin</label><br />
<input type="checkbox" id="bkmark" name="bookmarkRight"#(bookmarkRight)#:: checked="checked"#(/bookmarkRight)# /><label for="bkmark">Bookmarks</label>
<input type="checkbox" id="soap" name="soapRight"#(soapRight)#:: checked="checked"#(/soapRight)# /><label for="soap">SOAP</label>
#{rights}#
<input type="checkbox" id="#[name]#" name="#[name]#"#(set)#:: checked="checked"#(/set)# /><label for="#[name]#">#[friendlyName]# right</label><br />
#{/rights}#
</dd>
<dt><label for="tlimit">Timelimit</label>:</dt>
<dd><input type="text" id="tlimit" name="timelimit" value="#[timelimit]#" /></dd>

@ -59,7 +59,6 @@ import de.anomic.server.serverSwitch;
public class User_p {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
serverObjects prop = new serverObjects();
plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
@ -74,14 +73,15 @@ public class User_p {
prop.put("address", "");
prop.put("timelimit", "");
prop.put("timeused", "");
prop.put("timerange", "");
prop.put("proxyRight", 1);
prop.put("downloadRight", 0);
prop.put("uploadRight", 0);
prop.put("adminRight", 0);
prop.put("wikiAdminRight", 0);
prop.put("bookmarkRight", 0);
prop.put("soapRight", 0);
String[] rightNames=userDB.Entry.RIGHT_NAMES.split(",");
String[] rights=userDB.Entry.RIGHT_TYPES.split(",");
int i;
for(i=0;i<rights.length;i++){
prop.put("rights_"+i+"_name", rights[i]);
prop.put("rights_"+i+"_friendlyName", rightNames[i]);
prop.put("rights_"+i+"_set", 0);
}
prop.put("rights", i);
prop.put("users", 0);
@ -109,14 +109,10 @@ public class User_p {
prop.put("address", entry.getAddress());
prop.put("timelimit", entry.getTimeLimit());
prop.put("timeused", entry.getTimeUsed());
prop.put("proxyRight", (entry.hasRight(userDB.Entry.PROXY_RIGHT)?1:0));
prop.put("uploadRight", (entry.hasRight(userDB.Entry.UPLOAD_RIGHT)?1:0));
prop.put("downloadRight", (entry.hasRight(userDB.Entry.DOWNLOAD_RIGHT)?1:0));
prop.put("adminRight", (entry.hasRight(userDB.Entry.ADMIN_RIGHT)?1:0));
prop.put("blogRight", (entry.hasRight(userDB.Entry.BLOG_RIGHT)?1:0));
prop.put("wikiAdminRight", (entry.hasRight(userDB.Entry.WIKIADMIN_RIGHT)?1:0));
prop.put("bookmarkRight", (entry.hasRight(userDB.Entry.BOOKMARK_RIGHT)?1:0));
prop.put("soapRight", (entry.hasRight(userDB.Entry.SOAP_RIGHT)?1:0));
for(i=0;i<rights.length;i++){
prop.put("rights_"+i+"_set", (entry.hasRight(rights[i])?1:0));
}
prop.put("rights", i);
}
}else if( post.containsKey("delete_user") && !((String)post.get("user")).equals("newuser") ){
sb.userDB.removeEntry((String)post.get("user"));
@ -138,14 +134,10 @@ public class User_p {
String address=(String)post.get("address");
String timeLimit=(String)post.get("timelimit");
String timeUsed=(String)post.get("timeused");
String proxyRight=( post.containsKey("proxyRight")&&((String)post.get("proxyRight")).equals("on") ? "true" : "false");
String uploadRight=( post.containsKey("uploadRight")&&((String)post.get("uploadRight")).equals("on") ? "true" : "false");
String downloadRight=( post.containsKey("downloadRight")&&((String)post.get("downloadRight")).equals("on") ? "true" : "false");
String adminRight=( post.containsKey("adminRight")&&((String)post.get("adminRight")).equals("on") ? "true" : "false");
String blogRight=( post.containsKey("blogRight")&&((String)post.get("blogRight")).equals("on") ? "true" : "false");
String wikiAdminRight=( post.containsKey("wikiAdminRight")&&((String)post.get("wikiAdminRight")).equals("on") ? "true" : "false");
String bookmarkRight=( post.containsKey("bookmarkRight")&&((String)post.get("bookmarkRight")).equals("on") ? "true" : "false");
String soapRight=( post.containsKey("soapRight")&&((String)post.get("soapRight")).equals("on") ? "true" : "false");
HashMap rightsSet=new HashMap();
for(i=0;i<rights.length;i++){
rightsSet.put(rights[i], post.containsKey(rights[i])&&((String)post.get(rights[i])).equals("on") ? "true" : "false");
}
HashMap mem=new HashMap();
if( post.get("current_user").equals("newuser")){ //new user
@ -157,13 +149,8 @@ public class User_p {
mem.put(userDB.Entry.USER_ADDRESS, address);
mem.put(userDB.Entry.TIME_LIMIT, timeLimit);
mem.put(userDB.Entry.TIME_USED, timeUsed);
mem.put(userDB.Entry.PROXY_RIGHT, proxyRight);
mem.put(userDB.Entry.UPLOAD_RIGHT, uploadRight);
mem.put(userDB.Entry.DOWNLOAD_RIGHT, downloadRight);
mem.put(userDB.Entry.BLOG_RIGHT, blogRight);
mem.put(userDB.Entry.WIKIADMIN_RIGHT, wikiAdminRight);
mem.put(userDB.Entry.BOOKMARK_RIGHT, bookmarkRight);
mem.put(userDB.Entry.SOAP_RIGHT, soapRight);
for(i=0;i<rights.length;i++)
mem.put(rights[i], (String)rightsSet.get(rights[i]));
try{
entry=sb.userDB.createEntry(username, mem);
@ -188,14 +175,8 @@ public class User_p {
entry.setProperty(userDB.Entry.USER_ADDRESS, address);
entry.setProperty(userDB.Entry.TIME_LIMIT, timeLimit);
entry.setProperty(userDB.Entry.TIME_USED, timeUsed);
entry.setProperty(userDB.Entry.PROXY_RIGHT, proxyRight);
entry.setProperty(userDB.Entry.UPLOAD_RIGHT, uploadRight);
entry.setProperty(userDB.Entry.DOWNLOAD_RIGHT, downloadRight);
entry.setProperty(userDB.Entry.ADMIN_RIGHT, adminRight);
entry.setProperty(userDB.Entry.BLOG_RIGHT, blogRight);
entry.setProperty(userDB.Entry.WIKIADMIN_RIGHT, wikiAdminRight);
entry.setProperty(userDB.Entry.BOOKMARK_RIGHT, bookmarkRight);
entry.setProperty(userDB.Entry.SOAP_RIGHT, soapRight);
for(i=0;i<rights.length;i++)
entry.setProperty(rights[i], (String)rightsSet.get(rights[i]));
}catch (IOException e){
}
}else{

@ -316,6 +316,12 @@ public final class userDB {
public static final String BOOKMARK_RIGHT = "bookmarkRight";
public static final String SOAP_RIGHT = "soapRight";
//to create new rights, you just need to edit this strings
public static final String RIGHT_TYPES=
ADMIN_RIGHT+","+DOWNLOAD_RIGHT+","+UPLOAD_RIGHT+","+PROXY_RIGHT+","+
BLOG_RIGHT+","+BOOKMARK_RIGHT+","+WIKIADMIN_RIGHT+","+SOAP_RIGHT;
public static final String RIGHT_NAMES="Admin,Download,Upload,Proxy usage,Blog,Bookmark,Wiki Admin,SOAP";
public static final int PROXY_ALLOK = 0; //can Surf
public static final int PROXY_ERROR = 1; //unknown error
public static final int PROXY_NORIGHT = 2; //no proxy right

Loading…
Cancel
Save