diff --git a/umbraco/cms/businesslogic/web/Document.cs b/umbraco/cms/businesslogic/web/Document.cs index ed6eef40b9..2ad5911e67 100644 --- a/umbraco/cms/businesslogic/web/Document.cs +++ b/umbraco/cms/businesslogic/web/Document.cs @@ -929,7 +929,8 @@ namespace umbraco.cms.businesslogic.web { umbraco.BusinessLogic.Actions.Action.RunActionHandlers(this, ActionDelete.Instance); UnPublish(); - Move(-20); + Move((int)RecycleBin.RecycleBinType.Content); + FireAfterMoveToTrash(e); } diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index b05eda7578..e55793f91a 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -475,6 +475,12 @@ TreeControl.ascx + + + + + + DLRScripting.ascx ASPXCodeBehind @@ -482,6 +488,22 @@ DLRScripting.ascx + + + + + + + + + + + + + + + + Preview.aspx ASPXCodeBehind @@ -617,7 +639,7 @@ simple.ascx - + Code diff --git a/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs b/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs index a85274d803..b4e5f7fd1a 100644 --- a/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs +++ b/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs @@ -33,23 +33,6 @@ namespace umbraco.cms.presentation.Trees public ContentRecycleBin(string application) : base(application) { } - private string m_treeAlias; - /// - /// Change the tree alias so that it is the same as the content tree - /// - public override string TreeAlias - { - get - { - if (string.IsNullOrEmpty(m_treeAlias)) - { - TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(); - m_treeAlias = (treeDef != null ? treeDef.Tree.Alias : "content"); - } - return m_treeAlias; - } - } - protected override void CreateRootNodeActions(ref List actions) { actions.Clear(); @@ -60,7 +43,7 @@ namespace umbraco.cms.presentation.Trees protected override void CreateAllowedActions(ref List actions) { - actions.Clear(); + actions.Clear(); actions.Add(ActionMove.Instance); actions.Add(ContextMenuSeperator.Instance); actions.Add(ActionDelete.Instance); @@ -93,7 +76,7 @@ namespace umbraco.cms.presentation.Trees { get { - return -20; + return (int)RecycleBin.RecycleBinType.Content; } } @@ -102,17 +85,7 @@ namespace umbraco.cms.presentation.Trees /// /// public override void RenderJS(ref StringBuilder Javascript) { } - - ///// - ///// Returns the tree service url to render the tree. Ensures that IsRecycleBin is flagged. - ///// - ///// - //public override string GetTreeInitUrl() - //{ - // TreeService treeSvc = new TreeService(true, this.StartNodeID, TreeAlias, null, null, "", ""); - // return treeSvc.GetInitUrl(); - //} - + protected override void OnRenderNode(ref XmlTreeNode xNode, Document doc) { xNode.Style.DimNode(); diff --git a/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs b/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs index 483f955b4f..41d04ba60f 100644 --- a/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs +++ b/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs @@ -36,23 +36,6 @@ namespace umbraco.cms.presentation.Trees } - private string m_treeAlias; - /// - /// Change the tree alias so that it is the same as the media tree - /// - public override string TreeAlias - { - get - { - if (string.IsNullOrEmpty(m_treeAlias)) - { - TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(); - m_treeAlias = (treeDef != null ? treeDef.Tree.Alias : "media"); - } - return m_treeAlias; - } - } - protected override void CreateRootNodeActions(ref List actions) { actions.Clear(); @@ -78,7 +61,7 @@ namespace umbraco.cms.presentation.Trees { get { - return -21; + return (int)RecycleBin.RecycleBinType.Media; } } diff --git a/umbraco/presentation/umbraco/config/create/UI.xml b/umbraco/presentation/umbraco/config/create/UI.xml index 83465b8e56..7fe689cb11 100644 --- a/umbraco/presentation/umbraco/config/create/UI.xml +++ b/umbraco/presentation/umbraco/config/create/UI.xml @@ -50,6 +50,13 @@ + +
Page
+ /create/content.ascx + + + +
Page
/create/content.ascx @@ -129,6 +136,13 @@
+ +
Media
+ /create/media.ascx + + + +
Media
/create/media.ascx diff --git a/umbraco/presentation/umbraco/create/CreatedPackageTasks.cs b/umbraco/presentation/umbraco/create/CreatedPackageTasks.cs new file mode 100644 index 0000000000..3e27de41ef --- /dev/null +++ b/umbraco/presentation/umbraco/create/CreatedPackageTasks.cs @@ -0,0 +1,67 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class CreatedPackageTasks : interfaces.ITaskReturnUrl + { + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + 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 Delete() + { + cms.businesslogic.packager.CreatedPackage.GetById(ParentID).Delete(); + return true; + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/DLRScriptingTasks.cs b/umbraco/presentation/umbraco/create/DLRScriptingTasks.cs new file mode 100644 index 0000000000..e1540c65d1 --- /dev/null +++ b/umbraco/presentation/umbraco/create/DLRScriptingTasks.cs @@ -0,0 +1,141 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class DLRScriptingTasks : interfaces.ITaskReturnUrl + { + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set + { + _userID = value; + } + } + + public int TypeID + { + get + { + return _typeID; + } + set + { + _typeID = value; + } + } + + public string Alias + { + get + { + return _alias; + } + set + { + _alias = value; + } + } + + public int ParentID + { + get + { + return _parentID; + } + set + { + _parentID = value; + } + } + + public bool Save() + { + + string template = _alias.Substring(0, _alias.IndexOf("|||")).Trim(); + string fileName = _alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3).Replace(" ", ""); + + if (!fileName.Contains(".")) + fileName = _alias + ".py"; + + string scriptContent = ""; + if (!string.IsNullOrEmpty(template)) + { + System.IO.StreamReader templateFile = System.IO.File.OpenText(IOHelper.MapPath(IO.SystemDirectories.Umbraco + "/scripting/templates/" + template)); + scriptContent = templateFile.ReadToEnd(); + templateFile.Close(); + } + + + if (fileName.Contains("/")) //if there's a / create the folder structure for it + { + string[] folders = fileName.Split("/".ToCharArray()); + string basePath = IOHelper.MapPath(SystemDirectories.Python); + for (int i = 0; i < folders.Length - 1; i++) + { + basePath = System.IO.Path.Combine(basePath, folders[i]); + System.IO.Directory.CreateDirectory(basePath); + } + } + + string abFileName = IOHelper.MapPath(SystemDirectories.Python + "/" + fileName); + + System.IO.StreamWriter scriptWriter = System.IO.File.CreateText(abFileName); + scriptWriter.Write(scriptContent); + scriptWriter.Flush(); + scriptWriter.Close(); + + + if (ParentID == 1) + { + cms.businesslogic.macro.Macro m = cms.businesslogic.macro.Macro.MakeNew( + helper.SpaceCamelCasing(fileName.Substring(0, (fileName.LastIndexOf('.') + 1)).Trim('.'))); + m.ScriptingFile = fileName; + } + + m_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/python/editPython.aspx?file={0}", fileName); + return true; + } + + public bool Delete() + { + + string path = IOHelper.MapPath(SystemDirectories.Python + "/" + Alias.TrimStart('/')); + + System.Web.HttpContext.Current.Trace.Warn("", "*" + path + "*"); + try + { + System.IO.File.Delete(path); + } + catch (Exception ex) + { + Log.Add(LogTypes.Error, UmbracoEnsuredPage.CurrentUser, -1, "Could not remove XSLT file " + Alias + ". ERROR: " + ex.Message); + } + return true; + } + + public DLRScriptingTasks() + { + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/DataTypeTasks.cs b/umbraco/presentation/umbraco/create/DataTypeTasks.cs new file mode 100644 index 0000000000..303e3e8803 --- /dev/null +++ b/umbraco/presentation/umbraco/create/DataTypeTasks.cs @@ -0,0 +1,74 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class DataTypeTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + + int id = cms.businesslogic.datatype.DataTypeDefinition.MakeNew(BusinessLogic.User.GetUser(_userID), Alias).Id; + m_returnUrl = string.Format("developer/datatypes/editDataType.aspx?id={0}", id); + return true; + } + + public bool Delete() + { + cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(ParentID).delete(); + return true; + } + + public DataTypeTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + + } +} diff --git a/umbraco/presentation/umbraco/create/MediaTypeTasks.cs b/umbraco/presentation/umbraco/create/MediaTypeTasks.cs new file mode 100644 index 0000000000..269215d8fc --- /dev/null +++ b/umbraco/presentation/umbraco/create/MediaTypeTasks.cs @@ -0,0 +1,73 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class MediaTypeTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + int id = cms.businesslogic.media.MediaType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias.Replace("'", "''")).Id; + m_returnUrl = string.Format("settings/editMediaType.aspx?id={0}", id); + return true; + } + + public bool Delete() + { + new cms.businesslogic.media.MediaType(_parentID).delete(); + return false; + } + + public MediaTypeTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + + } +} diff --git a/umbraco/presentation/umbraco/create/MemberGroupTasks.cs b/umbraco/presentation/umbraco/create/MemberGroupTasks.cs new file mode 100644 index 0000000000..1d8d874332 --- /dev/null +++ b/umbraco/presentation/umbraco/create/MemberGroupTasks.cs @@ -0,0 +1,93 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class MemberGroupTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + System.Web.Security.Roles.CreateRole(Alias); + // int id = cms.businesslogic.member.MemberGroup.MakeNew(Alias, BusinessLogic.User.GetUser(_userID)).Id; + m_returnUrl = string.Format("members/EditMemberGroup.aspx?id={0}", System.Web.HttpContext.Current.Server.UrlEncode(Alias)); + return true; + } + + public bool Delete() + { + // only build-in roles can be deleted + if (cms.businesslogic.member.Member.IsUsingUmbracoRoles()) + { + cms.businesslogic.member.MemberGroup.GetByName(Alias).delete(); + return true; + } + else + { + return false; + } + //try + //{ + + // MembershipUser u = Membership.GetUser(_parentID); + // Membership.DeleteUser(u.UserName); + // return true; + + //}catch + //{ + // Log.Add(LogTypes.Error, _parentID, "Member cannot be deleted."); + // return false; + //} + } + + public MemberGroupTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/MemberTypeTasks.cs b/umbraco/presentation/umbraco/create/MemberTypeTasks.cs new file mode 100644 index 0000000000..50c863977e --- /dev/null +++ b/umbraco/presentation/umbraco/create/MemberTypeTasks.cs @@ -0,0 +1,73 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class MemberTypeTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + + int id = cms.businesslogic.member.MemberType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias).Id; + m_returnUrl = string.Format("members/EditMemberType.aspx?id={0}", id); + return true; + } + + public bool Delete() + { + new cms.businesslogic.member.MemberType(_parentID).delete(); + return true; + } + + public MemberTypeTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/NewMemberUIEventArgs.cs b/umbraco/presentation/umbraco/create/NewMemberUIEventArgs.cs new file mode 100644 index 0000000000..743b81f780 --- /dev/null +++ b/umbraco/presentation/umbraco/create/NewMemberUIEventArgs.cs @@ -0,0 +1,15 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class NewMemberUIEventArgs : System.ComponentModel.CancelEventArgs + { + } +} diff --git a/umbraco/presentation/umbraco/create/PythonTasks.cs b/umbraco/presentation/umbraco/create/PythonTasks.cs new file mode 100644 index 0000000000..ec1814ff07 --- /dev/null +++ b/umbraco/presentation/umbraco/create/PythonTasks.cs @@ -0,0 +1,13 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class PythonTasks : DLRScriptingTasks { } +} diff --git a/umbraco/presentation/umbraco/create/ScriptTasks.cs b/umbraco/presentation/umbraco/create/ScriptTasks.cs new file mode 100644 index 0000000000..45aa87fb90 --- /dev/null +++ b/umbraco/presentation/umbraco/create/ScriptTasks.cs @@ -0,0 +1,90 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class ScriptTasks : interfaces.ITaskReturnUrl + { + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + string[] scriptFileAr = _alias.Split('¤'); + + + + string relPath = scriptFileAr[0]; + string fileName = scriptFileAr[1]; + string fileType = scriptFileAr[2]; + + int createFolder = ParentID; + + string basePath = IOHelper.MapPath(SystemDirectories.Scripts + "/" + relPath + fileName); + + if (createFolder == 1) + { + System.IO.Directory.CreateDirectory(basePath); + } + else + { + System.IO.File.Create(basePath + "." + fileType).Close(); + m_returnUrl = string.Format("settings/scripts/editScript.aspx?file={0}{1}.{2}", relPath, fileName, fileType); + } + return true; + } + + public bool Delete() + { + string path = IOHelper.MapPath(SystemDirectories.Scripts + "/" + _alias.TrimStart('/')); + + if (System.IO.File.Exists(path)) + System.IO.File.Delete(path); + else if (System.IO.Directory.Exists(path)) + System.IO.Directory.Delete(path, true); + + BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Delete, umbraco.BasePages.UmbracoEnsuredPage.CurrentUser, -1, _alias + " Deleted"); + return true; + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/StylesheetTasks.cs b/umbraco/presentation/umbraco/create/StylesheetTasks.cs new file mode 100644 index 0000000000..97fd1452f1 --- /dev/null +++ b/umbraco/presentation/umbraco/create/StylesheetTasks.cs @@ -0,0 +1,67 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class StylesheetTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + + int id = cms.businesslogic.web.StyleSheet.MakeNew(BusinessLogic.User.GetUser(_userID), Alias, "", "").Id; + m_returnUrl = string.Format("settings/stylesheet/editStylesheet.aspx?id={0}", id); + return true; + } + + public bool Delete() + { + cms.businesslogic.web.StyleSheet s = new cms.businesslogic.web.StyleSheet(ParentID); + s.delete(); + return true; + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/XsltTasks.cs b/umbraco/presentation/umbraco/create/XsltTasks.cs new file mode 100644 index 0000000000..a08cacd277 --- /dev/null +++ b/umbraco/presentation/umbraco/create/XsltTasks.cs @@ -0,0 +1,131 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + /// + /// Summary description for standardTasks. + /// + /// + + public class XsltTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + + + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + string template = _alias.Substring(0, _alias.IndexOf("|||")); + string fileName = _alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3).Replace(" ", ""); + string xsltTemplateSource = IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/templates/" + template); + string xsltNewFilename = IOHelper.MapPath(SystemDirectories.Xslt + "/" + fileName + ".xslt"); + + if (fileName.Contains("/")) //if there's a / create the folder structure for it + { + string[] folders = fileName.Split("/".ToCharArray()); + string xsltBasePath = IOHelper.MapPath(SystemDirectories.Xslt); + for (int i = 0; i < folders.Length - 1; i++) + { + xsltBasePath = System.IO.Path.Combine(xsltBasePath, folders[i]); + System.IO.Directory.CreateDirectory(xsltBasePath); + } + } + + // System.IO.File.Copy(xsltTemplateSource, xsltNewFilename, false); + + // update with xslt references + string xslt = ""; + System.IO.StreamReader xsltFile = System.IO.File.OpenText(xsltTemplateSource); + xslt = xsltFile.ReadToEnd(); + xsltFile.Close(); + + // prepare support for XSLT extensions + xslt = macro.AddXsltExtensionsToHeader(xslt); + System.IO.StreamWriter xsltWriter = System.IO.File.CreateText(xsltNewFilename); + xsltWriter.Write(xslt); + xsltWriter.Flush(); + xsltWriter.Close(); + + // Create macro? + if (ParentID == 1) + { + cms.businesslogic.macro.Macro m = + cms.businesslogic.macro.Macro.MakeNew( + helper.SpaceCamelCasing(_alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3))); + m.Xslt = fileName + ".xslt"; + } + + m_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/xslt/editXslt.aspx?file={0}.xslt", fileName); + + return true; + } + + public bool Delete() + { + string path = IOHelper.MapPath(SystemDirectories.Xslt + "/" + Alias.TrimStart('/')); + + System.Web.HttpContext.Current.Trace.Warn("", "*" + path + "*"); + + try + { + System.IO.File.Delete(path); + } + catch (Exception ex) + { + Log.Add(LogTypes.Error, UmbracoEnsuredPage.CurrentUser, -1, "Could not remove XSLT file " + Alias + ". ERROR: " + ex.Message); + } + return true; + } + + public XsltTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + + } +} diff --git a/umbraco/presentation/umbraco/create/contentItemTasks.cs b/umbraco/presentation/umbraco/create/contentItemTasks.cs new file mode 100644 index 0000000000..4951a3cfff --- /dev/null +++ b/umbraco/presentation/umbraco/create/contentItemTasks.cs @@ -0,0 +1,78 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class contentItemTasks : interfaces.ITask + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set + { + _parentID = value; + } + get + { + return _parentID; + } + } + + public bool Save() + { + // TODO : fix it!! + return true; + } + + public bool Delete() + { + cms.businesslogic.contentitem.ContentItem d = new cms.businesslogic.contentitem.ContentItem(ParentID); + + // Version3.0 - moving to recycle bin instead of deletion + //d.delete(); + d.Move(-20); + return true; + + } + + public bool Sort() + { + return false; + } + + public contentItemTasks() + { + // + // TODO: Add constructor logic here + // + } + } +} diff --git a/umbraco/presentation/umbraco/create/contentItemTypeTasks.cs b/umbraco/presentation/umbraco/create/contentItemTypeTasks.cs new file mode 100644 index 0000000000..24fba8215a --- /dev/null +++ b/umbraco/presentation/umbraco/create/contentItemTypeTasks.cs @@ -0,0 +1,63 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class contentItemTypeTasks : interfaces.ITask + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + + cms.businesslogic.contentitem.ContentItemType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias); + return true; + } + + public bool Delete() + { + new cms.businesslogic.contentitem.ContentItemType(_parentID).delete(); + return true; + } + + public contentItemTypeTasks() + { + // + // TODO: Add constructor logic here + // + } + } +} diff --git a/umbraco/presentation/umbraco/create/contentTasks.cs b/umbraco/presentation/umbraco/create/contentTasks.cs new file mode 100644 index 0000000000..5c7288a16d --- /dev/null +++ b/umbraco/presentation/umbraco/create/contentTasks.cs @@ -0,0 +1,100 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class contentTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + private string _returnUrl = ""; + + public int UserId + { + set { _userID = value; } + } + + public string ReturnUrl + { + get { return _returnUrl; } + } + + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set + { + _parentID = value; + } + get + { + return _parentID; + } + } + + public bool Save() + { + cms.businesslogic.web.DocumentType dt = new cms.businesslogic.web.DocumentType(TypeID); + cms.businesslogic.web.Document d = cms.businesslogic.web.Document.MakeNew(Alias, dt, BusinessLogic.User.GetUser(_userID), ParentID); + if (d == null) + { + //TODO: Slace - Fix this to use the language files + BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.error, "Document Creation", "Document creation was canceled"); + return false; + } + else + { + _returnUrl = "editContent.aspx?id=" + d.Id.ToString() + "&isNew=true"; + return true; + } + } + + public bool Delete() + { + cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(ParentID); + + // Log + BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage(); + BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, ""); + + library.UnPublishSingleNode(d.Id); + + d.delete(); + + return true; + + } + + public bool Sort() + { + return false; + } + + public contentTasks() + { + // + // TODO: Add constructor logic here + // + } + } +} diff --git a/umbraco/presentation/umbraco/create/dictionaryTasks.cs b/umbraco/presentation/umbraco/create/dictionaryTasks.cs new file mode 100644 index 0000000000..a8ac6aecea --- /dev/null +++ b/umbraco/presentation/umbraco/create/dictionaryTasks.cs @@ -0,0 +1,100 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class dictionaryTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set + { + _parentID = value; + // NASTY HACK ON NASTY HACK§!! + // if (_parentID == 1) _parentID = -1; + } + get + { + return _parentID; + } + } + + public bool Save() + { + //check to see if key is already there + if (cms.businesslogic.Dictionary.DictionaryItem.hasKey(Alias)) + return false; + + // Create new dictionary item if name no already exist + if (ParentID > 0) + { + int id = cms.businesslogic.Dictionary.DictionaryItem.addKey(Alias, "", new cms.businesslogic.Dictionary.DictionaryItem(ParentID).key); + m_returnUrl = string.Format("settings/editDictionaryItem.aspx?id={0}", id); + } + else + { + int id = cms.businesslogic.Dictionary.DictionaryItem.addKey(Alias, ""); + m_returnUrl = string.Format("settings/editDictionaryItem.aspx?id={0}", id); + } + return true; + } + + public bool Delete() + { + BusinessLogic.Log.Add(LogTypes.Debug, ParentID, _typeID.ToString() + " " + _parentID.ToString() + " deleting " + Alias); + + new cms.businesslogic.Dictionary.DictionaryItem(ParentID).delete(); + return true; + } + + public bool Sort() + { + return false; + } + + public dictionaryTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/languageTasks.cs b/umbraco/presentation/umbraco/create/languageTasks.cs new file mode 100644 index 0000000000..d716c566ba --- /dev/null +++ b/umbraco/presentation/umbraco/create/languageTasks.cs @@ -0,0 +1,64 @@ +using System; +using System.Data; + +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class languageTasks : interfaces.ITask + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + cms.businesslogic.language.Language.MakeNew(Alias); + return true; + } + + public bool Delete() + { + new cms.businesslogic.language.Language(ParentID).Delete(); + return false; + } + + public languageTasks() + { + // + // TODO: Add constructor logic here + // + } + } + +} diff --git a/umbraco/presentation/umbraco/create/macroTasks.cs b/umbraco/presentation/umbraco/create/macroTasks.cs new file mode 100644 index 0000000000..17e1fcc197 --- /dev/null +++ b/umbraco/presentation/umbraco/create/macroTasks.cs @@ -0,0 +1,88 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class macroTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + protected static ISqlHelper SqlHelper + { + get { return Application.SqlHelper; } + } + + public int UserId + { + set { _userID = value; } + } + + + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + int id = umbraco.cms.businesslogic.macro.Macro.MakeNew(_alias).Id; + m_returnUrl = string.Format("developer/Macros/editMacro.aspx?macroID={0}", id); + return true; + } + + public bool Delete() + { + // Release cache + System.Web.Caching.Cache macroCache = System.Web.HttpRuntime.Cache; + if (macroCache["umbMacro" + ParentID.ToString()] != null) + { + macroCache.Remove("umbMacro" + ParentID.ToString()); + } + + // Clear cache! + macro.ClearAliasCache(); + new cms.businesslogic.macro.Macro(ParentID).Delete(); + return true; + } + + public macroTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/mediaTasks.cs b/umbraco/presentation/umbraco/create/mediaTasks.cs new file mode 100644 index 0000000000..5c4d3d6dbb --- /dev/null +++ b/umbraco/presentation/umbraco/create/mediaTasks.cs @@ -0,0 +1,89 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class mediaTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + private string _returnUrl = ""; + + public int UserId + { + set { _userID = value; } + } + + public string ReturnUrl + { + get { return _returnUrl; } + } + + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set + { + _parentID = value; + } + get + { + return _parentID; + } + } + + public bool Save() + { + cms.businesslogic.media.MediaType dt = new cms.businesslogic.media.MediaType(TypeID); + cms.businesslogic.media.Media m = cms.businesslogic.media.Media.MakeNew(Alias, dt, BusinessLogic.User.GetUser(_userID), ParentID); + _returnUrl = "editMedia.aspx?id=" + m.Id.ToString() + "&isNew=true"; + + return true; + } + + public bool Delete() + { + cms.businesslogic.media.Media d = new cms.businesslogic.media.Media(ParentID); + + // Log + BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage(); + BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, ""); + + d.delete(); + return true; + + } + + public bool Sort() + { + return false; + } + + public mediaTasks() + { + // + // TODO: Add constructor logic here + // + } + } +} diff --git a/umbraco/presentation/umbraco/create/memberTasks.cs b/umbraco/presentation/umbraco/create/memberTasks.cs new file mode 100644 index 0000000000..3e9d6ea3ae --- /dev/null +++ b/umbraco/presentation/umbraco/create/memberTasks.cs @@ -0,0 +1,127 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class memberTasks : interfaces.ITaskReturnUrl + { + /// + /// The new event handler + /// + new public delegate void NewUIMemberEventHandler(Member sender, string unencryptedPassword, NewMemberUIEventArgs e); + + new public static event NewUIMemberEventHandler NewMember; + new protected virtual void OnNewMember(NewMemberUIEventArgs e, string unencryptedPassword, Member m) + { + if (NewMember != null) + { + NewMember(m, unencryptedPassword, e); + } + } + + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + private string _returnUrl = ""; + + public int UserId + { + set { _userID = value; } + } + + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + public string ReturnUrl + { + get { return _returnUrl; } + } + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set + { + _parentID = value; + if (_parentID == 1) _parentID = -1; + } + get + { + return _parentID; + } + } + + public bool Save() + { + string[] nameAndMail = Alias.Split("|".ToCharArray()); + string name = nameAndMail[0]; + string email = nameAndMail.Length > 0 ? nameAndMail[1] : ""; + string password = nameAndMail.Length > 1 ? nameAndMail[2] : ""; + if (cms.businesslogic.member.Member.InUmbracoMemberMode() && TypeID != -1) + { + cms.businesslogic.member.MemberType dt = new cms.businesslogic.member.MemberType(TypeID); + cms.businesslogic.member.Member m = cms.businesslogic.member.Member.MakeNew(name, dt, BusinessLogic.User.GetUser(_userID)); + m.Password = password; + m.Email = email; + m.LoginName = name.Replace(" ", "").ToLower(); + + NewMemberUIEventArgs e = new NewMemberUIEventArgs(); + this.OnNewMember(e, password, m); + + _returnUrl = "members/editMember.aspx?id=" + m.Id.ToString(); + } + else + { + MembershipCreateStatus mc = new MembershipCreateStatus(); + Membership.CreateUser(name, password, email, "empty", "empty", true, out mc); + if (mc != MembershipCreateStatus.Success) + { + throw new Exception("Error creating Member: " + mc.ToString()); + } + _returnUrl = "members/editMember.aspx?id=" + System.Web.HttpContext.Current.Server.UrlEncode(name); + } + + return true; + } + + public bool Delete() + { + //cms.businesslogic.member.Member d = new cms.businesslogic.member.Member(ParentID); + //d.delete(); + //return true; + MembershipUser u = Membership.GetUser(Alias); + Membership.DeleteUser(u.UserName, true); + return true; + + + } + + public bool Sort() + { + return false; + } + + public memberTasks() + { + // + // TODO: Add constructor logic here + // + } + } +} diff --git a/umbraco/presentation/umbraco/create/nodetypeTasks.cs b/umbraco/presentation/umbraco/create/nodetypeTasks.cs new file mode 100644 index 0000000000..4655bdf11e --- /dev/null +++ b/umbraco/presentation/umbraco/create/nodetypeTasks.cs @@ -0,0 +1,93 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class nodetypeTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + cms.businesslogic.web.DocumentType dt = cms.businesslogic.web.DocumentType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias.Replace("'", "''")); + dt.IconUrl = "folder.gif"; + + // Create template? + if (ParentID == 1) + { + cms.businesslogic.template.Template[] t = { cms.businesslogic.template.Template.MakeNew(_alias, BusinessLogic.User.GetUser(_userID)) }; + dt.allowedTemplates = t; + dt.DefaultTemplate = t[0].Id; + } + + // Master Content Type? + if (TypeID != 0) + { + dt.MasterContentType = TypeID; + } + + m_returnUrl = "settings/editNodeTypeNew.aspx?id=" + dt.Id.ToString(); + + return true; + } + + public bool Delete() + { + new cms.businesslogic.web.DocumentType(ParentID).delete(); + + //after a document type is deleted, we clear the cache, as some content will now have disappeared. + library.RefreshContent(); + + return false; + } + + public nodetypeTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/standardTasks.cs b/umbraco/presentation/umbraco/create/standardTasks.cs deleted file mode 100644 index b27dd8ec08..0000000000 --- a/umbraco/presentation/umbraco/create/standardTasks.cs +++ /dev/null @@ -1,1647 +0,0 @@ -using System; -using System.Data; - -using System.Web.Security; -using umbraco.BusinessLogic; -using umbraco.DataLayer; -using umbraco.BasePages; -using umbraco.IO; -using umbraco.cms.businesslogic.member; - -namespace umbraco -{ - /// - /// Summary description for standardTasks. - /// - /// - - public class XsltTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - - - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - string template = _alias.Substring(0, _alias.IndexOf("|||")); - string fileName = _alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3).Replace(" ", ""); - string xsltTemplateSource = IOHelper.MapPath( SystemDirectories.Umbraco + "/xslt/templates/" + template); - string xsltNewFilename = IOHelper.MapPath( SystemDirectories.Xslt + "/" + fileName + ".xslt"); - - if (fileName.Contains("/")) //if there's a / create the folder structure for it - { - string[] folders = fileName.Split("/".ToCharArray()); - string xsltBasePath = IOHelper.MapPath(SystemDirectories.Xslt); - for (int i = 0; i < folders.Length - 1; i++) - { - xsltBasePath = System.IO.Path.Combine(xsltBasePath, folders[i]); - System.IO.Directory.CreateDirectory(xsltBasePath); - } - } - -// System.IO.File.Copy(xsltTemplateSource, xsltNewFilename, false); - - // update with xslt references - string xslt = ""; - System.IO.StreamReader xsltFile = System.IO.File.OpenText(xsltTemplateSource); - xslt = xsltFile.ReadToEnd(); - xsltFile.Close(); - - // prepare support for XSLT extensions - xslt = macro.AddXsltExtensionsToHeader(xslt); - System.IO.StreamWriter xsltWriter = System.IO.File.CreateText(xsltNewFilename); - xsltWriter.Write(xslt); - xsltWriter.Flush(); - xsltWriter.Close(); - - // Create macro? - if (ParentID == 1) - { - cms.businesslogic.macro.Macro m = - cms.businesslogic.macro.Macro.MakeNew( - helper.SpaceCamelCasing(_alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3))); - m.Xslt = fileName + ".xslt"; - } - - m_returnUrl = string.Format( SystemDirectories.Umbraco + "/developer/xslt/editXslt.aspx?file={0}.xslt", fileName); - - return true; - } - - public bool Delete() - { - string path = IOHelper.MapPath(SystemDirectories.Xslt + "/" + Alias.TrimStart('/')); - - System.Web.HttpContext.Current.Trace.Warn("", "*" + path + "*"); - - try - { - System.IO.File.Delete(path); - } - catch (Exception ex) - { - Log.Add(LogTypes.Error, UmbracoEnsuredPage.CurrentUser, -1, "Could not remove XSLT file " + Alias + ". ERROR: " + ex.Message); - } - return true; - } - - public XsltTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - - } - - public class DLRScriptingTasks : interfaces.ITaskReturnUrl - { - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set - { - _userID = value; - } - } - - public int TypeID - { - get - { - return _typeID; - } - set - { - _typeID = value; - } - } - - public string Alias - { - get - { - return _alias; - } - set - { - _alias = value; - } - } - - public int ParentID - { - get - { - return _parentID; - } - set - { - _parentID = value; - } - } - - public bool Save() - { - - string template = _alias.Substring(0, _alias.IndexOf("|||")).Trim(); - string fileName = _alias.Substring(_alias.IndexOf("|||") + 3, _alias.Length - _alias.IndexOf("|||") - 3).Replace(" ", ""); - - if (!fileName.Contains(".")) - fileName = _alias + ".py"; - - string scriptContent = ""; - if (!string.IsNullOrEmpty(template)) - { - System.IO.StreamReader templateFile = System.IO.File.OpenText( IOHelper.MapPath( IO.SystemDirectories.Umbraco + "/scripting/templates/" + template)); - scriptContent = templateFile.ReadToEnd(); - templateFile.Close(); - } - - - if (fileName.Contains("/")) //if there's a / create the folder structure for it - { - string[] folders = fileName.Split("/".ToCharArray()); - string basePath = IOHelper.MapPath(SystemDirectories.Python); - for (int i = 0; i < folders.Length - 1; i++) - { - basePath = System.IO.Path.Combine(basePath, folders[i]); - System.IO.Directory.CreateDirectory(basePath); - } - } - - string abFileName = IOHelper.MapPath(SystemDirectories.Python + "/" + fileName); - - System.IO.StreamWriter scriptWriter = System.IO.File.CreateText(abFileName); - scriptWriter.Write(scriptContent); - scriptWriter.Flush(); - scriptWriter.Close(); - - - if (ParentID == 1) - { - cms.businesslogic.macro.Macro m = cms.businesslogic.macro.Macro.MakeNew( - helper.SpaceCamelCasing(fileName.Substring(0, (fileName.LastIndexOf('.') + 1)).Trim('.'))); - m.ScriptingFile = fileName; - } - - m_returnUrl = string.Format(SystemDirectories.Umbraco + "/developer/python/editPython.aspx?file={0}", fileName); - return true; - } - - public bool Delete() - { - - string path = IOHelper.MapPath(SystemDirectories.Python + "/" + Alias.TrimStart('/')); - - System.Web.HttpContext.Current.Trace.Warn("", "*" + path + "*"); - try - { - System.IO.File.Delete(path); - } - catch (Exception ex) - { - Log.Add(LogTypes.Error, UmbracoEnsuredPage.CurrentUser, -1, "Could not remove XSLT file " + Alias + ". ERROR: " + ex.Message); - } - return true; - } - - public DLRScriptingTasks() - { - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - public class PythonTasks : DLRScriptingTasks { } - - public class ScriptTasks : interfaces.ITaskReturnUrl - { - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - string[] scriptFileAr = _alias.Split('¤'); - - - - string relPath = scriptFileAr[0]; - string fileName = scriptFileAr[1]; - string fileType = scriptFileAr[2]; - - int createFolder = ParentID; - - string basePath = IOHelper.MapPath(SystemDirectories.Scripts + "/" + relPath + fileName); - - if (createFolder == 1) - { - System.IO.Directory.CreateDirectory(basePath); - } - else - { - System.IO.File.Create(basePath + "." + fileType).Close(); - m_returnUrl = string.Format("settings/scripts/editScript.aspx?file={0}{1}.{2}", relPath, fileName, fileType); - } - return true; - } - - public bool Delete() - { - string path = IOHelper.MapPath( SystemDirectories.Scripts + "/" + _alias.TrimStart('/')); - - if (System.IO.File.Exists(path)) - System.IO.File.Delete(path); - else if(System.IO.Directory.Exists(path)) - System.IO.Directory.Delete(path, true); - - BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Delete, umbraco.BasePages.UmbracoEnsuredPage.CurrentUser, -1, _alias + " Deleted"); - return true; - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class CreatedPackageTasks : interfaces.ITaskReturnUrl - { - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - 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 Delete() - { - cms.businesslogic.packager.CreatedPackage.GetById(ParentID).Delete(); - return true; - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class macroTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - protected static ISqlHelper SqlHelper - { - get { return Application.SqlHelper; } - } - - public int UserId - { - set { _userID = value; } - } - - - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - int id = umbraco.cms.businesslogic.macro.Macro.MakeNew(_alias).Id; - m_returnUrl = string.Format("developer/Macros/editMacro.aspx?macroID={0}", id); - return true; - } - - public bool Delete() - { - // Release cache - System.Web.Caching.Cache macroCache = System.Web.HttpRuntime.Cache; - if (macroCache["umbMacro" + ParentID.ToString()] != null) - { - macroCache.Remove("umbMacro" + ParentID.ToString()); - } - - // Clear cache! - macro.ClearAliasCache(); - new cms.businesslogic.macro.Macro(ParentID).Delete(); - return true; - } - - public macroTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class MediaTypeTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - int id = cms.businesslogic.media.MediaType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias.Replace("'", "''")).Id; - m_returnUrl = string.Format("settings/editMediaType.aspx?id={0}", id); - return true; - } - - public bool Delete() - { - new cms.businesslogic.media.MediaType(_parentID).delete(); - return false; - } - - public MediaTypeTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - - } - - public class nodetypeTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - cms.businesslogic.web.DocumentType dt = cms.businesslogic.web.DocumentType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias.Replace("'", "''")); - dt.IconUrl = "folder.gif"; - - // Create template? - if (ParentID == 1) - { - cms.businesslogic.template.Template[] t = { cms.businesslogic.template.Template.MakeNew(_alias, BusinessLogic.User.GetUser(_userID)) }; - dt.allowedTemplates = t; - dt.DefaultTemplate = t[0].Id; - } - - // Master Content Type? - if (TypeID != 0) - { - dt.MasterContentType = TypeID; - } - - m_returnUrl = "settings/editNodeTypeNew.aspx?id=" + dt.Id.ToString(); - - return true; - } - - public bool Delete() - { - new cms.businesslogic.web.DocumentType(ParentID).delete(); - - //after a document type is deleted, we clear the cache, as some content will now have disappeared. - library.RefreshContent(); - - return false; - } - - public nodetypeTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class templateTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - int masterId = ParentID; - BusinessLogic.Log.Add(LogTypes.Debug, -1, "tp id:" + masterId.ToString()); - if (masterId > 0) - { - int id = cms.businesslogic.template.Template.MakeNew(Alias, BusinessLogic.User.GetUser(_userID), new cms.businesslogic.template.Template(masterId)).Id; - m_returnUrl = string.Format("settings/editTemplate.aspx?templateID={0}", id); - } - else - { - int id = cms.businesslogic.template.Template.MakeNew(Alias, BusinessLogic.User.GetUser(_userID)).Id; - m_returnUrl = string.Format("settings/editTemplate.aspx?templateID={0}", id); - - } - return true; - } - - public bool Delete() - { - new cms.businesslogic.template.Template(_parentID).delete(); - return false; - } - - public templateTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class mediaTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - private string _returnUrl = ""; - - public int UserId - { - set { _userID = value; } - } - - public string ReturnUrl - { - get { return _returnUrl; } - } - - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set - { - _parentID = value; - } - get - { - return _parentID; - } - } - - public bool Save() - { - cms.businesslogic.media.MediaType dt = new cms.businesslogic.media.MediaType(TypeID); - cms.businesslogic.media.Media m = cms.businesslogic.media.Media.MakeNew(Alias, dt, BusinessLogic.User.GetUser(_userID), ParentID); - _returnUrl = "editMedia.aspx?id=" + m.Id.ToString() + "&isNew=true"; - - return true; - } - - public bool Delete() - { - cms.businesslogic.media.Media d = new cms.businesslogic.media.Media(ParentID); - - // Log - BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage(); - BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, ""); - - d.delete(); - return true; - - } - - public bool Sort() - { - return false; - } - - public mediaTasks() - { - // - // TODO: Add constructor logic here - // - } - } - - public class contentTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - private string _returnUrl = ""; - - public int UserId - { - set { _userID = value; } - } - - public string ReturnUrl - { - get { return _returnUrl; } - } - - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set - { - _parentID = value; - } - get - { - return _parentID; - } - } - - public bool Save() - { - cms.businesslogic.web.DocumentType dt = new cms.businesslogic.web.DocumentType(TypeID); - cms.businesslogic.web.Document d = cms.businesslogic.web.Document.MakeNew(Alias, dt, BusinessLogic.User.GetUser(_userID), ParentID); - if (d == null) - { - //TODO: Slace - Fix this to use the language files - BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.error, "Document Creation", "Document creation was canceled"); - return false; - } - else - { - _returnUrl = "editContent.aspx?id=" + d.Id.ToString() + "&isNew=true"; - return true; - } - } - - public bool Delete() - { - cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(ParentID); - - // Log - BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage(); - BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, ""); - - library.UnPublishSingleNode(d.Id); - - d.delete(); - - return true; - - } - - public bool Sort() - { - return false; - } - - public contentTasks() - { - // - // TODO: Add constructor logic here - // - } - } - - public class userTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - private string _returnUrl = ""; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public string ReturnUrl - { - get { return _returnUrl; } - } - - public bool Save() - { - // Hot damn HACK > user is allways UserType with id = 1 = administrator ??? - // temp password deleted by NH - //BusinessLogic.User.MakeNew(Alias, Alias, "", BusinessLogic.UserType.GetUserType(1)); - //return true; - - MembershipCreateStatus status = MembershipCreateStatus.ProviderError; - try - { - // Password is auto-generated. They are they required to change the password by editing the user information. - MembershipUser u = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].CreateUser(Alias, - Membership.GeneratePassword( - Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredPasswordLength, - Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredNonAlphanumericCharacters), - "", "", "", true, null, out status); - - _returnUrl = string.Format("users/EditUser.aspx?id={0}", u.ProviderUserKey.ToString()); - - return status == MembershipCreateStatus.Success; - } - catch (Exception ex) - { - Log.Add(LogTypes.Error, ParentID, String.Format("Failed to create the user. Error from provider: {0}", status.ToString())); - Log.Add(LogTypes.Debug, ParentID, ex.Message); - return false; - } - } - - public bool Delete() - { - BusinessLogic.User u = BusinessLogic.User.GetUser(ParentID); - u.disable(); - return true; - } - - public userTasks() - { - // - // TODO: Add constructor logic here - // - } - } - - public class DataTypeTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - - int id = cms.businesslogic.datatype.DataTypeDefinition.MakeNew(BusinessLogic.User.GetUser(_userID), Alias).Id; - m_returnUrl = string.Format("developer/datatypes/editDataType.aspx?id={0}", id); - return true; - } - - public bool Delete() - { - cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(ParentID).delete(); - return true; - } - - public DataTypeTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - - } - - public class contentItemTypeTasks : interfaces.ITask - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - - cms.businesslogic.contentitem.ContentItemType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias); - return true; - } - - public bool Delete() - { - new cms.businesslogic.contentitem.ContentItemType(_parentID).delete(); - return true; - } - - public contentItemTypeTasks() - { - // - // TODO: Add constructor logic here - // - } - } - - public class MemberGroupTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - System.Web.Security.Roles.CreateRole(Alias); - // int id = cms.businesslogic.member.MemberGroup.MakeNew(Alias, BusinessLogic.User.GetUser(_userID)).Id; - m_returnUrl = string.Format("members/EditMemberGroup.aspx?id={0}", System.Web.HttpContext.Current.Server.UrlEncode(Alias)); - return true; - } - - public bool Delete() - { - // only build-in roles can be deleted - if (cms.businesslogic.member.Member.IsUsingUmbracoRoles()) - { - cms.businesslogic.member.MemberGroup.GetByName(Alias).delete(); - return true; - } - else - { - return false; - } - //try - //{ - - // MembershipUser u = Membership.GetUser(_parentID); - // Membership.DeleteUser(u.UserName); - // return true; - - //}catch - //{ - // Log.Add(LogTypes.Error, _parentID, "Member cannot be deleted."); - // return false; - //} - } - - public MemberGroupTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class MemberTypeTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - - int id = cms.businesslogic.member.MemberType.MakeNew(BusinessLogic.User.GetUser(_userID), Alias).Id; - m_returnUrl = string.Format("members/EditMemberType.aspx?id={0}", id); - return true; - } - - public bool Delete() - { - new cms.businesslogic.member.MemberType(_parentID).delete(); - return true; - } - - public MemberTypeTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class StylesheetTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - - int id = cms.businesslogic.web.StyleSheet.MakeNew(BusinessLogic.User.GetUser(_userID), Alias, "", "").Id; - m_returnUrl = string.Format("settings/stylesheet/editStylesheet.aspx?id={0}", id); - return true; - } - - public bool Delete() - { - cms.businesslogic.web.StyleSheet s = new cms.businesslogic.web.StyleSheet(ParentID); - s.delete(); - return true; - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class stylesheetPropertyTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - try - { - cms.businesslogic.web.StyleSheet s = new cms.businesslogic.web.StyleSheet(ParentID); - int id = s.AddProperty(Alias, BusinessLogic.User.GetUser(_userID)).Id; - m_returnUrl = string.Format("settings/stylesheet/property/EditStyleSheetProperty.aspx?id={0}", id); - } - catch - { - throw new ArgumentException("DER ER SKET EN FEJL MED AT OPRETTE NOGET MED ET PARENT ID : " + ParentID); - } - return true; - } - - public bool Delete() - { - cms.businesslogic.web.StylesheetProperty sp = new cms.businesslogic.web.StylesheetProperty(ParentID); - cms.businesslogic.web.StyleSheet s = sp.StyleSheet(); - s.saveCssToFile(); - sp.delete(); - - return true; - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - public class NewMemberUIEventArgs : System.ComponentModel.CancelEventArgs - { - } - - public class memberTasks : interfaces.ITaskReturnUrl - { - /// - /// The new event handler - /// - new public delegate void NewUIMemberEventHandler(Member sender, string unencryptedPassword, NewMemberUIEventArgs e); - - new public static event NewUIMemberEventHandler NewMember; - new protected virtual void OnNewMember(NewMemberUIEventArgs e, string unencryptedPassword, Member m) - { - if (NewMember != null) - { - NewMember(m, unencryptedPassword, e); - } - } - - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - private string _returnUrl = ""; - - public int UserId - { - set { _userID = value; } - } - - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - public string ReturnUrl - { - get { return _returnUrl; } - } - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set - { - _parentID = value; - if (_parentID == 1) _parentID = -1; - } - get - { - return _parentID; - } - } - - public bool Save() - { - string[] nameAndMail = Alias.Split("|".ToCharArray()); - string name = nameAndMail[0]; - string email = nameAndMail.Length > 0 ? nameAndMail[1] : ""; - string password = nameAndMail.Length > 1 ? nameAndMail[2] : ""; - if (cms.businesslogic.member.Member.InUmbracoMemberMode() && TypeID != -1) - { - cms.businesslogic.member.MemberType dt = new cms.businesslogic.member.MemberType(TypeID); - cms.businesslogic.member.Member m = cms.businesslogic.member.Member.MakeNew(name, dt, BusinessLogic.User.GetUser(_userID)); - m.Password = password; - m.Email = email; - m.LoginName = name.Replace(" ", "").ToLower(); - - NewMemberUIEventArgs e = new NewMemberUIEventArgs(); - this.OnNewMember(e, password, m); - - _returnUrl = "members/editMember.aspx?id=" + m.Id.ToString(); - } - else - { - MembershipCreateStatus mc = new MembershipCreateStatus(); - Membership.CreateUser(name, password, email, "empty", "empty", true, out mc); - if (mc != MembershipCreateStatus.Success) - { - throw new Exception("Error creating Member: " + mc.ToString()); - } - _returnUrl = "members/editMember.aspx?id=" + System.Web.HttpContext.Current.Server.UrlEncode(name); - } - - return true; - } - - public bool Delete() - { - //cms.businesslogic.member.Member d = new cms.businesslogic.member.Member(ParentID); - //d.delete(); - //return true; - MembershipUser u = Membership.GetUser(Alias); - Membership.DeleteUser(u.UserName, true); - return true; - - - } - - public bool Sort() - { - return false; - } - - public memberTasks() - { - // - // TODO: Add constructor logic here - // - } - } - - public class contentItemTasks : interfaces.ITask - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set - { - _parentID = value; - } - get - { - return _parentID; - } - } - - public bool Save() - { - // TODO : fix it!! - return true; - } - - public bool Delete() - { - cms.businesslogic.contentitem.ContentItem d = new cms.businesslogic.contentitem.ContentItem(ParentID); - - // Version3.0 - moving to recycle bin instead of deletion - //d.delete(); - d.Move(-20); - return true; - - } - - public bool Sort() - { - return false; - } - - public contentItemTasks() - { - // - // TODO: Add constructor logic here - // - } - } - - public class dictionaryTasks : interfaces.ITaskReturnUrl - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set - { - _parentID = value; - // NASTY HACK ON NASTY HACK§!! - // if (_parentID == 1) _parentID = -1; - } - get - { - return _parentID; - } - } - - public bool Save() - { - //check to see if key is already there - if (cms.businesslogic.Dictionary.DictionaryItem.hasKey(Alias)) - return false; - - // Create new dictionary item if name no already exist - if (ParentID > 0) - { - int id = cms.businesslogic.Dictionary.DictionaryItem.addKey(Alias, "", new cms.businesslogic.Dictionary.DictionaryItem(ParentID).key); - m_returnUrl = string.Format("settings/editDictionaryItem.aspx?id={0}", id); - } - else - { - int id = cms.businesslogic.Dictionary.DictionaryItem.addKey(Alias, ""); - m_returnUrl = string.Format("settings/editDictionaryItem.aspx?id={0}", id); - } - return true; - } - - public bool Delete() - { - BusinessLogic.Log.Add(LogTypes.Debug, ParentID, _typeID.ToString() + " " + _parentID.ToString() + " deleting " + Alias); - - new cms.businesslogic.Dictionary.DictionaryItem(ParentID).delete(); - return true; - } - - public bool Sort() - { - return false; - } - - public dictionaryTasks() - { - // - // TODO: Add constructor logic here - // - } - - #region ITaskReturnUrl Members - private string m_returnUrl = ""; - public string ReturnUrl - { - get { return m_returnUrl; } - } - - #endregion - } - - public class languageTasks : interfaces.ITask - { - - private string _alias; - private int _parentID; - private int _typeID; - private int _userID; - - public int UserId - { - set { _userID = value; } - } - public int TypeID - { - set { _typeID = value; } - get { return _typeID; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentID = value; } - get { return _parentID; } - } - - public bool Save() - { - cms.businesslogic.language.Language.MakeNew(Alias); - return true; - } - - public bool Delete() - { - new cms.businesslogic.language.Language(ParentID).Delete(); - return false; - } - - public languageTasks() - { - // - // TODO: Add constructor logic here - // - } - } - -} diff --git a/umbraco/presentation/umbraco/create/stylesheetPropertyTasks.cs b/umbraco/presentation/umbraco/create/stylesheetPropertyTasks.cs new file mode 100644 index 0000000000..0a9c94cd58 --- /dev/null +++ b/umbraco/presentation/umbraco/create/stylesheetPropertyTasks.cs @@ -0,0 +1,77 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class stylesheetPropertyTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + try + { + cms.businesslogic.web.StyleSheet s = new cms.businesslogic.web.StyleSheet(ParentID); + int id = s.AddProperty(Alias, BusinessLogic.User.GetUser(_userID)).Id; + m_returnUrl = string.Format("settings/stylesheet/property/EditStyleSheetProperty.aspx?id={0}", id); + } + catch + { + throw new ArgumentException("DER ER SKET EN FEJL MED AT OPRETTE NOGET MED ET PARENT ID : " + ParentID); + } + return true; + } + + public bool Delete() + { + cms.businesslogic.web.StylesheetProperty sp = new cms.businesslogic.web.StylesheetProperty(ParentID); + cms.businesslogic.web.StyleSheet s = sp.StyleSheet(); + s.saveCssToFile(); + sp.delete(); + + return true; + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/templateTasks.cs b/umbraco/presentation/umbraco/create/templateTasks.cs new file mode 100644 index 0000000000..7ef55bc8ac --- /dev/null +++ b/umbraco/presentation/umbraco/create/templateTasks.cs @@ -0,0 +1,83 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class templateTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public bool Save() + { + int masterId = ParentID; + BusinessLogic.Log.Add(LogTypes.Debug, -1, "tp id:" + masterId.ToString()); + if (masterId > 0) + { + int id = cms.businesslogic.template.Template.MakeNew(Alias, BusinessLogic.User.GetUser(_userID), new cms.businesslogic.template.Template(masterId)).Id; + m_returnUrl = string.Format("settings/editTemplate.aspx?templateID={0}", id); + } + else + { + int id = cms.businesslogic.template.Template.MakeNew(Alias, BusinessLogic.User.GetUser(_userID)).Id; + m_returnUrl = string.Format("settings/editTemplate.aspx?templateID={0}", id); + + } + return true; + } + + public bool Delete() + { + new cms.businesslogic.template.Template(_parentID).delete(); + return false; + } + + public templateTasks() + { + // + // TODO: Add constructor logic here + // + } + + #region ITaskReturnUrl Members + private string m_returnUrl = ""; + public string ReturnUrl + { + get { return m_returnUrl; } + } + + #endregion + } +} diff --git a/umbraco/presentation/umbraco/create/userTasks.cs b/umbraco/presentation/umbraco/create/userTasks.cs new file mode 100644 index 0000000000..050f0aade2 --- /dev/null +++ b/umbraco/presentation/umbraco/create/userTasks.cs @@ -0,0 +1,92 @@ +using System; +using System.Data; +using System.Web.Security; +using umbraco.BusinessLogic; +using umbraco.DataLayer; +using umbraco.BasePages; +using umbraco.IO; +using umbraco.cms.businesslogic.member; + +namespace umbraco +{ + public class userTasks : interfaces.ITaskReturnUrl + { + + private string _alias; + private int _parentID; + private int _typeID; + private int _userID; + private string _returnUrl = ""; + + public int UserId + { + set { _userID = value; } + } + public int TypeID + { + set { _typeID = value; } + get { return _typeID; } + } + + + public string Alias + { + set { _alias = value; } + get { return _alias; } + } + + public int ParentID + { + set { _parentID = value; } + get { return _parentID; } + } + + public string ReturnUrl + { + get { return _returnUrl; } + } + + public bool Save() + { + // Hot damn HACK > user is allways UserType with id = 1 = administrator ??? + // temp password deleted by NH + //BusinessLogic.User.MakeNew(Alias, Alias, "", BusinessLogic.UserType.GetUserType(1)); + //return true; + + MembershipCreateStatus status = MembershipCreateStatus.ProviderError; + try + { + // Password is auto-generated. They are they required to change the password by editing the user information. + MembershipUser u = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].CreateUser(Alias, + Membership.GeneratePassword( + Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredPasswordLength, + Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].MinRequiredNonAlphanumericCharacters), + "", "", "", true, null, out status); + + _returnUrl = string.Format("users/EditUser.aspx?id={0}", u.ProviderUserKey.ToString()); + + return status == MembershipCreateStatus.Success; + } + catch (Exception ex) + { + Log.Add(LogTypes.Error, ParentID, String.Format("Failed to create the user. Error from provider: {0}", status.ToString())); + Log.Add(LogTypes.Debug, ParentID, ex.Message); + return false; + } + } + + public bool Delete() + { + BusinessLogic.User u = BusinessLogic.User.GetUser(ParentID); + u.disable(); + return true; + } + + public userTasks() + { + // + // TODO: Add constructor logic here + // + } + } +} diff --git a/umbraco/presentation/umbraco/umbraco.aspx b/umbraco/presentation/umbraco/umbraco.aspx index 42aee1864a..94667b3997 100644 --- a/umbraco/presentation/umbraco/umbraco.aspx +++ b/umbraco/presentation/umbraco/umbraco.aspx @@ -101,8 +101,6 @@
- -