i've made another modification to control the session
i created this table
CREATE TABLE ls_status (
id int(255) NOT NULL auto_increment,
session_id varchar(255) NOT NULL default '',
status varchar(10) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
then i modified these files
in catalog/live_support.php (to open the conversation)
just below the welcome message
tep_db_query("insert into " . TABLE_LS_STATUS . " (id, session_id, status) values ('', '" . $osCsid . "', 'yes')");
]
in catalog/ls_comm_main.php (only post if the conversation is open)
before
// Lets read the contents of the conversation
$conversation_query = tep_db_query("select id, guest, tech, message, tech_reply from " . TABLE_LS_CONVERSATIONS . " a where tech ='Soporte' and
session_id = '" . $osCsid . "' order by id desc");
while ($conversation =tep_db_fetch_array($conversation_query)) { if($conversation['tech_reply'] == '0') {
echo "<span class="question"><b>$conversation[guest]:</b> $conversation[message]</span><br>n";
}
if($conversation['tech_reply'] == '1') {
echo "<span class="reply"><b>$conversation[tech]:</b> $conversation[message]</span><br>n";
}
if($conversation['tech_reply'] == '2') {
echo "<p align="center" class="system"> $conversation[message]</p><br>n";
}
}
after
$status_query = tep_db_query("select status from " . TABLE_LS_STATUS . " a where session_id = '" . $osCsid . "'");
while ($status_info =tep_db_fetch_array($status_query)) {
$status = $status_info['status'];
}
if ($status=='yes')
{
// Lets read the contents of the conversation
$conversation_query = tep_db_query("select id, guest, tech, message, tech_reply from " . TABLE_LS_CONVERSATIONS . " a where tech ='Soporte' and
session_id = '" . $osCsid . "' order by id desc");
while ($conversation =tep_db_fetch_array($conversation_query)) { if($conversation['tech_reply'] == '0') {
echo "<span class="question"><b>$conversation[guest]:</b> $conversation[message]</span><br>n";
}
if($conversation['tech_reply'] == '1') {
echo "<span class="reply"><b>$conversation[tech]:</b> $conversation[message]</span><br>n";
}
if($conversation['tech_reply'] == '2') {
echo "<p align="center" class="system"> $conversation[message]</p><br>n";
}
}
}
else
{
echo "Session is closed yadayadayada";
}
in catalog/ls_comm_top.php (leave ls_conversation empty if the session is closed)
before
if($text) {
$guest_query = tep_db_query("select guest from " . TABLE_LS_CONVERSATIONS . " a where session_id = '" . $osCsid . "'");
while ($guest_info =tep_db_fetch_array($guest_query)) {
$guest = $guest_info['guest'];
}
$message = tep_db_prepare_input($HTTP_POST_VARS['text']);
tep_db_query("insert into " . TABLE_LS_CONVERSATIONS . " (id, guest, tech, session_id, message, tech_reply) values ('', '" . $guest . "', 'Soporte', '" . $osCsid . "', '" . $message . "', '0')");
}
after
$status_query = tep_db_query("select status from " . TABLE_LS_STATUS . " a where session_id = '" . $osCsid . "'");
while ($status_info =tep_db_fetch_array($status_query)) {
$status = $status_info['status'];
}
if ($status=='yes')
{
if($text) {
$guest_query = tep_db_query("select guest from " . TABLE_LS_CONVERSATIONS . " a where session_id = '" . $osCsid . "'");
while ($guest_info =tep_db_fetch_array($guest_query)) {
$guest = $guest_info['guest'];
}
$message = tep_db_prepare_input($HTTP_POST_VARS['text']);
tep_db_query("insert into " . TABLE_LS_CONVERSATIONS . " (id, guest, tech, session_id, message, tech_reply) values ('', '" . $guest . "', 'Soporte', '" . $osCsid . "', '" . $message . "', '0')");
}
}
in catalog/ls_comm_top.php (just in case)
before
echo "<td> <input class=textbox size=30 name=text> <input class=button type=submit value=Send></td>";
after
<?
$status_query = tep_db_query("select status from " . TABLE_LS_STATUS . " a where session_id = '" . $osCsid . "'");
while ($status_info =tep_db_fetch_array($status_query)) {
$status = $status_info['status'];
}
if ($status=='yes')
{
echo "<td> <input class=textbox size=30 name=text> <input class=button type=submit value=Send></td>";
}
else {
echo "i told you, session is closed";
}
?>
in catalog/ls_exit.php (what to do if the admin closed the session)
put it just below the for cycle
$status_query = tep_db_query("select status from " . TABLE_LS_STATUS . " a where session_id = '" . $osCsid . "'");
while ($status_info =tep_db_fetch_array($status_query)) {
$status = $status_info['status'];
}
echo $status;
if ($status=='yes')
{
$guest ='';
$message='the customer is gone';
tep_db_query("insert into " . TABLE_LS_CONVERSATIONS . " (id, guest, tech, session_id, message, tech_reply) values ('', '" . $guest . "', 'Sales', '" . $osCsid . "', '" . $message . "', '0')");
echo "<script>window.close()</script>";
}
else {
echo "<script>window.close()</script>";
}
in admin/ls_comm_exit.php (he has to finish the session)
put it just below the for cycle
tep_db_query("delete from " . TABLE_LS_STATUS . " where session_id = '" . $osCsid . "' ");
and that's it, the code it's not perfect but it works :)
....damn, this is my longest post by far :D