prefix}blocks ( id SERIAL8 PRIMARY KEY, name varchar(40) NOT NULL default '', version INT8 NOT NULL default '0', cron INT8 NOT NULL default '0', lastcron INT8 NOT NULL default '0', visible int NOT NULL default '1' ) ") ; } if ($oldversion < 2004101900 && $result) { $result = execute_sql("CREATE TABLE {$CFG->prefix}block ( id SERIAL8 PRIMARY KEY, name varchar(40) NOT NULL default '', version INT8 NOT NULL default '0', cron INT8 NOT NULL default '0', lastcron INT8 NOT NULL default '0', visible int NOT NULL default '1', multiple int NOT NULL default '0' ) "); if(!$result) { return false; } $records = get_records('blocks'); if(!empty($records)) { foreach($records as $block) { $block->multiple = 0; unset($block->id); insert_record('block', $block); } } execute_sql("DROP TABLE {$CFG->prefix}blocks"); $result = execute_sql("CREATE TABLE {$CFG->prefix}block_instance ( id SERIAL8 PRIMARY KEY, blockid INT8 not null default '0', pageid INT8 not null default '0', pagetype varchar(12) not null default '', position char not null check (position in ('l', 'r')) , weight int not null default '0', visible int not null default '0', configdata text not null default '' )"); if(!$result) { return false; } $records = get_records('course'); if(!empty($records)) { foreach($records as $thiscourse) { // The @ suppresses a notice emitted if there is no : in the string @list($left, $right) = split(':', $thiscourse->blockinfo); if(!empty($left)) { $arr = explode(',', $left); foreach($arr as $weight => $blk) { $instance = new stdClass; $instance->blockid = abs($blk); $instance->pageid = $thiscourse->id; $instance->pagetype = PAGE_COURSE_VIEW; $instance->position = BLOCK_POS_LEFT; $instance->weight = $weight; $instance->visible = ($blk > 0) ? 1 : 0; $instance->configdata = ''; insert_record('block_instance', $instance); } } if(!empty($right)) { $arr = explode(',', $right); foreach($arr as $weight => $blk) { $instance = new stdClass; $instance->blockid = abs($blk); $instance->pageid = $thiscourse->id; $instance->pagetype = PAGE_COURSE_VIEW; $instance->position = BLOCK_POS_RIGHT; $instance->weight = $weight; $instance->visible = ($blk > 0) ? 1 : 0; $instance->configdata = ''; insert_record('block_instance', $instance); } } } } execute_sql("ALTER TABLE {$CFG->prefix}course DROP COLUMN blockinfo"); } if ($oldversion < 2004112900 && $result) { $result = $result && table_column('block_instance', 'pagetype', 'pagetype', 'varchar', '20', ''); $result = $result && table_column('block_instance', 'position', 'position', 'varchar', '10', ''); } //Finally, return result return $result; } ?>