Here are all the code changes I have made to my installation. The only thing left is to have the chat request in the operator's monitor to be removed once the chat times out, but my boss doesn't care about that right now, to neither do I
Fix for preventing multiple operators from being on the same chatFew of things to be aware of. 1) This will prevent an operator with a higher priority from accepting a chat after the system has moved it to the next operator. 2) I have only tested this with 2 operators and they do not have the same priority. 3) While there are chats waiting to be accepted, the monitor will do full refreshes, not just AJAX queries.
class/js/monitor.php: This change is needed to send the operator ID to the server when trying to open the new chat window.
52c52
< window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&chatid='+chatid, 'chat_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['chat_op_width']); ?>, height=<?php echo($GLOBALS['conf']['chat_op_height']); ?>'); break; case 'transfer':
---
> window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&chatid='+chatid+'&operatorid='+'<?php echo($operatorid); ?>', 'chat_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['chat_op_width']); ?>, height=<?php echo($GLOBALS['conf']['chat_op_height']); ?>'); break; case 'transfer':
class/monitor.php: This change prevents the database from being updated if the accept button is clicked and the chat has already moved on to the next operator.
391a392,396
> // See there are chats waiting for other operators and tell client to refresh monitor
> if ($GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`!="'.$GLOBALS['operator']->id().'"'))
> {
> $this->response .= 'request-cancelled|';
> }
423a429,431
> // Only update the database if this is still available for this operator
> if ($GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`="'.$GLOBALS['operator']->id().'"'))
> {
429a438
> }
live/chat/main.php: This change prevents the pop-up chat window from connecting to a chat that has already moved on to the next operator.
53a54,64
> if ($GLOBALS['auth']->operator() && isset($_GET['admin']) && !isset($_GET['opchat']))
> {
> // Check to make sure this is valid for this operator
> if (! $GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `chatid`="'.addslashes($_GET['chatid']).'" AND `operatorid`="'.addslashes($_GET['operatorid']).'"'))
> {
> // And it isn't
> $GLOBALS['template']->assign('onload', ' onload="Chat.empty();"');
> $GLOBALS['template']->assign('text', $GLOBALS['lang']['chat_empty']);
> }
> else
> {
58a70,71
> } // if (! $GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`="'.$GLOBALS['operator']->id().'"'))
> } // if ($GLOBALS['auth']->operator() && isset($_GET['admin']) && !isset($_GET['opchat']))
And that is it. I have done a couple of other things:
Fix put timezone in transcriptclass/transcript.php33a34
> var $timezone;
50a52
> $this->timezone = date('T');
59,60c61,62
< $this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.rawurldecode($this->text).'</span><br />';
< //$this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
---
> $this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.rawurldecode($this->text).'</span><br />';
> //$this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
62c64
< $this->text = '<span class="guest"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($message).'</span><br />';
---
> $this->text = '<span class="guest"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($message).'</span><br />';
77a80
> $this->timezone = date('T');
86c89
< $this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
---
> $this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
88c91
< $this->text = '<span class="guest"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';
---
> $this->text = '<span class="guest"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';
159a163
> $this->timezone = date('T');
168c172
< $this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
---
> $this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
170c174
< $this->text = '<span class="guest"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';
---
> $this->text = '<span class="guest"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';
Firefox 3.0.6 fixclass/js/aardvark.php28c28,38
< function Aardvark(object) { this.object = object; this.xmlhttp = new XMLHttpRequest(); this.mac = navigator.platform.indexOf('Mac'); this.msie = navigator.userAgent.indexOf("MSIE"); this.image = new Image(); this.fallback = false; this.url = ''; this.variables = new Array(); this.vars = new Array(); this.connect_host = ''; this.install_host = ''; this.initiated = false; this.url_built = false; this.response = ''; this.gc = 'reset'; this.validateurl = function()
---
> function Aardvark(object) { this.object = object; this.xmlhttp = new XMLHttpRequest(); this.mac = navigator.platform.indexOf('Mac'); this.msie = navigator.userAgent.indexOf("MSIE"); this.image = new Image();
> /* Start Changed the following line to fix the Firefox 3.0.6 bug
> this.fallback = false;
> */
> if (navigator.appName == 'Microsoft Internet Explorer') {
> this.fallback = false;
> } else {
> this.fallback = true;
> }
> /* End Changed the following line to fix the Firefox 3.0.6 bug */
> this.url = ''; this.variables = new Array(); this.vars = new Array(); this.connect_host = ''; this.install_host = ''; this.initiated = false; this.url_built = false; this.response = ''; this.gc = 'reset'; this.validateurl = function()
Firefox 3.0.7 fix (I haven't tested this
http://www.helpcenterlive.com/smf/sound_issues_with_firefox_307-t928.0.html)
templates/Bliss/monitor_content.tpl (or in your own template directory)
54c54
< <embed src="{$conf.url}/templates/{$conf.template}/sounds/{$sounds[i].file}.mp3" autostart="true" hidden="true">
---
> <embed src="{$conf.url}/templates/{$conf.template}/sounds/{$sounds[i].file}.mp3" autostart="true" hidden="true" type="audio/mpeg">
class/js/chat.php155c155
< if ((x == 'o' && admin == 'false') || (x == 'g' && admin == 'true')) { parent.window.chat_display.document.body.innerHTML = parent.window.chat_display.document.body.innerHTML + this.chat_message; this.font_apply(); if (this.sounds_flag) { if (this.mac > -1) { parent.window.chat_type.document.getElementById('typing').innerHTML = '<embed src="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" id="message_sound" loop="false" autostart="true" hidden="true"></embed>';} else { parent.window.chat_type.document.getElementById('typing').innerHTML = '<object height="0" width="0" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param name="AutoStart" value="1" /><param name="FileName" value="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" /></object>';}
---
> if ((x == 'o' && admin == 'false') || (x == 'g' && admin == 'true')) { parent.window.chat_display.document.body.innerHTML = parent.window.chat_display.document.body.innerHTML + this.chat_message; this.font_apply(); if (this.sounds_flag) { if (this.mac > -1) { parent.window.chat_type.document.getElementById('typing').innerHTML = '<embed src="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" id="message_sound" loop="false" autostart="true" hidden="true" type="audio/mpeg"></embed>';} else { parent.window.chat_type.document.getElementById('typing').innerHTML = '<object height="0" width="0" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param name="AutoStart" value="1" /><param name="FileName" value="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" /></object>';}
- brian
(of, I have to b!tch a little)
You know, a little input from a developer would have helped a lot here. If nothing else, just to understand the database layout. I mean, I see the post on the front page of HCL
The 'community' certainly hasn't contributed much more than questions and overhead, and some outside assistance in handling that would really be appreciated.
I was (obviously) willing to make the fixes myself. I was just looking for some info on how everything works. <sigh>