Sebastian,
This script works fine for setting up our skin object logo in the upper left as shown but does not change the Favicon unless we manually upload it. All that has to happen for the upper left logo is to copy the image to the child portal root and use the script below to set the files / folders tables. Refresh the site and the logo is there.
Thus, for the upper left logo, just using System.File.IO methods to copy it and running the script with the right portal id values, etc. fixes this logo programmatically.
The same script applied to the Fav Icon doesn't work. Comparing the Fav Icon Files/Folders entry after the script is run to the same entry that gets updated if Site Settings API is used, there's no difference in the records in the Files and Folders tables. I ran the script for the favicon, then copied with headers to an Excel file. Then did the Site Settings API upload and inserted this below the record already in the Excel file.
The only thing I can think of is the local cache is not cleared unless the API is used. So even though the Files / Folders is right for the favicon with the script, it's persisted locally until the Site Settings API is used and then the cache is cleared.
If I'm missing something in my script let me know.
Here is the script:
-- DROP TABLE ##TEMPFILES
DECLARE @PORTALID INT
DECLARE @FILENAME VARCHAR(100)
SET @PORTALID = 3
--SET @FILENAME = 'purpleOnlyFlavicon.ico' -- for the favicon, our skins guy named it "flavi" probabaly for Flava Flav, a rapper
SET @FILENAME = 'ABFR_none_horizontal.png' -- for the upper left logo
SELECT *
INTO ##TEMPFILES
FROM dbo.Files
WHERE Portalid = 0
AND FileName LIKE '%' + @FILENAME
AND CreatedByUserID = 1
--SELECT * FROM ##TEMPFILES
UPDATE ##TEMPFILES SET PORTALID = @PORTALID
INSERT INTO DBO.FILES
(
[PortalId]
,[FileName]
,[Extension]
,[Size]
,[Width]
,[Height]
,[ContentType]
,[FolderID]
,[Content]
,[CreatedByUserID]
,[CreatedOnDate]
,[LastModifiedByUserID]
,[LastModifiedOnDate]
,[UniqueId]
,[VersionGuid]
,[SHA1Hash]
,[LastModificationTime]
,[Title]
,[StartDate]
,[EnablePublishPeriod]
,[EndDate]
,[PublishedVersion]
,[ContentItemID]
)
SELECT
PORTALID
, FILENAME
, Extension
, SIZE
, Width
, Height
, ContentType
, (SELECT folderid FROM dbo.Folders WHERE PortalId = @PORTALID AND FOLDERPATH LIKE '') AS FolderId
, Content
, 1 -- createdy by user
, GETDATE() -- created on date, take default
, 1 -- last modified by user
, GETDATE()-- last modified on date take default
, NEWID()-- unique id take default
, NEWID()-- version guid take default
, SHA1Hash-- SHA1Hash take default
, GETDATE()-- last modification time take default
--, '' AS FOLDER (THIS COMPUTED)
, Title
, GETDATE() AS StartDate
, EnablePublishPeriod
, EndDate
, PublishedVersion
, ContentItemID
FROM ##TEMPFILES
--SELECT * FROM DBO.FILES WHERE FILENAME LIKE '%' + 'purpleOnlyFlavicon.ico'