public HttpResponseMessage SetUserMode(string mode) { var apiResponse = new DTO.ApiResponse <bool>(); try { switch (mode.ToLower()) { case "view": case "edit": case "layout": var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); personalization.Profile["Usability:UserMode" + PortalSettings.PortalId] = mode.ToUpper(); personalization.IsModified = true; personalizationController.SaveProfile(personalization); apiResponse.Success = true; break; } } catch (Exception err) { apiResponse.Success = false; apiResponse.Message = err.Message; Exceptions.LogException(err); } return(Request.CreateResponse(HttpStatusCode.OK, apiResponse)); }
public HttpResponseMessage SwitchLanguage(SwitchLanguageDTO dto) { if (UserController.GetCurrentUserInfo().IsSuperUser) { try { if ((!string.IsNullOrEmpty(dto.Language))) { var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); personalization.Profile["Usability:UICulture"] = dto.Language; personalization.IsModified = true; personalizationController.SaveProfile(personalization); return(Request.CreateResponse(HttpStatusCode.OK)); } } catch (System.Threading.ThreadAbortException) { //Do nothing we are not logging ThreadAbortxceptions caused by redirects } catch (Exception ex) { Exceptions.LogException(ex); } } return(Request.CreateResponse(HttpStatusCode.InternalServerError)); }
private void ToggleUserMode(string mode) { var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); personalization.Profile["Usability:UserMode" + PortalSettings.PortalId] = mode.ToUpper(); personalization.IsModified = true; personalizationController.SaveProfile(personalization); }
public HttpResponseMessage SetUserSetting(UserSetting setting) { var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(this.UserInfo.UserID, this.PortalSettings.PortalId); personalization.Profile[setting.Key + this.PortalSettings.PortalId] = setting.Value; personalization.IsModified = true; personalizationController.SaveProfile(personalization); return this.Request.CreateResponse(HttpStatusCode.OK); }
public static void ToggleUserMode(PortalSettings portalSettings, string mode = "VIEW") { DotNetNuke.Services.Personalization.PersonalizationController personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); DotNetNuke.Services.Personalization.PersonalizationInfo personalization = personalizationController.LoadProfile(portalSettings.UserInfo.UserID, portalSettings.PortalId); if (personalization.Profile["Usability:UserMode" + portalSettings.PortalId] != null && personalization.Profile["Usability:UserMode" + portalSettings.PortalId].ToString() != mode.ToUpper()) { personalization.Profile["Usability:UserMode" + portalSettings.PortalId] = mode.ToUpper(); personalization.IsModified = true; personalizationController.SaveProfile(personalization); } }
public HttpResponseMessage SaveBookmark(BookmarkDTO bookmark) { if (string.IsNullOrEmpty(bookmark.Bookmark)) { bookmark.Bookmark = string.Empty; } var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); personalization.Profile["ControlBar:" + bookmark.Title + PortalSettings.PortalId] = bookmark.Bookmark; personalization.IsModified = true; personalizationController.SaveProfile(personalization); return(Request.CreateResponse(HttpStatusCode.OK)); }
public void SaveBookMark(int portalId, int userId, string bookmarkTitle, string bookmarkValue) { var ensuredBookmarkValue = bookmarkValue; if (bookmarkTitle == BookmarkModulesTitle) { ensuredBookmarkValue = EnsureBookmarkValue(portalId, ensuredBookmarkValue); } var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(userId, portalId); personalization.Profile["ControlBar:" + bookmarkTitle + portalId] = ensuredBookmarkValue; personalization.IsModified = true; personalizationController.SaveProfile(personalization); }
private IEnumerable <KeyValuePair <string, PortalDesktopModuleInfo> > GetBookmarkedModules(int portalId, int userId) { var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(userId, portalId); var bookmarkItems = personalization.Profile["ControlBar:" + BookmarkModulesTitle + portalId]; if (bookmarkItems == null) { return(new List <KeyValuePair <string, PortalDesktopModuleInfo> >()); } var bookmarkItemsKeys = bookmarkItems.ToString().Split(',').ToList(); var bookmarkedModules = DesktopModuleController.GetPortalDesktopModules(PortalSettings.Current.PortalId) .Where(dm => bookmarkItemsKeys.Contains(dm.Value.DesktopModuleID.ToString(CultureInfo.InvariantCulture))); return(bookmarkedModules); }
public HttpResponseMessage GetUserSetting(string key) { var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); var value = personalization.Profile[key + PortalSettings.PortalId]; if (value == null) { return(Request.CreateResponse(HttpStatusCode.OK, new { Value = false })); } var userSetting = new UserSetting { Key = key, Value = value }; return(Request.CreateResponse(HttpStatusCode.OK, userSetting)); }
private void ToggleUserMode(string mode) { var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); personalization.Profile["Usability:UserMode" + PortalSettings.PortalId] = mode.ToUpper(); personalization.IsModified = true; personalizationController.SaveProfile(personalization); }
public HttpResponseMessage SaveBookmark(BookmarkDTO bookmark) { if (string.IsNullOrEmpty(bookmark.Bookmark)) bookmark.Bookmark = string.Empty; var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); personalization.Profile["ControlBar:" + bookmark.Title + PortalSettings.PortalId] = bookmark.Bookmark; personalization.IsModified = true; personalizationController.SaveProfile(personalization); return Request.CreateResponse(HttpStatusCode.OK); }
public HttpResponseMessage SwitchLanguage(SwitchLanguageDTO dto) { if (UserController.GetCurrentUserInfo().IsSuperUser) { try { if ((!string.IsNullOrEmpty(dto.Language))) { var personalizationController = new DotNetNuke.Services.Personalization.PersonalizationController(); var personalization = personalizationController.LoadProfile(UserInfo.UserID, PortalSettings.PortalId); personalization.Profile["Usability:UICulture"] = dto.Language; personalization.IsModified = true; personalizationController.SaveProfile(personalization); return Request.CreateResponse(HttpStatusCode.OK); } } catch (System.Threading.ThreadAbortException) { //Do nothing we are not logging ThreadAbortxceptions caused by redirects } catch (Exception ex) { Exceptions.LogException(ex); } } return Request.CreateResponse(HttpStatusCode.InternalServerError); }