Tutorial: how to COMPLETELY integrate FlashChat into SMF so you have a cool CHAT

Started by marcnyc, October 09, 2004, 07:21:56 AM

Previous topic - Next topic

James Woodcock


marcnyc

Quote from: Ben_S on October 16, 2004, 09:01:49 AM
There is no documentation provided with the package for integrating it with smf, though if you look at the one for IPB and do the same (obviously uncommenting the line for SMF not IPB) it will work.

Actually there is, but for some strange reason it is in one of the subfolders. I too first thought there wasn't but then I found it. Just look in ALL subfolders and you'll find it, I promise!

James Woodcock

Quote from: James Woodcock on October 17, 2004, 01:45:28 PM
Is there a way to make the chat room show the users visible name rather then their log in?

I think this would be a great alteration, anyone figued out how to do it yet?  Im guessing it is done via the smf cms mod?

James Woodcock

Ahhh Steve my programmer has done it, if you want it to display the visible name instead of the user name ie:  James Woodcock instead of GlideM then:

In file >>> FlashChat\inc\cmses\smfCMS.php

Find:
function SMFCMS() {

    $this->loginStmt = new Statement("SELECT ID_MEMBER as id, memberName AS login, passwd, is_activated from {$GLOBALS['db_prefix']}members WHERE memberName=? AND passwd=?");
    $this->getUserStmt = new Statement("SELECT ID_MEMBER AS id, memberName AS login, ID_GROUP as status FROM {$GLOBALS['db_prefix']}members WHERE ID_MEMBER=?");
    $this->getUsersStmt = new Statement("SELECT ID_MEMBER as id, memberName as login FROM {$GLOBALS['db_prefix']}members");

Replace:
function SMFCMS() {

    $this->loginStmt = new Statement("SELECT ID_MEMBER as id, memberName AS login, passwd, is_activated from {$GLOBALS['db_prefix']}members WHERE memberName=? AND passwd=?");
    $this->getUserStmt = new Statement("SELECT ID_MEMBER AS id, realName AS login, ID_GROUP as status FROM {$GLOBALS['db_prefix']}members WHERE ID_MEMBER=?");
    $this->getUsersStmt = new Statement("SELECT ID_MEMBER as id, realName as login FROM {$GLOBALS['db_prefix']}members");

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0


Elijah Bliss


marcnyc

Awesome to hear this, ESPECIALLY when it comes from a supposingly talented and php-experienced charter member that I am sure could have come up with it too easier than I did with my limited knowledge

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

marcnyc

I am sorry, I can't answer this. You'll have to take this on up with the developer.

Owdy

Ok.  In firefox that iframe shows scrollbars in both ways. I cant get rid of those.

Idea, if user is chatting action=chat , that would be nice if it shows in whosonline list. Anyone want make mod for this?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

Add to Modifications.finnish.php:

$txt['whoall_chat'] = 'Chatting!';

Off hand... I think that should work ;).

-[Unknown]

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

babylonking


Ben_S

Liverpool FC Forum with 14 million+ posts.

Owdy

Quote from: Owdy on October 21, 2004, 01:04:04 PM
It doewsnt allow äö etc in nicknames. How can i fix that?

smfcms.php

find:
function getUserProfile($userid) {

    if ($userid == SPY_USERID) $rv = NULL;

    elseif ($user = $this->getUser($userid)) {
      $rv  = $GLOBALS['boardurl'] . "/index.php?action=profile;u=".$userid;
    }

    return $rv;
  }


  function getUser($userid) {


    $rv = NULL;
    if(($rs = $this->getUserStmt->process($userid)) && ($rec = $rs->next())) {
      $rec['roles'] = $this->getRoles($rec['status']);
      $rv = $rec;
    }

    return $rv;
  }

replace:

function getUserProfile($userid) {

    if ($userid == SPY_USERID) $rv = NULL;

    elseif ($user = $this->getUser($userid)) {
      $rv  = $GLOBALS['boardurl'] . "/index.php?action=profile;u=".$userid;
    }

    return $rv;
  }

function latin12utf8( $latin1 ) {
// translates these characters from latin-1/iso 8859-1 to UTF-8/Unicode

   $replacements = array(      'å' => 'Ã¥',
               'ä' => 'ä',
               'æ' => 'æ',
               'ö' => 'ö',
               'ø' => 'ø',
               'Å' => 'Ã...',
               'Ä' => 'Ã,,',
               'Æ' => 'Æ',
               'Ö' => 'Ö',
               'Ø' => 'Ø',
               'é' => 'é',
               'è' => 'è',
               'ê' => 'ê',
               'â' => 'â',
               'ü' => 'ü',
               'ß' => 'ß');

   return strtr($latin1, $replacements);
}


  function getUser($userid) {
   
   
    $rv = NULL;
    if(($rs = $this->getUserStmt->process($userid)) && ($rec = $rs->next())) {
      $rec['roles'] = $this->getRoles($rec['status']);
      $rec['login'] = $this->latin12utf8( $rec['login'] );
      $rv = $rec;
    }

    return $rv;
  }
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Tohelo

Thanks Owdy.

Now, if somebody still found the way to get rooms only for certain groups... rooms behind passwords or so. I have understood that this would not be possible - yet.

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Owdy

';


$chatrequest = db_query("
            SELECT COUNT(*) AS numb
            FROM  fc_connections
            WHERE userid IS NOT NULL", __FILE__, __LINE__);
         list ($chatcount) = mysql_fetch_row($chatrequest);   
         mysql_free_result($chatrequest);
         
if ( @$_GET['action'] != "chat" ) {
if ( $chatcount == "1" ) {
$singularplural1 = " on ";
$singularplural2 = "jäsen";
} else {
$singularplural1 = " on";
$singularplural2 = "jäsentä";
}
if (!$context['user']['is_guest'])
echo ' <font size="-2" >' . $chatcount . ' '.$singularplural2.' chattäilemässä.</font><br>

';
I use that so guests cant see that notise. How to change that so it wont sho nothing if chat is empty?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

marcnyc

You forgot to read the addition I made, right after the code you copied, you simply have to put the echo statement inside an if statement that checks whether the variable $chatcount is different than zero.

Basically your last three lines of code:
if (!$context['user']['is_guest'])
echo ' <font size="-2" >' . $chatcount . ' '.$singularplural2.' chattäilemässä.</font><br>

';


have to be replaced with these ones:
if (!$context['user']['is_guest'] || $chatcount != 0 )
echo ' <font size="-2" >' . $chatcount . ' '.$singularplural2.' chattäilemässä.</font><br>

';


I have simply added "|| $chatcount != 0" which means "or if $chatcount is different than zero".
Hope this helps.

Advertisement: