unified feedback v1
This commit is contained in:
@@ -63,6 +63,7 @@ class Databap extends PhpObject
|
||||
const SUCCESS = '__SUCCESS__';
|
||||
const DISCONNECTED = '__DISCONNECTED__';
|
||||
const NOT_FOUND = '__NOT_FOUND__';
|
||||
const NOT_AUTH = '__NOT_AUTHORIZED__';
|
||||
const FAIL_INSERT = '__FAIL_INSERT__';
|
||||
const FAIL_UPDATE = '__FAIL_UPDATE__';
|
||||
const FAIL_DELETE = '__FAIL_DELETE__';
|
||||
@@ -380,7 +381,12 @@ class Databap extends PhpObject
|
||||
'version_date'=>self::VERSION_DATE,
|
||||
'default_page'=>$sPage,
|
||||
'default_id'=>$oItemId,
|
||||
'errors'=>array('disconnected'=>self::DISCONNECTED, 'not_found'=>self::NOT_FOUND, 'insert'=>self::FAIL_INSERT, 'update'=>self::FAIL_UPDATE, 'delete'=>self::FAIL_DELETE),
|
||||
'errors'=>array('disconnected'=>self::DISCONNECTED,
|
||||
'not_authorized'=>self::NOT_AUTH,
|
||||
'not_found'=>self::NOT_FOUND,
|
||||
'insert'=>self::FAIL_INSERT,
|
||||
'update'=>self::FAIL_UPDATE,
|
||||
'delete'=>self::FAIL_DELETE),
|
||||
'success'=>self::SUCCESS,
|
||||
'error'=>self::ERROR,
|
||||
'keep_alive'=>self::KEEP_ALIVE,
|
||||
@@ -1416,14 +1422,16 @@ class Databap extends PhpObject
|
||||
$iCompChan = array_search($sChanSafeName, array_map(array('self', 'getChanSafeName'), $asCompanies));
|
||||
$asPm = $this->isPmChan($sChanSafeName);
|
||||
|
||||
return $sChanSafeName!='' && //Empty channel name
|
||||
return $sChanSafeName!='' && //Empty channel name
|
||||
($iCompChan===false || $asUserInfo['company']==self::getCompanyFormat($asCompanies[$iCompChan])) && //Test Company Channel
|
||||
(!$asPm['is_pm'] || $iUserId==$asPm['from'] || $iUserId==$asPm['to']); //Test PM
|
||||
}
|
||||
|
||||
public function joinChan($sChanName, $bFirstConn=false, $asAttendees=array())
|
||||
{
|
||||
$asResult = array('success'=>self::ERROR);
|
||||
$bSuccess = false;
|
||||
$sDesc = '';
|
||||
$asVars = array();
|
||||
$sSafeChanName = self::getChanSafeName($sChanName);
|
||||
|
||||
//Authorization to join channel
|
||||
@@ -1457,21 +1465,21 @@ class Databap extends PhpObject
|
||||
//Is user already connected to this chan
|
||||
$bConnectedUser = $this->isUserConnected($iChanId);
|
||||
$iConnId = $this->oMySql->insertUpdateRow(self::CONN_TABLE, array($sUserIdCol=>$this->getUserId(), $sChanIdCol=>$iChanId), array($sUserIdCol, $sChanIdCol), false);
|
||||
if($iConnId>0) $asResult['success'] = self::SUCCESS;
|
||||
if($iConnId>0) $bSuccess = true;
|
||||
|
||||
if($asResult['success']==self::SUCCESS)
|
||||
if($bSuccess)
|
||||
{
|
||||
//Return connected channels
|
||||
$asResult['channels'] = $this->getChannels($this->getUserId());
|
||||
$asVars['channels'] = $this->getChannels($this->getUserId());
|
||||
|
||||
//Add tab title (customized)
|
||||
//FIXME delete this shit and insert the channel type into channels DB table
|
||||
foreach($asResult['channels'] as $iConnectedChanId=>$sConnectedChanName)
|
||||
foreach($asVars['channels'] as $iConnectedChanId=>$sConnectedChanName)
|
||||
{
|
||||
$asPm = $this->isPmChan($sConnectedChanName);
|
||||
$asResult['channel_tab_names'][$iConnectedChanId] = $asPm['is_pm']?$this->getChatNickNames($asPm['from']==$this->getUserId()?$asPm['to']:$asPm['from']):$sConnectedChanName;
|
||||
$asVars['channel_tab_names'][$iConnectedChanId] = $asPm['is_pm']?$this->getChatNickNames($asPm['from']==$this->getUserId()?$asPm['to']:$asPm['from']):$sConnectedChanName;
|
||||
}
|
||||
$asResult['current_chan_id'] = $iChanId;
|
||||
$asVars['current_chan_id'] = $iChanId;
|
||||
|
||||
//Communicate on user's connection
|
||||
if(!$bConnectedUser)
|
||||
@@ -1502,9 +1510,11 @@ class Databap extends PhpObject
|
||||
//Update chan leds
|
||||
$this->pingChans();
|
||||
}
|
||||
else $sDesc = self::FAIL_UPDATE;
|
||||
}
|
||||
else $sDesc = 'Nom de chan non autorisé (nom de personne / nom de société interdit)';
|
||||
|
||||
return self::jsonExport($asResult);
|
||||
return self::getJsonPostResult($bSuccess, $sDesc, $asVars);
|
||||
}
|
||||
|
||||
private function isUserConnected($iChanId=0, $iUserId=0)
|
||||
|
||||
Reference in New Issue
Block a user