private function load_version()
 {
     global $cache;
     $this->info = myfbconnect_info();
     $this->plugins = $cache->read('shade_plugins');
     $this->old_version = $this->plugins[$this->info['name']]['version'];
     $this->version = $this->info['version'];
 }
function myfbconnect_uninstall()
{
    global $db, $PL, $cache, $lang;
    if (!$lang->myfbconnect) {
        $lang->load('myfbconnect');
    }
    if (!file_exists(PLUGINLIBRARY)) {
        flash_message($lang->myfbconnect_pluginlibrary_missing, "error");
        admin_redirect("index.php?module=config-plugins");
    }
    $PL or (require_once PLUGINLIBRARY);
    // Drop settings
    $PL->settings_delete('myfbconnect');
    // Delete our columns
    $db->query("ALTER TABLE " . TABLE_PREFIX . "users DROP `fbavatar`, DROP `fbsex`, DROP `fbdetails`, DROP `fbbio`, DROP `fbbday`, DROP `fblocation`, DROP `myfb_uid`");
    // Delete the plugin from cache
    $info = myfbconnect_info();
    $shadePlugins = $cache->read('shade_plugins');
    unset($shadePlugins[$info['name']]);
    $cache->update('shade_plugins', $shadePlugins);
    $PL->templates_delete('myfbconnect');
    // Try to update templates
    require_once MYBB_ROOT . 'inc/adminfunctions_templates.php';
    find_replace_templatesets('header_welcomeblock_guest', '#' . preg_quote('&mdash; <a href="{$mybb->settings[\'bburl\']}/myfbconnect.php?action=login">{$lang->myfbconnect_login}</a>') . '#i', '');
}
function myfbconnect_update()
{
    global $mybb, $db, $cache, $lang;
    // Download report
    if ($mybb->input['export_id'] and $mybb->input['gid'] == myfbconnect_settings_gid()) {
        $plugin_info = myfbconnect_info();
        $xml = "<?xml version=\"1.0\" encoding=\"{$lang->settings['charset']}\"?" . ">\r\n";
        $xml .= "<report name=\"" . $plugin_info['name'] . "\" version=\"" . $plugin_info['version'] . "\">\r\n";
        $query = $db->simple_select('myfbconnect_reports', '*', 'id = ' . (int) $mybb->input['export_id']);
        while ($report = $db->fetch_array($query)) {
            foreach ($report as $k => $v) {
                $xml .= "\t\t<{$k}>{$v}</{$k}>\r\n";
            }
        }
        $xml .= "</report>";
        header("Content-disposition: attachment; filename=" . $plugin_info['name'] . "-report-" . $mybb->input['export_id'] . ".xml");
        header("Content-type: application/octet-stream");
        header("Content-Length: " . strlen($xml));
        header("Pragma: no-cache");
        header("Expires: 0");
        echo $xml;
        exit;
    }
    $file = MYBB_ROOT . "inc/plugins/MyFacebookConnect/class_update.php";
    if (file_exists($file)) {
        require_once $file;
    }
}