/**
  * Log the session out and deactivate it
  * @param   boolean   $skip_msg   If TRUE, then system messages 105 and 115 will be NOT inserted
  */
 function _s_logOut($skip_msg = false)
 {
     if ($this->_s_id != '') {
         if (!empty($this->_s_user_id)) {
             _pcpin_loadClass('message');
             $msg = new PCPIN_Message($this);
             if (!empty($this->_s_room_id)) {
                 // Session owner was in a room
                 _pcpin_loadClass('room');
                 $room = new PCPIN_Room($this);
                 $room->putUser($this->_s_user_id, 0, $skip_msg);
             }
             // Delete invitations
             _pcpin_loadClass('invitation');
             $invitation = new PCPIN_Invitation($this);
             $invitation->deleteUserInvitations($this->_s_user_id);
             // Delete temporary data
             _pcpin_loadClass('tmpdata');
             $tmpdata = new PCPIN_TmpData($this);
             $tmpdata->deleteUserRecords($this->_s_user_id);
             // Update session owner stats
             _pcpin_loadClass('user');
             $user = new PCPIN_User($this);
             if ($user->_db_loadObj($this->_s_user_id)) {
                 if ($user->is_guest == 'y') {
                     // User was a guest. Delete record.
                     $user->deleteUser($this->_s_user_id);
                 } else {
                     // Update registered user stats
                     $user->time_online = $user->calculateOnlineTime($user->id);
                     $user->last_message_id = $user->last_message_id < $this->_s_last_message_id ? $this->_s_last_message_id : $user->last_message_id;
                     $user->_db_updateObj($user->id);
                 }
             }
             if (true !== $skip_msg) {
                 $msg->addMessage(105, 'n', 0, '', 0, 0, $this->_s_user_id);
             }
         }
         // Delete session from database
         $this->_db_deleteRow($this->_s_id, '_s_id');
     }
 }