/** * save category meta data if category is updated */ function init_page() { if (qa_clicked('dosavecategory') && !qa_clicked('docancel')) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $categoryid = qa_post_text('edit'); if (!empty($categoryid)) { // update admin/category form to save form's category meta data $et_category['et_cat_title'] = qa_post_text('et_category_link_title'); if (!isset($et_category['et_cat_title'])) { $et_category['et_cat_title'] = ''; } $et_category['et_cat_desc'] = qa_post_text('et_category_description'); if (!isset($et_category['et_cat_desc'])) { $et_category['et_cat_desc'] = ''; } $et_category['et_cat_icon48'] = qa_post_text('et_category_icon_48'); if (!isset($et_category['et_cat_icon48'])) { $et_category['et_cat_icon48'] = ''; } $et_category['et_cat_icon64'] = qa_post_text('et_category_icon_64'); if (!isset($et_category['et_cat_icon64'])) { $et_category['et_cat_icon64'] = ''; } qa_db_categorymeta_set($categoryid, 'et_category', json_encode($et_category)); } } // when loading question page after edit if category is updated, Q2A will attempt to Re-Update question category based on "q_category_X" field. // this happens when category already exists, and we attempt to change it while editing question. // here we will set category id to "q_category_1" field, so it wont change it to null after question is updated $questionid = qa_request_part(0); $num_questionid = (int) $questionid; if (qa_clicked('q_dosave') && $questionid == $num_questionid) { $result = qa_db_read_one_assoc(qa_db_query_sub('SELECT categoryid FROM ^posts WHERE postid=$', $num_questionid), true); $_POST['q_category_1'] = $result['categoryid']; } }
function process_request($request) { $parts = explode('/', $request); $categoryid = $parts[1]; $fullcategory = qa_db_select_with_pending(qa_db_full_category_selectspec($categoryid, true)); $slugs = explode('/', $fullcategory['backpath']); $new_request = implode('/', array_reverse($slugs)); $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('useo/edit_desc_for_x', qa_html($fullcategory['title'])); if (qa_user_permit_error('useo_cat_desc_permit_edit')) { $qa_content['error'] = qa_lang_html('users/no_permission'); return $qa_content; } require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; if (qa_clicked('dosave')) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; qa_db_categorymeta_set($categoryid, 'useo_cat_title', qa_post_text('useo_cat_title')); qa_db_categorymeta_set($categoryid, 'useo_cat_description', qa_post_text('useo_cat_description')); qa_redirect($new_request); } $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('label' => 'Link Title:', 'type' => 'text', 'rows' => 2, 'tags' => 'NAME="useo_cat_title" ID="useo_cat_title"', 'value' => qa_html(qa_db_categorymeta_get($categoryid, 'useo_cat_title'))), array('label' => 'Description:', 'type' => 'text', 'rows' => 4, 'tags' => 'NAME="useo_cat_description" ID="useo_cat_description"', 'value' => qa_html(qa_db_categorymeta_get($categoryid, 'useo_cat_description')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => qa_lang_html('useo/save_desc_button')))); $qa_content['focusid'] = 'tagtitle'; return $qa_content; }