[Phpfreechat-svn] SF.net SVN: phpfreechat: [509] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-05-26 20:56:42
|
Revision: 509 Author: kerphi Date: 2006-05-26 13:56:29 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=509&view=rev Log Message: ----------- Code refactoring : change the specific "privmsg" metadata key to a more generic "cmdtoplay" Modified Paths: -------------- trunk/src/commands/nick.class.php trunk/src/commands/update.class.php trunk/src/phpfreechat.class.php trunk/src/proxys/auth.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Added Paths: ----------- trunk/src/commands/kick.class.php trunk/src/commands/op.class.php Added: trunk/src/commands/kick.class.php =================================================================== --- trunk/src/commands/kick.class.php (rev 0) +++ trunk/src/commands/kick.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -0,0 +1,16 @@ +<?php + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); + +class pfcCommand_kick extends pfcCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $xml_reponse->addScript("alert('/kick $param command');"); + } +} + +?> \ No newline at end of file Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/commands/nick.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -130,4 +130,4 @@ } } -?> +?> \ No newline at end of file Added: trunk/src/commands/op.class.php =================================================================== --- trunk/src/commands/op.class.php (rev 0) +++ trunk/src/commands/op.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -0,0 +1,16 @@ +<?php + +require_once(dirname(__FILE__)."/../pfccommand.class.php"); + +class pfcCommand_op extends pfcCommand +{ + function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) + { + $c =& $this->c; + $u =& $this->u; + + $xml_reponse->addScript("alert('op command');"); + } +} + +?> \ No newline at end of file Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/commands/update.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -23,18 +23,21 @@ // $cmd =& pfcCommand::Factory("notice"); // $cmd->run($xml_reponse, $clientid, _pfc("%s quit (timeout)",$u), $sender, $recipient, $recipientid, 2); // } - - // ----- - // check if other user talk to me or not + + + // --- + // play the other commands $nickid = $container->getNickId($u->nick); - $pvnicks = $container->getMeta("privmsg", "nickname", $nickid); - if (is_string($pvnicks)) $pvnicks = unserialize($pvnicks); - if (!is_array($pvnicks)) $pvnicks = array(); - for( $i=0; $i < count($pvnicks); $i++) - $xml_reponse->addScript("pfc.handleResponse('update', 'privmsg', '".addslashes($pvnicks[$i])."');"); - $container->rmMeta("privmsg", "nickname", $nickid); - // ----- + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $nickid); + if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); + if (!is_array($cmdtoplay)) $cmdtoplay = array(); + foreach($cmdtoplay as $cmdstr => $cmdparams) + foreach($cmdparams as $cmdparam) + $xml_reponse->addScript("pfc.handleResponse('update', 'cmdtoplay', Array('".$cmdstr."','".addslashes($cmdparam)."'));"); + $container->rmMeta("cmdtoplay", "nickname", $nickid); + // --- + // update the user nickname timestamp $cmd =& pfcCommand::Factory("updatemynick"); foreach( $u->channels as $id => $chan ) Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/phpfreechat.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -343,22 +343,27 @@ { $recipient = $u->privmsg[$recipientid]["recipient"]; + + // @todo: move this code in a proxy if ($rawcmd != "update" && - $rawcmd != "leave") // do not open the pv tab when other user close the tab + $rawcmd != "leave" && // do not open the pv tab when other user close the tab + $rawcmd != "privmsg2") { // alert the other from the new pv // (warn other user that someone talk to him) $container =& $c->getContainerInstance(); - $pvs = $container->getMeta("privmsg", "nickname", $u->privmsg[$recipientid]["pvnickid"]); - if (is_string($pvs)) $pvs = unserialize($pvs); - if (!is_array($pvs)) $pvs = array(); - if (!in_array($u->nick,$pvs)) + $cmdtoplay = $container->getMeta("cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + if (is_string($cmdtoplay)) $cmdtoplay = unserialize($cmdtoplay); + if (!is_array($cmdtoplay)) $cmdtoplay = array(); + if (!isset($cmdtoplay["privmsg2"])) $cmdtoplay["privmsg2"] = array(); + if (!in_array($u->nick, $cmdtoplay["privmsg2"])) { - $pvs[] = $u->nick; - // $xml_reponse->addScript("alert('pvs[]=".serialize($pvs)."');"); - $container->setMeta(serialize($pvs), "privmsg", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + $cmdtoplay["privmsg2"][] = $u->nick; + $container->setMeta(serialize($cmdtoplay), "cmdtoplay", "nickname", $u->privmsg[$recipientid]["pvnickid"]); + // $xml_reponse->addScript("alert('cmdtoplay[]=".serialize($cmdtoplay)."');"); } } + } $cmd =& pfcCommand::Factory($rawcmd); Modified: trunk/src/proxys/auth.class.php =================================================================== --- trunk/src/proxys/auth.class.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/src/proxys/auth.class.php 2006-05-26 20:56:29 UTC (rev 509) @@ -32,10 +32,22 @@ { function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { + $c =& $this->c; + $u =& $this->u; + // $xml_reponse->addScript("alert('proxy auth');"); // if ($this->name == "send") // $xml_reponse->addScript("alert('proxy auth');"); + + if ($this->name == "op") + { + if (!in_array($u->nick, $c->admins)) + { + $xml_reponse->addScript("alert('not allowed to do /op');"); + } + } + // on passe la main a au prochain proxy (ou a la command finale) $this->next->run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-26 20:54:59 UTC (rev 508) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-26 20:56:29 UTC (rev 509) @@ -322,24 +322,22 @@ if (resp == "ok") { } - else if (resp == "privmsg") + else if (resp == "cmdtoplay") { - // check if the wanted privmsg exists or not - var index = this.privmsgs.indexOf(param); - if (index == -1) + if (param[0] == "privmsg2") { - // it doesn't exists, create it in the background - this.sendRequest('/privmsg2', param); - } - else - { - var tabid = this.privmsgids[index]; - if (this.gui.getTabId() != tabid) + // do not open the same tab twice + // (it's not necessary to speak to the server if the tab is allready open) + // so we check if the wanted privmsg tab exists or not + var index = this.privmsgs.indexOf(param[1]); + if (index == -1) { - // alert user something occurs in the pv tab - // alert("todo: highlight the '"+param+"' tab (tabid="+tabid+")"); + // it doesn't exists, create it in the background + this.sendRequest("/"+param[0],param[1]); } } + else + this.sendRequest("/"+param[0],param[1]); } // else // alert(cmd + "-"+resp+"-"+param); @@ -649,7 +647,7 @@ { var recipientid = this.gui.getTabId(); var req = cmd+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+(param?" "+param : ""); - if (cmd != "/update") alert(req); + <?php if ($debug) { ?> if (cmd != "/update") alert(req);<?php } ?> return <?php echo $prefix; ?>handleRequest(req); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |