Beispiel #1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            CategorySearchButtonWrapper.Visible = (!WebsiteBrandManager.GetBrand().HideCategorySearch);
            FilterSearchButtonWrapper.Visible   = (!WebsiteBrandManager.GetBrand().HideFilterSearch);

            MetadataFilters.FilterSearchClick += (MetadataFilters_FilterSearchClick);
        }
        private bool DisplayDownloadHyperlink(Asset asset)
        {
            if (ShowButtons.IsSet(Buttons.Download))
            {
                // Only display download link for users who can download the asset
                // when the direct download feature is enabled.
                if (WebsiteBrandManager.GetBrand().DirectDownloadEnabled)
                {
                    return(!EntitySecurityManager.IsAssetRestricted(CurrentUser, asset));
                }

                // Super-admins can always download assets
                if (CurrentUser.UserRole.Equals(UserRole.SuperAdministrator))
                {
                    return(true);
                }

                // Upload users can always download their own assets
                if (asset.UploadedByUserId.Equals(CurrentUser.UserId))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
 protected void ResetSearchButton_Click(object sender, EventArgs e)
 {
     SavedUserAssetSearch.AssetFinder         = SearchManager.GetBaseAssetFinder(CurrentUser);
     SavedUserAssetSearch.AssetFinder.BrandId = WebsiteBrandManager.GetBrand().BrandId.GetValueOrDefault();
     SavedUserAssetSearch.SelectCategory(0);
     Response.Redirect("~/SearchResults.aspx", false);
 }
Beispiel #4
0
        protected override void OnPreRender(EventArgs e)
        {
            BrandMetadataSetting setting = Brand.GetMetadataSetting(FieldName);

            if (setting.IsNull)
            {
                setting = WebsiteBrandManager.GetMasterBrand().GetMetadataSetting(FieldName);
            }

            if (setting.IsNull || StringUtils.IsBlank(setting.FieldName))
            {
                Text = GeneralUtils.SplitIntoSentence(FieldName);
                return;
            }

            Text = string.Format("<a href=\"#\" title=\"{0}\" class=\"PanelTxt Bold\">{1}:</a>", setting.ToolTip, setting.FieldName);

            if (ShowRequiredFlag && setting.IsRequired)
            {
                Text += "  <span class=\"ReqField\">*</span>";
            }

            if (!StringUtils.IsBlank(setting.AdditionalCopy))
            {
                Text += string.Format("<br /><span class=\"PanelTxt\">{0}</span>", setting.AdditionalCopy);
            }
        }
        public void AddAdvancedSearchCriteria(ref AssetFinder finder)
        {
            // Don't add anything if filter search is disabled
            if (WebsiteBrandManager.GetBrand().HideFilterSearch)
            {
                return;
            }
            //-------------------------------------------------------------------
            // Metadata input selections
            //-------------------------------------------------------------------
            foreach (MetadataInputWrapper input in TemporaryMetaControlsPlaceHolder.Controls)
            {
                IEnumerable <int> metaIds;

                input.GetSelection(out metaIds);

                if (metaIds != null)
                {
                    finder.MetadataIds[input.GroupNumber] = metaIds.ToList();
                }
            }

            if (FileSizeDropDownList.SelectedValue != "any")
            {
                long parsedFileSize = ConvertUserInputToFileSize(FileSizeTextBox.Text);

                if (parsedFileSize > 0)
                {
                    CompareType compareType = GeneralUtils.ParseEnum(FileSizeDropDownList.SelectedValue, CompareType.Exact);
                    finder.AddComplexCriteria(Asset.Columns.FileSize, parsedFileSize, compareType);
                }
            }

            //-------------------------------------------------------------------
            // Production date criteria
            //-------------------------------------------------------------------
            finder.FromProductionDay   = FromDayDropDownList.SelectedId;
            finder.FromProductionMonth = FromMonthDropDownList.SelectedId;
            finder.FromProductionYear  = FromYearDropDownList.SelectedId;
            finder.ToProductionDay     = ToDayDropDownList.SelectedId;
            finder.ToProductionMonth   = ToMonthDropDownList.SelectedId;
            finder.ToProductionYear    = ToYearDropDownList.SelectedId;


            //-------------------------------------------------------------------
            // Asset type specific criteria
            //-------------------------------------------------------------------
            if (AssetTypeCache.Instance.GetById(finder.AssetTypeId).FileExtensionList.Select(extension => AssetTypeInfo.Get(extension)).Any(ati => ati.HasOrientation))
            {
                if (OrientationDropDownList.SelectedValue != "all")
                {
                    finder.Orientation = GeneralUtils.ParseEnum(OrientationDropDownList.SelectedValue, Data.Orientation.All);
                }
            }

            SetupHiddenAssetOptions(finder);
        }
        protected override void OnInit(System.EventArgs e)
        {
            if (AutoSetBrand)
            {
                BrandId = WebsiteBrandManager.GetBrand().BrandId.GetValueOrDefault();
            }

            base.OnInit(e);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ChangeMasterBrandButton.Attributes["onClick"] = "return confirm('Are you sure you want to change the master brand?')";

            if (!Page.IsPostBack)
            {
                MasterBrandDropDownList.SafeSelectValue(WebsiteBrandManager.GetMasterBrand().BrandId);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Saves the selected brands to user.
        /// </summary>
        /// <param name="user">The user.</param>
        private void SaveSelectedBrandsToUser(User user)
        {
            if (user.IsNull)
            {
                throw new SystemException("Brands cannot be added to a null user");
            }

            user.Brands.Clear();
            user.PrimaryBrandId = 0;

            if (BrandSelectorRow.Visible)
            {
                foreach (RepeaterItem ri in BrandSelectorRepeater.Items)
                {
                    switch (ri.ItemType)
                    {
                    case ListItemType.Item:
                    case ListItemType.AlternatingItem:

                        // Get the brand ID
                        HiddenField BrandIdHiddenField = (HiddenField)ri.FindControl("BrandIdHiddenField");
                        int         brandId            = NumericUtils.ParseInt32(BrandIdHiddenField.Value, 0);

                        // Get the user interface controls
                        CheckBox    IsSelectedCheckBox     = (CheckBox)ri.FindControl("IsSelectedCheckBox");
                        RadioButton IsMainBrandRadioButton = (RadioButton)ri.FindControl("IsMainBrandRadioButton");

                        // If the brand is selected or set as the primary, add it to the list
                        if (IsSelectedCheckBox.Checked || IsMainBrandRadioButton.Checked)
                        {
                            user.Brands.Add(BrandCache.Instance.GetById(brandId));
                        }

                        // Set the primary brand
                        if (IsMainBrandRadioButton.Checked)
                        {
                            user.PrimaryBrandId = brandId;
                        }

                        break;
                    }
                }
            }
            else
            {
                // Brand selector is not visible, either because there's only one brand
                // or the user is a brand administrator.  Therefore, only add the current brand.

                Brand brand = WebsiteBrandManager.GetBrand();
                user.Brands.Add(brand);
                user.PrimaryBrandId = brand.BrandId.GetValueOrDefault();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Global.AllowPublicRegistration)
            {
                throw new HttpException(404, "Page not found");
            }

            if (!Page.IsPostBack)
            {
                UserDetailsForm1.BrandId = WebsiteBrandManager.GetBrand().BrandId.GetValueOrDefault();
            }
        }
Beispiel #10
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (Mode == Modes.Registration)
     {
         RegistrationOnlyOptions.Visible = true;
         BrandSelectorRow.Visible        = (WebsiteBrandManager.GetBrand().IsBrandSelectionAllowed&& BrandCache.Instance.GetList().Count > 1);
     }
     else
     {
         RegistrationOnlyOptions.Visible = false;
     }
 }
Beispiel #11
0
        private static void AddCategorySearchCriteria()
        {
            // Don't add anything if category search is disabled
            if (WebsiteBrandManager.GetBrand().HideCategorySearch)
            {
                return;
            }

            if (!SavedUserAssetSearch.CurrentCategory.IsNull)
            {
                SavedUserAssetSearch.SelectCategory(SavedUserAssetSearch.CurrentCategoryId);
            }
        }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IsStaffUserRadioButtonList.SelectedValue = "1";
                CompanyNameTextBox.Text = WebsiteBrandManager.GetBrand().OrganisationName;

                //Sets the default state for the form.
                IsStaffUserCheck();

                BindCompanyDropDownList();
            }
        }
Beispiel #13
0
        public void ToggleSearchVisibility(bool filtersVisible, bool categoriesVisible, bool updateSavedSearch)
        {
            if (WebsiteBrandManager.GetBrand().HideFilterSearch)
            {
                filtersVisible = false;
            }

            if (WebsiteBrandManager.GetBrand().HideCategorySearch)
            {
                categoriesVisible = false;
            }

            FiltersPanel.Visible            = filtersVisible;
            CategoryNavigationPanel.Visible = categoriesVisible;

            if (updateSavedSearch)
            {
                SavedUserAssetSearch.FilterOpen     = filtersVisible;
                SavedUserAssetSearch.CategoriesOpen = categoriesVisible;
            }

            if (categoriesVisible)
            {
                // Show the "view all assets" link in the category panel if we have a search keyword
                // This will allow us to clear the text but retain the category, so that all assets
                // in the selected category are displayed.
                ViewAllAssetsLinkButtonWrapper.Visible = (!StringUtils.IsBlank(SavedUserAssetSearch.AssetFinder.GeneralKeyword));
            }

            if (filtersVisible)
            {
                // Get the finder from the session
                var finder = SavedUserAssetSearch.AssetFinder;

                //load meta lists and dropdowns
                RebindMetadataFilter();

                // load metadata filter
                MetadataFilters.LoadFilterFromStoredValues(finder);

                // No need to rebind these
                // BrandDropDownList1.SafeSelectValue(finder.BrandId);
                // AssetTypeDropDownList1.SafeSelectValue(finder.AssetTypeId);



                ToggleAssetTypeFilters();
            }

            TogglePanelButtonText();
        }
Beispiel #14
0
        /// <summary>
        /// Gets the primary brand id.
        /// </summary>
        /// <returns></returns>
        private int GetPrimaryBrandId()
        {
            if (BrandSelectorRow.Visible)
            {
                return((from RepeaterItem ri in BrandSelectorRepeater.Items
                        where GeneralUtils.ValueIsInList(ri.ItemType, ListItemType.Item, ListItemType.AlternatingItem)
                        let IsMainBrandRadioButton = (RadioButton)ri.FindControl("IsMainBrandRadioButton")
                                                     where IsMainBrandRadioButton.Checked
                                                     select(HiddenField) ri.FindControl("BrandIdHiddenField")
                                                     into BrandIdHiddenField
                                                     select NumericUtils.ParseInt32(BrandIdHiddenField.Value, 0)).FirstOrDefault());
            }

            return(WebsiteBrandManager.GetBrand().BrandId.GetValueOrDefault());
        }
Beispiel #15
0
        protected override void OnPreRender(EventArgs e)
        {
            BrandMetadataSetting setting = Brand.GetMetadataSetting(FieldName);

            if (setting.IsNull)
            {
                setting = WebsiteBrandManager.GetMasterBrand().GetMetadataSetting(FieldName);
            }

            if (setting.IsNull || StringUtils.IsBlank(setting.FieldName))
            {
                Text = GeneralUtils.SplitIntoSentence(FieldName);
                return;
            }

            Text = setting.FieldName;
        }
Beispiel #16
0
        protected override void Render(HtmlTextWriter writer)
        {
            // Don't do anything if no CSS has been specified
            if (StringUtils.IsBlank(Css))
            {
                return;
            }

            int brandId = WebsiteBrandManager.GetBrand().BrandId.GetValueOrDefault();

            // Use the brand ID if one has specified
            if (BrandId > 0)
            {
                Brand brand = WebsiteBrandManager.GetBrandById(BrandId);

                if (brand != null)
                {
                    brandId = brand.BrandId.GetValueOrDefault();
                }
            }

            if (brandId == 0)
            {
                brandId = WebsiteBrandManager.GetMasterBrand().BrandId.GetValueOrDefault();
                writer.WriteLine("<!-- SKIN FOLDER NOT SPECIFIED. USING MASTER BRAND INSTEAD -->");
            }

            // List of CSS files
            string[] cssFiles = Css.Split('|');

            // Check that the specified files exist and load these into a list
            List <string> list = (from cssFile in cssFiles
                                  select string.Format("~/Brands/Brand_{0}/UI/{1}.css", brandId, cssFile)
                                  into relativePath let absolutePath = CurrentContext.Server.MapPath(relativePath)
                                                                       where File.Exists(absolutePath)
                                                                       select relativePath).ToList();

            // Render the link tags for the CSS files
            foreach (string s in list)
            {
                writer.AddAttribute("rel", "stylesheet");
                writer.AddAttribute("type", "text/css");
                writer.AddAttribute("href", ResolveUrl(s));
                writer.RenderBeginTag("link");
            }
        }
        protected bool ShowFileMetadata()
        {
            if (!WebsiteBrandManager.GetBrand().GetMetadataSetting(BrandMetadataSettings.SHOW_FILE_METADATA).OnAssetDetail)
            {
                return(false);
            }

            var metadataList = CurrentAsset.GetFileMetadata(true);

            if (metadataList.Count > 0)
            {
                AssetFileMetadataRepeater.DataSource = metadataList;
                AssetFileMetadataRepeater.DataBind();
                return(true);
            }

            return(false);
        }
Beispiel #18
0
        protected void BrandSelectorRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:

                Brand brand   = (Brand)e.Item.DataItem;
                int   brandId = brand.BrandId.GetValueOrDefault();

                HiddenField BrandIdHiddenField = (HiddenField)e.Item.FindControl("BrandIdHiddenField");
                BrandIdHiddenField.Value = brandId.ToString();

                Label BrandNameLabel = (Label)e.Item.FindControl("BrandNameLabel");
                BrandNameLabel.Text = brand.Name;

                bool isSelected;
                bool isMainBrand;

                if (UserBeingEdited.IsNull)
                {
                    isSelected  = WebsiteBrandManager.GetBrand().BrandId == brandId;
                    isMainBrand = isSelected;
                }
                else
                {
                    isSelected  = (UserBeingEdited.PrimaryBrandId == brandId || UserBeingEdited.CanAccessBrand(brandId));
                    isMainBrand = (UserBeingEdited.PrimaryBrandId == brandId);
                }

                CheckBox IsSelectedCheckBox = (CheckBox)e.Item.FindControl("IsSelectedCheckBox");
                IsSelectedCheckBox.Checked = isSelected;

                RadioButton IsMainBrandRadioButton = (RadioButton)e.Item.FindControl("IsMainBrandRadioButton");
                IsMainBrandRadioButton.Checked = isMainBrand;

                const string script = "setUniqueRadioButton('BrandSelectorRepeater.*IsMainBrand',this)";
                IsMainBrandRadioButton.Attributes.Add("onclick", script);

                break;
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            if (!WebsiteBrandManager.GetBrand().DisablePoweredByLogo)
            {
                // THE FOCUSOPEN ATTRIBUTION FOOTER MUST BE RETAINED AS PART OF THE TERMS OF USE OF THE GPL LICENSE
                // This is included below as backwards text and using string concatenation to avoid finding this using
                // standard find and replace tools, and deter casual copyright infringement.

                const string text = ">a/<reganaM tessA latigiD NEPOsucoF>\"knalb_\"=tegrat \";000#:roloc;me7.0:ezis-tnof\"=elyts \"/moc.reganamtessalatigid.www//:ptth\"=ferh a<>/ rb<>a/<>/ \"0\"=redrob \"$$lru-egami$$\"=crs gmi<>\"knalb_\"=tegrat \"/moc.reganamtessalatigid.www//:ptth\"=ferh a<";

                foreach (char c in text)
                {
                    Text = c + Text;
                }

                Text = Text.Replace("$$image-url$$", ResolveUrl("~/ima" + "ges/p" + "ow" + "ere" + "d-by" + ".jpg"));

                SetGPLFooter();
            }
        }
Beispiel #20
0
        private void BindCompanyDropDownList()
        {
            List <Company> list = new List <Company>();

            list.AddRange(CompanyCache.Instance.GetList()
                          .Where(c => (c.IsInternal) && (BrandManager.IsSingleBrandMode || c.BrandList.Any(b => b.BrandId == WebsiteBrandManager.GetBrand().BrandId.GetValueOrDefault()))));

            CompanyDropDownList.DataSource     = list;
            CompanyDropDownList.DataTextField  = Company.Columns.Name.ToString();
            CompanyDropDownList.DataValueField = Company.Columns.Name.ToString();
            CompanyDropDownList.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (CurrentAsset.IsNull)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "close", "self.close();", true);
                    return;
                }

                // Get the asset ID
                int assetId = CurrentAsset.AssetId.GetValueOrDefault();

                // Get the asset type info
                AssetTypeInfo assetType = AssetTypeInfo.Get(CurrentAsset.FileExtension);


                //-----------------------------------------------------------------------------------------------------
                // Set up UI elements based on asset type
                //-----------------------------------------------------------------------------------------------------
                OrientationRow.Visible = assetType.HasOrientation;
                DurationRow.Visible    = assetType.HasDuration;
                DimensionsRow.Visible  = assetType.HasDimensions;

                //-----------------------------------------------------------------------------------------------------
                // Set up asset breadcrumbs based on category
                //-----------------------------------------------------------------------------------------------------
                AssetBreadcrumb.CategoryId = CurrentAsset.PrimaryCategoryId;

                //-----------------------------------------------------------------------------------------------------
                // Update the audit log
                //-----------------------------------------------------------------------------------------------------
                AuditLogManager.LogAssetAction(assetId, CurrentUser, AuditAssetAction.ViewedAssetDetail);
                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ViewedAssetDetail, string.Format("Viewed asset detail for AssetId: {0}", assetId));

                //-----------------------------------------------------------------------------------------------------
                // Initialise the asset preview and buttons
                //-----------------------------------------------------------------------------------------------------
                AssetPreview1.Asset = CurrentAsset;
                AssetButtons1.Initialise(CurrentAsset);

                //-----------------------------------------------------------------------------------------------------
                // Bind categories list
                //-----------------------------------------------------------------------------------------------------
                AssetCategoriesContainer.Visible = (CurrentAsset.CategoryList.Count > 0);
                CategoriesRepeater.DataSource    = CurrentAsset.CategoryList;
                CategoriesRepeater.DataBind();

                //-----------------------------------------------------------------------------------------------------
                // Bind attached files
                //-----------------------------------------------------------------------------------------------------
                List <AssetFile> attachedFiles = CurrentAsset.GetAttachedFiles();
                AttachedFilesRow.Visible         = (attachedFiles.Count > 0);
                AttachedFilesDataList.DataSource = attachedFiles;
                AttachedFilesDataList.DataBind();

                //-----------------------------------------------------------------------------------------------------
                // Bind linked assets
                //-----------------------------------------------------------------------------------------------------
                LinkedAssetsRow.Visible         = (CurrentAsset.ReciprocalLinkedAssetList.Count > 0);
                LinkedAssetsRepeater.DataSource = CurrentAsset.ReciprocalLinkedAssetList;
                LinkedAssetsRepeater.DataBind();

                //-----------------------------------------------------------------------------------------------------
                // Set up the file type icon
                //-----------------------------------------------------------------------------------------------------
                FileTypeIconImage.ImageUrl = SiteUtils.GetFileTypeImageUrl(CurrentAsset.FileExtension);
                FileTypeIconImage.ToolTip  = CurrentAsset.Filename;

                //-----------------------------------------------------------------------------------------------------
                // Brand controlled metadata
                //-----------------------------------------------------------------------------------------------------
                AssetIdCell.InnerText      = CurrentAsset.AssetId.ToString();
                DateUploadedLabel.Text     = CurrentAsset.UploadDate.ToString(Global.DateFormat);
                FilenameCell.InnerText     = FileUtils.GetTruncatedFilename(CurrentAsset.Filename, 25);
                FileHashLabel.Text         = StringUtils.IsBlank(CurrentAsset.FileHash) ? "[Not Available]" : CurrentAsset.FileHash.Substring(0, 15) + " ...";
                FileHashLabel.ToolTip      = CurrentAsset.FileHash;
                FilesizeCell.InnerText     = FileUtils.FriendlyFileSize(CurrentAsset.FileSize);
                AssetTypeCell.InnerText    = CurrentAsset.AssetType.Name;
                DateProducedCell.InnerText = CurrentAsset.GetProductionDate();
                OriginatorCell.InnerText   = CurrentAsset.Originator;
                TitleCell.InnerText        = CurrentAsset.Title;
                ProjectCodeCell.InnerText  = CurrentAsset.ProjectCode;
                BrandCell.InnerText        = CurrentAsset.Brand.Name;

                AssetDescriptionContainer.InnerHtml = SiteUtils.ConvertTextToHtml(CurrentAsset.Description);
                AdditionalKeywordsCell.InnerText    = CurrentAsset.Keywords;
                CopyrightOwnerCell.InnerHtml        = StringUtils.IgnoreCaseCompare(CurrentAsset.CopyrightOwner, WebsiteBrandManager.GetBrand().OrganisationName) ? "(c) " + CurrentAsset.CopyrightOwner : CurrentAsset.CopyrightOwner;
                UsageRestrictionsCell.InnerHtml     = CurrentAsset.UsageRestrictions;
                ContactEmailHyperLink.EmailAddress  = CurrentAsset.ContactEmail;
                PublicationDateCell.InnerText       = CurrentAsset.PublishDate.ToString(Global.DateFormat);
                ExpiryDateCell.InnerText            = CurrentAsset.ExpiryDate.ToString(Global.DateFormat);

                // order metas according to their meta settings asset detail order numbers
                TrBrand.Attributes["class"]              = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.BRAND).AssetDetailOrderNum.ToString();
                TrAssetType.Attributes["class"]          = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ASSET_TYPE).AssetDetailOrderNum.ToString();
                TrFilename.Attributes["class"]           = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.FILENAME).AssetDetailOrderNum.ToString();
                TrFileSize.Attributes["class"]           = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.FILESIZE).AssetDetailOrderNum.ToString();
                TrFileHash.Attributes["class"]           = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.FILEHASH).AssetDetailOrderNum.ToString();
                TrDateUploaded.Attributes["class"]       = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.DATE_UPLOADED).AssetDetailOrderNum.ToString();
                TrTitle.Attributes["class"]              = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.TITLE).AssetDetailOrderNum.ToString();
                TrProjectCode.Attributes["class"]        = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.PROJECT_CODE).AssetDetailOrderNum.ToString();
                TrOriginator.Attributes["class"]         = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ORIGINATOR).AssetDetailOrderNum.ToString();
                TrDateProduced.Attributes["class"]       = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.DATE_PRODUCED).AssetDetailOrderNum.ToString();
                TrContactEmail.Attributes["class"]       = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.CONTACT_EMAIL).AssetDetailOrderNum.ToString();
                TrCopyrightOwner.Attributes["class"]     = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.COPYRIGHT_OWNER).AssetDetailOrderNum.ToString();
                TrRestrictedDownload.Attributes["class"] = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.DOWNLOAD_RESTRICTIONS).AssetDetailOrderNum.ToString();
                TrUsageRestrictions.Attributes["class"]  = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.USAGE_RESTRICTIONS).AssetDetailOrderNum.ToString();
                TrAdditionalKeywords.Attributes["class"] = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ADDITIONAL_KEYWORDS).AssetDetailOrderNum.ToString();
                TrPublicationDate.Attributes["class"]    = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.PUBLICATION_DATE).AssetDetailOrderNum.ToString();
                TrExpiryDate.Attributes["class"]         = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.EXPIRY_DATE).AssetDetailOrderNum.ToString();
                LinkedAssetsRow.Attributes["class"]      = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.LINKED_ASSETS).AssetDetailOrderNum.ToString();
                AttachedFilesRow.Attributes["class"]     = CurrentAsset.Brand.GetMetadataSetting(BrandMetadataSettings.ATTACHED_FILES).AssetDetailOrderNum.ToString();

                var allSettings = BrandMetadataSettingManager.GetCustomMetadataSettings(CurrentAsset.Brand.BrandId.GetValueOrDefault());
                var lastNum     = allSettings.OrderBy(s => s.AssetDetailOrderNum).LastOrDefault().AssetDetailOrderNum;

                DimensionsRow.Attributes["class"]  = (lastNum++).ToString();
                DurationRow.Attributes["class"]    = (lastNum++).ToString();
                OrientationRow.Attributes["class"] = (lastNum++).ToString();

                //-----------------------------------------------------------------------------------------------------
                // Other stuff
                //-----------------------------------------------------------------------------------------------------
                OrientationCell.InnerText        = CurrentAsset.GetOrientation();
                DurationCell.InnerText           = SiteUtils.FriendlyDuration(CurrentAsset.Duration.GetValueOrDefault(), "Unknown");
                DimensionsCell.InnerText         = CurrentAsset.GetDimensions();
                RestrictedDownloadCell.InnerText = EntitySecurityManager.IsAssetRestricted(CurrentUser, CurrentAsset) ? "Yes" : "No";

                // Only show file metadata link if we have some available
                // ShowFileMeta data returns true if there is File metadata to display.
                FileMetadataLinkButton.Visible  = ShowFileMetadata();
                FileMetadataLinkDivider.Visible = FileMetadataLinkButton.Visible;

                //-----------------------------------------------------------------------------------------------------
                // Setup security in UI: Only display the edit and status links of the user has access
                //-----------------------------------------------------------------------------------------------------
                if (EntitySecurityManager.CanManageAsset(CurrentUser, CurrentAsset))
                {
                    string editUrl = "~/Admin/Assets/AssetForm.aspx?assetId=" + CurrentAsset.AssetId;
                    EditHyperLink.NavigateUrl = editUrl;
                    EditHyperLink.Attributes.Add("onClick", string.Format("GetParentWindow().location.href='{0}';self.close();return false;", ResolveUrl(editUrl)));

                    string statsUrl = "~/Admin/Reports/AssetStats.aspx?assetId=" + assetId;
                    StatsHyperLink.NavigateUrl = statsUrl;
                    StatsHyperLink.Attributes.Add("onClick", string.Format("GetParentWindow().location.href='{0}';self.close();return false;", ResolveUrl(statsUrl)));

                    string logHyperlink = "~/Admin/Reports/AssetAuditTrail.aspx?AssetId=" + CurrentAsset.AssetId;
                    LogHyperLink.NavigateUrl = logHyperlink;
                    LogHyperLink.Attributes.Add("onClick", string.Format("GetParentWindow().location.href='{0}';self.close();return false;", ResolveUrl(logHyperlink)));
                }
                else
                {
                    AssetLinksContainer.Visible = false;
                }

                //-----------------------------------------------------------------------------------------------------
                // Control access or AssetOrderHistory links.
                //-----------------------------------------------------------------------------------------------------
                if (!EntitySecurityManager.CanViewAssetOrderHistory(CurrentUser, CurrentAsset))
                {
                    // Get the asset order history, if there isn't any order history
                    // then hide the link.
                    // Set visiblity of order history link
                    OrderHistoryDivider.Visible    = false;
                    OrderHistoryLinkButton.Visible = false;
                }
                else
                {
                    // Get the asset order history, if there isn't any order history
                    // then hide the link.
                    if (!ShowOrderHistory())
                    {
                        // Set visiblity of order history link
                        OrderHistoryDivider.Visible    = false;
                        OrderHistoryLinkButton.Visible = false;
                    }
                }

                //-----------------------------------------------------------------------------------------------------
                // Populate blank cells
                //-----------------------------------------------------------------------------------------------------
                SiteUtils.PopulateBlankControl(AssetDescriptionContainer);
                SiteUtils.PopulateBlankControl(FilenameCell);
                SiteUtils.PopulateBlankControl(FilesizeCell);
                SiteUtils.PopulateBlankControl(TitleCell);
                SiteUtils.PopulateBlankControl(DurationCell);
                SiteUtils.PopulateBlankControl(ProjectCodeCell);
                SiteUtils.PopulateBlankControl(OriginatorCell);
                SiteUtils.PopulateBlankControl(DateProducedCell);
                SiteUtils.PopulateBlankControl(CopyrightOwnerCell);
                SiteUtils.PopulateBlankControl(OrientationCell);
                SiteUtils.PopulateBlankControl(UsageRestrictionsCell);
            }

            //sort metas on every request
            ClientScript.RegisterStartupScript(GetType(), "SortMetas2", "SortMetas();", true);

            //bind repeater on every request as otherwise labels stuff is lost
            MetadataRepeater.DataSource = BrandMetadataSettingManager.GetCustomMetadataSettings(CurrentAsset.BrandId);
            MetadataRepeater.DataBind();
        }
Beispiel #22
0
        private static List <BrandMetadataSetting> GetMetadataSettings(int brandId)
        {
            // Get all of the metadata settings for this brand
            BrandMetadataSettingFinder finder = new BrandMetadataSettingFinder {
                BrandId = brandId
            };
            List <BrandMetadataSetting> settings = BrandMetadataSetting.FindMany(finder);

            // Return settings if found
            if (settings.Count == 0)
            {
                // Otherwise, we need to get the default settings
                List <int> brandIdList = new List <int>();

                // Check the master brand first
                if (brandId != WebsiteBrandManager.GetMasterBrand().BrandId)
                {
                    brandIdList.Add(WebsiteBrandManager.GetMasterBrand().BrandId.GetValueOrDefault());
                }

                // Then all subsequent brands
                foreach (Brand brand in BrandCache.Instance.GetList())
                {
                    if (!brandIdList.Contains(brand.BrandId.GetValueOrDefault()))
                    {
                        brandIdList.Add(brand.BrandId.GetValueOrDefault());
                    }
                }

                // Now check each brand
                foreach (int id in brandIdList)
                {
                    // Get the metadata settings in this brand
                    finder = new BrandMetadataSettingFinder {
                        BrandId = id, IsCustom = false
                    };
                    settings = BrandMetadataSetting.FindMany(finder);

                    if (settings.Count > 0)
                    {
                        // Settings found.  Copy all of them to the brand
                        // being edited and drop out of the loop as we've
                        // found what we're looking for.

                        foreach (BrandMetadataSetting setting in settings)
                        {
                            setting.BrandMetadataSettingId = null;
                            setting.BrandId = brandId;
                            BrandMetadataSetting.Update(setting);
                        }

                        break;
                    }
                }
            }

            // Still no settings, so copy them from the default metadata options
//			if (settings.Count == 0)
//			{
            // Still no settings so try and add these using our configuration settings
//				foreach (MetadataOption option in m_MetadataOptions)
//					AddMetadataSettingToDatabase(brandId, option, settings);
//			}
//
            // There should be the same number of settings in the database as there are default metadata
            // options or this means that these are out of sync. In this case, add the new setting to the list.
//
//			if (settings.Count < m_MetadataOptions.Count)
//			{
            // First get the missing settings.  These are items that exist in the metadata options list
            // but not in the list we got from the database.
//				var missingSettings = (from o in m_MetadataOptions
//				                       where !settings.Any(s => s.FieldId == o.FieldId)
//				                       select o);
//
            // Now add them to the database and the settings list
//				foreach (var setting in missingSettings)
//					AddMetadataSettingToDatabase(brandId, setting, settings);
//			}

            return(settings);
        }
Beispiel #23
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            string email     = GetEmailAddress();
            string password  = PasswordTextBox.Text.Trim();
            bool   saveEmail = RememberMeCheckBox.Checked;

            try
            {
                User user = Data.User.Empty;

#if DEBUG
                if (Request.IsLocal && password == "!!!")
                {
                    user = Data.User.GetByEmail(email);
                    LoginManager.UpdateLastLoginAuditInfo(user);
                }

                if (Request.IsLocal && password == "~!!!")
                {
                    user = Data.User.GetByEmail(email);
                    throw new PasswordExpiredException("Debug login - password has expired", user);
                }
#endif

                if (user.IsNull)
                {
                    user = LoginManager.Login(email, password);
                }

#if (!DEBUG)
                Brand brand = WebsiteBrandManager.GetBrand();

                if (!user.CanAccessBrand(brand.BrandId.GetValueOrDefault()))
                {
                    Response.Redirect(brand.WebsiteUrl + "Login.aspx?message=AccessDenied&errorDetail=BrandAccessDenied");
                }
#endif

                CurrentUser = user;

                SetupSessionForCurrentSessionUser();

                SaveEmail(saveEmail, user.Email);

                Redirect();
            }
            catch (UserPendingEmailConfirmationException ex)
            {
                MessageLabel1.SetErrorMessage(ex.Message, "An email message has been sent to you containing a link to confirm your email address.  If you do not receive this email message or continue to have problems logging in, please contact your systems administrator for further assistance.");
                UserManager.FireUserCreateEvent(ex.Entity);
            }
            catch (LoginException ex)
            {
                MessageLabel1.SetErrorMessage(ex.Message);
            }
            catch (LoginSecurityException ex)
            {
                MessageLabel1.SetErrorMessage(ex.Message, "Please contact your Systems Administrator for further information.");

                if (ex.NotifyAdmins)
                {
                    NotifyEngine.InvalidLoginAttempt(ex);
                }
            }
            catch (AccountExpiredException ex)
            {
                MessageLabel1.SetErrorMessage("Your account has expired", "An email message has been sent to you containing a link to reactivate your account. If you do not receive this email message or continue to have problems logging in, please contact your systems administrator for further assistance.");
                NotifyEngine.SendReactivateAccountMessage(ex.Entity);
            }
            catch (PasswordExpiredException ex)
            {
                Context.Items.Add("User", ex.Entity);
                Server.Transfer("~/ChangePassword.aspx", false);
            }
        }
Beispiel #24
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            Brand brand = Brand.Empty;

            if (WebUtils.GetIntRequestParam("BrandId", 0) != 0)
            {
                brand = Brand.Get(WebUtils.GetIntRequestParam("BrandId", 0));
            }

            if (brand.IsNull)
            {
                brand = Brand.New();
            }

            brand.Name                         = FullBrandNameTextBox.Text.Trim();
            brand.ShortName                    = ShortBrandNameTextBox.Text.Trim();
            brand.ApplicationName              = ApplicationNameTextBox.Text.Trim();
            brand.OrganisationName             = OrganisationNameTextBox.Text.Trim();
            brand.WebsiteUrl                   = WebsiteUrlTextBox.Text.Trim();
            brand.EmailFrom                    = EmailFromTextBox.Text.Trim();
            brand.IsBrandSelectionAllowed      = AllowBrandSelectionDuringRegistrationCheckBox.Checked;
            brand.DisablePoweredByLogo         = (DisabledPoweredByFooterCheckBox != null) ? DisabledPoweredByFooterCheckBox.Checked : false;
            brand.LoginPageUpperCopy           = LoginPageUpperCopyTextBox.Text.Trim();
            brand.LoginPageLowerCopy           = LoginPageLowerCopyTextBox.Text.Trim();
            brand.DefaultUsageRestrictionsCopy = DefaultUsageRestrictionsCopyTextBox.Text.Trim();
            brand.MyAccountCopy                = MyAccountCopyTextBox.Text.Trim();
            brand.AdminCopy                    = AdminCopyTextBox.Text.Trim();
            brand.TermsConditionsCopy          = TermsConditionsCopyTextBox.Text.Trim();
            brand.PrivacyPolicyCopy            = PrivacyPolicyCopyTextBox.Text.Trim();
            brand.DirectDownloadEnabled        = EnableDirectDownloadCheckBox.Checked;

            BinaryFile filePack       = new BinaryFile(BrandFilePackUpload.PostedFile);
            BinaryFile watermarkImage = new BinaryFile(PreviewWatermarkImageUpload.PostedFile);

            try
            {
                if (!IsBrandFolderWriteable())
                {
                    MessageLabel1.SetErrorMessage("Error saving brand", "Brand folder not writeable - please change the permissions in the brands folder");
                    return;
                }

                // Temp flag to check if brand is new
                // Do not inline. This will be cleared when brand is saved.
                bool isNew = brand.IsNew;

                // Validate and save the brand info to the database
                BrandManager.Save(brand, filePack, watermarkImage);

                // Update log
                AuditUserAction action = (isNew) ? AuditUserAction.AddBrand : AuditUserAction.ModifyBrand;
                AuditLogManager.LogUserAction(CurrentUser, action, string.Format("Saved brand: {0}. Brand ID: {1}", brand.Name, brand.BrandId));

                // Get the relative brand folder
                string brandFolderPath = string.Format("~/Brands/Brand_{0}/", brand.BrandId);

                // Convert brand folder to absolute path
                string absBrandFolderPath = Server.MapPath(brandFolderPath);

                // Create the brand folder if it doesn't exist
                if (!Directory.Exists(absBrandFolderPath))
                {
                    Directory.CreateDirectory(absBrandFolderPath);
                    m_Logger.DebugFormat("Created brand folder path: {0}", absBrandFolderPath);
                }

                // Ensure specific brand folder is writeable
                string tmpPath = Path.Combine(absBrandFolderPath, Guid.NewGuid() + ".tmp");

                try
                {
                    File.WriteAllText(tmpPath, "Folder is writeable");
                    File.Delete(tmpPath);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error checking if brand folder is writeable: " + ex.Message);
                    MessageLabel1.SetErrorMessage(string.Format("Brand folder not writeable (~/Brands/Brand_{0}/) - please change the permissions in the brands folder", brand.BrandId));
                    return;
                }

                // Save watermark
                if (!watermarkImage.IsEmpty)
                {
                    // Get any old watermark files
                    var files = (from f in Directory.GetFiles(absBrandFolderPath)
                                 where (Path.GetFileName(f) ?? string.Empty).ToLower().StartsWith("watermark")
                                 select f);

                    // Delete them
                    foreach (string file in files)
                    {
                        File.Delete(file);
                    }

                    // Save new watermark
                    string watermarkPath = Path.Combine(absBrandFolderPath, "watermark." + watermarkImage.FileExtension);
                    watermarkImage.SaveAs(watermarkPath);
                }

                if (!filePack.IsEmpty)
                {
                    // Save the zip file to disk
                    string tempZipPath = Path.GetTempFileName() + ".zip";
                    filePack.SaveAs(tempZipPath);

                    // Extract the uploaded zip into the brand folder
                    FastZip fz = new FastZip();
                    fz.ExtractZip(tempZipPath, absBrandFolderPath, FastZip.Overwrite.Always, null, string.Empty, string.Empty, true);

                    // Delete the temp zip file
                    File.Delete(tempZipPath);
                }

                if (filePack.IsEmpty && isNew)
                {
                    Brand  masterBrand       = WebsiteBrandManager.GetMasterBrand();
                    string masterBrandFolder = Server.MapPath(string.Format("~/Brands/Brand_{0}/", masterBrand.BrandId));

                    try
                    {
                        CopyFolder(masterBrandFolder, absBrandFolderPath);
                        m_Logger.DebugFormat("Copied folder {0} to {1}", masterBrandFolder, absBrandFolderPath);
                    }
                    catch (Exception ex)
                    {
                        m_Logger.Error(string.Format("Error copying Brand folder from master brand to new brand: {0}. Error: {1}", brand.Name, ex.Message), ex);
                    }
                }

                Response.Redirect("ManageBrands.aspx?message=BrandSaved", false);
            }
            catch (InvalidBrandException ibex)
            {
                MessageLabel1.SetErrorMessage("Error saving brand", ibex.Errors);
            }
            catch (Exception ex)
            {
                MessageLabel1.SetErrorMessage("An unknown error occurred while saving brand", ex.Message);
                m_Logger.ErrorFormat("Error saving brand: " + ex.Message, ex);
                ExceptionHandler.HandleException(ex, "Error saving brand");
            }
        }