Пример #1
0
 public App(int appId, int zoneId, PortalSettings ownerPS, IDataSource parentSource = null)
 {
     AppId = appId;
     ZoneId = zoneId;
     //InitialSource = parentSource;
     OwnerPS = ownerPS;
 }
Пример #2
0
        /// <summary>
        /// Returns the ZoneID from PortalSettings
        /// </summary>
        /// <param name="portalId"></param>
        /// <returns></returns>
        public static int? GetZoneID(int portalId)
        {
            // additional protection agains invalid portalid which may come from bad dnn configs and execute in search-index mode
            // see https://github.com/2sic/2sxc/issues/1054
            if (portalId < 0)
                throw new Exception("Can't get zone for invalid portal ID: " + portalId);

            var zoneSettingKey = Settings.PortalSettingsPrefix + "ZoneID";
            var c = PortalController.GetPortalSettingsDictionary(portalId);
            var portalSettings = new PortalSettings(portalId);

            int zoneId;

            // Create new zone automatically
            if (!c.ContainsKey(zoneSettingKey))
            {
                var newZone = AddZone(portalSettings.PortalName + " (Portal " + portalId + ")");
                SetZoneID(newZone.ZoneID, portalId);
                zoneId = newZone.ZoneID;
            }
            else
            {
                zoneId = Int32.Parse(c[zoneSettingKey]);
            }

            return zoneId;
        }
Пример #3
0
        public AdamNavigator(SxcInstance sexy, App app, PortalSettings ps, Guid entityGuid, string fieldName)
        {
            EntityBase = new EntityBase(sexy, app, ps, entityGuid, fieldName);
            Manager = new AdamManager(ps.PortalId, app);

            if (!Exists)
                return;

            var f = Manager.Get(Root) as FolderInfo;

            if (f == null)
                return;

            PortalID = f.PortalID;
            FolderPath = f.FolderPath;
            MappedPath = f.MappedPath;
            StorageLocation = f.StorageLocation;
            IsProtected = f.IsProtected;
            IsCached = f.IsCached;
            FolderMappingID = f.FolderMappingID;
            LastUpdated = f.LastUpdated;
            FolderID = f.FolderID;
            DisplayName = f.DisplayName;
            DisplayPath = f.DisplayPath;
            IsVersioned = f.IsVersioned;
            KeyID = f.KeyID;
            ParentID = f.ParentID;
            UniqueId = f.UniqueId;
            VersionGuid = f.VersionGuid;
            WorkflowID = f.WorkflowID;

            // IAdamItem interface properties
            Name = DisplayName;
        }
 public static void SetFilePathHack (this DnnFilePickerUploader picker, PortalSettings portalSettings)
 {
     if (picker.FileID > 0)
         picker.FilePath = FileManager.Instance.GetUrl (
             FileManager.Instance.GetFile (picker.FileID))
             .Remove (0, portalSettings.HomeDirectory.Length);
 }
Пример #5
0
        public TabInfo AddCoursePage(string tabName, string tabTitle)
        {
            PortalSettings portalSettings = new PortalSettings();
            int portalId = portalSettings.PortalId;

            TabController tabController = new TabController();
            TabInfo getTab = tabController.GetTabByName(tabName, portalId);
            if (getTab != null)
                throw new Exception("Cannot create Page. Page with this PageName already exists");

            TabInfo newTab = new TabInfo();
            newTab.PortalID = portalId;
            newTab.TabName = tabName;
            newTab.Title = tabTitle;
            newTab.SkinSrc = "[G]Skins/20047-UnlimitedColorPack-033/CoursePage.ascx";
            newTab.ContainerSrc = portalSettings.DefaultPortalContainer;
            CommonTabSettings(newTab);
            AddViewPermissions(newTab);

            int tabId = tabController.AddTab(newTab, true);
            DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(tabId);

            AddTabURL(newTab); //Makes the URL of Page /4 or /C4

            // add modules to new page

            AddModuleToPage(newTab, ModuleType.DisplayCourse);

            AddModuleToPage(newTab, ModuleType.Rating);

            AddModuleToPage(newTab, ModuleType.Comments);

            return newTab;
        }
    static public void EventLog(string title, string message, int userid)
    {
        DotNetNuke.Entities.Portals.PortalSettings          PS          = (DotNetNuke.Entities.Portals.PortalSettings)System.Web.HttpContext.Current.Items["PortalSettings"];
        DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();

        objEventLog.AddLog(title, message, PS, userid, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT);
    }
 public SyndicationFeedFormatter(PortalSettings portalSettings, HttpRequest request)
 {
     this.portalSettings = portalSettings;
     this.request = request;
     SupportedMediaTypes.Add(new MediaTypeHeaderValue(atom));
     SupportedMediaTypes.Add(new MediaTypeHeaderValue(rss));
 }
Пример #8
0
Файл: App.cs Проект: 2sic/2sxc
        //public App(int zoneId, int appId, PortalSettings ownerPortalSettings): this(...)
        // todo: I should change the order of the parameters app/zone because this is the only
        // system which reverses it with app-first
        // better to create two overloads, but when I have two parameters, assume that zone is first
        // 2016-04-04 2dm: wait with refactoring/correcting this till 2tk checks in his code
        public App(int zoneId, int appId, PortalSettings ownerPortalSettings, bool allowSideEffects = true)
        {
            // require valid ownerPS - note: not sure what this is actually used for
            if (ownerPortalSettings == null)
                throw new Exception("no portal settings received");

            // if zone is missing, try to find it; if still missing, throw error
            if (zoneId == -1) zoneId = ZoneHelpers.GetZoneID(ownerPortalSettings.PortalId) ?? -1;
            if (zoneId == -1) throw new Exception("Cannot find zone-id for portal specified");

            // Save basic values
            AppId = appId;
            ZoneId = zoneId;
            OwnerPortalSettings = ownerPortalSettings;

            // 2016-03-27 2dm: move a bunch of stuff to here from AppManagement.GetApp
            // the code there was a slight bit different, could still cause errors

            // Look up name
            // Get appName from cache
            AppGuid = ((BaseCache)DataSource.GetCache(zoneId, null)).ZoneApps[zoneId].Apps[appId];

            if (AppGuid == Constants.DefaultAppName)
                Name = Folder = ContentAppName;
            else
                InitializeResourcesSettingsAndMetadata(allowSideEffects);
        }
Пример #9
0
        public IHttpHandler GetDnnHttpHandler(RequestContext requestContext, int portal, int tab, string[] passThrough)
        {
            PortalController pcontroller = new PortalController();
            PortalInfo pinfo = pcontroller.GetPortal(portal);
            PortalAliasController pacontroller = new PortalAliasController();
            PortalAliasCollection pacollection = pacontroller.GetPortalAliasByPortalID(portal);
            //pacollection.
            //PortalSettings psettings = new PortalSettings(pinfo);
            PortalSettings psettings = new PortalSettings(tab, portal);               // 64 is the stats tab. TODO: get by page name and not hardcoded id
            foreach (string key in pacollection.Keys)
            {
                psettings.PortalAlias = pacollection[key];
            }
            TabController tcontroller = new TabController();
            // psettings.ActiveTab = tcontroller.GetTab(57, 0, true);                  // 57 is the profile tab.
            requestContext.HttpContext.Items["PortalSettings"] = psettings;

            requestContext.HttpContext.Items["UrlRewrite:OriginalUrl"] = requestContext.HttpContext.Request.RawUrl;
            //UserInfo uinfo = requestContext.HttpContext.User == null ? new UserInfo() : UserController.GetUserByName(psettings.PortalId, requestContext.HttpContext.User.Identity.Name);
            UserInfo uinfo = requestContext.HttpContext.User == null ? new UserInfo() : UserController.GetCachedUser(psettings.PortalId, requestContext.HttpContext.User.Identity.Name);
            requestContext.HttpContext.Items["UserInfo"] = uinfo;
            foreach (string s in passThrough)
            {
                requestContext.HttpContext.Items[s] = requestContext.RouteData.Values[s];
            }
            IHttpHandler page = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(DotNetNuke.Framework.PageBase)) as IHttpHandler;
            return page;
        }
        public static UniversityPortalConfig GetInstance (int portalId)
        {
            var lazyPortalConfig = portalConfigs.GetOrAdd (portalId, newKey => 
                new Lazy<UniversityPortalConfig> (() => {

                    var portalSettings = new PortalSettings (portalId);
                    var portalConfigFile = Path.Combine (portalSettings.HomeDirectoryMapPath, "R7.University.yml");

                    // ensure portal config file exists
                    if (!File.Exists (portalConfigFile)) {
                        File.Copy (Path.Combine (
                            Globals.ApplicationMapPath,
                            "DesktopModules\\R7.University\\R7.University\\R7.University.yml"), 
                            portalConfigFile);
                    }

                    using (var configReader = new StringReader (File.ReadAllText (portalConfigFile))) {
                        var deserializer = new Deserializer (namingConvention: new HyphenatedNamingConvention ());
                        return deserializer.Deserialize<UniversityPortalConfig> (configReader);
                    }
                }
                ));

            return lazyPortalConfig.Value;
        }
Пример #11
0
        /// <summary>
        ///   Includes page urls on the sitemap
        /// </summary>
        /// <remarks>
        ///   Pages that are included:
        ///   - are not deleted
        ///   - are not disabled
        ///   - are normal pages (not links,...)
        ///   - are visible (based on date and permissions)
        /// </remarks>
        public override List<SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            SitemapUrl pageUrl = null;
            var urls = new List<SitemapUrl>();

            useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False"));
            minPagePriority = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"), CultureInfo.InvariantCulture);
            includeHiddenPages = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "True"));

            this.ps = ps;

            foreach (TabInfo tab in TabController.Instance.GetTabsByPortal(portalId).Values.Where(t => !t.IsSystem))
            {
                if (!tab.IsDeleted && !tab.DisableLink && tab.TabType == TabType.Normal && (Null.IsNull(tab.StartDate) || tab.StartDate < DateTime.Now) &&
                    (Null.IsNull(tab.EndDate) || tab.EndDate > DateTime.Now) && IsTabPublic(tab.TabPermissions))
                {
                    if ((includeHiddenPages || tab.IsVisible) && tab.HasBeenPublished)
                    {
                        pageUrl = GetPageUrl(tab, (ps.ContentLocalizationEnabled) ? tab.CultureCode : null);
                        urls.Add(pageUrl);
                    }
                }
            }

            return urls;
        }
        public string BecomeUser(int userToBecomeId, int currentlyLoggedInUser, HttpContext context, PortalSettings portalSettings, HttpSessionState sessionState)
        {
            string url = string.Empty;
            string sessionStateName = string.Empty;
            if (Settings[ModuleSettingsNames.SessionObject] != null)
                sessionStateName = Settings[ModuleSettingsNames.SessionObject].ToString();
            if (userToBecomeId > 0)
            {
                DataCache.ClearUserCache(portalSettings.PortalId, context.User.Identity.Name);
                PortalSecurity portalSecurity = new PortalSecurity();
                portalSecurity.SignOut();

                UserInfo newUserInfo = UserController.GetUserById(portalSettings.PortalId, userToBecomeId);

                if (newUserInfo != null)
                {
                    sessionState.Contents[sessionStateName] = null;
                    UserController.UserLogin(portalSettings.PortalId, newUserInfo, portalSettings.PortalName, HttpContext.Current.Request.UserHostAddress, false);

                    if (currentlyLoggedInUser != 0)
                    {
                        sessionState[sessionStateName] = currentlyLoggedInUser;
                    }
                    else
                    {
                        sessionState[sessionStateName] = null;
                    }
                    url = (context.Request.UrlReferrer.AbsoluteUri);
                }
            }

            return url;
        }
        public static List<ListItem> GetTemplates(PortalSettings portalSettings, int ModuleId, string SelectedTemplate, string moduleSubDir)
        {
            string basePath = HostingEnvironment.MapPath(GetSiteTemplateFolder(portalSettings, moduleSubDir));
            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            List<ListItem> lst = new List<ListItem>();
            foreach (var dir in Directory.GetDirectories(basePath))
            {
                string TemplateCat = "Site";
                string DirName = Path.GetFileNameWithoutExtension(dir);
                int ModId = -1;
                if (int.TryParse(DirName, out ModId))
                {
                    if (ModId == ModuleId)
                    {
                        TemplateCat = "Module";
                    }
                    else
                    {
                        continue;
                    }
                }
                string scriptName = dir;
                if (TemplateCat == "Module")
                    scriptName = TemplateCat;
                else
                    scriptName = TemplateCat + ":" + scriptName.Substring(scriptName.LastIndexOf("\\") + 1);

                string scriptPath = ReverseMapPath(dir);
                var item = new ListItem(scriptName, scriptPath);
                if (!(string.IsNullOrEmpty(SelectedTemplate)) && scriptPath.ToLowerInvariant() == SelectedTemplate.ToLowerInvariant())
                {
                    item.Selected = true;
                }
                lst.Add(item);
            }
            // skin
            basePath = HostingEnvironment.MapPath(GetSkinTemplateFolder(portalSettings, moduleSubDir));
            if (Directory.Exists(basePath))
            {
                foreach (var dir in Directory.GetDirectories(basePath))
                {
                    string TemplateCat = "Skin";
                    string DirName = Path.GetFileNameWithoutExtension(dir);
                    string scriptName = dir;
                    scriptName = TemplateCat + ":" + scriptName.Substring(scriptName.LastIndexOf("\\") + 1);
                    string scriptPath = ReverseMapPath(dir);
                    var item = new ListItem(scriptName, scriptPath);
                    if (!(string.IsNullOrEmpty(SelectedTemplate)) && scriptPath.ToLowerInvariant() == SelectedTemplate.ToLowerInvariant())
                    {
                        item.Selected = true;
                    }
                    lst.Add(item);
                }
            }
            return lst;
        }
Пример #14
0
        /// <summary>
        /// Sends the notifications.
        /// </summary>
        /// <param name="uow">The Unit Of Work.</param>
        /// <param name="topic">The topic.</param>
        /// <param name="name">The name.</param>
        /// <param name="email">The email.</param>
        /// <param name="comment">The comment.</param>
        /// <param name="ipaddress">The IP Address.</param>
        public static void SendNotifications(
            UnitOfWork uow,
            Topic topic,
            string name,
            string email,
            string comment,
            string ipaddress)
        {
            if (topic != null)
            {
                List <string> lstEmailsAddresses = new TopicBO(uow).GetNotificationEmails(topic);

                if (lstEmailsAddresses.Count > 0)
                {
                    DotNetNuke.Entities.Portals.PortalSettings objPortalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();
                    string strResourceFile = Globals.ApplicationPath + "/DesktopModules/Wiki/Views/" + Localization.LocalResourceDirectory + "/" + Localization.LocalSharedResourceFile;
                    string strSubject      = Localization.GetString("NotificationSubject", strResourceFile);
                    string strBody         = Localization.GetString("NotificationBody", strResourceFile);

                    string redirectUrl = DotNetNuke.Common.Globals.NavigateURL(objPortalSettings.ActiveTab.TabID, objPortalSettings, string.Empty, "topic=" + WikiMarkup.EncodeTitle(topic.Name));
                    strBody = strBody.Replace("[URL]", redirectUrl);

                    strBody = strBody.Replace("[NAME]", name);
                    strBody = strBody.Replace("[EMAIL]", email);
                    strBody = strBody.Replace("[COMMENT]", comment);
                    strBody = strBody.Replace("[IP]", string.Empty);

                    System.Text.StringBuilder usersToEmailSB = new System.Text.StringBuilder();
                    foreach (string userToEmail in lstEmailsAddresses)
                    {
                        usersToEmailSB.Append(userToEmail);
                        usersToEmailSB.Append(";");
                    }

                    // remove the last ;
                    usersToEmailSB.Remove(usersToEmailSB.Length - 1, 1);

                    // Services.Mail.Mail.SendMail(objPortalSettings.Email, objPortalSettings.Email,
                    //// sbUsersToEmail.ToString, strSubject, strBody, "", "", "", "", "", "")

                    Mail.SendMail(
                        objPortalSettings.Email,
                        usersToEmailSB.ToString(),
                        string.Empty,
                        string.Empty,
                        MailPriority.Normal,
                        strSubject,
                        MailFormat.Html,
                        Encoding.UTF8,
                        strBody,
                        string.Empty,
                        Host.SMTPServer,
                        Host.SMTPAuthentication,
                        Host.SMTPUsername,
                        Host.SMTPPassword,
                        Host.EnableSMTPSSL);
                }
            }
        }
 public static Dictionary<string, string> GetResourceFile(PortalSettings portalSettings, string resourceFile, string locale)
 {
     return
         (Dictionary<string, string>) GetCompiledResourceFileCallBack(
             new CacheItemArgs("Compiled-" + resourceFile + "-" + locale + "-" + portalSettings.PortalId,
                 DataCache.ResourceFilesCacheTimeOut, DataCache.ResourceFilesCachePriority, resourceFile, locale,
                 portalSettings));
 }
Пример #16
0
        public AssetEditor(App app, string path, UserInfo userInfo, PortalSettings portalSettings, bool global = false)
        {
            _app = app;
            _userInfo = userInfo;
            _portalSettings = portalSettings;

            EditInfo = new AssetEditInfo(_app.AppId, _app.Name, path, global);
        }
Пример #17
0
 public SecurityGrid(DotNetNuke.Entities.Portals.PortalSettings ps, bool isReadOnly, string imgPath, PermissionInfo sec, int permId)
 {
     PortalSettings = ps;
     ReadOnly       = isReadOnly;
     ImagePath      = imgPath;
     Security       = sec;
     PermissionsId  = permId;
 }
 internal override string FriendlyUrl(TabInfo tab, string path, string pageName, PortalSettings portalSettings)
 {
     if (portalSettings == null)
     {
         throw new ArgumentNullException("portalSettings");
     }
     return FriendlyUrlInternal(tab, path, pageName, String.Empty, portalSettings);
 }
 public GroupViewParser(PortalSettings portalSettings, RoleInfo roleInfo, UserInfo currentUser, string template, int groupViewTabId)
 {
     PortalSettings = portalSettings;
     RoleInfo = roleInfo;
     CurrentUser = currentUser;
     Template = template;
     GroupViewTabId = groupViewTabId;
 }
 private static void SetThreadCulture(PortalSettings portalSettings)
 {
     CultureInfo pageLocale = TestableLocalization.Instance.GetPageLocale(portalSettings);
     if (pageLocale != null)
     {
         TestableLocalization.Instance.SetThreadCultures(pageLocale, portalSettings);
     }
 }
 public bool CanInjectModule(ModuleInfo module, PortalSettings portalSettings)
 {
     return ModulePermissionController.CanViewModule(module) 
             && module.IsDeleted == false 
             && ((module.StartDate < DateTime.Now && module.EndDate > DateTime.Now) 
                     || Globals.IsLayoutMode() 
                     || Globals.IsEditMode()
             );
 }
Пример #22
0
        //, bool global = false)
        public AssetEditor(App app, int templateId, UserInfo userInfo, PortalSettings portalSettings)
        {
            _app = app;
            _userInfo = userInfo;
            _portalSettings = portalSettings;

            var template = _app.TemplateManager.GetTemplate(templateId);
            EditInfo = TemplateAssetsInfo(template);
        }
        public virtual void ConfigureActiveTab(PortalSettings portalSettings)
        {
            var activeTab = portalSettings.ActiveTab;

            if (activeTab == null || activeTab.TabID == Null.NullInteger) return;

            UpdateSkinSettings(activeTab, portalSettings);

            activeTab.BreadCrumbs = new ArrayList(GetBreadcrumbs(activeTab.TabID, portalSettings.PortalId));
        }
Пример #24
0
        /// <summary>
        /// Returns all Apps for the current zone
        /// </summary>
        /// <param name="includeDefaultApp"></param>
        /// <returns></returns>
        public static List<App> GetApps(int zoneId, bool includeDefaultApp, PortalSettings ownerPS)
        {
            var eavApps = ((BaseCache)DataSource.GetCache(zoneId, null)).ZoneApps[zoneId].Apps;
            var sexyApps = eavApps.Select<KeyValuePair<int, string>, App>(eavApp => new App(zoneId, eavApp.Key, ownerPS));

            if (!includeDefaultApp)
                sexyApps = sexyApps.Where(a => a.Name != Constants.ContentAppName);

            return sexyApps.OrderBy(a => a.Name).ToList();
        }
Пример #25
0
        public static IApp App(int appId, PortalSettings ownerPortalSettings)
        {
            var appStuff = new App(ownerPortalSettings, appId);

            var provider = new ValueCollectionProvider(); // use blank provider for now

            appStuff.InitData(false, provider);

            return appStuff;
        }
Пример #26
0
        public void Constructor_Creates_Registration_Property()
        {
            //Arrange

            //Act
            var settings = new PortalSettings();

            //Assert
            Assert.IsNotNull(settings.Registration);
        }
    static public IQueryable <StaffBroker.User> GetStaff(params int[] ExcludeIDs)
    {
        DotNetNuke.Entities.Portals.PortalSettings PS = (DotNetNuke.Entities.Portals.PortalSettings)System.Web.HttpContext.Current.Items["PortalSettings"];

        StaffBrokerDataContext d = new StaffBrokerDataContext();
        var q = from c in d.Users where c.AP_StaffBroker_Staffs.Active && c.AP_StaffBroker_Staffs.PortalId == PS.PortalId && !(ExcludeIDs.Contains(c.UserID)) select c;

        q = q.Union(from c in d.Users join b in d.AP_StaffBroker_Staffs on c.UserID equals b.UserId2 where b.Active && b.PortalId == PS.PortalId && !(ExcludeIDs.Contains(c.UserID)) select c);
        return(q.OrderBy(c => c.LastName).ThenBy(c => c.FirstName));
    }
Пример #28
0
 public EntityBase(SxcInstance sexy, App app, PortalSettings ps, Guid eGuid, string fName)
 {
     _portalSettings = ps;
     _adamManager = new AdamManager(ps.PortalId, app);
     Sexy = sexy;
     App = app;
     //Dnn = dnn;
     entityGuid = eGuid;
     fieldName = fName;
 }
Пример #29
0
 public ErrorContainer( PortalSettings portalSettings, string strError, Exception exc )
 {
     UserInfo userInfo = UserController.GetCurrentUserInfo();
     if( userInfo.IsSuperUser )
     {
         this.Container = this.FormatException( strError, exc );
         return;
     }            
     //this.Container = this.FormatException( strError );
     this.Container = this.FormatException( strError, exc );
 }
Пример #30
0
 public ErrorContainer(PortalSettings _PortalSettings, string strError, Exception exc)
 {
     UserInfo objUserInfo = UserController.GetCurrentUserInfo();
     if (objUserInfo.IsSuperUser)
     {
         Container = FormatException(strError, exc);
     }
     else
     {
         Container = FormatException(strError);
     }
 }
Пример #31
0
        /// <summary>
        /// Sets a single sitemap item.
        /// </summary>
        /// <param name="objQuestion"></param>
        /// <param name="ps"></param>
        /// <returns></returns>
        private static SitemapUrl GetQuestionUrl(AlbumInfo objQuestion, PortalSettings ps)
        {
            var pageUrl = new SitemapUrl
                            {
                                Url = Links.ViewQuestion(objQuestion.AlbumID, objQuestion.TabID, ps),
                                Priority = (float) 0.5,
                                LastModified = objQuestion.LastModifiedOnDate,
                                ChangeFrequency = SitemapChangeFrequency.Daily
                            };

            return pageUrl;
        }
Пример #32
0
        /// <summary>
        /// Gets the list of users who have a given status.
        /// </summary>
        /// <param name="portalSettings">The settings of the portal in which the module is currently operating.</param>
        /// <param name="statusId">The ID of the status we're looking for.</param>
        /// <returns>A sequence of all users in the given portal.</returns>
        public static IEnumerable<UserStatusInfo> GetUsersWithStatus(PortalSettings portalSettings, int statusId)
        {
            if (portalSettings == null)
            {
                throw new ArgumentNullException("portalSettings");
            }

            var userStatusTable = DataProvider.Instance().GetUsersWithStatus(portalSettings.PortalId, statusId);

            return from DataRow row in userStatusTable.Rows
                   select FillUserInfo(row);
        }
        private static PortalSettings SetupPortalSettings(HttpRequestMessage request)
        {
            var domainName = TestableGlobals.Instance.GetDomainName(request.RequestUri);
            var alias = PortalAliasController.Instance.GetPortalAlias(domainName);

            int tabId;
            ValidateTabAndModuleContext(request, alias.PortalID, out tabId);

            var portalSettings = new PortalSettings(tabId, alias);

            request.GetHttpContext().Items["PortalSettings"] = portalSettings;
            return portalSettings;
        }
Пример #34
0
        /// <summary>
        /// This is used to populate a list of active questions to include in the SEO sitemap. 
        /// </summary>
        /// <param name="portalID"></param>
        /// <param name="ps"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public override List<SitemapUrl> GetUrls(int portalID, PortalSettings ps, string version)
        {
            var cntQa = new AlbumController();
            var colEntries = cntQa.GetSitemapQuestions(portalID);
            var urls = new List<SitemapUrl>();

            foreach (var objQuestion in colEntries)
            {
                urls.Add(GetQuestionUrl(objQuestion, ps));
            }

            return urls;
        }
Пример #35
0
        public static void CreatePortalFolder(DotNetNuke.Entities.Portals.PortalSettings PortalSettings, string FolderName)
        {
            bool blnCreated = false;

            //try normal test (doesn;t work on medium trust, but avoids waiting for GetFolder.)
            try
            {
                blnCreated = System.IO.Directory.Exists(PortalSettings.HomeDirectoryMapPath + FolderName);
            }
            catch (Exception ex)
            {
                blnCreated = false;
            }

            if (!blnCreated)
            {
                FolderManager.Instance.Synchronize(PortalSettings.PortalId, PortalSettings.HomeDirectory, true, true);
                var folderInfo = FolderManager.Instance.GetFolder(PortalSettings.PortalId, FolderName);
                if (folderInfo == null & !string.IsNullOrEmpty(FolderName))
                {
                    //add folder and permissions
                    try
                    {
                        FolderManager.Instance.AddFolder(PortalSettings.PortalId, FolderName);
                    }
                    catch (Exception ex)
                    {
                    }
                    folderInfo = FolderManager.Instance.GetFolder(PortalSettings.PortalId, FolderName);
                    if ((folderInfo != null))
                    {
                        int folderid = folderInfo.FolderID;
                        DotNetNuke.Security.Permissions.PermissionController objPermissionController = new DotNetNuke.Security.Permissions.PermissionController();
                        var arr = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "");
                        foreach (DotNetNuke.Security.Permissions.PermissionInfo objpermission in arr)
                        {
                            if (objpermission.PermissionKey == "WRITE")
                            {
                                // add READ permissions to the All Users Role
                                FolderManager.Instance.SetFolderPermission(folderInfo, objpermission.PermissionID, int.Parse(DotNetNuke.Common.Globals.glbRoleAllUsers));
                            }
                        }
                    }
                }
            }
        }
Пример #36
0
 protected override void RenderContents(HtmlTextWriter writer)
 {
     if (UserId == -1)
     {
         return;
     }
     try
     {
         string output = string.Empty;
         DotNetNuke.Entities.Portals.PortalSettings ps = (DotNetNuke.Entities.Portals.PortalSettings)(Context.Items["PortalSettings"]);
         DotNetNuke.Entities.Users.UserInfo         cu = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
         string imagePath = string.Empty;
         int    portalId  = ps.PortalId;
         string tmp       = string.Empty;
         if (Template == null)
         {
             tmp = "<span class=\"aslabelsmbold\">[RESX:Posts]:</span> [AF:PROFILE:POSTCOUNT]<br />" + "<span class=\"aslabelsmbold\">[RESX:RankName]:</span> [AF:PROFILE:RANKNAME]<br />" + "<span class=\"aslabelsmbold\">[RESX:RankDisplay]:</span> [AF:PROFILE:RANKDISPLAY] <br />" + "<span class=\"aslabelsmbold\">[RESX:LastUpdate]:</span> [AF:PROFILE:DATELASTACTIVITY:d] <br />" + "<span class=\"aslabelsmbold\">[RESX:MemberSince]:</span> [AF:PROFILE:DATECREATED:d]";
         }
         else
         {
             tmp = Template.Text;
         }
         if (ModuleId == -1)
         {
             DotNetNuke.Entities.Modules.ModuleController mc = new DotNetNuke.Entities.Modules.ModuleController();
             DotNetNuke.Entities.Tabs.TabController       tc = new DotNetNuke.Entities.Tabs.TabController();
             DotNetNuke.Entities.Tabs.TabInfo             ti = null;
             foreach (DotNetNuke.Entities.Modules.ModuleInfo mi in mc.GetModules(portalId))
             {
                 if (mi.DesktopModule.ModuleName.ToUpperInvariant() == "Active Forums".ToUpperInvariant())
                 {
                     ModuleId = mi.ModuleID;
                     break;
                 }
             }
         }
         output = TemplateUtils.ParseProfileTemplate(tmp, UserId, portalId, ModuleId, cu.UserID, Convert.ToInt32(PortalSettings.Current.TimeZone.BaseUtcOffset.TotalMinutes));
         output = Utilities.LocalizeControl(output);
         writer.Write(output);
     }
     catch (Exception ex)
     {
         writer.Write(ex.Message);
     }
 }
Пример #37
0
    static public AP_StaffBroker_Department CreateDept(string Name, string RC, int manager, int?del)
    {
        StaffBrokerDataContext d = new StaffBrokerDataContext();

        DotNetNuke.Entities.Portals.PortalSettings PS = (DotNetNuke.Entities.Portals.PortalSettings)System.Web.HttpContext.Current.Items["PortalSettings"];
        if (del == 0)
        {
            del = null;
        }
        var q = from c in d.AP_StaffBroker_Departments where c.CostCentre == RC && c.PortalId == PS.PortalId select c;

        if (q.Count() > 0)
        {
            q.First().Name = Name;
            q.First().CostCentreManager  = manager;
            q.First().CostCentreDelegate = del;
            d.SubmitChanges();
            return(q.First());
        }
        else
        {
            AP_StaffBroker_Department insert = new AP_StaffBroker_Department();
            insert.PortalId          = PS.PortalId;
            insert.Name              = Name;
            insert.CostCentre        = RC;
            insert.CostCentreManager = manager;
            insert.CanRmb            = true;
            insert.CanGiveTo         = false;

            insert.CanCharge      = false;
            insert.IsProject      = false;
            insert.Spare1         = "False";
            insert.GivingText     = "";
            insert.GivingShortcut = "";
            insert.PayType        = "";


            insert.CostCentreDelegate = del;

            d.AP_StaffBroker_Departments.InsertOnSubmit(insert);
            d.SubmitChanges();
            return(insert);
        }
    }
Пример #38
0
        public List <MenuNode> ManipulateNodes(List <MenuNode> nodes, DotNetNuke.Entities.Portals.PortalSettings portalSettings)
        {
            _objCtrl = new NBrightDataController();
            var nodeTabList = "*";

            foreach (var n in nodes)
            {
                nodeTabList += n.Text + n.TabId + "*" + n.Breadcrumb + "*";
            }
            var cachekey = "NBrightPL*" + portalSettings.PortalId + "*" + Utils.GetCurrentCulture() + "*" + nodeTabList; // use nodeTablist incase the DDRMenu has a selector.
            var rtnnodes = (List <MenuNode>)Utils.GetCache(cachekey);

            if (rtnnodes != null)
            {
                return(rtnnodes);
            }

            nodes = BuildNodes(nodes, portalSettings);

            var dataRecord = _objCtrl.GetByGuidKey(portalSettings.PortalId, -1, "SETTINGS", "NBrightPL");

            if (dataRecord != null)
            {
                var menuproviders = dataRecord.GetXmlProperty("genxml/textbox/menuproviders");
                var provlist      = menuproviders.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
                foreach (var p in provlist)
                {
                    var prov = CreateProvider(p);
                    if (prov != null)
                    {
                        nodes = prov.ManipulateNodes(nodes, portalSettings);
                    }
                }
            }

            Utils.SetCache(cachekey, nodes);

            return(nodes);
        }
Пример #39
0
    static public Boolean IsDept(int PortalId, string costCenter)
    {
        DotNetNuke.Entities.Portals.PortalSettings PS = (DotNetNuke.Entities.Portals.PortalSettings)System.Web.HttpContext.Current.Items["PortalSettings"];
        StaffBrokerDataContext d = new StaffBrokerDataContext();

        if (GetSetting("NonDynamics", PS.PortalId) == "True")
        {
            return((from c in d.AP_StaffBroker_Departments where c.CostCentre.ToLower() == costCenter.ToLower() && c.PortalId == PS.PortalId select c.CostCenterId).Count() > 0);
        }
        else
        {
            var cc = from c in d.AP_StaffBroker_CostCenters where c.CostCentreCode == costCenter select c.Type;
            if (cc.Count() > 0)
            {
                return(cc.First() == CostCentreType.Department);
            }

            else
            {
                return(false);
            }
        }
    }
Пример #40
0
        private List <MenuNode> BuildNodes(List <MenuNode> nodes, DotNetNuke.Entities.Portals.PortalSettings portalSettings)
        {
            foreach (var n in nodes)
            {
                var dataRecord = _objCtrl.GetByGuidKey(portalSettings.PortalId, -1, "PL", n.TabId.ToString(""));
                if (dataRecord != null)
                {
                    var dataRecordLang = _objCtrl.GetDataLang(dataRecord.ItemID, Utils.GetCurrentCulture());
                    if (dataRecordLang != null)
                    {
                        n.Text        = dataRecordLang.GetXmlProperty("genxml/textbox/pagename");
                        n.Keywords    = dataRecordLang.GetXmlProperty("genxml/textbox/tagwords");
                        n.Title       = dataRecordLang.GetXmlProperty("genxml/textbox/pagetitle");
                        n.Description = dataRecordLang.GetXmlProperty("genxml/textbox/pagedescription");

                        if (n.Children.Count > 0)
                        {
                            BuildNodes(n.Children, portalSettings);
                        }
                    }
                }
            }
            return(nodes);
        }
Пример #41
0
        public List <MenuNode> ManipulateNodes(List <MenuNode> nodes, DotNetNuke.Entities.Portals.PortalSettings portalSettings)
        {
            // jump out if we don't have [CAT] token in nodes
            if (nodes.Count(x => x.Text.ToUpper() == "[CAT]") == 0)
            {
                return(nodes);
            }

            // use cache ()
            var nodeTabList = "*";

            foreach (var n in nodes)
            {
                nodeTabList += n.Text + n.TabId + "*" + n.Breadcrumb + "*";
            }
            var cachekey = "NBrightPL*" + portalSettings.PortalId + "*" + Utils.GetCurrentCulture() + "*" + nodeTabList; // use nodeTablist incase the DDRMenu has a selector.
            var rtnnodes = (List <MenuNode>)Utils.GetCache(cachekey);

            if (rtnnodes != null)
            {
                return(rtnnodes);
            }

            _tabid = PortalSettings.Current.ActiveTab.TabID.ToString("");

            var defaultListPage = "";

            defaultListPage = StoreSettings.Current.Get("productlisttab");

            var catNodeList = GetCatNodeXml(_tabid, 0, true, 0, null, defaultListPage);

            // see if we need to merge into the current pages, by searching for marker page [cat]
            int idx     = 0;
            var catNods = new Dictionary <int, MenuNode>();

            foreach (var n in nodes)
            {
                if (n.Text.ToLower() == "[cat]")
                {
                    catNods.Add(idx, n);
                    break;
                }
                idx += 1;
            }


            if (catNods.Count > 0)
            {
                foreach (var catNod in catNods)
                {
                    // remove marker page [cat]
                    nodes.Remove(catNod.Value);
                }
                var insidx = idx;
                foreach (var n2 in catNodeList)
                {
                    if (n2.Parent == null)
                    {
                        nodes.Insert(insidx, n2);
                    }
                    insidx += 1;
                }
            }

            Utils.SetCacheList(cachekey, nodes, "category_cachelist");

            return(nodes);
        }
        //public string PageName { get; }


        public void Init(string[] args, DotNetNuke.Entities.Portals.PortalSettings portalSettings, DotNetNuke.Entities.Users.UserInfo userInfo, int activeTabId)
        {
            Initialize(args, portalSettings, userInfo, activeTabId);
            StringBuilder sbErrors = new StringBuilder();

            if (HasFlag(FLAG_PAGEID))
            {
                int tmpId = 0;
                if (int.TryParse(Flag(FLAG_PAGEID), out tmpId))
                {
                    PageId = tmpId;
                }
                else
                {
                    sbErrors.AppendFormat("When used, the --{0} flag must be an integer; ", FLAG_PAGEID);
                }
            }
            else
            {
                if (args.Length >= 2 && !IsFlag(args[1]))
                {
                    // attempt to parse first arg as the page ID
                    int tmpId = 0;
                    if (int.TryParse(args[1], out tmpId))
                    {
                        PageId = tmpId;
                    }
                    else
                    {
                        sbErrors.AppendFormat("No valid Page ID found. Pass it using the --{0} flag or by sending it as the first argument after the command name", FLAG_PAGEID);
                    }
                }
            }

            if (!PageId.HasValue)
            {
                PageId = base.TabId;
            }


            ModuleName  = Flag(FLAG_NAME);
            ModuleTitle = Flag(FLAG_TITLE);
            All         = HasFlag(FLAG_ALL);
            if (HasFlag(FLAG_DELETED))
            {
                bool tmp = false;
                if (bool.TryParse(Flag(FLAG_DELETED), out tmp))
                {
                    Deleted = tmp;
                }
                else
                {
                    if (Flag(FLAG_DELETED, null) == null)
                    {
                        // user specified deleted flag with no value. Default to True
                        Deleted = true;
                    }
                }
            }

            ValidationMessage = sbErrors.ToString();
        }
Пример #43
0
        public override bool CheckForRedirect(int tabId, int portalid, string httpAlias, Uri requestUri, NameValueCollection queryStringCol, FriendlyUrlOptions options, out string redirectLocation,
                                              ref List <string> messages)
        {
            bool doRedirect = false;

            redirectLocation = "";//set blank location
            //compare to known pattern of old Urls
            string path = requestUri.AbsoluteUri;

            if (string.IsNullOrEmpty(path) == false && Regex.IsMatch(path, @"(^|/)(mid|moduleId)/\d+/?", RegexOptions.IgnoreCase) == false)
            {
                //could be in old /groupId/xx format - if so, we want to redirect it
                Regex pathRegex = new Regex(@"/groupid/(?<groupid>\d+)", RegexOptions.IgnoreCase);
                Match pathMatch = pathRegex.Match(path);
                if (pathMatch.Success)
                {
                    string groupIdRaw = pathMatch.Groups["groupid"].Value;
                    int    groupId;
                    if (int.TryParse(groupIdRaw, out groupId))
                    {
                        //ok, valid item Id found
                        //get the valid Url for this item
                        Hashtable friendlyUrlIndex = UrlController.GetFriendlyUrlIndex(portalid, this, options);
                        //look up the friendly url index using the item key
                        string furlKey = FriendlyUrlInfo.MakeKey("group", groupId);
                        if (friendlyUrlIndex != null)
                        {
                            string        friendlyUrl = null;
                            TabController tc          = new TabController();
                            TabInfo       tab         = tc.GetTab(tabId, portalid, false);
                            if (tab != null && tab.ParentId == GroupPagePathTabId)
                            {
                                //this is the child tab of the group tab
                                string cpFurlKey = "t" + tabId.ToString() + furlKey;
                                friendlyUrl = (string)friendlyUrlIndex[cpFurlKey];
                            }
                            if (friendlyUrl == null)
                            {
                                friendlyUrl = (string)friendlyUrlIndex[furlKey];
                            }
                            if (friendlyUrl != null)
                            {
                                //ok, we're going to replace this in the Url
                                if (HideGroupPagePath == false)
                                {
                                    friendlyUrl = base.EnsureLeadingChar("/", friendlyUrl);
                                    string result = pathRegex.Replace(path, friendlyUrl);
                                    doRedirect       = true;
                                    redirectLocation = result;
                                }
                                else
                                {
                                    DotNetNuke.Entities.Portals.PortalAliasInfo pa = DotNetNuke.Entities.Portals.PortalAliasController.GetPortalAliasInfo(httpAlias);
                                    if (pa != null)
                                    {
                                        DotNetNuke.Entities.Portals.PortalSettings ps = new DotNetNuke.Entities.Portals.PortalSettings(tabId, pa);
                                        redirectLocation = DotNetNuke.Common.Globals.NavigateURL(tabId, ps, "", "groupid=" + groupId);
                                        doRedirect       = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(doRedirect);
        }
Пример #44
0
        public List <MenuNode> ManipulateNodes(List <MenuNode> nodes, DotNetNuke.Entities.Portals.PortalSettings portalSettings)
        {
            // jump out if we don't have [CAT] token in nodes
            if (nodes.Count(x => x.Text.ToUpper() == "[CAT]") == 0)
            {
                return(nodes);
            }

            var nameValueCollection = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query);

            _catid      = nameValueCollection["catid"];
            _catguidkey = nameValueCollection["category"];

            _tabid = PortalSettings.Current.ActiveTab.TabID.ToString("");

            var defaultListPage = "";

            defaultListPage = StoreSettings.Current.Get("productlisttab");

            var catNodeList = GetCatNodeXml(_tabid, 0, true, 0, null, defaultListPage);

            // [TODO: We want to cache this data, but doing so brakes the menu, becuase the cache is by Reference to the object, which is changed on display to fit into the menu.  We can't easily clone the object because MenuNode doesn't support IClone, need to find a way around this.]
            //const string cacheListKey = "catnodesxml_list"; // keep a list of menu nodes so we can remove them
            //var cacheKey = "catnodesxml_" + _tabid;
            //var catNodeList = (List<MenuNode>)Utils.GetCache(cacheKey);
            //if (catNodeList == null)
            //{
            //    catNodeList = GetCatNodeXml(_tabid);
            //    Utils.SetCache(cacheKey, catNodeList);
            //    var keylist = (List<String>)Utils.GetCache(cacheListKey) ?? new List<string>();
            //    keylist.Add(cacheKey);
            //    Utils.SetCache(cacheListKey, keylist);
            //}
            //if (catNodeList.Count >= 1) catNodeList[0].Parent = null;
            //Utils.RemoveCache(cacheKey);

            // see if we need to merge into the current pages, by searching for marker page [cat]
            int idx     = 0;
            var catNods = new Dictionary <int, MenuNode>();

            foreach (var n in nodes)
            {
                if (n.Text.ToLower() == "[cat]")
                {
                    catNods.Add(idx, n);
                    break;
                }
                idx += 1;
            }


            if (catNods.Count > 0)
            {
                foreach (var catNod in catNods)
                {
                    // remove marker page [cat]
                    nodes.Remove(catNod.Value);
                }
                var insidx = idx;
                foreach (var n2 in catNodeList)
                {
                    if (n2.Parent == null)
                    {
                        nodes.Insert(insidx, n2);
                    }
                    insidx += 1;
                }
            }

            return(nodes);
        }
Пример #45
0
        public List <MenuNode> ManipulateNodes(List <MenuNode> nodes, DotNetNuke.Entities.Portals.PortalSettings portalSettings)
        {
            var parentcatref = "";

            // jump out if we don't have [CAT] token in nodes
            if (nodes.Count(x => x.Text.ToUpper() == "[CAT]") == 0 && nodes.Count(x => x.Text.ToUpper().StartsWith("[CAT:")) == 0)
            {
                return(nodes);
            }

            // use cache ()
            var nodeTabList = "*";

            foreach (var n in nodes)
            {
                nodeTabList += n.Text + n.TabId + "*" + n.Breadcrumb + "*";
            }
            var cachekey = "NBrightPL*" + portalSettings.PortalId + "*" + Utils.GetCurrentCulture() + "*" + nodeTabList; // use nodeTablist incase the DDRMenu has a selector.
            var rtnnodes = (List <MenuNode>)Utils.GetCache(cachekey);

            if (rtnnodes != null)
            {
                return(rtnnodes);
            }

            var categoryInjectList = new Dictionary <int, int>();
            var idx1     = 0;
            var listCats = new List <int>();

            if (nodes.Count(x => x.Text.ToUpper().StartsWith("[CAT")) > 0)
            {
                // find the selected node.
                var nods = nodes.Where(x => (x.Text.ToUpper().StartsWith("[CAT"))).ToList();
                foreach (var n in nods)
                {
                    if (n.Text.ToUpper().StartsWith("[CAT:"))
                    {
                        var s = n.Text.Split(':');
                        if (s.Count() >= 2)
                        {
                            parentcatref = s[1].TrimEnd(']');
                            var objCtrl   = new NBrightBuyController();
                            var parentcat = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", parentcatref);
                            if (parentcat != null)
                            {
                                listCats.Add(parentcat.ItemID);
                                categoryInjectList.Add(idx1, n.TabId);
                                idx1 += 1;
                            }
                        }
                    }
                    else
                    {
                        categoryInjectList.Add(0, n.TabId);
                        listCats.Add(0);
                    }
                }
            }
            var lp = 0;

            foreach (var parentItemId in listCats)
            {
                _tabid = PortalSettings.Current.ActiveTab.TabID.ToString("");

                var defaultListPage = "";
                defaultListPage = StoreSettings.Current.Get("productlisttab");

                var catNodeList = GetCatNodeXml(_tabid, categoryInjectList[lp], parentItemId, true, 0, null, defaultListPage);

                // see if we need to merge into the current pages, by searching for marker page [cat]
                int idx     = 0;
                var catNods = new Dictionary <int, MenuNode>();
                foreach (var n in nodes)
                {
                    if (n.Text.ToLower() == "[cat]" || n.Text.ToLower().StartsWith("[cat:"))
                    {
                        catNods.Add(idx, n);
                        break;
                    }
                    idx += 1;
                }


                if (catNods.Count > 0)
                {
                    foreach (var catNod in catNods)
                    {
                        // remove marker page [cat]
                        nodes.Remove(catNod.Value);
                    }
                    var insidx = idx;
                    foreach (var n2 in catNodeList)
                    {
                        if (n2.Parent == null)
                        {
                            nodes.Insert(insidx, n2);
                        }
                        insidx += 1;
                    }
                }
                lp += 1;
            }

            Utils.SetCacheList(cachekey, nodes, "category_cachelist");
            return(nodes);
        }
 /// <summary>
 /// Detect whether current page is custom error page.
 /// </summary>
 /// <param name="portalSettings"></param>
 /// <returns></returns>
 public static bool InErrorPageRequest(this PortalSettings portalSettings)
 {
     return(portalSettings.ActiveTab.TabID == portalSettings.ErrorPage404 ||
            portalSettings.ActiveTab.TabID == portalSettings.ErrorPage500);
 }