Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Just a quick question, is there any chance, how to get list of users, which rates items in one list, or documents in one library ? Maybe I only overlook something really obvious...

Thank you

share|improve this question
add comment

2 Answers

You can write a powershell with foreach for a site collection or a web and get a output text file.

# get the site collection
$s = get-spsite http://siteurl 

# loop through all site in the site collection, 
# then through all lists / libraries in that site (filtering out everything but actual doc libs 
# (The catalog filter excludes all sharepoint libs like the masterpage catalog etc.
// for each list, add a folder called test to the rootfolder
$s.AllWebs | Foreach-Object { 
  $_.Lists | Where { ($_.BaseType -eq "DocumentLibrary") -and ($_.BaseTemplate -notmatch "Catalog") } | Foreach-Object {
    # Do your code here and if u need to include basetype do so
    # 
  }
}
share|improve this answer
    
Thank you very much Ken! Can you write me the BaseType and Template for lists please? I'm not able to get list of users for list objects. –  Molik Jul 2 '12 at 11:19
add comment

SocialRatingManager.GetRatings can give you all Ratings for an Url or for a User.
See MSDN article How to: Create and Retrieve a Social Rating for more info for more info on how to work with ratings programatically

To get all ratings for a single library you can use code like this:

using System;
using Microsoft.Office.Server.SocialData;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

namespace SharePointConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var url = "http://sp2010/TestDocs";
            using (var site = new SPSite(url))
            {
                var sc = SPServiceContext.GetContext(site);
                var sm = new SocialRatingManager(sc);
                using (var web = site.OpenWeb())
                {
                    var list = web.GetList(url);
                    foreach (SPListItem item in list.Items)
                    {
                        foreach (var rating in sm.GetRatings(new Uri(SPUrlUtility.CombineUrl(site.MakeFullUrl(web.ServerRelativeUrl), item.Url))))
                        {
                            Console.WriteLine("{0} rated {1} to {2}", rating.Owner.DisplayName, rating.Url, rating.Rating);
                        }
                    }
                }
            }
        }
    }
}
share|improve this answer
    
how can i convert it to web part for appear in dashboards? –  saber tabatabaee yazdi Jul 29 '13 at 11:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.