Example #1
0
        public BaseCollection <CmsScript> GetAllScripts()
        {
            if (_allScripts == null)
            {
                //eerst alle scripts van site
                _allScripts = Site.Scripts;

                //mocht die dannog leeg zijn, dan nieuwe lege aanmaken:
                if (_allScripts == null)
                {
                    _allScripts = new BaseCollection <CmsScript>();
                }

                //dan alle van template eraan toevoegen
                BaseCollection <CmsScript> templateScripts = this.Template.Scripts;
                foreach (CmsScript script in templateScripts)
                {
                    if (!_allScripts.Contains(script))
                    {
                        _allScripts.Add(script);
                    }
                }
                //dan alle van pagina eraan toevoegen
                BaseCollection <CmsScript> pageScripts = this.Scripts;
                foreach (CmsScript script in pageScripts)
                {
                    if (!_allScripts.Contains(script))
                    {
                        _allScripts.Add(script);
                    }
                }
                //dan nog alle module specifieke scripts toevoegen
                foreach (string scriptUrl in GetModuleDependentScripts())
                {
                    CmsScript dummy = new CmsScript();
                    if (scriptUrl.EndsWith("css"))
                    {
                        dummy.ScriptType = ScriptTypeEnum.Css;
                    }
                    else
                    {
                        dummy.ScriptType = ScriptTypeEnum.Js;
                    }
                    dummy.Url = scriptUrl;
                    //dummy.UrlLive = scriptUrl;
                    dummy.ID = Guid.NewGuid();
                    _allScripts.Add(dummy);
                }
            }
            return(_allScripts);
        }
Example #2
0
        public void DCMRemoveUserRoles(int storageObjID, string userAccount, BaseCollection <string> rolesToRemove)
        {
            (storageObjID > 0).FalseThrow <ArgumentException>("ID值{0}无效,请传入大于0的值.", storageObjID);
            using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                ListItem listItem = GetListItemById(storageObjID, context);
                if (null == listItem)
                {
                    return;
                }
                context.Load(listItem);
                context.Load(listItem.RoleAssignments);
                context.ExecuteQuery();

                RoleAssignmentCollection roleAssignments = listItem.RoleAssignments;

                foreach (RoleAssignment roleAssignment in roleAssignments)
                {
                    context.Load(roleAssignment.Member);
                    context.Load(roleAssignment.RoleDefinitionBindings);
                    context.ExecuteQuery();
                    if (!IsSameUser(roleAssignment.Member.LoginName, userAccount))
                    {
                        continue;
                    }
                    for (int i = 0; i < roleAssignment.RoleDefinitionBindings.Count; i++)
                    {
                        RoleDefinition roleDefinition = roleAssignment.RoleDefinitionBindings[i];
                        string         rolename       = roleDefinition.Name;
                        if (rolesToRemove.Contains(rolename))
                        {
                            roleAssignment.RoleDefinitionBindings.Remove(roleDefinition);
                            i--;
                        }
                    }
                    roleAssignment.Update();
                }
                context.ExecuteQuery();
            }
        }