[Phpfreechat-svn] SF.net SVN: phpfreechat: [552] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-06-07 20:11:34
|
Revision: 552 Author: kerphi Date: 2006-06-06 10:21:08 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=552&view=rev Log Message: ----------- Bug fix: the "channels" parameter didn't work as expected Modified Paths: -------------- trunk/src/commands/init.class.php trunk/src/commands/rehash.class.php trunk/src/pfcglobalconfig.class.php trunk/src/pfcuserconfig.class.php trunk/themes/default/templates/pfcclient.js.tpl.php Modified: trunk/src/commands/init.class.php =================================================================== --- trunk/src/commands/init.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/commands/init.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -7,14 +7,12 @@ function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; - + $u =& $this->u; + $cmd =& pfcCommand::Factory("quit"); $cmd->run($xml_reponse, $clientid, $param, $sender, $recipient, $recipientid); - if (isset($_COOKIE[session_name()])) - { - setcookie(session_name(), '', time()-42000, '/'); - } // clobber the cookie + $u->destroy(); } } Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/commands/rehash.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -14,7 +14,8 @@ function run(&$xml_reponse, $clientid, $param, $sender, $recipient, $recipientid) { $c =& $this->c; - $synchro = $c->synchronizeWithCache(true); // true => destroy the cache + $c->destroy(); + $synchro = $c->synchronizeWithCache(); if ($synchro) $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '');"); Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/pfcglobalconfig.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -35,14 +35,12 @@ // these parameters are dynamic (not cached) var $nick = ""; // the initial nickname ("" means the user will be queried) var $isadmin = false; - var $channels = array(); // the default joined channels when opening the chat - var $privmsg = array(); // the default privmsg chat to lauch when opening the chat - var $active = false; // by default the user is not connected // these parameters are static (cached) var $proxys = array("auth"); var $title = ""; // default is _pfc("My Chat") - var $channel = ""; // default is _pfc("My room") + var $channels = array(); // the default joined channels when opening the chat + var $privmsg = array(); // the default privmsg chat to lauch when opening the chat var $frozen_nick = false; var $max_nick_len = 15; var $max_text_len = 400; @@ -182,12 +180,12 @@ if ($this->debug) pxlog("pfcGlobalConfig::init()", "chatconfig", $this->getId()); if ($this->title == "") $this->title = _pfc("My Chat"); - if ($this->channel == "") $this->channel = _pfc("My room"); if ($this->ie7path == "") $this->ie7path = dirname(__FILE__)."/../lib/IE7_0_9"; if ($this->xajaxpath == "") $this->xajaxpath = dirname(__FILE__)."/../lib/xajax_0.2.3"; if ($this->jspath == "") $this->jspath = dirname(__FILE__)."/../lib/javascript"; if ($this->csstidypath == "") $this->csstidypath = dirname(__FILE__)."/../lib/csstidy-1.1"; - + if (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"); $err_session_x = "You need PHP 4 or PHP 5"; @@ -374,23 +372,22 @@ function getId() { - /* channel is concatenated because it dynamic parameters - * further these parameter must be separated from global pfcconfig - * and can be changed dynamicaly in the user session */ return $this->serverid; } - + function destroy() + { + $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); + @unlink($cachefile); + } + /** * save the pfcConfig object into cache if it doesn't exists yet * else restore the old pfcConfig object */ - function synchronizeWithCache($destroy = false) + function synchronizeWithCache() { $cachefile = $this->data_private_path."/cache/pfcglobalconfig_".$this->getId(); - - // destroy the cache if init parameter is present into the url - if (isset($_GET["init"]) || $destroy) @unlink($cachefile); if (file_exists($cachefile)) { Modified: trunk/src/pfcuserconfig.class.php =================================================================== --- trunk/src/pfcuserconfig.class.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/src/pfcuserconfig.class.php 2006-06-06 17:21:08 UTC (rev 552) @@ -17,9 +17,10 @@ function pfcUserConfig() { + $c =& pfcGlobalConfig::Instance(); + // start the session : session is used for locking purpose and cache purpose session_name( "phpfreechat" ); - if (isset($_GET["init"])) unset($_COOKIE[session_name()]); if(session_id() == "") session_start(); // echo "pfcUserConfig()<br>"; @@ -28,7 +29,7 @@ // user parameters are cached in sessions $this->_getParam("nick"); - if (!isset($this->nick)) $this->_setParam("nick",""); + if (!isset($this->nick)) $this->_setParam("nick",$c->nick); $this->_getParam("active"); if (!isset($this->active)) $this->_setParam("active",false); $this->_getParam("channels"); @@ -46,8 +47,6 @@ $sessionid_param = $sessionid."_".$p; if (isset($_SESSION[$sessionid_param])) $this->$p = $_SESSION[$sessionid_param]; - else - $this->$p = $c->$p; // take the default parameter from the global config } return $this->$p; } @@ -60,6 +59,15 @@ $_SESSION[$sessionid_param] = $v; $this->$p = $v; } + + function _rmParam($p) + { + $c =& pfcGlobalConfig::Instance(); + $sessionid = "pfcuserconfig_".$c->getId(); + $sessionid_param = $sessionid."_".$p; + unset($_SESSION[$sessionid_param]); + unset($this->$p); + } function &Instance() { @@ -149,6 +157,14 @@ } } */ + + function destroy() + { + $this->_rmParam("nick"); + $this->_rmParam("active"); + $this->_rmParam("channels"); + $this->_rmParam("privmsg"); + } function saveInCache() { Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-06 17:19:21 UTC (rev 551) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-06-06 17:21:08 UTC (rev 552) @@ -162,7 +162,8 @@ // or the default one <?php if (count($u->channels) == 0) - echo "this.sendRequest('/join', '".addslashes($c->channel)."');\n"; + foreach($c->channels as $ch) + echo "this.sendRequest('/join', '".addslashes($ch)."');\n"; foreach($u->channels as $ch) echo "this.sendRequest('/join', '".addslashes($ch["name"])."');\n"; foreach($u->privmsg as $pv) @@ -306,7 +307,8 @@ // or the default one <?php if (count($u->channels) == 0) - echo "this.sendRequest('/join', '".addslashes($c->channel)."');\n"; + foreach($c->channels as $ch) + echo "this.sendRequest('/join', '".addslashes($ch)."');\n"; foreach($u->channels as $ch) echo "this.sendRequest('/join', '".addslashes($ch["name"])."');\n"; foreach($u->privmsg as $pv) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |