[Phpfreechat-svn] SF.net SVN: phpfreechat: [1005] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-03-20 19:28:14
|
Revision: 1005 http://svn.sourceforge.net/phpfreechat/?rev=1005&view=rev Author: kerphi Date: 2007-03-20 10:28:34 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Work in progresse : fix the "You must be connected to send a message" [3h00] Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/nick.class.php trunk/src/commands/update.class.php trunk/src/proxies/auth.class.php trunk/src/proxies/checktimeout.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2007-03-20 08:51:29 UTC (rev 1004) +++ trunk/src/commands/connect.class.php 2007-03-20 17:28:34 UTC (rev 1005) @@ -13,6 +13,7 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; $getoldmsg = isset($p["getoldmsg"]) ? $p["getoldmsg"] : true; + $joinoldchan = isset($p["joinoldchan"]) ? $p["joinoldchan"] : true; // nickname must be given to be able to connect to the chat $nick = $params[0]; @@ -24,43 +25,7 @@ // reset the message id indicator (see getnewmsg.class.php) // i.e. be ready to re-get all last posted messages if ($getoldmsg) - { - // reset the channel identifiers - require_once(dirname(__FILE__)."/join.class.php"); - $channels = array(); - if (count($u->channels) == 0) - $channels = $c->channels; - else - foreach($u->channels as $chan) - $channels[] = $chan["name"]; - foreach($channels as $channame) - { - $chanrecip = pfcCommand_join::GetRecipient($channame); - $chanid = pfcCommand_join::GetRecipientId($channame); - // reset the fromid flag - $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$chanid; - $from_id = $ct->getLastId($chanrecip)-$c->max_msg; - $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; - // reset the oldmsg flag - $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; - $_SESSION[$oldmsg_sid] = true; - } - // reset the private messages identifiers - if (count($u->privmsg) > 0) - { - foreach($u->privmsg as $recipientid2 => $pv) - { - $recipient2 = $pv['recipient']; - // reset the fromid flag - $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$recipientid2; - $from_id = $ct->getLastId($recipient2)-$c->max_msg; - $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; - // reset the oldmsg flag - $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$recipientid2; - $_SESSION[$oldmsg_sid] = true; - } - } - } + $this->_resetChannelIdentifier($clientid); // check if the user is alone on the server, and give it the admin status if yes $isadmin = $ct->getUserMeta($u->nickid, 'isadmin'); @@ -102,6 +67,10 @@ if ($ret) { + // @todo join the channels if $joinoldchan is true (see /update command code) + // @todo remove the /join client side in pfcclient.js.php + + $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', Array('".addslashes($nick)."'));"); } else @@ -109,6 +78,53 @@ $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ko', Array('".addslashes($nick)."'));"); } } + + /** + * reset the channel identifiers + */ + function _resetChannelIdentifier($clientid) + { + $c =& pfcGlobalConfig::Instance(); + $u =& pfcUserConfig::Instance(); + $ct =& pfcContainer::Instance(); + + // reset the channel identifiers + require_once(dirname(__FILE__)."/join.class.php"); + $channels = array(); + if (count($u->channels) == 0) + $channels = $c->channels; + else + foreach($u->channels as $chan) + $channels[] = $chan["name"]; + foreach($channels as $channame) + { + $chanrecip = pfcCommand_join::GetRecipient($channame); + $chanid = pfcCommand_join::GetRecipientId($channame); + // reset the fromid flag + $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$chanid; + $from_id = $ct->getLastId($chanrecip)-$c->max_msg; + $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; + // reset the oldmsg flag + $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; + $_SESSION[$oldmsg_sid] = true; + } + // reset the private messages identifiers + if (count($u->privmsg) > 0) + { + foreach($u->privmsg as $recipientid2 => $pv) + { + $recipient2 = $pv['recipient']; + // reset the fromid flag + $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$recipientid2; + $from_id = $ct->getLastId($recipient2)-$c->max_msg; + $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; + // reset the oldmsg flag + $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$recipientid2; + $_SESSION[$oldmsg_sid] = true; + } + } + } + } ?> \ No newline at end of file Modified: trunk/src/commands/nick.class.php =================================================================== --- trunk/src/commands/nick.class.php 2007-03-20 08:51:29 UTC (rev 1004) +++ trunk/src/commands/nick.class.php 2007-03-20 17:28:34 UTC (rev 1005) @@ -77,7 +77,7 @@ { // this is a first connection : create the nickname on the server $ct->createNick($u->nickid, $newnick); - $u->nick = $nick; + $u->nick = $newnick; $u->saveInCache(); $this->forceWhoisReload($u->nickid); Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2007-03-20 08:51:29 UTC (rev 1004) +++ trunk/src/commands/update.class.php 2007-03-20 17:28:34 UTC (rev 1005) @@ -14,21 +14,22 @@ $c =& pfcGlobalConfig::Instance(); $u =& pfcUserConfig::Instance(); + + // check the user has not been disconnected from the server by timeout + // if he has been disconnected, then I reconnect him with /connect command + if ($u->nick != '' && !$u->isOnline()) + { + $cmd =& pfcCommand::Factory("connect"); + $cmdp = $p; + $cmdp['params'] = array($u->nick); + $cmdp['getoldmsg'] = false; + $cmdp['joinoldchan'] = false; + $cmd->run($xml_reponse, $cmdp); + } // do not update if user isn't active (didn't connect) if ($u->isOnline()) { - // check the user has not been disconnected from the server by timeout - // if I found he has been disconnected, then I reconnect him with /connect command - $ct =& pfcContainer::Instance(); - if ($ct->isNickOnline(NULL, $u->nickid) < 0) - { - $cmd =& pfcCommand::Factory("connect"); - $cmdp = $p; - $cmdp["getoldmsg"] = false; - $cmd->run($xml_reponse, $cmdp); - } - $cmdp = $p; // update the user nickname timestamp on the server @@ -72,7 +73,9 @@ $xml_reponse->script("pfc.handleResponse('update', 'ok', '');"); } else + { $xml_reponse->script("pfc.handleResponse('update', 'ko', '');"); + } } } Modified: trunk/src/proxies/auth.class.php =================================================================== --- trunk/src/proxies/auth.class.php 2007-03-20 08:51:29 UTC (rev 1004) +++ trunk/src/proxies/auth.class.php 2007-03-20 17:28:34 UTC (rev 1005) @@ -45,6 +45,7 @@ // do not allow someone to run a command if he is not online if ($this->name != 'error' && $this->name != 'connect' && + $this->name != 'update' && !$u->isOnline()) { $cmdp = $p; Modified: trunk/src/proxies/checktimeout.class.php =================================================================== --- trunk/src/proxies/checktimeout.class.php 2007-03-20 08:51:29 UTC (rev 1004) +++ trunk/src/proxies/checktimeout.class.php 2007-03-20 17:28:34 UTC (rev 1005) @@ -39,7 +39,7 @@ $recipient = $p["recipient"]; $recipientid = $p["recipientid"]; - if ($this->name == 'update') + if ($this->name == 'update' || $this->name == 'connect') { $c =& pfcGlobalConfig::Instance(); $u =& pfcUserConfig::Instance(); @@ -53,17 +53,19 @@ for($j=0; $j<count($disconnected_users["channels"][$i]); $j++) { $chan = $disconnected_users["channels"][$i][$j]; - $online_users = $ct->getOnlineNick($chan); - if ($chan != 'SERVER' && - count($online_users['nickid'])) + if ($chan != 'SERVER') { - $cmdp = $p; - $cmdp["param"] = _pfc("%s quit (timeout)", $nick); - $cmdp["flag"] = 2; - $cmdp["recipient"] = $chan; - $cmdp["recipientid"] = md5($chan); // @todo: clean the recipient/recipientid notion - $cmd =& pfcCommand::Factory("notice"); - $cmd->run($xml_reponse, $cmdp); + $online_users = $ct->getOnlineNick($chan); + if (count($online_users['nickid']) > 0) + { + $cmdp = $p; + $cmdp["param"] = _pfc("%s quit (timeout)", $nick); + $cmdp["flag"] = 2; + $cmdp["recipient"] = $chan; + $cmdp["recipientid"] = md5($chan); // @todo: clean the recipient/recipientid notion + $cmd =& pfcCommand::Factory("notice"); + $cmd->run($xml_reponse, $cmdp); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |