Tuesday, January 20, 2009

Image rotator embedding in a content editor webpart.

Place the images in a image library(eg, http://SiteCollName/sites/sitename/doclibname/Image3.JPG")
now, copy paste the below code in the content editor webpart.
<script language="JavaScript">
<!--function adArray()
{for (i=0; i*2<adArray.arguments.length; i++)
{
this[i] = new Object();
this[i].src = adArray.arguments[i*2];
this[i].href = adArray.arguments[i*2+1];}this.length = i;
}

function getAdNum()
{
dat = new Date();
dat = (dat.getTime()+"").charAt(8);
if (dat.length == 1)ad_num = dat%ads.length;
elsead_num = 0;return ad_num;
}
var ads = new adArray("http://google.com/",
"http://SiteCollName/sites/sitename/doclibname/Image2.JPG","http://www.microsoft.com",
"http://SiteCollName/sites/sitename/doclibname/Image3.JPG","http://www.google.com",
"http://SiteCollName/sites/sitename/doclibname/Image4.JPG","http://www.google.com");
var ad_num = getAdNum();
document.write('<div align="center"><A HREF="'+ads[ad_num].href+'" target="_blank"><IMG SRC="'+ads[ad_num].src+'" '+'BORDER=0 name=js_ad></A></div>');
link_num = document.links.length-1;
function rotateSponsor() 
{
  if (document.images) 
  {
   ad_num = (ad_num+1)%ads.length;
   document.js_ad.src = ads[ad_num].src;
   document.links[link_num].href = ads[ad_num].href;
   setTimeout("rotateSponsor()",4000);
}
}
setTimeout("rotateSponsor()",4000);// --></script>



source: http://armsinfragilehands.blogspot.com/2008/10/sharepoint-image-rotator.html

Tuesday, January 13, 2009

change anonymous access settings options disabled

Prob Definition:
Inorder to explain the prob definition, I will walk you through the entire Anonymous access settings froms the scratch.

While setting the Anonymous access to a document library,

  1. You set Anonymous access on the desired IIS website:
    IIS -> Websites -> double click on the desired Website -> Properties -> Directory Security -> check the anonymous access box
  2. You set the anonymous access on the web application level
    SCA -> Application management -> Application Security ->Authentication Providers -> Default -> Check the Anonymous access check box
  3. You set the Anonymous access on the site that you desire
    Site Actions -> Site Settings -> Advanced Permisions -> settings -> Anonymous access
  4. Now when you try to set the Anonymous access on a particular document library/list, you try to go to the document library, -> Settings -> Document library settings -> permissions for this document library -> Settings -> Anonymous access
    You get to see the available option disabled or grayed out.

Reason:

Document library you are trying to set the anonymous access is configured to allow only read access on the doc lib.

Fix:

Trick is with the Advanced settings.

Document library -> Settings -> Doc lib settings -> Adv settings -> Item-level Permissions -> Read Access -> All responses.

Note: Edit Access can be set any thing.
Show results can be set any thing

Sunday, January 4, 2009

Modifying the person.aspx file to filter the display in sharepoint 2007

Person.aspx will use various query strings to load the desired person's profile

accountname User's account name, e.g. (DOMAIN\username)
guid The user's guid in SharePoint
sid The user's sid from Active Directory
preferredname Tries to find a match based on the displayName attribute from Active Directory
user Takes various iterations of display names or usernames and tries to resolve to a user, by redirecting to _layouts/SelectUser.aspx.


Open the Person.aspx to see what controls are being used and concentrate on the ProfileViewer (the control that displays Profile Property values).

<SPSWC:ProfileViewer id="ProfileViewer" ShowBusinessCardIfEmpty="false" runat="server" />


this ProfileViewer is inherited from ProfileUI, the InitControl will have the code:

this.objLoader = ProfilePropertyLoader.FindLoader(this.Page);


this is the method call to get a loaded profile.
Now looking in to the ProfilePropertyLoader, will look for the object. If not found in the HttpContext.Items collection, that will create a new object.

The ProfilePropertyLoader has two properties that return a UserProfile object, ProfileCurrentUser (the profile for the browsing user) and ProfileLoaded (the profile of the user to be displayed, which may be the same as ProfileCurrentUser).


after getting to know the UserProfile object via ProfilePropertyLoader, create a filter web part, so that you could pass in filter or query values from the UserProfile to other web parts via Connections.

MSDN has a great article on creating a Filter provider web part, so follow that and add code to get user profile values and pass those into other web parts.

public ReadOnlyCollection<string> ParameterValues   
 { 
get
{
        // Get a reference to the ProfilePropertyLoader,
         // which contains the reference to the UserProfile 
         Microsoft.SharePoint.Portal.WebControls.ProfilePropertyLoader loader = Microsoft.SharePoint.Portal.WebControls.ProfilePropertyLoader.FindLoader(this.Page);  
        if (loader == null)  
       {  
          return null; 
        } 
       Microsoft.Office.Server.UserProfiles.UserProfile profile = loader.ProfileLoaded; 
  if (profile == null)  
    {  
           return null;  
       }  
       string thirdPartyAppUserID = (string)profile["ThirdPartyAppUserID"].Value; 
        if (string.IsNullOrEmpty(thirdPartyAppUserID))  
        {  
            return null; 
        }  
        List<string> thirdPartyAppUserIDList = new List<string>();  
       thirdPartyAppUserIDList.Add(thirdPartyAppUserID); 
         return new ReadOnlyCollection<string>(thirdPartyAppUserIDList);  
    }   }


source:
http://www.sharepointblogs.com/toth/archive/2008/05/30/filtering-data-on-the-mysite-profile-page-person-aspx.aspx

Friday, January 2, 2009

Context changes in Sharepoint Designer

current user's permission for that item is shown in the 'perm' attribute in SPD code view.
Open SharePoint Designer 2007 and navigate to the page containing the Data Form Web Part. (follow the "Steps to Reproduce" above) In Code view,search for the following peace of code:Perm="{ddwrt:CurrentRights()}" Replace it with the following peace of code:Perm="{@PermMask}" Save the page.

permanent solution:
Go to the folder where SharePoint Designer 2007 is installed. Usually it will be: "c:\Program Files\Microsoft Office\Office12". Find the file CAML2XSL.XSL and open it in a text editor (I used Notepad). Look for the following peace of code (There should be only one occurrence of it) : ddwrt:CurrentRights() Replace it with the following peace of code: @PermMask Save the file