MyBB Community Forums

Full Version: Envolve chat integration with MyBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been chipping away at this problem for a while and have finally got it to work - I have no idea how to create a plugin for it or indeed whether it is the best way to do it.

For what it is worth this is how I did it:

First download and install this mod (make sure you are happy with the idea / risk of using php in templates! )

http://mybbhacks.zingaburga.com/xthreads...tpl-2.0.7z

Visit the Envolve site - https://www.envolve.com/ - and set up an account.
Download the PHP API library and FTP it to your forum root.

Use a text editor to create the following file, replacing API key with your key from the Envolve website, - name it envolve_login.php and FTP it to your forum root -

<?php
define("IN_MYBB",1);
require_once('./envolve_api_client.php');

if($mybb->usergroup['issupermod'])
{
$envolve_code = envapi_get_html_for_reg_user('API key', $mybb->user['username'], NULL, $mybb->user['avatar'], true, $mybb->user['usertitle']);
}
else
{
$envolve_code = envapi_get_html_for_reg_user('API key', $mybb->user['username'], NULL, $mybb->user['avatar'], false, $mybb->user['usertitle']);
}
?>


Finally, go to the templates in the Admin CP and insert the following code at the end of the footer template -

<?php
define("IN_MYBB",1);
require_once"envolve_login.php";
echo $envolve_code;
?>


That's it - you will now have envolve chat with single login on your forum and users will show up with the correct username, their avatar (if set) and their user title. Board admins will show up in the right colour and have mod rights.

The only reason I used the PHP plugin is because I have no idea how to pass variables from the .php files into the templates - if you can do this then there is no need for the PHP plugin.
goooooooooooooood..its working.... please tell me how to add avatar username? step by step

how to show chat bar register user only...
Ah - just reading another thread re the link between php & templates - I have started a plugin but need some HELP!

So far - code to be inserted at start of global.php - but how do I edit the footer template to add the variable $envolve_code ? and how do we do the activate/deactivate code for the acp - including setting for insertion of the API variable?

<?php
/**
* Envolve plugin 0.1
* Copyright 2013 Chris Betson
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook('global_start', 'envolve_plugin-code');

function envolve_plugin_info()
{
return array(
"name" => "Envolve plugin",
"description" => "Provides single sign on integration for Envolve chat in MyBB.",
"website" => "",
"author" => "ChrisBetson",
"authorsite" => "",
"version" => "0.1",
"compatibility" => "16*",
"guid" => ""
);
}

function envolve_plugin_code()
require_once('./envolve_api_client.php');
if($mybb->usergroup['issupermod'])
{
$envolve_code = envapi_get_html_for_reg_user($envolve_api, $mybb->user['username'], NULL, $mybb->user['avatar'], true, $mybb->user['usertitle']);
}
else
{
$envolve_code = envapi_get_html_for_reg_user($envolve_api, $mybb->user['username'], NULL, $mybb->user['avatar'], false, $mybb->user['usertitle']);
}
?>
please sir tell me step by step...im new
Cracked it finally - you need to turn off GZIP in the acp first though.

Have submitted it so you should have an Envolve plugin soon ....

<?php
//Disallow direct Initialization for extra security.
if(!defined("IN_MYBB"))
{
die("You Cannot Access This File Directly. Please Make Sure IN_MYBB Is Defined.");
}
//Add hook for code to be inserted at the start of global.php to generate $envolve_code for later insertion in the footer template.
$plugins->add_hook('global_start', 'envolve_code');
//Information
function envolve_info()
{
return array(
"name" => "Envolve plugin",
"description" => "Provides single sign on integration for Envolve chat in MyBB.",
"website" => "http://equus-online.co.uk",
"author" => "ChrisBetson",
"authorsite" => "http://equus-online.co.uk",
"version" => "0.1",
"compatibility" => "16*",
"guid" => "46c227c0e7a38344272ae0a63eb8a963",
);
}
//Activate
function envolve_activate()
{
global $db;
$envolve_group = array(
'gid' => 'NULL',
'name' => 'envolveplugin',
'title' => 'Envolve plugin settings',
'description' => 'Allows you to change the forum rules shown by the rules page plugin.',
'disporder' => '1',
'isdefault' => '0',
);
$db->insert_query('settinggroups', $envolve_group);
$gid = $db->insert_id();
$envolveapi = array(
'sid' => 'NULL',
'name' => 'envolveapi',
'title' => 'Envolve API',
'description' => 'Insert your Envolve API',
'optionscode' => 'textarea',
'value' => '',
'disporder' => '1',
'gid' => intval($gid),
);
$db->insert_query("settings", $envolveapi);
rebuild_settings();
}
//Deactivate
function envolve_deactivate()
{
global $db;
$db->delete_query("settinggroups", "name = 'envolveplugin'");
$db->delete_query('settings', 'name = "envolveapi"');
rebuild_settings();
}
//Generate the code using api key from Envolve and their API library for PHP envolve_api_client.php located in forum root
function envolve_code()
{
global $mybb;
require_once MYBB_ROOT."envolve_api_client.php";
$api_key = $mybb->settings['envolveapi'];
if($mybb->usergroup['issupermod'])
{
$envolve_code = envapi_get_html_for_reg_user($api_key, $mybb->user['username'], NULL, $mybb->user['avatar'], true, $mybb->user['usertitle']);
}
else
{
$envolve_code = envapi_get_html_for_reg_user($api_key, $mybb->user['username'], NULL, $mybb->user['avatar'], false, $mybb->user['usertitle']);
}
echo($envolve_code);
}
?>
I have tried your plugin and it seems to be functioning but it also gives several errors. Undecided

There was no readme file or instyructions on where to put your file. I put it in the plugins folder. Other than that I am pretty sure I have everything else correct.

I do not know a anything about chasing down these errors or how to resolve them. If you know what is wrong please let me know.
[Image: envolve_mybb_errors_zps10e95ebf.jpg]