public static void AddDesktopModuleToPortals(int desktopModuleID) { PortalController controller = new PortalController(); foreach (PortalInfo portal in controller.GetPortals()) { AddDesktopModuleToPortal(portal.PortalID, desktopModuleID, true, false); } DataCache.ClearHostCache(true); }
protected void PopulatePortal2DDL(string selected_value) { string ApplicationId = ddlApplicationList.SelectedValue; PortalController portal_obj = new PortalController(); DataTable dt = portal_obj.GetListByApplicationId(ApplicationId); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dt; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); ddlPortalList.SelectedValue = selected_value; }
protected void PopulatePortal2DDL(string selected_value) { PortalController portal_obj = new PortalController(); DataTable dt = portal_obj.GetList(); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dt; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); ddlPortalList.SelectedValue = selected_value; ddlPortalList.Enabled = false; }
private void Synchronize() { PortalController objPortals = new PortalController(); ArrayList arrPortals = objPortals.GetPortals(); PortalInfo objPortal; FileSystemUtils.Synchronize(Null.NullInteger, Null.NullInteger, Common.Globals.HostMapPath, false); int intIndex; for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++) { objPortal = (PortalInfo)arrPortals[intIndex]; FileSystemUtils.Synchronize(objPortal.PortalID, objPortal.AdministratorRoleId, objPortal.HomeDirectoryMapPath, false); } }
private void LoadPortalionList2DDL() { ddlPortalList.Items.Clear(); PortalController portal_obj = new PortalController(); DataTable dt = portal_obj.GetList(); //select all the nodes from DB ddlPortalList.DataSource = dt; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); //ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); ddlPortalList.SelectedValue = Session["PortalId"].ToString(); ddlPortalList.Enabled = false; }
private void PopulatePortalList2DDL() { PortalController portal_obj = new PortalController(); DataTable dtNodes = portal_obj.GetList(); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dtNodes; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); //ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); ddlPortalList.SelectedIndex = 0; ddlPortalList.AutoPostBack = true; }
private void LoadPortalionList2DDL() { ddlPortalList.Items.Clear(); string ApplicationId = ddlApplicationList.SelectedValue; PortalController portal_obj = new PortalController(); DataTable dt = portal_obj.GetListByApplicationId(ApplicationId); //select all the nodes from DB ddlPortalList.DataSource = dt; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); ddlPortalList.AutoPostBack = true; if(Session["PortalId"] !=null && Session["PortalId"].ToString() != string.Empty) ddlPortalList.SelectedValue = Session["PortalId"].ToString(); else ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); }
private void PopulatePortalList2DDL() { string ApplicationId = ddlApplicationList.SelectedValue; if (!string.IsNullOrEmpty(ApplicationId)) { PortalController portal_obj = new PortalController(); DataTable dtNodes = portal_obj.GetListByApplicationId(ApplicationId); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dtNodes; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); //ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); ddlPortalList.SelectedIndex = 0; ddlPortalList.AutoPostBack = true; } }
protected void PopulatePortal2DDL() { string ApplicationId = ddlApplicationList.SelectedValue; if (!string.IsNullOrEmpty(ApplicationId)) { PortalController portal_obj = new PortalController(); DataTable dt = portal_obj.GetListByApplicationId(ApplicationId); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dt; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "")); if (Session["PortalId"] != null && Session["PortalId"].ToString() != string.Empty) ddlPortalList.SelectedValue = Session["PortalId"].ToString(); else ddlPortalList.SelectedIndex = 0; } ddlPortalList.AutoPostBack = true; }
public static int AddDesktopModuleToPortal(int portalID, int desktopModuleID, bool addPermissions, bool clearCache) { int portalDesktopModuleID = Null.NullInteger; PortalDesktopModuleInfo portalDesktopModule = GetPortalDesktopModule(portalID, desktopModuleID); if (portalDesktopModule == null) { portalDesktopModuleID = DataProvider.Instance().AddPortalDesktopModule(portalID, desktopModuleID, UserController.GetCurrentUserInfo().UserID); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog("PortalDesktopModuleID", portalDesktopModuleID.ToString(), PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.PORTALDESKTOPMODULE_CREATED); if (addPermissions) { ArrayList permissions = PermissionController.GetPermissionsByPortalDesktopModule(); if (permissions.Count > 0) { PermissionInfo permission = permissions[0] as PermissionInfo; PortalInfo objPortal = new PortalController().GetPortal(portalID); if (permission != null && objPortal != null) { DesktopModulePermissionInfo desktopModulePermission = new DesktopModulePermissionInfo(permission); desktopModulePermission.RoleID = objPortal.AdministratorRoleId; desktopModulePermission.AllowAccess = true; desktopModulePermission.PortalDesktopModuleID = portalDesktopModuleID; DesktopModulePermissionController.AddDesktopModulePermission(desktopModulePermission); } } } } else { portalDesktopModuleID = portalDesktopModule.PortalDesktopModuleID; } if (clearCache) { DataCache.ClearPortalCache(portalID, true); } return portalDesktopModuleID; }
private void PopulatePortalList2DDL() { PortalController portal_obj = new PortalController(); DataTable dtNodes = portal_obj.GetList(); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dtNodes; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); ddlPortalList.AutoPostBack = true; //ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); if (Session["PortalId"] == null && Session["PortalId"].ToString() == string.Empty) { ddlPortalList.SelectedIndex = 0; ddlPortalList.Enabled = true; } else { ddlPortalList.SelectedValue = Session["PortalId"].ToString(); ddlPortalList.Enabled = false; } ddlPortalList.AutoPostBack = true; }
private void LoadData() { PortalController portal_obj = new PortalController(); DataTable dt = portal_obj.GetDetails(_idx); string PortalName = dt.Rows[0]["PortalName"].ToString(); string ApplicationId = dt.Rows[0]["ApplicationId"].ToString(); string ExpiryDate = dt.Rows[0]["ExpiryDate"].ToString(); string Currency = dt.Rows[0]["Currency"].ToString(); string HostFee = dt.Rows[0]["HostFee"].ToString(); string HostSpace = dt.Rows[0]["HostSpace"].ToString(); string DefaultLanguage = dt.Rows[0]["DefaultLanguage"].ToString(); string HomeDirectory = dt.Rows[0]["HomeDirectory"].ToString(); string Url = dt.Rows[0]["Url"].ToString(); string KeyWords = dt.Rows[0]["KeyWords"].ToString(); string FooterText = dt.Rows[0]["FooterText"].ToString(); string Description = dt.Rows[0]["Description"].ToString(); txtPortalName.Text = PortalName; txtExpiryDate.Text = ExpiryDate; txtHostFee.Text = HostFee; txtHostSpace.Text = HostSpace; txtHomeDirectory.Text = HomeDirectory; txtUrl.Text = Url; txtKeyWords.Text = KeyWords; txtFooterText.Text = FooterText; txtDescription.Text = Description; PopulateApplicationList2DDL(ApplicationId); PopulateLanguage2DDL(DefaultLanguage); // PopulateCurrencyTypeList2DDL(Currency); string logo_dir_path = "~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/portal_images/logo"; string background_dir_path = "~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/portal_images/backgrounds"; string LogoFile = dt.Rows[0]["LogoFile"].ToString(); HiddenLogoFile.Value = LogoFile; Logo_Img.ImageUrl = logo_dir_path + "/" + LogoFile; Logo_Img.Height = 50; Logo_Img.Width = 50; string BackgroundFile = dt.Rows[0]["BackgroundFile"].ToString(); HiddenBackgroundFile.Value = BackgroundFile; Background_Img.ImageUrl = background_dir_path + "/" + BackgroundFile; Background_Img.Height = 50; Background_Img.Width = 50; }
public static void AddModuleToPages(string tabPath, int ModuleDefId, string ModuleTitle, string ModuleIconFile, bool InheritPermissions) { PortalController objPortalController = new PortalController(); TabController objTabController = new TabController(); ArrayList portals = objPortalController.GetPortals(); foreach (PortalInfo portal in portals) { int tabID = TabController.GetTabByTabPath(portal.PortalID, tabPath); if ((tabID != Null.NullInteger)) { TabInfo tab = objTabController.GetTab(tabID, portal.PortalID, true); if ((tab != null)) { AddModuleToPage(tab, ModuleDefId, ModuleTitle, ModuleIconFile, InheritPermissions); } } } }
private void PopulatePortalList2DDL() { PortalController portal_obj = new PortalController(); DataTable dtNodes = portal_obj.GetList(); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dtNodes; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); //ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); string PortalId = Session["PortalId"].ToString(); if(!string.IsNullOrEmpty(PortalId)) { if (PortalId == "0") { ddlPortalList.SelectedIndex = 0; ddlPortalList.Enabled = true; } else { ddlPortalList.SelectedValue = PortalId; ddlPortalList.Enabled = false; } } }
private int UpdateData() { string ApplicationId = ddlApplicationList.SelectedValue; string PortalName = txtPortalName.Text; string Currency = ddlCurrencyTypeList.SelectedValue; string HostFee = txtHostFee.Text; int HostSpace = Convert.ToInt32(txtHostSpace.Text); string DefaultLanguage = ddlLanguageList.Text; string HomeDirectory = txtHomeDirectory.Text; string Url = txtUrl.Text; string KeyWords = txtKeyWords.Text; string FooterText = txtFooterText.Text; string Description = txtDescription.Text; string LastModifiedByUserId = Session["UserId"].ToString(); ; #region UPLOAD ************************************************************************************************************/ string logo_dir_path = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/portal_images/logo"); string background_dir_path = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/portal_images/backgrounds"); string LogoFile = string.Empty; string BackgroundFile = string.Empty; FileHandleClass file_handle_obj = new FileHandleClass(); HttpPostedFile _logo_file = InputLogoFile.PostedFile; if (_logo_file.ContentLength > 0) { string logo_file_path = logo_dir_path + "/" + HiddenLogoFile.Value; if (File.Exists(logo_file_path)) { File.Delete(logo_file_path); } LogoFile = file_handle_obj.uploadInputFile(_logo_file, logo_dir_path); } else { LogoFile = HiddenLogoFile.Value; } HttpPostedFile _background_file = InputBackgroundFile.PostedFile; if (_background_file.ContentLength > 0) { string background_file_path = background_dir_path + "/" + HiddenLogoFile.Value; if (File.Exists(background_file_path)) { File.Delete(background_file_path); } BackgroundFile = file_handle_obj.uploadInputFile(_background_file, background_dir_path); } else { BackgroundFile = HiddenBackgroundFile.Value; } #endregion ================================================================================ #region xu ly thoi gian ===================================================================================== System.Globalization.DateTimeFormatInfo MyDateTimeFormatInfo = new System.Globalization.DateTimeFormatInfo(); MyDateTimeFormatInfo.ShortDatePattern = "dd/MM/yyyy"; string ExpiryDate = null; if (txtExpiryDate.Text != string.Empty) { DateTime _ExpiryDate = DateTime.Parse(txtExpiryDate.Text, MyDateTimeFormatInfo); ExpiryDate = _ExpiryDate.ToString("yyyy-MM-dd"); } #endregion ==================================================================================================== PortalController portal_obj = new PortalController(); int i = portal_obj.Update(_idx, ApplicationId, PortalName, ExpiryDate, Currency, HostFee, HostSpace, DefaultLanguage, HomeDirectory, Url, LogoFile, BackgroundFile, KeyWords, FooterText, Description, LastModifiedByUserId); return i; }
public static string UnzipFile(string fileName, string DestFolder, PortalSettings settings) { ZipInputStream objZipInputStream = null; string strMessage = ""; try { int FolderPortalId = GetFolderPortalId(settings); bool isHost = settings.ActiveTab.ParentId == settings.SuperTabId; PortalController objPortalController = new PortalController(); CommonLibrary.Services.FileSystem.FolderController objFolderController = new CommonLibrary.Services.FileSystem.FolderController(); CommonLibrary.Services.FileSystem.FileController objFileController = new CommonLibrary.Services.FileSystem.FileController(); string sourceFolderName = Globals.GetSubFolderPath(fileName, FolderPortalId); string sourceFileName = GetFileName(fileName); CommonLibrary.Services.FileSystem.FolderInfo folder = objFolderController.GetFolder(FolderPortalId, sourceFolderName, false); CommonLibrary.Services.FileSystem.FileInfo file = objFileController.GetFile(sourceFileName, FolderPortalId, folder.FolderID); int storageLocation = folder.StorageLocation; ZipEntry objZipEntry; string strFileName = ""; string strExtension; try { objZipInputStream = new ZipInputStream(GetFileStream(file)); } catch (Exception ex) { return ex.Message; } ArrayList sortedFolders = new ArrayList(); objZipEntry = objZipInputStream.GetNextEntry(); while (objZipEntry != null) { if (objZipEntry.IsDirectory) { try { sortedFolders.Add(objZipEntry.Name.ToString()); } catch (Exception ex) { objZipInputStream.Close(); return ex.Message; } } objZipEntry = objZipInputStream.GetNextEntry(); } sortedFolders.Sort(); foreach (string s in sortedFolders) { try { AddFolder(settings, DestFolder, s.ToString(), storageLocation); } catch (Exception ex) { return ex.Message; } } objZipInputStream = new ZipInputStream(GetFileStream(file)); objZipEntry = objZipInputStream.GetNextEntry(); while (objZipEntry != null) { if (!objZipEntry.IsDirectory) { if (objPortalController.HasSpaceAvailable(FolderPortalId, objZipEntry.Size)) { strFileName = Path.GetFileName(objZipEntry.Name); if (!String.IsNullOrEmpty(strFileName)) { strExtension = Path.GetExtension(strFileName).Replace(".", ""); if (("," + Host.FileExtensions.ToLower()).IndexOf("," + strExtension.ToLower()) != 0 || isHost) { try { string folderPath = System.IO.Path.GetDirectoryName(DestFolder + objZipEntry.Name.Replace("/", "\\")); DirectoryInfo Dinfo = new DirectoryInfo(folderPath); if (!Dinfo.Exists) { AddFolder(settings, DestFolder, objZipEntry.Name.Substring(0, objZipEntry.Name.Replace("/", "\\").LastIndexOf("\\"))); } string zipEntryFileName = DestFolder + objZipEntry.Name.Replace("/", "\\"); strMessage += AddFile(FolderPortalId, objZipInputStream, zipEntryFileName, "", objZipEntry.Size, Globals.GetSubFolderPath(zipEntryFileName, settings.PortalId), false, false); } catch (Exception ex) { if (objZipInputStream != null) { objZipInputStream.Close(); } return ex.Message; } } else { strMessage += "<br>" + string.Format(Localization.GetString("RestrictedFileType"), strFileName, Host.FileExtensions.Replace(",", ", *.")); } } } else { strMessage += "<br>" + string.Format(Localization.GetString("DiskSpaceExceeded"), strFileName); } } objZipEntry = objZipInputStream.GetNextEntry(); } } finally { if (objZipInputStream != null) { objZipInputStream.Close(); objZipInputStream.Dispose(); } } return strMessage; }
/// ----------------------------------------------------------------------------- /// <summary> /// AddAdminPages adds an Admin Page and an associated Module to all configured Portals /// </summary> /// <param name="TabName">The Name to give this new Tab</param> /// <param name="TabIconFile">The Icon for this new Tab</param> /// <param name="IsVisible">A flag indicating whether the tab is visible</param> /// <param name="ModuleDefId">The Module Deinition Id for the module to be aded to this tab</param> /// <param name="ModuleTitle">The Module's title</param> /// <param name="ModuleIconFile">The Module's icon</param> /// <param name="InheritPermissions">Modules Inherit the Pages View Permisions</param> /// <history> /// [cnurse] 11/11/2004 created /// </history> /// ----------------------------------------------------------------------------- public static void AddAdminPages(string TabName, string Description, string TabIconFile, string TabIconFileLarge, bool IsVisible, int ModuleDefId, string ModuleTitle, string ModuleIconFile, bool InheritPermissions) { PortalController objPortals = new PortalController(); PortalInfo objPortal = default(PortalInfo); ArrayList arrPortals = objPortals.GetPortals(); int intPortal = 0; TabInfo newPage = default(TabInfo); //Add Page to Admin Menu of all configured Portals for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++) { objPortal = (PortalInfo)arrPortals[intPortal]; //Create New Admin Page (or get existing one) newPage = AddAdminPage(objPortal, TabName, Description, TabIconFile, TabIconFileLarge, IsVisible); //Add Module To Page AddModuleToPage(newPage, ModuleDefId, ModuleTitle, ModuleIconFile, InheritPermissions); } }
/// ----------------------------------------------------------------------------- /// <summary> /// RemoveCoreModule removes a Core Module from the system /// </summary> /// <remarks> /// </remarks> /// <param name="DesktopModuleName">The Friendly Name of the Module to Remove</param> /// <param name="ParentTabName">The Name of the parent Tab/Page for this module</param> /// <param name="TabName">The Name to tab that contains the Module</param> /// <param name="TabRemove">A flag to determine whether to remove the Tab if it has no /// other modules</param> /// <history> /// [cnurse] 10/14/2004 documented /// </history> /// ----------------------------------------------------------------------------- private static void RemoveCoreModule(string DesktopModuleName, string ParentTabName, string TabName, bool TabRemove) { int ParentId = 0; int intModuleDefId = Null.NullInteger; int intDesktopModuleId = 0; //Find and remove the Module from the Tab switch (ParentTabName) { case "Host": TabController objTabs = new TabController(); TabInfo objTab = objTabs.GetTabByName("Host", Null.NullInteger, Null.NullInteger); if (objTab != null) { intModuleDefId = RemoveModule(DesktopModuleName, TabName, objTab.TabID, TabRemove); } break; case "Admin": PortalController objPortals = new PortalController(); PortalInfo objPortal = default(PortalInfo); ArrayList arrPortals = objPortals.GetPortals(); int intPortal = 0; //Iterate through the Portals to remove the Module from the Tab for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++) { objPortal = (PortalInfo)arrPortals[intPortal]; ParentId = objPortal.AdminTabId; intModuleDefId = RemoveModule(DesktopModuleName, TabName, ParentId, TabRemove); } break; } DesktopModuleInfo objDesktopModule = null; if (intModuleDefId == Null.NullInteger) { objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName(DesktopModuleName, Null.NullInteger); intDesktopModuleId = objDesktopModule.DesktopModuleID; } else { //Get the Module Definition ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController(); ModuleDefinitionInfo objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(intModuleDefId); if (objModuleDefinition != null) { intDesktopModuleId = objModuleDefinition.DesktopModuleID; objDesktopModule = DesktopModuleController.GetDesktopModule(intDesktopModuleId, Null.NullInteger); } } if (objDesktopModule != null) { //Delete the Desktop Module DesktopModuleController objDesktopModules = new DesktopModuleController(); objDesktopModules.DeleteDesktopModule(intDesktopModuleId); //Delete the Package PackageController.DeletePackage(objDesktopModule.PackageID); } }
/// ----------------------------------------------------------------------------- /// <summary> /// AddSearchResults adds a top level Hidden Search Results Page /// </summary> /// <param name="ModuleDefId">The Module Deinition Id for the Search Results Module</param> /// <history> /// [cnurse] 11/11/2004 created /// </history> /// ----------------------------------------------------------------------------- private static void AddSearchResults(int ModuleDefId) { PortalController objPortals = new PortalController(); PortalInfo objPortal = default(PortalInfo); ArrayList arrPortals = objPortals.GetPortals(); int intPortal = 0; TabInfo newPage = default(TabInfo); //Add Page to Admin Menu of all configured Portals for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++) { Security.Permissions.TabPermissionCollection objTabPermissions = new Security.Permissions.TabPermissionCollection(); objPortal = (PortalInfo)arrPortals[intPortal]; AddPagePermission(objTabPermissions, "View", Convert.ToInt32(Common.Globals.glbRoleAllUsers)); AddPagePermission(objTabPermissions, "View", Convert.ToInt32(objPortal.AdministratorRoleId)); AddPagePermission(objTabPermissions, "Edit", Convert.ToInt32(objPortal.AdministratorRoleId)); //Create New Page (or get existing one) newPage = AddPage(objPortal.PortalID, Null.NullInteger, "Search Results", "", "", "", false, objTabPermissions, false); //Add Module To Page AddModuleToPage(newPage, ModuleDefId, "Search Results", ""); } }
private void LoadPortalList2DDL(string selected_value) { ddlPortalList.Items.Clear(); string ApplicationId = ddlApplicationList.SelectedValue; PortalController portal_obj = new PortalController(); DataTable dt = portal_obj.GetListByApplicationId(ApplicationId); ddlPortalList.DataSource = dt; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); //ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); ddlPortalList.SelectedValue = selected_value; //ddlPortalList.Enabled = false; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); #region Bind Handles optHost.CheckedChanged += new EventHandler(optHost_CheckedChanged); optSite.CheckedChanged += new EventHandler(optSite_CheckedChanged); cmdPreview.Click += new EventHandler(cmdPreview_Click); #endregion try { PortalController objPortals = new PortalController(); if (Request.QueryString["pid"] != null && (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId || UserController.GetCurrentUserInfo().IsSuperUser)) { _objPortal = objPortals.GetPortal(Int32.Parse(Request.QueryString["pid"])); } else { _objPortal = objPortals.GetPortal(PortalSettings.PortalId); } if (!Page.IsPostBack) { ViewState["SkinControlWidth"] = _Width; ViewState["SkinRoot"] = _SkinRoot; ViewState["SkinSrc"] = _SkinSrc; if (!String.IsNullOrEmpty(_Width)) { cboSkin.Width = System.Web.UI.WebControls.Unit.Parse(_Width); } if (!String.IsNullOrEmpty(_SkinSrc)) { switch (_SkinSrc.Substring(0, 3)) { case "[L]": optHost.Checked = false; optSite.Checked = true; break; case "[G]": optSite.Checked = false; optHost.Checked = true; break; } } else { string strRoot = _objPortal.HomeDirectoryMapPath + SkinRoot; if (Directory.Exists(strRoot) && Directory.GetDirectories(strRoot).Length > 0) { optHost.Checked = false; optSite.Checked = true; } } LoadSkins(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// AddPortal manages the Installation of a new DotNetNuke Portal /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 11/06/2004 created /// </history> /// ----------------------------------------------------------------------------- public static int AddPortal(XmlNode node, bool status, int indent) { try { int intPortalId = 0; string strHostPath = Common.Globals.HostMapPath; string strChildPath = ""; string strDomain = ""; if ((HttpContext.Current != null)) { strDomain = Globals.GetDomainName(HttpContext.Current.Request, true).ToLowerInvariant().Replace("/install", ""); } string strPortalName = XmlUtils.GetNodeValue(node.CreateNavigator(), "portalname"); if (status) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal: " + strPortalName + "<br>"); } PortalController objPortalController = new PortalController(); XmlNode adminNode = node.SelectSingleNode("administrator"); string strFirstName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "firstname"); string strLastName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "lastname"); string strUserName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "username"); string strPassword = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "password"); string strEmail = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "email"); string strDescription = XmlUtils.GetNodeValue(node.CreateNavigator(), "description"); string strKeyWords = XmlUtils.GetNodeValue(node.CreateNavigator(), "keywords"); string strTemplate = XmlUtils.GetNodeValue(node.CreateNavigator(), "templatefile"); string strServerPath = Globals.ApplicationMapPath + "\\"; bool isChild = bool.Parse(XmlUtils.GetNodeValue(node.CreateNavigator(), "ischild")); string strHomeDirectory = XmlUtils.GetNodeValue(node.CreateNavigator(), "homedirectory"); //Get the Portal Alias XmlNodeList portalAliases = node.SelectNodes("portalaliases/portalalias"); string strPortalAlias = strDomain; if (portalAliases.Count > 0) { if (!string.IsNullOrEmpty(portalAliases[0].InnerText)) { strPortalAlias = portalAliases[0].InnerText; } } //Create default email if (string.IsNullOrEmpty(strEmail)) { strEmail = "admin@" + strDomain.Replace("www.", ""); //Remove any domain subfolder information ( if it exists ) if (strEmail.IndexOf("/") != -1) { strEmail = strEmail.Substring(0, strEmail.IndexOf("/")); } } if (isChild) { strChildPath = strPortalAlias.Substring(strPortalAlias.LastIndexOf("/") + 1); } //Create Portal intPortalId = objPortalController.CreatePortal(strPortalName, strFirstName, strLastName, strUserName, strPassword, strEmail, strDescription, strKeyWords, strHostPath, strTemplate, strHomeDirectory, strPortalAlias, strServerPath, strServerPath + strChildPath, isChild); if (intPortalId > -1) { //Add Extra Aliases foreach (XmlNode portalAlias in portalAliases) { if (!string.IsNullOrEmpty(portalAlias.InnerText)) { if (status) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal Alias: " + portalAlias.InnerText + "<br>"); } objPortalController.AddPortalAlias(intPortalId, portalAlias.InnerText); } } //Force Administrator to Update Password on first log in PortalInfo objPortal = objPortalController.GetPortal(intPortalId); UserInfo objAdminUser = UserController.GetUserById(intPortalId, objPortal.AdministratorId); objAdminUser.Membership.UpdatePassword = true; UserController.UpdateUser(intPortalId, objAdminUser); } return intPortalId; } catch (Exception ex) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "<font color='red'>Error: " + ex.Message + "</font><br>"); // failure return -1; } }
private static void UpgradeToVersion_500() { PortalController objPortals = new PortalController(); ArrayList arrPortals = objPortals.GetPortals(); TabController controller = new TabController(); //Add Edit Permissions for Admin Tabs to legacy portals PermissionController permissionControler = new PermissionController(); TabPermissionController tabPermissionControler = new TabPermissionController(); ArrayList permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT"); int permissionID = Null.NullInteger; if (permissions.Count == 1) { PermissionInfo permission = permissions[0] as PermissionInfo; permissionID = permission.PermissionID; foreach (PortalInfo portal in arrPortals) { TabInfo adminTab = controller.GetTab(portal.AdminTabId, portal.PortalID, true); if (adminTab != null) { TabPermissionInfo tabPermission = new TabPermissionInfo(); tabPermission.TabID = adminTab.TabID; tabPermission.PermissionID = permissionID; tabPermission.AllowAccess = true; tabPermission.RoleID = portal.AdministratorRoleId; if (!TabPermissionExists(tabPermission, portal.PortalID)) { adminTab.TabPermissions.Add(tabPermission); } //Save Tab Permissions to Data Base TabPermissionController.SaveTabPermissions(adminTab); foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID)) { tabPermission = new TabPermissionInfo(); tabPermission.TabID = childTab.TabID; tabPermission.PermissionID = permissionID; tabPermission.AllowAccess = true; tabPermission.RoleID = portal.AdministratorRoleId; if (!TabPermissionExists(tabPermission, portal.PortalID)) { childTab.TabPermissions.Add(tabPermission); } //Save Tab Permissions to Data Base TabPermissionController.SaveTabPermissions(childTab); } } } } //Update Host/Admin modules Visibility setting bool superTabProcessed = Null.NullBoolean; ModuleController moduleController = new ModuleController(); foreach (PortalInfo portal in arrPortals) { if (!superTabProcessed) { //Process Host Tabs foreach (TabInfo childTab in TabController.GetTabsByParent(portal.SuperTabId, Null.NullInteger)) { foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values) { tabModule.Visibility = VisibilityState.None; moduleController.UpdateModule(tabModule); } } } //Process Portal Tabs foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID)) { foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values) { tabModule.Visibility = VisibilityState.None; moduleController.UpdateModule(tabModule); } } } //Upgrade PortalDesktopModules to support new "model" permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY"); if (permissions.Count == 1) { PermissionInfo permission = permissions[0] as PermissionInfo; permissionID = permission.PermissionID; foreach (PortalInfo portal in arrPortals) { foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values) { if (!desktopModule.IsPremium) { //Parse the permissions DesktopModulePermissionCollection deployPermissions = new DesktopModulePermissionCollection(); DesktopModulePermissionInfo deployPermission = default(DesktopModulePermissionInfo); // if Not IsAdmin add Registered Users if (!desktopModule.IsAdmin) { deployPermission = new DesktopModulePermissionInfo(); deployPermission.PermissionID = permissionID; deployPermission.AllowAccess = true; deployPermission.RoleID = portal.RegisteredRoleId; deployPermissions.Add(deployPermission); } // if Not a Host Module add Administrators string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions"; if (!hostModules.Contains(desktopModule.ModuleName)) { deployPermission = new DesktopModulePermissionInfo(); deployPermission.PermissionID = permissionID; deployPermission.AllowAccess = true; deployPermission.RoleID = portal.AdministratorRoleId; deployPermissions.Add(deployPermission); } //Add Portal/Module to PortalDesktopModules DesktopModuleController.AddDesktopModuleToPortal(portal.PortalID, desktopModule, deployPermissions, false); } } DataCache.ClearPortalCache(portal.PortalID, true); } } LegacyUtil.ProcessLegacyModules(); LegacyUtil.ProcessLegacyLanguages(); LegacyUtil.ProcessLegacySkins(); LegacyUtil.ProcessLegacySkinControls(); }
private static void AddAdminRoleToPage(string tabPath) { PortalController portalCtrl = new PortalController(); TabController tabCtrl = new TabController(); int tabID = 0; TabInfo tab = default(TabInfo); foreach (PortalInfo portal in portalCtrl.GetPortals()) { tabID = TabController.GetTabByTabPath(portal.PortalID, tabPath); if ((tabID != Null.NullInteger)) { tab = tabCtrl.GetTab(tabID, portal.PortalID, true); if ((tab.TabPermissions.Count == 0)) { AddPagePermission(tab.TabPermissions, "View", Convert.ToInt32(portal.AdministratorRoleId)); AddPagePermission(tab.TabPermissions, "Edit", Convert.ToInt32(portal.AdministratorRoleId)); TabPermissionController.SaveTabPermissions(tab); } } } }
private static void UpgradeToVersion_470() { string strHostTemplateFile = Globals.HostMapPath + "Templates\\Default.page.template"; if (File.Exists(strHostTemplateFile)) { PortalController objPortals = new PortalController(); ArrayList arrPortals = objPortals.GetPortals(); foreach (PortalInfo objPortal in arrPortals) { string strPortalTemplateFolder = objPortal.HomeDirectoryMapPath + "Templates\\"; if (!Directory.Exists(strPortalTemplateFolder)) { //Create Portal Templates folder Directory.CreateDirectory(strPortalTemplateFolder); } string strPortalTemplateFile = strPortalTemplateFolder + "Default.page.template"; if (!File.Exists(strPortalTemplateFile)) { File.Copy(strHostTemplateFile, strPortalTemplateFile); //Synchronize the Templates folder to ensure the templates are accessible FileSystemUtils.SynchronizeFolder(objPortal.PortalID, strPortalTemplateFolder, "Templates/", false, true, true, false); } } } }
private static void UpgradeToVersion_440() { // remove module cache files with *.htm extension ( they are now securely named *.resources ) PortalController objPortals = new PortalController(); ArrayList arrPortals = objPortals.GetPortals(); foreach (PortalInfo objPortal in arrPortals) { if (Directory.Exists(Globals.ApplicationMapPath + "\\Portals\\" + objPortal.PortalID.ToString() + "\\Cache\\")) { string[] arrFiles = Directory.GetFiles(Globals.ApplicationMapPath + "\\Portals\\" + objPortal.PortalID.ToString() + "\\Cache\\", "*.htm"); foreach (string strFile in arrFiles) { File.Delete(strFile); } } } }
public static DateTime CurrentTimeForUser(UserInfo User) { if (User == null || User.UserID == -1 || User.Profile.TimeZone == Null.NullInteger) { int intOffset = 0; PortalSettings objSettings = PortalController.GetCurrentPortalSettings(); if (objSettings != null) { intOffset = objSettings.TimeZoneOffset; } else { PortalInfo objPCtr = new PortalController().GetPortal(User.PortalID); intOffset = objPCtr.TimeZoneOffset; } return DateTime.UtcNow.AddMinutes(intOffset); } else { return DateTime.UtcNow.AddMinutes(User.Profile.TimeZone); } }
private static string CreateFile(string RootPath, string FileName, long ContentLength, string ContentType, Stream InputStream, string NewFileName, bool Unzip) { // Obtain PortalSettings from Current Context PortalSettings settings = PortalController.GetCurrentPortalSettings(); int PortalId = GetFolderPortalId(settings); bool isHost = (bool)(settings.ActiveTab.ParentId == settings.SuperTabId ? true : false); PortalController objPortalController = new PortalController(); string strMessage = ""; string strFileName = FileName; if (NewFileName != Null.NullString) strFileName = NewFileName; strFileName = RootPath + Path.GetFileName(strFileName); string strExtension = Path.GetExtension(strFileName).Replace(".", ""); string strFolderpath = Globals.GetSubFolderPath(strFileName, PortalId); CommonLibrary.Services.FileSystem.FolderController objFolders = new CommonLibrary.Services.FileSystem.FolderController(); CommonLibrary.Services.FileSystem.FolderInfo objFolder = objFolders.GetFolder(PortalId, strFolderpath, false); if (FolderPermissionController.CanAdminFolder(objFolder)) { if (objPortalController.HasSpaceAvailable(PortalId, ContentLength)) { if (("," + Host.FileExtensions.ToUpper()).IndexOf("," + strExtension.ToUpper()) != -1 || isHost) { //Save Uploaded file to server try { strMessage += AddFile(PortalId, InputStream, strFileName, ContentType, ContentLength, strFolderpath, true, true); //Optionally Unzip File? if (Path.GetExtension(strFileName).ToLower() == ".zip" & Unzip == true) { strMessage += UnzipFile(strFileName, RootPath, settings); } } catch (Exception exc) { // save error - can happen if the security settings are incorrect on the disk strMessage += "<br>" + string.Format(Localization.GetString("SaveFileError"), strFileName); exc.ToString(); } } else { // restricted file type strMessage += "<br>" + string.Format(Localization.GetString("RestrictedFileType"), strFileName, Host.FileExtensions.Replace(",", ", *.")); } } else { // file too large strMessage += "<br>" + string.Format(Localization.GetString("DiskSpaceExceeded"), strFileName); } } else { // insufficient folder permission in the application strMessage += "<br>" + string.Format(Localization.GetString("InsufficientFolderPermission"), strFolderpath); } return strMessage; }
private void PopulatePortalList2DDL(string selected_value) { PortalController portal_obj = new PortalController(); DataTable dtNodes = portal_obj.GetList(); ddlPortalList.Items.Clear(); ddlPortalList.DataSource = dtNodes; ddlPortalList.DataTextField = "PortalName"; ddlPortalList.DataValueField = "PortalId"; ddlPortalList.DataBind(); ddlPortalList.AutoPostBack = true; //ddlPortalList.Items.Insert(0, new ListItem("- Chọn -", "0")); if (string.IsNullOrEmpty(selected_value)) { ddlPortalList.SelectedIndex = 0; ddlPortalList.Enabled = true; } else { ddlPortalList.SelectedValue = selected_value; ddlPortalList.Enabled = false; } }
public static void RemoveAdminPages(string tabPath) { PortalController objPortalController = new PortalController(); TabController objTabController = new TabController(); ArrayList portals = objPortalController.GetPortals(); foreach (PortalInfo portal in portals) { int tabID = TabController.GetTabByTabPath(portal.PortalID, tabPath); if ((tabID != Null.NullInteger)) { objTabController.DeleteTab(tabID, portal.PortalID); } } }