Esempio n. 1
0
function asb_admin_delete_box()
{
    global $mybb, $lang, $html;
    if ((int) $mybb->input['id'] == 0) {
        flash_message($lang->asb_delete_box_failure, 'error');
        admin_redirect($html->url());
    }
    $sidebox = new Sidebox($mybb->input['id']);
    if (!$sidebox->remove()) {
        flash_message($lang->asb_delete_box_failure, 'error');
    } else {
        flash_message($lang->asb_delete_box_success, 'success');
        asb_cache_has_changed();
    }
    admin_redirect($html->url());
}
function asb_get_all_sideboxes($good_script = '')
{
    global $db;
    // get any side boxes
    $return_array = array();
    $query = $db->simple_select('asb_sideboxes', '*', '', array("order_by" => 'display_order', "order_dir" => 'ASC'));
    if ($db->num_rows($query) > 0) {
        while ($data = $db->fetch_array($query)) {
            $sidebox = new Sidebox($data);
            if ($good_script) {
                $scripts = $sidebox->get('scripts');
                if (!empty($scripts) && !in_array($good_script, $scripts)) {
                    continue;
                }
            }
            // create the object and build basic data
            $return_array[$data['id']] = $sidebox;
        }
    }
    return $return_array;
}
Esempio n. 3
0
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;
}
Esempio n. 5
0
 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();
     }
 }