[Phpfreechat-svn] SF.net SVN: phpfreechat: [778] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-21 08:41:02
|
Revision: 778 http://svn.sourceforge.net/phpfreechat/?rev=778&view=rev Author: kerphi Date: 2006-09-21 01:40:39 -0700 (Thu, 21 Sep 2006) Log Message: ----------- [en] New parameters: 'max_channels' used to limit the number of channels tabs, 'max_privmsg' used to limit the number of private messages tabs (sponsored by Johnny Philavanh : 0 USD). [fr] Nouveaux parametres: 'max_channels' permet de limiter le nombre de channel qu'un utilisateur peut creer, 'max_privmsg' permet de limiter le nombre de messages prives par utilisateur (sponsorise par Johnny Philavanh : 0 USD) Modified Paths: -------------- trunk/demo/demo2_simple_with_params.php trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/commands/join.class.php trunk/src/commands/privmsg.class.php trunk/src/pfcglobalconfig.class.php Modified: trunk/demo/demo2_simple_with_params.php =================================================================== --- trunk/demo/demo2_simple_with_params.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/demo/demo2_simple_with_params.php 2006-09-21 08:40:39 UTC (rev 778) @@ -10,7 +10,9 @@ $params["shownotice"] = 0; // 0 = nothing, 1 = just nickname changes, 2 = connect/quit, 3 = nick + connect/quit $params["max_nick_len"] = 20; // nickname length could not be longer than 10 caracteres $params["max_text_len"] = 300; // a message cannot be longer than 50 caracteres -$params["refresh_delay"] = 10000; // chat refresh speed is 10 secondes (10000ms) +$params["max_channels"] = 3; // limit the number of joined channels tab to 3 +$params["max_privmsg"] = 1; // limit the number of private message tab to 1 +$params["refresh_delay"] = 10000; // chat refresh speed is 10 secondes (10000ms) $params["max_msg"] = 15; // max message in the history is 15 (message seen when reloading the chat) $params["height"] = "230px"; // height of chat area is 230px $params["width"] = "800px"; // width of chat area is 800px Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/client/chat.js.tpl.php 2006-09-21 08:40:39 UTC (rev 778) @@ -82,6 +82,8 @@ "A problem occurs during rehash", // _pfc "Choosen nickname is allready used", // _pfc "phpfreechat current version is %s", // _pfc + "Maximum number of joined channels has been reached", // _pfc + "Maximum number of private chat has been reached", // _pfc ); foreach($labels_to_load as $l) { Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/client/pfcclient.js 2006-09-21 08:40:39 UTC (rev 778) @@ -168,7 +168,7 @@ this.refresh_loginlogout(); } } - else if (cmd == "join") + else if (cmd == "join" || cmd == "join2") { if (resp =="ok") { @@ -176,29 +176,13 @@ var tabid = param[0]; var name = param[1]; this.gui.createTab(name, tabid, "ch"); - this.gui.setTabById(tabid); - /* - this.channels.push(name); - this.channelids.push(tabid); - */ + if (cmd != "join2") this.gui.setTabById(tabid); this.refresh_Smileys(); this.refresh_WhosOnline(); } - else - alert(cmd + "-"+resp+"-"+param); - } - else if (cmd == "join2") - { - if (resp =="ok") + else if (resp == "max_channels") { - // 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); - this.refresh_WhosOnline(); + this.displayMsg( cmd, this.res.getLabel('Maximum number of joined channels has been reached') ); } else alert(cmd + "-"+resp+"-"+param); @@ -228,7 +212,7 @@ } } - else if (cmd == "privmsg") + else if (cmd == "privmsg" || cmd == "privmsg2") { if (resp == "ok") { @@ -236,34 +220,16 @@ var tabid = param[0]; var name = param[1]; this.gui.createTab(name, tabid, "pv"); - this.gui.setTabById(tabid); + if (cmd != "privmsg2") this.gui.setTabById(tabid); this.privmsgs.push(name); this.privmsgids.push(tabid); } - else if (resp == "unknown") + else if (resp == "max_privmsg") { - // speak to unknown user + this.displayMsg( cmd, this.res.getLabel('Maximum number of private chat has been reached') ); } - 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 Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/commands/join.class.php 2006-09-21 08:40:39 UTC (rev 778) @@ -33,29 +33,31 @@ if(!isset($u->channels[$chanid])) { + if ($c->max_channels <= count($u->channels)) + { + // the maximum number of joined channels has been reached + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'max_channels', Array());"); + return; + } + $u->channels[$chanid]["recipient"] = $chanrecip; $u->channels[$chanid]["name"] = $channame; $u->saveInCache(); - + // clear the cached nicknames list for the given channel $nicklist_sid = "pfc_nicklist_".$c->getId()."_".$clientid."_".$chanid; $_SESSION[$nicklist_sid] = NULL; + + // show a join message + $cmdp = $p; + $cmdp["param"] = _pfc("%s joins %s",$u->nick, $channame); + $cmdp["recipient"] = $chanrecip; + $cmdp["recipientid"] = $chanid; + $cmdp["flag"] = 2; + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $cmdp); } - // show a join message - $cmdp = $p; - $cmdp["param"] = _pfc("%s joins %s",$u->nick, $channame); - $cmdp["recipient"] = $chanrecip; - $cmdp["recipientid"] = $chanid; - $cmdp["flag"] = 2; - $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $cmdp); - - - //$xml_reponse->addScript("alert('join: chan=".$channame.", from_id=".$from_id."');"); - // $xml_reponse->addScript("alert('join: u->nick=".$u->nick." chanid=".$chanid." channame=".addslashes($channame)."');"); - // $xml_reponse->addScript("alert('join: fromidsid=".$from_id_sid."');"); - // return ok to the client // then the client will create a new tab $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); Modified: trunk/src/commands/privmsg.class.php =================================================================== --- trunk/src/commands/privmsg.class.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/commands/privmsg.class.php 2006-09-21 08:40:39 UTC (rev 778) @@ -61,6 +61,13 @@ // in the sessions if (!isset($u->privmsg[$pvrecipientid])) { + if ($c->max_privmsg <= count($u->privmsg)) + { + // the maximum number of private messages has been reached + $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'max_privmsg', Array());"); + return; + } + $u->privmsg[$pvrecipientid]["recipient"] = $pvrecipient; $u->privmsg[$pvrecipientid]["name"] = $pvname; $u->privmsg[$pvrecipientid]["pvnickid"] = $pvnickid; Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-09-20 20:24:30 UTC (rev 777) +++ trunk/src/pfcglobalconfig.class.php 2006-09-21 08:40:39 UTC (rev 778) @@ -53,6 +53,8 @@ var $title = ""; // default is _pfc("My Chat") 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 $max_privmsg = 5; // this the max number of allowed privmsg by users var $frozen_nick = false; var $max_nick_len = 15; var $max_text_len = 400; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |