Commit | Line | Data |
---|---|---|
5a2812ca AC |
1 | <% @header[("title", ["Support"])]; |
2 | ||
3 | val you = Init.getUserId (); | |
4 | val admin = Group.inGroupName "support"; | |
5 | ||
6 | ref showNormal = true; | |
7 | ||
8 | if $"sub" <> "" then | |
9 | Support.subscribe { cat = Web.stoi ($"sub"), usr = you } | |
10 | %><h3><b>Subscribed</b></h3> | |
11 | ||
12 | <% elseif $"unsub" <> "" then | |
13 | Support.unsubscribe { cat = Web.stoi ($"unsub"), usr = you } | |
14 | %><h3><b>Unsubscribed</b></h3> | |
15 | ||
16 | <% elseif $"cmd" = "add" then | |
17 | Group.requireGroupName "support"; | |
18 | val id = Support.addCategory (Web.stoi ($"grp"), $"name", $"descr") | |
19 | %><h3><b>Category added</b></h3> | |
20 | ||
21 | <% elseif $"mod" <> "" then | |
22 | Group.requireGroupName "support"; | |
23 | showNormal := false; | |
24 | val id = Web.stoi ($"mod"); | |
25 | val cat = Support.lookupCategory id %> | |
26 | ||
27 | <h3><b>Modify category</b></h3> | |
28 | ||
a4ccdb5e | 29 | <form action="support" method="post"> |
5a2812ca AC |
30 | <input type="hidden" name="save" value="<% id %>"> |
31 | <table> | |
32 | <tr> <td align="right"><b>Name</b>:</td> <td><input name="name" value="<% Web.html (#name cat) %>"></td> </tr> | |
33 | <tr> <td align="right"><b>Owning group</b>:</td> <td><select name="grp"> | |
34 | <% foreach group in Group.listGroups () do %> | |
35 | <option value="<% #id group %>"<% if #id group = #grp cat then %> selected<% end %>><% #name group %></option> | |
36 | <% end %> | |
37 | </select></td> </tr> | |
38 | <tr> <td align="right"><b>Description</b>:</td> <td><input name="descr" value="<% Web.html (#descr cat) %>"></td> </tr> | |
39 | <tr> <td><input type="submit" value="Save"></td> </tr> | |
40 | </table> | |
41 | </form> | |
42 | ||
43 | <% elseif $"save" <> "" then | |
44 | Group.requireGroupName "support"; | |
45 | val id = Web.stoi ($"save"); | |
46 | val cat = Support.lookupCategory id; | |
47 | Support.modCategory {cat with name = $"name", descr = $"descr", grp = Web.stoi ($"grp")} | |
48 | %><h3><b>Category saved</b></h3> | |
49 | ||
50 | <% elseif $"del" <> "" then | |
51 | Group.requireGroupName "support"; | |
52 | showNormal := false; | |
53 | val id = Web.stoi ($"del"); | |
54 | val cat = Support.lookupCategory id; | |
55 | %><h3><b>Are you sure you want to delete category "<% Web.html (#name cat) %>"?</b></h3> | |
56 | <a href="support?del2=<% id %>">Yes, delete "<% Web.html (#name cat) %>"!</a> | |
57 | ||
58 | <% elseif $"del2" <> "" then | |
59 | Group.requireGroupName "support"; | |
60 | val id = Web.stoi ($"del2"); | |
61 | val cat = Support.lookupCategory id; | |
62 | Support.deleteCategory id; | |
63 | %><h3><b>"<% Web.html (#name cat) %>" deleted</b></h3> | |
64 | ||
65 | <% end; | |
66 | ||
67 | if showNormal then %> | |
68 | ||
1cb3df3f | 69 | <h3><b>Choose a category:</b></h3> |
5a2812ca AC |
70 | |
71 | <% foreach (sub, cat) in Support.listCategoriesWithSubscriptions you do %> | |
1cb3df3f | 72 | <a href="issue?cat=<% #id cat %>"><% Web.html (#name cat) %></a>: <% Web.html (#descr cat) %> |
5a2812ca AC |
73 | <% if sub then %> |
74 | <a href="support?unsub=<% #id cat %>">[Unsubscribe]</a> | |
75 | <% else %> | |
76 | <a href="support?sub=<% #id cat %>">[Subscribe]</a> | |
77 | <% end %> | |
78 | <% if admin then %> | |
79 | <a href="support?mod=<% #id cat %>">[Modify]</a> | |
80 | <a href="support?del=<% #id cat %>">[Delete]</a> | |
81 | <% end %> | |
82 | <br> | |
83 | <% end %> | |
84 | ||
85 | <% if admin then %> | |
86 | ||
87 | <h3><b>Add new category</b></h3> | |
88 | ||
a4ccdb5e | 89 | <form action="support" method="post"> |
5a2812ca AC |
90 | <input type="hidden" name="cmd" value="add"> |
91 | <table> | |
92 | <tr> <td align="right"><b>Name</b>:</td> <td><input name="name"></td> </tr> | |
93 | <tr> <td align="right"><b>Owning group</b>:</td> <td><select name="grp"> | |
94 | <% foreach group in Group.listGroups () do %> | |
95 | <option value="<% #id group %>"><% #name group %></option> | |
96 | <% end %> | |
97 | </select></td> </tr> | |
98 | <tr> <td align="right"><b>Description</b>:</td> <td><input name="descr"></td> </tr> | |
99 | <tr> <td><input type="submit" value="Add"></td> </tr> | |
100 | </table> | |
101 | </form> | |
102 | ||
103 | <% end %> | |
104 | ||
105 | <% end %> | |
106 | ||
107 | <% @footer[] %> |