Esempio n. 1
0
        private WebPartEntity CreateYammerWebPart(string feedType, YammerUser user, string yammerGroupName, string title)
        {
            YammerGroup group;
            string      groupId;

            // Notice that in general we do not recommend of matching Yammer group for each site to avoid "group pollution" in Yammer
            if (feedType == "Group")
            {
                // Get Yammer Group - Creates if does not exist. Let's create these as public by default.
                group = YammerUtility.CreateYammerGroup(yammerGroupName, false, ConfigurationManager.AppSettings["YammerAccessToken"]);
                // Get Yammer web part
                return(YammerUtility.GetYammerGroupDiscussionPart(user.network_name, group.id, false, false));
            }
            else
            {
                if (!string.IsNullOrEmpty(YammerExistingGroups.SelectedValue))
                {
                    group   = YammerUtility.GetYammerGroupByName(YammerExistingGroups.SelectedValue, ConfigurationManager.AppSettings["YammerAccessToken"]);
                    groupId = group.id.ToString();
                }
                else
                {
                    groupId = "";
                }

                // Get OpenGrap object for using that as the discussion feed
                return(YammerUtility.GetYammerOpenGraphDiscussionPart(user.network_name, Request["SPHostUrl"] + "/" + txtUrl.Text,
                                                                      false, false, "SharePoint Site Feed - " + title, "", groupId));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Actual sub site creation and modification logic. Calls Core component methods to make things work
        /// </summary>
        /// <param name="hostWeb"></param>
        /// <param name="url"></param>
        /// <param name="template"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="feedType"></param>
        /// <param name="yammerGroupName"></param>
        /// <returns></returns>
        public void CreateSubSite(Web hostWeb, string url, string template,
                                  string title, string description, string feedType, string yammerGroupName)
        {
            // Create new sub site
            Web newWeb = hostWeb.CreateWeb(title, url, description, template, 1033);

            // Set theme for the site
            newWeb.SetThemeToSubWeb(hostWeb, "Orange");

            //Remove the out of the box "NewsFeed" web part
            newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx");

            // Let's first get the details on the Yammer network using the access token
            WebPartEntity wpYammer;
            YammerUser    user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]);

            // Created Yammer web part with needed configuration
            wpYammer = CreateYammerWebPart(feedType, user, yammerGroupName, title);

            // Add Yammer web part to the page
            newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false);

            // Add theme to the site and apply that
            ApplyThemeToSite(hostWeb, newWeb);
        }
Esempio n. 3
0
        /// <summary>
        /// Actual sub site creation and modification logic. Calls Core component methods to make things work
        /// </summary>
        /// <param name="hostWeb"></param>
        /// <param name="url"></param>
        /// <param name="template"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="feedType"></param>
        /// <param name="yammerGroupName"></param>
        /// <returns></returns>
        public void CreateSubSite(Web hostWeb, string url, string template,
                                  string title, string description, string feedType, string yammerGroupName)
        {
            // Create new sub site
            Web newWeb = hostWeb.CreateSite(title, url, description, template, 1033);

            // Set theme for the site
            newWeb.SetThemeToSubWeb(hostWeb, "Orange");

            //Remove the out of the box "NewsFeed" web part
            newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx");

            // Let's first get the details on the Yammer network using the access token
            WebPartEntity wpYammer;
            YammerUser    user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]);

            // Notice that in general we do not recommend of matching Yammer group for each site to avoid "group pollution" in Yammer
            if (feedType == "Group")
            {
                // Get Yammer Group - Creates if does not exist. Let's create these as public by default.
                YammerGroup group =
                    YammerUtility.CreateYammerGroup(yammerGroupName, false, ConfigurationManager.AppSettings["YammerAccessToken"]);
                // Get Yammer web part
                wpYammer = YammerUtility.GetYammerGroupDiscussionPart(user.network_name, group.id, false, false);
            }
            else
            {
                // Get OpenGrap object for using that as the discussion feed
                wpYammer = YammerUtility.GetYammerOpenGraphDiscussionPart(user.network_name, Request["SPHostUrl"] + "/" + txtUrl.Text,
                                                                          false, false, "SharePoint Site Feed - " + title);
            }
            // Add Yammer web part to the page
            newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false);
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // define initial script, needed to render the chrome control
            string script = @"
            function chromeLoaded() {
                $('body').show();
            }

            //function callback to render chrome after SP.UI.Controls.js loads
            function renderSPChrome() {
                //Set the chrome options for launching Help, Account, and Contact pages
                var options = {
                    'appTitle': document.title,
                    'onCssLoaded': 'chromeLoaded()'
                };

                //Load the Chrome Control in the divSPChrome element of the page
                var chromeNavigation = new SP.UI.Controls.Navigation('divSPChrome', options);
                chromeNavigation.setVisible(true);
            }";

            //register script in page
            Page.ClientScript.RegisterClientScriptBlock(typeof(Default), "BasePageScript", script, true);

            if (!Page.IsPostBack)
            {
                lblBasePath.Text = Request["SPHostUrl"] + "/";
                listSites.Items.Add(new System.Web.UI.WebControls.ListItem("Team", "STS#0"));
                listSites.Items.Add(new System.Web.UI.WebControls.ListItem("Super Team", "STS#0"));
                listSites.Items.Add(new System.Web.UI.WebControls.ListItem("Über Team", "STS#0"));
                listSites.SelectedIndex = 0;
            }

            if (!this.IsPostBack)
            {
                // Get existing Yammer groups from the network to associate to them
                List <YammerGroup> groups = YammerUtility.GetYammerGroups(ConfigurationManager.AppSettings["YammerAccessToken"]);
                foreach (var item in groups)
                {
                    // Add items to the list.
                    YammerExistingGroups.Items.Add(new System.Web.UI.WebControls.ListItem(item.full_name, item.full_name));
                }
                YammerExistingGroups.Items.Add("");
                YammerExistingGroups.SelectedValue = "";
            }
        }
Esempio n. 5
0
 protected void YammerFeedType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (YammerFeedType.SelectedValue == "Group")
     {
         YammerGroupAssociationType.Enabled = true;
         // Get existing Yammer groups from the network to associate to them
         List <YammerGroup> groups = YammerUtility.GetYammerGroups(ConfigurationManager.AppSettings["YammerAccessToken"]);
         foreach (var item in groups)
         {
             // Add items to the list.
             YammerExistingGroups.Items.Add(new System.Web.UI.WebControls.ListItem(item.full_name, item.full_name));
         }
         YammerGroupAssociationType.Enabled = true;
         txtYammerGroup.Enabled             = true;
         YammerExistingGroups.Enabled       = true;
     }
     else
     {
         YammerGroupAssociationType.Enabled = false;
         txtYammerGroup.Enabled             = false;
         YammerExistingGroups.Enabled       = false;
     }
 }
Esempio n. 6
0
 static void Main(string[] args)
 {
     // Simple tester console to ensure that token works as expected. Details on getting token from here - https://developer.yammer.com/authentication
     string      accessToken = "GetYourOwnAccessTokenFromYammer";
     YammerGroup group       = YammerUtility.GetYammerGroupByName("fuu", accessToken);
 }