Tufat Flashchat and Elgg?

I've been using Flashchat for a long time and used it mostly with my phpnuke installs. But now that I've been switching communities over to Elgg (because it's awesome!) I've wanted to give the users back FlashChat.


I'd like to know if anyone has any thoughts on where to start integration? Or how I could get it to throw the usernames and such at the flash chat. If someone could help out with a little knowledge I'd appreciate it and I'd put the finished plugin up for everyone. I'm sure it would help the community as well.

 

  • What I've found on another site was this... I do have some code, but I don't know how to post it here without the formatting being ruined. :(  I'm at a bit of a loss, though since Elgg seems to use a lot of jumping back and forth through files... So, I'm not completely sure why it doesn't work or how to force it to. It might be a start, though. I'm still pretty new to Elgg myself.

     

  • @MagoMago 
    paste code
    click "html" and insert <pre> and </pre>

    <?php
    if(!defined('INC_DIR')) die('hacking attempt');


    // Start Elgg Engine

    $elgg_root_path = realpath(dirname(__FILE__) . '/var/www/') . '/';
    include($elgg_root_path . 'engine/start.php');

    global $CONFIG;
    /*
    // Profile meta data
    $elgguser = $_SESSION['user']->username;
    $elggprofilepic = '<img src="' . $CONFIG->wwwroot . 'mod/profile/icondirect.php?username=' . $profilename . '&size=medium">';
    $elggprofilelink = $CONFIG->wwwroot . 'pg/profile/' . $elgguser;
    */

    /* users_entity table
    Field Type Default Value
    guid bigint(20) Intet
    name text Intet
    username varchar(128)
    password varchar(32)
    salt varchar(8)
    email text Intet
    language varchar(6)
    code varchar(32)
    banned enum('yes','no') no
    last_action int(11) 0
    prev_last_action int(11) 0
    last_login int(11) 0
    prev_last_login int(11) 0
    */

    class ElggCMS {
    var $userid;
    var $loginStmt;
    var $getUserStmt;
    var $getUsersStmt;
    var $userName = true; // change to true for user_name instead of user_loginname
    //-----------------------------------------------------------------------------------------
    function ElggCMS(){

    $this->loginStmt = new Statement("SELECT guid AS id, banned FROM ".$CONFIG->dbprefix."users_entity WHERE username=? AND password=md5(?)");
    $this->getUserStmt = new Statement("SELECT guid as id, name as login FROM ".$CONFIG->dbprefix."users_entity WHERE guid=?");
    $this->getUsersStmt = new Statement("SELECT guid as id, name as login FROM ".$CONFIG->dbprefix."users_entity ORDER BY name");
    //$this->getPhotoStmt = new Statement("SELECT user_avatar FROM {$GLOBALS['table_prefix']}users WHERE user_id=? AND user_active<>0 LIMIT 1");
    }
    //-----------------------------------------------------------------------------------------

    // See if user is logged in. Works
    function isLoggedIn() {
    $userid=NULL;
    $userid = $_SESSION['user']->name;
    return $userid;
    }

    function getRoles($rec) {

    $roles = ROLE_USER;

    if(isadminloggedin()) {
    $roles = ROLE_ADMIN;
    }

    return $roles;
    }

    // performs user login using provided login and password, return logged in user id, otherwise returns null
    function login($login, $password) {


    // If all is present and correct, try to log in
    $result = false;
    if (!empty($username) && !empty($password)) {
    $persistent = false;
    if ($user = authenticate($username,$password)) {
    $result = login($user, $persistent);
    }
    if ($result == true) {
    return $_SESSION['user']->guid;
    } else {
    return NULL;
    }
    }


    }

    // performs logging out for actual user
    function logout(){
    $this->user = null;
    }

    // returns used data for provided user id. User data is an array like:
    // array(
    // 'id' => <user id>,
    // 'login' => <user login>,
    // 'roles'=> ROLE_USER for users, ROLE_ADMIN for admins, or ROLE_USER | ROLE_ADMIN if user has both roles
    // );
    // ROLE_USER and ROLE_ADMIN are constants defined in inc/common.php
    // returns null if such user is not found

    function getUser($userid) {

    global $fp;
    $rv = NULL;


    if($userid) {
    $rv['roles'] = getRoles($userid);
    $rv['id'] = $_SESSION['user']->guid;
    $rv['login'] = $_SESSION['user']->name;
    }
    return $rv;

    }

    function getUsers() {
    return $this->getUsersStmt->process();
    }

    // returns URL of user profile page for such user id or null if user not found
    function getUserProfile($userid) {
    return $CONFIG->wwwroot . 'pg/profile/' . $_SESSION['user']->username;
    }

    // checks user role
    function userInRole($userid, $role) {
    if($user = $this->getUser($userid)) {
    return ($user['roles'] == $role);
    }
    return false;
    }

    }

    $GLOBALS['fc_config']['db'] = array(
    'host' => $CONFIG->dbhost,
    'user' => $CONFIG->dbuser,
    'pass' => $CONFIG->dbpass,
    'base' => $CONFIG->dbname,
    'pref' => $CONFIG->dbprefix . 'fc_',
    );

    $GLOBALS['fc_config']['cms'] = new ElggCMS();

    foreach($GLOBALS['fc_config']['languages'] as $k => $v) {
    $GLOBALS['fc_config']['languages'][$k]['dialog']['login']['moderator'] = '';
    }
    ?>
  • I'm afraid I can't help you.

    I tried for a long time integrating flashchat, but gave up and used Ajax Chat instead.

    Much easier to integrate.

  • I would too, but I need the audio and webcam features.

  • @MagoX2

    Not give up hope yet ;-) *anything can be done with the right frame of mind and believe me here - we have coded minor code "miracles" before. If you want to pursue this elusive "Tufat Flashchat" - send me a PM and we take further detailed discussions offline until TuFat/Elgg  can become alive ;-)

  • @ Dhrup Thanks I'll try that out. If there's a way you could let me know how to post code I've a lot of code I'd like to share, but don't know what the code tags here are.

  • BAH! *laughs* So, it's html for the code. Cool. I shouldn't do these things when I'm tired. >.<

  • @Dhrup Will do. I sent you a message. It's still a learning process for me with Elgg, but it would be great to release this for everyone. I know that a lot of people like that flashchat because it's only a few dollars. But to have it with Elgg would be a dream come true.

  • Have there been any updates with integrating flash chat and ELGG? Did a search and this came up so I will keep looking but I do not see it in the MODS anywhere. I have to agree, the flexibility of FlashChat with Elgg would seem to be an ideal match.