function section_add($parent, $name, $atts) { $rec = lAtts(array('path' => '', 'parent' => $parent, 'name' => '', 'title' => $name, 'inherit' => 0, 'page' => 'default', 'css' => 'default', 'in_rss' => '1', 'on_frontpage' => '1', 'searchable' => '1'), $atts); $default = section_default(); if (empty($rec['parent'])) { $rec['parent'] = $default['id']; } if (empty($rec['name'])) { $rec['name'] = dumbDown($rec['title']); } if ($rec['inherit']) { // find the closest ancestor // we do this at insert to save time when fetching pages $ancestor = section_inherit($parent); $rec['page'] = $ancestor['page']; $rec['css'] = $ancestor['css']; $rec['in_rss'] = $ancestor['in_rss']; $rec['on_frontpage'] = $ancestor['on_frontpage']; $rec['searchable'] = $ancestor['searchable']; } if ($parent) { list($lft, $rgt) = tree_insert_space('txp_section', $parent); } else { $lft = $rgt = 0; } $rec['lft'] = $lft; $rec['rgt'] = $rgt; $res = safe_insert_rec('txp_section', doSlash($rec)); return $res; }
function xml_restore_backup($xml, $tables = array()) { $data = xml_restore_decode($xml); // Assume all tables if none are specified if (empty($tables)) { $tables = safe_table_list(); } foreach (array_keys($data) as $table) { if (in_array($table, $tables)) { foreach ($data[$table] as $rec) { // FIXME: this should ignore duplicate key errors only @safe_insert_rec($table, $rec); } } } }