From: wolfgang Date: Wed, 11 Jul 2007 05:05:30 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1102 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25aa1b48de9d5d8dc986541920f7a25b2cb3cf7b;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1102 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/ChangeLog b/ChangeLog index 607614a8..2b35e808 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-07-11 Wolfgang Sourdeau + + * UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions + -quotasAction]): new method that returns a json representation of + the mailbox quotas. + 2007-07-10 Wolfgang Sourdeau * SoObjects/Mailer/SOGoMailBaseObject.m ([SOGoMailBaseObject diff --git a/NEWS b/NEWS index e003261c..9f170c71 100644 --- a/NEWS +++ b/NEWS @@ -3,14 +3,16 @@ - added the ability to specify a super user through the SOGoSuperUsername user default; - added the ability to view the message source; -- no longer autocreate folders if we are not their owners; +- don't autocreate folders if we are not their owners; - made compatible with PostgreSQL 8.2; - the months and years menus of the date selector would no longer appear; - fixed a bug which would produce task SQL records which would violate non-null constraints on the quick calendar tables; +- the tasks due date was wrongly set because of a change in the API; - it was impossible to reset the start and the due date in the task editor whenever they were set once; - imap folders with non-ascii characters are now correctly accessed; +- display the quotas of the selected mailbox on servers that support quotas; Local variables: mode: text diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 26912cf6..e00c4c37 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -126,3 +126,5 @@ "Do you really want to move this folder into the trash ?" = "Do you really want to move this folder into the trash ?"; "Operation failed" = "Operation failed"; + +"quotasFormat" = "Quotas: %{0} used on %{1} Kb; %{2}%"; diff --git a/UI/MailerUI/French.lproj/Localizable.strings b/UI/MailerUI/French.lproj/Localizable.strings index b3c4aaf4..eb928182 100644 --- a/UI/MailerUI/French.lproj/Localizable.strings +++ b/UI/MailerUI/French.lproj/Localizable.strings @@ -176,3 +176,5 @@ "Do you really want to move this folder into the trash ?" = "Voulez-vous vraiment déplacer le dossier sélectionné dans la corbeille?"; "Operation failed" = "L'opération a échoué."; + +"quotasFormat" = "Quotas: %{0} Ko utilisés sur %{1}; %{2}%"; diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 8f971f53..52b9d356 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -29,10 +29,12 @@ #import #import #import +#import #import #import #import +#import #import "UIxMailFolderActions.h" @@ -249,4 +251,29 @@ return [self _subscriptionStubAction]; } +- (WOResponse *) quotasAction +{ + SOGoMailFolder *folder; + NSURL *folderURL; + id infos; + WOResponse *response; + NGImap4Client *client; + NSString *responseString; + + response = [context response]; + [response setStatus: 200]; + [response setHeader: @"text/plain; charset=UTF-8" + forKey: @"content-type"]; + + folder = [self clientObject]; + folderURL = [folder imap4URL]; + + client = [[folder imap4Connection] client]; + infos = [client getQuotaRoot: [folder nameInContainer]]; + responseString = [[infos objectForKey: @"quotas"] jsonRepresentation]; + [response appendContentString: responseString]; + + return response; +} + @end diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 32f6c3eb..6746f77a 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -95,6 +95,11 @@ categories = { actionClass = "UIxMailFolderActions"; actionName = "unsubscribe"; }; + quotas = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "quotas"; + }; view = { protectedBy = "View"; pageName = "UIxMailListView"; diff --git a/UI/WebServerResources/JavascriptAPIExtensions.js b/UI/WebServerResources/JavascriptAPIExtensions.js index 7cdc85ec..cc07602a 100644 --- a/UI/WebServerResources/JavascriptAPIExtensions.js +++ b/UI/WebServerResources/JavascriptAPIExtensions.js @@ -2,6 +2,15 @@ String.prototype.trim = function() { return this.replace(/(^\s+|\s+$)/g, ''); } +String.prototype.formatted = function() { + var newString = this; + + for (var i = 0; i < arguments.length; i++) + newString = newString.replace("%{" + i + "}", arguments[i], "g"); + + return newString; +} + String.prototype.repeat = function(count) { var newString = ""; for (var i = 0; i < count; i++) { diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 0534c65f..434753d4 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -461,6 +461,10 @@ function openMailbox(mailbox, reload, idx) { document.messageListAjaxRequest = triggerAjaxRequest(url, messageListCallback, currentMessages[mailbox]); + + var quotasUrl = ApplicationBaseURL + mailbox + "/quotas"; + document.quotasAjaxRequest + = triggerAjaxRequest(quotasUrl, quotasCallback); } } @@ -509,6 +513,30 @@ function messageListCallback(http) { log("messageListCallback: problem during ajax request (readyState = " + http.readyState + ", status = " + http.status + ")"); } +function quotasCallback(http) { + if (http.readyState == 4 + && http.status == 200) { + var hasQuotas = false; + + var quotas = http.responseText.evalJSON(true); + for (var i in quotas) { + hasQuotas = true; + break; + } + + if (hasQuotas) { + var treePath = currentMailbox.split("/"); + var mbQuotas = quotas["/" + treePath[2]]; + var used = mbQuotas["usedSpace"]; + var max = mbQuotas["maxQuota"]; + var percents = (Math.round(used * 10000 / max) / 100); + var format = labels["quotasFormat"].decodeEntities(); + var text = format.formatted(used, max, percents); + window.status = text; + } + } +} + function onMessageContextMenu(event) { var menu = $('messageListMenu'); Event.observe(menu, "hideMenu", onMessageContextMenuHide); @@ -815,18 +843,6 @@ function onMenuViewMessageSource(event) { function newContactFromEmail(event) { var mailto = document.menuTarget.innerHTML; - // var emailre - // = /([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])/g; - // emailre.exec(mailto); - // email = RegExp.$1; - - // var namere = /(\w[\w\ _-]+)\ (<|<)/; - // var c_name = ''; - // if (namere.test(mailto)) { - // namere.exec(mailto); - // c_name += RegExp.$1; - // } - var email = extractEmailAddress(mailto); var c_name = extractEmailName(mailto); if (email.length > 0) @@ -841,7 +857,7 @@ function newContactFromEmail(event) { } return false; /* stop following the link */ - } +} function newEmailTo(sender) { return openMailTo(document.menuTarget.innerHTML);