]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - channels/details.php
Don't call channel.get() twice for simple GET requests.
[irc/unrealircd/unrealircd-webpanel.git] / channels / details.php
index 42782da0a8bcf85ba6dbe83979a9e2acaa52d1ec..115d24289797b71bcf4afd44f32eb74c72b1a186 100644 (file)
@@ -13,7 +13,7 @@ do_log($_POST);
 if (isset($_GET['chan']))
 {
        $channel = $_GET['chan'];
-       $channelObj = $rpc->channel()->get($channel);
+       $channelObj = $rpc->channel()->get($channel, 4);
        if (!$channelObj && strlen($channel))
        {
                Message::Fail("Could not find channel: \"$channel\"");
@@ -31,7 +31,7 @@ $del_ban = false;
 $checkboxes = [];
 
 $chanban_errors = [];
-if (isset($_POST))
+if (!empty($_POST))
 {
        if (isset($_POST['update_topic']) && isset($_POST['set_topic']))
        {
@@ -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']))
        {
@@ -76,7 +73,7 @@ if (isset($_POST))
                        $mode = (isset($_POST['add_chinv'])) ? $_POST['add_chinv'] : $_POST['add_chex'];
                
                $nick = (strlen($_POST['ban_nick'])) ? $_POST['ban_nick'] : false;
-               $action_string = (strlen($_POST['bantype_sel_action'])) ? $_POST['bantype_sel_action'] : false;
+               $action_string = (isset($_POST['bantype_sel_action']) && strlen($_POST['bantype_sel_action'])) ? $_POST['bantype_sel_action'] : false;
                $action = "";
                $type_string = (strlen($_POST['bantype_sel_type'])) ? $_POST['bantype_sel_type'] : false;
                $type = "";
@@ -130,75 +127,53 @@ if (isset($_POST))
                        foreach($chanban_errors as $err)
                                Message::Fail($err);
        }
-       /* and finally re-grab the channel because updates lol */
-       $channelObj = $rpc->channel()->get($channel);
+       if ((isset($_POST['kickban']) || isset($_POST['muteban'])) && current_user_can(PERMISSION_EDIT_CHANNEL_USER))
+       {
+               $mute = (isset($_POST['muteban'])) ? true : false;
+               $mutestr = ($mute) ? "~quiet:" : "";
+               $user = (!$mute) ? $_POST['kickban'] : $_POST['muteban'];
+
+               $kbuser = $rpc->user()->get($user);
+
+               if (!$kbuser)
+                       Message::Fail("Could not kickban user: User does not exist");
+               else
+               {
+                       $rpc->channel()->set_mode($channelObj->name, "+b", "~time:".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME.":".$mutestr."*!*@".$kbuser->user->cloakedhost);
+                       if (!$mute)
+                               $rpc->channel()->kick($channelObj->name, $kbuser->name, DEFAULT_CHAN_DETAIL_QUICK_BAN_REASON);
 
+                       $msgbox_str = ($mute)
+                       ?
+                               "User \"$kbuser->name\" has been muted for ".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME." minutes."
+                       :
+                               "User \"$kbuser->name\" has been banned for ".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME." minutes."
+                       ;
+                       Message::Success($msgbox_str);
+               }
+       }
+       /* Re-grab the channel because of updates */
+       $channelObj = $rpc->channel()->get($channel, 4);
 }
 
 ?>
 <title><?php echo $title; ?></title>
-<h4><?php echo $title; ?></h4>
+<h6><?php echo $title; ?></h6>
 <br>
 
-<!-- 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 class="container-xl">
+<form method="get" action="details.php">
+       <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>
        </div>
 </div>
-
+</form>
+<?php if (!$channelObj)
+               return; ?>
 
 <!-- Modal for Add Ban -->
 <div class="modal fade" id="ban" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
@@ -306,9 +281,9 @@ if (isset($_POST))
                        </div>
                </div>
                <div class="modal-footer">
-                       <input type="hidden" name="add_chinv" value="e"></input>
+                       <input type="hidden" name="add_chinv" value="I"></input>
                        <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
-                       <button type="submit" action="post" class="btn btn-danger">Add Channel Ban</button>
+                       <button type="submit" action="post" class="btn btn-danger">Add Invite</button>
                        </form>
                </div>
                </div>
@@ -366,23 +341,10 @@ if (isset($_POST))
                </div>
        </div>
 </div>
-<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="input-group-append">
-                       <button type="submit" class="btn btn-primary">Go</button>
-               </div>
-       </div>
-</div>
-</form>
-
-<?php if (!$channelObj)
-               return; ?>
 
 <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) : ""; ?>">
@@ -393,80 +355,115 @@ if ($topicset)
        Message::Success("The topic for $channelObj->name has been updated to be: \"".htmlspecialchars($channelObj->topic)."\"");
 ?>
 <br>
-<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>
+
+<!-- Modal for User Action -->
+<div class="modal fade" id="useraction" 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">Add New Channel Ban</h5>
+                       <div type="button" class="close" data-dismiss="modal" aria-label="Close">
+                       <span aria-hidden="true">&times;</span>
                </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="accordion" id="accordionExample">
-               <div class="card">
-                       <div class="card-header" id="headingOne">
-                       <h2 class="mb-0">
-                               <button class="btn" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
-                               User List
-                               </button>
-                       </h2>
-                       </div>
-
-                       <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
-                       <div class="card-body">
-                               <?php generate_chan_occupants_table($channelObj); ?>
-                       </div>
+               <div class="modal-body">
+                       <form method="post">
+                       <div class="input-group mb-3">
+                               <label for="ban_nick">Mask
+                                       <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
+                                       title="The mask or other value. For example if you are matching a country in 'Ban Type' then you would put the country code as this value. Click to view more information on Extended Bans"
+                                       ></i></a>
+                                       <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
+                                                       placeholder="nick!user@host or something else"
+                                       ></label>
+                                       
                        </div>
-               </div>
-               <div class="card">
-                       <div class="card-header" id="headingTwo">
-                       <h2 class="mb-0">
-                               <button class="btn collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
-                               Collapsible Group Item #2
-                               </button>
-                       </h2>
+                       <div class="input-group mb-3">
+                               <label for="bantype_action">Ban Action
+                                       <select class="form-control" name="bantype_sel_action" id="bantype_sel">
+                                               <option></option>
+                                               <option>Quiet (Mute)</option>
+                                               <option>Nick-change</option>
+                                               <option>Join</option>
+                                       </select>
+                               </label>
                        </div>
-                       <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
-                       <div class="card-body">
-                               Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
+                       <div class="input-group mb-3">
+                               <label for="bantype_sel_type">Ban Type
+                                       <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
+                                               <option></option>
+                                               <option>Match Account</option>
+                                               <option>Match Channel</option>
+                                               <option>Match Country</option>
+                                               <option>Match OperClass</option>
+                                               <option>Match RealName / GECOS</option>
+                                               <option>Match Security Group</option>
+                                               <option>Match Certificate Fingerprint</option>
+                                       </select>
+                               </label>
                        </div>
+                       <div class="input-group mb-3">
+                       <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
+                                       <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
+                               </label>
                        </div>
                </div>
-               <div class="card">
-                       <div class="card-header" id="headingThree">
-                       <h2 class="mb-0">
-                               <button class="btn collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
-                               Collapsible Group Item #3
-                               </button>
-                       </h2>
-                       </div>
-                       <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
-                       <div class="card-body">
-                               Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
-                       </div>
-                       </div>
+               <div class="modal-footer">
+                       <input type="hidden" id="server" name="add_chban" value="b"></input>
+                       <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
+                       <button type="submit" action="post" class="btn btn-danger">Add Channel Ban</button>
+                       </form>
+               </div>
                </div>
        </div>
 </div>
 
+<div class="container-xxl">
+  <div class="row">
+    <div class="col-sm-4">
+      <div class="card">
+        <div class="card-body">
+          <h6 class="card-title">User List</h6>
+          <p class="card-text"><?php generate_chan_occupants_table($channelObj); ?></p>
+        </div>
+      </div>
+    </div>
+    <div class="col-sm-8">
+      <div class="card">
+        <div class="card-body">
+               <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");