// new row $row = '<dd id="config_category_' . $id . '">'; $row .= '<span class="no">[' . $save['category_id'] . ']</span>'; $row .= '<span class="icon-delete" id="config_category_delete_' . $id . '" title="' . $lng['LNG_DELETE'] . ' ' . $text . '"> </span>'; $row .= $text . ' <span id="config_category_name_' . $id . '" title="' . $lng['LNG_CLICK_TO'] . ' ' . $lng['LNG_EDIT'] . '">' . $topic[LANGUAGE] . '</span>'; $row .= '</dd>'; $ret['data'] = rawurlencode($row); $ret['newId'] = "config_category_" . $id; } elseif (preg_match('/^config_(category)_delete_([0-9]+)$/', $action, $match)) { // ลบหมวดหมู่ $db->query("DELETE FROM `" . DB_CATEGORY . "` WHERE `module_id`='{$module_id}' AND `id`='{$match['2']}' LIMIT 1"); // รายการที่ลบ $ret['del'] = "config_{$match['1']}_" . $match[2]; } elseif (preg_match('/^config_(category)_name_([0-9]+)$/', $action, $match)) { // แก้ไขชื่อหมวดหมู่ $topic[LANGUAGE] = $db->sql_trim_str(gcms::oneLine($_POST['value'])); $sql = "SELECT `id` FROM `" . DB_CATEGORY . "` WHERE `module_id`='{$module_id}' AND `id`='{$match['2']}' LIMIT 1"; $category = $db->customQuery($sql); if (sizeof($category) == 1) { $db->edit(DB_CATEGORY, $category[0]['id'], array('topic' => gcms::array2Ser($topic))); // ส่งข้อมูลใหม่ไปแสดงผล $ret['edit'] = rawurlencode($topic[LANGUAGE]); $ret['editId'] = $action; } } } } else { $ret['error'] = 'ACTION_ERROR'; } // คืนค่าเป็น JSON echo gcms::array2json($ret);
// referer, member if (gcms::isReferer() && gcms::isMember()) { if (isset($_SESSION['login']['account']) && $_SESSION['login']['account'] == 'demo') { $ret['error'] = 'EX_MODE_ERROR'; } else { $save = array(); $error = false; $input = false; $topic = array(); $detail = array(); foreach ($_POST['category_topic'] as $k => $v) { $v = $db->sql_trim_str(gcms::oneLine($v)); if ($v != '') { $topic[$k] = $v; } $v = $db->sql_trim_str(gcms::oneLine($_POST['category_detail'][$k])); if ($v != '') { $detail[$k] = $v; } } // ค่าที่ส่งมา $id = gcms::getVars($_POST, 'write_id', 0); $category_id = gcms::getVars($_POST, 'category_id', 0); $module_id = gcms::getVars($_POST, 'module_id', 0); if ($id > 0) { // แก้ไข, ตรวจสอบหมวดที่เลือก $sql = "SELECT C.`id`,C.`module_id`,C.`icon`,CONCAT(M.`config` ,'\n' ,C.`config`) AS `config`"; $sql .= ",(SELECT `id` FROM `" . DB_CATEGORY . "` WHERE `category_id`={$category_id} AND `module_id`={$module_id}) AS `cid`"; $sql .= " FROM `" . DB_CATEGORY . "` AS C"; $sql .= " INNER JOIN `" . DB_MODULES . "` AS M ON M.`id`={$module_id} AND M.`owner`='board'"; $sql .= " WHERE C.`id`={$id} AND C.`module_id`={$module_id} LIMIT 1";