diff --git a/Common/Enums/DocumentType.cs b/Common/Enums/DocumentType.cs index 03369727..ce34d3f4 100644 --- a/Common/Enums/DocumentType.cs +++ b/Common/Enums/DocumentType.cs @@ -47,6 +47,16 @@ namespace Swarmops.Common.Enums /// /// Photo documenting an external activity /// - ExternalActivityPhoto + ExternalActivityPhoto, + + /// + /// Organization logotype (public) + /// + Logo, + + /// + /// Other artwork (public) + /// + Artwork } } \ No newline at end of file diff --git a/Common/Enums/ObjectOptionalDataType.cs b/Common/Enums/ObjectOptionalDataType.cs index b3e48457..d95d224a 100644 --- a/Common/Enums/ObjectOptionalDataType.cs +++ b/Common/Enums/ObjectOptionalDataType.cs @@ -406,6 +406,16 @@ namespace Swarmops.Common.Enums /// /// If nonpresentation currency, which currency was used (Int64 cents). /// - NativeCurrencyAmountCents + NativeCurrencyAmountCents, + + /// + /// Document identity of an organization's 16x9 landscape logo. + /// + OrgLogoLandscape, + + /// + /// Document identity of an organization's square logo - also usable for circle-type avatars + /// + OrgLogoSquare } } \ No newline at end of file diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index b4f28cdd..55caddc6 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -1060,5 +1060,23 @@ namespace Swarmops.Logic.Structure this.FinancialAccounts.AssetsVatInbound.Active); } } + + public Document LogoLandscape + { + get + { + int docId = OptionalData.GetOptionalDataInt(ObjectOptionalDataType.OrgLogoLandscape); + if (docId > 0) + { + return Document.FromIdentity(docId); + } + + return null; + } + set + { + OptionalData.SetOptionalDataInt(ObjectOptionalDataType.OrgLogoLandscape, value.Identity); + } + } } } \ No newline at end of file diff --git a/Logic/Support/Document.cs b/Logic/Support/Document.cs index b92b5c5b..ea48667c 100644 --- a/Logic/Support/Document.cs +++ b/Logic/Support/Document.cs @@ -151,6 +151,14 @@ namespace Swarmops.Logic.Support .SetDocumentForeignObject (Identity, GetDocumentTypeForObject (foreignObject), foreignObject.Identity); } + public void SetDocumentTypeDirect(DocumentType docType, IHasIdentity foreignObject) + { + // Overrides the standard checks -- used for organization-level documents of many types + SwarmDb.GetDatabaseForWriting() + .SetDocumentForeignObject(this.Identity, docType, foreignObject.Identity); + } + + public void Delete() { // Unlink, actually diff --git a/Site/Automation/OrgFunctions.aspx b/Site/Automation/OrgFunctions.aspx new file mode 100644 index 00000000..19846206 --- /dev/null +++ b/Site/Automation/OrgFunctions.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrgFunctions.aspx.cs" Inherits="Swarmops.Frontend.Automation.OrgFunctions" %> diff --git a/Site/Automation/OrgFunctions.aspx.cs b/Site/Automation/OrgFunctions.aspx.cs new file mode 100644 index 00000000..37c15948 --- /dev/null +++ b/Site/Automation/OrgFunctions.aspx.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Services; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Common.Enums; +using Swarmops.Logic.Support; + +namespace Swarmops.Frontend.Automation +{ + public partial class OrgFunctions : DataV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + + [WebMethod] + static AjaxInputCallResult AdminUploads(string guid, string cookie) + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + Documents newDocuments = Documents.RecentFromDescription(guid); + if (newDocuments.Count < 1) + { + throw new ArgumentException( + "No docs found in /Automation/OrgFunctions.aspx/AdminUploads using supplied GUID (" + guid + ")"); + + } + + switch (cookie) + { + case "LogoLandscape": + if (newDocuments.Count > 1) + { + throw new ArgumentException("More than one doc matches"); + } + + newDocuments[0].SetDocumentTypeDirect(DocumentType.Logo, authData.CurrentOrganization); + authData.CurrentOrganization.LogoLandscape = newDocuments[0]; + + return new AjaxInputCallResult { Success = true, ObjectIdentity = newDocuments[0].Identity }; + + default: + throw new ArgumentException("Unimplemented cookie -- '" + cookie + + "' -- in /Automation/OrgFunctions.aspx/AdminUploads"); + } + } + } +} \ No newline at end of file diff --git a/Site/Automation/OrgFunctions.aspx.designer.cs b/Site/Automation/OrgFunctions.aspx.designer.cs new file mode 100644 index 00000000..1f54836f --- /dev/null +++ b/Site/Automation/OrgFunctions.aspx.designer.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Frontend.Automation { + + + public partial class OrgFunctions { + } +} diff --git a/Site/Controls/v5/Base/FileUpload.ascx b/Site/Controls/v5/Base/FileUpload.ascx index a58898fc..dc387ba0 100644 --- a/Site/Controls/v5/Base/FileUpload.ascx +++ b/Site/Controls/v5/Base/FileUpload.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="FileUpload.ascx.cs" Inherits="Swarmops.Controls.Base.FileUpload" %> +<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="FileUpload.ascx.cs" CodeFile="FileUpload.ascx.cs" Inherits="Swarmops.Controls.Base.FileUpload" %> <%@ Import Namespace="System.Net" %> diff --git a/Site/Pages/v5/Admin/OrgSettings.aspx b/Site/Pages/v5/Admin/OrgSettings.aspx index 70e05546..900b88be 100644 --- a/Site/Pages/v5/Admin/OrgSettings.aspx +++ b/Site/Pages/v5/Admin/OrgSettings.aspx @@ -97,6 +97,30 @@ } } + function onFileUploaded(guid, cookie) { + var jsonData = {}; + jsonData.guid = guid; + jsonData.cookie = cookie; + + alertify.success("onFileUploaded"); + + SwarmopsJS.ajaxCall( + '/Automation/OrgFunctions.aspx/AdminUploads', + jsonData, + function(data) { + if (data.Success) { + // Some special cases + if (cookie == "LogoLandscape") { + // Replace the main sidebar logo + $('img#ctl00_ImageLogo').attr("src", "/Pages/v5/Support/StreamUpload.aspx?DocId=" + data.DocumentId); + } + } else { + alertify.error("The server says the file was not accepted. Try again?"); + } + }); + + } +