public override void delete() { DeleteEventArgs e = new DeleteEventArgs(); FireBeforeDelete(e); if (!e.Cancel) { //first clear the prevalues PreValues.DeleteByDataTypeDefinition(this.Id); //next clear out the property types var propTypes = PropertyType.GetByDataTypeDefinition(this.Id); foreach (var p in propTypes) { p.delete(); } //delete the cmsDataType role, then the umbracoNode SqlHelper.ExecuteNonQuery("delete from cmsDataType where nodeId=@nodeId", SqlHelper.CreateParameter("@nodeId", this.Id)); base.delete(); cache.Cache.ClearCacheItem(string.Format("UmbracoDataTypeDefinition{0}", Id)); FireAfterDelete(e); } }
/// <summary> /// Add a property to the Content /// </summary> /// <param name="pt">The PropertyType of the Property</param> /// <param name="versionId">The version of the document on which the property should be add'ed</param> /// <returns>The new Property</returns> public virtual Property addProperty(PropertyType pt, Guid versionId) { ClearLoadedProperties(); return(property.Property.MakeNew(pt, this, versionId)); }
/// <summary> /// Retrieve a property given the propertytype /// </summary> /// <param name="pt">PropertyType</param> /// <returns>The property with the given propertytype</returns> public virtual Property getProperty(PropertyType pt) { EnsureProperties(); return(_loadedProperties.SingleOrDefault(x => x.PropertyType.Id == pt.Id)); }
private void SetupChannel() { Channel userChannel; try { userChannel = new Channel(u.Id); } catch { userChannel = new Channel(); } // Populate dropdowns foreach (DocumentType dt in DocumentType.GetAllAsList()) { cDocumentType.Items.Add( new ListItem(dt.Text, dt.Alias) ); } // populate fields ArrayList fields = new ArrayList(); cDescription.ID = "cDescription"; cCategories.ID = "cCategories"; cExcerpt.ID = "cExcerpt"; cDescription.Items.Add(new ListItem(ui.Text("choose"), "")); cCategories.Items.Add(new ListItem(ui.Text("choose"), "")); cExcerpt.Items.Add(new ListItem(ui.Text("choose"), "")); foreach (PropertyType pt in PropertyType.GetAll()) { if (!fields.Contains(pt.Alias)) { cDescription.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias)); cCategories.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias)); cExcerpt.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias)); fields.Add(pt.Alias); } } // Handle content and media pickers PlaceHolder medias = new PlaceHolder(); cMediaPicker.AppAlias = Constants.Applications.Media; cMediaPicker.TreeAlias = "media"; if (userChannel.MediaFolder > 0) { cMediaPicker.Value = userChannel.MediaFolder.ToString(); } else { cMediaPicker.Value = "-1"; } medias.Controls.Add(cMediaPicker); PlaceHolder content = new PlaceHolder(); cContentPicker.AppAlias = Constants.Applications.Content; cContentPicker.TreeAlias = "content"; if (userChannel.StartNode > 0) { cContentPicker.Value = userChannel.StartNode.ToString(); } else { cContentPicker.Value = "-1"; } content.Controls.Add(cContentPicker); // Setup the panes Pane ppInfo = new Pane(); ppInfo.addProperty(ui.Text("name", UmbracoUser), cName); ppInfo.addProperty(ui.Text("user", "startnode", UmbracoUser), content); ppInfo.addProperty(ui.Text("user", "searchAllChildren", UmbracoUser), cFulltree); ppInfo.addProperty(ui.Text("user", "mediastartnode", UmbracoUser), medias); Pane ppFields = new Pane(); ppFields.addProperty(ui.Text("user", "documentType", UmbracoUser), cDocumentType); ppFields.addProperty(ui.Text("user", "descriptionField", UmbracoUser), cDescription); ppFields.addProperty(ui.Text("user", "categoryField", UmbracoUser), cCategories); ppFields.addProperty(ui.Text("user", "excerptField", UmbracoUser), cExcerpt); TabPage channelInfo = UserTabs.NewTabPage(ui.Text("user", "contentChannel", UmbracoUser)); channelInfo.Controls.Add(ppInfo); channelInfo.Controls.Add(ppFields); if (!IsPostBack) { cName.Text = userChannel.Name; cDescription.SelectedValue = userChannel.FieldDescriptionAlias; cCategories.SelectedValue = userChannel.FieldCategoriesAlias; cExcerpt.SelectedValue = userChannel.FieldExcerptAlias; cDocumentType.SelectedValue = userChannel.DocumentTypeAlias; cFulltree.Checked = userChannel.FullTree; } }
/// <summary> /// Add a property to the Content /// </summary> /// <param name="pt">The PropertyType of the Property</param> /// <param name="versionId">The version of the document on which the property should be add'ed</param> /// <returns>The new Property</returns> public virtual Property addProperty(PropertyType pt, Guid versionId) { ClearLoadedProperties(); return property.Property.MakeNew(pt, this, versionId); }
/// <summary> /// Retrieve a property given the propertytype /// </summary> /// <param name="pt">PropertyType</param> /// <returns>The property with the given propertytype</returns> public virtual Property getProperty(PropertyType pt) { EnsureProperties(); return m_LoadedProperties.SingleOrDefault(x => x.PropertyType.Id == pt.Id); }
private void SynchronizeMemberTypeProperties(Type typeMemberType, MemberType memberType) { int propertySortOrder = 0; foreach (PropertyInfo propInfo in typeMemberType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { DocumentTypePropertyAttribute propAttr = Util.GetAttribute <DocumentTypePropertyAttribute>(propInfo); if (propAttr == null) { continue; // skip this property - not part of a document type } // getting name and alias string propertyName; string propertyAlias; DocumentTypeManager.ReadPropertyNameAndAlias(propInfo, propAttr, out propertyName, out propertyAlias); if (HasObsoleteAttribute(propInfo)) { Util.DeletePropertyType(memberType, propertyAlias); continue; } if (propAttr.DefaultValue != null) { _hadDefaultValues = true; // at least one property has a default value } umbraco.cms.businesslogic.datatype.DataTypeDefinition dataTypeDefinition = GetDataTypeDefinition(typeMemberType, propAttr, propInfo); // getting property if already exists, or creating new if it not exists umbraco.cms.businesslogic.propertytype.PropertyType propertyType = memberType.PropertyTypes.FirstOrDefault(p => p.Alias == propertyAlias); if (propertyType == null) // if not exists, create it { memberType.AddPropertyType(dataTypeDefinition, propertyAlias, propertyName); propertyType = memberType.PropertyTypes.FirstOrDefault(p => p.Alias == propertyAlias); } //// Setting up the tab of this property. If tab doesn't exists, create it. if (!string.IsNullOrEmpty(propAttr.TabAsString) && propAttr.TabAsString.ToLower() != DocumentTypeDefaultValues.TabGenericProperties.ToLower()) { // try to find this tab umbraco.cms.businesslogic.propertytype.PropertyTypeGroup pg = memberType.PropertyTypeGroups.FirstOrDefault(x => x.Name == propAttr.TabAsString); if (pg == null) // if found { memberType.AddVirtualTab(propAttr.TabAsString); pg = memberType.PropertyTypeGroups.FirstOrDefault(x => x.Name == propAttr.TabAsString); } if (propAttr.TabOrder.HasValue) { pg.SortOrder = propAttr.TabOrder.Value; } propertyType.PropertyTypeGroup = pg.Id; } propertyType.Name = propertyName; propertyType.Mandatory = propAttr.Mandatory; propertyType.ValidationRegExp = propAttr.ValidationRegExp; propertyType.Description = propAttr.Description; propertyType.SortOrder = propertySortOrder; propertySortOrder++; } }
/// <summary> /// Get an true/false if the given data defined in the propertytype, should be visible on the members profile page /// </summary> /// <param name="pt">Propertytype</param> /// <returns>True if the data should be displayed on the profilepage</returns> public bool ViewOnProfile(PropertyType pt) { return(MemberTypeItem.MemberCanViewProperty(pt.Alias)); }
/// <summary> /// Get an true/false if the Member can edit the given data defined in the propertytype /// </summary> /// <param name="pt">Propertytype to edit</param> /// <returns>True if the Member can edit the data</returns> public bool MemberCanEdit(PropertyType pt) { return(MemberTypeItem.MemberCanEditProperty(pt.Alias)); }
/// <summary> /// Set if the data should be displayed on members of this type's profilepage /// </summary> /// <param name="pt">PropertyType</param> /// <param name="value">True/False if the data should be displayed</param> public void setMemberViewOnProfile(PropertyType pt, bool value) { MemberTypeItem.SetMemberCanViewProperty(pt.Alias, value); }
/// <summary> /// Set if the member should be able to edit the data defined by its propertytype /// </summary> /// <param name="pt">PropertyType</param> /// <param name="value">True/False if Members of the type shoúld be able to edit the data</param> public void setMemberCanEdit(PropertyType pt, bool value) { MemberTypeItem.SetMemberCanEditProperty(pt.Alias, value); }