$escaped_id = $db->escape_string($vbulletin->GPC['prefixsetid']); foreach ($new_forums as $forumid) { $add_forums_query[] = "({$forumid}, '{$escaped_id}')"; } if ($add_forums_query) { $db->query_write("\r\n\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "forumprefixset\r\n\t\t\t\t(forumid, prefixsetid)\r\n\t\t\tVALUES\r\n\t\t\t\t" . implode(',', $add_forums_query)); } // find the forums that were removed and remove these prefixes from threads $removed_forums = array_diff($old_forums, $new_forums); if ($removed_forums) { $prefixes = array(); $prefix_sql = $db->query_read("\r\n\t\t\tSELECT prefixid\r\n\t\t\tFROM " . TABLE_PREFIX . "prefix\r\n\t\t\tWHERE prefixsetid = '" . $db->escape_string($vbulletin->GPC['prefixsetid']) . "'\r\n\t\t"); while ($prefix = $db->fetch_array($prefix_sql)) { $prefixes[] = $prefix['prefixid']; } remove_prefixes_forum($prefixes, $removed_forums); } build_prefix_datastore(); define('CP_REDIRECT', 'prefix.php?do=list'); print_stop_message('prefix_set_saved'); } // ######################################################################## if ($_REQUEST['do'] == 'addset' or $_REQUEST['do'] == 'editset') { $vbulletin->input->clean_array_gpc('r', array('prefixsetid' => TYPE_NOHTML)); // fetch existing prefix set if we want to edit if ($vbulletin->GPC['prefixsetid']) { $prefixset = $db->query_first("\r\n\t\t\tSELECT *\r\n\t\t\tFROM " . TABLE_PREFIX . "prefixset\r\n\t\t\tWHERE prefixsetid = '" . $db->escape_string($vbulletin->GPC['prefixsetid']) . "'\r\n\t\t"); if ($prefixset) { $phrase = $db->query_first("\r\n\t\t\t\tSELECT text\r\n\t\t\t\tFROM " . TABLE_PREFIX . "phrase\r\n\t\t\t\tWHERE varname = '" . $db->escape_string("prefixset_{$prefixset['prefixsetid']}_title") . "'\r\n\t\t\t\t\tAND fieldname = 'prefix'\r\n\t\t\t\t\tAND languageid = 0\r\n\t\t\t"); $prefixset['title'] = $phrase['text']; }
/** * Additional data to update after a save call (such as denormalized values in other tables). * In batch updates, is executed for each record updated. * * @param boolean Do the query? */ function post_save_each($doquery = true) { // update phrase $db =& $this->registry->db; $vbulletin =& $this->registry; if (strval($this->info['title_plain']) !== '') { $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "phrase (languageid, fieldname, varname, text, product, username, dateline, version) VALUES ( 0, 'global', '" . $db->escape_string('prefix_' . $this->fetch_field('prefixid') . '_title_plain') . "', '" . $db->escape_string($this->info['title_plain']) . "', 'vbulletin', '" . $db->escape_string($vbulletin->userinfo['username']) . "', " . TIMENOW . ", '" . $db->escape_string($vbulletin->templateversion) . "' ) "); } if (strval($this->info['title_rich']) !== '') { $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "phrase (languageid, fieldname, varname, text, product, username, dateline, version) VALUES ( 0, 'global', '" . $db->escape_string('prefix_' . $this->fetch_field('prefixid') . '_title_rich') . "', '" . $db->escape_string($this->info['title_rich']) . "', 'vbulletin', '" . $db->escape_string($vbulletin->userinfo['username']) . "', " . TIMENOW . ", '" . $db->escape_string($vbulletin->templateversion) . "' ) "); } if (!empty($this->existing['prefixsetid']) AND $this->existing['prefixsetid'] != $this->fetch_field('prefixsetid')) { // updating the prefix set. We need to determine where we used // to be able to use this set but can't any more. $old_set = $this->existing['prefixsetid']; $new_set = $this->fetch_field('prefixsetid'); $allowed_forums = array( $old_set => array(), $new_set => array() ); // find all forums where the new and old sets are usable $allowed_forums_sql = $db->query_read(" SELECT prefixsetid, forumid FROM " . TABLE_PREFIX . "forumprefixset WHERE prefixsetid IN ( '" . $db->escape_string($old_set) . "', '" . $db->escape_string($new_set) . "' ) "); while ($allowed_forum = $db->fetch_array($allowed_forums_sql)) { $allowed_forums["$allowed_forum[prefixsetid]"][] = $allowed_forum['forumid']; } // remove this prefix from any threads in forums that were removed $removed_forums = array_diff($allowed_forums["$old_set"], $allowed_forums["$new_set"]); if ($removed_forums) { require_once(DIR . '/includes/adminfunctions_prefix.php'); remove_prefixes_forum($this->fetch_field('prefixid'), $removed_forums); } } require_once(DIR . '/includes/adminfunctions_language.php'); build_language(); require_once(DIR . '/includes/adminfunctions_prefix.php'); build_prefix_datastore(); ($hook = vBulletinHook::fetch_hook('prefixdata_postsave')) ? eval($hook) : false; }
/** * Additional data to update after a save call (such as denormalized values in other tables). * In batch updates, is executed for each record updated. * * @param boolean Do the query? */ function post_save_each($doquery = true) { // update phrase $db =& $this->registry->db; $vbulletin =& $this->registry; if (strval($this->info['title_plain']) !== '') { $db->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t\t\t(languageid, fieldname, varname, text, product, username, dateline, version)\n\t\t\t\tVALUES\n\t\t\t\t\t(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t'global',\n\t\t\t\t\t\t'" . $db->escape_string('prefix_' . $this->fetch_field('prefixid') . '_title_plain') . "',\n\t\t\t\t\t\t'" . $db->escape_string($this->info['title_plain']) . "',\n\t\t\t\t\t\t'vbulletin',\n\t\t\t\t\t\t'" . $db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t\t'" . $db->escape_string($vbulletin->templateversion) . "'\n\t\t\t\t\t)\n\t\t\t"); } if (strval($this->info['title_rich']) !== '') { $db->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t\t\t(languageid, fieldname, varname, text, product, username, dateline, version)\n\t\t\t\tVALUES\n\t\t\t\t\t(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t'global',\n\t\t\t\t\t\t'" . $db->escape_string('prefix_' . $this->fetch_field('prefixid') . '_title_rich') . "',\n\t\t\t\t\t\t'" . $db->escape_string($this->info['title_rich']) . "',\n\t\t\t\t\t\t'vbulletin',\n\t\t\t\t\t\t'" . $db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t\t'" . $db->escape_string($vbulletin->templateversion) . "'\n\t\t\t\t\t)\n\t\t\t"); } if (!empty($this->existing['prefixsetid']) and $this->existing['prefixsetid'] != $this->fetch_field('prefixsetid')) { // updating the prefix set. We need to determine where we used // to be able to use this set but can't any more. $old_set = $this->existing['prefixsetid']; $new_set = $this->fetch_field('prefixsetid'); $allowed_channels = array($old_set => array(), $new_set => array()); // find all forums where the new and old sets are usable $allowed_channels_sql = $db->query_read("\n\t\t\t\tSELECT prefixsetid, nodeid\n\t\t\t\tFROM " . TABLE_PREFIX . "channelprefixset\n\t\t\t\tWHERE prefixsetid IN (\n\t\t\t\t\t'" . $db->escape_string($old_set) . "',\n\t\t\t\t\t'" . $db->escape_string($new_set) . "'\n\t\t\t\t)\n\t\t\t"); while ($allowed_channel = $db->fetch_array($allowed_channels_sql)) { $allowed_channels["{$allowed_channel['prefixsetid']}"][] = $allowed_channel['nodeid']; } // remove this prefix from any threads in forums that were removed $removed_channels = array_diff($allowed_channels["{$old_set}"], $allowed_channels["{$new_set}"]); if ($removed_channels) { require_once DIR . '/includes/adminfunctions_prefix.php'; remove_prefixes_forum($this->fetch_field('prefixid'), $removed_channels); } } require_once DIR . '/includes/adminfunctions_language.php'; build_language(); require_once DIR . '/includes/adminfunctions_prefix.php'; build_prefix_datastore(); vB_Cache::instance()->event("vB_Language_languageCache"); // Legacy Hook 'prefixdata_postsave' Removed // }
$add_prefixsets = array(); foreach ($vbulletin->GPC['prefixset'] as $prefixsetid) { $add_prefixsets[] = '(' . $vbulletin->GPC['forumid'] . ", '" . $db->escape_string($prefixsetid) . "')"; } if ($add_prefixsets) { $db->query_write("\r\n\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "forumprefixset\r\n\t\t\t\t(forumid, prefixsetid)\r\n\t\t\tVALUES\r\n\t\t\t\t" . implode(',', $add_prefixsets)); } $removed_sets = array_diff($old_prefixsets, $vbulletin->GPC['prefixset']); if ($removed_sets) { $removed_sets = array_map(array(&$db, 'escape_string'), $removed_sets); $prefixes = array(); $prefix_sql = $db->query_read("\r\n\t\t\tSELECT prefixid\r\n\t\t\tFROM " . TABLE_PREFIX . "prefix\r\n\t\t\tWHERE prefixsetid IN ('" . implode("', '", $removed_sets) . "')\r\n\t\t"); while ($prefix = $db->fetch_array($prefix_sql)) { $prefixes[] = $prefix['prefixid']; } remove_prefixes_forum($prefixes, $vbulletin->GPC['forumid']); } require_once DIR . '/includes/adminfunctions_prefix.php'; build_prefix_datastore(); // rebuild ad templates for ads using the 'browsing a forum' criteria $ad_result = $db->query_read("\r\n\t\tSELECT ad.*\r\n\t\tFROM " . TABLE_PREFIX . "ad AS ad\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "adcriteria AS adcriteria ON(adcriteria.adid = ad.adid)\r\n\t\tWHERE (adcriteria.criteriaid = 'browsing_forum_x' OR adcriteria.criteriaid = 'browsing_forum_x_and_children')\r\n\t"); if ($db->num_rows($ad_result) > 0) { $ad_cache = array(); $ad_locations = array(); while ($ad = $db->fetch_array($ad_result)) { $ad_cache["{$ad['adid']}"] = $ad; $ad_locations[] = $ad['adlocation']; } require_once DIR . '/includes/functions_ad.php'; require_once DIR . '/includes/adminfunctions_template.php'; foreach ($ad_locations as $location) {
$escaped_id = $vbulletin->db->escape_string($vbulletin->GPC['prefixsetid']); foreach ($new_channels as $channelid) { $add_channels_query[] = "({$channelid}, '{$escaped_id}')"; } if ($add_channels_query) { $vbulletin->db->query_write("\n\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "channelprefixset\n\t\t\t\t(nodeid, prefixsetid)\n\t\t\tVALUES\n\t\t\t\t" . implode(',', $add_channels_query)); } // find the forums that were removed and remove these prefixes from threads $removed_channels = array_diff($old_channels, $new_channels); if ($removed_channels) { $prefixes = array(); $prefix_sql = $vbulletin->db->query_read("\n\t\t\tSELECT prefixid\n\t\t\tFROM " . TABLE_PREFIX . "prefix\n\t\t\tWHERE prefixsetid = '" . $vbulletin->db->escape_string($vbulletin->GPC['prefixsetid']) . "'\n\t\t"); while ($prefix = $vbulletin->db->fetch_array($prefix_sql)) { $prefixes[] = $prefix['prefixid']; } remove_prefixes_forum($prefixes, $removed_channels); } build_prefix_datastore(); print_stop_message2('prefix_set_saved', 'prefix', array('do' => 'list')); } // ######################################################################## if ($_REQUEST['do'] == 'addset' or $_REQUEST['do'] == 'editset') { $vbulletin->input->clean_array_gpc('r', array('prefixsetid' => vB_Cleaner::TYPE_NOHTML)); // fetch existing prefix set if we want to edit if ($vbulletin->GPC['prefixsetid']) { $prefixset = $vbulletin->db->query_first("\n\t\t\tSELECT *\n\t\t\tFROM " . TABLE_PREFIX . "prefixset\n\t\t\tWHERE prefixsetid = '" . $vbulletin->db->escape_string($vbulletin->GPC['prefixsetid']) . "'\n\t\t"); if ($prefixset) { $phrase = $vbulletin->db->query_first("\n\t\t\t\tSELECT text\n\t\t\t\tFROM " . TABLE_PREFIX . "phrase\n\t\t\t\tWHERE varname = '" . $vbulletin->db->escape_string("prefixset_{$prefixset['prefixsetid']}_title") . "'\n\t\t\t\t\tAND fieldname = 'prefix'\n\t\t\t\t\tAND languageid = 0\n\t\t\t"); $prefixset['title'] = $phrase['text']; } }