]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - misc/channel-lookup-misc.php
Channel modes: Split up larger strings
[irc/unrealircd/unrealircd-webpanel.git] / misc / channel-lookup-misc.php
index 72f096c4b43289bd60b3d7a26e8bf985af0628ed..101f9ec88d482c3f815bdb486825985ef9ca717a 100644 (file)
@@ -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 "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>";
                        $disabled = (current_user_can(PERMISSION_EDIT_CHANNEL_USER)) ? "" : "disabled";
                        $disabledcolor = ($disabled) ? "btn-secondary" : "btn-primary";
                        echo "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>";
-                       echo "<td><a href=\"".BASE_URL."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>";
+                       echo "<td><a href=\"".get_config("base_url")."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>";
                        echo "<td class='text-right'>$lvlstring</td>";
                        echo "<td><code>".((property_exists($member, 'hostname')) ? htmlspecialchars($member->hostname) : "")."</code></td>";
                        echo "</tr>";
                        echo "<td class='text-right'>$lvlstring</td>";
                        echo "<td><code>".((property_exists($member, 'hostname')) ? htmlspecialchars($member->hostname) : "")."</code></td>";
                        echo "</tr>";
@@ -397,16 +397,30 @@ function _do_chan_item_delete($chan, string $type, array $list, array &$errors)
 
        foreach($list as $l)
        {
 
        foreach($list as $l)
        {
+               // check if the string needs therapy
+               if ((strlen($n) + 1) + (strlen($str) + strlen($l)) > 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;
        }
                $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 ($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::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;
 }
 
        return false;
 }