A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Monday, August 1, 2005

SPS 2003: Use FrontPage Themes in SharePoint Sites

You may have applied themes to the SharePoint sites before. It is important because you can give a different look and feel to the sites belonging to different departments. Some groups of users like colorful sites. SharePoint contains a list of excellent themes that one can use but did you know that you can use FrontPage themes in SharePoint sites? FrontPage has an excellent collection of themes and you can use those themes for your SharePoint sites.


1. Open your SharaPoint site in FrontPage.


2. Select Format > Theme.


3. Select a theme from the collection (Click the down arrow to see options).


4. From the context menu, select "Apply as default theme".


5. A warning message will be displayed, click "Yes".


6. Check your site in browser.


-SSA

Thursday, June 16, 2005

SharePoint Server 2007 - Some Features

I attended "How Microsoft IT Plans SharePoint Capacity and Growth" Technet Webcast today. Following are some new features in SharePoint Server 2007 (taken from the webcast):

1. Infrastructure consolidation
> Co-hosting corporate and HostHeader mode sites in the same farm.
> Portals become site collections (fewer databases)
> No small/medium/large farm topology requirements

2. Full fidelity data protection
> Items, lists -> Recycle bin out of the box
> Webs, Sites -> Events that fire before the fact (SPEventReceivers)
> Benefit: Fewer database restores -> larger databases

3. Search
> Windows SharePoint Services: No SQL full-text search
> Common Office Server 2007/Windows SharePoint Services Search Engine

4. Life Cycle Management
> Site collection owner updatable by user
> Enable confirmation and auto deletion

4. Built-in page re-ghosting
> Fixes broken pages

5. Indexes on list columns

-SSA

Friday, April 1, 2005

SPS 2003: CheckRights(sitename, username) function checks user permissions in a site

Following is the code to check the rights of the users. Following code will show only those sites for which user has at least "Reader" rights.

Function CheckRights(ByVal sitePath As String, Byval strUser as string) As Boolean


//sitePath contains the site that you retrieved in the code shown above


// strUser contains the user for whom you want to check the rights and retrieve sites


Try
Dim blnStatus As Boolean = False
If Not sitePath Is Nothing Or Not sitePath = "" Then


Dim rtn As String() = parseURL(sitePath)


Dim siteCollection As SPSite
siteCollection = New SPSite(sitePath)
Dim site As SPWeb = siteCollection.OpenWeb(rtn(0))


Dim allUsers As SPUserCollection = site.Users
Dim user As SPUser


For Each user In allUsers
If user.LoginName.ToUpper = strUser Then


Dim allGroups As SPRoleCollection = user.Roles
Dim group As SPRole


For Each group In allGroups


Dim right As Integer
right = group.PermissionMask And SPRights.ViewListItems


If right = SPRights.ViewListItems Then


blnStatus = True
Return blnStatus
Exit Function


End If
Next


End If
Next


Return blnStatus


End If


Catch ex As Exception
//Exception handling code here!
End Try


End Function


The function shown above (CheckRights) uses another function called as parseURL(). Following is the code for the parseURL() function:


Public Function parseURL(ByVal _fullPath As String) As String()


_fullPath = System.Web.HttpUtility.UrlDecode(_fullPath)


Dim site As SPSite = New SPSite(_fullPath)


Dim web As SPWeb = site.RootWeb


Dim webPath As String = _fullPath.Replace(web.Url & "/", "")


Dim rtnObject As String() = {"", "", ""}


Dim w As SPWeb


Dim folderPath As String = ""


Dim docLibPath As String = ""


Dim i, j As Integer


While CType(w, Object) Is Nothing


Try


w = site.OpenWeb(webPath)


Dim s As String = w.ID.ToString


'//above will raise the exception too


Catch ex As Exception


w = Nothing


i = webPath.LastIndexOf("/")


If i = -1 Then


Exit While '//means the end of subsite lookup


End If


j = webPath.Length


webPath = webPath.Remove(i, j – i)


End Try


End While


'//if there was some sub-site object then


If Not CType(w, Object) Is Nothing Then


folderPath = _fullPath.Substring(_fullPath.IndexOf(webPath) + webPath.Length + 1)


If folderPath.IndexOf("/") > 0 Then


docLibPath = folderPath.Substring(0, folderPath.IndexOf("/"))


folderPath = folderPath.Remove(0, folderPath.IndexOf("/") + 1)


End If


If docLibPath = webPath Then webPath = "" '_fullPath


rtnObject(0) = webPath


rtnObject(1) = docLibPath


rtnObject(2) = folderPath


Else '//there was no sub-site obect was found


folderPath = _fullPath.Substring(_fullPath.IndexOf(webPath))


If folderPath.IndexOf("/") > 0 Then


docLibPath = folderPath.Substring(0, folderPath.IndexOf("/"))


folderPath = folderPath.Remove(0, folderPath.IndexOf("/") + 1)


End If


If docLibPath = webPath Then webPath = "" '_fullPath


rtnObject(0) = webPath


rtnObject(1) = docLibPath


rtnObject(2) = folderPath


End If


Return rtnObject


End Function

—————-

This code will look complex but it is easy to use. Just supply the arguments and get the results. I could have created a web part as well but i have published the code so that max. number of users can take advantage. Of course, you can create a web part as well.

Regards,

-SSA

Monday, January 3, 2005

Sending Email From InfoPath Using Managed Code

It is possible to send an email from InfoPath when a form is submitted. Just add a new data connection and select "Email message" as your data submission method. You can also send email from InfoPath using managed code. You must have InfoPath toolkit installed on your machine in order to write managed code for InfoPath forms.

Ref: /ssa/archive/2006/05/01/6186.aspx

Direct link to download toolkit: http://www.microsoft.com/downloads/details.aspx?familyid=7E9EBC57-E115-4CAC-9986-A712E22879BB&displaylang=en

1. Open your form in design mode and add a button to it.
2. Double click the button and select "Edit Form Code..." from the dialog box that pops up. This will open a Visual Studio editor. Add following code in button's OnClick() event:
[InfoPathEventHandler(MatchPath="CTRL1_1", EventType=InfoPathEventType.OnClick)]
public void CTRL1_1_OnClick(DocActionEvent e)

{
MailMessage MailMsg = new MailMessage();
MailMsg.Body = "This is a test message and currently logged in user is " + System.Environment.UserName;
MailMsg.From = "share.point@yahoo.com";
MailMsg.To = "user@sharepoint.com";
MailMsg.Subject = "InfoPath Test Message";
SmtpMail.SmtpServer = "smtp.yourdomain.com";
SmtpMail.Send(MailMsg);
}

Don't forget to add System.Web.Mail namespace in your code. Add following line in the start of the page:
using System.Web;
using System.Web.Mail;
Hint: Many people complain that they can not add System.Web.Mail to the code. You must add this library in the references before you can use it in your code.
1. Right click "References" in solution explorer and select "Add Reference".
2. Select "System.Web.dll" (.NET Pane) and click OK.

-SSA