ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatServerCommunicator Class Reference

Class ilChatServerCommunicator. More...

+ Collaboration diagram for ilChatServerCommunicator:

Public Member Functions

 __construct (&$chat_obj)
 Constructor public.
 setRecipientId ($a_id)
 getRecipientId ()
 setRecipientLogin ($a_login)
 getRecipientLogin ()
 setKickedUser ($k_user)
 getKickedUser ()
 setMessage ($a_message)
 getMessage ()
 setType ($a_type)
 getType ()
 getHtml ()
 send (&$id=null)
 getServerFrameSource ()
 isAlive ()

Static Public Member Functions

static _initObject ()
static _login ()
static _logout ()
static _lookupUser ($usr_id)
static _getTailMessages ($chat_id, $room_id, $start_date=0)

Data Fields

 $chat
 $message
 $socket_p
 $type
 $rcp_id
 $rcp_login
 $kicked_user

Private Member Functions

 getFormattedChatroom ()
 formatLogin ($a_login)
 formatMessage (&$id=null)
 emoticons ()
 openSocket ()

Detailed Description

Class ilChatServerCommunicator.

Author
Stefan Meyer
Version
Id:
class.ilChatServerCommunicator.php 19587 2009-04-09 15:08:42Z jposselt

Definition at line 32 of file class.ilChatServerCommunicator.php.

Constructor & Destructor Documentation

ilChatServerCommunicator::__construct ( $chat_obj)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 49 of file class.ilChatServerCommunicator.php.

{
define(TIMEOUT,2);
$this->chat =& $chat_obj;
}

Member Function Documentation

static ilChatServerCommunicator::_getTailMessages (   $chat_id,
  $room_id,
  $start_date = 0 
)
static

Definition at line 311 of file class.ilChatServerCommunicator.php.

References $ilDB, $res, and $row.

Referenced by ilChatMessageNotifyGUI\getHTML().

{
global $ilDB;
$ilDB->setLimit(1, 0);
$row = $ilDB->queryF('
SELECT entry_id, message
FROM chat_room_messages
WHERE
chat_id = %s
AND room_id = %s
AND commit_timestamp > %s
ORDER BY
commit_timestamp DESC',
array('integer', 'integer', 'integer'),
array($chat_id, $room_id, $start_date)
);
if ($row->numRows()) {
$line = $row->fetchRow();
$res = new stdClass();
$res->entryId = $line[0];
$res->message = $line[1];
return $res;
}
else
return false;
}

+ Here is the caller graph for this function:

static ilChatServerCommunicator::_initObject ( )
static

Definition at line 231 of file class.ilChatServerCommunicator.php.

References $ilDB, $ref_id, $res, $row, DB_FETCHMODE_OBJECT, and ilObjectFactory\getInstanceByRefId().

Referenced by _login(), and _logout().

{
global $ilias, $ilDB;
$res = $ilDB->queryF('
SELECT ref_id FROM object_data
NATURAL JOIN object_reference
WHERE type = %s',
array('text'),
array('chac')
);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$ref_id = $row->ref_id;
}
// GET INSTANCE
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatServerCommunicator::_login ( )
static

Definition at line 252 of file class.ilChatServerCommunicator.php.

References $_SESSION, and _initObject().

Referenced by ilStartUpGUI\showLogin().

{
// CALLED BY login.php
$obj->setType("login");
$obj->chat->chat_user->setUserId($_SESSION["AccountId"]);
$obj->send();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatServerCommunicator::_logout ( )
static

Definition at line 262 of file class.ilChatServerCommunicator.php.

References $_SESSION, and _initObject().

Referenced by ilStartUpGUI\showLogout().

{
// CALLED BY login.php
$obj->setType("logout");
$obj->chat->chat_user->setUserId($_SESSION["AccountId"]);
$obj->send();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatServerCommunicator::_lookupUser (   $usr_id)
static

Definition at line 272 of file class.ilChatServerCommunicator.php.

References $ilDB, $res, $row, and $usr_id.

Referenced by ilChatMessageNotifyGUI\getHTML().

{
global $ilDB, $ilObjDataCache;
$row = $ilDB->queryF('
SELECT room_id, chat_id, kicked FROM chat_user
WHERE
usr_id = %s AND
last_conn_timestamp > %s',
array('integer', 'integer'),
array($usr_id, time() - 60));
$found = $row->numRows() ? true : false;
if (!$found)
return false;
$line = $row->fetchRow();
$res = new stdClass();
$res->chatId = $line[1];
$res->roomId = $line[0];
$res->kicked = $line[2];
$room_title = '';
if((int)$res->roomId)
{
include_once 'Modules/Chat/classes/class.ilChatRoom.php';
$oTmpChatRoom = new ilChatRoom((int)$res->chatId);
$oTmpChatRoom->setRoomId((int)$res->roomId);
$room_title = $oTmpChatRoom->getTitle();
if($room_title != '')
$room_title = " (" . $room_title . ")";
}
$res->chatTitle = $ilObjDataCache->lookupTitle($res->chatId) . $room_title;
return $res;
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::emoticons ( )
private

Definition at line 211 of file class.ilChatServerCommunicator.php.

References $ilSetting, ilChatSmilies\_parseString(), getMessage(), and setMessage().

Referenced by formatMessage().

{
global $ilSetting;
if ($ilSetting->get('chat_smilies_status') == 1) {
include_once 'Modules/Chat/classes/class.ilChatSmilies.php';
$this->setMessage($str);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatServerCommunicator::formatLogin (   $a_login)
private

Definition at line 153 of file class.ilChatServerCommunicator.php.

Referenced by formatMessage(), and getServerFrameSource().

{
$nic = $this->chat->server_conf->getNic();
return substr($nic.md5($a_login),0,32);
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::formatMessage ( $id = null)
private

Definition at line 160 of file class.ilChatServerCommunicator.php.

References $ilSetting, emoticons(), formatLogin(), getFormattedChatroom(), getKickedUser(), getMessage(), getRecipientLogin(), and getType().

Referenced by send().

{
global $ilSetting;
if ((int)$ilSetting->get('chat_smilies_status') == 1)
$this->emoticons();
switch($this->getType())
{
case 'private':
// STORE MESSAGE IN DB
return "|".$this->formatLogin($this->getRecipientLogin()).
$this->formatLogin($this->chat->chat_user->getLogin()).
$this->getFormattedChatroom().$this->getMessage()."<br />";
case 'address':
// STORE MESSAGE IN DB
$id = $this->chat->chat_room->appendMessageToDb($this->getMessage());
return ">".$this->getFormattedChatroom().$this->getMessage()."<br />";
case 'normal':
// STORE MESSAGE IN DB
$id = $this->chat->chat_room->appendMessageToDb($this->getMessage());
return ">".$this->getFormattedChatroom().$this->getMessage()."<br />";
case 'login':
return "!".$this->formatLogin($this->chat->chat_user->getLogin()).$_SERVER["REMOTE_ADDR"];
case "logout":
return "-".$this->formatLogin($this->chat->chat_user->getLogin());
case "kick":
return "GET /moderate?".$this->chat->server_conf->getModeratorPassword().
"&kick&".$this->formatLogin($this->getKickedUser()).
"&".$this->getFormattedChatroom();
case "delete":
return "GET /moderate?".$this->chat->server_conf->getModeratorPassword().
"&delete&".$this->getFormattedChatroom();
case "empty":
return "GET /moderate?".$this->chat->server_conf->getModeratorPassword().
"&clear&".$this->getFormattedChatroom();
case "test":
return "GET /Version";
default:
return "GET /Version";
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatServerCommunicator::getFormattedChatroom ( )
private

Definition at line 145 of file class.ilChatServerCommunicator.php.

Referenced by formatMessage(), and getServerFrameSource().

{
$nic = $this->chat->server_conf->getNic();
return $nic.$this->chat->chat_room->getInternalName().
substr("______________",0,14-strlen($this->chat->chat_room->getInternalName()));
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::getHtml ( )

Definition at line 114 of file class.ilChatServerCommunicator.php.

{
return $this->html;
}
ilChatServerCommunicator::getKickedUser ( )

Definition at line 89 of file class.ilChatServerCommunicator.php.

References $kicked_user.

Referenced by formatMessage().

{
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::getMessage ( )

Definition at line 99 of file class.ilChatServerCommunicator.php.

References $message.

Referenced by emoticons(), and formatMessage().

{
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::getRecipientId ( )

Definition at line 69 of file class.ilChatServerCommunicator.php.

References $rcp_id.

{
return $this->rcp_id;
}
ilChatServerCommunicator::getRecipientLogin ( )

Definition at line 79 of file class.ilChatServerCommunicator.php.

References $rcp_login.

Referenced by formatMessage().

{
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::getServerFrameSource ( )

Definition at line 130 of file class.ilChatServerCommunicator.php.

References formatLogin(), and getFormattedChatroom().

{
return sprintf("http".($this->chat->server_conf->getSSLStatus() && $this->chat->server_conf->getSSLPort() ? "s" : "")."://%s:%s/%s%s",
$this->chat->server_conf->getExternalIp(),
($this->chat->server_conf->getSSLStatus() && $this->chat->server_conf->getSSLPort() ? $this->chat->server_conf->getSSLPort() : $this->chat->server_conf->getPort()),
$this->formatLogin($this->chat->chat_user->getLogin()),
}

+ Here is the call graph for this function:

ilChatServerCommunicator::getType ( )

Definition at line 109 of file class.ilChatServerCommunicator.php.

Referenced by formatMessage().

{
return $this->type ? $this->type : 'normal';
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::isAlive ( )

Definition at line 139 of file class.ilChatServerCommunicator.php.

References send(), and setType().

{
$this->setType("test");
return $this->send();
}

+ Here is the call graph for this function:

ilChatServerCommunicator::openSocket ( )
private

Definition at line 222 of file class.ilChatServerCommunicator.php.

Referenced by send().

{
$this->socket_p = @fsockopen($this->chat->server_conf->getInternalIp(),
$this->chat->server_conf->getPort(), $errno, $errstr, TIMEOUT);
return $this->socket_p == null ? false : true;
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::send ( $id = null)

Definition at line 119 of file class.ilChatServerCommunicator.php.

References formatMessage(), and openSocket().

Referenced by isAlive().

{
if(!$this->openSocket())
{
return false;
}
fputs($this->socket_p,$this->formatMessage($id));
fclose($this->socket_p);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatServerCommunicator::setKickedUser (   $k_user)

Definition at line 84 of file class.ilChatServerCommunicator.php.

{
$this->kicked_user = $k_user;
}
ilChatServerCommunicator::setMessage (   $a_message)

Definition at line 94 of file class.ilChatServerCommunicator.php.

Referenced by emoticons().

{
$this->message = $a_message;
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::setRecipientId (   $a_id)

Definition at line 57 of file class.ilChatServerCommunicator.php.

References setRecipientLogin().

{
$this->rcp_id = $a_id;
if($this->rcp_id)
{
$tmp_user =& new ilObjUser($this->rcp_id);
$this->setRecipientLogin($tmp_user->getLogin());
unset($tmp_user);
}
}

+ Here is the call graph for this function:

ilChatServerCommunicator::setRecipientLogin (   $a_login)

Definition at line 74 of file class.ilChatServerCommunicator.php.

Referenced by setRecipientId().

{
$this->rcp_login = $a_login;
}

+ Here is the caller graph for this function:

ilChatServerCommunicator::setType (   $a_type)

Definition at line 104 of file class.ilChatServerCommunicator.php.

Referenced by isAlive().

{
$this->type = $a_type;
}

+ Here is the caller graph for this function:

Field Documentation

ilChatServerCommunicator::$chat

Definition at line 34 of file class.ilChatServerCommunicator.php.

ilChatServerCommunicator::$kicked_user

Definition at line 41 of file class.ilChatServerCommunicator.php.

Referenced by getKickedUser().

ilChatServerCommunicator::$message

Definition at line 36 of file class.ilChatServerCommunicator.php.

Referenced by getMessage().

ilChatServerCommunicator::$rcp_id

Definition at line 39 of file class.ilChatServerCommunicator.php.

Referenced by getRecipientId().

ilChatServerCommunicator::$rcp_login

Definition at line 40 of file class.ilChatServerCommunicator.php.

Referenced by getRecipientLogin().

ilChatServerCommunicator::$socket_p

Definition at line 37 of file class.ilChatServerCommunicator.php.

ilChatServerCommunicator::$type

Definition at line 38 of file class.ilChatServerCommunicator.php.


The documentation for this class was generated from the following file: