changeset 753:9d5731af2c27

Merge with Oliver Gerlich
author Matthew Wild <mwild1@gmail.com>
date Fri, 27 Jul 2012 14:29:59 +0100
parents 9bbd99f2057a (diff) 3c37445f26ac (current diff)
children 713c6791fbcc
files mod_adhoc_cmd_admin/mod_adhoc_cmd_admin.lua mod_adhoc_cmd_modules/mod_adhoc_cmd_modules.lua mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua mod_adhoc_cmd_uptime/mod_adhoc_cmd_uptime.lua mod_admin_web/admin_web/mod_admin_web.lua mod_admin_web/admin_web/mod_admin_web_timber.lua mod_archive/mod_archive.lua
diffstat 1 files changed, 68 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/mod_archive/mod_archive.lua	Fri Jul 27 04:39:48 2012 +0200
+++ b/mod_archive/mod_archive.lua	Fri Jul 27 14:29:59 2012 +0100
@@ -446,39 +446,43 @@
     local count = table.getn(resset);
     if count > 0 then
         list_reverse(resset);
-        local max = elem.tags[1]:child_with_name("max");
-        if max then
-            max = tonumber(max:get_text()) or DEFAULT_MAX;
-        else max = DEFAULT_MAX; end
-        local after = elem.tags[1]:child_with_name("after");
-        local before = elem.tags[1]:child_with_name("before");
-        local index = elem.tags[1]:child_with_name("index");
-        local s, e = 1, 1+max;
-        if after then
-            after = after:get_text();
-            s = find_coll(resset, after);
-            if not s then -- not found
-                origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
-                return true;
-            end
-            s = s + 1;
-            e = s + max;
-        elseif before then
-            before = before:get_text();
-            if not before or before == '' then -- the last page
-                e = count + 1;
-                s = e - max;
-            else
-                e = find_coll(resset, before);
-                if not e then -- not found
+        local s, e = 1, 1+DEFAULT_MAX;
+        local rsmset = elem:child_with_name("set")
+        if rsmset then
+            local max = elem.tags[1]:child_with_name("max");
+            if max then
+                max = tonumber(max:get_text()) or DEFAULT_MAX;
+            else max = DEFAULT_MAX; end
+            e = 1 + max
+            local after = elem.tags[1]:child_with_name("after");
+            local before = elem.tags[1]:child_with_name("before");
+            local index = elem.tags[1]:child_with_name("index");
+            if after then
+                after = after:get_text();
+                s = find_coll(resset, after);
+                if not s then -- not found
                     origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
                     return true;
                 end
-                s = e - max;
+                s = s + 1;
+                e = s + max;
+            elseif before then
+                before = before:get_text();
+                if not before or before == '' then -- the last page
+                    e = count + 1;
+                    s = e - max;
+                else
+                    e = find_coll(resset, before);
+                    if not e then -- not found
+                        origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
+                        return true;
+                    end
+                    s = e - max;
+                end
+            elseif index then
+                s = tonumber(index:get_text()) + 1; -- 0-based
+                e = s + max;
             end
-        elseif index then
-            s = tonumber(index:get_text()) + 1; -- 0-based
-            e = s + max;
         end
         if s < 1 then s = 1; end
         if e > count + 1 then e = count + 1; end
@@ -529,37 +533,42 @@
     local reply = st.reply(stanza):tag('chat', collection.attr);
     local count = table.getn(resset);
     if count > 0 then
-        local max = elem.tags[1]:child_with_name("max");
-        if max then
-            max = tonumber(max:get_text()) or DEFAULT_MAX;
-        else max = DEFAULT_MAX; end
-        local after = elem.tags[1]:child_with_name("after");
-        local before = elem.tags[1]:child_with_name("before");
-        local index = elem.tags[1]:child_with_name("index");
-        local s, e = 1, 1+max;
-        if after then
-            after = tonumber(after:get_text());
-            if not after or after < 1 or after > count then -- not found
-                origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
-                return true;
+        local s, e = 1, 1+DEFAULT_MAX;
+        local rsmset = elem:child_with_name("set")
+        if rsmset then
+            local max = elem.tags[1]:child_with_name("max");
+            if max then
+                max = tonumber(max:get_text()) or DEFAULT_MAX;
+            else max = DEFAULT_MAX; end
+            e = 1+max
+            local after = elem.tags[1]:child_with_name("after");
+            local before = elem.tags[1]:child_with_name("before");
+            local index = elem.tags[1]:child_with_name("index");
+            --local s, e = 1, 1+max;
+            if after then
+                after = tonumber(after:get_text());
+                if not after or after < 1 or after > count then -- not found
+                    origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
+                    return true;
+                end
+                s = after + 1;
+                e = s + max;
+            elseif before then
+                before = tonumber(before:get_text());
+                if not before then -- the last page
+                    e = count + 1;
+                    s = e - max;
+                elseif before < 1 or before > count then
+                    origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
+                    return true;
+                else
+                    e = before;
+                    s = e - max;
+                end
+            elseif index then
+                s = tonumber(index:get_text()) + 1; -- 0-based
+                e = s + max;
             end
-            s = after + 1;
-            e = s + max;
-        elseif before then
-            before = tonumber(before:get_text());
-            if not before then -- the last page
-                e = count + 1;
-                s = e - max;
-            elseif before < 1 or before > count then
-                origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
-                return true;
-            else
-                e = before;
-                s = e - max;
-            end
-        elseif index then
-            s = tonumber(index:get_text()) + 1; -- 0-based
-            e = s + max;
         end
         if s < 1 then s = 1; end
         if e > count + 1 then e = count + 1; end