protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request.QueryString["id"]))
                return;

            CheckUser(Request.QueryString["id"]);

            var save = pnlUmbraco.Menu.NewButton();
            save.ID = "btnSave";
            save.ButtonType = uicontrols.MenuButtonType.Primary;
            save.OnClientClick = "SavePermissions(); return false;";
            save.Text = ui.Text("save");
            save.ToolTip = ui.Text("save");


            nodePermissions.UserID = Convert.ToInt32(Request.QueryString["id"]);
            pnlUmbraco.Text = ui.Text("user", "userPermissions");
            pnl1.Text = ui.Text("user", "permissionSelectPages");

			if (!IsPostBack)
			{	
				ClientTools cTools = new ClientTools(this);
				cTools.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<Trees.UserPermissions>().Tree.Alias)
					.SyncTree(Request.QueryString["id"], false);
			}
        }
Esempio n. 2
0
        public UploadResponse ProcessUploadRequest(HttpContext context)
        {
            int parentNodeId;
            if (int.TryParse(context.Request["parentNodeId"], out parentNodeId) && context.Request.Files.Count > 0)
            {
                try
                {
                    var parentNode = new Media(parentNodeId);
                    // Check FilePath
                    if (!string.IsNullOrEmpty(context.Request["path"]))
                    {
                        var pathParts = context.Request["path"].Trim('/').Split('/');
                        
                        foreach (var pathPart in pathParts.Where(part => string.IsNullOrWhiteSpace(part) == false))
                                parentNode = GetOrCreateFolder(parentNode, pathPart);

                        parentNodeId = parentNode.Id;
                    }

                    // Check whether to replace existing
                    bool parsed;
                    var replaceExisting = (context.Request["replaceExisting"] == "1" || (bool.TryParse(context.Request["replaceExisting"], out parsed) && parsed));

                    // loop through uploaded files
                    for (var j = 0; j < context.Request.Files.Count; j++)
                    {
                        // get the current file
                        var uploadFile = context.Request.Files[j];

                        using (var inputStream = uploadFile.InputStream)
                        {
                            // if there was a file uploded
                            if (uploadFile.ContentLength > 0)
                            {
                                // Ensure we get the filename without the path in IE in intranet mode 
                                // http://stackoverflow.com/questions/382464/httppostedfile-filename-different-from-ie
                                var fileName = uploadFile.FileName;
                                if (fileName.LastIndexOf(@"\") > 0)
                                    fileName = fileName.Substring(fileName.LastIndexOf(@"\") + 1);

                                fileName = Umbraco.Core.IO.IOHelper.SafeFileName(fileName);

                                var postedMediaFile = new PostedMediaFile
                                {
                                    FileName = fileName,
                                    DisplayName = context.Request["name"],
                                    ContentType = uploadFile.ContentType,
                                    ContentLength = uploadFile.ContentLength,
                                    InputStream = inputStream,
                                    ReplaceExisting = replaceExisting
                                };

                                // Get concrete MediaFactory
                                var factory = MediaFactory.GetMediaFactory(parentNodeId, postedMediaFile, AuthenticatedUser);

                                // Handle media Item
                                var media = factory.HandleMedia(parentNodeId, postedMediaFile, AuthenticatedUser);
                            }
                        }
                    }

                    var scripts = new ClientTools(new Page());
                    scripts.SyncTree(parentNode.Path, true);

                    // log succes
                    LogHelper.Info<MediaUploader>(string.Format("Success uploading to parent {0}", parentNodeId));
                }
                catch (Exception e)
                {
                    // log error
                    LogHelper.Error<MediaUploader>(string.Format("Error uploading to parent {0}", parentNodeId), e);
                }
            }
            else
            {
                // log error
                LogHelper.Warn<MediaUploader>(string.Format("Parent node id is in incorrect format: {0}", parentNodeId));
            }
            
            return new UploadResponse();
        }
 /// <summary>
 /// Updates the Node in the Tree
 /// </summary>
 private void UpdateTreeNode()
 {
     var clientTools = new ClientTools(this.Page);
     clientTools
         .SyncTree(_contentType.Path, true);
 }
Esempio n. 4
0
 public void speechBubble(speechBubbleIcon i, string header, string body)
 {
     ClientTools.ShowSpeechBubble(i, header, body);
 }