function asb_admin_xmlhttp() { global $db, $mybb; // if ordering (or trashing) if ($mybb->input['mode'] == 'order') { parse_str($mybb->input['data']); if ($mybb->input['pos'] == 'trash_column') { // if there is nothing in the column if (!is_array($trash_column) || empty($trash_column)) { exit; } // loop through them all $ids = array(); foreach ($trash_column as $id) { $sidebox = new Sidebox($id); $sidebox->remove(); // return the removed side boxes id to the Sidebox object (so that the div can be destroyed as well) $ids[] = $id; } asb_cache_has_changed(); $ids = implode(',', $ids); echo $ids; exit; } elseif ($mybb->input['pos'] == 'right_column') { $position = 1; $this_column = $right_column; } elseif ($mybb->input['pos'] == 'left_column') { $position = 0; $this_column = $left_column; } // if there are side boxes in this column after the move (this function is called by onUpdate) if (!is_array($this_column) || empty($this_column)) { return; } $disp_order = 1; // loop through all the side boxes in this column foreach ($this_column as $id) { $has_changed = false; $sidebox = new Sidebox($id); $this_order = (int) ($disp_order * 10); ++$disp_order; // if the order has been edited if ($sidebox->get('display_order') != $this_order) { // handle it $sidebox->set('display_order', $this_order); $has_changed = true; } // if the position has changed if ($sidebox->get('position') != $position) { // alter it $sidebox->set('position', $position); $has_changed = true; } // if the side box has been modified if ($has_changed != false) { // save it $sidebox->save(); asb_cache_has_changed(); } } } elseif ($mybb->input['mode'] == 'build_info' && (int) $mybb->input['id'] > 0) { $id = (int) $mybb->input['id']; $sidebox = new Sidebox($id); // we have to reaffirm our observance of the edit link when it is added/updated $script = <<<EOF <script type="text/javascript"> Event.observe('edit_sidebox_{$id}', 'click', function(event) { \t// stop the link from redirecting the user-- set up this way so that if JS is disabled the user goes to a standard form rather than a modal edit form \tEvent.stop(event); \t// create the modal edit box dialogue \tnew ASB.Modal({ \t\ttype: 'ajax', \t\turl: this.readAttribute('href') + '&ajax=1' \t}); }); </script> EOF; // this HTML output will be directly stored in the side box's representative <div> echo asb_build_sidebox_info($sidebox, false, true) . $script; } elseif ($mybb->input['mode'] == 'analyze_script' && trim($mybb->input['filename'])) { echo json_encode(asb_detect_script_info($mybb->input['filename'])); } }
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(); } }