admin_redirect("index.php?module=config-mysupport&action=support_denial&do=edit&drid={$drid}"); } $update = array("name" => $db->escape_string($mybb->input['name']), "description" => $db->escape_string($mybb->input['description'])); $db->update_query("mysupport", $update, "mid = '{$drid}'"); mysupport_cache("deniedreasons"); flash_message($lang->support_denial_reason_edited, 'success'); admin_redirect("index.php?module=config-mysupport&action=support_denial"); } elseif ($mybb->input['do'] == "do_delete") { if ($mybb->input['no']) { admin_redirect("index.php?module=config-mysupport&action=support_denial"); } else { $drid = intval($mybb->input['drid']); $update = array("deniedsupportreason" => 0); $db->update_query("users", $update, "deniedsupportreason = '{$drid}'"); $db->delete_query("mysupport", "mid = '{$drid}'"); mysupport_cache("deniedreasons"); flash_message($lang->support_denial_reason_deleted, 'success'); admin_redirect("index.php?module=config-mysupport&action=support_denial"); } } elseif ($mybb->input['do'] == "do_groups") { // reset the usergroup settings $update = array("canmanagesupportdenial" => 0); $db->update_query("usergroups", $update); $new_canmanagesupportdenial_groups = ""; if (empty($mybb->input['mysupport_canmanagesupportdenial'])) { $mybb->input['mysupport_canmanagesupportdenial'] = array(); } $new_canmanagesupportdenial_groups = implode(",", array_map("intval", $mybb->input['mysupport_canmanagesupportdenial'])); if (!empty($new_canmanagesupportdenial_groups)) { $update = array("canmanagesupportdenial" => 1); $db->update_query("usergroups", $update, "gid IN (" . $db->escape_string($new_canmanagesupportdenial_groups) . ")");
function mysupport_upgrade() { global $mybb, $db, $cache; $mysupport_cache = $cache->read("mysupport"); $old_version = $mysupport_cache['version']; // legacy if (!$old_version) { $old_version = $cache->read("mysupport_version"); } // only need to run through this if the version has actually changed if (!empty($old_version) && $old_version < MYSUPPORT_VERSION) { // reimport the settings to add any new ones and refresh the current ones mysupport_import_settings(); // remove the current templates, but only the master versions mysupport_do_templates(0, true); // re-import the master templates mysupport_do_templates(1); // add any new table columns that don't already exist mysupport_table_columns(1); mysupport_stylesheet(2); $deleted_settings = array(); $deleted_templates = array(); // go through each upgrade process; versions are only listed here if there were changes FROM that version to the next // it will go through the ones it needs to and make the changes it needs if ($old_version <= 0.3) { // made some mistakes with the original table column additions, 3 of the fields weren't long enough... I do apologise $db->modify_column("threads", "statusuid", "INT(10) NOT NULL DEFAULT '0'"); $db->modify_column("users", "deniedsupportreason", "INT(5) NOT NULL DEFAULT '0'"); $db->modify_column("users", "deniedsupportuid", "INT(10) NOT NULL DEFAULT '0'"); // maybe 255 isn't big enough for this after all $db->modify_column("mysupport", "description", "VARCHAR(500) NOT NULL"); } if ($old_version <= 0.4) { mysupport_insert_task(); mysupport_stylesheet(1); mysupport_recount_technical_threads(); $query = $db->simple_select("threads", "DISTINCT assign", "assign != '0'"); while ($user = $db->fetch_field($query, "assign")) { mysupport_recount_assigned_threads($user); } // there's just a 'mysupport' cache now with other things in it $db->delete_query("datacache", "title = 'mysupport_version'"); // cache priorities and support denial reasons mysupport_cache("priorities"); mysupport_cache("deniedreasons"); // we need to update the setting of what to log, to include putting threads on hold, but don't change which actions may have logging disabled if ($mybb->settings['mysupportmodlog']) { $mybb->settings['mysupportmodlog'] .= ","; } $mybb->settings['mysupportmodlog'] .= "12"; $update = array("value" => $db->escape_string($mybb->settings['mysupportmodlog'])); $db->update_query("settings", $update, "name = 'mysupportmodlog'"); rebuild_settings(); } if (!empty($deleted_settings)) { $deleted_settings = "'" . implode("','", array_map($db->escape_string, $deleted_settings)) . "'"; // have to use $db->escape_string above instead of around $deleted_settings directly because otherwise it escapes the ' around the names, which are important $db->delete_query("settings", "name IN ({$deleted_settings})"); mysupport_update_setting_orders(); rebuild_settings(); } if (!empty($deleted_templates)) { $deleted_templates = "'" . implode("','", array_map($db->escape_string, $deleted_templates)) . "'"; // have to use $db->escape_string above instead of around $deleted_templates directly because otherwise it escapes the ' around the names, which are important $db->delete_query("templates", "title IN ({$deleted_templates})"); } // now we can update the cache with the new version mysupport_cache("version"); // rebuild the forums and usergroups caches in case anything's changed $cache->update_forums(); $cache->update_usergroups(); } }