1<?php
2/**
3 * who2.class.php
4 *
5 * Copyright © 2006 Stephane Gully <stephane.gully@gmail.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, 51 Franklin St, Fifth Floor,
20 * Boston, MA  02110-1301  USA
21 */
22
23require_once(dirname(__FILE__)."/who.class.php");
24
25class pfcCommand_who2 extends pfcCommand_who
26{
27
28  function run(&$xml_reponse, $p)
29  {
30    $clientid    = $p["clientid"];
31    $param       = $p["param"];
32    $sender      = $p["sender"];
33    $recipient   = $p["recipient"];
34    $recipientid = $p["recipientid"];
35
36    $c =& pfcGlobalConfig::Instance();
37    $u =& pfcUserConfig::Instance();
38
39    if ($param != "")
40    {
41      require_once dirname(__FILE__)."/join.class.php";
42      $recipient   = pfcCommand_join::GetRecipient($param);
43      $recipientid = pfcCommand_join::GetRecipientId($param);
44    }
45
46    $chanmeta = $this->_getChanMeta($recipient, $recipientid);
47
48    //if (preg_match("/^pv_/", $recipient))
49    //$this->trace($xml_reponse, 'who2', $recipient);
50
51    // check if info didn't change since last call
52    $sid = "pfc_who2_".$c->getId()."_".$clientid."_".$recipientid;
53    if (isset($_SESSION[$sid]) && $chanmeta == $_SESSION[$sid])
54    {
55      // do not send the response to save bandwidth
56      //$xml_reponse->script("pfc.handleResponse('".$this->name."', 'unchanged', '');");
57    }
58    else
59    {
60      $_SESSION[$sid] = $chanmeta;
61      $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', ".$chanmeta.");");
62    }
63  }
64}
65
66?>