/** * @see Form::save() */ public function save() { ACPForm::save(); // save $this->category->update($this->category->categoryName, 'profile', $this->category->categoryIconS, $this->category->categoryIconM, $this->showOrder); // update language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.category.' . $this->category->categoryName => $this->categoryName), 0, PACKAGE_ID, array('wcf.user.option.category.' . $this->category->categoryName => 1)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::validate() */ public function save() { AbstractForm::save(); // update $this->userOption->update($this->userOption->optionName, $this->categoryName, $this->optionType, $this->defaultValue, $this->validationPattern, $this->selectOptions, '', $this->required, $this->askDuringRegistration, $this->editable, $this->visible, $this->getOutputClass(), $this->searchable, $this->showOrder); // update languages variables require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.' . $this->userOption->optionName => $this->optionName, 'wcf.user.option.' . $this->userOption->optionName . '.description' => $this->optionDescription), 0, PACKAGE_ID, array('wcf.user.option.' . $this->userOption->optionName => 1, 'wcf.user.option.' . $this->userOption->optionName . '.description' => 1)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see Action::execute(); */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.help.canEditHelpItem'); // get help item $helpItem = new HelpItemEditor($this->helpItemID); if (!$helpItem->helpItemID) { throw new IllegalLinkException(); } // change language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.help.item.' . $helpItem->helpItem => $this->title), 0, PACKAGE_ID, array('wcf.help.item.' . $helpItem->helpItem => 1)); // reset cache WCF::getCache()->clearResource('help-' . PACKAGE_ID); $this->executed(); }
/** * @see Action::execute(); */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.board.canEditBoard'); // check board title if (StringUtil::encodeHTML($this->board->title) != WCF::getLanguage()->get(StringUtil::encodeHTML($this->board->title))) { // change language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($this->board->title => $this->title), 0, PACKAGE_ID, array($this->board->title => 1)); } else { // change title $this->board->updateData(array('title' => $this->title)); } // reset cache WCF::getCache()->clearResource('board'); $this->executed(); }
/** * @see Form::save() */ public function save() { parent::save(); // create random name $name = "userOptionCategory" . time(); // save $userOptionCategory = UserOptionCategoryEditor::create($name, 'profile', '', '', $this->showOrder); // change name $userOptionCategory->update('userOptionCategory' . $userOptionCategory->categoryID, 'profile', '', '', $this->showOrder); // save name as language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.category.' . 'userOptionCategory' . $userOptionCategory->categoryID => $this->categoryName)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // reset values $this->categoryName = ''; $this->showOrder = 0; // show success message WCF::getTPL()->assign('success', true); }
/** * @see Action::execute(); */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.pageMenu.canEditPageMenuItem'); // get menu item $menuItem = new PageMenuItemEditor($this->menuItemID); if (!$menuItem->menuItemID) { throw new IllegalLinkException(); } // check menu item title if (StringUtil::encodeHTML($menuItem->menuItem) != WCF::getLanguage()->get(StringUtil::encodeHTML($menuItem->menuItem))) { // change language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($menuItem->menuItem => $this->title), 0, PACKAGE_ID, array($menuItem->menuItem => 1)); } else { $menuItem->update($this->title, $menuItem->link, $menuItem->iconS, $menuItem->iconM, $menuItem->showOrder, $menuItem->position, $menuItem->languageID); } // reset cache WCF::getCache()->clearResource('menu-' . PACKAGE_ID); $this->executed(); }
/** * @see Form::save() */ public function save() { parent::save(); // create new language category $languageCategoryID = $this->languageCategoryID; if (!empty($this->newLanguageCategory)) { $languageCategoryID = LanguageEditor::createCategory($this->newLanguageCategory); // clear language cache WCF::getCache()->clearResource('languages'); } // save item values foreach (array_keys($this->languages) as $languageID) { $language = new LanguageEditor($languageID); $language->updateItems(array($this->languageItemName => isset($this->languageItemValues[$languageID]) ? $this->languageItemValues[$languageID] : ''), $languageCategoryID); } // reset values //$this->languageCategoryID = 0; $this->newLanguageCategory = $this->languageItemName = ''; $this->languageItemValues = array(); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::save() */ public function save() { parent::save(); $menuItemID = 0; // create dynamic page $item = DynamicPageEditor::create($this->title, $this->allowSpidersToIndexThisPage, $this->additionalHeadContent, $menuItemID, $this->isPublic, $this->isDefaultPage, $this->hostID); DynamicPageEditor::clearCache($item->pageID, $this->hostID); // create menu item if ($this->createMenuItem) { require_once WCF_DIR . 'lib/data/page/menu/PageMenuItemEditor.class.php'; // build language var $lang = 'wcf.header.menu.host' . $this->hostID . '.page' . $item->pageID; $title = empty($this->menuItemTitle) ? $this->title : $this->menuItemTitle; // create menu item $menuItem = PageMenuItemEditor::create($lang, 'index.php?page=CMS&pageID=' . $item->pageID, $this->menuItemIconS, $this->menuItemIconM, $this->menuItemSortOrder, $this->menuItemPosition); $menuItemID = $menuItem->menuItemID; // clear cache PageMenuItemEditor::clearCache(); // enable or disable entry $menuItem->enable($this->isPublic); // create language var require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; // save language variable $language = new LanguageEditor($this->host->languageID); $language->updateItems(array($lang => $title)); // include host require_once WCF_DIR . 'lib/data/host/Host.class.php'; // remove menu item ID cache Host::removeMenuItemIDCache(); } // update menu item id $item->menuItemID = $menuItemID; $item->update(); // write to property $this->newPage = $item; // send redirect headers HeaderUtil::redirect('index.php?form=DynamicPageEdit&pageID=' . $item->pageID . '&packageID=' . PACKAGE_ID . '&created=1' . SID_ARG_2ND_NOT_ENCODED); // call event $this->saved(); }
/** * @see Form::save() */ public function save() { parent::save(); // create random name $name = "userOption" . time(); // save option $this->optionID = UserOptionEditor::create($name, $this->categoryName, $this->optionType, $this->defaultValue, $this->validationPattern, $this->selectOptions, '', $this->required, $this->askDuringRegistration, $this->editable, $this->visible, $this->getOutputClass(), $this->searchable, $this->showOrder); // change random name $name = "userOption" . $this->optionID; WCF::getDB()->sendQuery("UPDATE\t\twcf" . WCF_N . "_user_option\n\t\t\t\t\tSET\t\toptionName = '{$name}'\n\t\t\t\t\tWHERE \t\toptionID = " . $this->optionID); // save language variables require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.' . $name => $this->optionName, 'wcf.user.option.' . $name . '.description' => $this->optionDescription)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // reset values $this->optionName = $this->optionDescription = $this->categoryName = $this->optionType = $this->defaultValue = $this->validationPattern = ''; $this->optionType = $this->selectOptions = ''; $this->required = $this->editable = $this->visible = $this->searchable = $this->showOrder = $this->askDuringRegistration = 0; // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::save() */ public function save() { ACPForm::save(); // read variables $this->page->title = $this->title; $this->page->allowSpidersToIndexThisPage = $this->allowSpidersToIndexThisPage; $this->page->additionalHeadContent = $this->additionalHeadContent; $this->page->isPublic = $this->isPublic; $this->page->isDefaultPage = $this->isDefaultPage; // update $this->page->update(); // handle isDefaultPage checkbox if ($this->isDefaultPage) { $sql = "UPDATE\r\n\t\t\t\t\t\twcf" . WCF_N . "_page\r\n\t\t\t\t\tSET\r\n\t\t\t\t\t\tisDefaultPage = 0\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tpageID NOT IN (" . $this->page->pageID . ")"; WCF::getDB()->sendQuery($sql); } DynamicPageEditor::clearCache($this->page->pageID, $this->page->hostID); if ($this->menuEntry !== null) { // create language variable name $lang = 'wcf.header.menu.host' . $this->page->hostID . '.page' . $this->pageID; // get menu entry title $title = empty($this->menuItemTitle) ? $this->title : $this->menuItemTitle; // update menu entry $this->menuEntry->update($lang, $this->menuEntry->menuItemLink, $this->menuItemIconS, $this->menuItemIconM, $this->menuItemSortOrder, $this->menuItemPosition); // enable or disable entry $this->menuEntry->enable($this->isPublic); // update language require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($lang => $title)); // clear cache PageMenuItemEditor::clearCache(); } if ($this->createMenuItem) { // build language var $lang = 'wcf.header.menu.host' . $this->page->hostID . '.page' . $item->pageID; $title = empty($this->menuItemTitle) ? $this->title : $this->menuItemTitle; // create menu item $menuItem = PageMenuItemEditor::create($lang, 'index.php?page=CMS&pageID=' . $this->pageID, $this->menuItemIconS, $this->menuItemIconM, $this->menuItemSortOrder, $this->menuItemPosition); $menuItemID = $menuItem->menuItemID; // clear cache PageMenuItemEditor::clearCache(); // create language var require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; // save language variable $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($lang => $title)); // include host require_once WCF_DIR . 'lib/data/host/Host.class.php'; // remove menu item ID cache Host::removeMenuItemIDCache(); } // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::save() */ public function save() { AbstractForm::save(); $this->showOrder = $this->getShowOrder($this->showOrder, $this->parentMenuItem, 'parentMenuItem'); if ($this->useiFrame) { $sql = "UPDATE wcf" . WCF_N . "_admin_tools_iframe SET\n\t\t\t\t\t\turl = '" . $this->menuItemLink . "',\n\t\t\t\t\t\twidth = '" . escapeString($this->iframeWidth) . "',\n\t\t\t\t\t\theight = '" . escapeString($this->iframeWidth) . "',\n\t\t\t\t\t\tborderWidth = '" . escapeString($this->borderWidth) . "',\n\t\t\t\t\t\tborderColor = '" . escapeString($this->borderColor) . "',\n\t\t\t\t\t\tborderStyle = '" . escapeString($this->borderStyle) . "'\n\t\t\t\t\t\tWHERE iframeID = " . $this->iframeID; WCF::getDB()->sendQuery($sql); $this->menuItemLink = 'index.php?page=AdminToolsiFrame&iFrameID=' . $this->iframeID; } if ($this->createLangVar) { $menuItemID = WCF::getDB()->getInsertID(); $name = 'wcf.acp.menu.menuItem' . $menuItemID; $value = $this->menuItem; $languages = WCF::getLanguage()->getAvailableLanguages(); foreach ($languages as $language) { $langEdit = new LanguageEditor($language['languageID']); $langEdit->updateItems(array($name => $value)); } } $sql = "SELECT menuItem FROM wcf" . WCF_N . "_acp_menu_item\n \t\t\tWHERE menuItemID=" . $this->menuItemID; $row = WCF::getDB()->getFirstRow($sql); if ($row['menuItem'] != $this->menuItem) { // relink children $sql = "UPDATE wcf" . WCF_N . "_acp_menu_item\n\t\t\t\tSET parentMenuItem='" . escapeString($this->menuItem) . "'\n\t\t\t\tWHERE parentMenuItem='" . $row['menuItem'] . "'"; WCF::getDB()->sendQuery($sql); } //update the item $sql = "UPDATE IGNORE wcf" . WCF_N . "_acp_menu_item SET\n\t\t\t\t menuItem = '" . escapeString($this->menuItem) . "',\n\t\t\t\t menuItemLink = '" . escapeString($this->menuItemLink) . "',\n\t\t\t\t menuItemIcon ='" . escapeString($this->menuItemIcon) . "',\n\t\t\t\t permissions ='" . escapeString($this->permissions) . "',\n\t\t\t\t showOrder = " . $this->showOrder . ",\n\t\t\t\t parentMenuItem = '" . escapeString($this->parentMenuItem) . "'\n\t\t\t\t WHERE menuItemID=" . $this->menuItemID; WCF::getDB()->sendQuery($sql); $this->menuItem = $this->menuItemLink = $this->menuItemIcon = $this->parentMenuItem = $this->iframeHeight = $this->iframeWidth = $this->borderWidth = $this->borderColor = $this->borderStyle = ''; $this->permissions = array(); $this->showOrder = 0; WCF::getCache()->clear(WCF_DIR . 'cache/', 'cache.menu-*'); $this->saved(); WCF::getTPL()->assign(array('success' => true)); }
/** * Searches in language items. * * @param string $search search query * @param string $replace * @param integer $languageID * @param boolean $useRegex * @param boolean $caseSensitive * @param boolean $searchVariableName * @return array results */ public static function search($search, $replace = null, $languageID = null, $useRegex = 0, $caseSensitive = 0, $searchVariableName = 0) { // get available language items $results = array(); $availableLanguageItems = array(); $sql = "SELECT\t\tlanguageItemID, languageItem, languageID\n\t\t\tFROM\t\twcf" . WCF_N . "_language_item language_item,\n\t\t\t\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tWHERE \t\tlanguage_item.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . PACKAGE_ID . "\n\t\t\t\t\t" . ($languageID !== null ? "AND languageID = " . $languageID : "") . "\n\t\t\tORDER BY\tpackage_dependency.priority"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $availableLanguageItems[$row['languageID']][$row['languageItem']] = $row['languageItemID']; } // get ids if (!count($availableLanguageItems)) { return $results; } $languageItemIDs = ''; foreach ($availableLanguageItems as $languageItems) { if (!empty($languageItemIDs)) { $languageItemIDs .= ','; } $languageItemIDs .= implode(',', $languageItems); } // build condition $searchCondition = ''; // case sensitive if ($caseSensitive) { $searchCondition .= 'BINARY '; } // search field if ($searchVariableName) { $searchCondition .= 'languageItem '; } else { $searchCondition .= 'languageItemValue '; } // regex if ($useRegex) { $searchCondition .= "REGEXP '" . escapeString($search) . "'"; } else { $searchCondition .= "LIKE '%" . addcslashes(escapeString($search), '_%') . "%'"; } if (!$searchVariableName) { $searchCondition .= ' OR ' . ($caseSensitive ? 'BINARY ' : '') . 'languageCustomItemValue '; // regex if ($useRegex) { $searchCondition .= "REGEXP '" . escapeString($search) . "'"; } else { $searchCondition .= "LIKE '%" . addcslashes(escapeString($search), '_%') . "%'"; } } // search $updatedItems = array(); $sql = "SELECT\t\tlanguageItemID, languageItem, languageID, languageCategoryID, languageItemValue, languageCustomItemValue\n\t\t\tFROM\t\twcf" . WCF_N . "_language_item\n\t\t\tWHERE\t\tlanguageItemID IN (" . $languageItemIDs . ")\n\t\t\t\t\tAND (" . $searchCondition . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if ($replace !== null) { // search and replace $matches = 0; if ($useRegex) { $newValue = preg_replace('/' . $search . '/s' . (!$caseSensitive ? 'i' : ''), $replace, $row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue'], -1, $matches); } else { if ($caseSensitive) { $newValue = StringUtil::replace($search, $replace, $row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue'], $matches); } else { $newValue = StringUtil::replaceIgnoreCase($search, $replace, $row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue'], $matches); } } if ($matches > 0) { // update value if (!isset($updatedItems[$row['languageID']])) { $updatedItems[$row['languageID']] = array(); } if (!isset($updatedItems[$row['languageID']][$row['languageCategoryID']])) { $updatedItems[$row['languageID']][$row['languageCategoryID']] = array(); } $updatedItems[$row['languageID']][$row['languageCategoryID']][$row['languageItem']] = $newValue; // save matches $row['matches'] = $matches; } } $results[] = $row; } // save updates if (count($updatedItems) > 0) { foreach ($updatedItems as $languageID => $categories) { $language = new LanguageEditor($languageID); foreach ($categories as $categoryID => $items) { $useCustom = array(); foreach (array_keys($items) as $item) { $useCustom[$item] = 1; } $language->updateItems($items, $categoryID, PACKAGE_ID, $useCustom); } } } return $results; }
/** * Updates this help item. * * @param string $name * @param string $text * @param string $parentItem * @param string $refererPattern * @param integer $showOrder * @param boolean $isDisabled * @param integer $languageID * @param integer $packageID */ public function update($name, $text = '', $parentItem = '', $refererPattern = '', $showOrder = 0, $isDisabled = 0, $languageID = 0, $packageID = PACKAGE_ID) { if ($parentItem == $this->helpItem) { $parentItem = $this->parentHelpItem; } // update show order if ($parentItem == $this->parentHelpItem) { if ($this->showOrder != $showOrder) { if ($showOrder < $this->showOrder) { $sql = "UPDATE\twcf" . WCF_N . "_help_item\n\t\t\t\t\t\tSET \tshowOrder = showOrder + 1\n\t\t\t\t\t\tWHERE \tshowOrder >= " . $showOrder . "\n\t\t\t\t\t\t\tAND showOrder < " . $this->showOrder . "\n\t\t\t\t\t\t\tAND parentHelpItem = '" . escapeString($parentItem) . "'"; WCF::getDB()->sendQuery($sql); } else { if ($showOrder > $this->showOrder) { $sql = "UPDATE\twcf" . WCF_N . "_help_item\n\t\t\t\t\t\tSET\tshowOrder = showOrder - 1\n\t\t\t\t\t\tWHERE\tshowOrder <= " . $showOrder . "\n\t\t\t\t\t\t\tAND showOrder > " . $this->showOrder . "\n\t\t\t\t\t\t\tAND parentHelpItem = '" . escapeString($parentItem) . "'"; WCF::getDB()->sendQuery($sql); } } } } else { $sql = "UPDATE\twcf" . WCF_N . "_help_item\n\t\t\t\tSET \tshowOrder = showOrder - 1\n\t\t\t\tWHERE \tshowOrder >= " . $this->showOrder . "\n\t\t\t\t\tAND parentHelpItem = '" . escapeString($this->parentHelpItem) . "'"; WCF::getDB()->sendQuery($sql); $sql = "UPDATE \twcf" . WCF_N . "_help_item\n\t\t\t\tSET \tshowOrder = showOrder + 1\n\t\t\t\tWHERE \tshowOrder >= " . $showOrder . "\n\t\t\t\t\tAND parentHelpItem = '" . escapeString($parentItem) . "'"; WCF::getDB()->sendQuery($sql); } // Update $sql = "UPDATE\twcf" . WCF_N . "_help_item\n\t\t\tSET\t" . ($languageID == 0 ? "helpItem = '" . escapeString($name) . "'," : '') . "\n\t\t\t\tparentHelpItem = '" . escapeString($parentItem) . "',\n\t\t\t\trefererPattern = '" . escapeString($refererPattern) . "',\n\t\t\t\tshowOrder = " . $showOrder . ",\n\t\t\t\tisDisabled = " . $isDisabled . "\n\t\t\tWHERE \thelpItemID = " . $this->helpItemID . ";"; WCF::getDB()->sendQuery($sql); if ($languageID != 0) { // save language variables $language = new LanguageEditor($languageID); $language->updateItems(array('wcf.help.item.' . $this->helpItem => $name, 'wcf.help.item.' . $this->helpItem . '.description' => $text), 0, $this->packageID, array('wcf.help.item.' . $this->helpItem => 1, 'wcf.help.item.' . $this->helpItem . '.description' => 1)); LanguageEditor::deleteLanguageFiles($languageID, 'wcf.help.item'); $language->deleteCompiledTemplates(); } }
/** * @see Form::save() */ public function save() { parent::save(); $this->showOrder = $this->getShowOrder($this->showOrder, $this->parentMenuItem, 'parentMenuItem'); $iframeID = 0; // save iframe if ($this->useiFrame) { $sql = "INSERT INTO wcf" . WCF_N . "_admin_tools_iframe (url, width, height, borderWidth, borderColor, borderStyle)\n\t\t\t\t\tVALUES\t('" . escapeString($this->menuItemLink) . "',\n\t\t\t\t\t\t\t '" . escapeString($this->iframeWidth) . "',\n\t\t\t\t\t\t\t '" . escapeString($this->iframeHeight) . "',\n\t\t\t\t\t\t\t '" . escapeString($this->borderWidth) . "',\n\t\t\t\t\t\t\t '" . escapeString($this->borderColor) . "',\n\t\t\t\t\t\t\t '" . escapeString($this->borderStyle) . "')"; WCF::getDB()->sendQuery($sql); $iframeID = WCF::getDB()->getInsertID(); $this->menuItemLink = 'index.php?page=AdminToolsiFrame&iFrameID=' . $iframeID; } // create menu item $sql = "INSERT INTO wcf" . WCF_N . "_acp_menu_item (packageID, menuItem, menuItemLink, menuItemIcon, permissions, showOrder, parentMenuItem)\n\t\t\t\tVALUES\t(1,\n\t\t\t\t '" . escapeString($this->menuItem) . "',\n\t\t\t\t '" . escapeString($this->menuItemLink) . "',\n\t\t\t\t '" . escapeString($this->menuItemIcon) . "',\n\t\t\t\t '" . escapeString($this->permissions) . "',\n\t\t\t\t " . $this->showOrder . ",\t\t\t\t \n\t\t\t\t '" . escapeString($this->parentMenuItem) . "')"; WCF::getDB()->sendQuery($sql); if ($this->useiFrame) { $sql = "UPDATE wcf" . WCF_N . "_admin_tools_iframe SET menuItemID = " . WCF::getDB()->getInsertID() . " WHERE iframeID = " . $iframeID; WCF::getDB()->sendQuery($sql); } // create language variable if necessary if ($this->createLangVar) { $menuItemID = WCF::getDB()->getInsertID(); $name = 'wcf.acp.menu.menuItem' . $menuItemID; $value = $this->menuItem; $languages = WCF::getLanguage()->getAvailableLanguages(); foreach ($languages as $language) { $langEdit = new LanguageEditor($language['languageID']); $langEdit->updateItems(array($name => $value)); } $sql = "UPDATE wcf" . WCF_N . "_acp_menu_item\n\t\t\t\t\t\t\tSET menuItem = '" . escapeString($name) . "'\n\t\t\t\t\t\t\tWHERE menuItemID = " . $menuItemID; WCF::getDB()->sendQuery($sql); } // reset values $this->menuItem = $this->menuItemLink = $this->menuItemIcon = $this->parentMenuItem = $this->iframeHeight = $this->iframeWidth = $this->borderWidth = $this->borderColor = $this->borderStyle = ''; $this->permissions = array(); $this->showOrder = 0; WCF::getCache()->clear(WCF_DIR . 'cache/', 'cache.menu-*'); $this->saved(); WCF::getTPL()->assign(array('success' => true)); }
/** * Updates this page menu item. * * @param string $name * @param string $link * @param string $iconS * @param string $iconM * @param integer $showOrder * @param string $position * @param integer $languageID */ public function update($name, $link, $iconS = '', $iconM = '', $showOrder = 0, $position = 'header', $languageID = 0) { if ($position == $this->menuPosition) { if ($this->showOrder != $showOrder) { if ($showOrder < $this->showOrder) { $sql = "UPDATE\twcf" . WCF_N . "_page_menu_item\r\n\t\t\t\t\t\tSET \tshowOrder = showOrder + 1\r\n\t\t\t\t\t\tWHERE \tshowOrder >= " . $showOrder . "\r\n\t\t\t\t\t\t\tAND showOrder < " . $this->showOrder . "\r\n\t\t\t\t\t\t\tAND menuPosition = '" . escapeString($position) . "'"; WCF::getDB()->sendQuery($sql); } else { if ($showOrder > $this->showOrder) { $sql = "UPDATE\twcf" . WCF_N . "_page_menu_item\r\n\t\t\t\t\t\tSET\tshowOrder = showOrder - 1\r\n\t\t\t\t\t\tWHERE\tshowOrder <= " . $showOrder . "\r\n\t\t\t\t\t\t\tAND showOrder > " . $this->showOrder . "\r\n\t\t\t\t\t\t\tAND menuPosition = '" . escapeString($position) . "'"; WCF::getDB()->sendQuery($sql); } } } } else { $sql = "UPDATE\twcf" . WCF_N . "_page_menu_item\r\n\t\t\t\tSET \tshowOrder = showOrder - 1\r\n\t\t\t\tWHERE \tshowOrder >= " . $this->showOrder . "\r\n\t\t\t\t\tAND menuPosition = '" . escapeString($this->menuPosition) . "'"; WCF::getDB()->sendQuery($sql); $sql = "UPDATE \twcf" . WCF_N . "_page_menu_item\r\n\t\t\t\tSET \tshowOrder = showOrder + 1\r\n\t\t\t\tWHERE \tshowOrder >= " . $showOrder . "\r\n\t\t\t\t\tAND menuPosition = '" . escapeString($position) . "'"; WCF::getDB()->sendQuery($sql); } // Update $sql = "UPDATE\twcf" . WCF_N . "_page_menu_item\n\t\t\tSET\t" . ($languageID == 0 ? "menuItem = '" . escapeString($name) . "'," : '') . "\n\t\t\t\tmenuItemlink\t= '" . escapeString($link) . "',\r\n\t\t\t\tmenuItemIconS \t= '" . escapeString($iconS) . "',\r\n\t\t\t\tmenuItemIconM \t= '" . escapeString($iconM) . "',\r\n\t\t\t\tmenuPosition\t= '" . escapeString($position) . "',\r\n\t\t\t\tshowOrder \t= " . $showOrder . "\n\t\t\tWHERE \tmenuItemID \t= " . $this->menuItemID; WCF::getDB()->sendQuery($sql); if ($languageID != 0) { // save language variables $language = new LanguageEditor($languageID); $language->updateItems(array($this->menuItem => $name), 0, PACKAGE_ID, array($this->menuItem => 1)); } }