/// <summary>
        /// Performs the package action during package installation
        /// </summary>
        /// <param name="packageName">
        /// The package name.
        /// </param>
        /// <param name="xmlData">
        /// The xml data.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/> indicating success of failure.
        /// </returns>
        public bool Execute(string packageName, XmlNode xmlData)
        {
            var dtd = _services.DataTypeService.GetDataTypeDefinitionById(-88);

            // Create the MerchelloCustomer MemberType
            var mt = new MemberType(-1)
            {
                Alias         = MemberTypeName,
                Name          = MemberTypeName,
                AllowedAsRoot = true
            };

            var fn = new PropertyType(dtd)
            {
                Alias = "firstName", Name = "First name"
            };
            var ln = new PropertyType(dtd)
            {
                Alias = "lastName", Name = "Last name"
            };

            mt.AddPropertyType(fn);
            mt.AddPropertyType(ln);

            mt.SetMemberCanEditProperty("firstName", true);
            mt.SetMemberCanEditProperty("lastName", true);
            mt.SetMemberCanViewProperty("firstName", true);
            mt.SetMemberCanViewProperty("lastName", true);

            _services.MemberTypeService.Save(mt);


            // Add the MemberGroup
            var mg = new MemberGroup()
            {
                Name = MemberGroupName
            };

            _services.MemberGroupService.Save(mg);

            return(true);
        }
        /// <summary>
        /// Adds the Merchello MemberType.
        /// </summary>
        /// <returns>
        /// The <see cref="IMemberType"/>.
        /// </returns>
        private IMemberType AddMemberType()
        {
            var dtd = _services.DataTypeService.GetDataTypeDefinitionById(-88);

            // Create the MerchelloCustomer MemberType
            var mt = new MemberType(-1)
            {
                Alias         = "merchelloCustomer",
                Name          = "Merchello Customer",
                AllowedAsRoot = true
            };

            var fn = new PropertyType(dtd)
            {
                Alias = "firstName", Name = "First name"
            };
            var ln = new PropertyType(dtd)
            {
                Alias = "lastName", Name = "Last name"
            };

            mt.AddPropertyType(fn);
            mt.AddPropertyType(ln);

            mt.SetMemberCanEditProperty("firstName", true);
            mt.SetMemberCanEditProperty("lastName", true);
            mt.SetMemberCanViewProperty("firstName", true);
            mt.SetMemberCanViewProperty("lastName", true);

            _services.MemberTypeService.Save(mt);


            // Add the MemberGroup
            var mg = new MemberGroup()
            {
                Name = "Customers"
            };

            _services.MemberGroupService.Save(mg);

            return(mt);
        }
Ejemplo n.º 3
0
        private void AddMemberTypeProperty(ref MemberType m)
        {
            var ddt = DataTypeDefinition.GetAll().First();
            //needs to start with a letter
            var alias = "m" + Guid.NewGuid().ToString("N");

            m.AddPropertyType(ddt, alias, alias);
            //make sure it's there
            var prop = m.getPropertyType(alias);

            Assert.IsInstanceOfType(prop, typeof(PropertyType));
        }
Ejemplo n.º 4
0
        private IMemberType GetMemberType()
        {
            var entity = new MemberType(-1)
            {
                Alias = "Member"
            };

            entity.AddPropertyGroup(Umbraco.Core.Constants.Conventions.Member.StandardPropertiesGroupName);
            var standardPropertyTypes = Umbraco.Core.Constants.Conventions.Member.GetStandardPropertyTypeStubs();

            foreach (var standardPropertyType in standardPropertyTypes)
            {
                entity.AddPropertyType(standardPropertyType.Value, Umbraco.Core.Constants.Conventions.Member.StandardPropertiesGroupName);
            }
            return(entity);
        }
Ejemplo n.º 5
0
        public void Can_Set_Is_Member_Specific_Property_Type_Options(bool isSensitive, bool canView, bool canEdit)
        {
            var        propertyTypeAlias = "testType";
            MemberType memberType        = BuildMemberType();
            var        propertyType      = new PropertyTypeBuilder()
                                           .WithAlias("testType")
                                           .Build();

            memberType.AddPropertyType(propertyType);

            memberType.SetIsSensitiveProperty(propertyTypeAlias, isSensitive);
            memberType.SetMemberCanViewProperty(propertyTypeAlias, canView);
            memberType.SetMemberCanEditProperty(propertyTypeAlias, canEdit);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(isSensitive, memberType.IsSensitiveProperty(propertyTypeAlias));
                Assert.AreEqual(canView, memberType.MemberCanViewProperty(propertyTypeAlias));
                Assert.AreEqual(canEdit, memberType.MemberCanEditProperty(propertyTypeAlias));
            });
        }
Ejemplo n.º 6
0
        public IMemberType AddDialogueMemberType()
        {
            #region DataType Ids
            //-49	    Umbraco.TrueFalse
            //-51	    Umbraco.Integer
            //-87	    Umbraco.TinyMCEv3
            //-88	    Umbraco.Textbox
            //-89	    Umbraco.TextboxMultiple
            //-90	    Umbraco.UploadField
            //-92	    Umbraco.NoEdit
            //-36	    Umbraco.DateTime
            //-37	    Umbraco.ColorPickerAlias
            //-38	    Umbraco.FolderBrowser
            //-39	    Umbraco.DropDownMultiple
            //-40	    Umbraco.RadioButtonList
            //-41	    Umbraco.Date
            //-42	    Umbraco.DropDown
            //-43	    Umbraco.CheckBoxList
            //1034	    Umbraco.ContentPickerAlias
            //1035	    Umbraco.MediaPicker
            //1036	    Umbraco.MemberPicker
            //1040	    Umbraco.RelatedLinks
            //1041	    Umbraco.Tags
            //1045	    Umbraco.MultipleMediaPicker
            //1077	    Apt.PartialPicker
            //1089	    Umbraco.ImageCropper
            //1092	    Umbraco.TinyMCEv3
            //1103	    Our.Umbraco.FilePicker
            //1104	    Umbraco.MemberGroupPicker
            //1105	    Apt.CssPicker
            //1128	    Dialogue.ThemePicker
            //1132	    Dialogue.Permissions
            //1147	    Umbraco.MultipleTextstring
            #endregion

            var label           = _dataTypeService.GetDataTypeDefinitionById(-92);
            var upload          = _dataTypeService.GetDataTypeDefinitionById(-90);
            var textstring      = _dataTypeService.GetDataTypeDefinitionById(-88);
            var textboxMultiple = _dataTypeService.GetDataTypeDefinitionById(-89);
            var truefalse       = _dataTypeService.GetDataTypeDefinitionById(-49);
            var numeric         = _dataTypeService.GetDataTypeDefinitionById(-51);
            var datetime        = _dataTypeService.GetDataTypeDefinitionById(-36);

            // Profile, Settings, Social Tokens

            // Create the member Type
            var memType = new MemberType(-1)
            {
                Alias = AppConstants.MemberTypeAlias,
                Name  = "Dialogue Member"
            };

            // Create the Profile group/tab
            var profileGroup = new PropertyGroup
            {
                Name = "Profile",
            };
            profileGroup.PropertyTypes.Add(new PropertyType(label)
            {
                Alias       = "email",
                Name        = "Email",
                SortOrder   = 0,
                Description = "This is a bit rubbish, but it's the only way to get the email from the new member service at the current time"
            });
            profileGroup.PropertyTypes.Add(new PropertyType(upload)
            {
                Alias       = "avatar",
                Name        = "Avatar",
                SortOrder   = 0,
                Description = ""
            });
            profileGroup.PropertyTypes.Add(new PropertyType(textstring)
            {
                Alias       = "website",
                Name        = "Website",
                SortOrder   = 0,
                Description = ""
            });
            profileGroup.PropertyTypes.Add(new PropertyType(textstring)
            {
                Alias       = "twitter",
                Name        = "Twitter",
                SortOrder   = 0,
                Description = ""
            });
            profileGroup.PropertyTypes.Add(new PropertyType(textboxMultiple)
            {
                Alias       = "signature",
                Name        = "Signature",
                SortOrder   = 0,
                Description = ""
            });
            profileGroup.PropertyTypes.Add(new PropertyType(datetime)
            {
                Alias       = "lastActiveDate",
                Name        = "Last Active Date",
                SortOrder   = 0,
                Description = ""
            });
            memType.PropertyGroups.Add(profileGroup);

            // Create the Settings group/tab
            var settingsGroup = new PropertyGroup
            {
                Name = "Settings",
            };
            settingsGroup.PropertyTypes.Add(new PropertyType(truefalse)
            {
                Alias       = "canEditOtherMembers",
                Name        = "Can Edit Other Members",
                SortOrder   = 0,
                Description = "Enable this and the user can edit other members posts, their profiles and ban members (Usually use in conjunction with moderate permissions)."
            });
            settingsGroup.PropertyTypes.Add(new PropertyType(truefalse)
            {
                Alias       = "disableEmailNotifications",
                Name        = "Disable Email Notifications",
                SortOrder   = 0,
                Description = ""
            });
            settingsGroup.PropertyTypes.Add(new PropertyType(truefalse)
            {
                Alias       = "disablePosting",
                Name        = "Disable Posting",
                SortOrder   = 0,
                Description = ""
            });
            settingsGroup.PropertyTypes.Add(new PropertyType(truefalse)
            {
                Alias       = "disablePrivateMessages",
                Name        = "Disable Private Messages",
                SortOrder   = 0,
                Description = ""
            });
            settingsGroup.PropertyTypes.Add(new PropertyType(truefalse)
            {
                Alias       = "disableFileUploads",
                Name        = "Disable File Uploads",
                SortOrder   = 0,
                Description = ""
            });
            settingsGroup.PropertyTypes.Add(new PropertyType(numeric)
            {
                Alias       = "postCount",
                Name        = "Post Count",
                SortOrder   = 0,
                Description = "The users post count. This is kept like this to help reduce SQL queries and improve performance of the forum"
            });
            memType.PropertyGroups.Add(settingsGroup);

            // Create the Settings group/tab
            var socialGroup = new PropertyGroup
            {
                Name = "Social Tokens",
            };
            socialGroup.PropertyTypes.Add(new PropertyType(textstring)
            {
                Name        = "Facebook Access Token",
                Alias       = "facebookAccessToken",
                SortOrder   = 0,
                Description = ""
            });
            socialGroup.PropertyTypes.Add(new PropertyType(textstring)
            {
                Name        = "Facebook Id",
                Alias       = "facebookId",
                SortOrder   = 0,
                Description = ""
            });
            socialGroup.PropertyTypes.Add(new PropertyType(textstring)
            {
                Name        = "Google Access Token",
                Alias       = "googleAccessToken",
                SortOrder   = 0,
                Description = ""
            });
            socialGroup.PropertyTypes.Add(new PropertyType(textstring)
            {
                Name        = "Google Id",
                Alias       = "googleId",
                SortOrder   = 0,
                Description = ""
            });
            memType.PropertyGroups.Add(socialGroup);

            // Add Slug
            memType.AddPropertyType(new PropertyType(textstring)
            {
                Name        = "Slug",
                Alias       = "slug",
                SortOrder   = 0,
                Description = "This is what we use to look up the member in the front end"
            });

            _memberTypeService.Save(memType);

            return(memType);
        }
Ejemplo n.º 7
0
        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++;
            }
        }
        protected void CreateMemberTypeAndMemberGroup(object sender, EventArgs e)
        {
            MemberGroup[] memberGroups     = MemberGroup.GetAll;
            bool          memberGroupExist = false;

            foreach (MemberGroup memberGroup in memberGroups)
            {
                if (memberGroup.Text == "Extranet")
                {
                    memberGroupExist = true;
                }
            }
            if (memberGroupExist == false)
            {
                MemberGroup memberType = MemberGroup.MakeNew("Extranet", umbraco.BasePages.UmbracoEnsuredPage.CurrentUser);
            }

            MemberType[] memberTypes     = MemberType.GetAll;
            bool         memberTypeExist = false;

            foreach (MemberType memberType in memberTypes)
            {
                if (memberType.Text == "Extranet")
                {
                    memberTypeExist = true;
                }
            }
            if (memberTypeExist == false)
            {
                MemberType memberType = MemberType.MakeNew(umbraco.BasePages.UmbracoEnsuredPage.CurrentUser, "Standard");
                memberType.Alias     = "Standard";
                memberType.Text      = "Standard";
                memberType.IconUrl   = "memberType.gif";
                memberType.Thumbnail = "member.png";

                int tabInfoId     = memberType.AddVirtualTab("Info");
                int tabPersonalId = memberType.AddVirtualTab("Personal");
                int tabServicesId = memberType.AddVirtualTab("Services");
                int tabDataId     = memberType.AddVirtualTab("Data");

                DataTypeDefinition textstring         = DataTypeDefinition.GetDataTypeDefinition(-88);
                DataTypeDefinition checkbox           = DataTypeDefinition.GetDataTypeDefinition(-49);
                DataTypeDefinition upload             = DataTypeDefinition.GetDataTypeDefinition(-90);
                DataTypeDefinition datePickerWithTime = DataTypeDefinition.GetDataTypeDefinition(-36);
                DataTypeDefinition numeric            = DataTypeDefinition.GetDataTypeDefinition(-51);
                DataTypeDefinition textboxMultiple    = DataTypeDefinition.GetDataTypeDefinition(-89);

                // Info
                memberType.AddPropertyType(textstring, "nickname", "Nickname");
                memberType.getPropertyType("nickname").TabId = tabInfoId;

                memberType.AddPropertyType(upload, "profilePicture", "Profile picture");
                memberType.getPropertyType("profilePicture").TabId = tabInfoId;

                // Personal
                memberType.AddPropertyType(datePickerWithTime, "birthdate", "Birthdate");
                memberType.getPropertyType("birthdate").TabId = tabPersonalId;

                memberType.AddPropertyType(textstring, "gender", "Gender");
                memberType.getPropertyType("gender").TabId = tabPersonalId;

                memberType.AddPropertyType(textstring, "firstname", "Firstname");
                memberType.getPropertyType("firstname").TabId = tabPersonalId;

                memberType.AddPropertyType(textstring, "surname", "Surname");
                memberType.getPropertyType("surname").TabId = tabPersonalId;

                memberType.AddPropertyType(textstring, "locationAddress", "Address");
                memberType.getPropertyType("locationAddress").TabId = tabPersonalId;

                memberType.AddPropertyType(textstring, "locationZip", "Zip code");
                memberType.getPropertyType("locationZip").TabId = tabPersonalId;

                memberType.AddPropertyType(textstring, "locationCity", "City");
                memberType.getPropertyType("locationCity").TabId = tabPersonalId;

                memberType.AddPropertyType(textstring, "locationCountry", "Country");
                memberType.getPropertyType("locationCountry").TabId = tabPersonalId;

                // Servives
                memberType.AddPropertyType(textstring, "twitterAlias", "Twitter alias");
                memberType.getPropertyType("twitterAlias").TabId = tabServicesId;

                memberType.AddPropertyType(textstring, "flickrAlias", "Flickr alias");
                memberType.getPropertyType("flickrAlias").TabId = tabServicesId;

                // Data
                memberType.AddPropertyType(checkbox, "approved", "Approved");
                memberType.getPropertyType("approved").TabId = tabDataId;

                memberType.AddPropertyType(checkbox, "lock", "Lock user");
                memberType.getPropertyType("lock").TabId = tabDataId;

                memberType.AddPropertyType(numeric, "failed_logins", "Failed Password Attempts");
                memberType.getPropertyType("failed_logins").TabId = tabDataId;

                memberType.AddPropertyType(textboxMultiple, "comments", "Comment");
                memberType.getPropertyType("comments").TabId = tabDataId;

                memberType.AddPropertyType(datePickerWithTime, "last_login", "LastLogin");
                memberType.getPropertyType("last_login").TabId = tabDataId;

                memberType.AddPropertyType(textstring, "SecretCode", "Hemmelig kode");
                PropertyType typeSecretCode = memberType.getPropertyType("SecretCode");
                typeSecretCode.TabId       = tabDataId;
                typeSecretCode.Description = "Bruges blandt andet til aktivering/sletning emails";
            }
        }
        public static void Import(XmlNode n, bool ImportStructure)
        {
            if (n == null)
            {
                throw new ArgumentNullException("Node cannot be null");
            }

            //
            // using xmlHelper not XmlHelper because GetNodeValue has gone all
            // Internall on us, this function probibly does belong in the core
            // (umbraco.cms.buisnesslogic.packageInstaller) so that packages
            // can also do member types, but at the mo, it's uSync's until i read
            // about contributing to the core.
            //

            // using user 0 will come unstuck oneday
            User u = new User(0);

            // does this member type already exist ?
            string alias = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Alias"));

            if (String.IsNullOrEmpty(alias))
            {
                throw new Exception("no alias in sync file");
            }

            MemberType mt = null;

            try
            {
                mt = MemberType.GetByAlias(alias);
            }
            catch (Exception ex)
            {
                LogHelper.Debug <SyncMemberType>("Member type corrupt? {0}", () => ex.ToString());
            }

            if (mt == null)
            {
                // we are new
                mt       = MemberType.MakeNew(u, xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Name")));
                mt.Alias = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Alias"));
            }
            else
            {
                mt.Text = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Name"));
            }

            // core
            mt.IconUrl     = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Icon"));
            mt.Thumbnail   = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Thumbnail"));
            mt.Description = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Description"));

            // v6 you can have allow at root.
            // Allow at root (check for node due to legacy)
            bool   allowAtRoot     = false;
            string allowAtRootNode = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/AllowAtRoot"));

            if (!String.IsNullOrEmpty(allowAtRootNode))
            {
                bool.TryParse(allowAtRootNode, out allowAtRoot);
            }
            mt.AllowAtRoot = allowAtRoot;

            //Master content type
            string master = xmlHelper.GetNodeValue(n.SelectSingleNode("Info/Master"));


            if (!String.IsNullOrEmpty(master))
            {
                // throw new System.Exception(String.Format("Throwing in {0}, master {1}", mt.Text, master));
                try
                {
                    MemberType pmt = MemberType.GetByAlias(master);
                    if (pmt != null)
                    {
                        mt.MasterContentType = pmt.Id;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Debug <SyncMemberType>("Member type corrupt? {0}", () => ex.ToString());
                }
            }

            //tabs

            ContentType.TabI[] tabs = mt.getVirtualTabs;

            // load the current tabs
            string tabnames = ";";

            for (int t = 0; t < tabs.Length; t++)
            {
                tabnames += tabs[t].Caption + ";";
            }

            Hashtable ht = new Hashtable();

            foreach (XmlNode t in n.SelectNodes("Tabs/Tab"))
            {
                // is this a new tab?
                // if ( tabnames.IndexOf(";" + xmlHelper.GetNodeValue(t.SelectSingleNode("Caption")) + ";" == -1)
                if (!tabnames.Contains(";" + xmlHelper.GetNodeValue(t.SelectSingleNode("Caption")) + ";"))
                {
                    ht.Add(int.Parse(xmlHelper.GetNodeValue(t.SelectSingleNode("Id"))),
                           mt.AddVirtualTab(xmlHelper.GetNodeValue(t.SelectSingleNode("Caption"))));
                }
            }
            // clear cache
            mt.ClearVirtualTabs();

            // put tabs in a hashtable, so we can check they exist when we add properties.
            Hashtable tabList = new Hashtable();

            foreach (ContentType.TabI t in mt.getVirtualTabs.ToList())
            {
                if (!tabList.ContainsKey(t.Caption))
                {
                    tabList.Add(t.Caption, t.Id);
                }
            }

            // properties..
            global::umbraco.cms.businesslogic.datatype.controls.Factory f =
                new global::umbraco.cms.businesslogic.datatype.controls.Factory();

            foreach (XmlNode gp in n.SelectNodes("GenericProperties/GenericProperty"))
            {
                int  dfId = 0;
                Guid dtId = new Guid(xmlHelper.GetNodeValue(gp.SelectSingleNode("Type")));

                if (gp.SelectSingleNode("Definition") != null && !string.IsNullOrEmpty(xmlHelper.GetNodeValue(gp.SelectSingleNode("Definition"))))
                {
                    Guid dtdId = new Guid(xmlHelper.GetNodeValue(gp.SelectSingleNode("Definition")));
                    if (CMSNode.IsNode(dtdId))
                    {
                        dfId = new CMSNode(dtdId).Id;
                    }
                }

                if (dfId == 0)
                {
                    try
                    {
                        dfId = findDataTypeDefinitionFromType(ref dtId);
                    }
                    catch
                    {
                        throw new Exception(String.Format("Cound not find datatype with id {0}.", dtId));
                    }
                }

                //fix for ritch text editor
                if (dfId == 0 && dtId == new Guid("a3776494-0574-4d93-b7de-efdfdec6f2d1"))
                {
                    dtId = new Guid("83722133-f80c-4273-bdb6-1befaa04a612");
                    dfId = findDataTypeDefinitionFromType(ref dtId);
                }

                if (dfId != 0)
                {
                    PropertyType pt = mt.getPropertyType(xmlHelper.GetNodeValue(gp.SelectSingleNode("Alias")));
                    if (pt == null)
                    {
                        mt.AddPropertyType(
                            global::umbraco.cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(dfId),
                            xmlHelper.GetNodeValue(gp.SelectSingleNode("Alias")),
                            xmlHelper.GetNodeValue(gp.SelectSingleNode("Name"))
                            );
                        pt = mt.getPropertyType(xmlHelper.GetNodeValue(gp.SelectSingleNode("Alias")));
                    }
                    else
                    {
                        pt.DataTypeDefinition = global::umbraco.cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(dfId);
                        pt.Name = xmlHelper.GetNodeValue(gp.SelectSingleNode("Name"));
                    }

                    pt.Mandatory        = bool.Parse(xmlHelper.GetNodeValue(gp.SelectSingleNode("Mandatory")));
                    pt.ValidationRegExp = xmlHelper.GetNodeValue(gp.SelectSingleNode("Validation"));
                    pt.Description      = xmlHelper.GetNodeValue(gp.SelectSingleNode("Description"));

                    // tab
                    try
                    {
                        if (tabList.ContainsKey(xmlHelper.GetNodeValue(gp.SelectSingleNode("Tab"))))
                        {
                            pt.TabId = (int)tabList[xmlHelper.GetNodeValue(gp.SelectSingleNode("Tab"))];
                        }
                    }
                    catch (Exception ee)
                    {
                        LogHelper.Debug <SyncMemberType>("Packager: Error assigning property to tab: {0}", () => ee.ToString());
                    }
                    pt.Save();
                }
            }

            if (ImportStructure)
            {
                if (mt != null)
                {
                    ArrayList allowed = new ArrayList();
                    foreach (XmlNode structure in n.SelectNodes("Structure/MemberType"))
                    {
                        try
                        {
                            MemberType dtt = MemberType.GetByAlias(xmlHelper.GetNodeValue(structure));
                            if (dtt != null)
                            {
                                allowed.Add(dtt.Id);
                            }
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Info <uSync>("Can't find structure MemberType - so skipping");
                        }
                    }

                    int[] adt = new int[allowed.Count];
                    for (int i = 0; i < allowed.Count; i++)
                    {
                        adt[i] = (int)allowed[i];
                    }
                    mt.AllowedChildContentTypeIDs = adt;
                }
            }

            mt.Save();

            /*
             * foreach (MediaType.TabI t in mt.getVirtualTabs.ToList())
             * {
             *  MediaType.FlushTabCache(t.Id, mt.Id);
             * }
             *
             * // need to do this more i think
             * MediaType.FlushFromCache(mt.Id);
             */
        }