1<?php
2
3require_once(dirname(__FILE__)."/../pfccommand.class.php");
4
5class pfcCommand_quit extends pfcCommand
6{
7  function run(&$xml_reponse, $p)
8  {
9    $clientid    = $p["clientid"];
10    $param       = $p["param"];
11    $sender      = $p["sender"];
12    $recipient   = $p["recipient"];
13    $recipientid = $p["recipientid"];
14
15    $c  =& pfcGlobalConfig::Instance();
16    $u  =& pfcUserConfig::Instance();
17    $ct =& pfcContainer::Instance();
18
19    $nick = $ct->getNickname($u->nickid);
20
21    // leave the channels
22    foreach( $u->channels as $id => $chandetail )
23      if ($ct->removeNick($chandetail["recipient"], $u->nickid))
24      {
25        $cmdp = $p;
26        $cmdp["param"] = $id;
27        $cmdp["recipient"] = $chandetail["recipient"];
28        $cmdp["recipientid"] = $id;
29        $cmd =& pfcCommand::Factory("leave");
30        $cmd->run($xml_reponse, $cmdp);
31      }
32    // leave the private messages
33    foreach( $u->privmsg as $id => $pvdetail )
34      if ($ct->removeNick($pvdetail["recipient"], $u->nickid))
35      {
36        $cmdp = $p;
37        $cmdp["param"] = $id;
38        $cmdp["recipient"] = $pvdetail["recipient"];
39        $cmdp["recipientid"] = $id;
40        $cmd =& pfcCommand::Factory("leave");
41        $cmd->run($xml_reponse, $cmdp);
42      }
43    // leave the server
44    $ct->removeNick(NULL, $u->nickid);
45
46    /*
47    // then set the chat inactive
48    $u->active = false;
49    $u->saveInCache();
50    */
51
52    $xml_reponse->script("pfc.handleResponse('quit', 'ok', '');");
53  }
54}
55
56?>
57