public HttpResponseMessage Create(CreateDTO postData) { try { var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId); var roleIdsList = string.IsNullOrEmpty(postData.RoleIds) ? null : postData.RoleIds.FromJson <IList <int> >(); var userIdsList = string.IsNullOrEmpty(postData.UserIds) ? null : postData.UserIds.FromJson <IList <int> >(); var fileIdsList = string.IsNullOrEmpty(postData.FileIds) ? null : postData.FileIds.FromJson <IList <int> >(); var roles = roleIdsList != null && roleIdsList.Count > 0 ? roleIdsList.Select(id => RoleController.Instance.GetRole(portalId, r => r.RoleID == id)).Where(role => role != null).ToList() : null; List <UserInfo> users = null; if (userIdsList != null) { users = userIdsList.Select(id => UserController.Instance.GetUser(portalId, id)).Where(user => user != null).ToList(); } var message = new Message { Subject = HttpUtility.UrlDecode(postData.Subject), Body = HttpUtility.UrlDecode(postData.Body) }; MessagingController.Instance.SendMessage(message, roles, users, fileIdsList); return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "success", Value = message.MessageID })); } catch (Exception exc) { Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage LoadFiles(FolderItemDTO folderItem) { int effectivePortalId = PortalSettings.PortalId; if (string.IsNullOrEmpty(folderItem.FolderPath)) { folderItem.FolderPath = ""; } if (IsUserFolder(folderItem.FolderPath)) { if (!UserInfo.IsSuperUser) { effectivePortalId = PortalController.GetEffectivePortalId(effectivePortalId); } else { effectivePortalId = -1; } } var list = Globals.GetFileList(effectivePortalId, folderItem.FileFilter, !folderItem.Required, folderItem.FolderPath); var fileItems = list.OfType <FileItem>().ToList(); return(Request.CreateResponse(HttpStatusCode.OK, fileItems)); }
public HttpResponseMessage GetUsers(string searchText, UserFilters filter, int pageIndex, int pageSize, string sortColumn, bool sortAscending) { try { int totalRecords; var getUsersContract = new GetUsersContract { SearchText = searchText, PageIndex = pageIndex, PageSize = pageSize, SortColumn = sortColumn, SortAscending = sortAscending, PortalId = PortalController.GetEffectivePortalId(PortalId), Filter = filter }; var results = Components.UsersController.Instance.GetUsers(getUsersContract, UserInfo.IsSuperUser, out totalRecords); var response = new { Results = results, TotalResults = totalRecords }; return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { Logger.Error(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Search(string q) { var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId); var controller = new ListController(); ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image"); IList <SearchResult> results = new List <SearchResult>(); foreach (var definition in ProfileController.GetPropertyDefinitionsByPortal(portalId) .Cast <ProfilePropertyDefinition>() .Where(definition => definition.DataType != imageType.EntryID)) { AddProperty(results, definition.PropertyName, q); } AddProperty(results, "Email", q); AddProperty(results, "DisplayName", q); AddProperty(results, "Username", q); AddProperty(results, "Password", q); AddProperty(results, "PasswordConfirm", q); AddProperty(results, "PasswordQuestion", q); AddProperty(results, "PasswordAnswer", q); return(Request.CreateResponse(HttpStatusCode.OK, results.OrderBy(sr => sr.id))); }
public HttpResponseMessage LoadFiles(FolderItemDTO folderItem) { int effectivePortalId = PortalSettings.PortalId; if (string.IsNullOrEmpty(folderItem.FolderPath)) { folderItem.FolderPath = string.Empty; } int userId; if (IsUserFolder(folderItem.FolderPath, out userId)) { var user = UserController.GetUserById(effectivePortalId, userId); if (user != null && user.IsSuperUser) { effectivePortalId = Null.NullInteger; } else { effectivePortalId = PortalController.GetEffectivePortalId(effectivePortalId); } } var list = Globals.GetFileList(effectivePortalId, folderItem.FileFilter, !folderItem.Required, folderItem.FolderPath); var fileItems = list.OfType <FileItem>().ToList(); return(Request.CreateResponse(HttpStatusCode.OK, fileItems)); }
public IList <UserInfo> GetUsersAdvancedSearch(int portalId, int userId, int filterUserId, int filterRoleId, int relationshipTypeId, bool isAdmin, int pageIndex, int pageSize, string sortColumn, bool sortAscending, string propertyNames, string propertyValues) { return(MembershipProvider.Instance().GetUsersAdvancedSearch(PortalController.GetEffectivePortalId(portalId), userId, filterUserId, filterRoleId, relationshipTypeId, isAdmin, pageIndex, pageSize, sortColumn, sortAscending, propertyNames, propertyValues)); }
public virtual MessageBoxView GetArchivedMessages(int userId, int afterMessageId, int numberOfRecords) { var reader = _dataService.GetArchiveBoxView(userId, PortalController.GetEffectivePortalId(GetCurrentUserInfo().PortalID), afterMessageId, numberOfRecords, ConstSortColumnDate, !ConstAscending); return(new MessageBoxView { Conversations = CBO.FillCollection <MessageConversationView>(reader) }); }
public virtual MessageBoxView GetSentbox(int userId, int afterMessageId, int numberOfRecords, string sortColumn, bool sortAscending, MessageReadStatus readStatus, MessageArchivedStatus archivedStatus) { var reader = _dataService.GetSentBoxView(userId, PortalController.GetEffectivePortalId(GetCurrentUserInfo().PortalID), afterMessageId, numberOfRecords, sortColumn, sortAscending); return(new MessageBoxView { Conversations = CBO.FillCollection <MessageConversationView>(reader) }); }
public HttpResponseMessage Search(string q) { var results = RegistrationProfileController.Instance.Search(PortalController.GetEffectivePortalId(this.PortalSettings.PortalId), q); return(this.Request.CreateResponse( HttpStatusCode.OK, results.OrderBy(sr => sr) .Select(field => new { id = field, name = field }))); }
private void OnLoginClick(object sender, EventArgs e) { if ((this.UseCaptcha && this.ctlCaptcha.IsValid) || !this.UseCaptcha) { var loginStatus = UserLoginStatus.LOGIN_FAILURE; string userName = PortalSecurity.Instance.InputFilter( this.txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup); // DNN-6093 // check if we use email address here rather than username UserInfo userByEmail = null; var emailUsedAsUsername = PortalController.GetPortalSettingAsBoolean("Registration_UseEmailAsUserName", this.PortalId, false); if (emailUsedAsUsername) { // one additonal call to db to see if an account with that email actually exists userByEmail = UserController.GetUserByEmail(PortalController.GetEffectivePortalId(this.PortalId), userName); if (userByEmail != null) { // we need the username of the account in order to authenticate in the next step userName = userByEmail.Username; } } UserInfo objUser = null; if (!emailUsedAsUsername || userByEmail != null) { objUser = UserController.ValidateUser(this.PortalId, userName, this.txtPassword.Text, "DNN", string.Empty, this.PortalSettings.PortalName, this.IPAddress, ref loginStatus); } var authenticated = Null.NullBoolean; var message = Null.NullString; if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED) { message = "UserNotAuthorized"; } else { authenticated = loginStatus != UserLoginStatus.LOGIN_FAILURE; } // Raise UserAuthenticated Event var eventArgs = new UserAuthenticatedEventArgs(objUser, userName, loginStatus, "DNN") { Authenticated = authenticated, Message = message, RememberMe = this.chkCookie.Checked, }; this.OnUserAuthenticated(eventArgs); } }
public virtual IList <Notification> GetNotifications(int userId, int portalId, int afterNotificationId, int numberOfRecords) { var pid = portalId; if (PortalController.IsMemberOfPortalGroup(portalId)) { pid = PortalController.GetEffectivePortalId(portalId); } return(CBO.FillCollection <Notification>(_dataService.GetNotifications(userId, pid, afterNotificationId, numberOfRecords))); }
private void BindList() { if (IsList) { lstEntries.Mode = "ListEntries"; lstEntries.SelectedKey = PropertyDefinition.PropertyName; lstEntries.ListPortalID = PortalController.GetEffectivePortalId(UsersPortalId); lstEntries.ShowDelete = false; lstEntries.DataBind(); } }
public virtual int ReplyMessage(int conversationId, string body, IList <int> fileIDs, UserInfo sender) { if (sender == null || sender.UserID <= 0) { throw new ArgumentException(Localization.Localization.GetString("MsgSenderRequiredError", Localization.Localization.ExceptionsResourceFile)); } if (string.IsNullOrEmpty(body)) { throw new ArgumentException(Localization.Localization.GetString("MsgBodyRequiredError", Localization.Localization.ExceptionsResourceFile)); } //Cannot have attachments if it's not enabled if (fileIDs != null && !InternalMessagingController.Instance.AttachmentsAllowed(sender.PortalID)) { throw new AttachmentsNotAllowed(Localization.Localization.GetString("MsgAttachmentsNotAllowed", Localization.Localization.ExceptionsResourceFile)); } //Profanity Filter var profanityFilterSetting = GetPortalSetting("MessagingProfanityFilters", sender.PortalID, "NO"); if (profanityFilterSetting.Equals("YES", StringComparison.InvariantCultureIgnoreCase)) { body = InputFilter(body); } //call ReplyMessage var messageId = _dataService.CreateMessageReply(conversationId, PortalController.GetEffectivePortalId(sender.PortalID), body, sender.UserID, sender.DisplayName, GetCurrentUserInfo().UserID); if (messageId == -1) //Parent message was not found or Recipient was not found in the message { throw new MessageOrRecipientNotFoundException(Localization.Localization.GetString("MsgMessageOrRecipientNotFound", Localization.Localization.ExceptionsResourceFile)); } //associate attachments if (fileIDs != null) { foreach (var attachment in fileIDs.Select(fileId => new MessageAttachment { MessageAttachmentID = Null.NullInteger, FileID = fileId, MessageID = messageId })) { _dataService.SaveMessageAttachment(attachment, UserController.Instance.GetCurrentUserInfo().UserID); } } // Mark reply as read and dispatched by the sender var recipient = GetMessageRecipient(messageId, sender.UserID); MarkMessageAsDispatched(messageId, recipient.RecipientID); MarkRead(conversationId, sender.UserID); return(messageId); }
private void LoadFiles() { int effectivePortalId = PortalId; if (IsUserFolder(_cboFolders.SelectedItem.Value)) { effectivePortalId = PortalController.GetEffectivePortalId(PortalId); } _cboFiles.DataSource = Globals.GetFileList(effectivePortalId, FileFilter, !Required, _cboFolders.SelectedItem.Value); _cboFiles.DataBind(); }
private void LoadFiles() { int effectivePortalId = this.PortalId; if (this.IsUserFolder(this._cboFolders.SelectedItem.Value)) { effectivePortalId = PortalController.GetEffectivePortalId(this.PortalId); } this._cboFiles.DataSource = Globals.GetFileList(effectivePortalId, this.FileFilter, !this.Required, this._cboFolders.SelectedItem.Value); this._cboFiles.DataBind(); }
public ActionResult Search(string q) { try { var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId); var isAdmin = UserInfo.IsSuperUser || UserInfo.IsInRole("Administrators"); const int numResults = 10; // GetUsersAdvancedSearch doesn't accept a comma or a single quote in the query so we have to remove them for now. See issue 20224. q = q.Replace(",", "").Replace("'", ""); if (q.Length == 0) { return(Json(null, JsonRequestBehavior.AllowGet)); } var results = TestableUserController.Instance.GetUsersBasicSearch(portalId, 0, numResults, "DisplayName", true, "DisplayName", q) .Select(user => new SearchResult { id = "user-" + user.UserID, name = user.DisplayName, iconfile = string.Format(Globals.UserProfilePicFormattedUrl(), user.UserID, 32, 32), }).ToList(); //Roles should be visible to Administrators or Group Owner if (isAdmin || UserInfo.Social.Roles.Any(role => role.IsOwner)) { var roles = TestableRoleController.Instance.GetRolesBasicSearch(portalId, numResults, q); results.AddRange(from roleInfo in roles where isAdmin || UserInfo.Social.Roles.SingleOrDefault( ur => ur.RoleID == roleInfo.RoleID && ur.IsOwner) != null select new SearchResult { id = "role-" + roleInfo.RoleID, name = roleInfo.RoleName, iconfile = TestableGlobals.Instance.ResolveUrl( string.IsNullOrEmpty(roleInfo.IconFile) ? "~/images/no_avatar.gif" : PortalSettings.HomeDirectory.TrimEnd('/') + "/" + roleInfo.IconFile) }); } return(Json(results.OrderBy(sr => sr.name), JsonRequestBehavior.AllowGet)); } catch (Exception exc) { DnnLog.Error(exc); return(Json(null, JsonRequestBehavior.AllowGet)); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (PortalController.IsMemberOfPortalGroup(PortalId) && PortalController.GetEffectivePortalId(PortalId) != PortalId) { dnnUserSettings.Visible = false; CannotChangeSettingsMessage.Visible = true; } manageServiceItem.Visible = usersControl.Visible = !IsHostMenu; }
public HttpResponseMessage CountNotifications() { try { var portalId = PortalController.GetEffectivePortalId(UserController.Instance.GetCurrentUserInfo().PortalID); int notifications = NotificationsController.Instance.CountNotifications(this.UserInfo.UserID, portalId); return(this.Request.CreateResponse(HttpStatusCode.OK, notifications)); } catch (Exception exc) { Logger.Error(exc); return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
protected void DeleteFile(string filePath, string folderUrl) { var folderManager = FolderManager.Instance; int effectivePortalId = PortalController.GetEffectivePortalId(Settings.PortalId); IFolderInfo folderInfo; folderInfo = folderManager.GetFolder(effectivePortalId, folderUrl); string filename = Path.GetFileName(filePath); IFileInfo file = FileManager.Instance.GetFile(folderInfo, filename); FileManager.Instance.DeleteFile(file); }
public ActionResult CountUnreadMessages() { try { var portalId = PortalController.GetEffectivePortalId(UserController.GetCurrentUserInfo().PortalID); var unreadMessages = InternalMessagingController.Instance.CountUnreadMessages(UserInfo.UserID, portalId); return(Json(unreadMessages, JsonRequestBehavior.AllowGet)); } catch (Exception exc) { DnnLog.Error(exc); return(Json(null, JsonRequestBehavior.AllowGet)); } }
public ActionResult CountNotifications() { try { var portalId = PortalController.GetEffectivePortalId(UserController.GetCurrentUserInfo().PortalID); var notifications = NotificationsController.Instance.CountNotifications(UserInfo.UserID, portalId); return(Json(notifications, JsonRequestBehavior.AllowGet)); } catch (Exception exc) { DnnLog.Error(exc); return(Json(null, JsonRequestBehavior.AllowGet)); } }
public HttpResponseMessage CountUnreadMessages() { try { var portalId = PortalController.GetEffectivePortalId(UserController.GetCurrentUserInfo().PortalID); var unreadMessages = InternalMessagingController.Instance.CountUnreadMessages(UserInfo.UserID, portalId); return(Request.CreateResponse(HttpStatusCode.OK, unreadMessages)); } catch (Exception exc) { Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage CountUnreadMessages() { try { var portalId = PortalController.GetEffectivePortalId(UserController.Instance.GetCurrentUserInfo().PortalID); var unreadMessages = InternalMessagingController.Instance.CountUnreadMessages(this.UserInfo.UserID, portalId); return(this.Request.CreateResponse(HttpStatusCode.OK, unreadMessages)); } catch (Exception ex) { var message = "An unexpected error occurred while attempting to , consult the server logs for more information."; Logger.Error(message, ex); return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, message)); } }
public HttpResponseMessage UpdateUserSettings(UserSettings settings) { try { var controller = PersonaBarUserSettingsController.Instance; var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId); controller.UpdatePersonaBarUserSettings(settings, UserInfo.UserID, portalId); return(Request.CreateResponse(HttpStatusCode.OK, new {})); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex.Message)); } }
public UserInfo GetUser(int portalId, int userId, bool useCache = true) { if (useCache) { return(UserController.GetUserById(portalId, userId)); } // Copied from DNN. Turns out there is no other way to ensure that we don't use cached user info var effectivePortalId = PortalController.GetEffectivePortalId(portalId); var user = MembershipProvider.Instance().GetUser(effectivePortalId, userId); if (user != null) { user.PortalID = portalId; } return(user); }
public ActionResult Archived(int afterMessageId, int numberOfRecords) { try { var messageBoxView = InternalMessagingController.Instance.GetArchivedMessages(UserInfo.UserID, afterMessageId, numberOfRecords); var portalId = PortalController.GetEffectivePortalId(UserController.GetCurrentUserInfo().PortalID); messageBoxView.TotalNewThreads = InternalMessagingController.Instance.CountUnreadMessages(UserInfo.UserID, portalId); messageBoxView.TotalConversations = InternalMessagingController.Instance.CountArchivedMessages(UserInfo.UserID, portalId); return(Json(messageBoxView, JsonRequestBehavior.AllowGet)); } catch (Exception exc) { DnnLog.Error(exc); return(Json(null, JsonRequestBehavior.AllowGet)); } }
public HttpResponseMessage Archived(int afterMessageId, int numberOfRecords) { try { var messageBoxView = InternalMessagingController.Instance.GetArchivedMessages(UserInfo.UserID, afterMessageId, numberOfRecords); var portalId = PortalController.GetEffectivePortalId(UserController.GetCurrentUserInfo().PortalID); messageBoxView.TotalNewThreads = InternalMessagingController.Instance.CountUnreadMessages(UserInfo.UserID, portalId); messageBoxView.TotalConversations = InternalMessagingController.Instance.CountArchivedMessages(UserInfo.UserID, portalId); return(Request.CreateResponse(HttpStatusCode.OK, messageBoxView)); } catch (Exception exc) { Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage Search(string q) { try { var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId); var isAdmin = UserInfo.IsSuperUser || UserInfo.IsInRole("Administrators"); const int numResults = 10; // GetUsersAdvancedSearch doesn't accept a comma or a single quote in the query so we have to remove them for now. See issue 20224. q = q.Replace(",", "").Replace("'", ""); if (q.Length == 0) { return(Request.CreateResponse <SearchResult>(HttpStatusCode.OK, null)); } var results = UserController.Instance.GetUsersBasicSearch(portalId, 0, numResults, "DisplayName", true, "DisplayName", q) .Select(user => new SearchResult { id = "user-" + user.UserID, name = user.DisplayName, iconfile = string.Format(Globals.UserProfilePicRelativeUrl(), user.UserID, 32, 32), }).ToList(); //Roles should be visible to Administrators or User in the Role. var roles = RoleController.Instance.GetRolesBasicSearch(portalId, numResults, q); results.AddRange(from roleInfo in roles where isAdmin || UserInfo.Social.Roles.SingleOrDefault(ur => ur.RoleID == roleInfo.RoleID) != null select new SearchResult { id = "role-" + roleInfo.RoleID, name = roleInfo.RoleName, iconfile = TestableGlobals.Instance.ResolveUrl(string.IsNullOrEmpty(roleInfo.IconFile) ? "~/images/no_avatar.gif" : PortalSettings.HomeDirectory.TrimEnd('/') + "/" + roleInfo.IconFile) }); return(Request.CreateResponse(HttpStatusCode.OK, results.OrderBy(sr => sr.name))); } catch (Exception exc) { Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage Archived(int afterMessageId, int numberOfRecords) { try { var messageBoxView = InternalMessagingController.Instance.GetArchivedMessages(this.UserInfo.UserID, afterMessageId, numberOfRecords); var portalId = PortalController.GetEffectivePortalId(UserController.Instance.GetCurrentUserInfo().PortalID); messageBoxView.TotalNewThreads = InternalMessagingController.Instance.CountUnreadMessages(this.UserInfo.UserID, portalId); messageBoxView.TotalConversations = InternalMessagingController.Instance.CountArchivedConversations(this.UserInfo.UserID, portalId); return(this.Request.CreateResponse(HttpStatusCode.OK, messageBoxView)); } catch (Exception ex) { var message = "An unexpected error occurred while attempting to fetch the archived box."; Logger.Error(message, ex); return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, message)); } }
public IList <Relationship> GetRelationshipsByPortalId(int portalId) { var pid = portalId; if (PortalController.IsMemberOfPortalGroup(portalId)) { pid = PortalController.GetEffectivePortalId(portalId); } var cacheArgs = new CacheItemArgs(string.Format(DataCache.RelationshipByPortalIDCacheKey, pid), DataCache.RelationshipByPortalIDCacheTimeOut, DataCache.RelationshipByPortalIDCachePriority, pid); return(CBO.GetCachedObject <IList <Relationship> >(cacheArgs, c => CBO.FillCollection <Relationship>( _dataService.GetRelationshipsByPortalId( (int)c.ParamList[0])))); }