Public Member Functions | Data Fields

ilChatServerCommunicator Class Reference

Public Member Functions

 ilChatServerCommunicator (&$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 ()
 getServerFrameSource ()
 isAlive ()
 __getFormattedChatroom ()
 __formatLogin ($a_login)
 __formatMessage ()
 __emoticons ()
 __openSocket ()
 _initObject ()
 _login ()
 _logout ()

Data Fields

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

Detailed Description

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


Member Function Documentation

ilChatServerCommunicator::__emoticons (  ) 

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

References getMessage(), and setMessage().

Referenced by __formatMessage().

        {
                $str = $this->getMessage();
                $str = str_replace(":)", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_smile.gif\" border=0>", $str);
                $str = str_replace(":-)", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_smile.gif\" border=0>", $str);
                $str = str_replace(":smile:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_smile.gif\" border=0>", $str);
                $str = str_replace(";)", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_wink.gif\" border=0>", $str);
                $str = str_replace(";-)", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_wink.gif\" border=0>", $str);
                $str = str_replace(":wink:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_wink.gif\" border=0>", $str);
                $str = str_replace(":D", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_laugh.gif\" border=0>", $str);
                $str = str_replace(":-D", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_laugh.gif\" border=0>", $str);
                $str = str_replace(":laugh:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_laugh.gif\" border=0>", $str);
                $str = str_replace(":grin:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_laugh.gif\" border=0>", $str);
                $str = str_replace(":biggrin:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_laugh.gif\" border=0>", $str);
                $str = str_replace(":(", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_sad.gif\" border=0>", $str);
                $str = str_replace(":-(", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_sad.gif\" border=0>", $str);
                $str = str_replace(":sad:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_sad.gif\" border=0>", $str);
                $str = str_replace(":o", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_shocked.gif\" border=0>", $str);
                $str = str_replace(":-o", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_shocked.gif\" border=0>", $str);
                $str = str_replace(":shocked:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_smile.gif\" border=0>", $str);
                $str = str_replace(":p", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_tongue.gif\" border=0>", $str);
                $str = str_replace(":-p", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_tongue.gif\" border=0>", $str);
                $str = str_replace(":tongue:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_smile.gif\" border=0>", $str);
                $str = str_replace(":cool:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_cool.gif\" border=0>", $str);
                $str = str_replace(":eek:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_eek.gif\" border=0>", $str);
                $str = str_replace(":||", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_angry.gif\" border=0>", $str);
                $str = str_replace(":-||", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_angry.gif\" border=0>", $str);
                $str = str_replace(":angry:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_angry.gif\" border=0>", $str);
                $str = str_replace(":flush:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_flush.gif\" border=0>", $str);
                $str = str_replace(":idea:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_idea.gif\" border=0>", $str);
                $str = str_replace(":thumbup:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_thumbup.gif\" border=0>", $str);
                $str = str_replace(":thumbdown:", "<img src=\"" . ILIAS_HTTP_PATH . 
                                                   "/templates/default/images/emoticons/icon_thumbdown.gif\" border=0>", $str);
                $this->setMessage($str);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilChatServerCommunicator::__formatLogin ( a_login  ) 

Definition at line 145 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 (  ) 

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

References __emoticons(), __formatLogin(), __getFormattedChatroom(), getKickedUser(), getMessage(), getRecipientLogin(), and getType().

Referenced by send().

        {
                $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
                                $this->chat->chat_room->appendMessageToDb($this->getMessage());
                                return ">".$this->__getFormattedChatroom().$this->getMessage()."<br />";

                        case 'normal':
                                // STORE MESSAGE IN DB
                                $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 (  ) 

Definition at line 138 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::__openSocket (  ) 

Definition at line 265 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::_initObject (  ) 

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

References $ilias, $query, $ref_id, $res, $row, ilObjectFactory::getInstanceByRefId(), and ilChatServerCommunicator().

Referenced by _login(), and _logout().

        {
                global $ilias;
                
                $query = "SELECT ref_id FROM object_data NATURAL JOIN object_reference ".
                        "WHERE type = 'chac'";
                
                $res = $ilias->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $ref_id = $row->ref_id;
                }
                
                // GET INSTANCE
                return new ilChatServerCommunicator($tmp =& ilObjectFactory::getInstanceByRefId($ref_id));
        }               

Here is the call graph for this function:

Here is the caller graph for this function:

ilChatServerCommunicator::_login (  ) 

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

References $_SESSION, and _initObject().

Referenced by ilStartUpGUI::showLogin().

        {
                $obj =& ilChatServerCommunicator::_initObject();

                // 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:

ilChatServerCommunicator::_logout (  ) 

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

References $_SESSION, and _initObject().

Referenced by ilStartUpGUI::showLogout().

        {
                $obj =& ilChatServerCommunicator::_initObject();

                // 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:

ilChatServerCommunicator::getHtml (  ) 

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

        {
                return $this->html;
        }

ilChatServerCommunicator::getKickedUser (  ) 

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

Referenced by __formatMessage().

        {
                return $this->kicked_user;
        }

Here is the caller graph for this function:

ilChatServerCommunicator::getMessage (  ) 

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

Referenced by __emoticons(), and __formatMessage().

        {
                return $this->message;
        }

Here is the caller graph for this function:

ilChatServerCommunicator::getRecipientId (  ) 

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

        {
                return $this->rcp_id;
        }

ilChatServerCommunicator::getRecipientLogin (  ) 

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

Referenced by __formatMessage().

        {
                return $this->rcp_login;
        }

Here is the caller graph for this function:

ilChatServerCommunicator::getServerFrameSource (  ) 

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

References __formatLogin(), and __getFormattedChatroom().

        {
                return sprintf("http://%s:%s/%s%s",
                       $this->chat->server_conf->getExternalIp(),
                                           $this->chat->server_conf->getPort(),
                                           $this->__formatLogin($this->chat->chat_user->getLogin()),
                                           $this->__getFormattedChatroom());

        }

Here is the call graph for this function:

ilChatServerCommunicator::getType (  ) 

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

Referenced by __formatMessage().

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

Here is the caller graph for this function:

ilChatServerCommunicator::ilChatServerCommunicator ( &$  chat_obj  ) 

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

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

Referenced by _initObject().

        {
                define(TIMEOUT,2);

                $this->chat =& $chat_obj;
        }

Here is the caller graph for this function:

ilChatServerCommunicator::isAlive (  ) 

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

References send(), and setType().

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

Here is the call graph for this function:

ilChatServerCommunicator::send (  ) 

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

References __formatMessage(), and __openSocket().

Referenced by isAlive().

        {
                if(!$this->__openSocket())
                {
                        return false;
                }
                fputs($this->socket_p,$this->__formatMessage());
                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 80 of file class.ilChatServerCommunicator.php.

        {
                $this->kicked_user = $k_user;
        }

ilChatServerCommunicator::setMessage ( a_message  ) 

Definition at line 88 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 $tmp_user, and 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 72 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 96 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 35 of file class.ilChatServerCommunicator.php.

ilChatServerCommunicator::$kicked_user

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

ilChatServerCommunicator::$message

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

ilChatServerCommunicator::$rcp_id

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

ilChatServerCommunicator::$rcp_login

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

ilChatServerCommunicator::$socket_p

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

ilChatServerCommunicator::$type

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


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