]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - Classes/class-rpc.php
Allow adding spamfilter entries
[irc/unrealircd/unrealircd-webpanel.git] / Classes / class-rpc.php
index cf8a2d51ac5c11db8b33221186cf879e37ff5820..a952d0974a773f5493621b5e1b3b3d5120342ccd 100644 (file)
@@ -13,6 +13,8 @@ if (!defined('UPATH'))
 require UPATH . '/vendor/autoload.php';
 
 use UnrealIRCd\Connection;
+use UnrealIRCd\User;
+use UnrealIRCd\Channel;
 
 class RPC_List
 {
@@ -32,10 +34,10 @@ function rpc_pop_lists()
        GLOBAL $rpc;
 
        /* Get the user list */
-       $ret = $rpc->query("user.list");
+       $ret = $rpc->user()->getAll();
        // TODO: error checking
 
-       foreach($ret->list as $r)
+       foreach($ret as $r)
        {
                RPC_List::$user[] = $r;
                if (strpos($r->user->modes,"o") !== false && strpos($r->user->modes,"S") == false)
@@ -45,8 +47,8 @@ function rpc_pop_lists()
        }
 
        /* Get the channels list */
-       $ret = $rpc->query("channel.list");
-       foreach($ret->list as $r)
+       $ret = $rpc->channel()->getAll();
+       foreach($ret as $r)
        {
                RPC_List::$channel[] = $r;
                if ($r->num_users > RPC_List::$channel_pop_count)
@@ -57,74 +59,17 @@ function rpc_pop_lists()
        }
 
        /* Get the tkl list */
-       $ret = $rpc->query("server_ban.list");
-       foreach($ret->list as $r)
+       $ret = $rpc->serverban()->getAll();
+       foreach($ret as $r)
                RPC_List::$tkl[] = $r;
 
        /* Get the spamfilter list */
-       $ret = $rpc->query("spamfilter.list");
-       foreach($ret->list as $r)
+       $ret = $rpc->spamfilter()->getAll();
+       foreach($ret as $r)
                RPC_List::$spamfilter[] = $r;
 
 }
 
-
-/** RPC TKL Add */
-function rpc_tkl_add($name, $type, $expiry, $reason) : bool
-{
-       GLOBAL $rpc;
-
-       $params = ["name" => $name, "type" => $type, "reason" => $reason, "duration_string" => $expiry];
-       $result = $rpc->query("server_ban.add", $params);
-       if ($result->error)
-       {
-               $msg = "The $type could not be added: $name - ".$result->error->message . " (" . $result->error->code . ")";
-               Message::Fail($msg);
-               return false;
-       }
-       return true;
-}
-
-
-/** RPC TKL Delete */
-function rpc_tkl_del($name, $type) : bool
-{
-       GLOBAL $rpc;
-
-       $params = ["name" => $name, "type" => $type];
-       $result = $rpc->query("server_ban.del", $params);
-       if ($result->error)
-       {
-               $msg = "The $type could not be deleted: $name - ".$result->error->message . " (" . $result->error->code . ")";
-               Message::Fail($msg);
-               return false;
-       }
-       return true;
-}
-
-/** RPC Spamfilter Delete
- * 
- */
-function rpc_sf_del($name, $mtype, $targets, $action) : bool
-{
-       GLOBAL $rpc;
-
-       $params = ["name" => $name, "match_type" => $mtype, "spamfilter_targets" => $targets, "ban_action" => $action, "set_by" => "YoMama"];
-       $result = $rpc->query("spamfilter.del", $params);
-       if ($result->error)
-       {
-               $msg = "The spamfilter entry could not be deleted: $name - ".$result['error']['message'] . " (" . $result['error']['code'] . ")";
-               Message::Fail($msg);
-               return false;
-       }
-       else
-       {
-               $r = $result->tkl;
-               Message::Success("Deleted spamfilter entry: ".$r->name." [type: ".$r->match_type."] [targets: ".$r->spamfilter_targets. "] [action: ".$r->ban_action."] [reason: ".$r->reason."] [set by: ".$r->set_by."]");
-       }
-       return true;
-}
-
 /** Convert the duration_string */
 function rpc_convert_duration_string($str)
 {