]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - channels/details.php
Move some PHP files from ./ to ./inc: common, connection, header, footer
[irc/unrealircd/unrealircd-webpanel.git] / channels / details.php
index 0c11a15567ce7397bb6b42cac6e14faf53616454..8cf6543914963545af6222f5a96ac72ce82f86ac 100644 (file)
@@ -1,19 +1,23 @@
 <?php
-require_once "../common.php";
-require_once "../header.php";
-require_once "../misc/channel-lookup-misc.php";
+require_once "../inc/common.php";
+require_once "../inc/connection.php";
+require_once "../inc/header.php";
 
+if ($uplink = $rpc->server()->get())
+       IRCList::setmodes($uplink->server->features->chanmodes);
 $title = "Channel Lookup";
 $channel = "";
 $channame = "";
 $nick = NULL;
 $channelObj = NULL;
+
+$can_edit = current_user_can(PERMISSION_EDIT_CHANNEL);
 do_log($_GET);
 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 +35,7 @@ $del_ban = false;
 $checkboxes = [];
 
 $chanban_errors = [];
-if (isset($_POST))
+if (!empty($_POST))
 {
        if (isset($_POST['update_topic']) && isset($_POST['set_topic']))
        {
@@ -152,26 +156,67 @@ if (isset($_POST))
                        Message::Success($msgbox_str);
                }
        }
-       /* and finally re-grab the channel because updates lol */
-       $channelObj = $rpc->channel()->get($channel);
 
+       if (isset($_POST['newmodes']) && isset($_POST['paramed_modes']) && $can_edit)
+       {
+               $m = $_POST['newmodes'];
+               $p = $_POST['paramed_modes'];
+
+               do_log($p,$m);
+               $addmodestring = "+";
+               $addparamstring = "";
+               $delmodestring = "-";
+               $delparamstring = "";
+               foreach ($m as $mode)
+               {
+                       strcat($addmodestring, $mode);
+                       if (isset($p[$mode]) && strlen($p[$mode]))
+                               strcat($addparamstring, $p[$mode]." ");
+               }
+
+               $fmodes = $channelObj->modes;
+               $tok = split($fmodes);
+               $modes = $tok[0];
+               $params = rparv($fmodes);
+               $paramed_modes = sort_paramed_modes($modes, $params);
+               for ($i = 0; isset($modes[$i]) && $mode = $modes[$i]; $i++)
+               {
+                       if (!strstr($addmodestring, $mode))
+                       {
+                               $req = IRCList::lookup($mode)['requires'];
+                               if ($req == "Server")
+                                       continue;
+                               strcat($delmodestring, $mode);
+                               $grp = get_chmode_group($mode);
+                               if ($grp == 2)
+                                       strcat($delparamstring, $paramed_modes[$mode]." ");
+                       }
+                       
+               }
+
+
+               if ($rpc->channel()->set_mode($channel, $delmodestring.$addmodestring, $delparamstring." ".$addparamstring))
+                       Message::Success("Channel settings have been successfully updated");
+               else
+                       Message::Fail("Could not change channel settings: $rpc->error");
+       }
+
+       /* Re-grab the channel because of updates */
+       $channelObj = $rpc->channel()->get($channel, 4);
 }
 
 ?>
 <title><?php echo $title; ?></title>
 <h6><?php echo $title; ?></h6>
-<br>
 
 
-<div class="container-xl">
 <form method="get" action="details.php">
-       <div class="text-left input-group">
+       <div class="text-left input-group" style="width: 35%;">
                <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; ?>
@@ -209,7 +254,7 @@ if (isset($_POST))
                                </label>
                        </div>
                        <div class="input-group mb-3">
-                               <label for="bantype_sel_type">Ban Type
+                               <label for="bantype_sel_type">Ban Type <small>Leave this blank for a "normal" ban</small>
                                        <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
                                                <option></option>
                                                <option>Match Account</option>
@@ -292,11 +337,11 @@ if (isset($_POST))
 </div>
 
 <!-- Modal for Add Ban Exceptions -->
-<div class="modal fade" id="except" tabindex="-1" role="dialog" aria-labelledby="add_except_modal" aria-hidden="true">
+<div class="modal fade" id="except" tabindex="-1" role="dialog" aria-labelledby="except" 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="add_except_modal">Add New Channel Ban Exception</h5>
+                       <h5 class="modal-title" >Add New Channel Ban Exception</h5>
                        <div type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                </div>
@@ -343,6 +388,28 @@ if (isset($_POST))
        </div>
 </div>
 
+<!-- Modal for Edit Channel Modes -->
+<div class="modal fade" id="editchmodes" tabindex="-1" role="dialog" aria-labelledby="editchmodes" aria-hidden="true">
+       <div class="modal-dialog  modal-dialog-centered" role="document">
+               <div class="modal-content">
+               <div class="modal-header">
+                       <h5 class="modal-title" id="editchmodes">Edit Channel Modes</h5>
+                       <div type="button" class="close" data-dismiss="modal" aria-label="Close">
+                       <span aria-hidden="true">&times;</span>
+               </div>
+               </div>
+               <div class="modal-body">
+                       <form method="post">
+                       <?php generate_edit_chmodes($channelObj); ?>
+                       <input type="hidden" id="server" name="add_chex" value="e"></input>
+                       <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
+                       <button type="submit" action="post" class="btn btn-danger">Update</button>
+                       </form>
+               </div>
+               </div>
+       </div>
+</div>
+
 <br>
 <h6>
        Topic:<br></h6>
@@ -421,7 +488,7 @@ if ($topicset)
 
 <div class="container-xxl">
   <div class="row">
-    <div class="col-sm-3">
+    <div class="col-sm-4">
       <div class="card">
         <div class="card-body">
           <h6 class="card-title">User List</h6>
@@ -429,7 +496,7 @@ if ($topicset)
         </div>
       </div>
     </div>
-    <div class="col-sm-6">
+    <div class="col-sm-8">
       <div class="card">
         <div class="card-body">
                <h6 class="card-title">Channel Settings</h6>
@@ -441,20 +508,31 @@ if ($topicset)
                        </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>
+                       <br>
+                       <div class="tab-pane fade in" id="chanmodes">
+                               <button id="editlol" class="btn btn-sm btn-primary" <?php echo ($can_edit) ? "" : "disabled"; ?>>Change Settings</button>
+                               <p class="card-text"><?php generate_html_chansettings($channelObj); ?></p>
+                       </div><form id="editchanmodes" method="post" name="editchanmodes">
+                       <div class="tab-pane" style="display: none" id="chanmodes_edit">
+                               
+                                       <div class="btn btn-sm btn-secondary" id="editchmodesbk">Go back</div>
+                                       <button type="submit" class="btn btn-sm btn-primary">Save Changes</button>
+                                       <p class="card-text"><?php generate_edit_chmodes($channelObj); ?></p>
+                               </form>
+                       </div>
+                       
+                       <div class="tab-pane fade in" id="chanbans">
+                               <p class="card-text"><?php generate_chanbans_table($channelObj); ?></p>
+                       </div>
+                       <div class="tab-pane fade in" id="chaninv">
+                               <p class="card-text"><?php generate_chaninvites_table($channelObj); ?></p>
+                       </div>
+                       <div class="tab-pane fade in" id="chanex">
+                               <p class="card-text"><?php generate_chanexcepts_table($channelObj); ?></p>
+                       </div>
+                       <div class="tab-pane fade in" id="chanmodes_edit">
+                               <p class="card-text"><?php /* insert hacks here */ ?></p>
+                       </div>
                
                </div>
         </div>
@@ -462,9 +540,23 @@ if ($topicset)
     </div>
 </div>
 <script>
+       const toggleBtn = document.getElementById('editlol');
+       const staticInfo = document.getElementById('chanmodes');
+       const options = document.getElementById('chanmodes_edit');
+       const backBtn = document.getElementById('editchmodesbk');
+
+       backBtn.addEventListener('click', function() {
+               staticInfo.style.display = '';
+               options.style.display = 'none';
+       });
+       toggleBtn.addEventListener('click', function() {
+               staticInfo.style.display = 'none';
+               options.style.display = '';
+       });
+
     // show dat first tab
 $('.nav-tabs a[href="#chanmodes"]').tab('show')
 </script>
 <?php 
-require_once("../footer.php");
+require_once("../inc/footer.php");