private void UserAccountEncouragement(User user, string additionalData = null) { if (!user.EnableEmail.GetValueOrDefault(true)) { return; } EmailHealthEncouragementContainer emailDigestContainer = new EmailHealthEncouragementContainer(); PublicApi.Users.RunAsUser(user.Username, () => { emailDigestContainer.ContentRecommendations = PublicApi.ContentRecommendations.List(new ContentRecommendationsListOptions() { PageSize = 25, PageIndex = 0, ContentTypeIds = new Guid[] { PublicApi.BlogPosts.ContentTypeId, PublicApi.ForumThreads.ContentTypeId, PublicApi.Media.ContentTypeId, PublicApi.WikiPages.ContentTypeId, PublicApi.ForumReplies.ContentTypeId } }).ToList(); }); TemplateContext templateContext = new TemplateContext(new Dictionary <Guid, object>() { { PublicApi.Users.ContentTypeId, user }, { EmailHealthEncouragementContainer.DateTypeId, emailDigestContainer } }); PublicApi.Users.RunAsUser(user.Username, () => { var mailTempalte = Telligent.Evolution.Extensibility.Version1.PluginManager.GetSingleton <UserEncouragementEmailTemplate>(); if (mailTempalte != null) { var mailOptions = mailTempalte.GetSendMailOptions(user.Id.GetValueOrDefault(), templateContext); if (additionalData != null) { var attachments = new List <System.Net.Mail.Attachment>(); byte[] byteArray = Encoding.UTF8.GetBytes(additionalData); var attachment = new System.Net.Mail.Attachment(new MemoryStream(byteArray), new System.Net.Mime.ContentType("text/plain; charset=us-ascii")); attachment.ContentDisposition.DispositionType = "attachment"; attachment.ContentDisposition.FileName = "userlist.txt"; attachment.ContentDisposition.Size = byteArray.Length; attachments.Add(attachment); mailOptions.Attachments = attachments; } PublicApi.SendEmail.Send(mailOptions); } }); }
private ContextItem BuildUserContextItem(Telligent.Evolution.Extensibility.Api.Entities.Version1.User user) { var item = new ContextItem() { TypeName = "User", ApplicationId = user.ContentId, ApplicationTypeId = TEApi.Users.ContentTypeId, ContainerId = user.ContentId, ContainerTypeId = TEApi.Users.ContentTypeId, ContentId = user.ContentId, ContentTypeId = TEApi.Users.ContentTypeId, Id = user.Id.ToString() }; return(item); }
/// <summary> /// Returns the correct spacing for a user property. The InProcess API properties contain whitespace and the REST API properties do not. /// </summary> /// <param name="user">Api user</param> /// <param name="field">Field name for lookup</param> /// <returns>Field name with proper spacing</returns> private static string GetFieldName(ApiUser user, string field) { if (user == null || field.Equals(AvatarUrlField, StringComparison.OrdinalIgnoreCase)) { return(string.Empty); } var profileField = user.ProfileFields.FirstOrDefault(pf => String.Equals(field, pf.Label.Replace(" ", string.Empty), StringComparison.InvariantCultureIgnoreCase)); if (profileField != null) { return(profileField.Label); } SPLog.Event(String.Format("Could Not Locate Field Name ({0}) for User({1}).", field, user.Id ?? -1)); return(string.Empty); }
public ICustomNavigationItem GetNavigationItem(Guid id, ICustomNavigationItemConfiguration configuration) { Telligent.Evolution.Extensibility.Api.Entities.Version1.User user = null; if (configuration.GetStringValue("user", "current") == "accessing") { user = TEApi.Users.AccessingUser; } else { var userItem = TEApi.Url.CurrentContext.ContextItems.GetItemByContentType(TEApi.Users.ContentTypeId); if (userItem != null) { user = TEApi.Users.Get(new UsersGetOptions() { ContentId = userItem.ContentId }); } } return(new UserPollsNavigationItem(this, configuration, id, user.Id.Value, () => _translation.GetLanguageResourceValue("configuration_defaultLabel"))); }
internal static Dictionary <string, object> GetInternalUserFields(ApiUser user) { var fields = new Dictionary <string, object> { { "Bio", user.Bio() } }; try { foreach (var property in UserProperties.Values) { if (property.Name == "ProfileFields") { continue; } var fieldName = property.Name.Replace(" ", string.Empty); fields.Add(fieldName, property.GetValue(user, null)); } if (user.ProfileFields == null) { throw new Exception(string.Format("The 'ProfileFields' property is null for user {0}. Please verify __CommunityServer__Service__ contains the Administrators role.", user.Id)); } foreach (var field in user.ProfileFields) { var fieldName = field.Label.Replace(" ", string.Empty); if (!fields.ContainsKey(fieldName)) { fields.Add(fieldName, field.Value); } } } catch (Exception ex) { SPLog.UserNotFound(ex, ex.Message); } return(fields); }
private void UserAccountEncouragement(User user , string additionalData = null) { if (!user.EnableEmail.GetValueOrDefault(true)) return; EmailHealthEncouragementContainer emailDigestContainer = new EmailHealthEncouragementContainer(); PublicApi.Users.RunAsUser(user.Username, () => { emailDigestContainer.ContentRecommendations = PublicApi.ContentRecommendations.List(new ContentRecommendationsListOptions() { PageSize = 25, PageIndex = 0, ContentTypeIds = new Guid[] { PublicApi.BlogPosts.ContentTypeId, PublicApi.ForumThreads.ContentTypeId, PublicApi.Media.ContentTypeId, PublicApi.WikiPages.ContentTypeId, PublicApi.ForumReplies.ContentTypeId } }).ToList(); }); TemplateContext templateContext = new TemplateContext(new Dictionary<Guid, object>() { { PublicApi.Users.ContentTypeId, user }, { EmailHealthEncouragementContainer.DateTypeId, emailDigestContainer } }); PublicApi.Users.RunAsUser(user.Username, () => { var mailTempalte = Telligent.Evolution.Extensibility.Version1.PluginManager.GetSingleton<UserEncouragementEmailTemplate>(); if (mailTempalte != null) { var mailOptions = mailTempalte.GetSendMailOptions(user.Id.GetValueOrDefault(), templateContext); if (additionalData != null) { var attachments = new List<System.Net.Mail.Attachment>(); byte[] byteArray = Encoding.UTF8.GetBytes(additionalData); var attachment = new System.Net.Mail.Attachment(new MemoryStream(byteArray), new System.Net.Mime.ContentType("text/plain; charset=us-ascii")); attachment.ContentDisposition.DispositionType = "attachment"; attachment.ContentDisposition.FileName = "userlist.txt"; attachment.ContentDisposition.Size = byteArray.Length; attachments.Add(attachment); mailOptions.Attachments = attachments; } PublicApi.SendEmail.Send(mailOptions); } }); }
public TEApiUser(string idFieldName, string emailFieldName, TE.User userProfile) : base(idFieldName, emailFieldName) { Profile = userProfile; }