searchInput:v,negative:n}),vm.currentSearchParam=""}}functionnewFolder(parentFolder){Dialog.prompt(l("New folder"),l("Enter the new name of your folder :")).then(function(name){parentFolder.$newMailbox(parentFolder.id,name).then(function(){},function(data,status){Dialog.alert(l('An error occured while creating the mailbox "%{0}".',name),l(data.error))})})}functiondelegate(account){functionMailboxDelegationController($scope,$mdDialog,User,account){functionuserFilter($query){returnUser.$filter($query,account.delegates)}functioncloseModal(){$mdDialog.hide()}functionremoveUser(user){account.$removeDelegate(user.uid)["catch"](function(data,status){Dialog.alert(l("Warning"),l("An error occured please try again."))})}functionaddUser(data){data&&account.$addDelegate(data).then(function(){vm.userToAdd="",vm.searchText=""},function(error){Dialog.alert(l("Warning"),error)})}varvm=this;vm.users=account.delegates,vm.account=account,vm.userToAdd="",vm.searchText="",vm.userFilter=userFilter,vm.closeModal=closeModal,vm.removeUser=removeUser,vm.addUser=addUser}$mdDialog.show({templateUrl:account.id+"/delegation",controller:MailboxDelegationController,controllerAs:"delegate",clickOutsideToClose:!0,escapeToClose:!0,locals:{User:User,account:account}}),MailboxDelegationController.$inject=["$scope","$mdDialog","User","account"]}functioneditFolder(folder){vm.editMode=folder.path,focus("mailboxName_"+folder.path)}functionrevertEditing(folder){folder.$reset(),vm.editMode=!1}functionselectFolder(account,folder){vm.editMode!=folder.path&&(vm.editMode=!1,vm.showingAdvancedSearch=!1,vm.service.$virtualMode=!1,$state.go("mail.account.mailbox",{accountId:account.id,mailboxId:encodeUriFilter(folder.path)}))}functionsaveFolder(folder){folder.$rename()}functioncompactFolder(folder){folder.$compact().then(function(){},function(error){Dialog.alert(l("Warning"),error)})}functionemptyTrashFolder(folder){folder.$emptyTrash().then(function(){},function(error){Dialog.alert(l("Warning"),error)})}functionexportMails(folder){window.location.href=ApplicationBaseURL+"/"+folder.id+"/exportFolder"}functionconfirmDelete(folder){Dialog.confirm(l("Confirmation"),l("Do you really want to move this folder into the trash ?")).then(function(){folder.$delete().then(function(){$state.go("mail")},function(data,status){Dialog.alert(l('An error occured while deleting the mailbox "%{0}".',folder.name),l(data.error))})})}functionmarkFolderRead(folder){folder.$markAsRead()}functionshare(folder){folder.$acl.$users().then(function(){$mdDialog.show({templateUrl:folder.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:folder.$acl.users,User:User,folder:folder}})})}functionmetadataForFolder(folder){return"inbox"==folder.type?{name:folder.name,icon:"inbox"}:"draft"==folder.type?{name:l("DraftsFolderName"),icon:"drafts"}:"sent"==folder.type?{name:l("SentFolderName"),icon:"send"}:"trash"==folder.type?{name:l("TrashFolderName"),icon:"delete"}:"additional"==folder.type?{name:folder.name,icon:"folder_shared"}:{name:folder.name,icon:"folder"}}functionsetFolderAs(folder,type){folder.$setFolderAs(type).then(function(){folder.$account.$getMailboxes({reload:!0})},function(error){Dialog.alert(l("Warning"),error)})}functionrefreshUnseenCount(){varunseenCountFolders=window.unseenCountFolders;_.forEach(vm.accounts,function(account){_.includes(unseenCountFolders,account.id+"/folderINBOX")||unseenCountFolders.push(account.id+"/folderINBOX"),_.forEach(account.$$flattenMailboxes,function(mailbox){angular.isDefined(mailbox.unseenCount)&&!_.includes(unseenCountFolders,mailbox.id)&&unseenCountFolders.push(mailbox.id)})}),Account.$$resource.post("","unseenCount",{mailboxes:unseenCountFolders}).then(function(data){_.forEach(vm.accounts,function(account){_.forEach(account.$$flattenMailboxes,function(mailbox){data[mailbox.id]&&(mailbox.unseenCount=data[mailbox.id])})})}),Preferences.ready().then(function(){varrefreshViewCheck=Preferences.defaults.SOGoRefreshViewCheck;refreshViewCheck&&"manually"!=refreshViewCheck