SharePoint - Obtaining all files from a web - sharepoint

I have a requirement wherein I have to obtain all the files of a web recursively (i.e. traversing through the folders and sub folders) and display them for the user through SP Object Model.
This has to be security trimmed, in the sense, if the user doesn't have sufficient privileges to view or open the file, then that file shouldn't be taken into account. Is it possible to obtain all the files without looping through each and every document library, folders and sub folders?
Also, I don't want the default document libraries like web part gallery, master page gallery,etc to be listed out. Any insights on how to achieve this?

The Content Query Web Part can get you most of the way there. Out-of-the-box you could set this up to show all files (based on a content type or content type category) from a site collection. You could even filter to remove system files although that might be a little tricky to get the filters right.
If that doesn't get you far enough, then you could write a web part that extends the Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart class. You could override the Filters (by setting the FilterField1, FilterType1, FilterOperator1, FilterValue1, etc).
The security trimming should happen for you by the default behavior of the ContentQueryWebPart. The Web Part and Master Page galleries will get filtered out based on your content type settings so you shouldn't have to worry about those.

Related

Sharepoint 2010 - Questions regarding basic concepts

I am beginning sharepoint development and have some quick questions concerning basic terms.
How do i find out whether a particular site is a site collection, or a site JUST BY THE URL? Is their a powershell command to do this?
I was creating some sites in sharepoint. Some sites were appended with /sites/sitename whereas others were just under the base url of sharepoint. What is the difference between the 2? AND, how do i recreate the ones under the sites node? For some reason, I cant find the option to create under the sites node again. Please explain this concept as all msdn tutorial are very confusion for beginners like me. Those are good once you get the hang of basics.
Please provide an analogy how to understand web app, site collection, site, web site, etc.
Is there a way to use NEWFORM.aspx for a document library instead of UPLOAD.aspx?
The Site collection is at the root level of your Web application.
So http://abc.com/ => Site collection
Using Powershell, open the Sharepoint Powershell prompt and run Get-SPSite to get all Site-Collections
the /sites/ is called as a managed path
It can be defined in the Central Administration for every web application.
The option to select the /sites will be available only when you create the second site collection under the Web Application (The first one take the / by default.)
Have a look at Technet Article
document library is for uploading file, not for storing user submitted data, for that you need to create a list
1) Document Set is used in cases where multiple documents have the same properties, its like putting all these documents in a folder and then providing attributes to that folder which are in turn applied for each document in that folder.
In your case, if all the files have the same values for the 8 fields then the document set is the correct way to go.
2)If there is additional metadata associated with the files then these can be added either to the content type (eg. document or document set content type) or to the columns in the library itself, you dont need to create a separate list for holding that data. Adding data to the content type ensures consistency across all the document libraries within that site collection, adding columns to the library affects only that library.

Display document only to user who uploaded it in sharepoint

I have a specific requirement where-in I want only the uploader of the document and a specific team to be able to view it in list / library. 1) is it possible? 2) If yes, how...?
Ok. So I was able to resolve my issue with the steps mentioned below. Soon will be documenting it in form of a blog and share it:
Created the document library and modified the default view to only show documents that were created by/modified by [Me].
Added a new web page to the library and gave exclusive rights to access that to a certain set of users.
Restricted all users from creating a view with the help of creating special permission level where user only had access to upload or delete a document but not creating/updating/deleting lists/views. Also disabled private view creation.
Hope this may be helpful to others too who are looking for restricted views / disabling view creation.
You need to set item level permission through event handler:
http://www.chakkaradeep.com/post/SharePoint-ndash3b-Setting-Item-level-permission.aspx
http://msdnvietnam.net/blogs/quang/archive/2009/07/02/sharepoint-eventhandler-set-item-level-permission.aspx
#Ashish, in SharePoint 2007 GUI you cannot make a query that will show documents that belongs to a specific group, however CAML specification supports it (Membership tag), it wasn't documented until SP2010, but it works on SP2007 (i'm using it)
However this involves custom coding and this doesn't assign permissions automatically, it just enables you to filter documents by groups.
For a solution without custom coding you could consider making a seperate folder/list for every person/group and set permissions to folder/list accordingly. This will also help performance - it's better to have permissions set on high-level container than having fine grained permissions (i'm just assuming that, because i read everywhere that mass fine-grained permissions are bad for performance)
You may use current user filter web part to filter the document by whom logged in into the sharepoint site by passing the value Dispaly Name

Changing the source of a Sharepoint List View

Effectively I am looking to change the viewed Document Library within an exsisting List View Web Part from 'Document Library #1' to Document Library #2'. I want to do so without having to re-create the entire web part (e.g. settings & views) as I would have to do this multiple times.
Sharepoint version is 2007 and Sharepoint Designer is not avaliable.
Context: I am currently building a Sharepoint area which will consist of multiple ASPX pages all based off an original layout. This layout includes a List View web part that directly views a Document Library.
Each ASPX page has a Document Library attributed to it (e.g. Page1.aspx and DocLib1), which I wish to display within this List View web part.
Page1.aspx was setup just fine (effectively the original). When setting up Page2.aspx as a direct copy of the first, I am unable to change the List View from DocLib1 to DocLib2 as there seems no option to do so.
The list view web part isn't easily customizable unless you can edit the xml for the web part and change some guids. If you want to be able to change the source list through the browser you will need to use a different web part - the content query web part is an out of box option, though obviously that is quite different from the standard list view.
You may also be able to do something with with list templates - if you can use a custom template instead of the standard document library template, you may be able to alter AllItems.aspx to do what you need.

Is it feasible to programmatically change the name of a directory in SharePoint?

To quickly summarise my question:
Is it feasible to programmatically change the name of a directory (with both files and sub-folders) in SharePoint? I am expecting that users will have files checked out on at least some occasions what I am attempting the rename.
The background:
I am currently contracting for a company that produces web based software (ASP.NET) with a configurable document management system. The system can be configured to use different underlying systems, with the most common environment being SharePoint (WSS 3).
I have been assigned a task to extend what has to now been a fairly simple system (simply output files into a fixed directory structure, occasionally read). Having never worked with SharePoint before I am doing some research on best practices, and am attempting to work out what is viable. At this stage I do not have access to a testing environment myself, so am limited to reading up online.
One request is to have the directory structure reflect the name (as one example) of the current client - so all documentation for a client will be in one place, and can be accessed externally via SharePoint or other compatible applications. The specification cites that if the name of the client changes then the directory structure should immediately update. My concern is that this will either directly cause errors (eg. Permission denied) or indirectly cause errors (loss of work for users who have externally checked out files).
As a follow up question if there are concerns with the above, is there a better way to implement the above? I have looked at suggesting the users use views to access the structure in SharePoint, however there is a concern from our BA that users will not be able to directly upload new files into this structure.
Thanks
The issue with Folders in SharePoint is that they are not really folders in the way you would expect of a file system. All files in a SiteCollection are stored in one big-assed table on the Database (checkout the AllDocs table).
I cannot categorically say it is safe to rename the folder without doing a bit of testing, I know that the folders "name" is not the key to accessing the document, despite it appearing to be based on the Url you see in the browser.
The best bet is to do a quick test, but I am pretty sure that your plan will not be a problem.
The potential issue is if any Content Query Web Parts etc rely on specific folders to exist or if any other "code" or "pages" look for that folder and not the folderId.
Save the content of the list before you "attempt" it in production. You don't want to loose data.
Checked out documents will still work the way you expect them to.
You may however have to run a crawl again.

Search Center on SharePoint Publishing site

Can someone give me some directions on how to setup SharePoint Search Center so I can get results from the list and that they have some custom (modified) link?
I have Forms authentication (and anonymous access) enabled with alternate access mapping.
Right now in the Default zone I get results from the data in lists and they all point to the AllItems.aspx. If try search from the Internet zone I don't get any results from the lists and I am guessing that this is because of some security settings. But if make them to show how will I customize resulting link so that list items are shown with some publishing page.
For example if I keep news in the News list and when I do search I want to get result with link in following format
http://somesite/Pages/News.aspx?itemId=12
where the itemID is he id of the news item.
Can I customize link in the result ?
You can customize the result link using the Core Search Results web part. It is all in the XSL which is available if you modify the shared properties of the web part.
The problem is that this page is meant to show search results of all types including documents in SharePoint, files potentially outside of SharePoint, web pages, business data, etc.
You may want to have a custom search results page that uses a specific scope or managed property query such that you can be sure the results will be list items. This can probably be done without any coding (if you don't consider XSL coding) and you could still use the Core Search Results web part.
Another option may be similar, but use the Data Form/View web part (through SharePoint Designer) or the Content Query Web Part (Publishing Infrastructure feature required).

Resources