Tuesday, September 13, 2011

How to create custom permissions for sub sites in Foundation

In SharePoint foundation I came across a new feature or I should say a variation from the earlier versions of the  SharePoint. So below is the description -

I created a new Site collection. Then I created a few subsite. Now the requirement was this - I had to create a few custom permission level for the subsite- lets say "subs".

Now the problem begins , i tried to navigate to the site permissions, then permission level and the boom - no where to find add permission level. Then i tried to find it on other sub sites. No luck. Finally i went back to the site collection. And yes , there it is- "Add Permission Level".

What i came to know from some R&D that , even if we create a new sub site with unique permissions, the site inherits the permission levels. What benefit we achieved from this - yes a great one !! a custom permission levels are at one place. We dont have to hunt all the 100s of subsites when we need to see particular permission level. Also it is reusable.

So process to create a custom permission level for a subsite -

1. You should have "Manage Permission" permission to do this.
2. Go to the site collection.
3. Click on the Site Actions -Site Setting
4. Then click permission levels
5. Then click onn add permission level
6. Name the permission and add the permission as per the requirement and save it.
7. Now go to your sub site- SUBS
8. Click on the Site Actions -Site Setting
9. Create new group - grant the permission level you created in step 6 and save.
10. Now you have a group with custom permissions. Add users to it.

The best part is - i dont have to create this custom permission again & again for seperate sub sites  without inheriting the parents permission.

Sunday, September 11, 2011

How to filter search results in SharePoint Foundation

I have been working on this for past few days. Actually I wanted to filter all my serach results as i dont want to show people content of my lists. So heres what i did to achieve it -

1. Created a new scope in my site collection.
2. Add rules to the scope to include and exculde content from your site. Here i tried to include all the site pages but excluded the default sharepoint forms like allitems.aspx , etc.

3. Now save this scope.

4. Now it will prompt that the scope will take 14 minutes. You may choose to restart it immediately with Central Administration.
 Go to Central Administration-> Search Service Application-> Search Admin istration and then on "Scopes needing update" click on update now

5. Now go back to your site -open sharepoint designer and create a new page. You may name it as searchresults.aspx. Now  insert a Search Core Result box. Now right click on the webpart and click on webpart properties.

6. Here the trick begin - expand "result query option". Under append the text to query type Scope="QA Portal"  as in my case the name of the scope is QA Portal.


7. Now you can place a search box on any page in your site and link it to the searchresult.aspx page. This will display all your search results.

It worked for me, i hope it will work for you too.

Cheers !!


Tuesday, September 6, 2011

How to remove users from SharePoint groups through code

 

You can create a variable to store the current user(who created) the survey item.

then create a method 

 
public void removeuser(string groupName, string userLoginName)
{
string strUrl = "http://mysite:5050/";
using (SPSite site = new SPSite(strUrl))
{
using (SPWeb web = site.OpenWeb())
{
try
{
web.AllowUnsafeUpdates = true;
SPUser spUser = web.AllUsers[userLoginName];
{
SPGroup spGroup = web.Groups[groupName];
if (spGroup != null)
spGroup.RemoveUser(spUser);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
web.AllowUnsafeUpdates = false;
}
}
}
}



 




call this method and pass the group name & "variable" created earlier.

Note :Replace "http://mysite:5050/" with your site URL

How to change the font on a SharePoint site

Method 1 

Using IE open the Developer Tool (F12) > Cick  Find, Element by Click > then CSS, then click on the element you want to change the Developer Toolbar will tell you the Div or Tag that is being used to Style the Font your talking about.  Then use Heather Solomons Chart of CSS Elementshttp://www.heathersolomon.com/content/sp07cssreference.htm. Heather lists the Style Sheet being used and the line # of the Tag or Div with an image so you can easily see what you need to modify.


Method 2



you can create a new theme all together and deploy it.
Creating themes is an easy method -

To create a new theme

  1. Start Microsoft Word 2010.
  2. In the Ribbon, click the Page Layout tab.
  3. In the Themes group, display the Colors menu. Choose Create New Theme Colors. Choose the colors you want to use for the new theme. Provide a name, and then click Save.
  4. In the Themes group, display the Fonts menu. Choose Create New Theme Fonts. Choose the fonts that you want to use for the new theme. Provide a name, and then click Save.
  5. In the Themes group, display the Themes menu. Choose Save Current Theme.
  6. In the Save Current Theme dialog box, supply a name for the new theme. Pick a convenient location for the .thmx file, such as the Desktop, and then click Save.
After the .thmx file has been created, you can import it into the SharePoint installation.

To import a theme

  1. In Enterprise Portal, browse to the main Enterprise Portal site.
  2. In the Site Actions menu, click Site Settings.
  3. In the Galleries group, click Themes.
  4. In the Ribbon, display the Documents tab.
  5. In the New group, click Upload Document.
  6. Click Browse. Select the .thmx file that you created, and then click Open.
  7. Click OK to upload the new theme.
  8. Verify the name for the theme. You can also provide a description of the new theme. Click Save.