1<?php 2/** 3 * who.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__)."/../pfccommand.class.php"); 24 25class pfcCommand_who extends pfcCommand 26{ 27 var $usage = "/who channel"; 28 29 function run(&$xml_reponse, $p) 30 { 31 $clientid = $p["clientid"]; 32 $param = $p["param"]; 33 $sender = $p["sender"]; 34 $recipient = $p["recipient"]; 35 $recipientid = $p["recipientid"]; 36 37 $c =& pfcGlobalConfig::Instance(); 38 $u =& pfcUserConfig::Instance(); 39 40 if ($param != "") 41 { 42 require_once dirname(__FILE__)."/join.class.php"; 43 $recipient = pfcCommand_join::GetRecipient($param); 44 $recipientid = pfcCommand_join::GetRecipientId($param); 45 } 46 47 $chanmeta = $this->_getChanMeta($recipient, $recipientid); 48 49 $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', ".$chanmeta.");"); 50 } 51 52 function _getChanMeta($recipient, $recipientid) 53 { 54 $c =& pfcGlobalConfig::Instance(); 55 $ct =& pfcContainer::Instance(); 56 $chanmeta = array(); 57 $chanmeta['chan'] = $recipient; 58 $chanmeta['chanid'] = $recipientid; 59 $chanmeta['meta'] = $ct->getAllUserMeta($chanmeta['chan']); 60 $users = $ct->getOnlineNick($chanmeta['chan']); 61 $chanmeta['meta']['users'] = array(); 62 $chanmeta['meta']['users']['nick'] = $users['nick']; 63 $chanmeta['meta']['users']['nickid'] = $users['nickid']; 64 65 require_once dirname(__FILE__).'/../pfcjson.class.php'; 66 $json = new pfcJSON(); 67 $js = $json->encode($chanmeta); 68 return $js; 69 } 70} 71 72?>