X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/ae7257d0257f7c687270c9dce6fe480a182e68ff..34eac98afbb1e170e5fff9646bb22cf39fc3f72d:/misc/channel-lookup-misc.php diff --git a/misc/channel-lookup-misc.php b/misc/channel-lookup-misc.php index 64004af..101f9ec 100644 --- a/misc/channel-lookup-misc.php +++ b/misc/channel-lookup-misc.php @@ -3,7 +3,7 @@ function generate_chanbans_table($channel) { global $rpc; $channel = $rpc->channel()->get($channel->name); - ?>

+ ?>

@@ -40,7 +40,7 @@ function generate_chaninvites_table($channel) { global $rpc; $channel = $rpc->channel()->get($channel->name); - ?>

+ ?>

@@ -78,11 +78,11 @@ function generate_chaninvites_table($channel) function generate_chanexcepts_table($channel) { global $rpc; - echo ""; + $channel = $rpc->channel()->get($channel->name); - ?>

+ ?>

- +

@@ -181,7 +181,7 @@ function generate_chan_occupants_table($channel) $disabled = (current_user_can(PERMISSION_EDIT_CHANNEL_USER)) ? "" : "disabled"; $disabledcolor = ($disabled) ? "btn-secondary" : "btn-primary"; echo ""; - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -211,15 +211,17 @@ function generate_html_chansettings($channel) $tok = split($fmodes); $modes = $tok[0]; $params = rparv($fmodes); - + $paramed_modes = sort_paramed_modes($modes, $params); + for ($i=0; ($mode = (isset($modes[$i])) ? $modes[$i] : NULL); $i++) { - $modeinfo = IRCList::$cmodes[$mode]; + $modeinfo = IRCList::lookup($mode); if (!$modeinfo) continue; ?> + @@ -235,55 +237,104 @@ function generate_html_chansettings($channel) "kliRzOL", ... + * The group "Other" has a number of preset ones PLUS + * will be automatically filled with any remaining modes + * that are detected and that we forgot to put in Other. + */ +function group_modes() +{ + $modes = ''; + foreach(IRCList::$uplink as $mode_groups) + $modes .= $mode_groups; + + $grouping = IRCList::$grouping; + + foreach (str_split($modes) as $letter) + { + $found = false; + foreach($grouping as $groupname=>$value) + { + if (str_contains($value, $letter)) + { + $found = true; + break; + } + } + if (!$found) + $grouping["Other"] .= $letter; + + } + return $grouping; +} + function generate_edit_chmodes($chan) { ?> - -
id\">".htmlspecialchars($member->name)."id\">".htmlspecialchars($member->name)."$lvlstring".((property_exists($member, 'hostname')) ? htmlspecialchars($member->hostname) : "")."
- modes)) - { - echo "No modes set"; - return; - } - $fmodes = $chan->modes; - $tok = split($fmodes); - $modes = $tok[0]; - $params = rparv($fmodes); - $paramed_modes = sort_paramed_modes($modes, $params); - foreach (IRCList::$uplink as $m) - for ($i=0; ($mode = (isset($m[$i])) ? $m[$i] : NULL); $i++) - { - $group = get_chmode_group($mode); - if (!$group || $group == 1) - continue; - $modeinfo = IRCList::lookup($mode); - $checked = (strstr($modes,$mode)) ? "checked " : " "; - - $disabled = ""; - if (isset($modeinfo) && $modeinfo['requires'] == "Server") - $disabled = "disabled"; - - ?> - - - - + if (!isset($chan->modes)) + { + echo "No modes set"; + return; + } + $fmodes = $chan->modes; + $tok = split($fmodes); + $modes = $tok[0]; + $params = rparv($fmodes); + $paramed_modes = sort_paramed_modes($modes, $params); + + $all_modes = IRCList::$uplink; + $groups = group_modes(); + + foreach ($groups as $group_name=>$m) + { + echo "
\n"; + echo "$group_name\n"; + for ($i=0; ($mode = (isset($m[$i])) ? $m[$i] : NULL); $i++) + { + $group = get_chmode_group($mode); + if (!$group || $group == 1) + continue; + $modeinfo = IRCList::lookup($mode); + $checked = (strstr($modes,$mode)) ? "checked " : " "; + + $disabled = ""; + if (isset($modeinfo) && $modeinfo['requires'] == "Server") + $disabled = "disabled"; + + ?> +
+
+ type="checkbox" value='' name="newmodes[]"> + +$mode)"; ?> +
+
"> +
+
+ \n"; + } ?> -
-
type="checkbox" value='' name="newmodes[]">+$mode)"; ?> - "> -
- 150) + { + // send what we've got already and prepare for the next lot + if (!$rpc->channel()->set_mode($chan->name, htmlspecialchars("-$n"), htmlspecialchars($str))) + $errors[] = $rpc->error . " ($rpc->errno)"; + + // prepare for the next set + $n = ""; + $str = ""; + } $n .= $char; $str .= " ".$l; } + // if multiple, this will be the last one so we return here if ($rpc->channel()->set_mode($chan->name, htmlspecialchars("-$n"), htmlspecialchars($str))) { + if (!empty($errors)) + Message::Fail("One or more errors occurred:", $errors); Message::Success("Deleted successfully"); return true; } $errors[] = $rpc->error . " ($rpc->errno)"; - Message::Fail("An error occurred: $rpc->error"); + Message::Fail("An error occurred:", $errors); return false; }