Пример #1
0
        private void LoadUrls()
        {
            var objUrls = new UrlController();

            cboUrls.Items.Clear();
            cboUrls.DataSource = objUrls.GetUrls(_objPortal.PortalID);
            cboUrls.DataBind();
        }
Пример #2
0
        private void ShowControls()
        {
            UrlController objUrls = new UrlController();

            // set url type
            if (optType.SelectedItem == null)
            {
                if (!String.IsNullOrEmpty(_Url))
                {
                    string TrackingUrl = _Url;

                    _UrlType = Globals.GetURLType(_Url).ToString("g").Substring(0, 1);

                    if (_UrlType == "F")
                    {
                        FileController objFiles = new FileController();
                        if (_Url.ToLower().StartsWith("fileid="))
                        {
                            TrackingUrl = _Url;
                            FileInfo objFile = objFiles.GetFileById(int.Parse(_Url.Substring(7)), _objPortal.PortalID);
                            if (objFile != null)
                            {
                                _Url = objFile.Folder + objFile.FileName;
                            }
                        }
                        else
                        {
                            // to handle legacy scenarios before the introduction of the FileServerHandler
                            TrackingUrl = "FileID=" + objFiles.ConvertFilePathToFileId(_Url, _objPortal.PortalID);
                        }
                    }

                    if (_UrlType == "M")
                    {
                        if (_Url.ToLower().StartsWith("userid="))
                        {
                            UserInfo objUser = UserController.GetUser(_objPortal.PortalID, int.Parse(_Url.Substring(7)), false);
                            if (objUser != null)
                            {
                                _Url = objUser.Username;
                            }
                        }
                    }

                    UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(_objPortal.PortalID, TrackingUrl, ModuleID);
                    if (objUrlTracking != null)
                    {
                        optType.Items.FindByValue(objUrlTracking.UrlType).Selected = true;
                        chkNewWindow.Checked = objUrlTracking.NewWindow;
                        chkTrack.Checked     = objUrlTracking.TrackClicks;
                        chkLog.Checked       = objUrlTracking.LogActivity;
                    }
                    else // the url does not exist in the tracking table
                    {
                        optType.Items.FindByValue(_UrlType).Selected = true;
                        chkNewWindow.Checked = false;
                        chkTrack.Checked     = true;
                        chkLog.Checked       = false;
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(_UrlType))
                    {
                        if (optType.Items.FindByValue(_UrlType) != null)
                        {
                            optType.Items.FindByValue(_UrlType).Selected = true;
                        }
                        else
                        {
                            optType.Items[0].Selected = true;
                        }
                    }
                    else
                    {
                        optType.Items[0].Selected = true;
                    }
                    chkNewWindow.Checked = false;
                    chkTrack.Checked     = true;
                    chkLog.Checked       = false;
                }
            }

            // load listitems
            switch (optType.SelectedItem.Value)
            {
            case "N":     // None

                URLRow.Visible  = false;
                TabRow.Visible  = false;
                FileRow.Visible = false;
                UserRow.Visible = false;
                break;

            case "U":     // Url

                URLRow.Visible  = true;
                TabRow.Visible  = false;
                FileRow.Visible = false;
                UserRow.Visible = false;

                if (txtUrl.Text == "")
                {
                    txtUrl.Text = _Url;
                }
                if (txtUrl.Text == "")
                {
                    txtUrl.Text = "http://";
                }
                txtUrl.Visible = true;

                cmdSelect.Visible = true;

                cboUrls.Items.Clear();
                cboUrls.DataSource = objUrls.GetUrls(_objPortal.PortalID);
                cboUrls.DataBind();
                if (cboUrls.Items.FindByValue(_Url) != null)
                {
                    cboUrls.Items.FindByValue(_Url).Selected = true;
                }
                cboUrls.Visible = false;

                cmdAdd.Visible    = false;
                cmdDelete.Visible = false;
                break;

            case "T":     // tab

                URLRow.Visible  = false;
                TabRow.Visible  = true;
                FileRow.Visible = false;
                UserRow.Visible = false;

                cboTabs.Items.Clear();

                cboTabs.DataSource = Globals.GetPortalTabs(_objPortal.PortalID, !_Required, true, false, false, false);
                cboTabs.DataBind();
                if (cboTabs.Items.FindByValue(_Url) != null)
                {
                    cboTabs.Items.FindByValue(_Url).Selected = true;
                }
                break;

            case "F":     // file

                URLRow.Visible  = false;
                TabRow.Visible  = false;
                FileRow.Visible = true;
                UserRow.Visible = false;

                LoadFolders();

                if (cboFolders.Items.Count == 0)
                {
                    lblMessage.Text = Localization.GetString("NoPermission", this.LocalResourceFile);
                    FileRow.Visible = false;
                    return;
                }

                // select folder
                string FileName;
                string FolderPath;
                if (_Url != string.Empty)
                {
                    FileName   = _Url.Substring(_Url.LastIndexOf("/") + 1);
                    FolderPath = _Url.Replace(FileName, "");
                }
                else
                {
                    FileName   = _Url;
                    FolderPath = string.Empty;
                }
                if (cboFolders.Items.FindByValue(FolderPath) != null)
                {
                    cboFolders.Items.FindByValue(FolderPath).Selected = true;
                }
                else
                {
                    cboFolders.Items[0].Selected = true;
                    FolderPath = cboFolders.SelectedValue;
                }

                //cboFiles.DataSource = GetFileList(FileFilter, !_Required, cboFolders.SelectedItem.Value);
                cboFiles.DataSource = GetFileList(!_Required);
                cboFiles.DataBind();
                if (cboFiles.Items.FindByText(FileName) != null)
                {
                    cboFiles.Items.FindByText(FileName).Selected = true;
                }
                cboFiles.Visible = true;
                txtFile.Visible  = false;

                string strWriteRoles = GetWriteRoles(FolderPath);
                cmdUpload.Visible = PortalSecurity.IsInRoles(strWriteRoles) && _ShowUpLoad;

                SetStorageLocationType();

                txtUrl.Visible    = false;
                cmdSave.Visible   = false;
                cmdCancel.Visible = false;
                break;

            case "M":     // membership users

                URLRow.Visible  = false;
                TabRow.Visible  = false;
                FileRow.Visible = false;
                UserRow.Visible = true;

                if (txtUser.Text == "")
                {
                    txtUser.Text = _Url;
                }
                break;
            }
        }