Example #1
0
function tree_rebuild_full($table, $where = '1=1', $sortby = 'name')
{
    return tree_rebuild($table, 0, 1, $where, $sortby);
}
Example #2
0
if (!safe_column_exists('txp_section', 'id')) {
    safe_alter('txp_section', 'drop primary key');
}
safe_upgrade_table('txp_section', array('id' => DB_AUTOINC . ' PRIMARY KEY', 'path' => "varchar(255) not null default ''", 'parent' => 'INT', 'lft' => 'INT not null default 0', 'rgt' => 'INT not null default 0', 'inherit' => 'SMALLINT not null default 0'));
safe_update('txp_section', 'path=name', "path=''");
// shortname has to be unique within a parent
if (!safe_index_exists('txp_section', 'parent_idx')) {
    safe_upgrade_index('txp_section', 'parent_idx', 'unique', 'parent,name');
}
#if (!safe_index_exists('txp_section', 'path_idx'))
#	safe_upgrade_index('txp_section', 'path_idx', 'unique', 'path');
safe_update('txp_section', 'parent=0', "name='default'");
$root_id = safe_field('id', 'txp_section', "name='default'");
safe_update('txp_section', "parent='" . $root_id . "'", "parent IS NULL");
include_once txpath . '/lib/txplib_tree.php';
tree_rebuild('txp_section', $root_id, 1);
// <txp:message /> is dropped
safe_update('txp_form', "Form = REPLACE(Form, '<txp:message', '<txp:comment_message')", "1 = 1");
// Expiry datetime for articles
safe_upgrade_table('textpattern', array('Expires' => "datetime NOT NULL default '0000-00-00 00:00:00' after `Posted`"));
if (!safe_field('name', 'txp_prefs', "name = 'publish_expired_articles'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'publish_expired_articles', val = '0', type = '1', event='publish', html='yesnoradio', position='130'");
}
/*
 * @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
Example #3
0
 function upgrade_table()
 {
     parent::upgrade_table();
     safe_update($this->_table_name, 'path=name', "path=''");
     # shortname has to be unique within a parent
     if (!safe_index_exists($this->_table_name, 'parent_idx')) {
         safe_upgrade_index($this->_table_name, 'parent_idx', 'unique', 'parent,name');
     }
     safe_update('txp_section', 'parent=0', "name='default'");
     $this->update(array('parent' => 0), array('name' => 'default'));
     $root_id = safe_field('id', $this->_table_name, "name='default'");
     safe_update($this->_table_name, "parent='" . $root_id . "'", "parent IS NULL");
     include_once txpath . '/lib/txplib_tree.php';
     tree_rebuild($this->_table_name, $root_id, 1);
 }