function asb_xmlhttp()
{
    global $mybb;
    if ($mybb->input['action'] != 'asb') {
        return;
    }
    // get the ASB core stuff
    require_once MYBB_ROOT . 'inc/plugins/asb/functions_addon.php';
    require_once MYBB_ROOT . 'inc/plugins/asb/classes/xmlhttp.php';
    // attempt to load the module and side box requested
    $module = new Addon_type($mybb->input['addon']);
    $sidebox = new Sidebox($mybb->input['id']);
    // we need both objects to continue
    if ($module->is_valid() && $sidebox->is_valid()) {
        // then call the module's AJAX method and echo its return value
        echo $module->do_xmlhttp($mybb->input['dateline'], $sidebox->get('settings'), $mybb->input['width'], $mybb->input['script']);
    }
    exit;
}
function asb_build_permissions_table($id)
{
    if (!$id) {
        return false;
    }
    global $lang, $all_scripts;
    $sidebox = new Sidebox($id);
    if (!$sidebox->is_valid()) {
        return $lang->asb_invalid_sidebox;
    }
    if (!$all_scripts) {
        return $lang->asb_no_active_scripts;
    }
    $visibility_rows = asb_build_visibility_rows($sidebox, $group_count, $global);
    $theme_list = asb_build_theme_visibility_list($sidebox, $group_count + 1, $global);
    return <<<EOF
<table width="100%" class="box_info">{$visibility_rows}{$theme_list}
</table>
EOF;
}
 protected function update_children()
 {
     global $db;
     // get all boxes of this type in use
     $module = $db->escape_string(strtolower($this->base_name));
     $query = $db->simple_select('asb_sideboxes', '*', "LOWER(box_type)='{$module}'");
     if ($db->num_rows($query) == 0) {
         // this module has no children so we are done
         return;
     }
     // loop through all the children
     while ($data = $db->fetch_array($query)) {
         // create a new Sidebox object from the data
         $sidebox = new Sidebox($data);
         if (!$sidebox->is_valid()) {
             // something went wrong and this box has no ID
             // if we continue, we'll be creating a side box when we save
             // so . . . don't ;)
             continue;
         }
         // retrieve the settings
         $sidebox_settings = $sidebox->get('settings');
         // unset any removed settings
         foreach ($sidebox_settings as $name => $setting) {
             if (!isset($this->settings[$name])) {
                 unset($sidebox_settings[$name]);
             }
         }
         // update any settings which are missing
         foreach ($this->settings as $name => $setting) {
             if (!isset($sidebox_settings[$name])) {
                 // new setting-- default value
                 $sidebox_settings[$name] = $this->settings[$name]['value'];
             }
         }
         // save the side box
         $sidebox->set('settings', $sidebox_settings);
         $sidebox->save();
     }
 }