Karakas Online

20.5.3. How to create a Help Center Live block

We will now move on to consider a block that can integrate the whole functionality of a Help Center: the Help Center Live block for PHP-Nuke. Help Center Live is an Open Source Application that is distributed under the GNU Genreal Public License (GPL). It helps you build a real support department for your business. With Help Center Live you can:

How can you incorporate all this functionality into your PHP-Nuke site?

At first, you must install Help Center Live on our site, or, if we only want to test it, local system. For this, download the package from Help Center Live and extract its contents into some folder of your web root, say under /helpcenter. Then you must edit the config.php file in the inc directory of that folder with the decent text editor (Chapter 11) of your choice. There are various parameters you can set up there, but the most important are the $URL_* ones

$URL_site = "midas";
$URL_dir = "/helpcenter/"; 
$URL_maindir = "http://midas/helpcenter";
$URL_secure = 0;

as well as the DB_* ones:

$DB_host = "localhost";
$DB_user = "db user here";
$DB_pass = "db password here";
$DB_name = "db name here"; 
$DB_prefix = "prefix here";
$DB_pconnect = 0;

The $DB_host, $DB_user, $DB_pass and $DB_name variables could be the same as the $dbhost, $dbuser, $dbpass and $dbname variables in config.php respectively (see Section 3.7), although not necessarily so.

Tip Terminate the DB_prefix with an underscore!
 

If you use a $DB_prefix, make sure it ends in an underscore (_), otherwise it will be directly concatenated with the table names, rendering them difficult to tell apart.

The $URL_site, $URL_dir and $URL_secure variables are only used in calls to the PHP setcookie() function:

setcookie("Help Center LiveUser", $INFO_username, $time, $URL_dir, $URL_site, $URL_secure);

Calls to setcookie() like the above are scattered throughout the code - Table 20-1 lists all files and lines containing such calls. If you experience the infamous login loop problem, it is probably because the setcookie() function was not able to set the cookie on the client. frown

Table 20-1. Help Center Live: setcookie() calls

File

setcookie() call

cp/logout.php

setcookie("HelpCenterLiveOperator", $LOGIN_username, $time, $URL_dir, $URL_site, $URL_secure);

cp/logout.php

setcookie("HelpCenterLivePassword", $LOGIN_password, $time, $URL_dir, $URL_site, $URL_secure);

cp/login.php

setcookie("HelpCenterLiveOperator", $LOGIN_username, $time, $URL_dir, $URL_site, $URL_secure);

cp/login.php

setcookie("HelpCenterLivePassword", $LOGIN_password, $time, $URL_dir, $URL_site, $URL_secure);

lh/live_request.php

setcookie("HelpCenterLiveGuest", $REQUEST_name, $time, $URL_dir, $URL_site, $URL_secure);

lh/live_request.php

setcookie("HelpCenterLiveGuest", $REQUEST_delname, $deltime, $URL_dir, $URL_site, $URL_secure);

lh/live_request.php

setcookie("HelpCenterLiveGuest", $REQUEST_name, $time, $URL_dir, $URL_site, $URL_secure);

lh/live_mail.php

setcookie("HelpCenterLiveUser", $LOGIN_username, $time, $URL_dir, $URL_site, $URL_secure);

lh/live_mail.php

setcookie("HelpCenterLivePass", $LOGIN_password, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_register.php

setcookie("Help Center LiveUser", $REGISTER_username, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_register.php

setcookie("Help Center LivePass", $REGISTER_password, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_login.php

setcookie("HelpCenterLiveUser", $LOGIN_username, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_login.php

setcookie("HelpCenterLivePass", $LOGIN_password, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_logout.php

setcookie("HelpCenterLiveUser", $LOGIN_username, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_logout.php

setcookie("HelpCenterLivePass", $LOGIN_password, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_info.php

setcookie("Help Center LiveUser", $INFO_username, $time, $URL_dir, $URL_site, $URL_secure);

tt/user_info.php

setcookie("Help Center LivePass", $INFO_password, $time, $URL_dir, $URL_site, $URL_secure);



This happens if, for example, you are installing Help Center Live locally, and the host name for $URL_site is taken from a hosts file and not from DNS. One way to get around this is to change all calls to setcookie() listed in Table 20-1 and take out the last two parameters, $URL_site and $URL_secure, as in the following example:

setcookie("Help Center LiveUser", $INFO_username, $time, $URL_dir);

After the installation of Help Center Live, you can point your browser the the address you entered for $URL_maindir (http://midas/helpcenter, in our example) and, after a successful login, you will be presented with the main screen (Figure 20-5).

Figure 20-5. Help Center Live: Main screen.

Help Center Live: Main screen.

Help Center Live: Main screen.



Now, create a PHP-Nuke block that uses the method of our Hello World example in Section 20.5.1 to incorporate Help Center Live's functionality:

<?php
if (eregi("block-Online_Support.php",$_SERVER[PHP_SELF])) {
    Header("Location: index.php");
    die();
}
$content.="<center><script language=\"JavaScript\"
src=\"http://midas/helpcenter/lh/live.php\"></script></center></b>";
?>

We named the block above "block-Online_Support", but of course you can use whatever title you like, as long as it is passed as the "needle" string to the eregi() function of the block. The main code consists of only one line, which inserts a Javascript code, whose source file is the lh/live.php PHP script of Help Center Live. We did the same in Section 20.5.1 to output a Hello World message, but now, this simple line opens a whole world of possibilities for our PHP-Nuke page! Let's see what happens when we activate the Online Support block we just created:

As long as all Help Center operators are logged off, the block will display a "Live Support is Offline" message, as in Figure 20-6.

Figure 20-6. Help Center Live block: Live Support is Offline.

Help Center Live block: Live Support is Offline.

Help Center Live block: Live Support is Offline.



In this case, a click on the arrow in the block's inside will open a window that gives the customer the possibility to enter a trouble ticket (Figure 20-7). The window also offers a link to the FAQ and offers the choice to refer to an existing trouble ticket or create a new one.

Figure 20-7. Help Center Live block: Creating a trouble ticket.

Help Center Live block: Creating a trouble ticket.

Help Center Live block: Creating a trouble ticket.



On the other side, if some support operator is online and has launched the request monitor (which opens a window for the operator, displaying the live connections he is currently maintaining), the block will display it with a "Live Support is Online!" message (Figure 20-8).

Figure 20-8. Help Center Live block: Live Support is Online.

Help Center Live block: Live Support is Online.

Help Center Live block: Live Support is Online.



The request monitor, on the operator's side, will display all hosts that are currently viewing the PHP-Nuke page with the Online Support block showing the "Live Support is Online!" message (Figure 20-9). In other words, both users and operators are informed of each other's online presence.

Figure 20-9. Help Center Live block: Request monitor for the operator.

Help Center Live block: Request monitor for the operator.

Help Center Live block: Request monitor for the operator.



Now - and this adds a tremendous value to that tiny block we just created - each side can initiate an online chat with the other part:

The operator can click on the "Initiate" link and, after selecting the aproppriate department, initiate a chat with the selected user. The user will get pop-up window, notifying him of the operator's wish for a chat (Figure 20-10). The user can then decide whether to accept or decline the chat request.

Figure 20-10. Help Center Live block: User notification of the operator's chat request.

Help Center Live block: User notification of the operator's chat request.

Help Center Live block: User notification of the operator's chat request.



On the user's side, everybody can click on the arrow besides the "Online!" message in the Online Support block. This will initiate a chat request on behalf of the user (Figure 20-11). The operator will get a pop-up window notifying him of the user's request, which he can accept or decline as well.

Figure 20-11. Help Center Live block: User chat request.

Help Center Live block: User chat request.

Help Center Live block: User chat request.



Either way, initiating from the operator's or user's side, a chat session starts between the two, hopefully leading to the solution of the user's problem. A transcript of the chat can be sent to an e-mail address of the participant's choice for future reference.

This completes our brief review of Help Center Live's features. If you have a look at the code of the Online Support block above and the code of the Hello World block in Section 20.5.1, you will see that they both use the same method to incorporate functionality in a PHP-Nuke block through Javascript. The method is the same, but what a huge difference in functionality! There, a simple "Hello World" output - here, a full-featured Help Center! This demonstrates the broad spectrum of possibilities that a simple line like

$content.="<center><script language=\"JavaScript\"
src=\"Some <acronym>PHP</acronym> script\"></script></center></b>";

can offer, when used intelligently in a PHP-Nuke block with Javascript.

Note Help Center Live is looking for a sponsor!
 

HCL is getting well over a million hits per month and its on a huge increase keeping in mind that Fantastico now has HCL as a featured script for install. Mike, the developer of HCL, offers it under the GPL - however, he is looking for sponsor to help him continue its development for free and cope with the ever-increasing hosting fees and other expenses. Please contact Mike, if you are interested and serious about sponsoring HCL.

Last updated Sun Aug 7 21:14:12 CEST 2005 Permalink: http://www.karakas-online.de/EN-Book/create-help-center-live-block.html All contents © 2004 Chris Karakas, Claudio Erba