Gitlab has been upgraded to v13.9 🎉. Enjoy

Commit 63d5de70 authored by Ted Trask's avatar Ted Trask

Changes to use new htmlviewfunctions functions

parent 8c84c4c0
......@@ -4,9 +4,9 @@ html = require("acf.html")
%>
<% -- Pregenerate the list of users
local useroptions = {{value="", label=""}}
if viewlibrary.check_permission("listusers") and (viewlibrary.check_permission("forwardmessage") or viewlibrary.check_permission("forwardmymessage")) then
local users = viewlibrary.dispatch_component("listusers", nil, true)
useroptions = {"<option></option>"}
for i,v in ipairs(users.value) do
v.firstname = v.firstname or ""
v.lastname = v.lastname or ""
......@@ -15,14 +15,15 @@ if viewlibrary.check_permission("listusers") and (viewlibrary.check_permission("
table.sort(users.value, function(a,b) if a.firstname ~= b.firstname then return a.firstname < b.firstname elseif a.lastname ~= b.lastname then return a.lastname < b.lastname else return a.username < b.username end end)
for i,u in ipairs(users.value) do
if u.username ~= session.userinfo.userid then
useroptions[#useroptions+1] = '<option value="'..html.html_escape(u.username)..'">'..html.html_escape(u.firstname)..' '..html.html_escape(u.lastname)..' ('..html.html_escape(u.username)..')</option>'
useroptions[#useroptions+1] = {value=u.firstname, label=u.firstname..' '..u.lastname..' ('..u.username..')'}
end
end
useroptions = table.concat(useroptions)
end
%>
<% -- Pregenerate the list of folders
reversefolders = {}
local reversefolders = {}
local folderoptions = {{value="", label=""}}
local dontmove=false
if viewlibrary.check_permission("listfolders") then
local folders = viewlibrary.dispatch_component("listfolders", nil, true)
for i,u in ipairs(folders.value) do
......@@ -32,16 +33,14 @@ if viewlibrary.check_permission("listfolders") then
if #folders.value <= 1 then
dontmove = true
end
folderoptions = {"<option></option>"}
for i,u in ipairs(folders.value) do
folderoptions[#folderoptions+1] = '<option value="'..html.html_escape(u.in_folder)..'">'..html.html_escape(u.label)..'</option>'
folderoptions[#folderoptions+1] = {value=u.in_folder, label=u.label}
end
folderoptions = table.concat(folderoptions)
end
end
%>
<% -- Figure out the callback number
callmenumber = nil
local callmenumber = nil
if viewlibrary.check_permission("editmyusersettings") and viewlibrary.check_permission("callbackmymessage") then
local settings = viewlibrary.dispatch_component("editmyusersettings", nil, true)
if settings and settings.value and settings.value.callmenumber then
......@@ -203,65 +202,50 @@ end
});
$(".playmessage").click(PlayMessage);
<% if viewlibrary.check_permission("deletemessage") or viewlibrary.check_permission("deletemymessage") then %>
$("#multidelete").click(HandleMulti);
$(".multidelete").click(HandleMulti);
<% end %>
<% if viewlibrary.check_permission("forwardmessage") or viewlibrary.check_permission("forwardmymessage") then %>
$("#multiforward").click(HandleMulti);
$(".multiforward").click(HandleMulti);
<% end %>
<% if viewlibrary.check_permission("emailmessage") or viewlibrary.check_permission("emailmymessage") then %>
$("#multiemail").click(HandleMulti);
$(".multiemail").click(HandleMulti);
<% end %>
<% if viewlibrary.check_permission("movemessage") or viewlibrary.check_permission("movemymessage") then %>
$("#multimove").click(HandleMulti);
$(".multimove").click(HandleMulti);
<% end %>
});
</script>
<% htmlviewfunctions.displaycommandresults({"deletemessage", "deletemymessage", "forwardmessage", "forwardmymessage", "emailmessage", "emailmymessage", "movemessage", "movemymessage", "callbackmessage", "callbackmymessage"}, session) %>
<h1>Messages</h1>
<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<table><tr><td>
<% if viewlibrary.check_permission("deletemessage") or viewlibrary.check_permission("deletemymessage") then %>
<form id="multidelete" action="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller) %>/
<% if viewlibrary.check_permission("deletemessage") then io.write("deletemessage") else io.write("deletemymessage") end %>
" method="post">
<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action) %>" >
<input class="hidden" type="hidden" name="message" value="" >
<input class="submit" type="submit" name="submit" value="Delete">
</form>
<% end %>
<% if viewlibrary.check_permission("forwardmessage") or viewlibrary.check_permission("forwardmymessage") then %>
<form id="multiforward" action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) %>/
<% if viewlibrary.check_permission("forwardmessage") then io.write("forwardmessage") else io.write("forwardmymessage") end %>
" method="post">
<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action) %>" >
<input class="hidden" type="hidden" name="message" value="" >
<input class="submit" type="submit" name="submit" value="Forward">
<select name="newuser"><%= (useroptions or "") %></select>
</form>
<% end %>
<% if viewlibrary.check_permission("emailmessage") or viewlibrary.check_permission("emailmymessage") then %>
<form id="multiemail" action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) %>/
<% if viewlibrary.check_permission("emailmessage") then io.write("emailmessage") else io.write("emailmymessage") end %>
" method="post">
<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action) %>" >
<input class="hidden" type="hidden" name="message" value="" >
<input class="submit" type="submit" name="submit" value="E-mail">
<input class="text" type="text" name="address" value="">
</form>
<% end %>
<% if viewlibrary.check_permission("movemessage") or viewlibrary.check_permission("movemymessage") then %>
<% if not dontmove then %>
<form id="multimove" action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) %>/
<% if viewlibrary.check_permission("movemessage") then io.write("movemessage") else io.write("movemymessage") end %>
" method="post">
<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action) %>" >
<input class="hidden" type="hidden" name="message" value="" >
<input class="submit" type="submit" name="submit" value="Move">
<select name="newfolder"><%= (folderoptions or "") %></select>
</form>
<% end %>
<% end %>
<% local message = cfe({type="hidden"}) %>
<% if viewlibrary.check_permission("deletemessage") or viewlibrary.check_permission("deletemymessage") then
local form = cfe({type="form", value={message=message}, label="", option="Delete", action="deletemymessage", class="multidelete" })
if viewlibrary.check_permission("deletemessage") then form.action = "deletemessage" end
htmlviewfunctions.displayitem(form, page_info, -1)
end
if viewlibrary.check_permission("forwardmessage") or viewlibrary.check_permission("forwardmymessage") then
local form = cfe({type="form", value={message=message}, label="", option="Forward", action="forwardmymessage", class="multiforward" })
if viewlibrary.check_permission("forwardmessage") then form.action = "forwardmessage" end
form.value.newuser = cfe({type="select", option=useroptions})
htmlviewfunctions.displayitem(form, page_info, -1)
end
if viewlibrary.check_permission("emailmessage") or viewlibrary.check_permission("emailmymessage") then
local form = cfe({type="form", value={message=message}, label="", option="E-mail", action="emailmymessage", class="multiemail" })
if viewlibrary.check_permission("emailmessage") then form.action = "emailmessage" end
form.value.address = cfe({})
htmlviewfunctions.displayitem(form, page_info, -1)
end
if viewlibrary.check_permission("movemessage") or viewlibrary.check_permission("movemymessage") then
if not dontmove then
local form = cfe({type="form", value={message=message}, label="", option="Move", action="movemymessage", class="multimove" })
if viewlibrary.check_permission("movemessage") then form.action = "movemessage" end
form.value.newfolder = cfe({type="select", option=folderoptions})
htmlviewfunctions.displayitem(form, page_info, -1)
end
end %>
</td></tr></table>
<table><tr><td>
<small>select: </small>
......@@ -282,19 +266,23 @@ end
<th>Duration</th>
</tr>
</thead><tbody>
<% local message = cfe({ type="hidden" }) %>
<% local viewtype = cfe({ type="hidden", value="stream" }) %>
<% local extension = cfe({ type="hidden", value=callmenumber }) %>
<% for k,v in ipairs( view.value ) do %>
<tr>
<td><input type=checkbox class="multicheck" value="<%= html.html_escape(v.uuid) %>"></td>
<td>
<% message.value = v.uuid %>
<% if viewlibrary.check_permission("downloadmessage") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/downloadmessage?viewtype=stream&message="..v.uuid, label="Download "} %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/downloadmessage?viewtype=stream&message="..v.uuid, class="playmessage", label="Play "} %>
<% htmlviewfunctions.displayitem(cfe({type="link", value={message=message, viewtype=viewtype}, label="", option="Download", action="downloadmessage"}), page_info, -1) %>
<% htmlviewfunctions.displayitem(cfe({type="link", value={message=message, viewtype=viewtype}, label="", option="Play", action="downloadmessage", class="playmessage"}), page_info, -1) %>
<% elseif viewlibrary.check_permission("downloadmymessage") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/downloadmymessage?viewtype=stream&message="..v.uuid, label="Download "} %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/downloadmymessage?viewtype=stream&message="..v.uuid, class="playmessage", label="Play "} %>
<% htmlviewfunctions.displayitem(cfe({type="link", value={message=message, viewtype=viewtype}, label="", option="Download", action="downloadmymessage"}), page_info, -1) %>
<% htmlviewfunctions.displayitem(cfe({type="link", value={message=message, viewtype=viewtype}, label="", option="Play", action="downloadmymessage", class="playmessage"}), page_info, -1) %>
<% end %>
<% if callmenumber then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/callbackmymessage?submit=true&message="..v.uuid.."&extension="..callmenumber, label="CallMe "} %>
<% htmlviewfunctions.displayitem(cfe({type="form", value={message=message, extension=extension}, label="", option="CallMe", action="callbackmymessage"}), page_info, -1) %>
<% end %>
</td>
<td><%= html.html_escape(os.date("%x", v.created_epoch)) %></td>
......@@ -315,3 +303,4 @@ end
<% if #view.value == 0 then %>
<p>No messages found</p>
<% end %>
<% htmlviewfunctions.displaysectionend(header_level) %>
......@@ -24,7 +24,8 @@ html = require("acf.html")
<% htmlviewfunctions.displaycommandresults({"createuser", "deleteuser", "editusersettings"}, session) %>
<h1>Users</h1>
<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<% local header_level2 = htmlviewfunctions.incrementheader(header_level) %>
<table id="list" class="tablesorter"><thead>
<tr>
<th>Action</th>
......@@ -33,14 +34,17 @@ html = require("acf.html")
<th>Last Name</th>
</tr>
</thead><tbody>
<% local username = cfe({ type="hidden", value="" }) %>
<% local redir = cfe({ type="hidden", value=page_info.orig_action }) %>
<% for k,v in ipairs( view.value ) do %>
<tr>
<td>
<% username.value = v.username %>
<% if viewlibrary.check_permission("editusersettings") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editusersettings?username="..v.username, label="Edit "} %>
<% htmlviewfunctions.displayitem(cfe({type="link", value={username=username, redir=redir}, label="", option="Edit", action="editusersettings"}), page_info, -1) %>
<% end %>
<% if viewlibrary.check_permission("deleteuser") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleteuser?username="..v.username.."&submit=true", label="Delete ", class="deleteuser"} %>
<% htmlviewfunctions.displayitem(cfe({type="form", value={username=username}, label="", option="Delete", action="deleteuser", class="deleteuser" }), page_info, -1) %>
<% end %>
</td>
<td><%= html.html_escape(v.username) %></td>
......@@ -59,23 +63,11 @@ html = require("acf.html")
<% end %>
<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createuser") then %>
<h2>Create New User</h2>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) %>/createuser" method="post">
<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action) %>" >
<div class='item'><p class='left'></p>
<div class='right'>
<input class="submit" type="submit" value="Create">
</div></div><!-- end .item -->
</form>
<% htmlviewfunctions.displayitem(cfe({type="link", value={redir=redir}, label="Create New User", option="Create", action="createuser" }), page_info, header_level2) %>
<% end %>
<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createmanyusers") then %>
<h2>Create Multiple Users</h2>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) %>/createmanyusers" method="post">
<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action) %>" >
<div class='item'><p class='left'></p>
<div class='right'>
<input class="submit" type="submit" value="Create">
</div></div><!-- end .item -->
</form>
<% htmlviewfunctions.displayitem(cfe({type="link", value={redir=redir}, label="Create Multiple Users", option="Create", action="createmanyusers" }), page_info, header_level2) %>
<% end %>
<% htmlviewfunctions.displaysectionend(header_level) %>
......@@ -380,7 +380,7 @@ mymodule.list_messages = function(username)
if not res and err then
errtxt = err
end
return cfe({ type="structure", value=retval, label="List of Messages", errtxt=errtxt })
return cfe({ type="structure", value=retval, label="Messages", errtxt=errtxt })
end
mymodule.get_message = function(message, username)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment