function createCategory($catOptions) { global $smcFunc; // Check required values. if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { trigger_error('createCategory(): A category name is required', E_USER_ERROR); } // Set default values. if (!isset($catOptions['move_after'])) { $catOptions['move_after'] = 0; } if (!isset($catOptions['is_collapsible'])) { $catOptions['is_collapsible'] = true; } // Don't log an edit right after. $catOptions['dont_log'] = true; // Add the category to the database. $smcFunc['db_insert']('', '{db_prefix}categories', array('name' => 'string-48'), array($catOptions['cat_name']), array('id_cat')); // Grab the new category ID. $category_id = $smcFunc['db_insert_id']('{db_prefix}categories', 'id_cat'); // Set the given properties to the newly created category. modifyCategory($category_id, $catOptions); logAction('add_cat', array('catname' => $catOptions['cat_name']), 'admin'); // Return the database ID of the category. return $category_id; }
$history = ''; $errorMessage = _t('슬래시가 들어간 카테고리 이름은 사용할 수 없습니다'); /*} elseif ((!empty($_POST['newCategory']) && strpos($_POST['newCategory'], '&') !== false) || (!empty($_POST['modifyCategoryName']) && strpos($_POST['modifyCategoryName'], '&') !== false)) { $history = ''; $errorMessage = _t('앰퍼샌드(&)가 들어간 카테고리 이름은 사용할 수 없습니다');*/ } elseif (!empty($_POST['newCategory']) && strpos($_POST['newCategory'], '?') !== false || !empty($_POST['modifyCategoryName']) && strpos($_POST['modifyCategoryName'], '?') !== false) { $history = ''; $errorMessage = _t('물음표가 들어간 카테고리 이름은 사용할 수 없습니다'); } elseif (!empty($_POST['newCategory'])) { $history = addCategory($blogid, $selected == 0 ? null : $_POST['id'], trim($_POST['newCategory'])) ? 'document.getElementById("newCategory").select();' : ''; if (empty($history)) { $errorMessage = _t('같은 이름의 카테고리가 이미 존재합니다'); } } else { if (!empty($_POST['modifyCategoryName']) || !empty($_POST['modifyCategoryBodyId'])) { $history = modifyCategory($blogid, $_POST['id'], trim($_POST['modifyCategoryName']), trim($_POST['modifyCategoryBodyId'])) ? 'document.getElementById("modifyCategoryName").select();' : ''; $tempParentId = POD::queryCell("SELECT `parent` FROM `{$database['prefix']}Categories` WHERE `id` = {$_POST['id']} AND `blogid` = " . getBlogId()); if (preg_match('/^[0-9]+$/', $tempParentId, $temp)) { $depth = 2; } else { $depth = 1; } } else { $history = ''; } } $categories = getCategories($blogid); $name = getCategoryNameById($blogid, $selected) ? getCategoryNameById($blogid, $selected) : _t('전체'); $bodyid = getCategoryBodyIdById($blogid, $selected); if (empty($_POST['search']) || $searchColumn === true) { $searchParam = true;
function EditCategory2() { global $db_prefix, $sourcedir; checkSession(); require_once $sourcedir . '/Subs-Boards.php'; $_POST['cat'] = (int) $_POST['cat']; // Add a new category or modify an existing one.. if (isset($_POST['edit']) || isset($_POST['add'])) { $catOptions = array(); if (isset($_POST['cat_order'])) { $catOptions['move_after'] = (int) $_POST['cat_order']; } // Change "This & That" to "This & That" but don't change "¢" to "¢"... $catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $_POST['cat_name']); $catOptions['is_collapsible'] = isset($_POST['collapse']); if (isset($_POST['add'])) { createCategory($catOptions); } else { modifyCategory($_POST['cat'], $catOptions); } } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) { EditCategory(); return; } elseif (isset($_POST['delete'])) { // First off - check if we are moving all the current boards first - before we start deleting! if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) { if (empty($_POST['cat_to'])) { fatal_lang_error('mboards_delete_error'); } deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); } else { deleteCategories(array($_POST['cat'])); } } redirectexit('action=manageboards'); }
<?php require_once '../../library/config.php'; require_once '../library/functions.php'; checkUser(); $action = isset($_GET['action']) ? $_GET['action'] : ''; switch ($action) { case 'add': addCategory(); break; case 'modify': modifyCategory(); break; case 'delete': deleteCategory(); break; case 'deleteImage': deleteImage(); break; default: // if action is not defined or unknown // move to main category page header('Location: index.php'); } /* Add a category */ function addCategory() { // $catId = $_POST['cboCategory']; $name = $_POST['txtName'];
/** * Create a new category. * general function to create a new category and set its position. * allows (almost) the same options as the modifyCat() function. * returns the ID of the newly created category. * * @param mixed[] $catOptions */ function createCategory($catOptions) { $db = database(); // Check required values. if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { trigger_error('createCategory(): A category name is required', E_USER_ERROR); } // Set default values. if (!isset($catOptions['move_after'])) { $catOptions['move_after'] = 0; } if (!isset($catOptions['is_collapsible'])) { $catOptions['is_collapsible'] = true; } // Don't log an edit right after. $catOptions['dont_log'] = true; $cat_columns = array('name' => 'string-48'); $cat_parameters = array($catOptions['cat_name']); call_integration_hook('integrate_create_category', array(&$catOptions, &$cat_columns, &$cat_parameters)); // Add the category to the database. $db->insert('', '{db_prefix}categories', $cat_columns, $cat_parameters, array('id_cat')); // Grab the new category ID. $category_id = $db->insert_id('{db_prefix}categories', 'id_cat'); // Set the given properties to the newly created category. modifyCategory($category_id, $catOptions); logAction('add_cat', array('catname' => $catOptions['cat_name']), 'admin'); // Return the database ID of the category. return $category_id; }
function createCategory($catOptions) { global $db_prefix; // Check required values. if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { trigger_error('createCategory(): A category name is required', E_USER_ERROR); } // Set default values. if (!isset($catOptions['move_after'])) { $catOptions['move_after'] = 0; } if (!isset($catOptions['is_collapsible'])) { $catOptions['is_collapsible'] = true; } // Add the category to the database. db_query("\n\t\tINSERT INTO {$db_prefix}categories\n\t\t\t(name)\n\t\tVALUES (SUBSTRING('{$catOptions['cat_name']}', 1, 48))", __FILE__, __LINE__); // Grab the new category ID. $category_id = db_insert_id(); // Set the given properties to the newly created category. modifyCategory($category_id, $catOptions); // Return the database ID of the category. return $category_id; }
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ include '../../../mainfile.php'; include sprintf('%s/include/cp_header.php', XOOPS_ROOT_PATH); include_once sprintf('%s/modules/%s/header.php', XOOPS_ROOT_PATH, $xoopsModule->dirname()); include 'admin.inc.php'; include_once sprintf('%s/class/xoopstree.php', XOOPS_ROOT_PATH); $myts =& MyTextSanitizer::getInstance(); $mytree = new XoopsTree($xoopsDB->prefix($mydirname . '_category'), 'cat_id', 'cat_pid'); $action = isset($_POST['action']) ? $_POST['action'] : ""; $action = isset($_GET['action']) ? $_GET['action'] : $action; switch ($action) { case "modCat": modifyCategory($_POST); break; case "modCatS": modifyCategoryS($_POST); break; case "modCatall": modifyCategoryAll(); break; case "addCat": addCategory($_POST); break; case "delCat": delCategory($_POST, $_GET); break; default: catManager();
/** * Function for handling a submitted form saving the category. * * What it does: * - complete the modifications to a specific category. * - It also handles deletion of a category. * - It requires manage_boards permission. * - Called by ?action=admin;area=manageboards;sa=cat2 * - Redirects to ?action=admin;area=manageboards. */ public function action_cat2() { checkSession(); validateToken('admin-bc-' . $_REQUEST['cat']); require_once SUBSDIR . '/Categories.subs.php'; $_POST['cat'] = (int) $_POST['cat']; // Add a new category or modify an existing one.. if (isset($_POST['edit']) || isset($_POST['add'])) { $catOptions = array(); if (isset($_POST['cat_order'])) { $catOptions['move_after'] = (int) $_POST['cat_order']; } // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... $catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $_POST['cat_name']); $catOptions['is_collapsible'] = isset($_POST['collapse']); if (isset($_POST['add'])) { createCategory($catOptions); } else { modifyCategory($_POST['cat'], $catOptions); } } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) { $this->action_cat(); return; } elseif (isset($_POST['delete'])) { // First off - check if we are moving all the current boards first - before we start deleting! if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) { if (empty($_POST['cat_to'])) { fatal_lang_error('mboards_delete_error'); } deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); } else { deleteCategories(array($_POST['cat'])); } } redirectexit('action=admin;area=manageboards'); }