Modify UI in DVWP based on Users is in Sharepoint Group

I have DVWP which display data from Sql Server 2005 and i have also Insert,Edit and Delete link enable in DVWP.
Client wants like only Super admin can see all of these link,Admin can see only edit and Insert link and Read only users cant see any link.so what i did is i have Created 3 Sharepoint group as mention above and Used Jquery Web services library developed By Marc d Anderson to hide links based on whether users is in group or not.

<script src="/JSLibrary/jquery.SPServices-0.4.6.min.js" type="text/javascript"></script>
<script src="/JSLibrary/jquery1.3.min.js" type="text/javascript"></script></div>
<script type="text/javascript">
      $().SPServices ({
              operation: "GetGroupCollectionFromUser",
              userLoginName: $().SPServices.SPGetCurrentUser(),
              async: false,
              completefunc: function(xData, Status) {
                           if($(xData.responseXML).find("Group[Name='Read']").length == 1){ 
                                                    $("img[alt='Edit']").hide();
                                                    $("img[alt='Delete']").hide();
                            }
                          else if($(xData.responseXML).find("Group[Name='Admin']").length == 1){
                                                   $("img[alt='Delete']").hide();</div>
                                       }
                        }
});
</script>

Ronak

Leave a comment