[Phpfreechat-svn] SF.net SVN: phpfreechat: [506] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-05-25 11:47:36
|
Revision: 506 Author: kerphi Date: 2006-05-25 04:47:21 -0700 (Thu, 25 May 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=506&view=rev Log Message: ----------- + Bug fix: when speaking to someone the new open tab is now open in the background (/privmsg2 command) + As for the /privmsg2 command, a new command /join2 has been created in order to supporte invitation to a channel in the future. Modified Paths: -------------- trunk/src/commands/join.class.php trunk/src/commands/privmsg.class.php trunk/src/phpfreechat.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Added Paths: ----------- trunk/src/commands/join2.class.php trunk/src/commands/privmsg2.class.php Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/src/commands/join.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -40,7 +40,7 @@ // return ok to the client // then the client will create a new tab - $xml_reponse->addScript("pfc.handleResponse('join', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); } } Added: trunk/src/commands/join2.class.php =================================================================== --- trunk/src/commands/join2.class.php (rev 0) +++ trunk/src/commands/join2.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -0,0 +1,34 @@ +<?php +/** + * join2.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +require_once(dirname(__FILE__)."/join.class.php"); + +/** + * Same as join command but open the tab in the background + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcCommand_join2 extends pfcCommand_join +{ +} + +?> \ No newline at end of file Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/src/commands/privmsg.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -8,7 +8,7 @@ { $c =& $this->c; $u =& $this->u; - + $pvname = $param; // check the pvname exists on the server @@ -19,7 +19,7 @@ // error: can't speak to myself if ($pvnickid == $nickid) { - $xml_reponse->addScript("pfc.handleResponse('privmsg', 'ko', Array('".addslashes($pvname)."','speak to myself'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', Array('".addslashes($pvname)."','speak to myself'));"); return; } @@ -39,7 +39,7 @@ $u->saveInCache(); } - $xml_reponse->addScript("pfc.handleResponse('privmsg', 'unknown', Array('".addslashes($pvname)."','speak to unknown'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'unknown', Array('".addslashes($pvname)."','speak to unknown'));"); return; } @@ -73,7 +73,7 @@ // return ok to the client // then the client will create a new tab - $xml_reponse->addScript("pfc.handleResponse('privmsg', 'ok', Array('".$pvrecipientid."','".addslashes($pvname)."'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$pvrecipientid."','".addslashes($pvname)."'));"); } } Added: trunk/src/commands/privmsg2.class.php =================================================================== --- trunk/src/commands/privmsg2.class.php (rev 0) +++ trunk/src/commands/privmsg2.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -0,0 +1,34 @@ +<?php +/** + * privmsg2.class.php + * + * Copyright © 2006 Stephane Gully <ste...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +require_once(dirname(__FILE__)."/privmsg.class.php"); + +/** + * Same as privmsg command but open the tab in the background + * + * @author Stephane Gully <ste...@gm...> + */ +class pfcCommand_privmsg2 extends pfcCommand_privmsg +{ +} + +?> \ No newline at end of file Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/src/phpfreechat.class.php 2006-05-25 11:47:21 UTC (rev 506) @@ -315,7 +315,7 @@ $sender = ""; //if (preg_match("/^\/([a-z]*) ([0-9a-f]*) ([0-9a-f]*)( (.*)|)/", $request, $res)) //if (preg_match("/^\/([a-z]+) ([0-9a-f]+) ([0-9a-f]+) (.*)/", $request, $res)) - if (preg_match("/^\/([a-z]+) ([0-9a-f]+) ([0-9a-f]+)( (.*)|)/", $request, $res)) + if (preg_match("/^\/([a-z0-9]+) ([0-9a-f]+) ([0-9a-f]+)( (.*)|)/", $request, $res)) { $rawcmd = isset($res[1]) ? $res[1] : ""; Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-25 11:45:57 UTC (rev 505) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-05-25 11:47:21 UTC (rev 506) @@ -14,8 +14,10 @@ this.nickname = '<?php echo $u->nick; ?>'; + /* this.channels = Array(); this.channelids = Array(); + */ this.privmsgs = Array(); this.privmsgids = Array(); @@ -203,6 +205,22 @@ else alert(cmd + "-"+resp+"-"+param); } + else if (cmd == "join2") + { + if (resp =="ok") + { + // create the new channel + var tabid = param[0]; + var name = param[1]; + this.gui.createTab(name, tabid, "ch"); + // do not switch to the new created tab + // keep it in the background + // this.gui.setTabById(tabid); + alert("ccc"); + } + else + alert(cmd + "-"+resp+"-"+param); + } else if (cmd == "leave") { //alert(cmd + "-"+resp+"-"+param); @@ -213,11 +231,13 @@ this.gui.removeTabById(tabid); // synchronize the channel client arrays + /* var index = -1; index = this.channelids.indexOf(tabid); this.channelids = this.channelids.without(tabid); this.channels = this.channels.without(this.channels[index]); - + */ + // synchronize the privmsg client arrays index = -1; index = this.privmsgids.indexOf(tabid); @@ -247,6 +267,28 @@ else alert(cmd + "-"+resp+"-"+param); } + else if (cmd == "privmsg2") + { + if (resp == "ok") + { + // create the new channel + var tabid = param[0]; + var name = param[1]; + this.gui.createTab(name, tabid, "pv"); + // do not switch to the new created tab + // keep it in the background + // this.gui.setTabById(tabid); + + this.privmsgs.push(name); + this.privmsgids.push(tabid); + } + else if (resp == "unknown") + { + // speak to unknown user + } + else + alert(cmd + "-"+resp+"-"+param); + } else if (cmd == "nick") { if (resp == "connected") @@ -286,8 +328,8 @@ var index = this.privmsgs.indexOf(param); if (index == -1) { - // it doesn't exists, create it - this.sendRequest('/privmsg', param); + // it doesn't exists, create it in the background + this.sendRequest('/privmsg2', param); } else { @@ -355,7 +397,7 @@ { var w = this.el_words; var wval = w.value; - re = new RegExp("^(\/[a-z]+)( (.*)|)"); + re = new RegExp("^(\/[a-z0-9]+)( (.*)|)"); if (wval.match(re)) { /* a user command */ @@ -607,7 +649,7 @@ { var recipientid = this.gui.getTabId(); var req = cmd+" "+this.clientid+" "+(recipientid==''?'0':recipientid)+(param?" "+param : ""); - // if (cmd != "/update") alert(req); + if (cmd != "/update") alert(req); return <?php echo $prefix; ?>handleRequest(req); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |