Now I'll create a merge between that and sending the Recycle Bin icon (with link) to the Site Actions drop down menu.
To achieve this I created a SP Feature called HideRecycleBin in order to have the chance to enable/dissable it depending on Sites/Subsites:
Feature.xml
Elements.xml
HideRecycleBin.css
HideRecycleBinReceiver.cs
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Diagnostics;
using System.IO;
namespace CustomFeatures.HideRecycleBin
{
class HideRecycleBinReceiver : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
try
{
SPWeb web = (SPWeb)properties.Feature.Parent;
SPFile coreFile = web.Folders["Shared Resources"].Files["custom.css"];
coreFile.CopyTo("Shared Resources/customCSS-archive-HideRecycleBin.css", false);
SPFile customFile = web.Folders["Shared Resources"].Files["HideRecycleBin.css"];
customFile.CopyTo("Shared Resources/custom.css", true);
}
catch (SPException x)
{
logMessage(x.Message, EventLogEntryType.Error);
}
catch (Exception x)
{
logMessage(x.Message, EventLogEntryType.Error);
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
try
{
SPWeb web = (SPWeb)properties.Feature.Parent;
SPFile customFile = web.Folders["Shared Resources"].Files["customCSS-archive-HideRecycleBin.css"];
customFile.CopyTo("Shared Resources/custom.css", true);
SPFile HideRecycleFile = web.Folders["Shared Resources"].Files["HideRecycleBin.css"];
customFile.Delete();
HideRecycleFile.Delete();
}
catch (SPException x)
{
logMessage(x.Message, EventLogEntryType.Error);
}
catch (Exception x)
{
logMessage(x.Message, EventLogEntryType.Error);
}
}
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
logMessage("View Hide Recycle Bin Site Action feature installed", EventLogEntryType.SuccessAudit);
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
logMessage("View Hide Recycle Bin Site Action uninstalling", EventLogEntryType.Information);
}
private void logMessage(string message, EventLogEntryType type)
{
if (!EventLog.SourceExists("SharePoint"))
EventLog.CreateEventSource("SharePoint", "Application");
EventLog.WriteEntry("SharePoint", message, type);
}
}
}
Manifest.xml
No comments:
Post a Comment