Commit b8afbd15 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon

Bug 1813987: removing old layout from mahara install

behatnotneeded

Change-Id: If0e93ba7d1ff49fac57fc3d910c4586c9c23d877
parent a5fd2d09
...@@ -1647,6 +1647,10 @@ class BlockInstance { ...@@ -1647,6 +1647,10 @@ class BlockInstance {
$this->rebuild_artefact_list(); $this->rebuild_artefact_list();
// check the table exists in case we need to update a block in the upgrade before the creation of the table
if (db_table_exists('block_instance_dimension')) {
$this->set_block_dimensions($this->positionx, $this->positiony, $this->width, $this->height);
}
// Tell stuff about this // Tell stuff about this
handle_event('blockinstancecommit', $this); handle_event('blockinstancecommit', $this);
...@@ -1942,6 +1946,10 @@ class BlockInstance { ...@@ -1942,6 +1946,10 @@ class BlockInstance {
'row' => $this->get('row'), 'row' => $this->get('row'),
'column' => $this->get('column'), 'column' => $this->get('column'),
'order' => $this->get('order'), 'order' => $this->get('order'),
'positionx' => $this->get('positionx'),
'positiony' => $this->get('positiony'),
'width' => $this->get('width'),
'height' => $this->get('height'),
)); ));
if (($sameowner && $copytype != 'fullinclself') || $copytype == 'reference') { if (($sameowner && $copytype != 'fullinclself') || $copytype == 'reference') {
......
...@@ -796,7 +796,6 @@ ...@@ -796,7 +796,6 @@
<KEY NAME="ownerfk" TYPE="foreign" FIELDS="owner" REFTABLE="usr" REFFIELDS="id" /> <KEY NAME="ownerfk" TYPE="foreign" FIELDS="owner" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="submittedgroupfk" TYPE="foreign" FIELDS="submittedgroup" REFTABLE="group" REFFIELDS="id" /> <KEY NAME="submittedgroupfk" TYPE="foreign" FIELDS="submittedgroup" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="submittedhostfk" TYPE="foreign" FIELDS="submittedhost" REFTABLE="host" REFFIELDS="wwwroot" /> <KEY NAME="submittedhostfk" TYPE="foreign" FIELDS="submittedhost" REFTABLE="host" REFFIELDS="wwwroot" />
<KEY NAME="layoutfk" TYPE="foreign" FIELDS="layout" REFTABLE="view_layout" REFFIELDS="id"/>
<KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" /> <KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="institutionfk" TYPE="foreign" FIELDS="institution" REFTABLE="institution" REFFIELDS="name" /> <KEY NAME="institutionfk" TYPE="foreign" FIELDS="institution" REFTABLE="institution" REFFIELDS="name" />
<KEY NAME="typefk" TYPE="foreign" FIELDS="type" REFTABLE="view_type" REFFIELDS="type" /> <KEY NAME="typefk" TYPE="foreign" FIELDS="type" REFTABLE="view_type" REFFIELDS="type" />
...@@ -815,7 +814,6 @@ ...@@ -815,7 +814,6 @@
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" /> <KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="layoutfk" TYPE="foreign" FIELDS="layout" REFTABLE="view_layout" REFFIELDS="id"/>
<KEY NAME="usrfk" TYPE="foreign" FIELDS="usr" REFTABLE="usr" REFFIELDS="id"/> <KEY NAME="usrfk" TYPE="foreign" FIELDS="usr" REFTABLE="usr" REFFIELDS="id"/>
<KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" /> <KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="institutionfk" TYPE="foreign" FIELDS="institution" REFTABLE="institution" REFFIELDS="name" /> <KEY NAME="institutionfk" TYPE="foreign" FIELDS="institution" REFTABLE="institution" REFFIELDS="name" />
...@@ -851,9 +849,9 @@ ...@@ -851,9 +849,9 @@
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" /> <FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="configdata" TYPE="text" LENGTH="big" NOTNULL="false" /> <FIELD NAME="configdata" TYPE="text" LENGTH="big" NOTNULL="false" />
<FIELD NAME="view" TYPE="int" LENGTH="10" NOTNULL="true" /> <FIELD NAME="view" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="row" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="1" /> <FIELD NAME="row" TYPE="int" LENGTH="2" DEFAULT="1" NOTNULL="false" />
<FIELD NAME="column" TYPE="int" LENGTH="2" NOTNULL="true" /> <FIELD NAME="column" TYPE="int" LENGTH="2" NOTNULL="false" />
<FIELD NAME="order" TYPE="int" LENGTH="2" NOTNULL="true" /> <FIELD NAME="order" TYPE="int" LENGTH="2" NOTNULL="false" />
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" /> <KEY NAME="primary" TYPE="primary" FIELDS="id" />
......
...@@ -2631,22 +2631,19 @@ function install_system_grouphomepage_view() { ...@@ -2631,22 +2631,19 @@ function install_system_grouphomepage_view() {
array( array(
'blocktype' => 'groupinfo', 'blocktype' => 'groupinfo',
'title' => '', 'title' => '',
'row' => 1, 'positiony' => 0,
'column' => 1,
'config' => null, 'config' => null,
), ),
array( array(
'blocktype' => 'recentforumposts', 'blocktype' => 'recentforumposts',
'title' => '', 'title' => '',
'row' => 1, 'positiony' => 3,
'column' => 1,
'config' => null, 'config' => null,
), ),
array( array(
'blocktype' => 'groupviews', 'blocktype' => 'groupviews',
'title' => '', 'title' => '',
'row' => 1, 'positiony' => 6,
'column' => 1,
'config' => array( 'config' => array(
'showgroupviews' => 1, 'showgroupviews' => 1,
'showsharedviews' => 1, 'showsharedviews' => 1,
...@@ -2656,23 +2653,21 @@ function install_system_grouphomepage_view() { ...@@ -2656,23 +2653,21 @@ function install_system_grouphomepage_view() {
array( array(
'blocktype' => 'groupmembers', 'blocktype' => 'groupmembers',
'title' => '', 'title' => '',
'row' => 1, 'positiony' => 9,
'column' => 1,
'config' => null, 'config' => null,
), ),
); );
$installed = get_column_sql('SELECT name FROM {blocktype_installed}'); $installed = get_column_sql('SELECT name FROM {blocktype_installed}');
$weights = array(1 => 0);
foreach ($blocktypes as $blocktype) { foreach ($blocktypes as $blocktype) {
if (in_array($blocktype['blocktype'], $installed)) { if (in_array($blocktype['blocktype'], $installed)) {
$weights[$blocktype['column']]++;
$newblock = new BlockInstance(0, array( $newblock = new BlockInstance(0, array(
'blocktype' => $blocktype['blocktype'], 'blocktype' => $blocktype['blocktype'],
'title' => $blocktype['title'], 'title' => $blocktype['title'],
'view' => $view->get('id'), 'view' => $view->get('id'),
'row' => $blocktype['row'], 'positionx' => 0,
'column' => $blocktype['column'], 'positiony' => $blocktype['positiony'],
'order' => $weights[$blocktype['column']], 'width' => 12,
'height' => 3,
'configdata' => $blocktype['config'], 'configdata' => $blocktype['config'],
)); ));
$newblock->commit(); $newblock->commit();
......
...@@ -2813,20 +2813,25 @@ function install_system_profile_view() { ...@@ -2813,20 +2813,25 @@ function install_system_profile_view() {
$view->set_access(array(array( $view->set_access(array(array(
'type' => 'loggedin' 'type' => 'loggedin'
))); )));
$blocktypes = array('profileinfo' => 1, 'myviews' => 1, 'mygroups' => 1, 'myfriends' => 2, 'wall' => 2); // column ids $blocktypes = array(
'profileinfo' => array(0,0),
'myviews' => array(0,1),
'mygroups' => array(0,2),
'myfriends' => array(1,0),
'wall' => array(1,1)
); // block coordinates (x,y) in grid
$installed = get_column_sql('SELECT name FROM {blocktype_installed} WHERE name IN (' . join(',', array_map('db_quote', array_keys($blocktypes))) . ')'); $installed = get_column_sql('SELECT name FROM {blocktype_installed} WHERE name IN (' . join(',', array_map('db_quote', array_keys($blocktypes))) . ')');
$weights = array(1 => 0, 2 => 0);
foreach (array_keys($blocktypes) as $blocktype) { foreach (array_keys($blocktypes) as $blocktype) {
if (in_array($blocktype, $installed)) { if (in_array($blocktype, $installed)) {
$weights[$blocktypes[$blocktype]]++;
$title = ($blocktype == 'profileinfo') ? get_string('aboutme', 'blocktype.internal/profileinfo') : ''; $title = ($blocktype == 'profileinfo') ? get_string('aboutme', 'blocktype.internal/profileinfo') : '';
$newblock = new BlockInstance(0, array( $newblock = new BlockInstance(0, array(
'blocktype' => $blocktype, 'blocktype' => $blocktype,
'title' => $title, 'title' => $title,
'view' => $view->get('id'), 'view' => $view->get('id'),
'row' => 1, 'positionx' => $blocktypes[$blocktype][0] * 6,
'column' => $blocktypes[$blocktype], 'positiony' => $blocktypes[$blocktype][1] * 3,
'order' => $weights[$blocktypes[$blocktype]], 'height' => 3,
'width' => 6,
)); ));
$newblock->commit(); $newblock->commit();
} }
...@@ -2862,8 +2867,8 @@ function install_system_dashboard_view() { ...@@ -2862,8 +2867,8 @@ function install_system_dashboard_view() {
array( array(
'blocktype' => 'newviews', 'blocktype' => 'newviews',
'title' => '', 'title' => '',
'row' => 1, 'positionx' => 0,
'column' => 1, 'positiony' => 0,
'config' => array( 'config' => array(
'limit' => 5, 'limit' => 5,
), ),
...@@ -2871,15 +2876,15 @@ function install_system_dashboard_view() { ...@@ -2871,15 +2876,15 @@ function install_system_dashboard_view() {
array( array(
'blocktype' => 'myviews', 'blocktype' => 'myviews',
'title' => '', 'title' => '',
'row' => 1, 'positionx' => 0,
'column' => 1, 'positiony' => 3,
'config' => null, 'config' => null,
), ),
array( array(
'blocktype' => 'inbox', 'blocktype' => 'inbox',
'title' => '', 'title' => '',
'row' => 1, 'positionx' => 6,
'column' => 2, 'positiony' => 0,
'config' => array( 'config' => array(
'feedback' => true, 'feedback' => true,
'groupmessage' => true, 'groupmessage' => true,
...@@ -2895,8 +2900,8 @@ function install_system_dashboard_view() { ...@@ -2895,8 +2900,8 @@ function install_system_dashboard_view() {
array( array(
'blocktype' => 'inbox', 'blocktype' => 'inbox',
'title' => '', 'title' => '',
'row' => 1, 'positionx' => 6,
'column' => 2, 'positiony' => 3,
'config' => array( 'config' => array(
'newpost' => true, 'newpost' => true,
'maxitems' => '5', 'maxitems' => '5',
...@@ -2905,25 +2910,24 @@ function install_system_dashboard_view() { ...@@ -2905,25 +2910,24 @@ function install_system_dashboard_view() {
array( array(
'blocktype' => 'watchlist', 'blocktype' => 'watchlist',
'title' => '', 'title' => '',
'row' => 1, 'positionx' => 6,
'column' => 2, 'positiony' => 6,
'config' => array( 'config' => array(
'count' => '10', 'count' => '10',
), ),
), ),
); );
$installed = get_column_sql('SELECT name FROM {blocktype_installed}'); $installed = get_column_sql('SELECT name FROM {blocktype_installed}');
$weights = array(1 => 0, 2 => 0);
foreach ($blocktypes as $blocktype) { foreach ($blocktypes as $blocktype) {
if (in_array($blocktype['blocktype'], $installed)) { if (in_array($blocktype['blocktype'], $installed)) {
$weights[$blocktype['column']]++;
$newblock = new BlockInstance(0, array( $newblock = new BlockInstance(0, array(
'blocktype' => $blocktype['blocktype'], 'blocktype' => $blocktype['blocktype'],
'title' => $blocktype['title'], 'title' => $blocktype['title'],
'view' => $view->get('id'), 'view' => $view->get('id'),
'row' => $blocktype['row'], 'positionx' => $blocktype['positionx'],
'column' => $blocktype['column'], 'positiony' => $blocktype['positiony'],
'order' => $weights[$blocktype['column']], 'width' => 6,
'height' => 3,
'configdata' => $blocktype['config'], 'configdata' => $blocktype['config'],
)); ));
$newblock->commit(); $newblock->commit();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment