disconnect chat en page switch / tab closed

This commit is contained in:
2013-10-06 10:49:26 +02:00
parent 89970f9fe0
commit 7179edae80
2 changed files with 29 additions and 18 deletions

View File

@@ -1185,7 +1185,7 @@ class Databap extends PhpObject
$asHistory = $this->oMySql->selectRows($asInfo);
foreach($asHistory as $asCode)
{
$asProfile['history'][$asCode['id_code']]['action'] = (($asCode['refer_id']==$asCode['id_code'])?'Création':'Modification').' de code';
$asProfile['history'][$asCode['id_code']]['action'] = (($asCode['refer_id']==$asCode['id_code'])?'Création':'Modification').' de code';
$asProfile['history'][$asCode['id_code']]['date'] = self::getDateFormat($asCode['led']);
$asProfile['history'][$asCode['id_code']]['description'] = $asCode['description'];
$asProfile['history'][$asCode['id_code']]['phrase'] = ($asCode['phrase']=='')?$asCode['id_code']:$asCode['phrase'];
@@ -1326,7 +1326,6 @@ class Databap extends PhpObject
$asInfo['constraint'][MySqlManager::getId(MySqlManager::CHAN_TABLE)] = $iChanId;
$asInfo['constOpe'][MySqlManager::getId(MySqlManager::CHAN_TABLE)] = '=';
}
//$this->oMySql->bTrace = true;
return (count($this->oMySql->selectRows($asInfo))>0);
}
@@ -2152,11 +2151,16 @@ class Databap extends PhpObject
public function disconnectChat()
{
//$this->getConnectedChans();
$sTime = $this->oMySql->selectRows(array('select'=>'DATE_SUB(NOW(), INTERVAL '.self::KEEP_ALIVE.' SECOND)'));
$this->oMySql->updateRows(MySqlManager::CONN_TABLE, array(MySqlManager::getId(MySqlManager::USER_TABLE)=>$this->getUserId()), array('led'=>$sTime));
$this->addMessage('se déconnecte', self::MESSAGE_CONN, self::ALL_CHAN_ID);
//Is the user connected?
$sUserIdColName = MySqlManager::getId(MySqlManager::USER_TABLE);
$bConnected = $this->oMySql->selectRows(array('select'=>array('COUNT(1)'), 'from'=>MySqlManager::CONN_TABLE, 'constraint'=>array($sUserIdColName=>$this->getUserId(), 'led'=>$sTime), 'constOpe'=>array($sUserIdColName=>'=', 'led'=>'>')));
if($bConnected)
{
$this->oMySql->updateRows(MySqlManager::CONN_TABLE, array(MySqlManager::getId(MySqlManager::USER_TABLE)=>$this->getUserId()), array('led'=>$sTime));
$this->addMessage('se déconnecte', self::MESSAGE_CONN, self::ALL_CHAN_ID);
}
}
public function checkValue($sTableName, $asConstraints)