1<?php 2 3require_once(dirname(__FILE__)."/../pfccommand.class.php"); 4 5class pfcCommand_kick extends pfcCommand 6{ 7 var $usage = "/kick {nickname} [ {reason} ]"; 8 9 function run(&$xml_reponse, $p) 10 { 11 $clientid = $p["clientid"]; 12 $param = $p["param"]; 13 $params = $p["params"]; 14 $sender = $p["sender"]; 15 $recipient = $p["recipient"]; 16 $recipientid = $p["recipientid"]; 17 18 $c =& pfcGlobalConfig::Instance(); 19 $u =& pfcUserConfig::Instance(); 20 21 $nick = isset($params[0]) ? $params[0] : ''; 22 $reason = isset($params[1]) ? $params[1] : ''; 23 if ($reason == '') $reason = _pfc("no reason"); 24 25 // to allow unquotted reason 26 if (count($params) > 2) 27 for ($x=2;$x<count($params);$x++) 28 $reason.=" ".$params[$x]; 29 30 if ($nick == '') 31 { 32 // error 33 $cmdp = $p; 34 $cmdp["param"] = _pfc("Missing parameter"); 35 $cmdp["param"] .= " (".$this->usage.")"; 36 $cmd =& pfcCommand::Factory("error"); 37 $cmd->run($xml_reponse, $cmdp); 38 return; 39 } 40 41 // kicking a user just add a command to play to the aimed user metadata. 42 $ct =& pfcContainer::Instance(); 43 $otherid = $ct->getNickId($nick); 44 $channame = $u->channels[$recipientid]["name"]; 45 $cmdstr = 'leave'; 46 $cmdp = array(); 47 $cmdp['flag'] = 4; 48 $cmdp['params'][] = 'ch'; 49 $cmdp['params'][] = $channame; // channel name 50 $cmdp['params'][] = _pfc("kicked from %s by %s - reason: %s", $channame, $sender, $reason); // reason 51 pfcCommand::AppendCmdToPlay($otherid, $cmdstr, $cmdp); 52 } 53} 54 55?>