]> www.wagner.pp.ru Git - oss/stilllife.git/commitdiff
DEbugged getUserRights
authorVictor Wagner <vitus@wagner.pp.ru>
Tue, 25 Mar 2008 12:49:57 +0000 (12:49 +0000)
committerVictor Wagner <vitus@wagner.pp.ru>
Tue, 25 Mar 2008 12:49:57 +0000 (12:49 +0000)
templates/basicset/page.js

index e10791b127787de99fc08a14dadc20f62fc9cd80..9eca966bb8ceaa642ba95ef0d49abc71d644312e 100644 (file)
@@ -53,7 +53,7 @@ function showUser(username) {
                                links[i].href=userListUrl+"/" + username;
                        }       
                        links[i].appendChild(document.createTextNode(username));
-                       links[i].className = status;
+                       links[i].className = userStatus;
                } else if (links[i].href.substring(0,forumScriptUrl.length)==
                        forumScriptUrl && links[i].href.indexOf("login=")!=-1) {
                        while (links[i].childNodes.length>0) {
@@ -74,24 +74,27 @@ function getUserRights(user) {
     var status="user";
     var xhr=getXMLHttpRequest();
     if(!xhr) return status;
-    
+       // Strip http:// prefix from OpenID url
+       if (user.substring(0,7) == "http://") {
+               user=user.substring(7,user.length);
+       } 
     var hr=location.href.match(/^\w+:\/\/[^/]*\/([^?#]+)/);
     if(hr==null) return status;
     var depth=hr[1].split(/\//).length;
-    var re=new RegExp("\n\[\s*(admins|moderators|banned)\s*\]\s*[^[]+\n"+user+"\n","m");
+    var re=new RegExp("\n\\\[\s*(admins|moderators|banned)\s*\\\]\s*[^[]*\n"+user+"\n","m");
     for(var path="",i=0;i<depth;path+="../",i++) {
-       xhr.open(GET, path+"perms.txt",false);
+       xhr.open("GET", path+"perms.txt",false);
        xhr.send("");
        if(xhr.status!=200) continue;
        
-       var perms=("\n"+xhr.responsText+"\n").match(re);
+       var perms=("\n"+xhr.responseText+"\n").match(re);
        if(perms!=null) {
            if(perms[1]=="banned") return "banned";
            if(perms[1]=="admins") return "admin";
            status=="moderator";
        }
        
-       xhr.open(GET, path+".forum",false);
+       xhr.open("GET", path+".forum",false);
        xhr.send("");
        if(xhr.status==403 || xhr.status==200) break;
     }