if ($savetype != 'new') { } $stylevardata->set('value', $svdata); $stylevardata->set('dateline', TIMENOW); $stylevardata->set('username', $vbulletin->userinfo['username']); $stylevardata->save(true, true, $savetype != 'new'); $addon = $vbulletin->GPC['dostyleid'] == -2 ? '_mobile' : ''; $mastertype = $vbulletin->GPC['dostyleid'] == -2 ? 'standard' : 'mobile'; // Insert the friendly name into phrase $vbulletin->db->query_write("\n\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t(languageid, varname, text, product, fieldname, username, dateline, version)\n\t\tVALUES (\n\t\t\t-1,\n\t\t\t'stylevar_{$stylevarid}_name{$addon}',\n\t\t\t'" . $vbulletin->db->escape_string($vbulletin->GPC['svfriendlyname']) . "',\n\t\t\t'{$productid}',\n\t\t\t'style',\n\t\t\t'" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t" . TIMENOW . ",\n\t\t\t'" . $vbulletin->db->escape_string($vbulletin->options['templateversion']) . "'\n\t\t),\n\t\t(\n\t\t\t-1,\n\t\t\t'stylevar_{$stylevarid}_description{$addon}',\n\t\t\t'" . $vbulletin->db->escape_string($vbulletin->GPC['svdescription']) . "',\n\t\t\t'{$productid}',\n\t\t\t'style',\n\t\t\t'" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t" . TIMENOW . ",\n\t\t\t'" . $vbulletin->db->escape_string($vbulletin->options['templateversion']) . "'\n\t\t)\t\t\n\t"); // Move any translations to the correct product. // If the stylevar has changed name this will miss them, but they will get caught later $vbulletin->db->query_write("\n\t\tUPDATE " . TABLE_PREFIX . "phrase\n\t\tSET\n\t\t\tproduct = '{$productid}'\n\t\tWHERE\n\t\t\t(\n\t\t\t\tvarname = 'stylevar_{$stylevarid}_name{$addon}' \n\t\t\t\t\tOR\n\t\t\t\tvarname = 'stylevar_{$stylevarid}_description{$addon}')\n\t\t\tAND\n\t\t\t\tlanguageid > 0\n\t"); if (defined('DEV_AUTOEXPORT') and DEV_AUTOEXPORT and $vbulletin->GPC['styleid'] == -1) { require_once DIR . '/includes/functions_filesystemxml.php'; autoexport_write_style_and_language($vbulletin->GPC['dostyleid'], array($stylevar_dfn['product'], $vbulletin->GPC['product'])); } define('CP_REDIRECT', 'stylevar.php?do=fetchstylevareditor&dostyleid=' . $vbulletin->GPC['dostyleid'] . '&stylevarid[]=' . $vbulletin->GPC['stylevarid']); if ($savetype != 'change') { // Rebuild languages if we are exiting now. require_once DIR . '/includes/adminfunctions_language.php'; build_language(); print_stop_message('saved_stylevardfn_x_successfully', $stylevarid); } // Update any translations to the new stylevar name & product $vbulletin->db->query_write("\n\t\tUPDATE " . TABLE_PREFIX . "phrase\n\t\tSET varname = 'stylevar_{$stylevarid}_name{$addon}', product = '{$productid}'\n\t\tWHERE varname = 'stylevar_{$oldsvid}_name{$addon}' AND languageid > 0\n\t"); $vbulletin->db->query_write("\n\t\tUPDATE " . TABLE_PREFIX . "phrase\n\t\tSET varname = 'stylevar_{$stylevarid}_description{$addon}', product = '{$productid}'\n\t\tWHERE varname = 'stylevar_{$oldsvid}_description{$addon}' AND languageid > 0\n\t"); // Update any custom values to the new stylevar name $vbulletin->db->query_write("\n\t\tUPDATE " . TABLE_PREFIX . "stylevar AS stylevar, " . TABLE_PREFIX . "style AS style\n\t\tSET stylevar.stylevarid = '{$stylevarid}'\n\t\tWHERE\n\t\t\tstyle.styleid = stylevar.styleid\n\t\t\t\tAND\n\t\t\tstylevar.stylevarid = '{$oldsvid}'\n\t\t\t\tAND\n\t\t\tstyle.styleid > 0\n\t\t\t\tAND\n\t\t\tstyle.type = '{$mastertype}'\n\t"); // Delete old stylevar (Re-use code below) $_POST['do'] = 'dosvdelete';
//a filesystem xml change, but an obvious bug. $stylevarinfo = $assertor->getRow('vBForum:stylevardfn', array('stylevarid' => $vbulletin->GPC['stylevarid'])); $assertor->delete('vBForum:stylevar', array('stylevarid' => $vbulletin->GPC['stylevarid'])); $assertor->delete('vBForum:stylevardfn', array('stylevarid' => $vbulletin->GPC['stylevarid'])); if (!$stylevarinfo['product']) { $product = array('', 'vbulletin'); } else { $product = array($stylevarinfo['product']); } vB::getDbAssertor()->assertQuery('vBForum:phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'varname', 'value' => array("stylevar_" . $vbulletin->GPC['stylevarid'] . "_name", "stylevar_" . $vbulletin->GPC['stylevarid'] . "_description"), vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ), array('field' => 'fieldname', 'value' => 'style', vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ), array('field' => 'product', 'value' => $product, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ)))); // rebuild languages require_once DIR . '/includes/adminfunctions_language.php'; build_language(-1); if (defined('DEV_AUTOEXPORT') and DEV_AUTOEXPORT) { require_once DIR . '/includes/functions_filesystemxml.php'; autoexport_write_style_and_language($vbulletin->GPC['dostyleid'], $stylevarinfo['product']); } vB_Library::instance('Style')->setCssDate(); print_rebuild_style($vbulletin->GPC['dostyleid']); print_stop_message2(array('reverted_stylevar_x_successfully', $vbulletin->GPC['stylevarid']), 'stylevar', array('dostyleid' => $vbulletin->GPC['dostyleid'])); } else { $assertor->delete('vBForum:stylevar', array('stylevarid' => $vbulletin->GPC['stylevarid'], 'styleid' => intval($vbulletin->GPC['dostyleid']))); print_rebuild_style($vbulletin->GPC['dostyleid']); print_stop_message2(array('reverted_stylevar_x_successfully', $vbulletin->GPC['stylevarid']), 'stylevar', array('dostyleid' => $vbulletin->GPC['dostyleid'], 'do' => 'fetchstylevareditor', 'stylevarid[]' => $vbulletin->GPC['stylevarid'])); } } // ######################################################################## if ($_POST['do'] == 'savestylevar') { // $_POST['stylevar'] is an array of one or more stylevars to save. The key is the // stylevarid (a string) and the value is either an array of stylevar data or a // string of stylevar data.