Showing posts with label Custom. Show all posts
Showing posts with label Custom. Show all posts

Monday, October 27, 2008

Adding the Recycle Bin to "Site Actions"

In a previous post I pointed on how to hide the recycle bin icon from the SharePoint site web page.

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



Hidding the Recycle Bin in SharePoint

Working on customizing SharePoint lately? Needed to remove the recycle bin?

You just need to copy this code snippet into the .css that the web page is using:

#ctl00_PlaceHolderLeftNavBar_idNavLinkRecycleBin
{
Visibility:hidden;
}

and voilá, the recycle bin is not there anymore.

In a next post I'll explain how to create the Recycle Bin link in the "Site Actions" drop down list.

Monday, March 17, 2008

Assign Work Item to multiple TFS Users part. I

It is possible to assign an existent work item to multiple TFS users.

In this case I'm going to explain how to assign an existent work item to multiple TFS users but keep in mind that you can also create a new work item from scratch to accomplish this.

For this example we're going to use the following variables:

TFSServer: http://tfsserver:8080/
ProjectName: ProjectMX
WorkItem: task (to customize)

How to do it:

1- Create a i.e. MX_Group within the TFS project.
2- Add users to MX_Group group
3- Customize the task Work Item:

- Using the VS 2005 Command Prompt export the task Work Item :
witexport /f OutputXMLDef /t TFSServer /p ProjectName /n WorkItem

witexport /f "D:\Temp\Task.xml" /t "http://tfsserver:8080/" /p "ProjectMX" /n task

- Change the following in the exported Work Item definition:
















- Save the definition and import it back into TFS :
witimport /f XMLDef /t TFSServer /p ProjectName

witimport /f "D:\Temp\Task.xml" /t "http://tfsserver:8080/" /p "ProjectMX"

4- After restarting Visual Studio 2005 you should be able to assign tasks to MX_Group.