* @todo determine section:article relation key */ // populate section_id values // foreach (safe_rows('id, name', 'txp_section', '1=1') as $row) { // safe_update('textpattern', "section_id='".doSlash($row['id'])."'", "Section='".doSlash($row['name'])."'"); //} // fix up the parent field in txp_category safe_query("alter ignore table " . safe_pfx('txp_category') . " modify parent INT not null"); $types = safe_column('distinct type', 'txp_category', '1=1'); foreach ($types as $type) { $root = safe_field('id', 'txp_category', "type='" . doSlash($type) . "' and name='root' and parent=0"); if (!$root) { $root = safe_insert('txp_category', "name='root', type='" . doSlash($type) . "', parent=0"); } safe_update('txp_category', "parent='" . $root . "'", "type='" . doSlash($type) . "' and parent=0 and id != '" . $root . "'"); tree_rebuild_full('txp_category', "type='" . doSlash($type) . "'"); } // index on form type safe_upgrade_index('txp_form', 'type_idx', '', 'type'); // dropdown ui for certain prefs safe_upgrade_table('txp_prefs', array('choices' => 'varchar(64)')); safe_update('txp_prefs', "html='checkbox'", "html='yesnoradio'"); safe_update('txp_prefs', "html='text'", "html='text_input'"); safe_update('txp_prefs', "choices='commentmode', html='select'", "html='commentmode'"); safe_update('txp_prefs', "choices='logging', html='select'", "html='logging'"); safe_update('txp_prefs', "choices='production_stati', html='radio'", "html='prod_levels'"); safe_update('txp_prefs', "choices='gmtoffsets', html='select'", "html='gmtoffset_select'"); safe_update('txp_prefs', "choices='weeks', html='select'", "html='weeks'"); safe_update('txp_prefs', "choices='languages', html='select'", "html='languages'"); safe_update('txp_prefs', "choices='permlinkmodes', html='radio'", "html='permlinkmodes'"); safe_update('txp_prefs', "choices='dateformats', html='select'", "html='dateformats'");
function edit_post() { extract(doSlash(psa(array('name', 'old_name', 'title', 'type')))); $id = $this->psi('id'); $parent = $this->ps('parent'); if (!$parent) { $parent = tree_root_id('txp_category', "type='" . doSlash($type) . "'"); } $name = sanitizeForUrl($name); // make sure the name is valid if (!$name) { $this->_error(gTxt($type . '_category_invalid', array('{name}' => $name))); return; } // don't allow rename to clobber an existing category if (safe_field('id', 'txp_category', "name = '{$name}' and type = '{$type}' and id != {$id}")) { $this->_error(gTxt($type . '_category_already_exists', array('{name}' => $name))); return; } safe_update('txp_category', "name = '{$name}', parent = '{$parent}', title = '{$title}'", "id = {$id}"); tree_rebuild_full('txp_category', "type='{$type}'"); if ($type == 'article') { safe_update('textpattern', "Category1 = '{$name}'", "Category1 = '{$old_name}'"); safe_update('textpattern', "Category2 = '{$name}'", "Category2 = '{$old_name}'"); } elseif ($type == 'link') { safe_update('txp_link', "category = '{$name}'", "category = '{$old_name}'"); } elseif ($type == 'image') { safe_update('txp_image', "category = '{$name}'", "category = '{$old_name}'"); } elseif ($type == 'file') { safe_update('txp_file', "category = '{$name}'", "category = '{$old_name}'"); } // show a success message and switch back to the list view $this->_message(gTxt($type . '_category_updated', array('{name}' => doStrip($name)))); $this->_set_view('list'); }