private OpenSocialManager(string ownerUri, Page page, bool editMode)
{
this.guid = Guid.NewGuid();
this.isDebug = page.Session != null && page.Session[ORNG_DEBUG] != null && (bool)page.Session[ORNG_DEBUG];
this.noCache = page.Session != null && page.Session[ORNG_NOCACHE] != null && (bool)page.Session[ORNG_NOCACHE];
this.page = page;
this.pageName = page.AppRelativeVirtualPath.Substring(2).ToLower();
DebugLogging.Log("Creating OpenSocialManager for " + ownerUri + ", " + pageName);
if (shindigURL == null)
{
// do nothing
return;
}
this.ownerUri = ownerUri;
// in editMode we need to set the viewer to be the same as the owner
// otherwise, the gadget will not be able to save appData correctly
if (editMode)
{
viewerUri = ownerUri;
}
else
{
Profiles.Framework.Utilities.SessionManagement sm = new Profiles.Framework.Utilities.SessionManagement();
// if they have a Profile, use the Profile URI otherwise use the User URI. This allows admins and other folks without profile pages to use gadgets
if (sm.Session().PersonURI != null && sm.Session().PersonURI.Trim().Length > 0)
{
viewerUri = sm.Session().PersonURI;
}
else
{
viewerUri = sm.Session().UserURI;
}
if (viewerUri != null && viewerUri.Trim().Length == 0)
{
viewerUri = null;
}
}
string requestAppId = page.Request.QueryString["appId"];
foreach (GadgetSpec gadgetSpec in GetGadgetSpecifications())
{
// only add ones that are visible in this context!
if (((requestAppId == null && gadgetSpec.IsEnabled()) || gadgetSpec.GetAppId() == Convert.ToInt32(requestAppId)) && gadgetSpec.Show(viewerUri, ownerUri, GetPageName()))
{
gadgets.Add(new PreparedGadget(gadgetSpec, this));
}
}
// if we are in edit mode, clear the cache
if (editMode)
{
ClearOwnerCache();
}
// sort the gadgets
DebugLogging.Log("Visible Gadget Count : " + gadgets.Count);
gadgets.Sort();
}