Esempio n. 1
0
 public bool RegistryItem(IWebItem webItem)
 {
     var systemname = GetSystemName(webItem);
     if (!items.Contains(webItem) && (allowedItems.Contains(systemname) || allowedItems.Count == 0))
     {
         items.Add(webItem);
         items.Sort((x, y) => GetSortOrder(x, null).CompareTo(GetSortOrder(y, null)));
         return true;
     }
     return false;
 }
Esempio n. 2
0
        private static string GetAppThemeVirtualPath(IWebItem webitem)
        {
            if (webitem == null || string.IsNullOrEmpty(webitem.StartURL))
            {
                return string.Empty;
            }

            var dir = webitem.StartURL.Contains(".") ?
                          webitem.StartURL.Substring(0, webitem.StartURL.LastIndexOf("/")) :
                          webitem.StartURL.TrimEnd('/');
            return dir + "/app_themes";
        }
Esempio n. 3
0
        public static bool IsLicensed(IWebItem item)
        {
            if (item != null)
            {
                try
                {
                    var sysName = item.GetSysName();
                    return Licensing.License.Current.HasFeature(sysName) &&
                           Licensing.License.Current.GetFeature<bool>(sysName);

                }
                catch (Exception)
                {
                    
                }
            }
            return false;
        }
Esempio n. 4
0
 private void BuildName(SearchResult searchResult, ISearchHandlerEx sh, IWebItem module)
 {
     searchResult.Name = GetName(sh, module);
 }
Esempio n. 5
0
        private string GetName(ISearchHandlerEx sh, IWebItem module)
        {
            if (sh.GetType().Equals(typeof (EmployeeSearchHendler)))
                return Core.Users.CustomNamingPeople.Substitute<Resources.Resource>("Employees");

            return module != null ? module.Name : sh.SearchName;
        }
 public static bool IsDisabled(this IWebItem item, Tenant tenant)
 {
     return(item.IsDisabled(tenant, SecurityContext.CurrentAccount.ID));
 }
        private object GetItemSubscriptions(IWebItem webItem, bool isOpen)
        {
            var isEmpty = true;
            var canUnsubscribe = false;

            var groups = new List<object>();
            var types = new List<object>();
            var itemType = 1;

            var productSubscriptionManager = webItem.Context.SubscriptionManager as IProductSubscriptionManager;
            if (productSubscriptionManager.GroupByType == GroupByType.Modules)
            {
                foreach (var subItem in WebItemManager.Instance.GetSubItems(webItem.ID))
                {
                    if (subItem.Context == null || subItem.Context.SubscriptionManager == null)
                        continue;

                    var subscriptionTypes = subItem.Context.SubscriptionManager.GetSubscriptionTypes();
                    if (subscriptionTypes == null || subscriptionTypes.Count == 0)
                        continue;
                    else
                        subscriptionTypes = subscriptionTypes.FindAll(type => (type.IsEmptySubscriptionType != null && !type.IsEmptySubscriptionType(webItem.ID, subItem.ID, type.ID)));

                    if (subscriptionTypes == null || subscriptionTypes.Count == 0)
                        continue;

                    var group = new
                                    {
                                        Id = subItem.ID,
                                        ImageUrl = subItem.GetIconAbsoluteURL(),
                                        Name = subItem.Name.HtmlEncode(),
                                        Types = new List<object>()
                                    };

                    foreach (var type in subscriptionTypes)
                    {
                        var t = new
                                    {
                                        Id = type.ID,
                                        Name = type.Name.HtmlEncode(),
                                        Single = type.Single,
                                        IsSubscribed = type.CanSubscribe ? subItem.Context.SubscriptionManager.SubscriptionProvider.IsSubscribed(type.NotifyAction, GetCurrentRecipient(), null) : true
                                    };
                        if (t.IsSubscribed)
                            canUnsubscribe = true;

                        group.Types.Add(t);
                    }

                    groups.Add(group);
                    isEmpty = false;
                }

            }
            else if (productSubscriptionManager.GroupByType == GroupByType.Groups)
            {
                var subscriptionTypes = productSubscriptionManager.GetSubscriptionTypes();
                var subscriptionGroups = productSubscriptionManager.GetSubscriptionGroups();
                if (subscriptionTypes != null && subscriptionGroups != null)
                {
                    foreach (var gr in subscriptionGroups)
                    {
                        var sTypes = subscriptionTypes.FindAll(type => (type.IsEmptySubscriptionType != null && !type.IsEmptySubscriptionType(webItem.ID, gr.ID, type.ID)));
                        if (sTypes == null || sTypes.Count == 0)
                            continue;

                        var group = new
                                        {
                                            Id = gr.ID,
                                            ImageUrl = "",
                                            Name = gr.Name.HtmlEncode(),
                                            Types = new List<object>()
                                        };

                        foreach (var type in sTypes)
                        {
                            var t = new
                                        {
                                            Id = type.ID,
                                            Name = type.Name.HtmlEncode(),
                                            Single = type.Single,
                                            IsSubscribed = type.CanSubscribe ? productSubscriptionManager.SubscriptionProvider.IsSubscribed(type.NotifyAction, GetCurrentRecipient(), null) : true
                                        };

                            if (t.IsSubscribed)
                                canUnsubscribe = true;

                            group.Types.Add(t);
                        }

                        groups.Add(group);
                        isEmpty = false;
                    }
                }

            }
            else if (productSubscriptionManager.GroupByType == GroupByType.Simple)
            {
                itemType = 0;
                var subscriptionTypes = productSubscriptionManager.GetSubscriptionTypes();
                if (subscriptionTypes != null)
                {
                    foreach (var type in subscriptionTypes)
                    {
                        if (type.IsEmptySubscriptionType != null && type.IsEmptySubscriptionType(webItem.ID, webItem.ID, type.ID))
                            continue;

                        var t = new
                                    {
                                        Id = type.ID,
                                        Name = type.Name.HtmlEncode(),
                                        Single = type.Single,
                                        IsSubscribed = type.CanSubscribe ? productSubscriptionManager.SubscriptionProvider.IsSubscribed(type.NotifyAction, GetCurrentRecipient(), null) : true
                                    };
                        if (t.IsSubscribed)
                            canUnsubscribe = true;

                        types.Add(t);
                        isEmpty = false;
                    }
                }
            }

            return new
                       {
                           Id = webItem.ID,
                           LogoUrl = webItem.GetIconAbsoluteURL(),
                           Name = HttpUtility.HtmlEncode(webItem.Name),
                           IsEmpty = isEmpty,
                           IsOpen = isOpen,
                           CanUnSubscribe = canUnsubscribe,
                           NotifyType = GetNotifyByMethod(webItem.ID),
                           Groups = groups,
                           Types = types,
                           Type = itemType
                       };
        }
Esempio n. 8
0
 public int GetSortOrder(IWebItem item)
 {
     return(item != null && item.Context != null ? item.Context.DefaultSortOrder : 0);
 }
Esempio n. 9
0
        internal static string GetSystemName(IWebItem webitem)
        {
            if (webitem == null)
            {
                return string.Empty;
            }

            if (webitem is IRenderMyTools)
            {
                return ((IRenderMyTools)webitem).ParameterName;
            }

            if (string.IsNullOrEmpty(webitem.StartURL))
            {
                return webitem.GetType().Name;
            };

            var parts = webitem.StartURL.ToLower().Split('/', '\\').ToList();

            if (webitem is IProduct)
            {
                var index = parts.FindIndex(s => "products".Equals(s));
                if (0 <= index && index < parts.Count - 1)
                {
                    return parts[index + 1];
                }
            }

            if (webitem is IModule)
            {
                var index = parts.FindIndex(s => "modules".Equals(s));
                if (0 <= index && index < parts.Count - 1)
                {
                    return parts[index + 1];
                }
            }

            if (webitem is IAddon)
            {
                var index = parts.FindIndex(s => "addons".Equals(s));
                if (0 <= index && index < parts.Count - 1)
                {
                    return parts[index + 1];
                }
            }

            return parts[parts.Count - 1].Split('.')[0];
        }
Esempio n. 10
0
 public static bool IsDisabled(this IWebItem item)
 {
     return(IsDisabled(item, SecurityContext.CurrentAccount.ID));
 }
Esempio n. 11
0
 public static bool IsLicensed(IWebItem item)
 {
     return true;
 }
Esempio n. 12
0
 public static bool HasComplexHierarchyOfAccessRights(this IWebItem item)
 {
     return(item.Context.HasComplexHierarchyOfAccessRights);
 }
Esempio n. 13
0
 public static bool CanNotBeDisabled(this IWebItem item)
 {
     return(item.Context.CanNotBeDisabled);
 }
Esempio n. 14
0
 public static List <string> GetAdminOpportunities(this IWebItem item)
 {
     return(item.Context.AdminOpportunities != null?item.Context.AdminOpportunities() : new List <string>());
 }
 public static bool IsSubItem(this IWebItem item)
 {
     return(item is IModule && !(item is IProduct));
 }
 public static bool IsDisabled(this IWebItem item, Guid userID)
 {
     return(item != null && (!WebItemSecurity.IsAvailableForUser(item.ID, userID) || !item.Visible));
 }
Esempio n. 17
0
 private void BuildLogo(SearchResult searchResult, ISearchHandlerEx sh, IWebItem module)
 {
     searchResult.LogoURL = GetLogo(sh, module);
 }
Esempio n. 18
0
 public static bool IsLicensed(IWebItem item)
 {
     return(true);
 }
Esempio n. 19
0
        private string GetLogo(ISearchHandlerEx sh, IWebItem module)
        {

            if (sh.GetType().Equals(typeof (EmployeeSearchHendler)))
                return WebImageSupplier.GetAbsoluteWebPath("employee.png");

            if (module != null)
                return module.GetIconAbsoluteURL();

            return WebImageSupplier.GetAbsoluteWebPath(sh.Logo.ImageFileName, sh.Logo.PartID);
        }
Esempio n. 20
0
        public static int GetSortOrder(IWebItem item)
        {
            if (item == null) return 0;

            var index = allowedItems.IndexOf(GetSystemName(item));
            if (index != -1) return index;

            return item.Context != null ? item.Context.DefaultSortOrder : 0;
        }
Esempio n. 21
0
        public static int GetSortOrder(IWebItem item, WebItemSettings settings)
        {
            if (item == null) return 0;

            if (settings != null && item.IsSubItem())
            {
                var s = settings.SettingsCollection.Find(o => o.ItemID == item.ID);
                if (s != null && s.SortOrder != int.MinValue) return s.SortOrder;
            }

            var index = allowedItems.IndexOf(GetSystemName(item));
            if (index != -1) return index;

            return item.Context != null ? item.Context.DefaultSortOrder : 0;
        }
        private object GetItemSubscriptions(IWebItem webItem, bool isOpen)
        {
            var isEmpty        = true;
            var canUnsubscribe = false;

            var groups   = new List <object>();
            var types    = new List <object>();
            var itemType = 1;

            var productSubscriptionManager = webItem.Context.SubscriptionManager as IProductSubscriptionManager;

            if (productSubscriptionManager.GroupByType == GroupByType.Modules)
            {
                foreach (var subItem in WebItemManager.Instance.GetSubItems(webItem.ID))
                {
                    if (subItem.Context == null || subItem.Context.SubscriptionManager == null)
                    {
                        continue;
                    }

                    var subscriptionTypes = subItem.Context.SubscriptionManager.GetSubscriptionTypes();
                    if (subscriptionTypes == null || subscriptionTypes.Count == 0)
                    {
                        continue;
                    }
                    else
                    {
                        subscriptionTypes = subscriptionTypes.FindAll(type => (type.IsEmptySubscriptionType != null && !type.IsEmptySubscriptionType(webItem.ID, subItem.ID, type.ID)));
                    }

                    if (subscriptionTypes == null || subscriptionTypes.Count == 0)
                    {
                        continue;
                    }

                    var group = new
                    {
                        Id       = subItem.ID,
                        ImageUrl = subItem.GetIconAbsoluteURL(),
                        Name     = subItem.Name.HtmlEncode(),
                        Types    = new List <object>()
                    };

                    foreach (var type in subscriptionTypes)
                    {
                        var t = new
                        {
                            Id           = type.ID,
                            Name         = type.Name.HtmlEncode(),
                            Single       = type.Single,
                            IsSubscribed = type.CanSubscribe ? subItem.Context.SubscriptionManager.SubscriptionProvider.IsSubscribed(type.NotifyAction, GetCurrentRecipient(), null) : true
                        };
                        if (t.IsSubscribed)
                        {
                            canUnsubscribe = true;
                        }

                        group.Types.Add(t);
                    }

                    groups.Add(group);
                    isEmpty = false;
                }
            }
            else if (productSubscriptionManager.GroupByType == GroupByType.Groups)
            {
                var subscriptionTypes  = productSubscriptionManager.GetSubscriptionTypes();
                var subscriptionGroups = productSubscriptionManager.GetSubscriptionGroups();
                if (subscriptionTypes != null && subscriptionGroups != null)
                {
                    foreach (var gr in subscriptionGroups)
                    {
                        var sTypes = subscriptionTypes.FindAll(type => (type.IsEmptySubscriptionType != null && !type.IsEmptySubscriptionType(webItem.ID, gr.ID, type.ID)));
                        if (sTypes == null || sTypes.Count == 0)
                        {
                            continue;
                        }

                        var group = new
                        {
                            Id       = gr.ID,
                            ImageUrl = "",
                            Name     = gr.Name.HtmlEncode(),
                            Types    = new List <object>()
                        };

                        foreach (var type in sTypes)
                        {
                            var t = new
                            {
                                Id           = type.ID,
                                Name         = type.Name.HtmlEncode(),
                                Single       = type.Single,
                                IsSubscribed = type.CanSubscribe ? productSubscriptionManager.SubscriptionProvider.IsSubscribed(type.NotifyAction, GetCurrentRecipient(), null) : true
                            };

                            if (t.IsSubscribed)
                            {
                                canUnsubscribe = true;
                            }

                            group.Types.Add(t);
                        }

                        groups.Add(group);
                        isEmpty = false;
                    }
                }
            }
            else if (productSubscriptionManager.GroupByType == GroupByType.Simple)
            {
                itemType = 0;
                var subscriptionTypes = productSubscriptionManager.GetSubscriptionTypes();
                if (subscriptionTypes != null)
                {
                    foreach (var type in subscriptionTypes)
                    {
                        if (type.IsEmptySubscriptionType != null && type.IsEmptySubscriptionType(webItem.ID, webItem.ID, type.ID))
                        {
                            continue;
                        }

                        var t = new
                        {
                            Id           = type.ID,
                            Name         = type.Name.HtmlEncode(),
                            Single       = type.Single,
                            IsSubscribed = !type.CanSubscribe || !productSubscriptionManager.SubscriptionProvider.IsUnsubscribe((IDirectRecipient)GetCurrentRecipient(), type.NotifyAction, null)
                        };
                        if (t.IsSubscribed)
                        {
                            canUnsubscribe = true;
                        }

                        types.Add(t);
                        isEmpty = false;
                    }
                }
            }

            return(new
            {
                Id = webItem.ID,
                LogoUrl = webItem.GetIconAbsoluteURL(),
                Name = HttpUtility.HtmlEncode(webItem.Name),
                IsEmpty = isEmpty,
                IsOpen = isOpen,
                CanUnSubscribe = canUnsubscribe,
                NotifyType = GetNotifyByMethod(webItem.ID),
                Groups = groups,
                Types = types,
                Type = itemType,
                Class = webItem.ProductClassName
            });
        }