]>
Commit | Line | Data |
---|---|---|
261e05e8 VP |
1 | <?php |
2 | ||
3 | function generate_chanbans_table($channel) | |
4 | { | |
0b82418b VP |
5 | global $rpc; |
6 | $channel = $rpc->channel()->get($channel->name); | |
7 | ?> | |
8 | <form method="post"><p> | |
9 | <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ban">Delete</button> | |
10 | </p> | |
11 | <table class="table table-responsive table-hover"> | |
12 | <thead class="table-info"> | |
13 | <th><input type="checkbox" label='selectall' onClick="toggle_chanbans(this)" /></th> | |
14 | <th>Name</th> | |
15 | <th>Set by</th> | |
16 | <th>Set at</th> | |
17 | <th></th> | |
18 | </thead> | |
19 | <tbody> | |
20 | <?php | |
21 | foreach ($channel->bans as $ban) { | |
22 | echo "<tr>"; | |
23 | echo "<td scope=\"row\"><input type=\"checkbox\" value='$ban->name' name=\"cb_checkboxes[]\"></td>"; | |
24 | echo "<td><code>".htmlspecialchars($ban->name)."</code></td>"; | |
25 | $set_by = htmlspecialchars($ban->set_by); | |
26 | echo "<td>$set_by</td>"; | |
27 | $set_at = $ban->set_at; | |
28 | echo "<td>$set_at</td>"; | |
29 | echo "<td></td>"; | |
30 | echo "</tr>"; | |
31 | } | |
32 | ||
33 | ?> | |
34 | </tbody> | |
35 | </table> | |
36 | </form> | |
37 | <?php | |
261e05e8 VP |
38 | } |
39 | function generate_chaninvites_table($channel) | |
40 | { | |
0b82418b VP |
41 | global $rpc; |
42 | $channel = $rpc->channel()->get($channel->name); | |
43 | ?> | |
44 | <form method="post"><p> | |
45 | <button class="btn btn-info btn-sm" type="submit" name="delete_sel_inv">Delete</button> | |
46 | </p> | |
47 | <table class="table table-responsive table-hover"> | |
48 | <thead class="table-info"> | |
49 | <th><input type="checkbox" label='selectall' onClick="toggle_chaninvs(this)" /></th> | |
50 | <th>Name</th> | |
51 | <th>Set by</th> | |
52 | <th>Set at</th> | |
53 | <th></th> | |
54 | </thead> | |
55 | <tbody> | |
56 | <?php | |
57 | foreach ($channel->invite_exceptions as $inv) { | |
58 | echo "<tr>"; | |
59 | echo "<td scope=\"row\"><input type=\"checkbox\" value='$inv->name' name=\"ci_checkboxes[]\"></td>"; | |
60 | echo "<td><code>".htmlspecialchars($inv->name)."</code></td>"; | |
61 | $set_by = htmlspecialchars($inv->set_by); | |
62 | echo "<td>$set_by</td>"; | |
63 | $set_at = $inv->set_at; | |
64 | echo "<td>$set_at</td>"; | |
65 | echo "<td></td>"; | |
66 | echo "</tr>"; | |
67 | } | |
68 | ||
69 | ?> | |
70 | </tbody> | |
71 | </table> | |
72 | </form> | |
73 | <?php | |
261e05e8 VP |
74 | } |
75 | ||
76 | ||
77 | function generate_chanexcepts_table($channel) | |
78 | { | |
0b82418b VP |
79 | global $rpc; |
80 | $channel = $rpc->channel()->get($channel->name); | |
81 | ?> | |
82 | <form method="post"><p> | |
83 | <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ex">Delete</button> | |
84 | </p> | |
85 | <table class="table table-responsive table-hover"> | |
86 | <thead class="table-info"> | |
87 | <th><input type="checkbox" label='selectall' onClick="toggle_chanexs(this)" /></th> | |
88 | <th>Name</th> | |
89 | <th>Set by</th> | |
90 | <th>Set at</th> | |
91 | <th></th> | |
92 | </thead> | |
93 | <tbody> | |
94 | <?php | |
95 | foreach ($channel->ban_exemptions as $ex) { | |
96 | echo "<tr>"; | |
97 | echo "<td scope=\"row\"><input type=\"checkbox\" value='$ex->name' name=\"ce_checkboxes[]\"></td>"; | |
98 | echo "<td><code>".htmlspecialchars($ex->name)."</code></td>"; | |
99 | $set_by = htmlspecialchars($ex->set_by); | |
100 | echo "<td>$set_by</td>"; | |
101 | $set_at = $ex->set_at; | |
102 | echo "<td>$set_at</td>"; | |
103 | echo "<td></td>"; | |
104 | echo "</tr>"; | |
105 | } | |
261e05e8 | 106 | |
0b82418b VP |
107 | ?> |
108 | </tbody> | |
109 | </table> | |
110 | </form> | |
111 | <?php | |
112 | } | |
261e05e8 | 113 | |
0b82418b VP |
114 | /** |
115 | * Generate the user list of a channel | |
116 | * | |
117 | * Why is it called chan occupants? o.o | |
118 | * For the code, to avoid mixups | |
119 | * It's called "User List" on the website | |
120 | * @param mixed $channel | |
121 | * @return void | |
122 | */ | |
261e05e8 VP |
123 | function generate_chan_occupants_table($channel) |
124 | { | |
0b82418b VP |
125 | ?> |
126 | <form method="post"><p> | |
127 | ||
128 | </p> | |
129 | <table class="table table-responsive table-hover"> | |
130 | <thead class="table-info"> | |
131 | <th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th> | |
132 | <th>Name</th> | |
133 | <th>Status</th> | |
134 | <th>Actions</th> | |
135 | <th></th> | |
136 | </thead> | |
137 | <tbody> | |
138 | <?php | |
139 | foreach ($channel->members as $member) { | |
140 | echo "<tr>"; | |
141 | echo "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>"; | |
142 | echo "<td><a href=\"".BASE_URL."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>"; | |
143 | echo "<td>Status</td>"; | |
144 | echo "<td>Op</td>"; | |
145 | echo "<td>Deop</td>"; | |
146 | echo "</tr>"; | |
147 | } | |
148 | ||
149 | ?> | |
150 | </tbody> | |
151 | </table> | |
152 | </form> | |
153 | ||
154 | <?php | |
155 | } | |
156 | ||
785717b4 VP |
157 | /** |
158 | * Force loading of a particular modal by name | |
159 | */ | |
0b82418b VP |
160 | function chlkup_autoload_modal($name) |
161 | { | |
162 | ?> | |
163 | <script> | |
164 | $(document).ready(function () { | |
165 | $("#<?php echo $name; ?>").modal("show"); | |
166 | }); | |
167 | </script> | |
168 | <?php | |
169 | } | |
170 | ||
171 | ||
172 | function _do_chan_item_delete($chan, string $type, array $list, array &$errors) : bool | |
173 | { | |
174 | global $rpc; | |
175 | $n = ""; | |
176 | $str = ""; | |
177 | ||
178 | if ($type == "invite") | |
179 | $char = "I"; | |
180 | elseif ($type == "ban") | |
181 | $char = "b"; | |
182 | elseif ($type == "except") | |
183 | $char = "e"; | |
184 | else | |
185 | return false; | |
186 | ||
187 | foreach($list as $l) | |
188 | { | |
189 | $n .= $char; | |
190 | $str .= " ".$l; | |
191 | } | |
192 | if ($rpc->channel()->set_mode($chan->name, "-$n", $str)) | |
193 | { | |
194 | Message::Success("Deleted successfully"); | |
195 | return true; | |
196 | } | |
197 | $errors[] = $rpc->error . " ($rpc->errno)"; | |
198 | Message::Fail("An error occurred: $rpc->error"); | |
199 | return false; | |
200 | } | |
201 | ||
202 | function do_delete_invite($chan, $list) | |
203 | { | |
204 | $errs = []; | |
205 | _do_chan_item_delete($chan, "invite", $list, $errs); | |
206 | } | |
207 | ||
208 | function do_delete_chanban($chan, $list) | |
209 | { | |
210 | $errs = []; | |
211 | _do_chan_item_delete($chan, "ban", $list, $errs); | |
212 | } | |
213 | ||
214 | function do_delete_chanex($chan, $list) | |
215 | { | |
216 | $errs = []; | |
217 | _do_chan_item_delete($chan, "except", $list, $errs); | |
261e05e8 | 218 | } |