Ejemplo n.º 1
0
        private static void AddPortal(XmlNode portal)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            XmlNodeList childList = portal.ChildNodes;
            for (int i = 0; i < childList.Count; i++)
                data.Add(childList.Item(i).Name, childList.Item(i).InnerText);

            if (!data.ContainsKey("toid")) return;
            try
            {
                Dictionary<byte,PortalInfo> tmpdic;
                System.Globalization.CultureInfo culture;
                culture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
                PortalInfo nPortal = new PortalInfo(int.Parse(data["toid"]), float.Parse(data["x"],culture), float.Parse(data["y"],culture), float.Parse(data["z"],culture));
                if (data.ContainsKey("mapid"))
                    nPortal.m_mapID = byte.Parse(data["mapid"]);
                if (!portals.ContainsKey(byte.Parse(data["toid"])))
                {
                    tmpdic = new Dictionary<byte, PortalInfo>();
                    tmpdic.Add(byte.Parse(data["fromid"]), nPortal);
                    portals.Add(byte.Parse(data["toid"]), tmpdic);
                }
                else
                {
                    tmpdic = portals[byte.Parse(data["toid"])];
                    tmpdic.Add(byte.Parse(data["fromid"]), nPortal);
                }

            }
            catch (Exception e) { Logger.ShowError("cannot parse: " + data["toid"],null); Logger.ShowError(e,null); return; }
        }
Ejemplo n.º 2
0
 // --------------------------------------------------------------------------------
 // AccountToPortal
 // --------------------------------------------------------------------------------
 // Set portal
 public static Coroutine SetPortal(string accountId, PortalInfo portalInfo, GameDB.ActionOnResult<PortalInfo> func = null)
 {
     return GameDB.instance.StartCoroutine(GameDB.Set<PortalInfo>(
         "AccountToPortal",
         accountId,
         portalInfo,
         func
     ));
 }
Ejemplo n.º 3
0
 public override CustomObjectInfo SerializeObject()
 {
     PortalInfo x = new PortalInfo();
     if (PairPortal != null)
       x.PairPortal = PairPortal.ObjectID;
     else
       x.PairPortal = -1;
     x.Direction=Direction;
     x.BasicSerialization(this);
     return x;
 }
        private void SerializeTabs(XmlWriter writer, PortalInfo portal, Hashtable tabs, TabCollection tabCollection)
        {
            foreach (TabInfo tab in tabCollection.Values)
            {
                //if not deleted
                if (!tab.IsDeleted)
                {
                    XmlNode tabNode = null;
                    if (string.IsNullOrEmpty(tab.CultureCode) || tab.CultureCode == portal.DefaultLanguage)
                    {
                        // page in default culture and checked or page doesn't exist in tree(which should always export).
                        var tabId = tab.TabID.ToString(CultureInfo.InvariantCulture);
                        if (ctlPages.FindNodeByValue(tabId) == null || ctlPages.CheckedNodes.Any(p => p.Value == tabId))
                        {
                            tabNode = TabController.SerializeTab(new XmlDocument(), tabs, tab, portal, chkContent.Checked);
                        }
                    }
                    else
                    {
                        // check if default culture page is selected or default page doesn't exist in tree(which should always export).
                        TabInfo defaultTab = tab.DefaultLanguageTab;
                        var     tabId      = defaultTab.TabID.ToString(CultureInfo.InvariantCulture);
                        if (defaultTab == null ||
                            ctlPages.FindNodeByValue(tabId) == null ||
                            ctlPages.CheckedNodes.Count(p => p.Value == defaultTab.TabID.ToString(CultureInfo.InvariantCulture)) > 0)
                        {
                            tabNode = TabController.SerializeTab(new XmlDocument(), tabs, tab, portal, chkContent.Checked);
                        }
                    }

                    if (tabNode != null)
                    {
                        tabNode.WriteTo(writer);
                    }
                }
            }
        }
        public HttpResponseMessage RestoreStyleSheet(RestoreCssRequest request)
        {
            if (!PortalSettings.Current.UserInfo.IsSuperUser &&
                PortalSettings.Current.UserInfo.PortalID != request.PortalId)
            {
                throw new SecurityException("No Permission");
            }
            else
            {
                try
                {
                    PortalInfo portal = PortalController.Instance.GetPortal(request.PortalId);
                    if (portal != null)
                    {
                        if (File.Exists(portal.HomeDirectoryMapPath + "portal.css"))
                        {
                            //delete existing style sheet
                            File.Delete(portal.HomeDirectoryMapPath + "portal.css");
                        }

                        //copy file from Host
                        if (File.Exists(Globals.HostMapPath + "portal.css"))
                        {
                            File.Copy(Globals.HostMapPath + "portal.css", portal.HomeDirectoryMapPath + "portal.css");
                        }
                    }
                    var content = LoadStyleSheet(request.PortalId);

                    return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true, StyleSheetContent = content }));
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
                }
            }
        }
Ejemplo n.º 6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Serializes all portal Tabs
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="portal">Portal to serialize</param>
        /// <remarks>
        /// Only portal tabs will be exported to the template, Admin tabs are not exported.
        /// On each tab, all modules will also be exported.
        /// </remarks>
        /// <history>
        ///     [VMasanas]	23/09/2004	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void SerializeTabs(XmlWriter writer, PortalInfo portal)
        {
            //supporting object to build the tab hierarchy
            var tabs = new Hashtable();

            writer.WriteStartElement("tabs");

            if (chkMultilanguage.Checked)
            {
                //Process Default Language first
                SerializeTabs(writer, portal, tabs, TabController.Instance.GetTabsByPortal(portal.PortalID).WithCulture(portal.DefaultLanguage, true));

                //Process other locales
                foreach (ListItem language in chkLanguages.Items)
                {
                    if (language.Selected && language.Value != portal.DefaultLanguage)
                    {
                        SerializeTabs(writer, portal, tabs, TabController.Instance.GetTabsByPortal(portal.PortalID).WithCulture(language.Value, false));
                    }
                }
            }
            else
            {
                if (chkMultilanguage.Enabled)
                {
                    // only export 1 language
                    string language = languageComboBox.SelectedValue;
                    SerializeTabs(writer, portal, tabs, TabController.Instance.GetTabsByPortal(portal.PortalID).WithCulture(language, true));
                }
                else
                {
                    SerializeTabs(writer, portal, tabs, TabController.Instance.GetTabsByPortal(portal.PortalID));
                }
            }

            writer.WriteEndElement();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// [jmarino]  2011-06-16 Check for ContainsKey for a write added
        /// </summary>
        /// <param name="portalId"></param>
        /// <returns></returns>
        private static string GetCacheFolder(int portalId)
        {
            string cacheFolder;

            using (var readerLock = CacheFolderPath.GetReadLock())
            {
                if (CacheFolderPath.TryGetValue(portalId, out cacheFolder))
                {
                    return(cacheFolder);
                }
            }

            var        portalController = new PortalController();
            PortalInfo portalInfo       = portalController.GetPortal(portalId);

            string homeDirectoryMapPath = portalInfo.HomeDirectoryMapPath;


            if (!(string.IsNullOrEmpty(homeDirectoryMapPath)))
            {
                cacheFolder = string.Concat(homeDirectoryMapPath, "Cache\\Pages\\");
                if (!(Directory.Exists(cacheFolder)))
                {
                    Directory.CreateDirectory(cacheFolder);
                }
            }

            using (var writerLock = CacheFolderPath.GetWriteLock())
            {
                if (!CacheFolderPath.ContainsKey(portalId))
                {
                    CacheFolderPath.Add(portalId, cacheFolder);
                }
            }

            return(cacheFolder);
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                PortalController objPortals = new PortalController();
                if (!(Request.QueryString["pid"] == null) && (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId || UserController.GetCurrentUserInfo().IsSuperUser))
                {
                    _objPortal = objPortals.GetPortal(int.Parse(Request.QueryString["pid"]));
                }
                else
                {
                    _objPortal = objPortals.GetPortal(PortalSettings.PortalId);
                }

                if (!Page.IsPostBack)
                {
                    // set width of control
                    if (!String.IsNullOrEmpty(_Width))
                    {
                        cboTabs.Width = Unit.Parse(_Width);
                    }
                    // save persistent values
                    ViewState["ModuleId"]         = Convert.ToString(_ModuleID);
                    ViewState["SkinControlWidth"] = _Width;

                    // load listitems
                    cboTabs.Items.Clear();

                    cboTabs.DataSource = TabController.GetPortalTabs(_objPortal.PortalID, -1, true, true, false, false);
                    cboTabs.DataBind();
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        private void BindPaymentProcessor(PortalInfo portal)
        {
            var listController = new ListController();

            currencyCombo.DataSource = listController.GetListEntryInfoItems("Currency", "");
            var currency = portal.Currency;

            if (String.IsNullOrEmpty(currency))
            {
                currency = "USD";
            }
            currencyCombo.DataBind(currency);

            processorCombo.DataSource = listController.GetListEntryInfoItems("Processor", "");
            processorCombo.DataBind();
            processorCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", "");
            processorCombo.Select(Host.PaymentProcessor, true);

            processorLink.NavigateUrl = Globals.AddHTTP(processorCombo.SelectedItem.Value);

            txtUserId.Text = portal.ProcessorUserId;
            txtPassword.Attributes.Add("value", portal.ProcessorPassword);

            // use sandbox?
            bool bolPayPalSandbox = Boolean.Parse(PortalController.GetPortalSetting("paypalsandbox", portal.PortalID, "false"));

            chkPayPalSandboxEnabled.Checked = bolPayPalSandbox;

            // return url after payment or on cancel
            string strPayPalReturnURL = PortalController.GetPortalSetting("paypalsubscriptionreturn", portal.PortalID, Null.NullString);

            txtPayPalReturnURL.Text = strPayPalReturnURL;
            string strPayPalCancelURL = PortalController.GetPortalSetting("paypalsubscriptioncancelreturn", portal.PortalID, Null.NullString);

            txtPayPalCancelURL.Text = strPayPalCancelURL;
        }
        private bool IsAdminUser(UserInfo accessingUser)
        {
            bool isAdmin = false;

            if (accessingUser != null)
            {
                //Is Super User?
                isAdmin = accessingUser.IsSuperUser;

                if (!isAdmin && user.PortalID != -1)
                {
                    //Is Administrator
                    if (String.IsNullOrEmpty(administratorRoleName))
                    {
                        PortalInfo ps = PortalController.Instance.GetPortal(user.PortalID);
                        administratorRoleName = ps.AdministratorRoleName;
                    }

                    isAdmin = accessingUser.IsInRole(administratorRoleName);
                }
            }

            return(isAdmin);
        }
Ejemplo n.º 11
0
        internal static string LoadStyleSheet(int PortalID)
        {
            string     activeLanguage = LocaleController.Instance.GetDefaultLocale(PortalID).Code;
            PortalInfo portal         = PortalController.Instance.GetPortal(PortalID, activeLanguage);

            string uploadDirectory   = "";
            string styleSheetContent = "";

            if (portal != null)
            {
                uploadDirectory = portal.HomeDirectoryMapPath;
            }

            //read CSS file
            if (File.Exists(uploadDirectory + "portal.css"))
            {
                using (StreamReader text = File.OpenText(uploadDirectory + "portal.css"))
                {
                    styleSheetContent = text.ReadToEnd();
                }
            }

            return(styleSheetContent);
        }
Ejemplo n.º 12
0
 private void onFileChanged(object sender, FileSystemEventArgs e, PortalInfo portalInfo)
 {
     try
     {
         var    relativeFilePath = Utils.GetRelativePath(portalInfo.HomeDirectoryMapPath, e.FullPath);
         string fileName         = Path.GetFileName(e.Name);
         var    fileInfo         = FileManager.Instance.GetFile(0, relativeFilePath);
         if (fileInfo == null)
         {
             //Get Folder
             string folderPath = relativeFilePath.Replace(fileName, "");
             var    folderInfo = FolderManager.Instance.GetFolder(portalInfo.PortalID, folderPath);
             if (folderInfo == null)
             {
                 folderInfo = FolderManager.Instance.AddFolder(portalInfo.PortalID, folderPath);
             }
             FileManager.Instance.AddFile(folderInfo, fileName, null, false);
         }
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
     }
 }
        private void StartTests(object sender, EventArgs e)
        {
            Uri.TryCreate(tbSelenoidHubUri.Text, UriKind.Absolute, out Uri selenoidHubUri);

            if (rbRemoteDriver.Checked && selenoidHubUri == default)
            {
                MessageBox.Show(this, "Некорректный урл хаба селеноида", "Внимательнее будь, падаван", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (settingsTextboxes.Any(x => string.IsNullOrEmpty(x.Value.Text)))
                {
                    MessageBox.Show(this, "Надо заполнить все поля для ввода", "Что же ты творишь, падаван", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    Uri.TryCreate(tbPortalUri.Text, UriKind.Absolute, out Uri portalUri);

                    if (portalUri == default)
                    {
                        MessageBox.Show(this, "Невалидный адрес портала", "Возьми себя в руки, падаван", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        var admin = new User()
                        {
                            Login = tbPortalLogin.Text, Password = tbPortalPassword.Text
                        };
                        var testPortal    = new PortalInfo(portalUri, admin);
                        var selectedCases = CaseCollectionBuilder.CaseCollection.FindAll(x => x.Node.Checked);

                        var mainTask = Task.Run(() =>
                        {
                            foreach (var caseToRun in selectedCases)
                            {
                                caseToRun.Execute(rbRemoteDriver.Checked ? selenoidHubUri : default, testPortal);
Ejemplo n.º 14
0
        private TabDto MarkSelectedTab(TabDto rootNode, int selectedTabId, PortalInfo portalInfo, string cultureCode,
                                       bool isMultiLanguage, string validateTab)
        {
            var tempTabs = new List <int>();

            cultureCode = string.IsNullOrEmpty(cultureCode) ? portalInfo.CultureCode : cultureCode;
            var locale      = LocaleController.Instance.GetLocale(cultureCode);
            var selectedTab = this.GetTabByCulture(selectedTabId, portalInfo.PortalID, locale);

            if (selectedTab != null)
            {
                tempTabs.Add(Convert.ToInt32(selectedTab.TabId));
                if (selectedTab.ParentTabId > Null.NullInteger)
                {
                    var parentTab = selectedTab;
                    do
                    {
                        parentTab = this.GetTabByCulture(parentTab.ParentTabId, portalInfo.PortalID, locale);
                        if (parentTab != null)
                        {
                            tempTabs.Add(Convert.ToInt32(parentTab.TabId));
                        }
                    }while (parentTab != null && parentTab.ParentTabId > Null.NullInteger);
                }
            }

            tempTabs.Reverse();
            rootNode.ChildTabs = this.GetDescendantsForTabs(tempTabs, rootNode.ChildTabs, selectedTabId, portalInfo.PortalID,
                                                            cultureCode, isMultiLanguage).ToList();
            if (!string.IsNullOrEmpty(validateTab))
            {
                rootNode.ChildTabs = this.ValidateModuleInTab(rootNode.ChildTabs, validateTab).ToList();
            }

            return(rootNode);
        }
Ejemplo n.º 15
0
        public static ActionResult DeletePortal(int portalId, PortalSettings portalSettings)
        {
            ActionResult actionResult = new ActionResult();

            string LocalResourceFile = Components.Constants.LocalResourcesFile;

            try
            {
                PortalInfo portal = PortalController.Instance.GetPortal(portalId);
                if (portal != null)
                {
                    if (portal.PortalID != portalSettings.PortalId && !PortalController.IsMemberOfPortalGroup(portal.PortalID))
                    {
                        string strMessage = PortalController.DeletePortal(portal, portalSettings.HomeDirectoryMapPath);// need to check this line
                        if (string.IsNullOrEmpty(strMessage))
                        {
                            DeleteVanjaroPortal(portalId);
                            EventLogController.Instance.AddLog("PortalName", portal.PortalName, portalSettings as IPortalSettings, portalSettings.UserInfo.UserID, EventLogController.EventLogType.PORTAL_DELETED);
                            actionResult.IsSuccess = true;
                            return(actionResult);
                        }
                        actionResult.AddError("", strMessage);
                        return(actionResult);
                    }
                    actionResult.AddError("PortalDeletionDenied", Localization.GetString("PortalDeletionDenied", LocalResourceFile));
                    return(actionResult);
                }
                actionResult.AddError("PortalNotFound", Localization.GetString("PortalNotFound", Components.Constants.LocalResourcesFile));
                return(actionResult);
            }
            catch (Exception ex)
            {
                actionResult.AddError("", "", ex);
                return(actionResult);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Delete/Remove a User from a Role
        /// </summary>
        /// <param name="PortalId">The Id of the Portal</param>
        /// <param name="UserId">The Id of the User</param>
        /// <param name="RoleId">The Id of the Role</param>
        /// <returns></returns>
        public bool DeleteUserRole(int PortalId, int UserId, int RoleId)
        {
            UserInfo     objUser     = UserController.GetUser(PortalId, UserId, false);
            UserRoleInfo objUserRole = GetUserRole(PortalId, UserId, RoleId);

            PortalController objPortals = new PortalController();
            bool             blnDelete  = true;

            PortalInfo objPortal = objPortals.GetPortal(PortalId);

            if (objPortal != null)
            {
                if ((objPortal.AdministratorId != UserId || objPortal.AdministratorRoleId != RoleId) && objPortal.RegisteredRoleId != RoleId)
                {
                    provider.RemoveUserFromRole(PortalId, objUser, objUserRole);
                }
                else
                {
                    blnDelete = false;
                }
            }

            return(blnDelete);
        }
Ejemplo n.º 17
0
        public void LoadPortals(WzImage mapImage, Board mapBoard)
        {
            WzSubProperty portalParent = (WzSubProperty)mapImage["portal"];

            foreach (WzSubProperty portal in portalParent.WzProperties)
            {
                int       x                = InfoTool.GetInt(portal["x"]);
                int       y                = InfoTool.GetInt(portal["y"]);
                string    pt               = Program.InfoManager.PortalTypeById[InfoTool.GetInt(portal["pt"])];
                int       tm               = InfoTool.GetInt(portal["tm"]);
                string    tn               = InfoTool.GetString(portal["tn"]);
                string    pn               = InfoTool.GetString(portal["pn"]);
                string    image            = InfoTool.GetOptionalString(portal["image"]);
                string    script           = InfoTool.GetOptionalString(portal["script"]);
                int?      verticalImpact   = InfoTool.GetOptionalInt(portal["verticalImpact"]);
                int?      horizontalImpact = InfoTool.GetOptionalInt(portal["horizontalImpact"]);
                int?      hRange           = InfoTool.GetOptionalInt(portal["hRange"]);
                int?      vRange           = InfoTool.GetOptionalInt(portal["vRange"]);
                int?      delay            = InfoTool.GetOptionalInt(portal["delay"]);
                MapleBool hideTooltip      = InfoTool.GetOptionalBool(portal["hideTooltip"]);
                MapleBool onlyOnce         = InfoTool.GetOptionalBool(portal["onlyOnce"]);
                mapBoard.BoardItems.Portals.Add(PortalInfo.GetPortalInfoByType(pt).CreateInstance(mapBoard, x, y, pn, tn, tm, script, delay, hideTooltip, onlyOnce, horizontalImpact, verticalImpact, image, hRange, vRange));
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// cmdRestore_Click runs when the Restore Default Stylesheet Linkbutton is clicked.
        /// It reloads the default stylesheet (copies from _default Portal to current Portal)
        /// </summary>
        /// <history>
        ///     [cnurse]	9/9/2004	Modified
        /// </history>
        protected void cmdRestore_Click(object sender, EventArgs e)
        {
            try
            {
                PortalController objPortalController = new PortalController();
                PortalInfo       objPortal           = objPortalController.GetPortal(intPortalId);
                if (objPortal != null)
                {
                    if (File.Exists(objPortal.HomeDirectoryMapPath + "portal.css"))
                    {
                        // delete existing style sheet
                        File.Delete(objPortal.HomeDirectoryMapPath + "portal.css");
                    }
                    // copy the default style sheet to the upload directory
                    File.Copy(Globals.HostMapPath + "portal.css", objPortal.HomeDirectoryMapPath + "portal.css");
                }

                LoadStyleSheet();
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 19
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Serializes all portal Tabs
        /// </summary>
        /// <param name="objportal">Portal to serialize</param>
        /// <remarks>
        /// Only portal tabs will be exported to the template, Admin tabs are not exported.
        /// On each tab, all modules will also be exported.
        /// </remarks>
        /// <history>
        ///     [VMasanas]	23/09/2004	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void SerializeTabs(XmlWriter writer, PortalInfo objportal)
        {
            XmlNode nodeTab = null;
            var     objtabs = new TabController();

            //supporting object to build the tab hierarchy
            var hTabs = new Hashtable();

            writer.WriteStartElement("tabs");

            foreach (TabInfo objtab in objtabs.GetTabsByPortal(objportal.PortalID).Values)
            {
                //if not deleted
                if (!objtab.IsDeleted)
                {
                    //Serialize the Tab
                    var xmlTab = new XmlDocument();
                    nodeTab = TabController.SerializeTab(xmlTab, hTabs, objtab, objportal, chkContent.Checked);

                    nodeTab.WriteTo(writer);
                }
            }
            writer.WriteEndElement();
        }
Ejemplo n.º 20
0
        protected IEnumerable <string[]> LoadPortalsList()
        {
            var       portalCtrl = new PortalController();
            ArrayList portals    = portalCtrl.GetPortals();

            List <string[]> result = new List <string[]>();

            foreach (var portal in portals)
            {
                PortalInfo pi = portal as PortalInfo;

                if (pi != null)
                {
                    string[] p = new string[] {
                        pi.PortalName,
                        pi.PortalID.ToString()
                    };

                    result.Add(p);
                }
            }

            return(result);
        }
Ejemplo n.º 21
0
 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);
     }
 }
Ejemplo n.º 22
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchResults gets the search results for a passed in criteria string
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="portalId">A Id of the Portal</param>
        /// <param name="criteria">The criteria string</param>
        /// <history>
        ///		[cnurse]	11/15/2004	documented
        /// </history>
        /// -----------------------------------------------------------------------------
        public override SearchResultsInfoCollection GetSearchResults(int portalId, string criteria)
        {
            bool hasExcluded  = Null.NullBoolean;
            bool hasMandatory = Null.NullBoolean;

            var        objPortalController = new PortalController();
            PortalInfo objPortal           = objPortalController.GetPortal(portalId);

            //Get the Settings for this Portal
            var portalSettings = new PortalSettings(objPortal);

            //We will assume that the content is in the locale of the Portal
            Hashtable commonWords = GetCommonWords(portalSettings.DefaultLanguage);

            //clean criteria
            criteria = criteria.ToLower();

            //split search criteria into words
            var searchWords = new SearchCriteriaCollection(criteria);

            var searchResults = new Dictionary <string, SearchResultsInfoCollection>();

            //dicResults is a Dictionary(Of SearchItemID, Dictionary(Of TabID, SearchResultsInfo)
            var dicResults = new Dictionary <int, Dictionary <int, SearchResultsInfo> >();

            //iterate through search criteria words
            foreach (SearchCriteria criterion in searchWords)
            {
                if (commonWords.ContainsKey(criterion.Criteria) == false || portalSettings.SearchIncludeCommon)
                {
                    if (!searchResults.ContainsKey(criterion.Criteria))
                    {
                        searchResults.Add(criterion.Criteria, SearchDataStoreController.GetSearchResults(portalId, criterion.Criteria));
                    }
                    if (searchResults.ContainsKey(criterion.Criteria))
                    {
                        foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                        {
                            //Add results to dicResults
                            if (!criterion.MustExclude)
                            {
                                if (dicResults.ContainsKey(result.SearchItemID))
                                {
                                    //The Dictionary exists for this SearchItemID already so look in the TabId keyed Sub-Dictionary
                                    Dictionary <int, SearchResultsInfo> dic = dicResults[result.SearchItemID];
                                    if (dic.ContainsKey(result.TabId))
                                    {
                                        //The sub-Dictionary contains the item already so update the relevance
                                        SearchResultsInfo searchResult = dic[result.TabId];
                                        searchResult.Relevance += result.Relevance;
                                    }
                                    else
                                    {
                                        //Add Entry to Sub-Dictionary
                                        dic.Add(result.TabId, result);
                                    }
                                }
                                else
                                {
                                    //Create new TabId keyed Dictionary
                                    var dic = new Dictionary <int, SearchResultsInfo>();
                                    dic.Add(result.TabId, result);

                                    //Add new Dictionary to SearchResults
                                    dicResults.Add(result.SearchItemID, dic);
                                }
                            }
                        }
                    }
                }
            }
            foreach (SearchCriteria criterion in searchWords)
            {
                var mandatoryResults = new Dictionary <int, bool>();
                var excludedResults  = new Dictionary <int, bool>();
                if (searchResults.ContainsKey(criterion.Criteria))
                {
                    foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                    {
                        if (criterion.MustInclude)
                        {
                            //Add to mandatory results lookup
                            mandatoryResults[result.SearchItemID] = true;
                            hasMandatory = true;
                        }
                        else if (criterion.MustExclude)
                        {
                            //Add to exclude results lookup
                            excludedResults[result.SearchItemID] = true;
                            hasExcluded = true;
                        }
                    }
                }
                foreach (KeyValuePair <int, Dictionary <int, SearchResultsInfo> > kvpResults in dicResults)
                {
                    //The key of this collection is the SearchItemID,  Check if the value of this collection should be processed
                    if (hasMandatory && (!mandatoryResults.ContainsKey(kvpResults.Key)))
                    {
                        //1. If mandatoryResults exist then only process if in mandatoryResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                    else if (hasExcluded && (excludedResults.ContainsKey(kvpResults.Key)))
                    {
                        //2. Do not process results in the excludedResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                }
            }

            //Process results against permissions and mandatory and excluded results
            var results          = new SearchResultsInfoCollection();
            var objTabController = new TabController();

            foreach (KeyValuePair <int, Dictionary <int, SearchResultsInfo> > kvpResults in dicResults)
            {
                foreach (SearchResultsInfo result in kvpResults.Value.Values)
                {
                    if (!result.Delete)
                    {
                        //Check If authorised to View Tab
                        TabInfo objTab = objTabController.GetTab(result.TabId, portalId, false);
                        if (TabPermissionController.CanViewPage(objTab))
                        {
                            //Check If authorised to View Module
                            ModuleInfo objModule = new ModuleController().GetModule(result.ModuleId, result.TabId, false);
                            if (ModulePermissionController.CanViewModule(objModule))
                            {
                                results.Add(result);
                            }
                        }
                    }
                }
            }

            //Return Search Results Collection
            return(results);
        }
 public void SetMappedDirectory(PortalInfo portalInfo, HttpContext context)
 {
     try
     {
         string VirtualDirectory = Common.Globals.ApplicationPath + "/" + portalInfo.HomeDirectory + "/";
         SetMappedDirectory(VirtualDirectory, context);
     }
     catch (Exception exc)
     {
         Exceptions.Exceptions.LogException(exc);
     }
 }
Ejemplo n.º 24
0
        public static MsCrmResultObject GetPortalInfo(Guid portalId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                    b.new_portalId AS Id
                                    ,b.new_name AS Name
                                    --,b.new_imageurl AS [Image]
                                    ,b.new_languageId AS LanguageId
                                    ,b.new_languageIdName AS LanguageIdName
                                    ,b.statuscode AS StatusCode
                                FROM
                                    new_portal AS b (NOLOCK)
                                WHERE
                                    b.new_portalId='{0}'";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId));
                if (dt != null && dt.Rows.Count > 0)
                {
                    PortalInfo _portal = new PortalInfo();
                    _portal.Id = (Guid)dt.Rows[0]["Id"];
                    _portal.Name = dt.Rows[0]["Name"].ToString();
                    _portal.StatusCode = (int)dt.Rows[0]["StatusCode"];
                    //_portal.ImagePath = dt.Rows[0]["Image"] != DBNull.Value ? dt.Rows[0]["Image"].ToString() : "no_portallogo.png";

                    if (dt.Rows[0]["LanguageId"] != DBNull.Value)
                    {
                        EntityReference er = new EntityReference()
                        {
                            Id = (Guid)dt.Rows[0]["LanguageId"],
                            Name = dt.Rows[0]["LanguageIdName"].ToString()
                        };

                        _portal.Language = er;
                    }

                    MsCrmResult portalLogo = PortalHelper.GetPortalLogoAnnotationId(_portal.Id, sda);
                    if (portalLogo.Success)
                    {
                        _portal.LogoImage = AnnotationHelper.GetAnnotationDetail(portalLogo.CrmId, sda);
                    }

                    MsCrmResult portalLoginImage = PortalHelper.GetPortalLoginAnnotationId(_portal.Id, sda);
                    if (portalLoginImage.Success)
                    {
                        _portal.PortalLoginImage = AnnotationHelper.GetAnnotationDetail(portalLoginImage.CrmId, sda);
                    }

                    returnValue.Success = true;
                    returnValue.ReturnObject = _portal;
                }
                else
                {
                    returnValue.Success = true;
                    returnValue.Result = "M005"; //"Portal bilgisi bulunamadı!";
                }

            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
Ejemplo n.º 25
0
        public ActionResult AddUserToRole(UserRoleDto userRoleDto)
        {
            bool         notifyUser = false;
            bool         isOwner    = false;
            ActionResult response   = new ActionResult();

            try
            {
                Validate(userRoleDto);
                if (!UserManager.AllowExpired(userRoleDto.UserId, userRoleDto.RoleId, PortalSettings))
                {
                    userRoleDto.StartTime = userRoleDto.ExpiresTime = Null.NullDate;
                }
                UserInfo user = UserManager.GetUser(userRoleDto.UserId, PortalSettings, UserInfo, out response);
                if (user == null)
                {
                    return(response);
                }

                RoleInfo role = DotNetNuke.Security.Roles.RoleController.Instance.GetRoleById(PortalSettings.PortalId, userRoleDto.RoleId);
                if (role.SecurityMode != SecurityMode.SocialGroup && role.SecurityMode != SecurityMode.Both)
                {
                    isOwner = false;
                }

                if (role.Status != RoleStatus.Approved)
                {
                    response.AddError("HttpStatusCode.BadRequest" + HttpStatusCode.BadRequest, Localization.GetString("CannotAssginUserToUnApprovedRole", Dnn.PersonaBar.Roles.Components.Constants.LocalResourcesFile));
                }
                foreach (UserRoleInfoDTO ur in ConvertUserInfo(UserInfo, userRoleDto.RoleId))
                {
                    if (userRoleDto.UserId == ur.UserId)
                    {
                        response.AddError("UserAlreadyExist", Localization.GetString("UserAlreadyExist", Components.Constants.LocalResourcesFile));
                    }
                }

                if (response.IsSuccess)
                {
                    DotNetNuke.Security.Roles.RoleController.AddUserRole(user, role, PortalSettings, RoleStatus.Approved, userRoleDto.StartTime, userRoleDto.ExpiresTime, notifyUser, isOwner);
                    UserRoleInfo addedUser = DotNetNuke.Security.Roles.RoleController.Instance.GetUserRole(PortalSettings.PortalId, userRoleDto.UserId, userRoleDto.RoleId);
                    PortalInfo   portal    = PortalController.Instance.GetPortal(PortalSettings.PortalId);

                    UserRoleInfoDTO UserRoleDTO = new UserRoleInfoDTO
                    {
                        UserId       = addedUser.UserID,
                        RoleId       = addedUser.RoleID,
                        DisplayName  = addedUser.FullName,
                        StartTime    = addedUser.EffectiveDate,
                        ExpiresTime  = addedUser.ExpiryDate,
                        AllowExpired = UserManager.AllowExpired(addedUser.UserID, addedUser.RoleID, PortalSettings),
                        AllowDelete  = DotNetNuke.Security.Roles.RoleController.CanRemoveUserFromRole(portal, addedUser.UserID, addedUser.RoleID)
                    };
                    response.Data = UserRoleDTO;
                }
            }
            catch (ArgumentException ex)
            {
                response.AddError("HttpStatusCode.BadRequest" + HttpStatusCode.BadRequest, ex.Message);
            }
            catch (Exception ex)
            {
                response.AddError("HttpStatusCode.InternalServerError" + HttpStatusCode.InternalServerError, ex.Message);
            }
            return(response);
        }
Ejemplo n.º 26
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                bool blnValid = true;
//                string strTransactionID;
                int intRoleID   = 0;
                int intPortalID = PortalSettings.PortalId;
                int intUserID   = 0;
//                string strDescription;
                double dblAmount = 0;
//                string strEmail;
                bool   blnCancel           = false;
                string strPayPalID         = Null.NullString;
                var    objRoles            = new RoleController();
                var    objPortalController = new PortalController();
                string strPost             = "cmd=_notify-validate";
                foreach (string strName in Request.Form)
                {
                    string strValue = Request.Form[strName];
                    switch (strName)
                    {
                    case "txn_type":     //get the transaction type
                        string strTransactionType = strValue;
                        switch (strTransactionType)
                        {
                        case "subscr_signup":
                        case "subscr_payment":
                        case "web_accept":
                            break;

                        case "subscr_cancel":
                            blnCancel = true;
                            break;

                        default:
                            blnValid = false;
                            break;
                        }
                        break;

                    case "payment_status":     //verify the status
                        if (strValue != "Completed")
                        {
                            blnValid = false;
                        }
                        break;

                    case "txn_id":     //verify the transaction id for duplicates
//                            strTransactionID = strValue;
                        break;

                    case "receiver_email":     //verify the PayPalId
                        strPayPalID = strValue;
                        break;

                    case "mc_gross":     // verify the price
                        dblAmount = double.Parse(strValue);
                        break;

                    case "item_number":     //get the RoleID
                        intRoleID = Int32.Parse(strValue);
                        //RoleInfo objRole = objRoles.GetRole(intRoleID, intPortalID);
                        break;

                    case "item_name":     //get the product description
//                            strDescription = strValue;
                        break;

                    case "custom":     //get the UserID
                        intUserID = Int32.Parse(strValue);
                        break;

                    case "email":     //get the email
//                            strEmail = strValue;
                        break;
                    }

                    //reconstruct post for postback validation
                    strPost += string.Format("&{0}={1}", Globals.HTTPPOSTEncode(strName), Globals.HTTPPOSTEncode(strValue));
                }

                //postback to verify the source
                if (blnValid)
                {
                    Dictionary <string, string> settings = PortalController.GetPortalSettingsDictionary(PortalSettings.PortalId);
                    string strPayPalURL;

                    // Sandbox mode
                    if (settings.ContainsKey("paypalsandbox") && !String.IsNullOrEmpty(settings["paypalsandbox"]) && settings["paypalsandbox"] == "true")
                    {
                        strPayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?";
                    }
                    else
                    {
                        strPayPalURL = "https://www.paypal.com/cgi-bin/webscr?";
                    }
                    var objRequest = (HttpWebRequest)WebRequest.Create(strPayPalURL);
                    objRequest.Method        = "POST";
                    objRequest.ContentLength = strPost.Length;
                    objRequest.ContentType   = "application/x-www-form-urlencoded";
                    using (var objStream = new StreamWriter(objRequest.GetRequestStream()))
                    {
                        objStream.Write(strPost);
                    }

                    string strResponse;
                    using (var objResponse = (HttpWebResponse)objRequest.GetResponse())
                    {
                        using (var sr = new StreamReader(objResponse.GetResponseStream()))
                        {
                            strResponse = sr.ReadToEnd();
                        }
                    }
                    switch (strResponse)
                    {
                    case "VERIFIED":
                        break;

                    default:
                        //possible fraud
                        blnValid = false;
                        break;
                    }
                }
                if (blnValid)
                {
                    int        intAdministratorRoleId = 0;
                    string     strProcessorID         = Null.NullString;
                    PortalInfo objPortalInfo          = objPortalController.GetPortal(intPortalID);
                    if (objPortalInfo != null)
                    {
                        intAdministratorRoleId = objPortalInfo.AdministratorRoleId;
                        strProcessorID         = objPortalInfo.ProcessorUserId.ToLower();
                    }

                    if (intRoleID == intAdministratorRoleId)
                    {
                        //admin portal renewal
                        strProcessorID = Host.ProcessorUserId.ToLower();
                        float portalPrice = objPortalInfo.HostFee;
                        if ((portalPrice.ToString() == dblAmount.ToString()) && (HttpUtility.UrlDecode(strPayPalID.ToLower()) == strProcessorID))
                        {
                            objPortalController.UpdatePortalExpiry(intPortalID);
                        }
                        else
                        {
                            var objEventLog     = new EventLogController();
                            var objEventLogInfo = new LogInfo();
                            objEventLogInfo.LogPortalID   = intPortalID;
                            objEventLogInfo.LogPortalName = PortalSettings.PortalName;
                            objEventLogInfo.LogUserID     = intUserID;
                            objEventLogInfo.LogTypeKey    = "POTENTIAL PAYPAL PAYMENT FRAUD";
                            objEventLog.AddLog(objEventLogInfo);
                        }
                    }
                    else
                    {
                        //user subscription
                        RoleInfo objRoleInfo = TestableRoleController.Instance.GetRole(intPortalID, r => r.RoleID == intRoleID);
                        float    rolePrice   = objRoleInfo.ServiceFee;
                        float    trialPrice  = objRoleInfo.TrialFee;
                        if ((rolePrice.ToString() == dblAmount.ToString() || trialPrice.ToString() == dblAmount.ToString()) && (HttpUtility.UrlDecode(strPayPalID.ToLower()) == strProcessorID))
                        {
                            objRoles.UpdateUserRole(intPortalID, intUserID, intRoleID, blnCancel);
                        }
                        else
                        {
                            var objEventLog     = new EventLogController();
                            var objEventLogInfo = new LogInfo();
                            objEventLogInfo.LogPortalID   = intPortalID;
                            objEventLogInfo.LogPortalName = PortalSettings.PortalName;
                            objEventLogInfo.LogUserID     = intUserID;
                            objEventLogInfo.LogTypeKey    = "POTENTIAL PAYPAL PAYMENT FRAUD";
                            objEventLog.AddLog(objEventLogInfo);
                        }
                    }
                }
            }
            catch (Exception exc) //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
 public void UpdatePortalInfo(PortalInfo Portal)
 {
     UpdatePortalInfo(Portal.PortalID, Portal.PortalName, Portal.LogoFile, Portal.FooterText, Portal.ExpiryDate, Portal.UserRegistration, Portal.BannerAdvertising, Portal.Currency, Portal.AdministratorId, Portal.HostFee,
     Portal.HostSpace, Portal.PageQuota, Portal.UserQuota, Portal.PaymentProcessor, Portal.ProcessorUserId, Portal.ProcessorPassword, Portal.Description, Portal.KeyWords, Portal.BackgroundFile, Portal.SiteLogHistory,
     Portal.SplashTabId, Portal.HomeTabId, Portal.LoginTabId, Portal.RegisterTabId, Portal.UserTabId, Portal.DefaultLanguage, Portal.TimeZoneOffset, Portal.HomeDirectory, PortalController.GetActivePortalLanguage(Portal.PortalID));
 }
Ejemplo n.º 28
0
        private void RewriteUrl(HttpApplication app, out string portalAlias)
        {
            HttpRequest  request       = app.Request;
            HttpResponse response      = app.Response;
            string       requestedPath = app.Request.Url.AbsoluteUri;

            portalAlias = string.Empty;

            // determine portal alias looking for longest possible match
            string          myAlias = Globals.GetDomainName(app.Request, true);
            PortalAliasInfo objPortalAlias;

            do
            {
                objPortalAlias = PortalAliasController.Instance.GetPortalAlias(myAlias);

                if (objPortalAlias != null)
                {
                    portalAlias = myAlias;
                    break;
                }

                int slashIndex = myAlias.LastIndexOf('/');
                myAlias = slashIndex > 1 ? myAlias.Substring(0, slashIndex) : string.Empty;
            }while (myAlias.Length > 0);

            app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri);

            // Friendly URLs are exposed externally using the following format
            // http://www.domain.com/tabid/###/mid/###/ctl/xxx/default.aspx
            // and processed internally using the following format
            // http://www.domain.com/default.aspx?tabid=###&mid=###&ctl=xxx
            // The system for accomplishing this is based on an extensible Regex rules definition stored in /SiteUrls.config
            string sendTo = string.Empty;

            // save and remove the querystring as it gets added back on later
            // path parameter specifications will take precedence over querystring parameters
            string strQueryString = string.Empty;

            if (!string.IsNullOrEmpty(app.Request.Url.Query))
            {
                strQueryString = request.QueryString.ToString();
                requestedPath  = requestedPath.Replace(app.Request.Url.Query, string.Empty);
            }

            // get url rewriting rules
            RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

            // iterate through list of rules
            int matchIndex = -1;

            for (int ruleIndex = 0; ruleIndex <= rules.Count - 1; ruleIndex++)
            {
                // check for the existence of the LookFor value
                string pattern = "^" +
                                 RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[ruleIndex].LookFor) +
                                 "$";
                Match objMatch = Regex.Match(requestedPath, pattern, RegexOptions.IgnoreCase);

                // if there is a match
                if (objMatch.Success)
                {
                    // create a new URL using the SendTo regex value
                    sendTo = RewriterUtils.ResolveUrl(
                        app.Context.Request.ApplicationPath,
                        Regex.Replace(requestedPath, pattern, rules[ruleIndex].SendTo,
                                      RegexOptions.IgnoreCase));

                    string parameters = objMatch.Groups[2].Value;

                    // process the parameters
                    if (parameters.Trim().Length > 0)
                    {
                        // split the value into an array based on "/" ( ie. /tabid/##/ )
                        parameters = parameters.Replace("\\", "/");
                        string[] splitParameters = parameters.Split('/');

                        // icreate a well formed querystring based on the array of parameters
                        for (int parameterIndex = 0; parameterIndex < splitParameters.Length; parameterIndex++)
                        {
                            // ignore the page name
                            if (
                                splitParameters[parameterIndex].IndexOf(
                                    ".aspx",
                                    StringComparison.InvariantCultureIgnoreCase) ==
                                -1)
                            {
                                // get parameter name
                                string parameterName = splitParameters[parameterIndex].Trim();
                                if (parameterName.Length > 0)
                                {
                                    // add parameter to SendTo if it does not exist already
                                    if (
                                        sendTo.IndexOf(
                                            "?" + parameterName + "=",
                                            StringComparison.InvariantCultureIgnoreCase) == -1 &&
                                        sendTo.IndexOf(
                                            "&" + parameterName + "=",
                                            StringComparison.InvariantCultureIgnoreCase) == -1)
                                    {
                                        // get parameter delimiter
                                        string parameterDelimiter = sendTo.IndexOf("?", StringComparison.Ordinal) != -1 ? "&" : "?";
                                        sendTo = sendTo + parameterDelimiter + parameterName;

                                        // get parameter value
                                        string parameterValue = string.Empty;
                                        if (parameterIndex < splitParameters.Length - 1)
                                        {
                                            parameterIndex += 1;
                                            if (!string.IsNullOrEmpty(splitParameters[parameterIndex].Trim()))
                                            {
                                                parameterValue = splitParameters[parameterIndex].Trim();
                                            }
                                        }

                                        // add the parameter value
                                        if (parameterValue.Length > 0)
                                        {
                                            sendTo = sendTo + "=" + parameterValue;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    matchIndex = ruleIndex;
                    break; // exit as soon as it processes the first match
                }
            }

            if (!string.IsNullOrEmpty(strQueryString))
            {
                // add querystring parameters back to SendTo
                string[] parameters = strQueryString.Split('&');

                // iterate through the array of parameters
                for (int parameterIndex = 0; parameterIndex <= parameters.Length - 1; parameterIndex++)
                {
                    // get parameter name
                    string parameterName = parameters[parameterIndex];
                    if (parameterName.IndexOf("=", StringComparison.Ordinal) != -1)
                    {
                        parameterName = parameterName.Substring(0, parameterName.IndexOf("=", StringComparison.Ordinal));
                    }

                    // check if parameter already exists
                    if (sendTo.IndexOf("?" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1 &&
                        sendTo.IndexOf("&" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        // add parameter to SendTo value
                        sendTo = sendTo.IndexOf("?", StringComparison.Ordinal) != -1
                                     ? sendTo + "&" + parameters[parameterIndex]
                                     : sendTo + "?" + parameters[parameterIndex];
                    }
                }
            }

            // if a match was found to the urlrewrite rules
            if (matchIndex != -1)
            {
                if (rules[matchIndex].SendTo.StartsWith("~"))
                {
                    // rewrite the URL for internal processing
                    RewriterUtils.RewriteUrl(app.Context, sendTo);
                }
                else
                {
                    // it is not possible to rewrite the domain portion of the URL so redirect to the new URL
                    response.Redirect(sendTo, true);
                }
            }
            else
            {
                // Try to rewrite by TabPath
                string url;
                if (Globals.UsePortNumber() &&
                    ((app.Request.Url.Port != 80 && !app.Request.IsSecureConnection) ||
                     (app.Request.Url.Port != 443 && app.Request.IsSecureConnection)))
                {
                    url = app.Request.Url.Host + ":" + app.Request.Url.Port + app.Request.Url.LocalPath;
                }
                else
                {
                    url = app.Request.Url.Host + app.Request.Url.LocalPath;
                }

                if (!string.IsNullOrEmpty(myAlias))
                {
                    if (objPortalAlias != null)
                    {
                        int portalID = objPortalAlias.PortalID;

                        // Identify Tab Name
                        string tabPath = url;
                        if (tabPath.StartsWith(myAlias))
                        {
                            tabPath = url.Remove(0, myAlias.Length);
                        }

                        // Default Page has been Requested
                        if (tabPath == "/" + Globals.glbDefaultPage.ToLowerInvariant())
                        {
                            return;
                        }

                        // Start of patch
                        string cultureCode = string.Empty;

                        Dictionary <string, Locale> dicLocales = LocaleController.Instance.GetLocales(portalID);
                        if (dicLocales.Count > 1)
                        {
                            string[] splitUrl = app.Request.Url.ToString().Split('/');

                            foreach (string culturePart in splitUrl)
                            {
                                if (culturePart.IndexOf("-", StringComparison.Ordinal) > -1)
                                {
                                    foreach (KeyValuePair <string, Locale> key in dicLocales)
                                    {
                                        if (key.Key.ToLower().Equals(culturePart.ToLower()))
                                        {
                                            cultureCode = key.Value.Code;
                                            tabPath     = tabPath.Replace("/" + culturePart, string.Empty);
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        // Check to see if the tab exists (if localization is enable, check for the specified culture)
                        int tabID = TabController.GetTabByTabPath(
                            portalID,
                            tabPath.Replace("/", "//").Replace(".aspx", string.Empty),
                            cultureCode);

                        // Check to see if neutral culture tab exists
                        if (tabID == Null.NullInteger && cultureCode.Length > 0)
                        {
                            tabID = TabController.GetTabByTabPath(
                                portalID,
                                tabPath.Replace("/", "//").Replace(".aspx", string.Empty), string.Empty);
                        }

                        // End of patch
                        if (tabID != Null.NullInteger)
                        {
                            string sendToUrl = "~/" + Globals.glbDefaultPage + "?TabID=" + tabID;
                            if (!cultureCode.Equals(string.Empty))
                            {
                                sendToUrl = sendToUrl + "&language=" + cultureCode;
                            }

                            if (!string.IsNullOrEmpty(app.Request.Url.Query))
                            {
                                sendToUrl = sendToUrl + "&" + app.Request.Url.Query.TrimStart('?');
                            }

                            RewriterUtils.RewriteUrl(app.Context, sendToUrl);
                            return;
                        }

                        tabPath = tabPath.ToLowerInvariant();
                        if (tabPath.IndexOf('?') != -1)
                        {
                            tabPath = tabPath.Substring(0, tabPath.IndexOf('?'));
                        }

                        // Get the Portal
                        PortalInfo portal       = PortalController.Instance.GetPortal(portalID);
                        string     requestQuery = app.Request.Url.Query;
                        if (!string.IsNullOrEmpty(requestQuery))
                        {
                            requestQuery = TabIdRegex.Replace(requestQuery, string.Empty);
                            requestQuery = PortalIdRegex.Replace(requestQuery, string.Empty);
                            requestQuery = requestQuery.TrimStart('?', '&');
                        }

                        if (tabPath == "/login.aspx")
                        {
                            if (portal.LoginTabId > Null.NullInteger && Globals.ValidateLoginTabID(portal.LoginTabId))
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.LoginTabId + "&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.LoginTabId);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID + "&ctl=login&" +
                                        requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID + "&ctl=login");
                                }
                            }

                            return;
                        }

                        if (tabPath == "/register.aspx")
                        {
                            if (portal.RegisterTabId > Null.NullInteger)
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.RegisterTabId + "&portalid=" + portalID + "&" +
                                        requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.RegisterTabId + "&portalid=" + portalID);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID +
                                        "&ctl=Register&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID +
                                        "&ctl=Register");
                                }
                            }

                            return;
                        }

                        if (tabPath == "/terms.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Terms&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Terms");
                            }

                            return;
                        }

                        if (tabPath == "/privacy.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Privacy&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Privacy");
                            }

                            return;
                        }

                        tabPath = tabPath.Replace("/", "//");
                        tabPath = tabPath.Replace(".aspx", string.Empty);
                        TabCollection objTabs = TabController.Instance.GetTabsByPortal(tabPath.StartsWith("//host") ? Null.NullInteger : portalID);
                        foreach (KeyValuePair <int, TabInfo> kvp in objTabs)
                        {
                            if (kvp.Value.IsDeleted == false && kvp.Value.TabPath.ToLowerInvariant() == tabPath)
                            {
                                if (!string.IsNullOrEmpty(app.Request.Url.Query))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID +
                                        "&" + app.Request.Url.Query.TrimStart('?'));
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID);
                                }

                                return;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 29
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddAdminPage adds an Admin Tab Page
        /// </summary>
        ///	<param name="Portal">The Portal</param>
        ///	<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>
        /// <history>
        /// [cnurse]	11/11/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static TabInfo AddAdminPage(PortalInfo Portal, string TabName, string Description, string TabIconFile, string TabIconFileLarge, bool IsVisible)
        {

            TabController objTabController = new TabController();
            TabInfo AdminPage = objTabController.GetTab(Portal.AdminTabId, Portal.PortalID, false);

            if ((AdminPage != null))
            {
                Security.Permissions.TabPermissionCollection objTabPermissions = new Security.Permissions.TabPermissionCollection();
                AddPagePermission(objTabPermissions, "View", Convert.ToInt32(Portal.AdministratorRoleId));
                AddPagePermission(objTabPermissions, "Edit", Convert.ToInt32(Portal.AdministratorRoleId));
                return AddPage(AdminPage, TabName, Description, TabIconFile, TabIconFileLarge, IsVisible, objTabPermissions, true);
            }
            else
            {
                return null;

            }
        }
Ejemplo n.º 30
0
 public static bool CanRemoveUserFromRole(PortalInfo PortalInfo, int UserId, int RoleId)
 {
     return !((PortalInfo.AdministratorId == UserId && PortalInfo.AdministratorRoleId == RoleId) || PortalInfo.RegisteredRoleId == RoleId);
 }
Ejemplo n.º 31
0
        internal static bool CheckForParameterRedirect(Uri requestUri,
                                                       ref UrlAction result,
                                                       NameValueCollection queryStringCol,
                                                       FriendlyUrlSettings settings)
        {
            //check for parameter replaced works by inspecting the parameters on a rewritten request, comparing
            //them agains the list of regex expressions on the friendlyurls.config file, and redirecting to the same page
            //but with new parameters, if there was a match
            bool redirect = false;
            //get the redirect actions for this portal
            var messages = new List <string>();
            Dictionary <int, List <ParameterRedirectAction> > redirectActions = CacheController.GetParameterRedirects(settings, result.PortalId, ref messages);

            if (redirectActions != null && redirectActions.Count > 0)
            {
                try
                {
                    #region trycatch block

                    string rewrittenUrl = result.RewritePath ?? result.RawUrl;

                    List <ParameterRedirectAction> parmRedirects = null;
                    //find the matching redirects for the tabid
                    int tabId = result.TabId;
                    if (tabId > -1)
                    {
                        if (redirectActions.ContainsKey(tabId))
                        {
                            //find the right set of replaced actions for this tab
                            parmRedirects = redirectActions[tabId];
                        }
                    }
                    //check for 'all tabs' redirections
                    if (redirectActions.ContainsKey(-1)) //-1 means 'all tabs' - rewriting across all tabs
                    {
                        //initialise to empty collection if there are no specific tab redirects
                        if (parmRedirects == null)
                        {
                            parmRedirects = new List <ParameterRedirectAction>();
                        }
                        //add in the all redirects
                        List <ParameterRedirectAction> allRedirects = redirectActions[-1];
                        parmRedirects.AddRange(allRedirects); //add the 'all' range to the tab range
                        tabId = result.TabId;
                    }
                    if (redirectActions.ContainsKey(-2) && result.OriginalPath.ToLowerInvariant().Contains("default.aspx"))
                    {
                        //for the default.aspx page
                        if (parmRedirects == null)
                        {
                            parmRedirects = new List <ParameterRedirectAction>();
                        }
                        List <ParameterRedirectAction> defaultRedirects = redirectActions[-2];
                        parmRedirects.AddRange(defaultRedirects); //add the default.aspx redirects to the list
                        tabId = result.TabId;
                    }
                    //726 : allow for site-root redirects, ie redirects where no page match
                    if (redirectActions.ContainsKey(-3))
                    {
                        //request is for site root
                        if (parmRedirects == null)
                        {
                            parmRedirects = new List <ParameterRedirectAction>();
                        }
                        List <ParameterRedirectAction> siteRootRedirects = redirectActions[-3];
                        parmRedirects.AddRange(siteRootRedirects); //add the site root redirects to the collection
                    }
                    //OK what we have now is a list of redirects for the currently requested tab (either because it was specified by tab id,
                    // or because there is a replaced for 'all tabs'

                    if (parmRedirects != null && parmRedirects.Count > 0 && rewrittenUrl != null)
                    {
                        foreach (ParameterRedirectAction parmRedirect in parmRedirects)
                        {
                            //regex test each replaced to see if there is a match between the parameter string
                            //and the parmRedirect
                            string compareWith   = rewrittenUrl;
                            var    redirectRegex = RegexUtils.GetCachedRegex(parmRedirect.LookFor,
                                                                             RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                            Match regexMatch    = redirectRegex.Match(compareWith);
                            bool  success       = regexMatch.Success;
                            bool  siteRootTried = false;
                            //if no match, but there is a site root redirect to try
                            if (!success && parmRedirect.TabId == -3)
                            {
                                siteRootTried = true;
                                compareWith   = result.OriginalPathNoAlias;
                                regexMatch    = redirectRegex.Match(compareWith);
                                success       = regexMatch.Success;
                            }
                            if (!success)
                            {
                                result.DebugMessages.Add(parmRedirect.Name + " redirect not matched (" + rewrittenUrl +
                                                         ")");
                                if (siteRootTried)
                                {
                                    result.DebugMessages.Add(parmRedirect.Name + " redirect not matched [site root] (" +
                                                             result.OriginalPathNoAlias + ")");
                                }
                            }
                            else
                            {
                                //success! there was a match in the parameters
                                string parms = redirectRegex.Replace(compareWith, parmRedirect.RedirectTo);
                                if (siteRootTried)
                                {
                                    result.DebugMessages.Add(parmRedirect.Name + " redirect matched [site root] with (" +
                                                             result.OriginalPathNoAlias + "), replaced with " + parms);
                                }
                                else
                                {
                                    result.DebugMessages.Add(parmRedirect.Name + " redirect matched with (" +
                                                             compareWith + "), replaced with " + parms);
                                }
                                string finalUrl = "";
                                //now we need to generate the friendly Url

                                //first check to see if the parameter replacement string has a destination tabid specified
                                if (parms.ToLowerInvariant().Contains("tabid/"))
                                {
                                    //if so, using a feature whereby the dest tabid can be changed within the parameters, which will
                                    //redirect the page as well as redirecting the parameter values
                                    string[] parmParts = parms.Split('/');
                                    bool     tabIdNext = false;
                                    foreach (string parmPart in parmParts)
                                    {
                                        if (tabIdNext)
                                        {
                                            //changes the tabid of page, effects a page redirect along with a parameter redirect
                                            Int32.TryParse(parmPart, out tabId);
                                            parms = parms.Replace("tabid/" + tabId.ToString(), "");
                                            //remove the tabid/xx from the path
                                            break; //that's it, we're finished
                                        }
                                        if (parmPart.Equals("tabid", StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            tabIdNext = true;
                                        }
                                    }
                                }
                                else if (tabId == -1)
                                {
                                    //find the home tabid for this portal
                                    //735 : switch to custom method for getting portal
                                    PortalInfo portal = CacheController.GetPortal(result.PortalId, true);
                                    tabId = portal.HomeTabId;
                                }
                                if (parmRedirect.ChangeToSiteRoot)
                                {
                                    //when change to siteroot requested, new path goes directly off the portal alias
                                    //so set the finalUrl as the poratl alias
                                    finalUrl = result.Scheme + result.HttpAlias + "/";
                                }
                                else
                                {
                                    //if the tabid has been supplied, do a friendly url provider lookup to get the correct format for the tab url
                                    if (tabId > -1)
                                    {
                                        TabInfo tab = TabController.Instance.GetTab(tabId, result.PortalId, false);
                                        if (tab != null)
                                        {
                                            string path = Globals.glbDefaultPage + TabIndexController.CreateRewritePath(tab.TabID, "");
                                            string friendlyUrlNoParms = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(tab,
                                                                                                                        path,
                                                                                                                        Globals.glbDefaultPage,
                                                                                                                        result.HttpAlias,
                                                                                                                        false,
                                                                                                                        settings,
                                                                                                                        Guid.Empty);
                                            if (friendlyUrlNoParms.EndsWith("/") == false)
                                            {
                                                friendlyUrlNoParms += "/";
                                            }
                                            finalUrl = friendlyUrlNoParms;
                                        }
                                        if (tab == null)
                                        {
                                            result.DebugMessages.Add(parmRedirect.Name +
                                                                     " tabId in redirect rule (tabId:" +
                                                                     tabId.ToString() + ", portalId:" +
                                                                     result.PortalId.ToString() +
                                                                     " ), tab was not found");
                                        }
                                        else
                                        {
                                            result.DebugMessages.Add(parmRedirect.Name +
                                                                     " tabId in redirect rule (tabId:" +
                                                                     tabId.ToString() + ", portalId:" +
                                                                     result.PortalId.ToString() + " ), tab found : " +
                                                                     tab.TabName);
                                        }
                                    }
                                }
                                if (parms.StartsWith("//"))
                                {
                                    parms = parms.Substring(2);
                                }
                                if (parms.StartsWith("/"))
                                {
                                    parms = parms.Substring(1);
                                }

                                if (settings.PageExtensionUsageType != PageExtensionUsageType.Never)
                                {
                                    if (parms.EndsWith("/"))
                                    {
                                        parms = parms.TrimEnd('/');
                                    }
                                    if (parms.Length > 0)
                                    {
                                        //we are adding more parms onto the end, so remove the page extension
                                        //from the parameter list
                                        //946 : exception when settings.PageExtension value is empty
                                        parms += settings.PageExtension;
                                        //816: if page extension is /, then don't do this
                                        if (settings.PageExtension != "/" &&
                                            string.IsNullOrEmpty(settings.PageExtension) == false)
                                        {
                                            finalUrl = finalUrl.Replace(settings.PageExtension, "");
                                        }
                                    }
                                    else
                                    {
                                        //we are removing all the parms altogether, so
                                        //the url needs to end in the page extension only
                                        //816: if page extension is /, then don't do this
                                        if (settings.PageExtension != "/" &&
                                            string.IsNullOrEmpty(settings.PageExtension) == false)
                                        {
                                            finalUrl = finalUrl.Replace(settings.PageExtension + "/",
                                                                        settings.PageExtension);
                                        }
                                    }
                                }
                                //put the replaced parms back on the end
                                finalUrl += parms;

                                //set the final url
                                result.FinalUrl = finalUrl;
                                result.Reason   = RedirectReason.Custom_Redirect;
                                switch (parmRedirect.Action)
                                {
                                case "301":
                                    result.Action = ActionType.Redirect301;
                                    break;

                                case "302":
                                    result.Action = ActionType.Redirect302;
                                    break;

                                case "404":
                                    result.Action = ActionType.Output404;
                                    break;
                                }
                                redirect = true;
                                break;
                            }
                        }
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    Services.Exceptions.Exceptions.LogException(ex);
                    messages.Add("Exception: " + ex.Message + "\n" + ex.StackTrace);
                }
                finally
                {
                    if (messages.Count > 0)
                    {
                        result.DebugMessages.AddRange(messages);
                    }
                }
            }
            return(redirect);
        }
Ejemplo n.º 32
0
        public ActionResult GetRoleUsers(string keyword, int roleId, int pageIndex, int pageSize)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int      PortalID = (PortalController.Instance.GetCurrentSettings() as PortalSettings).PortalId;
                RoleInfo role     = DotNetNuke.Security.Roles.RoleController.Instance.GetRoleById(PortalID, roleId);
                if (role == null && !actionResult.IsSuccess)
                {
                    actionResult.AddError(HttpStatusCode.NotFound.ToString(), Localization.GetString("RoleNotFound", Components.Constants.LocalResourcesFile));
                }

                if (actionResult.IsSuccess)
                {
                    if (role.RoleID == PortalSettings.AdministratorRoleId && !IsAdmin())
                    {
                        actionResult.AddError(HttpStatusCode.BadRequest.ToString(), Localization.GetString("InvalidRequest", Components.Constants.LocalResourcesFile));
                    }
                }
                if (actionResult.IsSuccess)
                {
                    IList <UserRoleInfo> users = DotNetNuke.Security.Roles.RoleController.Instance.GetUserRoles(PortalID, Null.NullString, role.RoleName);
                    if (!string.IsNullOrEmpty(keyword))
                    {
                        users = users.Where(u => u.FullName.ToLower().Contains(keyword.ToLower())).ToList();
                    }

                    int                    totalRecords = users.Count;
                    int                    startIndex   = pageIndex * pageSize;
                    PortalInfo             portal       = PortalController.Instance.GetPortal(PortalID);
                    List <UserRoleInfoDTO> pagedData    = new List <UserRoleInfoDTO>();
                    foreach (UserRoleInfo u in users.Skip(startIndex).Take(pageSize))
                    {
                        UserRoleInfoDTO uRoleInfo = new UserRoleInfoDTO();
                        UserInfo        UserInfo  = UserController.GetUserById((PortalController.Instance.GetCurrentSettings() as PortalSettings).PortalId, u.UserID);
                        uRoleInfo.UserId       = u.UserID;
                        uRoleInfo.UserName     = UserInfo.Username;
                        uRoleInfo.Email        = UserInfo.Email;
                        uRoleInfo.Avatar       = UserInfo.Profile.PhotoURL.Contains("no_avatar.gif") ? Vanjaro.Common.Utilities.UserUtils.GetProfileImage(PortalSettings.Current.PortalId, u.UserID, u.Email) : UserInfo.Profile.PhotoURL;
                        uRoleInfo.FirstName    = UserInfo.FirstName;
                        uRoleInfo.LastName     = UserInfo.LastName;
                        uRoleInfo.RoleId       = u.RoleID;
                        uRoleInfo.DisplayName  = u.FullName;
                        uRoleInfo.StartTime    = u.EffectiveDate;
                        uRoleInfo.ExpiresTime  = u.ExpiryDate;
                        uRoleInfo.AllowExpired = AllowExpired(u.UserID, u.RoleID);
                        uRoleInfo.AllowDelete  = DotNetNuke.Security.Roles.RoleController.CanRemoveUserFromRole(portal, u.UserID, u.RoleID);
                        pagedData.Add(uRoleInfo);
                    }

                    if (actionResult.IsSuccess)
                    {
                        actionResult.Data = new { users = pagedData, totalRecords };
                    }
                }
            }
            catch (Exception ex)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), ex.Message);
            }
            return(actionResult);
        }
Ejemplo n.º 33
0
        internal override GameState getBestGame(GameState gs)
        {
            Random        r         = new Random(0);
            List <PointD> allPoints = new List <PointD>();

            index = new Dictionary <PointD, int>();
            for (int i = 0; i < gs.PortalInfos.Count; i++)
            {
                PortalInfo pInfo = gs.PortalInfos[i];
                allPoints.Add(pInfo.Pos);
                index[pInfo.Pos] = i;
            }
            List <PointD> remPoints = new List <PointD>(allPoints);

            List <PointD> hull = ConvexHull.MakeConvexHull(allPoints);

            foreach (PointD item in hull)
            {
                remPoints.Remove(item);
            }

            LinkPlan linkPlan = new LinkPlan(gs.PortalInfos.Count);

            for (int i = 0; i < hull.Count; i++)
            {
                //gs.addLink(index[hull[(i - 1 + hull.Count) % hull.Count]], index[hull[i]]);
                linkPlan.addLink(index[hull[(i - 1 + hull.Count) % hull.Count]], index[hull[i]]);
            }
            while (hull.Count > 3)
            {
                int mid  = r.Next(0, hull.Count);
                int ind1 = (mid - 1 + hull.Count) % hull.Count;
                int ind2 = (mid + 1 + hull.Count) % hull.Count;
                //gs.addLink(index[hull[ind1]], index[hull[ind2]]);
                linkPlan.addLink(index[hull[ind1]], index[hull[ind2]]);
                hull.RemoveAt(mid);
            }
            List <Triangle> remTriangles = new List <Triangle>();

            for (int p1 = 0; p1 < linkPlan.Portals.Length; p1++)
            {
                foreach (int p2 in linkPlan.Portals[p1].Links)
                {
                    foreach (int p3 in linkPlan.Portals[p2].Links)
                    {
                        if (linkPlan.Portals[p3].Links.Contains(p1))
                        {
                            int[] triangleKey = new int[] { p1, p2, p3 };
                            Array.Sort(triangleKey);
                            Triangle newTr = new Triangle(triangleKey);
                            if (remTriangles.Contains(newTr))
                            {
                                continue;
                            }
                            remTriangles.Add(newTr);
                        }
                    }
                }
            }

            while (remTriangles.Count > 0)
            {
                Triangle curTriangle = remTriangles[0];
                remTriangles.RemoveAt(0);

                foreach (PointD remPoint in remPoints)
                {
                    if (geohelper.PointInPolygon(new PointD[] { allPoints[curTriangle.P1], allPoints[curTriangle.P2], allPoints[curTriangle.P3] }, remPoint))
                    {
                        linkPlan.addLink(curTriangle.P1, index[remPoint]);
                        linkPlan.addLink(curTriangle.P2, index[remPoint]);
                        linkPlan.addLink(curTriangle.P3, index[remPoint]);

                        for (int i = 0; i < 3; i++)
                        {
                            int[] triangleKey = new int[] { curTriangle.P1, curTriangle.P2, curTriangle.P3 };
                            triangleKey[i] = index[remPoint];
                            Array.Sort(triangleKey);
                            Triangle newTr = new Triangle(triangleKey);
                            remTriangles.Add(newTr);
                        }

                        remPoints.Remove(remPoint);
                        break;
                    }
                }
            }



            AlgoWayOptimizer wopt = new AlgoWayOptimizer(gs, linkPlan, this);

            gs = wopt.linkConvex();


            this.newBestGame(gs);

            return(gs);
        }
Ejemplo n.º 34
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	5/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdUpdate_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                PortalController.PortalTemplateInfo template = LoadPortalTemplateInfoForSelectedItem();

                try
                {
                    bool   blnChild;
                    string strPortalAlias;
                    string strChildPath  = string.Empty;
                    var    closePopUpStr = string.Empty;

                    var objPortalController = new PortalController();

                    //check template validity
                    var    messages       = new ArrayList();
                    string schemaFilename = Server.MapPath(string.Concat(AppRelativeTemplateSourceDirectory, "portal.template.xsd"));
                    string xmlFilename    = template.TemplateFilePath;
                    var    xval           = new PortalTemplateValidator();
                    if (!xval.Validate(xmlFilename, schemaFilename))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, "", String.Format(Localization.GetString("InvalidTemplate", LocalResourceFile), Path.GetFileName(template.TemplateFilePath)), ModuleMessage.ModuleMessageType.RedError);
                        messages.AddRange(xval.Errors);
                        lstResults.Visible    = true;
                        lstResults.DataSource = messages;
                        lstResults.DataBind();
                        validationPanel.Visible = true;
                        return;
                    }

                    //Set Portal Name
                    txtPortalAlias.Text = txtPortalAlias.Text.ToLowerInvariant();
                    txtPortalAlias.Text = txtPortalAlias.Text.Replace("http://", "");

                    //Validate Portal Name
                    if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        blnChild       = true;
                        strPortalAlias = txtPortalAlias.Text;
                    }
                    else
                    {
                        blnChild = (optType.SelectedValue == "C");

                        strPortalAlias = blnChild ? PortalController.GetPortalFolder(txtPortalAlias.Text) : txtPortalAlias.Text;
                    }

                    string message = String.Empty;
                    ModuleMessage.ModuleMessageType messageType = ModuleMessage.ModuleMessageType.RedError;
                    if (!PortalAliasController.ValidateAlias(strPortalAlias, blnChild))
                    {
                        message = Localization.GetString("InvalidName", LocalResourceFile);
                    }

                    //check whether have conflict between tab path and portal alias.
                    var checkTabPath = string.Format("//{0}", strPortalAlias);
                    if (TabController.GetTabByTabPath(PortalSettings.PortalId, checkTabPath, string.Empty) != Null.NullInteger ||
                        TabController.GetTabByTabPath(Null.NullInteger, checkTabPath, string.Empty) != Null.NullInteger)
                    {
                        message = Localization.GetString("DuplicateWithTab", LocalResourceFile);
                    }

                    //Validate Password
                    if (txtPassword.Text != txtConfirm.Text)
                    {
                        if (!String.IsNullOrEmpty(message))
                        {
                            message += "<br/>";
                        }
                        message += Localization.GetString("InvalidPassword", LocalResourceFile);
                    }
                    string strServerPath = Globals.GetAbsoluteServerPath(Request);

                    //Set Portal Alias for Child Portals
                    if (String.IsNullOrEmpty(message))
                    {
                        if (blnChild)
                        {
                            strChildPath = strServerPath + strPortalAlias;

                            if (Directory.Exists(strChildPath))
                            {
                                message = Localization.GetString("ChildExists", LocalResourceFile);
                            }
                            else
                            {
                                if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                                {
                                    strPortalAlias = Globals.GetDomainName(Request, true) + "/" + strPortalAlias;
                                }
                                else
                                {
                                    strPortalAlias = txtPortalAlias.Text;
                                }
                            }
                        }
                    }

                    //Get Home Directory
                    string homeDir = txtHomeDirectory.Text != @"Portals/[PortalID]" ? txtHomeDirectory.Text : "";

                    //Validate Home Folder
                    if (!string.IsNullOrEmpty(homeDir))
                    {
                        if (string.IsNullOrEmpty(String.Format("{0}\\{1}\\", Globals.ApplicationMapPath, homeDir).Replace("/", "\\")))
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                        if (homeDir.Contains("admin") || homeDir.Contains("DesktopModules") || homeDir.ToLowerInvariant() == "portals/")
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                    }

                    //Validate Portal Alias
                    if (!string.IsNullOrEmpty(strPortalAlias))
                    {
                        PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasLookup(strPortalAlias.ToLower());
                        if (portalAlias != null)
                        {
                            message = Localization.GetString("DuplicatePortalAlias", LocalResourceFile);
                        }
                    }

                    //Create Portal
                    if (String.IsNullOrEmpty(message))
                    {
                        //Attempt to create the portal
                        UserInfo adminUser = new UserInfo();
                        int      intPortalId;
                        try
                        {
                            if (useCurrent.Checked)
                            {
                                adminUser   = UserInfo;
                                intPortalId = objPortalController.CreatePortal(txtPortalName.Text,
                                                                               adminUser.UserID,
                                                                               txtDescription.Text,
                                                                               txtKeyWords.Text,
                                                                               template,
                                                                               homeDir,
                                                                               strPortalAlias,
                                                                               strServerPath,
                                                                               strChildPath,
                                                                               blnChild);
                            }
                            else
                            {
                                adminUser = new UserInfo
                                {
                                    FirstName   = txtFirstName.Text,
                                    LastName    = txtLastName.Text,
                                    Username    = txtUsername.Text,
                                    DisplayName = txtFirstName.Text + " " + txtLastName.Text,
                                    Email       = txtEmail.Text,
                                    IsSuperUser = false,
                                    Membership  =
                                    {
                                        Approved         = true,
                                        Password         = txtPassword.Text,
                                        PasswordQuestion = txtQuestion.Text,
                                        PasswordAnswer   = txtAnswer.Text
                                    },
                                    Profile =
                                    {
                                        FirstName = txtFirstName.Text,
                                        LastName  = txtLastName.Text
                                    }
                                };

                                intPortalId = objPortalController.CreatePortal(txtPortalName.Text,
                                                                               adminUser,
                                                                               txtDescription.Text,
                                                                               txtKeyWords.Text,
                                                                               template,
                                                                               homeDir,
                                                                               strPortalAlias,
                                                                               strServerPath,
                                                                               strChildPath,
                                                                               blnChild);
                            }
                        }
                        catch (Exception ex)
                        {
                            intPortalId = Null.NullInteger;
                            message     = ex.Message;
                        }
                        if (intPortalId != -1)
                        {
                            //Create a Portal Settings object for the new Portal
                            PortalInfo objPortal   = objPortalController.GetPortal(intPortalId);
                            var        newSettings = new PortalSettings {
                                PortalAlias = new PortalAliasInfo {
                                    HTTPAlias = strPortalAlias
                                }, PortalId = intPortalId, DefaultLanguage = objPortal.DefaultLanguage
                            };
                            string webUrl = Globals.AddHTTP(strPortalAlias);
                            try
                            {
                                if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                                {
                                    message = Mail.SendMail(PortalSettings.Email,
                                                            txtEmail.Text,
                                                            PortalSettings.Email + ";" + Host.HostEmail,
                                                            Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", adminUser),
                                                            Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", adminUser),
                                                            "",
                                                            "",
                                                            "",
                                                            "",
                                                            "",
                                                            "");
                                }
                                else
                                {
                                    message = Mail.SendMail(Host.HostEmail,
                                                            txtEmail.Text,
                                                            Host.HostEmail,
                                                            Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", adminUser),
                                                            Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", adminUser),
                                                            "",
                                                            "",
                                                            "",
                                                            "",
                                                            "",
                                                            "");
                                }
                            }
                            catch (Exception exc)
                            {
                                Logger.Error(exc);

                                closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true, webUrl, true) + "\"" : "";
                                message       = string.Format(Localization.GetString("UnknownSendMail.Error", LocalResourceFile), webUrl, closePopUpStr);
                            }
                            var objEventLog = new EventLogController();
                            objEventLog.AddLog(objPortalController.GetPortal(intPortalId), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED);

                            // mark default language as published if content localization is enabled
                            bool ContentLocalizationEnabled = PortalController.GetPortalSettingAsBoolean("ContentLocalizationEnabled", PortalId, false);
                            if (ContentLocalizationEnabled)
                            {
                                LocaleController lc = new LocaleController();
                                lc.PublishLanguage(intPortalId, objPortal.DefaultLanguage, true);
                            }

                            //Redirect to this new site
                            if (message == Null.NullString)
                            {
                                webUrl = (PortalSettings.EnablePopUps) ? UrlUtils.ClosePopUp(true, webUrl, false) : webUrl;
                                Response.Redirect(webUrl, true);
                            }
                            else
                            {
                                closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true, webUrl, true) + "\"" : "";
                                message       = string.Format(Localization.GetString("SendMail.Error", LocalResourceFile), message, webUrl, closePopUpStr);
                                messageType   = ModuleMessage.ModuleMessageType.YellowWarning;
                            }
                        }
                    }
                    UI.Skins.Skin.AddModuleMessage(this, "", message, messageType);
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
        }
Ejemplo n.º 35
0
 public PortalSettings(int tabID, PortalInfo portal)
 {
     _ActiveTab = new TabInfo();
     GetPortalSettings(tabID, portal);
 }
Ejemplo n.º 36
0
        public void AddLog(object objCBO, PortalSettings _PortalSettings, int UserID, string UserName, string LogType)
        {
            LogController objLogController = new LogController();
            LogInfo       objLogInfo       = new LogInfo();

            objLogInfo.LogUserID  = UserID;
            objLogInfo.LogTypeKey = LogType.ToString();
            if (_PortalSettings != null)
            {
                objLogInfo.LogPortalID   = _PortalSettings.PortalId;
                objLogInfo.LogPortalName = _PortalSettings.PortalName;
            }
            switch (objCBO.GetType().FullName)
            {
            case "CommonLibrary.Entities.Portals.PortalInfo":
                PortalInfo objPortal = (PortalInfo)objCBO;
                objLogInfo.LogProperties.Add(new LogDetailInfo("PortalID", objPortal.PortalID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("PortalName", objPortal.PortalName));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Description", objPortal.Description));
                objLogInfo.LogProperties.Add(new LogDetailInfo("KeyWords", objPortal.KeyWords));
                objLogInfo.LogProperties.Add(new LogDetailInfo("LogoFile", objPortal.LogoFile));
                break;

            case "CommonLibrary.Entities.Tabs.TabInfo":
                TabInfo objTab = (TabInfo)objCBO;
                objLogInfo.LogProperties.Add(new LogDetailInfo("TabID", objTab.TabID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("PortalID", objTab.PortalID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("TabName", objTab.TabName));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Title", objTab.Title));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Description", objTab.Description));
                objLogInfo.LogProperties.Add(new LogDetailInfo("KeyWords", objTab.KeyWords));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Url", objTab.Url));
                objLogInfo.LogProperties.Add(new LogDetailInfo("ParentId", objTab.ParentId.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("IconFile", objTab.IconFile));
                objLogInfo.LogProperties.Add(new LogDetailInfo("IsVisible", objTab.IsVisible.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("SkinSrc", objTab.SkinSrc));
                objLogInfo.LogProperties.Add(new LogDetailInfo("ContainerSrc", objTab.ContainerSrc));
                break;

            case "CommonLibrary.Entities.Modules.ModuleInfo":
                ModuleInfo objModule = (ModuleInfo)objCBO;
                objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleId", objModule.ModuleID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleTitle", objModule.ModuleTitle));
                objLogInfo.LogProperties.Add(new LogDetailInfo("TabModuleID", objModule.TabModuleID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("TabID", objModule.TabID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("PortalID", objModule.PortalID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleDefId", objModule.ModuleDefID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("FriendlyName", objModule.DesktopModule.FriendlyName));
                objLogInfo.LogProperties.Add(new LogDetailInfo("IconFile", objModule.IconFile));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Visibility", objModule.Visibility.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("ContainerSrc", objModule.ContainerSrc));
                break;

            case "CommonLibrary.Entities.Users.UserInfo":
                UserInfo objUser = (UserInfo)objCBO;
                objLogInfo.LogProperties.Add(new LogDetailInfo("UserID", objUser.UserID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("FirstName", objUser.Profile.FirstName));
                objLogInfo.LogProperties.Add(new LogDetailInfo("LastName", objUser.Profile.LastName));
                objLogInfo.LogProperties.Add(new LogDetailInfo("UserName", objUser.Username));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Email", objUser.Email));
                break;

            case "CommonLibrary.Security.Roles.RoleInfo":
                RoleInfo objRole = (RoleInfo)objCBO;
                objLogInfo.LogProperties.Add(new LogDetailInfo("RoleID", objRole.RoleID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("RoleName", objRole.RoleName));
                objLogInfo.LogProperties.Add(new LogDetailInfo("PortalID", objRole.PortalID.ToString()));
                objLogInfo.LogProperties.Add(new LogDetailInfo("Description", objRole.Description));
                objLogInfo.LogProperties.Add(new LogDetailInfo("IsPublic", objRole.IsPublic.ToString()));
                break;

            default:
                objLogInfo.LogProperties.Add(new LogDetailInfo("logdetail", XmlUtils.Serialize(objCBO)));
                break;
            }
            objLogController.AddLog(objLogInfo);
        }
Ejemplo n.º 37
0
        private void BindTree(List <int> tabslist, PortalInfo portal)
        {
            #region Re-initialize RadTree
            ctlPages.Nodes.Clear();

            var tabController = new TabController();
            var rootNode      = new RadTreeNode
            {
                Text              = PortalSettings.PortalName,
                ImageUrl          = IconPortal,
                Value             = Null.NullInteger.ToString(CultureInfo.InvariantCulture),
                Expanded          = true,
                AllowEdit         = false,
                EnableContextMenu = true,
                Checked           = false
            };
            rootNode.Attributes.Add("isPortalRoot", "True");

            // diff with copied code :
            // strip the case a check multilanguage as the checkbox have no inetrest here.
            // based on System.Threading.Thread.CurrentThread.CurrentCulture vs combo selected before)
            // change the checked from default true to false.
            // Switch from TabName to LocalizedTabName
            // recheck all the checkbox with a check if clone module
            List <TabInfo> tabs = TabController.GetPortalTabs(TabController.GetTabsBySortOrder(portal.PortalID, System.Threading.Thread.CurrentThread.CurrentCulture.ToString(), true),
                                                              Null.NullInteger,
                                                              false,
                                                              "<" + Localization.GetString("None_Specified") + ">",
                                                              true,
                                                              false,
                                                              true,
                                                              false,
                                                              false);

            //tabs = tabController.GetTabsByPortal(portal.PortalID);

            foreach (var tab in tabs) //.Values)
            {
                if (tab.Level == 0)
                {
                    string tooltip;
                    var    nodeIcon = GetNodeIcon(tab, out tooltip);
                    var    node     = new RadTreeNode
                    {
                        Text      = string.Format("{0} {1}", tab.LocalizedTabName, GetNodeStatusIcon(tab)),
                        Value     = tab.TabID.ToString(CultureInfo.InvariantCulture),
                        AllowEdit = true,
                        ImageUrl  = nodeIcon,
                        ToolTip   = tooltip,
                        Checked   = false
                    };

                    AddChildNodes(node, portal);
                    rootNode.Nodes.Add(node);
                }
            }

            ctlPages.Nodes.Add(rootNode);
            #endregion

            //111113 custom code
            foreach (RadTreeNode n in ctlPages.GetAllNodes())
            {
                int thetabid = Convert.ToInt32(n.Value);
                n.Checked = getbchk(tabslist, thetabid);
            }
            //111113 custom code end
            ctlPages.DataBind();
        }
Ejemplo n.º 38
0
 public IDataReader GetSharedModulesByPortal(PortalInfo portal)
 {
     return(this._provider.ExecuteReader("GetSharedModulesByPortal", portal.PortalID));
 }
Ejemplo n.º 39
0
 private void GetPortalSettings(int tabID, PortalInfo portal)
 {
     ModuleController objModules = new ModuleController();
     ModuleInfo objModule;
     this.PortalId = portal.PortalID;
     this.PortalName = portal.PortalName;
     this.LogoFile = portal.LogoFile;
     this.FooterText = portal.FooterText;
     this.ExpiryDate = portal.ExpiryDate;
     this.UserRegistration = portal.UserRegistration;
     this.BannerAdvertising = portal.BannerAdvertising;
     this.Currency = portal.Currency;
     this.AdministratorId = portal.AdministratorId;
     this.Email = portal.Email;
     this.HostFee = portal.HostFee;
     this.HostSpace = portal.HostSpace;
     this.PageQuota = portal.PageQuota;
     this.UserQuota = portal.UserQuota;
     this.AdministratorRoleId = portal.AdministratorRoleId;
     this.AdministratorRoleName = portal.AdministratorRoleName;
     this.RegisteredRoleId = portal.RegisteredRoleId;
     this.RegisteredRoleName = portal.RegisteredRoleName;
     this.Description = portal.Description;
     this.KeyWords = portal.KeyWords;
     this.BackgroundFile = portal.BackgroundFile;
     this.GUID = portal.GUID;
     this.SiteLogHistory = portal.SiteLogHistory;
     this.AdminTabId = portal.AdminTabId;
     this.SuperTabId = portal.SuperTabId;
     this.SplashTabId = portal.SplashTabId;
     this.HomeTabId = portal.HomeTabId;
     this.LoginTabId = portal.LoginTabId;
     this.RegisterTabId = portal.RegisterTabId;
     this.UserTabId = portal.UserTabId;
     this.DefaultLanguage = portal.DefaultLanguage;
     this.TimeZoneOffset = portal.TimeZoneOffset;
     this.HomeDirectory = portal.HomeDirectory;
     this.Pages = portal.Pages;
     this.Users = portal.Users;
     if (Null.IsNull(this.HostSpace))
     {
         this.HostSpace = 0;
     }
     if (Null.IsNull(this.DefaultLanguage))
     {
         this.DefaultLanguage = Localization.SystemLocale;
     }
     if (Null.IsNull(this.TimeZoneOffset))
     {
         this.TimeZoneOffset = Localization.SystemTimeZoneOffset;
     }
     this.HomeDirectory = Common.Globals.ApplicationPath + "/" + portal.HomeDirectory + "/";
     if (VerifyPortalTab(PortalId, tabID))
     {
         if (this.ActiveTab != null)
         {
             if (Globals.IsAdminSkin())
             {
                 this.ActiveTab.SkinSrc = this.DefaultAdminSkin;
             }
             else
             {
                 if (String.IsNullOrEmpty(this.ActiveTab.SkinSrc))
                 {
                     this.ActiveTab.SkinSrc = this.DefaultPortalSkin;
                 }
             }
             this.ActiveTab.SkinSrc = SkinController.FormatSkinSrc(this.ActiveTab.SkinSrc, this);
             this.ActiveTab.SkinPath = SkinController.FormatSkinPath(this.ActiveTab.SkinSrc);
             if (Globals.IsAdminSkin())
             {
                 this.ActiveTab.ContainerSrc = this.DefaultAdminContainer;
             }
             else
             {
                 if (String.IsNullOrEmpty(this.ActiveTab.ContainerSrc))
                 {
                     this.ActiveTab.ContainerSrc = this.DefaultPortalContainer;
                 }
             }
             this.ActiveTab.ContainerSrc = SkinController.FormatSkinSrc(this.ActiveTab.ContainerSrc, this);
             this.ActiveTab.ContainerPath = SkinController.FormatSkinPath(this.ActiveTab.ContainerSrc);
             this.ActiveTab.Panes = new ArrayList();
             this.ActiveTab.Modules = new ArrayList();
             ArrayList crumbs = new ArrayList();
             GetBreadCrumbsRecursively(ref crumbs, this.ActiveTab.TabID);
             this.ActiveTab.BreadCrumbs = crumbs;
         }
     }
     if (this.ActiveTab != null)
     {
         Dictionary<string, int> objPaneModules = new Dictionary<string, int>();
         foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(this.ActiveTab.TabID))
         {
             ModuleInfo cloneModule = kvp.Value.Clone();
             if (Null.IsNull(cloneModule.StartDate))
             {
                 cloneModule.StartDate = System.DateTime.MinValue;
             }
             if (Null.IsNull(cloneModule.EndDate))
             {
                 cloneModule.EndDate = System.DateTime.MaxValue;
             }
             if (String.IsNullOrEmpty(cloneModule.ContainerSrc))
             {
                 cloneModule.ContainerSrc = this.ActiveTab.ContainerSrc;
             }
             cloneModule.ContainerSrc = SkinController.FormatSkinSrc(cloneModule.ContainerSrc, this);
             cloneModule.ContainerPath = SkinController.FormatSkinPath(cloneModule.ContainerSrc);
             if (objPaneModules.ContainsKey(cloneModule.PaneName) == false)
             {
                 objPaneModules.Add(cloneModule.PaneName, 0);
             }
             cloneModule.PaneModuleCount = 0;
             if (!cloneModule.IsDeleted)
             {
                 objPaneModules[cloneModule.PaneName] = objPaneModules[cloneModule.PaneName] + 1;
                 cloneModule.PaneModuleIndex = objPaneModules[cloneModule.PaneName] - 1;
             }
             this.ActiveTab.Modules.Add(cloneModule);
         }
         foreach (ModuleInfo module in this.ActiveTab.Modules)
         {
             module.PaneModuleCount = objPaneModules[module.PaneName];
         }
     }
 }
Ejemplo n.º 40
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="texturePool"></param>
        /// <param name="gameParent"></param>
        /// <param name="portalInstance"></param>
        /// <param name="device"></param>
        /// <param name="usedProps"></param>
        /// <returns></returns>
        public static PortalItem CreatePortalFromProperty(TexturePool texturePool, WzSubProperty gameParent, PortalInstance portalInstance, GraphicsDevice device, ref List <WzObject> usedProps)
        {
            PortalInfo portalInfo = (PortalInfo)portalInstance.BaseInfo;

            if (portalInstance.pt == PortalType.PORTALTYPE_STARTPOINT ||
                portalInstance.pt == PortalType.PORTALTYPE_INVISIBLE ||
                //portalInstance.pt == PortalType.PORTALTYPE_CHANGABLE_INVISIBLE ||
                portalInstance.pt == PortalType.PORTALTYPE_SCRIPT_INVISIBLE ||
                portalInstance.pt == PortalType.PORTALTYPE_SCRIPT ||
                portalInstance.pt == PortalType.PORTALTYPE_COLLISION ||
                portalInstance.pt == PortalType.PORTALTYPE_COLLISION_SCRIPT ||
                portalInstance.pt == PortalType.PORTALTYPE_COLLISION_CUSTOM_IMPACT || // springs in Mechanical grave 350040240
                portalInstance.pt == PortalType.PORTALTYPE_COLLISION_VERTICAL_JUMP)   // vertical spring actually
            {
                return(null);
            }

            List <IDXObject> frames = new List <IDXObject>(); // All frames "stand", "speak" "blink" "hair", "angry", "wink" etc

            //string portalType = portalInstance.pt;
            //int portalId = Program.InfoManager.PortalIdByType[portalInstance.pt];

            WzSubProperty portalTypeProperty = (WzSubProperty)gameParent[portalInstance.pt];

            if (portalTypeProperty == null)
            {
                portalTypeProperty = (WzSubProperty)gameParent["pv"];
            }
            else
            {
                // Support for older versions of MapleStory where 'pv' is a subproperty for the image frame than a collection of subproperty of frames
                if (portalTypeProperty["0"] is WzCanvasProperty)
                {
                    frames.AddRange(LoadFrames(texturePool, portalTypeProperty, portalInstance.X, portalInstance.Y, device, ref usedProps));
                    portalTypeProperty = null;
                }
            }

            if (portalTypeProperty != null)
            {
                WzSubProperty portalImageProperty = (WzSubProperty)portalTypeProperty[portalInstance.image == null ? "default" : portalInstance.image];

                if (portalImageProperty != null)
                {
                    WzSubProperty framesPropertyParent;
                    if (portalImageProperty["portalContinue"] != null)
                    {
                        framesPropertyParent = (WzSubProperty)portalImageProperty["portalContinue"];
                    }
                    else
                    {
                        framesPropertyParent = (WzSubProperty)portalImageProperty;
                    }

                    if (framesPropertyParent != null)
                    {
                        frames.AddRange(LoadFrames(texturePool, framesPropertyParent, portalInstance.X, portalInstance.Y, device, ref usedProps));
                    }
                }
            }
            if (frames.Count == 0)
            {
                return(null);
            }
            return(new PortalItem(portalInstance, frames));
        }
Ejemplo n.º 41
0
 public static XmlNode SerializeTab(XmlDocument xmlTab, Hashtable hTabs, TabInfo objTab, PortalInfo objPortal, bool includeContent)
 {
     XmlNode nodeTab;
     XmlNode urlNode;
     XmlNode newnode;
     CBO.SerializeObject(objTab, xmlTab);
     nodeTab = xmlTab.SelectSingleNode("tab");
     nodeTab.Attributes.Remove(nodeTab.Attributes["xmlns:xsd"]);
     nodeTab.Attributes.Remove(nodeTab.Attributes["xmlns:xsi"]);
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("tabid"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("moduleID"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("taborder"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("portalid"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("parentid"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("isdeleted"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("tabpath"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("haschildren"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("skindoctype"));
     foreach (XmlNode nodePermission in nodeTab.SelectNodes("tabpermissions/permission"))
     {
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("tabpermissionid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("permissionid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("tabid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("roleid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("userid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("username"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("displayname"));
     }
     urlNode = xmlTab.SelectSingleNode("tab/url");
     switch (objTab.TabType)
     {
         case TabType.Normal:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "Normal"));
             break;
         case TabType.Tab:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "Tab"));
             TabInfo tab = new TabController().GetTab(Int32.Parse(objTab.Url), objTab.PortalID, false);
             urlNode.InnerXml = tab.TabPath;
             break;
         case TabType.File:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "File"));
             Services.FileSystem.FileInfo file = new Services.FileSystem.FileController().GetFileById(Int32.Parse(objTab.Url.Substring(7)), objTab.PortalID);
             urlNode.InnerXml = file.RelativePath;
             break;
         case TabType.Url:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "Url"));
             break;
     }
     XmlUtils.SerializeHashtable(objTab.TabSettings, xmlTab, nodeTab, "tabsetting", "settingname", "settingvalue");
     if (objPortal != null)
     {
         if (objTab.TabID == objPortal.SplashTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "splashtab";
             nodeTab.AppendChild(newnode);
         }
         else if (objTab.TabID == objPortal.HomeTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "hometab";
             nodeTab.AppendChild(newnode);
         }
         else if (objTab.TabID == objPortal.UserTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "usertab";
             nodeTab.AppendChild(newnode);
         }
         else if (objTab.TabID == objPortal.LoginTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "logintab";
             nodeTab.AppendChild(newnode);
         }
     }
     if (hTabs != null)
     {
         if (!Null.IsNull(objTab.ParentId))
         {
             newnode = xmlTab.CreateElement("parent");
             newnode.InnerXml = HttpContext.Current.Server.HtmlEncode(hTabs[objTab.ParentId].ToString());
             nodeTab.AppendChild(newnode);
             hTabs.Add(objTab.TabID, hTabs[objTab.ParentId].ToString() + "/" + objTab.TabName);
         }
         else
         {
             hTabs.Add(objTab.TabID, objTab.TabName);
         }
     }
     XmlNode nodePanes;
     XmlNode nodePane;
     XmlNode nodeName;
     XmlNode nodeModules;
     XmlNode nodeModule;
     XmlDocument xmlModule;
     ModuleInfo objmodule;
     ModuleController objmodules = new ModuleController();
     nodePanes = nodeTab.AppendChild(xmlTab.CreateElement("panes"));
     foreach (KeyValuePair<int, ModuleInfo> kvp in objmodules.GetTabModules(objTab.TabID))
     {
         objmodule = kvp.Value;
         if (!objmodule.IsDeleted)
         {
             xmlModule = new XmlDocument();
             nodeModule = ModuleController.SerializeModule(xmlModule, objmodule, includeContent);
             if (nodePanes.SelectSingleNode("descendant::pane[name='" + objmodule.PaneName + "']") == null)
             {
                 nodePane = xmlModule.CreateElement("pane");
                 nodeName = nodePane.AppendChild(xmlModule.CreateElement("name"));
                 nodeName.InnerText = objmodule.PaneName;
                 nodePane.AppendChild(xmlModule.CreateElement("modules"));
                 nodePanes.AppendChild(xmlTab.ImportNode(nodePane, true));
             }
             nodeModules = nodePanes.SelectSingleNode("descendant::pane[name='" + objmodule.PaneName + "']/modules");
             nodeModules.AppendChild(xmlTab.ImportNode(nodeModule, true));
         }
     }
     return nodeTab;
 }
 public static string DeletePortal(PortalInfo portal, string serverPath)
 {
     string strPortalName;
     string strMessage = string.Empty;
     int portalCount = DataProvider.Instance().GetPortalCount();
     if (portalCount > 1)
     {
         if (portal != null)
         {
             Globals.DeleteFilesRecursive(serverPath, ".Portal-" + portal.PortalID.ToString() + ".resx");
             PortalAliasController objPortalAliasController = new PortalAliasController();
             ArrayList arr = objPortalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID);
             if (arr.Count > 0)
             {
                 PortalAliasInfo objPortalAliasInfo = (PortalAliasInfo)arr[0];
                 strPortalName = Globals.GetPortalDomainName(objPortalAliasInfo.HTTPAlias, null, true);
                 if (objPortalAliasInfo.HTTPAlias.IndexOf("/") > -1)
                 {
                     strPortalName = objPortalAliasInfo.HTTPAlias.Substring(objPortalAliasInfo.HTTPAlias.LastIndexOf("/") + 1);
                 }
                 if (!String.IsNullOrEmpty(strPortalName) && System.IO.Directory.Exists(serverPath + strPortalName))
                 {
                     Globals.DeleteFolderRecursive(serverPath + strPortalName);
                 }
             }
             Globals.DeleteFolderRecursive(serverPath + "Portals\\" + portal.PortalID.ToString());
             if (!string.IsNullOrEmpty(portal.HomeDirectory))
             {
                 string HomeDirectory = portal.HomeDirectoryMapPath;
                 if (System.IO.Directory.Exists(HomeDirectory))
                 {
                     Globals.DeleteFolderRecursive(HomeDirectory);
                 }
             }
             PortalController objPortalController = new PortalController();
             objPortalController.DeletePortalInfo(portal.PortalID);
         }
     }
     else
     {
         strMessage = Localization.GetString("LastPortal");
     }
     return strMessage;
 }
Ejemplo n.º 43
0
 public PortalSettings(PortalInfo portal)
 {
     _ActiveTab = new TabInfo();
     GetPortalSettings(Null.NullInteger, portal);
 }
Ejemplo n.º 44
0
        public void ExtractPortals()
        {
            WzSubProperty portalParent = (WzSubProperty)this["map"]["MapHelper.img"]["portal"];
            WzSubProperty editorParent = (WzSubProperty)portalParent["editor"];

            for (int i = 0; i < editorParent.WzProperties.Count; i++)
            {
                WzCanvasProperty portal = (WzCanvasProperty)editorParent.WzProperties[i];
                Program.InfoManager.PortalTypeById.Add(portal.Name);
                PortalInfo.Load(portal);
            }

            WzSubProperty gameParent = (WzSubProperty)portalParent["game"]["pv"];

            foreach (WzImageProperty portal in gameParent.WzProperties)
            {
                if (portal.WzProperties[0] is WzSubProperty)
                {
                    Dictionary <string, Bitmap> images = new Dictionary <string, Bitmap>();
                    Bitmap defaultImage = null;
                    foreach (WzSubProperty image in portal.WzProperties)
                    {
                        //WzSubProperty portalContinue = (WzSubProperty)image["portalContinue"];
                        //if (portalContinue == null) continue;
                        Bitmap portalImage = image["0"].GetBitmap();
                        if (image.Name == "default")
                        {
                            defaultImage = portalImage;
                        }
                        else
                        {
                            images.Add(image.Name, portalImage);
                        }
                    }
                    Program.InfoManager.GamePortals.Add(portal.Name, new PortalGameImageInfo(defaultImage, images));
                }
                else if (portal.WzProperties[0] is WzCanvasProperty)
                {
                    Dictionary <string, Bitmap> images = new Dictionary <string, Bitmap>();
                    Bitmap defaultImage = null;
                    try
                    {
                        foreach (WzCanvasProperty image in portal.WzProperties)
                        {
                            //WzSubProperty portalContinue = (WzSubProperty)image["portalContinue"];
                            //if (portalContinue == null) continue;
                            Bitmap portalImage = image.GetLinkedWzCanvasBitmap();
                            defaultImage = portalImage;
                            images.Add(image.Name, portalImage);
                        }
                        Program.InfoManager.GamePortals.Add(portal.Name, new PortalGameImageInfo(defaultImage, images));
                    }
                    catch (InvalidCastException)
                    {
                        continue;
                    } //nexon likes to toss ints in here zType etc
                }
            }

            for (int i = 0; i < Program.InfoManager.PortalTypeById.Count; i++)
            {
                Program.InfoManager.PortalIdByType[Program.InfoManager.PortalTypeById[i]] = i;
            }
        }
 public static bool IsChildPortal(PortalInfo portal, string serverPath)
 {
     bool isChild = Null.NullBoolean;
     string portalName;
     PortalAliasController aliasController = new PortalAliasController();
     ArrayList arr = aliasController.GetPortalAliasArrayByPortalID(portal.PortalID);
     if (arr.Count > 0)
     {
         PortalAliasInfo portalAlias = (PortalAliasInfo)arr[0];
         portalName = Globals.GetPortalDomainName(portalAlias.HTTPAlias, null, true);
         if (portalAlias.HTTPAlias.IndexOf("/") > -1)
         {
             portalName = portalAlias.HTTPAlias.Substring(portalAlias.HTTPAlias.LastIndexOf("/") + 1);
         }
         if (!String.IsNullOrEmpty(portalName) && System.IO.Directory.Exists(serverPath + portalName))
         {
             isChild = true;
         }
     }
     return isChild;
 }