private void processControls(Control parentControl, string listname, string listid, string viewid, string defaultcontrol, string webpartid, string ZoneIndex, bool hideNew) { foreach (Control childControl in parentControl.Controls) { if (childControl.ToString() == "System.Web.UI.WebControls.Label") { if (childControl.ID == "lblFilter") { //System.Web.UI.WebControls.HyperLink hl = (System.Web.UI.WebControls.HyperLink)childControl; //hl.NavigateUrl = "Javascript:switchFilter" + ZoneIndex + "('" + hl.ClientID + "');"; try { System.Web.UI.WebControls.Label lblFilterText = (System.Web.UI.WebControls.Label)parentControl.FindControl("lblFilterText"); System.Web.UI.WebControls.Label lblLink = (System.Web.UI.WebControls.Label)childControl; lblLink.Text = "<a onclick=\"Javascript:switchFilter" + ZoneIndex + "('" + lblFilterText.ClientID + "');\">"; filterIndex = parentControl.Parent.Controls.IndexOf(parentControl); } catch { } } } if (childControl.ToString().ToUpper() == "MICROSOFT.SHAREPOINT.WEBCONTROLS.NEWMENU") { if (hideNew) { childControl.Visible = false; } else if (useNewMenu) { if (hasList) { NewMenu menu = (NewMenu)childControl; try { Microsoft.SharePoint.WebControls.MenuItemTemplate mnu = menu.GetMenuItem("New0"); mnu.ClientOnClickNavigateUrl = "javascript:newAppPopup('" + list.ID.ToString().ToUpper() + @"');"; string txt = mnu.Text; int spaceloc = txt.IndexOf(" "); txt = txt.Substring(0, spaceloc); if (newMenuName == "") { mnu.Text = txt + " " + listname; } else { mnu.Text = txt + " " + newMenuName; } menu.MenuControl.ClientOnClickScript = "javascript:newAppPopup('" + list.ID.ToString().ToUpper() + @"');"; } catch { } } else { NewMenu menu = (NewMenu)childControl; try { Microsoft.SharePoint.WebControls.MenuItemTemplate mnu = menu.GetMenuItem("New0"); mnu.ClientOnClickNavigateUrl = SPContext.Current.Web.Url + "/_layouts/epmlive/newapp.aspx?List=" + listid; string txt = mnu.Text; int spaceloc = txt.IndexOf(" "); txt = txt.Substring(0, spaceloc); if (newMenuName == "") { mnu.Text = txt + " " + listname; } else { mnu.Text = txt + " " + newMenuName; } menu.MenuControl.ClientOnClickScript = "location.href='" + mnu.ClientOnClickNavigateUrl + "'"; } catch { } } } else if (listname != "Project Center" && listname != "Project Center Rollup" && rollupLists != "" && !disableNewButtonModification) { NewMenu menu = (NewMenu)childControl; try { menu.GetMenuItem("New0").Visible = false; menu.MenuControl.NavigateUrl = ""; menu.MenuControl.ClientOnClickScript = ""; string[] arrrolluplists = rollupLists.Split(','); foreach (string rolluplist in arrrolluplists) { string[] arrrolluplist = rolluplist.Split('|'); string image = ""; try { image = "/_layouts/images/" + arrrolluplist[1]; } catch { } menu.AddMenuItem("New1", "New " + arrrolluplist[0].Trim() + " Item", "", "", SPContext.Current.Web.Url + "/_layouts/epmlive/newitem.aspx?List=" + arrrolluplist[0] + "&Source=" + HttpUtility.UrlEncode(HttpContext.Current.Request.Url.ToString()), ""); } } catch { } } else { NewMenu menu = (NewMenu)childControl; MenuItemTemplate template = menu.GetMenuItem("New0"); } } if (childControl.ToString().ToUpper() == "MICROSOFT.SHAREPOINT.WEBCONTROLS.ACTIONSMENU") { ActionsMenu menu = (ActionsMenu)childControl; if (rollupLists != "") { try { menu.GetMenuItem("EditInGridButton").Visible = false; } catch { } try { menu.GetMenuItem("ExportToDatabase").Visible = false; } catch { } if (rollupLists != "") { try { menu.GetMenuItem("ViewRSS").Visible = false; } catch { } try { menu.GetMenuItem("SubscribeButton").Visible = false; } catch { } } try { SPWeb web = SPContext.Current.Web; MenuItemTemplate mnu = menu.GetMenuItem("ExportToSpreadsheet"); mnu.ClientOnClickScript = "location.href='" + web.ServerRelativeUrl + "/_layouts/epmlive/rollupexport.aspx?List=" + listid + "&View=" + viewid + "&Lists=" + HttpUtility.UrlEncode(rollupLists.Replace(",", ";")) + "'"; } catch { } } string url = HttpContext.Current.Request.Url.AbsolutePath; if (url.Contains("?")) { url += "&"; } else { url += "?"; } if (defaultcontrol.ToLower() == "grid") { } else if (defaultcontrol.ToLower() == "gantt") { menu.AddMenuItem("ViewInGrid", "View In Grid", "/_layouts/epmlive/images/menugridview.GIF", "View list using EPM Live Grid.", url + "webpartid=" + webpartid + "&gridmode=grid", ""); } } if (childControl == null) { return; } processControls(childControl, listname, listid, viewid, defaultcontrol, webpartid, ZoneIndex, hideNew); } }
protected override void OnLoad(EventArgs e) { if (this.Visible) { //using (SPSite site = SPContext.Current.Site) SPSite site = SPContext.Current.Site; { //SPFeature listDisplaySettingFeature = site.Features[new Guid("88E9E47A-BA92-47ab-A253-8AA472CCC76B")]; //if ((listDisplaySettingFeature != null) && (listDisplaySettingFeature.Definition.Status == Microsoft.SharePoint.Administration.SPObjectStatus.Online)) //{ if (View.ParentList.ParentWeb.Properties.ContainsKey(String.Format("ViewPermissions{0}", View.ParentList.ID.ToString()))) { featureEnabled = true; roleProperties = new Dictionary <int, Dictionary <string, bool> >(); defaultViews = new Dictionary <int, string>(); SPWeb web = View.ParentList.ParentWeb; { ViewPermissionUtil.ConvertFromString(ref roleProperties, ref defaultViews, web.Properties[String.Format("ViewPermissions{0}", View.ParentList.ID.ToString())], View.ParentList); } } foreach (SPView view in View.ParentList.Views) { if ((!view.Hidden) && (!view.PersonalView)) { views.Add(view); } } //} } base.OnLoad(e); //if(featureEnabled) { try { NameValueCollection nv = HttpUtility.ParseQueryString(Page.Request.UrlReferrer.Query); StringBuilder sbUrl = new StringBuilder(); bool bPersonal = false; try { if (nv["PageView"] == "Personal") { bPersonal = true; } } catch { } if (!bPersonal) { foreach (string key in nv.AllKeys) { if (isValidQS(key)) { sbUrl.Append("&"); sbUrl.Append(key); sbUrl.Append("="); sbUrl.Append(HttpUtility.UrlEncode(nv[key])); } } foreach (Control item in base.MenuTemplateControl.Controls) { try { if ((item is MenuItemTemplate) && (View.ParentList.Views[((MenuItemTemplate)item).Text]) != null) { if (featureEnabled) { item.Visible = UserCanSeeView(View.ParentList.Views[((MenuItemTemplate)item).Text].Url, roleProperties); } } Microsoft.SharePoint.WebControls.MenuItemTemplate mn = (Microsoft.SharePoint.WebControls.MenuItemTemplate)item; string sDoc = System.IO.Path.GetFileName(mn.ClientOnClickNavigateUrl); if (!sDoc.Contains("ViewEdit.aspx?") && !sDoc.Contains("ViewType.aspx?")) { if (sbUrl.ToString() != "") { //mn.ClientOnClickScript = mn.ClientOnClickScript.Insert(mn.ClientOnClickScript.Length - 3, "?" + sbUrl.ToString().TrimStart('&')); mn.ClientOnClickNavigateUrl += "?" + sbUrl.ToString().TrimStart('&'); } } } catch { } } } } catch { } } } else { base.OnLoad(e); } }