]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_privacy.erl: Privacy list items must be processed in the
authorBadlop <badlop@process-one.net>
Fri, 16 Jan 2009 16:06:21 +0000 (16:06 +0000)
committerBadlop <badlop@process-one.net>
Fri, 16 Jan 2009 16:06:21 +0000 (16:06 +0000)
specified order (EJAB-848)
* src/mod_privacy_odbc.erl: Likewise

SVN Revision: 1822

ChangeLog
src/mod_privacy.erl
src/mod_privacy_odbc.erl

index 9bf47ea5c11e73fd7400af0c59e92d8eaa114df0..774585bc20bcbc9155bd42e8504afdc76a1b1402 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-16  Badlop  <badlop@process-one.net>
+
+       * src/mod_privacy.erl: Privacy list items must be processed in the
+       specified order (EJAB-848)
+       * src/mod_privacy_odbc.erl: Likewise
+
 2009-01-13  Badlop  <badlop@process-one.net>
 
        * doc/release_notes_2.0.3.txt: Add release notes
index a9da69090eccf7a8003877e9a531180fb05a113e..5fd604511936cba2e267bc375512792f0e6bc0db 100644 (file)
@@ -414,7 +414,12 @@ parse_items(Els) ->
     parse_items(Els, []).
 
 parse_items([], Res) ->
-    lists:reverse(Res);
+    %% Sort the items by their 'order' attribute
+    %% 5 is the position of 'order' attribute in a #listitem tuple
+    %% This integer can be calculated at runtime with:
+    %% 2 + length(lists:takewhile(fun(E) -> E =/= order end,
+    %%                                record_info(fields, listitem))),
+    lists:keysort(5, Res);
 parse_items([{xmlelement, "item", Attrs, SubEls} | Els], Res) ->
     Type   = xml:get_attr("type",   Attrs),
     Value  = xml:get_attr("value",  Attrs),
index 1fdf799d736f080e263ca9ac343de34b3ceeab03..aac2955284471e06f4b6b3e86c09659e314cc7c0 100644 (file)
@@ -414,7 +414,12 @@ parse_items(Els) ->
     parse_items(Els, []).
 
 parse_items([], Res) ->
-    lists:reverse(Res);
+    %% Sort the items by their 'order' attribute
+    %% 5 is the position of 'order' attribute in a #listitem tuple
+    %% This integer can be calculated at runtime with:
+    %% 2 + length(lists:takewhile(fun(E) -> E =/= order end,
+    %%                                record_info(fields, listitem))),
+    lists:keysort(5, Res);
 parse_items([{xmlelement, "item", Attrs, SubEls} | Els], Res) ->
     Type   = xml:get_attr("type",   Attrs),
     Value  = xml:get_attr("value",  Attrs),