]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Move the channel details around, make it look better
authorValerie Pond <redacted>
Mon, 27 Mar 2023 05:52:18 +0000 (06:52 +0100)
committerValerie Pond <redacted>
Mon, 27 Mar 2023 05:52:18 +0000 (06:52 +0100)
Classes/class-cmodes.php
channels/details.php
common.php
misc/channel-lookup-misc.php

index f9749f29b88d14be09b5e7e56ea405830800184c..a8c7037f93dac921b9b16a9d47ffd26cc3cae729 100644 (file)
@@ -111,6 +111,10 @@ class IRCList {
             "description" => "Delay showing joins until someone actually speaks.",
             "requires" => "Operator"
         ],
+        "F" => [
+            "name" => "Flood Profile",
+            "description" => "Use a Flood Profile to easily apply flood protection mechanisms",
+        ],
         "G" => [
             "name" => "Filter",
             "description" => "Filters out all Bad words in messages with \"&lt;censored&gt;</pre>\".",
index c4649ef8bdafbcabfc96dcdaf55b54861f34ed55..180080fb3a605a2958eef920fee91ffb01cfaa1b 100644 (file)
@@ -50,22 +50,19 @@ if (isset($_POST))
        {
                foreach($_POST['ce_checkboxes'] as $c)
                        $checkboxes[] = $c;
-               $del_ex = true;
-               chlkup_autoload_modal("excepts_modal");
+               do_delete_chanex($channelObj, $checkboxes);
        }
-       else if (isset($_POST['delete_sel_inv']))
+       if (isset($_POST['delete_sel_inv']))
        {
                foreach($_POST['ci_checkboxes'] as $c)
                        $checkboxes[] = $c;
-               $del_inv = true;
-               chlkup_autoload_modal("invites_modal");
+               do_delete_invite($channelObj, $checkboxes);
        }
        else if (isset($_POST['delete_sel_ban']))
        {
                foreach($_POST['cb_checkboxes'] as $c)
                        $checkboxes[] = $c;
-               $del_ban = true;
-               chlkup_autoload_modal("bans_modal");
+               do_delete_chanban($channelObj, $checkboxes);
        }
        if (isset($_POST['add_chban']) || isset($_POST['add_chinv']) || isset($_POST['add_chex']))
        {
@@ -162,14 +159,14 @@ if (isset($_POST))
 
 ?>
 <title><?php echo $title; ?></title>
-<h4><?php echo $title; ?></h4>
+<h6><?php echo $title; ?></h6>
 <br>
 
 
 <div class="container-xl">
 <form method="get" action="details.php">
-       <div class="input-group">
-               <input  class="form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
+       <div class="text-left input-group">
+               <input class="form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
                <div class="input-group-append">
                        <button type="submit" class="btn btn-primary">Go</button>
                </div>
@@ -179,67 +176,6 @@ if (isset($_POST))
 <?php if (!$channelObj)
                return; ?>
 
-
-<!-- Modal for Channel Bans -->
-<div class="modal fade" id="bans_modal" name="bans_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
-       <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
-               <div class="modal-content">
-               <div class="modal-header">
-                       <h5 class="modal-title" id="myModalLabel">Channel Bans</h5>
-                       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-                       <span aria-hidden="true">&times;</span>
-                       </button>
-               </div>
-               <div class="modal-body">
-                       <?php if ($del_ban) do_delete_chanban($channelObj, $checkboxes); ?>
-                       <form method="post">
-                       <?php generate_chanbans_table($channelObj); ?>          
-                       </form>
-               </div>
-               </div>
-       </div>
-</div>
-<!-- Modal for Channel Invited -->
-<div class="modal fade" id="invites_modal" name="#invites_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
-       <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
-               <div class="modal-content">
-               <div class="modal-header">
-                       <h5 class="modal-title" id="myModalLabel">Channel Invites</h5>
-                       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-                       <span aria-hidden="true">&times;</span>
-                       </button>
-               </div>
-               <div class="modal-body">
-                       <?php if ($del_inv) do_delete_invite($channelObj, $checkboxes); ?>
-                       <form method="post">
-                       <?php generate_chaninvites_table($channelObj); ?>               
-                       </form>
-               </div>
-               </div>
-       </div>
-</div>
-
-<!-- Modal for Channel Exceptions -->
-<div class="modal fade" id="excepts_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
-       <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
-               <div class="modal-content">
-               <div class="modal-header">
-                       <h5 class="modal-title" id="myModalLabel">Channel Exceptions</h5>
-                       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-                       <span aria-hidden="true">&times;</span>
-                       </button>
-               </div>
-               <div class="modal-body">
-                       <?php if ($del_ex) do_delete_chanex($channelObj, $checkboxes); ?>
-                       <form method="post">
-                       <?php generate_chanexcepts_table($channelObj); ?>               
-                       </form>
-               </div>
-               </div>
-       </div>
-</div>
-
-
 <!-- Modal for Add Ban -->
 <div class="modal fade" id="ban" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
@@ -408,8 +344,8 @@ if (isset($_POST))
 </div>
 
 <br>
-<h3>
-       Topic:<br></h3>
+<h6>
+       Topic:<br></h6>
        <form method="post" action="details.php?chan=<?php echo urlencode($channelObj->name); ?>">
        <div class="input-group">
        <input maxlength="360" type="text" class="input-group form-control" name="set_topic" value="<?php echo (isset($channelObj->topic)) ? htmlspecialchars($channelObj->topic) : ""; ?>">
@@ -483,37 +419,12 @@ if ($topicset)
        </div>
 </div>
 
-<div class="row" style="margin-left: 0px">
-       <div class="p-1">
-               <button class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Bans</button>
-               <div class="dropdown-menu">
-                       <div class="dropdown-item" data-toggle="modal" data-target="#ban">Add New</div>
-                       <div class="dropdown-item" data-toggle="modal" data-target="#bans_modal">List</div>
-               </div>
-       </div>
-       <div class="p-1">
-               <button class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Invites</button>
-               <div class="dropdown-menu">
-                       <div class="dropdown-item" data-toggle="modal" data-target="#invite">Add New</div>
-                       <div class="dropdown-item" data-toggle="modal" data-target="#invites_modal">List</div>
-               </div>
-       </div>
-       <div class="p-1">       
-       <button class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Excepts</button>
-               <div class="dropdown-menu">
-                       <div class="dropdown-item" data-toggle="modal" data-target="#except">Add New</div>
-                       <div class="dropdown-item" data-toggle="modal" data-target="#excepts_modal">List</div>
-               </div>
-       </div>
-</div>
-<br>
-
 <div class="container-xxl">
   <div class="row">
     <div class="col-sm-5">
       <div class="card">
         <div class="card-body">
-          <h5 class="card-title">User List</h5>
+          <h6 class="card-title">User List</h6>
           <p class="card-text"><?php generate_chan_occupants_table($channelObj); ?></p>
         </div>
       </div>
@@ -521,13 +432,39 @@ if ($topicset)
     <div class="col-sm-6">
       <div class="card">
         <div class="card-body">
-          <h5 class="card-title">Channel Settings</h5>
-          <p class="card-text"><?php generate_html_chansettings($channelObj); ?></p>
+               <h6 class="card-title">Channel Settings</h6>
+                       <ul class="nav nav-tabs" role="tablist">
+                               <li class="nav-item" role="presentation"><a class="nav-link" href="#chanmodes" aria-controls="chanmodes" role="tab" data-toggle="tab">Settings / Modes</a></li>
+                               <li class="nav-item" role="presentation"><a class="nav-link" href="#chanbans" aria-controls="chanbans" role="tab" data-toggle="tab">Bans</a></li>
+                               <li class="nav-item" role="presentation"><a class="nav-link" href="#chaninv" aria-controls="chaninv" role="tab" data-toggle="tab">Invites</a></li>
+                               <li class="nav-item" role="presentation"><a class="nav-link" href="#chanex" aria-controls="chanex" role="tab" data-toggle="tab">Excepts</a></li>
+                       </ul>
+               
+               <div class="tab-content">
+               
+               <div role="tabpanel" class="tab-pane fade in" id="chanmodes">
+                       <p class="card-text"><?php generate_html_chansettings($channelObj); ?></p>
+               </div>
+               
+               <div role="tabpanel" class="tab-pane fade in" id="chanbans">
+                       <p class="card-text"><?php generate_chanbans_table($channelObj); ?></p>
+               </div>
+               <div role="tabpanel" class="tab-pane fade in" id="chaninv">
+                       <p class="card-text"><?php generate_chaninvites_table($channelObj); ?></p>
+               </div>
+               <div role="tabpanel" class="tab-pane fade in" id="chanex">
+                       <p class="card-text"><?php generate_chanexcepts_table($channelObj); ?></p>
+               </div>
+               
+               </div>
         </div>
       </div>
     </div>
 </div>
-
+<script>
+    // show dat first tab
+$('.nav-tabs a[href="#chanmodes"]').tab('show')
+</script>
 <?php 
 require_once("../footer.php");
 
index ab136be438fd581c529902510a53814f9071a72b..84ab0d9b81c7ff33b05ba74b68a640f71a75a755 100644 (file)
@@ -6,9 +6,11 @@ require_once "Classes/class-hook.php";
 if (!is_dir(UPATH . "/vendor"))
        die("The vendor/ directory is missing. Most likely the admin forgot to run 'composer install'\n");
 require_once UPATH . '/vendor/autoload.php';
+require_once UPATH . "/Classes/class-cmodes.php";
 require_once UPATH . "/cfg/defines.php";
 require_once UPATH . "/connection.php";
 require_once UPATH . "/misc/strings.php";
+require_once UPATH . "/misc/channel-lookup-misc.php";
 require_once UPATH . "/misc/user-lookup-misc.php";
 require_once UPATH . "/misc/server-lookup-misc.php";
 require_once UPATH . "/misc/ip-whois-misc.php";
@@ -16,7 +18,6 @@ require_once UPATH . "/Classes/class-log.php";
 require_once UPATH . "/Classes/class-message.php";
 require_once UPATH . "/Classes/class-rpc.php";
 require_once UPATH . "/Classes/class-paneluser.php";
-require_once UPATH . "/Classes/class-cmodes.php";
 require_once UPATH . "/plugins.php";
 
 $pages = [
index dbae86338f6688a6101b3f9893cf78f0cb1e757f..d2de46c74505f3060880bb4b29c6f0ef80bb2f0c 100644 (file)
@@ -4,11 +4,12 @@ function generate_chanbans_table($channel)
 {
        global $rpc;
        $channel = $rpc->channel()->get($channel->name);
-       ?>
-       <form method="post"><p>
+       ?><p><table class="container-xxl table table-responsive caption-top table-striped">
+       <button class="btn btn-primary mr-1 btn-sm" data-toggle="modal" data-target="#ban">Add New</button>
+       <form method="post">
        <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ban">Delete</button>
        </p>
-       <table class="table table-responsive table-hover caption-top table-striped">
+       
        <thead class="table-info">
                <th><input type="checkbox" label='selectall' onClick="toggle_chanbans(this)" /></th>
                <th>Name</th>
@@ -40,11 +41,12 @@ function generate_chaninvites_table($channel)
 {
        global $rpc;
        $channel = $rpc->channel()->get($channel->name);
-       ?>
-       <form method="post"><p>
+       ?><p><table class="table table-responsive table-hover caption-top table-striped">
+       <button class="btn btn-primary btn-sm mr-1" data-toggle="modal" data-target="#invite">Add New</button>
+       <form method="post">
        <button class="btn btn-info btn-sm" type="submit" name="delete_sel_inv">Delete</button>
        </p>
-       <table class="table table-responsive table-hover caption-top table-striped">
+       
        <thead class="table-info">
                <th><input type="checkbox" label='selectall' onClick="toggle_chaninvs(this)" /></th>
                <th>Name</th>
@@ -77,12 +79,14 @@ function generate_chaninvites_table($channel)
 function generate_chanexcepts_table($channel)
 {
        global $rpc;
+       echo "<form method=\"post\">";
        $channel = $rpc->channel()->get($channel->name);
-       ?>
-       <form method="post"><p>
+       ?><p><table class="table table-responsive table-hover caption-top table-striped">
+       <button class="btn btn-primary mr-1 btn-sm" data-toggle="modal" data-target="#except">Add New</button>
+       
        <button class="btn btn-info btn-sm" type="submit" name="delete_sel_ex">Delete</button>
        </p>
-       <table class="table table-responsive table-hover caption-top table-striped">
+       
        <thead class="table-info">
                <th><input type="checkbox" label='selectall' onClick="toggle_chanexs(this)" /></th>
                <th>Name</th>
@@ -122,21 +126,22 @@ function generate_chanexcepts_table($channel)
  */
 function generate_chan_occupants_table($channel)
 {
+       global $rpc;
        ?>
        <form method="post"><p>
        
        </p>
-       <table class="table table-responsive table-hover table-striped">
+       <table class="container-xxl table table-sm table-responsive caption-top table-striped">
        <thead class="table-info">
                <th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th>
                <th>Name</th>
+               <th>Host</th>
                <th>Status</th>
-               <th>Quick Actions</th>
-               <th></th>
        </thead>
        <tbody>
                <?php
-               foreach ($channel->members as $member)
+               $m = sort_user_list($channel->members);
+               foreach ($m as $member)
                {
                        $lvlstring = "";
 
@@ -171,13 +176,13 @@ function generate_chan_occupants_table($channel)
                        }
                        echo "<tr>";
                        ?><form method="post" action=""><?php
+                       $target = $rpc->user()->get($member->id);
                        $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>$lvlstring</td>";
-                       echo "<td><button name=\"kickban\" value=\"$member->id\" type=\"submit\" class=\"btn-sm $disabledcolor\" $disabled>Kick ban</button></td>";
-                       echo "<td><button name=\"muteban\" value=\"$member->id\" type=\"submit\" class=\"btn-sm $disabledcolor\" $disabled>Mute ban</button></td>";
+                       echo "<td><code>".htmlspecialchars($target->hostname)."</code></td>";
+                       echo "<td class='text-right'>$lvlstring</td>";
                        echo "</tr>";
                }
 
@@ -275,7 +280,7 @@ function _do_chan_item_delete($chan, string $type, array $list, array &$errors)
                $n .= $char;
                $str .= " ".$l;
        }
-       if ($rpc->channel()->set_mode($chan->name, "-$n", $str))
+       if ($rpc->channel()->set_mode($chan->name, htmlspecialchars("-$n"), htmlspecialchars($str)))
        {
                Message::Success("Deleted successfully");
                return true;
@@ -301,4 +306,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