Exemplo n.º 1
0
        // based on security and securityGroup settings, do we show this?
        public bool Show(string viewerUri, string ownerUri, String page)
        {
            page = page.ToLower();
            bool show = true;

            // if there are no view requirements, go ahead and show it.  We are likely testing out a new gadget
            // if there are some, turn it off unless this page says its OK to turn it on
            if (viewRequirements.Count > 0)
            {
                show = false;
            }

            if (viewRequirements.ContainsKey(page))
            {
                GadgetViewRequirements req = GetGadgetViewRequirements(page);
                string visibility          = (req.GetVisiblity() == OpenSocialManager.REGISTRY_DEFINED ? GetRegistryDefinedVisiblity(ownerUri) : req.GetVisiblity());
                if (OpenSocialManager.PUBLIC.Equals(visibility))
                {
                    show = true;
                }
                else if (OpenSocialManager.USERS.Equals(visibility) && viewerUri != null)
                {
                    show = true;
                }
                else if (OpenSocialManager.PRIVATE.Equals(visibility) && (viewerUri != null) && (viewerUri == ownerUri))
                {
                    show = true;
                }
                else if (OpenSocialManager.IS_REGISTERED.Equals(visibility) && GetRegistryDefinedVisiblity(ownerUri) != null)
                {
                    show = true;
                }
            }
            return(show);
        }
Exemplo n.º 2
0
        // based on security and securityGroup settings, do we show this?
        public bool Show(string viewerUri, string ownerUri, String page)
        {
            // if it is a sandbox gadget with no match in the db, always show it because
            // this means a developer is trying to test things
            if (unrecognized)
            {
                return(true);
            }
            page = page.ToLower();
            bool show = false;

            if (viewRequirements.ContainsKey(page))
            {
                GadgetViewRequirements req = GetGadgetViewRequirements(page);
                string visibility          = req.GetVisiblity();
                if (OpenSocialManager.PUBLIC.Equals(visibility))
                {
                    show = true;
                }
                else if (OpenSocialManager.USERS.Equals(visibility) && viewerUri != null)
                {
                    show = true;
                }
                else if (OpenSocialManager.PRIVATE.Equals(visibility) && (viewerUri != null) && (viewerUri == ownerUri))
                {
                    show = true;
                }
            }
            return(show);
        }
Exemplo n.º 3
0
        public int CompareTo(PreparedGadget other)
        {
            GadgetViewRequirements gvr1 = this.GetGadgetViewRequirements();
            GadgetViewRequirements gvr2 = other.GetGadgetViewRequirements();

            return(("" + this.GetChromeId() + (gvr1 != null ? 1000 + gvr1.GetDisplayOrder() : Int32.MaxValue)).CompareTo("" + other.GetChromeId() + (gvr2 != null ? 1000 + gvr2.GetDisplayOrder() : Int32.MaxValue)));
        }
Exemplo n.º 4
0
        public String GetView()
        {
            GadgetViewRequirements reqs = GetGadgetViewRequirements();

            if (reqs != null)
            {
                return(reqs.GetView());
            }
            // default behavior that will get invoked when there is no reqs.  Useful for sandbox gadgets
            else if (openSocialManager.GetPageName().Equals("edit/default.aspx"))
            {
                return("home");
            }
            else if (openSocialManager.GetPageName().Equals("profile/display.aspx"))
            {
                return("profile");
            }
            else if (openSocialManager.GetPageName().Equals("orng/gadgetdetails.aspx"))
            {
                return("canvas");
            }
            else if (gadgetSpec.GetGadgetURL().Contains("Tool"))
            {
                return("small");
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        // tool gadgets
        public PreparedGadget(GadgetSpec gadgetSpec, OpenSocialManager openSocialManager)
        {
            this.gadgetSpec        = gadgetSpec;
            this.openSocialManager = openSocialManager;
            this.securityToken     = SocketSendReceive(openSocialManager.GetViewerURI(), openSocialManager.GetOwnerURI(), gadgetSpec.GetGadgetURL());

            // look at the view requirements and what page we are on to set some things
            GadgetViewRequirements viewReqs = GetGadgetViewRequirements();

            if (viewReqs != null)
            {
                this.view      = viewReqs.GetView();
                this.chromeId  = viewReqs.GetChromeId();
                this.optParams = viewReqs.GetOptParams();
            }
            else  // must be a sandbox gadget
            {
                this.view      = "";
                this.chromeId  = "gadgets-test-" + gadgetSpec.GetAppId();
                this.optParams = "{}";
            }
        }
Exemplo n.º 6
0
        // tool gadgets
        public PreparedGadget(GadgetSpec gadgetSpec, OpenSocialManager openSocialManager)
        {
            this.gadgetSpec        = gadgetSpec;
            this.openSocialManager = openSocialManager;
            this.securityToken     = openSocialManager.GetSecurityToken(gadgetSpec.GetGadgetURL());

            // look at the view requirements and what page we are on to set some things
            GadgetViewRequirements viewReqs = GetGadgetViewRequirements();

            if (viewReqs != null)
            {
                this.view      = viewReqs.GetView();
                this.chromeId  = viewReqs.GetChromeIdBase() + "-" + GetAppId();
                this.optParams = viewReqs.GetOptParams();
            }
            else  // must be a sandbox gadget
            {
                this.view      = "sandbox";
                this.chromeId  = "gadgets-sandbox-" + GetAppId();
                this.optParams = "{}";
            }
        }
Exemplo n.º 7
0
        public string GetOptParams()
        {
            GadgetViewRequirements reqs = GetGadgetViewRequirements();

            return(reqs != null?reqs.GetOptParams() : "{}");
        }