Search This Blog

Wednesday, November 18, 2015

Content Hiding Of Seattle Master on Basis on Group and Users Permission

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
<script type="text/javascript">//<![CDATA[
                var g_pageLoadAnimationParams = { elementSlideIn : "sideNavBox", elementSlideInPhase2 : "contentBox" };
                $(document).ready(function(){
                                disableControls();           
                });
               
                function disableControls()
                {
                var clientContext= SP.ClientContext.get_current();
                var groupCollection = clientContext.get_web().get_siteGroups();
                var group = groupCollection.getById(3);//the SharePoint usergroup
                users = group.get_users();
                clientContext.load(group);
                clientContext.load(users);
                currentUser = clientContext.get_web().get_currentUser();
                clientContext.load(currentUser);
                clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded), Function.createDelegate(this,this.onQueryFailed));
                }
                function onQuerySucceeded()
                {
               
                   if(this.users.get_count() >0)
                               {
                       var UserExistInGroup = false;
                                                          for(var i=0; i < users.get_count(); i++)
                                                          {
                                                          //alert(users.itemAt(i).get_loginName());
                                                                         if(users.itemAt(i).get_loginName() == this.currentUser.get_loginName())
                                                                         {
                                                                                        UserExistInGroup = true;
                                                                                        break;
                                                                         }
                                                          }
                                               }
                                               if (UserExistInGroup)
                                               {
                                             
                               
                                               }
                                               else
                                               {
                             
                        if( window.parent.location.href.indexOf("EditForm.aspx") >= 0)
                                     {
                                                               
                                               
                                     }
                                     else if( window.parent.location.href.indexOf("DispForm.aspx") >= 0)
                                     {
                                                               
                                     }
                                     else
                                     {
                                      $("[id$='globalNavBox']").css('display','none');
                          }
                          $("[id$='suiteLinksBox']").css('display','none');
                          $("[id$='ms-help']").css('display','none');
                          $("[id$='ms-help']").css('display','none');
                          $("#suiteBarLeft").html(" Peguform VDR/GSP VDR Portal");
                          $(".ms-core-sideNavBox-removeLeftMargin").css('display','none');
                          $("#suiteBarLeft").css('font-weight','bold');   
                               }
                }
               
                function onQueryFailed(sender, args)
                {
                }
//]]>
</script>

No comments:

Post a Comment