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)
|
||||
|
||||
35
jquery/databap.js
vendored
35
jquery/databap.js
vendored
@@ -339,7 +339,7 @@ function Databap()
|
||||
{
|
||||
//Add page Header
|
||||
self.$title
|
||||
.find('.h1_wrap').attr('id', self.vars.current_page+'_title')
|
||||
.find('.side_margins').attr('id', self.vars.current_page+'_title')
|
||||
.find('#title_text').text(self.vars.page_titles[self.vars.current_page]);
|
||||
self.$title.fadeTo(self.consts.transTime, 1);
|
||||
self.vars.pageIcon = 'fa-c-'+self.vars.current_page;
|
||||
@@ -360,11 +360,11 @@ function Databap()
|
||||
|
||||
this.pageIcon = function(pageIcon, comment)
|
||||
{
|
||||
var $Header = $('#'+self.vars.current_page+'_title');
|
||||
$Header.find('i')
|
||||
.attr('class', 'fa fa-fw fa-20')
|
||||
.addClass(pageIcon);
|
||||
$Header.find('h1').attr('title', comment || '');
|
||||
self.$title
|
||||
.find('h1').attr('title', comment || '')
|
||||
.find('#page_icon')
|
||||
.attr('class', 'fa fa-fw fa-20')
|
||||
.addClass(pageIcon);
|
||||
};
|
||||
|
||||
this.addBufferIcon = function()
|
||||
@@ -432,7 +432,8 @@ function Databap()
|
||||
this.saveForm = function(action, $form, fOnSuccess, bProcessIcon, dataType)
|
||||
{
|
||||
var sFormVars = $form.serialize();
|
||||
if(typeof bProcessIcon != 'undefined') self.addBufferIcon();
|
||||
bProcessIcon = bProcessIcon || false;
|
||||
if(bProcessIcon) self.addBufferIcon();
|
||||
if(!dataType) dataType = 'text';
|
||||
|
||||
self.vars.loading = true;
|
||||
@@ -446,7 +447,7 @@ function Databap()
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = false;
|
||||
if(typeof bProcessIcon != 'undefined') self.resetIcon();
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(result);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
@@ -465,7 +466,8 @@ function Databap()
|
||||
{
|
||||
if(!vars) vars = {};
|
||||
if(!type) type = 'html';
|
||||
if(typeof bProcessIcon != 'undefined') self.addBufferIcon();
|
||||
bProcessIcon = bProcessIcon || false;
|
||||
if(bProcessIcon) self.addBufferIcon();
|
||||
|
||||
vars['a'] = action;
|
||||
self.vars.loading = true;
|
||||
@@ -482,7 +484,7 @@ function Databap()
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = false;
|
||||
if(typeof bProcessIcon != 'undefined') self.resetIcon();
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(result);
|
||||
}
|
||||
},
|
||||
@@ -493,7 +495,7 @@ function Databap()
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = true;
|
||||
debug('Error databap.js 361');
|
||||
if(typeof bProcessIcon != 'undefined') self.resetIcon();
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
if(!fOnError)
|
||||
{
|
||||
self.showError(textStatus);
|
||||
@@ -846,6 +848,17 @@ function Databap()
|
||||
$msg.hide().insertBefore(elem).slideDown('fast', function(){databap.updateScrollBar('bottom');}).delay(5000).slideUp('fast', function(){$(this).remove();databap.updateScrollBar();});
|
||||
};
|
||||
|
||||
this.feedback = function(sClass, sMsg)
|
||||
{
|
||||
$('<span>', {'class':'feedback '+sClass})
|
||||
.append($('<i>', {'class':'fa fa-inline'}))
|
||||
.append(self.addPunctuation(sMsg))
|
||||
.appendTo('#title_feedback')
|
||||
.slideDown('fast')
|
||||
.delay(5000)
|
||||
.slideUp('fast', function(){$(this).remove();});
|
||||
};
|
||||
|
||||
this.setTitle = function(extra)
|
||||
{
|
||||
if(!extra)
|
||||
|
||||
@@ -319,25 +319,33 @@ function joinChan(sChanName, bFirstConn, asAttendees, bSwitchOnJoin)
|
||||
databap.getInfo
|
||||
(
|
||||
'join_chan',
|
||||
function(result)
|
||||
function(data)
|
||||
{
|
||||
//Add to channels list
|
||||
var sConnectedChanKeyName = '';
|
||||
$.each
|
||||
(
|
||||
result.channels,
|
||||
function(iChanId, sReturnedChanName)
|
||||
{
|
||||
//Add tab if not already there
|
||||
if(!getChanName(iChanId)) addChanTab(iChanId, sReturnedChanName, result.channel_tab_names[iChanId], !bSwitchOnJoin);
|
||||
}
|
||||
);
|
||||
|
||||
//Full reload of messages
|
||||
refresh_chat(true);
|
||||
|
||||
//Switch to the right chan
|
||||
switchChan(bSwitchOnJoin?result.current_chan_id:null);
|
||||
debug(data);
|
||||
if(data.result == databap.consts.error)
|
||||
{
|
||||
databap.feedback('error', data.desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add to channels list
|
||||
var sConnectedChanKeyName = '';
|
||||
$.each
|
||||
(
|
||||
data.channels,
|
||||
function(iChanId, sReturnedChanName)
|
||||
{
|
||||
//Add tab if not already there
|
||||
if(!getChanName(iChanId)) addChanTab(iChanId, sReturnedChanName, data.channel_tab_names[iChanId], !bSwitchOnJoin);
|
||||
}
|
||||
);
|
||||
|
||||
//Full reload of messages
|
||||
refresh_chat(true);
|
||||
|
||||
//Switch to the right chan
|
||||
switchChan(bSwitchOnJoin?data.current_chan_id:null);
|
||||
}
|
||||
},
|
||||
{chan:sChanName, first_conn:(bFirstConn?1:0), attendees:asAttendees},
|
||||
'json',
|
||||
@@ -638,7 +646,6 @@ function refresh_chat(bReset)
|
||||
{
|
||||
var prevLastMsgId = self.tmp('last_message_id');;
|
||||
updateUsersList = false;
|
||||
databap.resetIcon();
|
||||
if(prevLastMsgId < result.last_message_id || bReset)
|
||||
{
|
||||
//Update last read message id
|
||||
|
||||
@@ -62,10 +62,11 @@
|
||||
</div>
|
||||
<div id="main_container" class="round">
|
||||
<div id="page_title">
|
||||
<div class="h1_wrap side_margins">
|
||||
<div class="side_margins">
|
||||
<h1 class="round">
|
||||
<i class="fa fa-fw fa-20 fa-c-loading fa-spin"></i>
|
||||
<i id="page_icon" class="fa fa-fw fa-20 fa-c-loading fa-spin"></i>
|
||||
<span id="title_text">Chargement...</span>
|
||||
<span id="title_feedback"></span>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -301,19 +301,6 @@ a[href^="table"].internal_link span.item {
|
||||
text-transform:uppercase;
|
||||
}
|
||||
|
||||
.h1_wrap h1 {
|
||||
margin:0 -12px 12px;
|
||||
padding:12px 10px;
|
||||
width:100%;
|
||||
border:2px solid #04357B;
|
||||
background-color:#D9E5F2;
|
||||
font-family:Arial;
|
||||
font-size:32px;
|
||||
line-height:32px;
|
||||
font-style:italic;
|
||||
font-weight:600;
|
||||
}
|
||||
|
||||
.author_box {
|
||||
padding:5px 10px;
|
||||
border:1px solid #04357B;
|
||||
@@ -1250,6 +1237,40 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
#page_title h1 {
|
||||
margin:0 -12px 12px;
|
||||
padding:12px 10px;
|
||||
width:100%;
|
||||
border:2px solid #04357B;
|
||||
font-family:Arial;
|
||||
font-size:32px;
|
||||
line-height:32px;
|
||||
font-style:italic;
|
||||
font-weight:600;
|
||||
|
||||
background: #D9E5F2;
|
||||
background: -moz-linear-gradient(45deg, #D9E5F2 25%, #ffffff 75%);
|
||||
background: -webkit-gradient(linear, left bottom, right top, color-stop(25%,#D9E5F2), color-stop(75%,#ffffff));
|
||||
background: -webkit-linear-gradient(45deg, #D9E5F2 25%,#ffffff 75%);
|
||||
background: -o-linear-gradient(45deg, #D9E5F2 25%,#ffffff 75%);
|
||||
background: -ms-linear-gradient(45deg, #D9E5F2 25%,#ffffff 75%);
|
||||
background: linear-gradient(45deg, #D9E5F2 25%,#ffffff 75%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#D9E5F2', endColorstr='#ffffff',GradientType=1 );
|
||||
}
|
||||
|
||||
#page_title h1 #title_feedback {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#title_feedback .feedback {
|
||||
margin:0;
|
||||
padding: 0 5px;
|
||||
border:none;
|
||||
position:absolute;
|
||||
right:10px;
|
||||
top:14px;
|
||||
}
|
||||
|
||||
#main {
|
||||
margin:0;
|
||||
padding:0;
|
||||
|
||||
Reference in New Issue
Block a user