X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/0b82418ba05d25a5f643b09c3e1b3f68d48e4832..34eac98afbb1e170e5fff9646bb22cf39fc3f72d:/misc/channel-lookup-misc.php?ds=sidebyside diff --git a/misc/channel-lookup-misc.php b/misc/channel-lookup-misc.php index b55cbd8..101f9ec 100644 --- a/misc/channel-lookup-misc.php +++ b/misc/channel-lookup-misc.php @@ -1,14 +1,14 @@ channel()->get($channel->name); - ?> -

+ ?>

+ +

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

+ ?>

Name
+ +

-
+ @@ -77,12 +78,14 @@ function generate_chaninvites_table($channel) function generate_chanexcepts_table($channel) { global $rpc; + $channel = $rpc->channel()->get($channel->name); - ?> -

+ ?>

Name
+ +

-
+ @@ -122,27 +125,65 @@ function generate_chanexcepts_table($channel) */ function generate_chan_occupants_table($channel) { + global $rpc; ?>

-
Name
+
- - + members as $member) { + $m = sort_user_list($channel->members); + + $i = 0; + foreach ($m as $member) + { + $lvlstring = ""; + + if (isset($member->level)) + { + for ($i = 0; isset($member->level[$i]) && $m = $member->level[$i]; $i++) + { + switch ($m) + { + case "v": + $lvlstring .= "
Voice
"; + break; + case "h": + $lvlstring .= "
Half-Op
"; + break; + case "o": + $lvlstring .= "
Op
"; + break; + case "a": + $lvlstring .= "
Admin
"; + break; + case "q": + $lvlstring .= "
Owner
"; + break; + + // providing support third/ojoin + case "Y": + $lvlstring .= "
OJOIN
"; + break; + } + } + } + echo ""; + ?>"; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; echo ""; } @@ -154,6 +195,161 @@ function generate_chan_occupants_table($channel) + +
Name StatusActionsHost
id\">".htmlspecialchars($member->name)."StatusOpDeopid\">".htmlspecialchars($member->name)."$lvlstring".((property_exists($member, 'hostname')) ? htmlspecialchars($member->hostname) : "")."
+ + modes)) + { + echo "No modes set"; + return; + } + $fmodes = $channel->modes; + $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::lookup($mode); + if (!$modeinfo) + continue; + ?> + + + + + + + +
+ +
+ + "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) +{ + ?> + 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"; + } + ?> + $grp) + if (strstr($grp,$mode)) + return $i + 1; + + return 0; // invalid +} + +/** + * Force loading of a particular modal by name + */ function chlkup_autoload_modal($name) { ?> @@ -165,6 +361,24 @@ function chlkup_autoload_modal($name) 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 ($rpc->channel()->set_mode($chan->name, "-$n", $str)) + // 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; } @@ -212,4 +440,84 @@ function do_delete_chanex($chan, $list) { $errs = []; _do_chan_item_delete($chan, "except", $list, $errs); +} + + + +/** + * Sort the channels user list: + */ +function sort_user_list($list) : array +{ + if (empty($list)) + return $list; + + $new = []; + foreach($list as $k => $user) + { + if (!property_exists($user,"level")) + { + $new["rest"][] = $user; + $list[$k] = NULL; + } + else if (strstr($user->level,"Y")) + { + $new["Y"][] = $user; + $list[$k] = NULL; + } + else if (strstr($user->level,"q")) + { + $new["q"][] = $user; + $list[$k] = NULL; + } + else if (strstr($user->level,"a")) + { + $new["a"][] = $user; + $list[$k] = NULL; + } + else if (strstr($user->level,"o")) + { + $new["o"][] = $user; + $list[$k] = NULL; + } + else if (strstr($user->level,"h")) + { + $new["h"][] = $user; + $list[$k] = NULL; + } + else if (strstr($user->level,"v")) + { + $new["v"][] = $user; + $list[$k] = NULL; + } + + } + + unset($list); + $list = []; + if (isset($new["q"])) + foreach($new["q"] as $u) + $list[] = $u; + + if (isset($new["a"])) + foreach($new["a"] as $u) + $list[] = $u; + + if (isset($new["o"])) + foreach($new["o"] as $u) + $list[] = $u; + + if (isset($new["h"])) + foreach($new["h"] as $u) + $list[] = $u; + + if (isset($new["v"])) + foreach($new["v"] as $u) + $list[] = $u; + + if (isset($new["rest"])) + foreach($new["rest"] as $u) + $list[] = $u; + + return $list; } \ No newline at end of file