Source for file RoomEntrance.class.php

Documentation is available at RoomEntrance.class.php

  1. <?php
  2. /**
  3.  * Class RoomEntrance, makes all needed things, like messages on user entrance
  4.  *
  5.  * LICENSE: CREATIVE COMMONS PUBLIC LICENSE  "Namensnennung — Nicht-kommerziell 2.0"
  6.  *
  7.  * @copyright  2009 <SEDesign />
  8.  * @license    http://creativecommons.org/licenses/by-nc/2.0/de/
  9.  * @version    $3.0.6$
  10.  * @link       http://www.sedesign.de/de_produkte_chat-v3.html
  11.  * @since      File available since Alpha 1.0
  12.  */
  13.  
  14. class RoomEntrance extends EtChatConfig
  15. {
  16.     /**
  17.     * DB-Connection Obj
  18.     * @var ConnectDB 
  19.     */
  20.     private $dbObj;
  21.  
  22.     /**
  23.     * XMLParser Obj with the needed lang tag from XML lang-file
  24.     * @var XMLParser 
  25.     */
  26.     private $_lang;
  27.     
  28.     /**
  29.     * Constructor
  30.     *
  31.     * @param  ConnectDB $dbObj, Obj with the db connection handler
  32.     * @param  XMLParser $lang, Obj with the needed lang tag from XML lang-file
  33.     * @uses ConnectDB::sqlGet()
  34.     * @return void 
  35.     */
  36.     public function __construct ($dbObj$lang)
  37.         
  38.         // call parent Constructor from class EtChatConfig
  39.         parent::__construct();
  40.         
  41.         $this->dbObj=$dbObj;
  42.         $this->_lang=$lang;
  43.         
  44.         // get the room entrance message 
  45.         $room_message=$this->dbObj->sqlGet("SELECT etchat_room_message FROM {$this->_prefix}etchat_rooms where etchat_id_room = 1");
  46.         
  47.         // if invisible mode on entrance
  48.         if (!empty($_POST['status_invisible']) && ($_SESSION['etchat_'.$this->_prefix.'user_priv']=='admin' || $_SESSION['etchat_'.$this->_prefix.'user_priv']=='mod')) 
  49.             $_SESSION['etchat_'.$this->_prefix.'invisible_on_enter'= true;
  50.         else 
  51.             $_SESSION['etchat_'.$this->_prefix.'invisible_on_enter'= false;
  52.         
  53.         // if no room message, just make a user entrance message
  54.         if (empty($room_message[0][0])) $this->withoutRoomMessage();
  55.         // else make make room entrance message first and then a user entrance message
  56.         else $this->withRoomMessage($room_message[0][0]);
  57.         
  58.         // this is a very important value. Its a counter for all incomming messages that will be shown in the user chat-window. It is needed 
  59.         // by chat.js for making a unique and continuous id for every gotten dataset.
  60.         $_SESSION['etchat_'.$this->_prefix.'last_id'= 0;
  61.     }
  62.     
  63.     /**
  64.     * WithoutRoomMessage
  65.     *
  66.     * @return void
  67.     */
  68.     private function withoutRoomMessage(){    
  69.  
  70.         $an = (!empty($_POST['status_invisible']) && ($_SESSION['etchat_'.$this->_prefix.'user_priv']=='admin' || $_SESSION['etchat_'.$this->_prefix.'user_priv']=='mod')) $_SESSION['etchat_'.$this->_prefix.'user_id': 0;
  71.         
  72.         // the first message id that have been shown for the user. This var will be worked up in reloader
  73.         $sysMessObj = new SysMessage($this->dbObj"<b>".$_SESSION['etchat_'.$this->_prefix.'username']."</b> ".$this->_lang->eintritt[0]->tagData0$an );
  74.         $_SESSION['etchat_'.$this->_prefix.'my_first_mess_id'$sysMessObj->lastInsertedId;
  75.     }
  76.     
  77.     /**
  78.     * WithoutRoomMessage
  79.     *
  80.     * @param string $room_message, message on room entrance
  81.     * @return void
  82.     */
  83.     private function withRoomMessage($room_message){    
  84.     
  85.         $an = (!empty($_POST['status_invisible']) && ($_SESSION['etchat_'.$this->_prefix.'user_priv']=='admin' || $_SESSION['etchat_'.$this->_prefix.'user_priv']=='mod')) $_SESSION['etchat_'.$this->_prefix.'user_id': 0;
  86.         
  87.         // word wrap in WIN
  88.         $room_message_insert = str_replace("\r\n","<br />",$room_message);
  89.         // word wrap in LIN, Uniux, MacOS
  90.         $room_message_insert = str_replace("\n","<br />",$room_message_insert);
  91.  
  92.         // the first message id that have been shown for the user. This var will be worked up in reloader
  93.  
  94.         $sysMessObj = new SysMessage($this->dbObj"<br /><div style=\"margin: 4px;\">".$room_message_insert."</div>"1$_SESSION['etchat_'.$this->_prefix.'user_id']);    
  95.         $_SESSION['etchat_'.$this->_prefix.'my_first_mess_id'$sysMessObj->lastInsertedId;        
  96.         new SysMessage($this->dbObj"<b>".$_SESSION['etchat_'.$this->_prefix.'username']."</b> ".$this->_lang->eintritt[0]->tagData0$an );
  97.         
  98.     }

Documentation generated on Thu, 05 May 2011 14:05:58 +0000 by phpDocumentor 1.4.3