public static string MarkAsSolution(string pageId) { if (MembershipHelper.IsAuthenticated()) { var m = Member.GetCurrentMember(); var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(pageId))); if (forumPost != null) { var forumTopic = _mapper.MapForumTopic(new Node(forumPost.ParentId.ToInt32())); // If this current member id doesn't own the topic then ignore, also // if the topic is already solved then ignore. if (m.Id == forumTopic.Owner.MemberId && !forumTopic.IsSolved) { // Get a user to save both documents with var usr = new User(0); // First mark the post as the solution var p = new Document(forumPost.Id); p.getProperty("forumPostIsSolution").Value = 1; p.Publish(usr); library.UpdateDocumentCache(p.Id); // Now update the topic var t = new Document(forumTopic.Id); t.getProperty("forumTopicSolved").Value = 1; t.Publish(usr); library.UpdateDocumentCache(t.Id); return library.GetDictionaryItem("Updated"); } } } return library.GetDictionaryItem("Error"); }
protected void BtnMoveClick(object sender, EventArgs e) { if (Category.Id != ddlCategories.SelectedValue.ToInt32()) { // Get the document you will move by its ID var doc = new Document(Topic.Id); // Create a user we can use for both var user = new User(0); // The new parent ID var newParentId = ddlCategories.SelectedValue.ToInt32(); // Now update the topic parent category ID doc.getProperty("forumTopicParentCategoryID").Value = newParentId; // publish application node doc.Publish(user); // Move the document the new parent doc.Move(newParentId); // update the document cache so its available in the XML umbraco.library.UpdateDocumentCache(doc.Id); // Redirect and show message Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicHasBeenMovedText"))); } else { // Can't move as they have selected the category that the topic is already in Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicAlreadyInThisCategory"))); } }
/// <summary> /// Processes a request to update the password for a membership user. /// </summary> /// <param name="username">The user to update the password for.</param> /// <param name="oldPassword">The current password for the specified user.</param> /// <param name="newPassword">The new password for the specified user.</param> /// <returns> /// true if the password was updated successfully; otherwise, false. /// </returns> /// <remarks> /// During installation the application will not be configured, if this is the case and the 'default' password /// is stored in the database then we will validate the user - this will allow for an admin password reset if required /// </remarks> protected override bool PerformChangePassword(string username, string oldPassword, string newPassword) { if (ApplicationContext.Current.IsConfigured == false && oldPassword == "default" || ValidateUser(username, oldPassword)) { var args = new ValidatePasswordEventArgs(username, newPassword, false); OnValidatingPassword(args); if (args.Cancel) { if (args.FailureInformation != null) throw args.FailureInformation; throw new MembershipPasswordException("Change password canceled due to password validation failure."); } var user = new User(username); //encrypt/hash the new one string salt; var encodedPassword = EncryptOrHashNewPassword(newPassword, out salt); //Yes, it's true, this actually makes a db call to set the password user.Password = FormatPasswordForStorage(encodedPassword, salt); //call this just for fun. user.Save(); return true; } return false; }
public override void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime) { base.Run(workflowInstance, runtime); var body = Helper.Instance.RenderTemplate(RenderTemplate); IList<string> files = new List<string>(); foreach(var nodeId in ((UmbracoWorkflowInstance) workflowInstance).CmsNodes) { var node = new CMSNode(nodeId); if(node.IsMedia()) { files.Add(IOHelper.MapPath((string) new Media(nodeId).getProperty("umbracoFile").Value)); } } var f = new User(From).Email; foreach(var r in GetRecipients()) { var mail = new MailMessage(f, r) {Subject = Subject, IsBodyHtml = true, Body = body}; foreach(var file in files) { var attach = new Attachment(file); mail.Attachments.Add(attach); } var smtpClient = new SmtpClient(); smtpClient.Send(mail); } runtime.Transition(workflowInstance, this, "done"); }
private static Member CreateNewMember(RegisterModel model) { var user = new User(0); var mt = MemberType.GetByAlias(model.MemberTypeAlias) ?? MemberType.MakeNew(user, model.MemberTypeAlias); var member = Member.MakeNew(model.Username, mt, user); if (model.Name != null) { member.Text = model.Name; } member.Email = model.Email; member.Password = model.Password; if (model.MemberProperties != null) { foreach (var property in model.MemberProperties.Where(p => p.Value != null)) { member.getProperty(property.Alias).Value = property.Value; } } member.Save(); return member; }
protected void btnSubmit_Click(object sender, EventArgs e) { var member = PrizeMemberAuthUtils.GetMemberData(); //if (HttpContext.Current.User.Identity.IsAuthenticated) if (member != null) { var memberName = member.Firstname + " " + member.Surname; Node current = Node.GetCurrent(); DocumentType dt = new DocumentType(3285); umbraco.BusinessLogic.User u = new umbraco.BusinessLogic.User(1); Document doc = Document.MakeNew(memberName + " " + DateTime.Now.ToString("dd-MM-yy HH:MM:ss"), dt, u, current.Id); doc.getProperty("commentName").Value = memberName; if (member.Photo != "") { doc.getProperty("commentImage").Value = member.Photo.Replace("http://web106.sand.studiocoast.com.au", "https://diypt.com.au").Replace("http://diypt.com.au", "https://diypt.com.au"); } else { doc.getProperty("commentImage").Value = @"\images\profile.jpg"; } doc.getProperty("commentText").Value = commentText.Text; //doc.Save(); doc.Publish(u); PrizeEmail.SendBlogComment(current.Name, memberName, commentText.Text); //commentText.Text = ""; Response.Redirect(Request.RawUrl); } }
public Media HandleMedia(int parentNodeId, PostedMediaFile postedFile, User user) { // Check to see if a file exists Media media; string mediaName = !string.IsNullOrEmpty(postedFile.DisplayName) ? postedFile.DisplayName : ExtractTitleFromFileName(postedFile.FileName); if (postedFile.ReplaceExisting && TryFindExistingMedia(parentNodeId, postedFile.FileName, out media)) { // Do nothing as existing media is returned } else { media = Media.MakeNew(mediaName, MediaType.GetByAlias(MediaTypeAlias), user, parentNodeId); } if (postedFile.ContentLength > 0) DoHandleMedia(media, postedFile, user); media.XmlGenerate(new XmlDocument()); return media; }
public static void ReadFromDisk(string path) { if (Directory.Exists(path)) { User user = new User(0); foreach (string file in Directory.GetFiles(path, "*.config")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file); XmlNode node = xmlDoc.SelectSingleNode("//Template"); if (node != null) { Template.Import(node,user); } } foreach (string folder in Directory.GetDirectories(path)) { ReadFromDisk(folder); } } }
/// <summary> /// Adds the specified log item to the log. /// </summary> /// <param name="type">The log type.</param> /// <param name="user">The user adding the item.</param> /// <param name="nodeId">The affected node id.</param> /// <param name="comment">Comment.</param> public static void Add(LogTypes type, User user, int nodeId, string comment) { if (Instance.ExternalLogger != null) { Instance.ExternalLogger.Add(type, user, nodeId, comment); if (UmbracoConfig.For.UmbracoSettings().Logging.ExternalLoggerEnableAuditTrail == false) { AddLocally(type, user, nodeId, comment); } } else { if (UmbracoConfig.For.UmbracoSettings().Logging.EnableLogging == false) return; if (UmbracoConfig.For.UmbracoSettings().Logging.DisabledLogTypes.Any(x => x.LogTypeAlias.InvariantEquals(type.ToString())) == false) { if (comment != null && comment.Length > 3999) comment = comment.Substring(0, 3955) + "..."; if (UmbracoConfig.For.UmbracoSettings().Logging.EnableAsyncLogging) { ThreadPool.QueueUserWorkItem( delegate { AddSynced(type, user == null ? 0 : user.Id, nodeId, comment); }); return; } AddSynced(type, user == null ? 0 : user.Id, nodeId, comment); } } }
/// <summary> /// Adds the specified log item to the log. /// </summary> /// <param name="type">The log type.</param> /// <param name="user">The user adding the item.</param> /// <param name="nodeId">The affected node id.</param> /// <param name="comment">Comment.</param> public static void Add(LogTypes type, User user, int nodeId, string comment) { if (Instance.ExternalLogger != null) { Instance.ExternalLogger.Add(type, user, nodeId, comment); if (!UmbracoSettings.ExternalLoggerLogAuditTrail) { AddLocally(type, user, nodeId, comment); } } else { if (!UmbracoSettings.EnableLogging) return; if (UmbracoSettings.DisabledLogTypes != null && UmbracoSettings.DisabledLogTypes.SelectSingleNode(String.Format("//logTypeAlias [. = '{0}']", type.ToString().ToLower())) == null) { if (comment != null && comment.Length > 3999) comment = comment.Substring(0, 3955) + "..."; if (UmbracoSettings.EnableAsyncLogging) { ThreadPool.QueueUserWorkItem( delegate { AddSynced(type, user == null ? 0 : user.Id, nodeId, comment); }); return; } AddSynced(type, user == null ? 0 : user.Id, nodeId, comment); } } }
private void initialize(int UserId) { XmlDocument configFile = config.MetaBlogConfigFile; XmlNode channelXml = configFile.SelectSingleNode(string.Format("//channel [user = '******']", UserId)); if (channelXml != null) { Id = UserId; User = new User(UserId); Name = channelXml.SelectSingleNode("./name").FirstChild.Value; StartNode = int.Parse(channelXml.SelectSingleNode("./startNode").FirstChild.Value); FullTree = bool.Parse(channelXml.SelectSingleNode("./fullTree").FirstChild.Value); DocumentTypeAlias = channelXml.SelectSingleNode("./documentTypeAlias").FirstChild.Value; if (channelXml.SelectSingleNode("./fields/categories").FirstChild != null) FieldCategoriesAlias = channelXml.SelectSingleNode("./fields/categories").FirstChild.Value; if (channelXml.SelectSingleNode("./fields/description").FirstChild != null) FieldDescriptionAlias = channelXml.SelectSingleNode("./fields/description").FirstChild.Value; if (channelXml.SelectSingleNode("./fields/excerpt") != null && channelXml.SelectSingleNode("./fields/excerpt").FirstChild != null) FieldExcerptAlias = channelXml.SelectSingleNode("./fields/excerpt").FirstChild.Value; XmlNode mediaSupport = channelXml.SelectSingleNode("./mediaObjectSupport"); ImageSupport = bool.Parse(mediaSupport.Attributes.GetNamedItem("enabled").Value); MediaFolder = int.Parse(mediaSupport.Attributes.GetNamedItem("folderId").Value); MediaTypeAlias = mediaSupport.Attributes.GetNamedItem("mediaTypeAlias").Value; MediaTypeFileProperty = mediaSupport.Attributes.GetNamedItem("mediaTypeFileProperty").Value; } else throw new ArgumentException(string.Format("No channel found for user with id: '{0}'", UserId)); }
/// <summary> /// Initializes a new instance of the DocumentVersionList class. /// </summary> /// <param name="Version">Unique version id</param> /// <param name="Date">Version createdate</param> /// <param name="Text">Version name</param> /// <param name="User">Creator</param> public DocumentVersionList(Guid Version, DateTime Date, string Text, User User) { _version = Version; _date = Date; _text = Text; _user = User; }
public bool IsCriteriaValid(UmbracoWorkflowInstantiationCriteria criteria, User u) { if(criteria.Users.Count > 0) Log.Debug(string.Format("Validating criteria for users {0}. Current user {1}", string.Join(", ", criteria.Users), u.Id)); Log.Debug(string.Format("Users contains user {0}", criteria.Users.Contains(u.Id))); if(criteria.UserTypes.Count > 0) Log.Debug(string.Format("User type criteria {0} current user {1}", string.Join(", ", criteria.UserTypes), u.UserType.Id)); Log.Debug(string.Format("UserTypes contains user {0}", criteria.UserTypes.Contains(u.UserType.Id))); var userMatches = UserMatches(criteria.Users, u); var userTypeMatches = UserTypeMatches(criteria.UserTypes, u); Log.Debug(string.Format("return: {0} and {1}", userMatches, userTypeMatches)); if((criteria.Users.Count > 0) && (criteria.UserTypes.Count > 0)) { if (criteria.CriteriaOperand == "and") { return userMatches && userTypeMatches; } return userMatches || userTypeMatches; } if(criteria.Users.Count > 0) { return userMatches; } if(criteria.UserTypes.Count > 0) { return userTypeMatches; } return true; }
internal static void MakeNew(User user, IEnumerable<CMSNode> nodes, char permissionKey, bool raiseEvents) { var asArray = nodes.ToArray(); foreach (var node in asArray) { var parameters = new[] { SqlHelper.CreateParameter("@userId", user.Id), SqlHelper.CreateParameter("@nodeId", node.Id), SqlHelper.CreateParameter("@permission", permissionKey.ToString()) }; // Method is synchronized so exists remains consistent (avoiding race condition) var exists = SqlHelper.ExecuteScalar<int>( "SELECT COUNT(userId) FROM umbracoUser2nodePermission WHERE userId = @userId AND nodeId = @nodeId AND permission = @permission", parameters) > 0; if (exists) return; SqlHelper.ExecuteNonQuery( "INSERT INTO umbracoUser2nodePermission (userId, nodeId, permission) VALUES (@userId, @nodeId, @permission)", parameters); } if (raiseEvents) { OnNew(new UserPermission(user, asArray, new[] { permissionKey }), new NewEventArgs()); } }
public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user) { // Get umbracoFile property var propertyId = media.getProperty("umbracoFile").Id; // Get paths var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName); var ext = Path.GetExtension(destFilePath).Substring(1); //var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath); //var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath); // Set media properties media.getProperty("umbracoFile").Value = FileSystem.GetUrl(destFilePath); media.getProperty("umbracoBytes").Value = uploadedFile.ContentLength; if (media.getProperty("umbracoExtension") != null) media.getProperty("umbracoExtension").Value = ext; if (media.getProperty("umbracoExtensio") != null) media.getProperty("umbracoExtensio").Value = ext; FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting); // Save media media.Save(); }
public static void ReadFromDisk(string path) { if (Directory.Exists(path)) { User u = new User(0) ; foreach (string file in Directory.GetFiles(path, "*.config")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file); XmlNode node = xmlDoc.SelectSingleNode("//DataType"); if (node != null) { DataTypeDefinition d = Import(node, u); if (d != null) { d.Save(); } else { Log.Add(LogTypes.Debug, 0, string.Format("NULL NODE FOR {0}", file)); } } } } }
public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user) { // Get umbracoFile property var propertyId = media.getProperty(Constants.Conventions.Media.File).Id; // Get paths var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName); var ext = Path.GetExtension(destFilePath).Substring(1); //var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath); //var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath); // Set media properties media.getProperty(Constants.Conventions.Media.File).Value = FileSystem.GetUrl(destFilePath); media.getProperty(Constants.Conventions.Media.Bytes).Value = uploadedFile.ContentLength; if (media.getProperty(Constants.Conventions.Media.Extension) != null) media.getProperty(Constants.Conventions.Media.Extension).Value = ext; // Legacy: The 'extensio' typo applied to MySQL (bug in install script, prior to v4.6.x) if (media.getProperty("umbracoExtensio") != null) media.getProperty("umbracoExtensio").Value = ext; FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting); // Save media media.Save(); }
protected void SendMail(string body) { var from = new User(From).Email; foreach (var person in GetRecipients()) SendEmail(from, person, Subject, body, true); }
public bool Save() { umbraco.BusinessLogic.User myUser = new umbraco.BusinessLogic.User(0); umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Delete, myUser, 0, "Xml save started"); int id = cms.businesslogic.packager.CreatedPackage.MakeNew(Alias).Data.Id; m_returnUrl = string.Format("developer/packages/editPackage.aspx?id={0}", id); return true; }
public bool Save() { umbraco.BusinessLogic.User myUser = new umbraco.BusinessLogic.User(0); umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Delete, myUser, 0, "Xml save started"); int id = cms.businesslogic.packager.CreatedPackage.MakeNew(Alias).Data.Id; m_returnUrl = string.Format("developer/packages/editPackage.aspx?id={0}", id); return(true); }
/// <summary> /// Adds a new membership user to the data source. /// </summary> /// <param name="memberTypeAlias"></param> /// <param name="username">The user name for the new user.</param> /// <param name="password">The password for the new user.</param> /// <param name="email">The e-mail address for the new user.</param> /// <param name="passwordQuestion">The password question for the new user.</param> /// <param name="passwordAnswer">The password answer for the new user</param> /// <param name="isApproved">Whether or not the new user is approved to be validated.</param> /// <param name="providerUserKey">The unique identifier from the membership data source for the user.</param> /// <param name="status">A <see cref="T:System.Web.Security.MembershipCreateStatus"></see> enumeration value indicating whether the user was created successfully.</param> /// <returns> /// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the information for the newly created user. /// </returns> public MembershipUser CreateUser(string memberTypeAlias, string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { if (Member.GetMemberFromLoginName(username) != null) { status = MembershipCreateStatus.DuplicateUserName; } else if (Member.GetMemberFromEmail(email) != null && RequiresUniqueEmail) { status = MembershipCreateStatus.DuplicateEmail; } else { var memberType = MemberType.GetByAlias(memberTypeAlias); if (memberType == null) { throw new InvalidOperationException("Could not find a member type with alias " + memberTypeAlias + ". Ensure your membership provider configuration is up to date and that the default member type exists."); } Member m = Member.MakeNew(username, email, memberType, User.GetUser(0)); m.Password = password; MembershipUser mUser = ConvertToMembershipUser(m); // custom fields if (!String.IsNullOrEmpty(m_PasswordRetrievalQuestionPropertyTypeAlias)) { UpdateMemberProperty(m, m_PasswordRetrievalQuestionPropertyTypeAlias, passwordQuestion); } if (!String.IsNullOrEmpty(m_PasswordRetrievalAnswerPropertyTypeAlias)) { UpdateMemberProperty(m, m_PasswordRetrievalAnswerPropertyTypeAlias, passwordAnswer); } if (!String.IsNullOrEmpty(m_ApprovedPropertyTypeAlias)) { UpdateMemberProperty(m, m_ApprovedPropertyTypeAlias, isApproved); } if (!String.IsNullOrEmpty(m_LastLoginPropertyTypeAlias)) { mUser.LastActivityDate = DateTime.Now; UpdateMemberProperty(m, m_LastLoginPropertyTypeAlias, mUser.LastActivityDate); } // save m.Save(); status = MembershipCreateStatus.Success; return(mUser); } return(null); }
public void Authorize() { CurrentUser = umbraco.BusinessLogic.User.GetCurrent(); if (CurrentUser == null) { HttpContext.Current.Response.StatusCode = 403; HttpContext.Current.Response.End(); } }
/// <summary> /// Copies the usertype permissions for single user /// </summary> /// <param name="user">The user.</param> public static void CopyPermissionsForSingleUser(User user) { var permissions = GetUserTypePermissions(user.UserType); foreach (var permission in permissions) { Permission.MakeNew(user, new CMSNode(permission.NodeId), permission.PermissionId); user.initCruds(); } }
protected void AddCustomMemberGroup() { //Admin user var adminUser = new User("admin"); //Let's add our Member Group var customMemberGroup = MemberGroup.MakeNew("CWS-Members", adminUser); //Save it customMemberGroup.Save(); }
/// <summary> /// Check if th user is logged in, if they are, return their language specified in the database. /// If they aren't logged in, check the current thread culture and return it, however if that is /// null, then return the default Umbraco culture. /// </summary> private static string GetLanguage(User u) { if (u != null) { return u.Language; } var language = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; if (string.IsNullOrEmpty(language)) language = UmbracoDefaultUiLanguage; return language; }
protected void AddCustomMemberGroup() { //Admin user var adminUser = new User(0); //Let's add our Member Group var customMemberGroup = MemberGroup.MakeNew(ConfigHelper.GetCWSMemberGroupName(), adminUser); //Save it customMemberGroup.Save(); }
/// <summary> /// Gets the current Culture for the logged-in users /// </summary> /// <param name="u">The user.</param> /// <returns></returns> public static string Culture(User u) { XmlDocument langFile = getLanguageFile(u.Language); try { return langFile.SelectSingleNode("/language").Attributes.GetNamedItem("culture").Value; } catch { return string.Empty; } }
public void EnsureInitialized(User user, string previewSet, bool validate, Action initialize) { lock (_initLock) { if (_initialized) return; _userId = user.Id; ValidPreviewSet = UpdatePreviewPaths(new Guid(previewSet), validate); initialize(); _initialized = true; } }
public virtual bool CanHandleMedia(int parentNodeId, PostedMediaFile postedFile, User user) { try { var parentNode = new Media(parentNodeId); return parentNodeId <= -1 || user.Applications.Any(app => app.alias.ToLower() == Constants.Applications.Media) && (user.StartMediaId <= 0 || ("," + parentNode.Path + ",").Contains("," + user.StartMediaId + ",")) && parentNode.ContentType.AllowedChildContentTypeIDs.Contains(MediaType.GetByAlias(MediaTypeAlias).Id); } catch { return false; } }
public override void DoHandleMedia(Media media, PostedMediaFile postedFile, User user) { // Set media property to upload the file as well as set all related properties media.MediaItem.SetValue("umbracoFile", postedFile.FileName, postedFile.InputStream); // Copy back the values from the internal IMedia to ensure that the values are persisted when saved foreach (var property in media.MediaItem.Properties) { media.getProperty(property.Alias).Value = property.Value; } // Save media (using legacy media object to ensure the usage of the legacy events). media.Save(); }
/// <summary> /// Create a new MemberType /// </summary> /// <param name="Text">The name of the MemberType</param> /// <param name="u">Creator of the MemberType</param> public static MemberType MakeNew(User u,string Text) { int ParentId= -1; int level = 1; Guid uniqueId = Guid.NewGuid(); CMSNode n = CMSNode.MakeNew(ParentId, _objectType, u.Id, level,Text, uniqueId); ContentType.Create(n.Id, Text,""); MemberType mt = new MemberType(n.Id); mt.IconUrl = "member.gif"; NewEventArgs e = new NewEventArgs(); mt.OnNew(e); return mt; }
/// <summary> /// Gets a summary of all the pages from the blog with the spefied blogId. /// </summary> /// <param name="blogid">The blogid.</param> /// <param name="username">The username.</param> /// <param name="password">The password.</param> /// <returns></returns> public wpPageSummary[] getPageList(string blogid, string username, string password) { if (User.validateCredentials(username, password, false)) { ArrayList blogPosts = new ArrayList(); ArrayList blogPostsObjects = new ArrayList(); User u = new User(username); Channel userChannel = new Channel(u.Id); Document rootDoc; if (userChannel.StartNode > 0) rootDoc = new Document(userChannel.StartNode); else rootDoc = new Document(u.StartNodeId); //store children array here because iterating over an Array object is very inneficient. var c = rootDoc.Children; foreach (Document d in c) { int count = 0; blogPosts.AddRange( findBlogPosts(userChannel, d, u.Name, ref count, 999, userChannel.FullTree)); } blogPosts.Sort(new DocumentSortOrderComparer()); foreach (Object o in blogPosts) { Document d = (Document)o; wpPageSummary p = new wpPageSummary(); p.dateCreated = d.CreateDateTime; p.page_title = d.Text; p.page_id = d.Id; p.page_parent_id = d.Parent.Id; blogPostsObjects.Add(p); } return (wpPageSummary[])blogPostsObjects.ToArray(typeof(wpPageSummary)); } else { return null; } }
public void Get_Root_Docs() { var user = new User(0); var mType = global::umbraco.cms.businesslogic.media.MediaType.MakeNew(user, "TestMediaType"); var mRoot1 = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot1", mType, user, -1); var mRoot2 = global::umbraco.cms.businesslogic.media.Media.MakeNew("MediaRoot2", mType, user, -1); var mChild1 = global::umbraco.cms.businesslogic.media.Media.MakeNew("Child1", mType, user, mRoot1.Id); var mChild2 = global::umbraco.cms.businesslogic.media.Media.MakeNew("Child2", mType, user, mRoot2.Id); var ctx = GetUmbracoContext("/test", 1234); var mediaStore = new DefaultPublishedMediaStore(); var roots = mediaStore.GetRootDocuments(ctx); Assert.AreEqual(2, roots.Count()); Assert.IsTrue(roots.Select(x => x.Id).ContainsAll(new[] {mRoot1.Id, mRoot2.Id})); }
/// <summary> /// Makes sure the user exists with the id specified /// </summary> /// <param name="strID"></param> private void CheckUser(string strID) { int id; bool parsed = false; umbraco.BusinessLogic.User oUser = null; if (parsed = int.TryParse(strID, out id)) { oUser = umbraco.BusinessLogic.User.GetUser(id); } if (oUser == null || oUser.UserType == null || !parsed) { throw new Exception("No user found with id: " + strID); } }
public static void ValidateUser(string login, string pass) { umbraco.BusinessLogic.User u = null; if (umbraco.UmbracoSettings.DefaultBackofficeProvider == "UsersMembershipProvider") { u = new User(login); if (u != null && pass != u.GetPassword()) { throw new Umbraco.Courier.Core.Exceptions.UnauthorizedClientException("User: "******" could not be authenticated"); } } else { if (Membership.Providers[umbraco.UmbracoSettings.DefaultBackofficeProvider].ValidateUser(login, pass)) { u = new User(login); } else { throw new Umbraco.Courier.Core.Exceptions.UnauthorizedClientException("User: "******" could not be authenticated"); } } if (u == null) { throw new Umbraco.Courier.Core.Exceptions.UnauthorizedClientException("User: "******" does not exists"); } if (u.Disabled) { throw new Umbraco.Courier.Core.Exceptions.UnauthorizedClientException("User: "******" is not enabled"); } // CLN: Can not compare passwords from membership providers -- Check is done //if (u.GetPassword() != pass) // throw new Umbraco.Courier.Core.Exceptions.UnauthorizedClientException("User: "******" and password: xxx does not match"); if (!Umbraco.Courier.Core.Configuration.Security.AllowAllUsers && Umbraco.Courier.Core.Configuration.Security.DeniedUsers.Contains(u.LoginName)) { throw new Umbraco.Courier.Core.Exceptions.UnauthorizedClientException("User: "******" does not have access to courier"); } if (u.Applications.Where(x => x.alias.ToLower() == "courier").Count() == 0) { throw new Umbraco.Courier.Core.Exceptions.UnauthorizedClientException("User: "******" does not have access to courier."); } }
public bool Delete() { BusinessLogic.User u = BusinessLogic.User.GetUser(ParentID); u.disable(); return(true); }