!function(){"use strict";function a(a,b){a.state("preferences",{abstract:!0,views:{preferences:{templateUrl:"preferences.html",controller:"PreferencesController",controllerAs:"app"}}}).state("preferences.general",{url:"/general",views:{module:{templateUrl:"generalPreferences.html"}}}).state("preferences.calendars",{url:"/calendars",views:{module:{templateUrl:"calendarsPreferences.html"}}}).state("preferences.addressbooks",{url:"/addressbooks",views:{module:{templateUrl:"addressbooksPreferences.html"}}}).state("preferences.mailer",{url:"/mailer",views:{module:{templateUrl:"mailerPreferences.html"}}}),b.otherwise("/general")}function b(a){a.$on("$routeChangeError",function(a,b,c,d){console.error(a,b,c,d)})}angular.module("SOGo.PreferencesUI",["ui.router","ck","angularFileUpload","SOGo.Common","SOGo.MailerUI","SOGo.ContactsUI","SOGo.Authentication","as.sortable"]).config(a).run(b),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["$rootScope"]}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j){function k(){t.account.security&&t.account.security.hasCertificate&&u.$certificate().then(function(a){t.certificate=a},function(){delete t.account.security.hasCertificate})}function m(a){var b=a.type.indexOf("pkcs12")>0||/\.(p12|pfx)$/.test(a.name);return t.form.certificateFilename.$setValidity("fileformat",b),b}function n(){return!(i>0)&&!j}function o(){t.uploader.queue[0].formData=[{password:t.certificatePassword}],t.uploader.uploadItem(0)}function p(a){t.form=a,t.uploader.clearQueue()}function q(){u.$removeCertificate().then(function(){delete t.account.security.hasCertificate})}function r(){b.cancel()}function s(){b.hide()}var t=this,u=new f({id:i,security:h.security});t.defaultPort=143,t.defaults=g,t.account=h,t.accountId=i,t.customFromIsReadonly=n,t.onBeforeUploadCertificate=p,t.removeCertificate=q,t.importCertificate=o,t.cancel=r,t.save=s,t.hostnameRE=i>0?/^(?!(127\.0\.0\.1|localhost(?:\.localdomain)?)$)/:/./,t.account.encryption?"ssl"==t.account.encryption&&(t.defaultPort=993):t.account.encryption="none",k(),t.uploader=new c({url:[e.activeUser("folderURL")+"Mail",i,"importCertificate"].join("/"),autoUpload:!1,queueLimit:1,filters:[{name:m,fn:m}],onAfterAddingFile:function(a){t.certificateFilename=a.file.name},onSuccessItem:function(b,c,d,e){this.clearQueue(),a(function(){_.assign(t.account,{security:{hasCertificate:!0}})}),k()},onErrorItem:function(a,b,c,e){d.alert(l("Error"),l("An error occurred while importing the certificate. Verify your password."))}})}a.$inject=["$timeout","$mdDialog","FileUploader","Dialog","sgSettings","Account","defaults","account","accountId","mailCustomFromEnabled"],angular.module("SOGo.PreferencesUI").controller("AccountDialogController",a)}(),function(){"use strict";function a(a,b,c,d,e,f){function g(){c.cancel()}function h(){var a=[o.filter.actions];return"allmessages"!=o.filter.match&&a.push(o.filter.rules),_.every(a,function(a){return a&&a.length>0})}function i(a){c.hide()}function j(a){o.filter.rules||(o.filter.rules=[]),o.filter.rules.push({field:"subject",operator:"contains"})}function k(a){o.filter.rules.splice(a,1)}function m(a){o.filter.actions||(o.filter.actions=[]),o.filter.actions.push({method:"discard"})}function n(a){o.filter.actions.splice(a,1)}var o=this,p=b.sieveCapabilities,q=b.forwardEnabled;b.vacationEnabled;o.filter=d,o.mailboxes=e,o.labels=f,o.cancel=g,o.hasRulesAndActions=h,o.save=i,o.addMailFilterRule=j,o.removeMailFilterRule=k,o.addMailFilterAction=m,o.removeMailFilterAction=n,o.fieldLabels={subject:l("Subject"),from:l("From"),to:l("To"),cc:l("Cc"),to_or_cc:l("To or Cc"),size:l("Size (Kb)"),header:l("Header")},p.indexOf("body")>-1&&(o.fieldLabels.body=l("Body")),o.methodLabels={discard:l("Discard the message"),keep:l("Keep the message"),stop:l("Stop processing filter rules")},q&&(o.methodLabels.redirect=l("Forward the message to")),p.indexOf("reject")>-1&&(o.methodLabels.reject=l("Send a reject message")),p.indexOf("fileinto")>-1&&(o.methodLabels.fileinto=l("File the message in")),(p.indexOf("imapflags")>-1||p.indexOf("imap4flags")>-1)&&(o.methodLabels.addflag=l("Flag the message with")),o.numberOperatorLabels={under:l("is under"),over:l("is over")},o.textOperatorLabels={is:l("is"),is_not:l("is not"),contains:l("contains"),contains_not:l("does not contain"),matches:l("matches"),matches_not:l("does not match")},p.indexOf("regex")>-1&&(o.textOperatorLabels.regex=l("matches regex"),o.textOperatorLabels.regex_not=l("does not match regex")),o.flagLabels={seen:l("Seen"),deleted:l("Deleted"),answered:l("Answered"),flagged:l("Flagged"),junk:l("Junk"),not_junk:l("Not Junk")}}a.$inject=["$scope","$window","$mdDialog","filter","mailboxes","labels"],angular.module("SOGo.PreferencesUI").controller("FiltersDialogController",a)}(),function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k,m,n,o){var p,q=this,r=[],s=(new Date).beginOfDay();this.$onInit=function(){this.preferences=n,this.passwords={newPassword:null,newPasswordConfirmation:null},this.timeZonesList=b.timeZonesList,this.timeZonesSearchText="",this.sieveVariablesCapability=b.sieveCapabilities.indexOf("variables")>=0,this.mailLabelKeyRE=new RegExp('^[^(){} %*"\\\\]*$'),h.activeUser("path").mail&&(p=new m({id:0}),p.$getMailboxes().then(function(){for(var a=p.$flattenMailboxes({all:!0}),b=-1,c=a.length;++b0&&angular.isDefined(this.preferences.defaults.Forward)&&this.preferences.defaults.Forward.enabled&&angular.isDefined(this.preferences.defaults.Forward.forwardAddress))for(h=this.preferences.defaults.Forward.forwardAddress.split(","),i=b.defaultEmailAddresses.split(/, */),_.forEach(i,function(a){var b=a.split("@")[1];b&&k.push(b.toLowerCase())}),e=0;e=0&&2==b.forwardConstraints&&(j.alert(l("Error"),l("You are not allowed to forward your messages to an internal email address.")),f=!1);return this.preferences.defaults.SOGoMailLabelsColorsKeys.length==this.preferences.defaults.SOGoMailLabelsColorsValues.length&&this.preferences.defaults.SOGoMailLabelsColorsKeys.length==_.uniq(this.preferences.defaults.SOGoMailLabelsColorsKeys).length||(j.alert(l("Error"),l("IMAP labels must have unique names.")),_.forEach(this.preferences.defaults.SOGoMailLabelsColorsKeys,function(a,b,d){c["mailIMAPLabel_"+b].$dirty&&(d.indexOf(a)!=b||d.indexOf(a,b+1)>-1)&&(c["mailIMAPLabel_"+b].$setValidity("duplicate",!1),f=!1)})),f?this.preferences.$save().then(function(a){d&&d.quick||(g.show(g.simple().content(l("Preferences saved")).position("bottom right").hideDelay(2e3)),c.$setPristine())}):a.reject()},this.canChangePassword=function(){return!!(this.passwords.newPassword&&this.passwords.newPassword.length>0&&this.passwords.newPasswordConfirmation&&this.passwords.newPasswordConfirmation.length&&this.passwords.newPassword==this.passwords.newPasswordConfirmation)},this.changePassword=function(){o.changePassword(this.passwords.newPassword).then(function(){var a=f.alert({title:l("Password"),content:l("The password was changed successfully."),ok:l("OK")});f.show(a).finally(function(){a=void 0})},function(a){var b=f.alert({title:l("Password"),content:a,ok:l("OK")});f.show(b).finally(function(){b=void 0})})},this.timeZonesListFilter=function(a){return _.filter(this.timeZonesList,function(b){return b.toUpperCase().indexOf(a.toUpperCase())>=0})},this.updateVacationDates=function(){var a=this.preferences.defaults;a&&a.Vacation&&a.Vacation.enabled&&(this.toggleVacationStartDate(),this.toggleVacationEndDate())},this.toggleVacationStartDate=function(){var a;a=this.preferences.defaults.Vacation,a.startDateEnabled&&a.endDateEnabled&&a.startDate.getTime()>a.endDate.getTime()&&(a.startDate=new Date(a.endDate.getTime()),a.startDate.addDays(-1))},this.toggleVacationEndDate=function(){var a;a=this.preferences.defaults.Vacation,a.endDateEnabled&&a.startDateEnabled&&a.endDate.getTime()=s.getTime()),c},this.validateVacationEndDate=function(a){var b=q.preferences.defaults,c=!0;return b&&b.Vacation&&b.Vacation.enabled&&b.Vacation.endDateEnabled&&(c=(!b.Vacation.startDateEnabled||a.getTime()>b.Vacation.startDate.getTime())&&a.getTime()>=s.getTime()),c}}a.$inject=["$q","$window","$state","$mdMedia","$mdSidenav","$mdDialog","$mdToast","sgSettings","sgFocus","Dialog","User","Account","Preferences","Authentication"],angular.module("SOGo.PreferencesUI").controller("PreferencesController",a)}(); //# sourceMappingURL=Preferences.js.map