[Phpfreechat-svn] SF.net SVN: phpfreechat: [793] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-24 20:08:57
|
Revision: 793 http://svn.sourceforge.net/phpfreechat/?rev=793&view=rev Author: kerphi Date: 2006-09-24 13:08:47 -0700 (Sun, 24 Sep 2006) Log Message: ----------- [en] New 'privmsg' parameter: this is an array of nicknames that you want to speak to (in a private chat) at first chat loading (thanks to Johnny Philavanh for his sponsoring : $130 USD) [3h00] [fr] Nouveau param?\195?\168tre 'privmsg' : c'est un tableau destin?\195?\169 ?\195?\160 contenir une liste de pseudonyme avec lesquels on souhaite ouvrir une fen?\195?\170tre de discussion au premier demarrage du chat (merci ?\195?\160 Johnny Philavanh pour sa donation de $130 USD). [3h00] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/commands/privmsg.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/client/chat.js.tpl.php 2006-09-24 20:08:47 UTC (rev 793) @@ -1,4 +1,6 @@ +<?php function quoteandescape($v) { return "'".addslashes($v)."'"; } ?> <?php $nick = $u->nick != "" ? addslashes($u->nick) : addslashes($c->nick); ?> + var pfc_nickname = '<?php echo ($GLOBALS["output_encoding"]=="UTF-8" ? $nick : iconv("UTF-8", $GLOBALS["output_encoding"],$nick)); ?>'; var pfc_version = '<?php echo $version; ?>'; var pfc_clientid = '<?php echo md5(uniqid(rand(), true)); ?>'; @@ -18,18 +20,22 @@ var pfc_connect_at_startup = <?php echo $connect_at_startup ? "true" : "false"; ?>; var pfc_notify_window = <?php echo $notify_window ? "true" : "false"; ?>; var pfc_defaultchan = Array(<?php - function quoteandescape($v) { return "'".addslashes($v)."'"; } - $list = array(); foreach($c->channels as $ch) {$list[] = $ch; } + $list = array(); foreach($c->channels as $item) {$list[] = $item; } $list = array_map("quoteandescape",$list); echo implode(",", $list); ?>); var pfc_userchan = Array(<?php - $list = array(); foreach($u->channels as $ch) {$list[] = $ch["name"];} + $list = array(); foreach($u->channels as $item) {$list[] = $item["name"];} $list = array_map("quoteandescape",$list); echo implode(",", $list); ?>); -var pfc_privmsg = Array(<?php - $list = array(); foreach($u->privmsg as $pv) {$list[] = $pv["name"];} +var pfc_defaultprivmsg = Array(<?php + $list = array(); foreach($c->privmsg as $item) {$list[] = $item; } + $list = array_map("quoteandescape",$list); + echo implode(",", $list); + ?>); +var pfc_userprivmsg = Array(<?php + $list = array(); foreach($u->privmsg as $item) {$list[] = $item["name"];} $list = array_map("quoteandescape",$list); echo implode(",", $list); ?>); @@ -86,6 +92,7 @@ "Maximum number of private chat has been reached", // _pfc "Click here to send your message", // _pfc "Send", // _pfc + "You are not allowed to speak to yourself", // _pfc ); foreach($labels_to_load as $l) { Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/client/pfcclient.js 2006-09-24 20:08:47 UTC (rev 793) @@ -234,6 +234,10 @@ { // speak to unknown user } + else if (resp == "speak_to_myself") + { + this.displayMsg( cmd, this.res.getLabel('You are not allowed to speak to yourself') ); + } else alert(cmd + "-"+resp+"-"+param); } @@ -241,20 +245,18 @@ { if (resp == "connected" || resp == "notchanged") { - // now join channels comming from sessions - // or the default one cmd = ''; - if (pfc_userchan.length == 0) + + // join the default channels comming from the parameter list + for (var i=0; i<pfc_defaultchan.length; i++) { - for (var i=0; i<pfc_defaultchan.length; i++) - { - if (i<pfc_defaultchan.length-1) - cmd = "/join2"; - else - cmd = "/join"; - this.sendRequest(cmd, pfc_defaultchan[i]); - } + if (i<pfc_defaultchan.length-1) + cmd = "/join2"; + else + cmd = "/join"; + this.sendRequest(cmd, pfc_defaultchan[i]); } + // now join channels comming from sessions for (var i=0; i<pfc_userchan.length; i++) { if (i<pfc_userchan.length-1) @@ -263,10 +265,21 @@ cmd = "/join"; this.sendRequest(cmd, pfc_userchan[i]); } - for (var i=0; i<pfc_privmsg.length; i++) + + // join the default privmsg comming from the parameter list + for (var i=0; i<pfc_defaultprivmsg.length; i++) { - this.sendRequest("/privmsg", pfc_privmsg[i]); + if (i<pfc_defaultprivmsg.length-1) + cmd = "/privmsg2"; + else + cmd = "/privmsg"; + this.sendRequest(cmd, pfc_defaultprivmsg[i]); } + // now join privmsg comming from the sessions + for (var i=0; i<pfc_userprivmsg.length; i++) + { + this.sendRequest("/privmsg", pfc_userprivmsg[i]); + } } if (resp == "ok" || resp == "notchanged" || resp == "changed" || resp == "connected") Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/commands/privmsg.class.php 2006-09-24 20:08:47 UTC (rev 793) @@ -25,7 +25,7 @@ // error: can't speak to myself if ($pvnickid == $nickid) { - $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', Array('".addslashes($pvname)."','speak to myself'));"); + $xml_reponse->addScript("pfc.handleResponse('".$this->name."','speak_to_myself');"); return; } Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-23 15:49:00 UTC (rev 792) +++ trunk/src/pfcglobalconfig.class.php 2006-09-24 20:08:47 UTC (rev 793) @@ -54,8 +54,9 @@ var $channels = array(); // the default joined channels when opening the chat var $frozen_channels = array(); // if empty, allows users to create there own channels var $max_channels = 10; // this the max number of allowed channels by users + var $privmsg = array(); // the joined private chat when opening the chat (the nicknames must be online) var $max_privmsg = 5; // this the max number of allowed privmsg by users - var $frozen_nick = false; + var $frozen_nick = false; // set it to true if you don't want the user to be able to change his nickname var $max_nick_len = 15; var $max_text_len = 400; var $refresh_delay = 5000; // in mili-seconds (5 seconds) @@ -111,7 +112,7 @@ // private parameters var $_sys_proxies = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log"); var $_proxies = array(); // will contains proxies to execute on each command (filled in the init step) - var $_dyn_params = array("nick","isadmin","islocked","admins","frozen_channels"); + var $_dyn_params = array("nick","isadmin","islocked","admins","frozen_channels", "channels", "privmsg"); var $_params_type = array(); function pfcGlobalConfig( $params = array() ) @@ -184,6 +185,12 @@ if (isset($params[$dp])) $this->$dp = $params[$dp]; + // 'channels' is now a dynamic parameter, just check if I need to initialize it or not + if (is_array($this->channels) && + count($this->channels) == 0 && + !isset($params['channels'])) + $this->channels = array(_pfc("My room")); + // now load or save the configuration in the cache $this->synchronizeWithCache(); } @@ -274,7 +281,6 @@ if ($this->title == "") $this->title = _pfc("My Chat"); if ($this->xajaxpath == "") $this->xajaxpath = dirname(__FILE__)."/../lib/xajax_0.2.3"; if ($this->jspath == "") $this->jspath = dirname(__FILE__)."/../lib/javascript"; - if (is_array($this->channels) && count($this->channels) == 0) $this->channels = array(_pfc("My room")); // first of all, check the used functions $f_list["file_get_contents"] = _pfc("You need %s", "PHP 4 >= 4.3.0 or PHP 5"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |