2 function generate_chanbans_table($channel)
5 $channel = $rpc->channel()->get($channel->name
);
6 ?><p
><table
class="container-xxl table table-sm table-responsive caption-top table-striped">
7 <button
class="btn btn-primary mr-1 btn-sm" data
-toggle
="modal" data
-target
="#ban">Add
New</button
>
9 <button
class="btn btn-info btn-sm" type
="submit" name
="delete_sel_ban">Delete
</button
>
12 <thead
class="table-info">
13 <th
><input type
="checkbox" label
='selectall' onClick
="toggle_chanbans(this)" /></th
>
21 foreach ($channel->bans
as $ban) {
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>";
39 function generate_chaninvites_table($channel)
42 $channel = $rpc->channel()->get($channel->name
);
43 ?><p
><table
class="table table-sm table-responsive table-hover caption-top table-striped">
44 <button
class="btn btn-primary btn-sm mr-1" data
-toggle
="modal" data
-target
="#invite">Add
New</button
>
46 <button
class="btn btn-info btn-sm" type
="submit" name
="delete_sel_inv">Delete
</button
>
49 <thead
class="table-info">
50 <th
><input type
="checkbox" label
='selectall' onClick
="toggle_chaninvs(this)" /></th
>
58 foreach ($channel->invite_exceptions
as $inv) {
60 echo "<td scope=\"row\"><input type=\"checkbox\" value='$inv->name' name=\"ci_checkboxes[]\"></td>";
61 echo "<td><code>".htmlspecialchars($inv->name
)."</code></td>";
62 $set_by = htmlspecialchars($inv->set_by
);
63 echo "<td>$set_by</td>";
64 $set_at = $inv->set_at
;
65 echo "<td>$set_at</td>";
78 function generate_chanexcepts_table($channel)
82 $channel = $rpc->channel()->get($channel->name
);
83 ?><p
><table
class="table table-sm table-responsive table-hover caption-top table-striped">
84 <button
class="btn btn-primary mr-1 btn-sm" data
-toggle
="modal" data
-target
="#except">Add
New</button
>
86 <button
class="btn btn-info btn-sm" type
="submit" name
="delete_sel_ex">Delete
</button
>
89 <thead
class="table-info">
90 <th
><input type
="checkbox" label
='selectall' onClick
="toggle_chanexs(this)" /></th
>
98 foreach ($channel->ban_exemptions
as $ex) {
100 echo "<td scope=\"row\"><input type=\"checkbox\" value='$ex->name' name=\"ce_checkboxes[]\"></td>";
101 echo "<td><code>".htmlspecialchars($ex->name
)."</code></td>";
102 $set_by = htmlspecialchars($ex->set_by
);
103 echo "<td>$set_by</td>";
104 $set_at = $ex->set_at
;
105 echo "<td>$set_at</td>";
118 * Generate the user list of a channel
120 * Why is it called chan occupants? o.o
121 * For the code, to avoid mixups
122 * It's called "User List" on the website
123 * @param mixed $channel
126 function generate_chan_occupants_table($channel)
130 <form method
="post"><p
>
133 <table
class="container-xxl table table-sm table-responsive caption-top table-striped">
134 <thead
class="table-info">
135 <th
><input type
="checkbox" label
='selectall' onClick
="toggle_checkbox(this)" /></th
>
142 $m = sort_user_list($channel->members
);
145 foreach ($m as $member)
149 if (isset($member->level
))
151 for ($i = 0; isset($member->level
[$i]) && $m = $member->level
[$i]; $i++
)
156 $lvlstring .= "<div class='badge rounded-pill badge-primary'>Voice</div> ";
159 $lvlstring .= "<div class='badge rounded-pill badge-secondary'>Half-Op</div> ";
162 $lvlstring .= "<div class='badge rounded-pill badge-warning'>Op</div> ";
165 $lvlstring .= "<div class='badge rounded-pill badge-danger'>Admin</div> ";
168 $lvlstring .= "<div class='badge rounded-pill badge-success'>Owner</div> ";
171 // providing support third/ojoin
173 $lvlstring .= "<div class='badge rounded-pill'>OJOIN</div> ";
180 ?><form method
="post" action
=""><?php
181 $disabled = (current_user_can(PERMISSION_EDIT_CHANNEL_USER
)) ? "" : "disabled";
182 $disabledcolor = ($disabled) ? "btn-secondary" : "btn-primary";
183 echo "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>";
184 echo "<td><a href=\"".get_config("base_url")."users/details.php?nick=$member->id\">".htmlspecialchars($member->name
)."</a></td>";
185 echo "<td class='text-right'>$lvlstring</td>";
186 echo "<td><code>".((property_exists($member, 'hostname')) ? htmlspecialchars($member->hostname
) : "")."</code></td>";
198 function generate_html_chansettings($channel)
202 <table
class="table-sm table-responsive caption-top table-hover">
205 if (BadPtr($channel->modes
))
210 $fmodes = $channel->modes
;
211 $tok = split($fmodes);
213 $params = rparv($fmodes);
214 $paramed_modes = sort_paramed_modes($modes, $params);
216 for ($i=0; ($mode = (isset($modes[$i])) ? $modes[$i] : NULL); $i++
)
218 $modeinfo = IRCList
::lookup($mode);
223 <th
><?php
echo $modeinfo['name']; ?></th
>
224 <td
><code
><?php
echo isset($paramed_modes[$mode]) ? $paramed_modes[$mode] : ""; ?></code
></td
>
226 <?php
echo $modeinfo['description']; ?>
240 /** Return user-friendly mode group names as an array like:
241 * "Join restrictions"=>"kliRzOL", ...
242 * The group "Other" has a number of preset ones PLUS
243 * will be automatically filled with any remaining modes
244 * that are detected and that we forgot to put in Other.
246 function group_modes()
249 foreach(IRCList
::$uplink as $mode_groups)
250 $modes .= $mode_groups;
252 $grouping = IRCList
::$grouping;
254 foreach (str_split($modes) as $letter)
257 foreach($grouping as $groupname=>$value)
259 if (str_contains($value, $letter))
266 $grouping["Other"] .= $letter;
272 function generate_edit_chmodes($chan)
276 if (!isset($chan->modes
))
281 $fmodes = $chan->modes
;
282 $tok = split($fmodes);
284 $params = rparv($fmodes);
285 $paramed_modes = sort_paramed_modes($modes, $params);
287 $all_modes = IRCList
::$uplink;
288 $groups = group_modes();
290 foreach ($groups as $group_name=>$m)
292 echo "<fieldset class=\"border p-1 col-sm-6\">\n";
293 echo "<legend class=\"w-auto\" style=\"font-size: 16px\">$group_name</legend>\n";
294 for ($i=0; ($mode = (isset($m[$i])) ? $m[$i] : NULL); $i++
)
296 $group = get_chmode_group($mode);
297 if (!$group || $group == 1)
299 $modeinfo = IRCList
::lookup($mode);
300 $checked = (strstr($modes,$mode)) ? "checked " : " ";
303 if (isset($modeinfo) && $modeinfo['requires'] == "Server")
304 $disabled = "disabled";
307 <div
class="form-group row">
308 <div
class="col-sm-5">
309 <input
<?php
echo $checked.$disabled; ?> type
="checkbox" value
='<?php echo $mode; ?>' name
="newmodes[]">
310 <span data
-toggle
="tooltip" data
-placement
="top" title
="<?php echo htmlspecialchars($modeinfo['description']); ?>"><?php
echo htmlspecialchars($modeinfo['name'])." (<code>+$mode</code>)"; ?>
312 <div
class="col-sm-2">
315 if ($group == 2 || $group == 3)
317 ?><input type
="text" class="input-group-sm" name
="paramed_modes[<?php echo $mode; ?>]"
318 id
="<?php echo $mode; ?>" value
="<?php echo ($checked)
321 isset($paramed_modes[$mode])
323 $paramed_modes[$mode]
335 echo "</fieldset>\n";
341 function get_chmode_group(string $mode) : int
343 foreach(IRCList
::$uplink as $i => $grp)
344 if (strstr($grp,$mode))
351 * Force loading of a particular modal by name
353 function chlkup_autoload_modal($name)
357 $
(document
).ready(function () {
358 $
("#<?php echo $name; ?>").modal("show");
365 * Returns an array of parametered modes and their params
367 function sort_paramed_modes($modes, $params) : array
370 for ($i=0; isset($modes[$i]) && $mode = $modes[$i]; $i++
)
372 $group = get_chmode_group($mode);
373 if ($group != 2 && $group != 3)
383 function _do_chan_item_delete($chan, string $type, array $list, array &$errors) : bool
389 if ($type == "invite")
391 elseif ($type == "ban")
393 elseif ($type == "except")
400 // check if the string needs therapy
401 if ((strlen($n) +
1) +
(strlen($str) +
strlen($l)) > 150)
403 // send what we've got already and prepare for the next lot
404 if (!$rpc->channel()->set_mode($chan->name
, htmlspecialchars("-$n"), htmlspecialchars($str)))
405 $errors[] = $rpc->error . " ($rpc->errno
)";
407 // prepare for the next set
414 // if multiple, this will be the last one so we return here
415 if ($rpc->channel()->set_mode($chan->name, htmlspecialchars("-$n"), htmlspecialchars($str)))
418 Message
::Fail("One or more errors occurred:", $errors);
419 Message
::Success("Deleted successfully");
422 $errors[] = $rpc->error
. " ($rpc->errno)";
423 Message
::Fail("An error occurred:", $errors);
427 function do_delete_invite($chan, $list)
430 _do_chan_item_delete($chan, "invite", $list, $errs);
433 function do_delete_chanban($chan, $list)
436 _do_chan_item_delete($chan, "ban", $list, $errs);
439 function do_delete_chanex($chan, $list)
442 _do_chan_item_delete($chan, "except", $list, $errs);
448 * Sort the channels user list:
450 function sort_user_list($list) : array
456 foreach($list as $k => $user)
458 if (!property_exists($user,"level"))
460 $new["rest"][] = $user;
463 else if (strstr($user->level
,"Y"))
468 else if (strstr($user->level
,"q"))
473 else if (strstr($user->level
,"a"))
478 else if (strstr($user->level
,"o"))
483 else if (strstr($user->level
,"h"))
488 else if (strstr($user->level
,"v"))
498 if (isset($new["q"]))
499 foreach($new["q"] as $u)
502 if (isset($new["a"]))
503 foreach($new["a"] as $u)
506 if (isset($new["o"]))
507 foreach($new["o"] as $u)
510 if (isset($new["h"]))
511 foreach($new["h"] as $u)
514 if (isset($new["v"]))
515 foreach($new["v"] as $u)
518 if (isset($new["rest"]))
519 foreach($new["rest"] as $u)