public object Messages(HttpContextBase context) { var selectedItem = new SelectionUtility(context, engine).ParseSelectionFromRequest() ?? engine.Persister.Get(engine.Host.DefaultSite.RootItemID); var ctx = CollaborationContext.Create(DateTime.MinValue, selectedItem, context.User); return(new { Messages = messages.GetMessages(ctx).ToList() }); }
private void NotifyViewing(IEngine engine, HttpContextWrapper context) { var selection = new SelectionUtility(context, engine); if (selection.SelectedItem != null) { engine.AddActivity(new ManagementActivity { Operation = "View", PerformedBy = context.User.Identity.Name, ID = selection.SelectedItem.ID, Path = selection.SelectedItem.Path }); } context.Response.WriteJson(new { Messages = engine.Resolve <ManagementMessageCollector>() .GetMessages(CollaborationContext.Create(engine.Resolve <IProfileRepository>(), selection.SelectedItem, context)) .ToList() }); }
private void NotifyEditing(IEngine engine, HttpContextWrapper context) { var selection = new SelectionUtility(context, engine); if (Convert.ToBoolean(context.Request["changes"])) { engine.AddActivity(new ManagementActivity { Operation = "Edit", PerformedBy = context.User.Identity.Name, ID = selection.SelectedItem.ID, Path = selection.SelectedItem.Path }); } var activities = ManagementActivity.GetActivity(engine, selection.SelectedItem); var messages = engine.Resolve <N2.Edit.Collaboration.ManagementMessageCollector>() .GetMessages(CollaborationContext.Create(engine.Resolve <IProfileRepository>(), selection.SelectedItem, context)) .ToList(); context.Response.ContentType = "application/json"; context.Response.Write(ManagementActivity.ToJson(activities, messages)); }
public virtual ContextData GetInterfaceContextData(HttpContextBase context, SelectionUtility selection) { var item = selection.ParseSelectionFromRequest(); Url selectedUrl = context.Request["selectedUrl"]; if (item == null && selectedUrl != null) { item = selection.ParseUrl(selectedUrl); } var data = new ContextData(); if (item != null) { var adapter = engine.GetContentAdapter <NodeAdapter>(item); data.CurrentItem = adapter.GetTreeNode(item); data.ExtendedInfo = CreateExtendedContextData(item, resolveVersions: true); var l = adapter.GetLanguage(item); if (l != null) { data.Language = new ContextLanguage { IconClass = "sprite " + (l.LanguageCode.Split('-').LastOrDefault() ?? string.Empty).ToLower(), LanguageCode = l.LanguageCode, LanguageTitle = l.LanguageTitle } } ; data.Flags = adapter.GetNodeFlags(item).ToList(); } else { data.Flags = new List <string>(); } var mangementUrl = "{ManagementUrl}".ResolveUrlTokens(); if (!selectedUrl.IsEmpty()) { data.ReturnUrl = HttpUtility.UrlDecode(selectedUrl["returnUrl"]); var isOrganizing = selectedUrl["edit"] == "drag"; if (selectedUrl.Path.StartsWith(mangementUrl, StringComparison.InvariantCultureIgnoreCase)) { data.Flags.Add("Management"); data.Flags.Add(selectedUrl.Path.Substring(mangementUrl.Length).ToUrl().PathWithoutExtension.Replace("/", "")); if (isOrganizing) { data.Flags.Add("Organize"); } } else if (isOrganizing) { data.Flags.Add("Management"); data.Flags.Add("Organize"); } } if (new[] { "MyselfRoot", "ContentEditRecursive", "ContentTemplatesDefault", "ContentWizardDefault", "UsersUsers" }.Intersect(data.Flags).Any() == false) { data.Flags.Add("ContentPages"); } data.Actions = CreateActions(context); var collaborationContext = CollaborationContext.Create(engine.Resolve <IProfileRepository>(), item, context); data.Messages = engine.Resolve <N2.Edit.Collaboration.ManagementMessageCollector>().GetMessages(collaborationContext).ToList(); data.Flags.AddRange(engine.Resolve <N2.Edit.Collaboration.ManagementFlagCollector>().GetFlags(collaborationContext)); if (ContextBuilt != null) { ContextBuilt(this, new ContextBuiltEventArgs { Data = data }); } return(data); }