Commit d614ba56 authored by Penny Leach's avatar Penny Leach
Browse files

Finalised the creation of hte group homepage view



Added all the new view blocktypes into the upgrade, and made sure the
installer creates the template as well
Signed-off-by: default avatarPenny Leach <penny@mjollnir.org>
parent 44e26ea4
......@@ -1759,65 +1759,20 @@ function xmldb_core_upgrade($oldversion=0) {
insert_record('view_type', (object)array(
'type' => 'grouphomepage',
));
/*
if ($data = check_upgrades('blocktype.groupmembers')) {
upgrade_plugin($data);
}
if ($data = check_upgrades('blocktype.groupinfo')) {
upgrade_plugin($data);
}
*/
$dbtime = db_format_timestamp(time());
// create a system template for group homepage views
require_once(get_config('libroot') . 'view.php');
$viewdata = (object) array(
'type' => 'grouphomepage',
'owner' => 0,
'numcolumns' => 1,
'template' => 1,
'title' => get_string('grouphomepageviewtitle', 'view'),
'ctime' => $dbtime,
'atime' => $dbtime,
'mtime' => $dbtime,
);
$id = insert_record('view', $viewdata, 'id', true);
$accessdata = (object) array('view' => $id, 'accesstype' => 'loggedin');
insert_record('view_access', $accessdata);
$blocktypes = array(
/*
array(
'blocktype' => 'groupinfo',
'title' => get_string('title', 'blocktype.groupinfo'),
'column' => 1,
'config' => null,
),
*/
array(
'blocktype' => 'recentforumposts',
'title' => get_string('title', 'blocktype.recentforumposts'),
'column' => 1,
'config' => null,
),
);
$installed = get_column_sql('SELECT name FROM {blocktype_installed}');
$weights = array(1 => 0, 2 => 0);
foreach ($blocktypes as $blocktype) {
if (in_array($blocktype['blocktype'], $installed)) {
$weights[$blocktype['column']]++;
insert_record('block_instance', (object) array(
'blocktype' => $blocktype['blocktype'],
'title' => $blocktype['title'],
'view' => $id,
'column' => $blocktype['column'],
'order' => $weights[$blocktype['column']],
'configdata' => serialize($blocktype['config']),
));
}
if ($data = check_upgrades('blocktype.groupviews')) {
upgrade_plugin($data);
}
require_once('group.php');
$id = install_system_grouphomepage_view();
// get back the template view so we can copy it for the groups
$templateview = new View($id);
// add a default group homepage view for all groups in the system
foreach (get_column('group', 'id') as $groupid) {
View::create_from_template(array(
......
......@@ -1353,3 +1353,72 @@ function group_get_homepage_view($groupid) {
$v = get_record('view', 'group', $groupid, 'type', 'grouphomepage');
return new View($v->id, (array)$v);
}
/**
* install the group homepage view
* This creates a template at system level
* which is subsequently copied to group hompages
*
* @return int the id of the new template
*/
function install_system_grouphomepage_view() {
$dbtime = db_format_timestamp(time());
// create a system template for group homepage views
require_once(get_config('libroot') . 'view.php');
$viewdata = (object) array(
'type' => 'grouphomepage',
'owner' => 0,
'numcolumns' => 1,
'template' => 1,
'title' => get_string('grouphomepageviewtitle', 'view'),
'ctime' => $dbtime,
'atime' => $dbtime,
'mtime' => $dbtime,
);
$id = insert_record('view', $viewdata, 'id', true);
$accessdata = (object) array('view' => $id, 'accesstype' => 'loggedin');
insert_record('view_access', $accessdata);
$blocktypes = array(
array(
'blocktype' => 'groupinfo',
'title' => get_string('title', 'blocktype.groupinfo'),
'column' => 1,
'config' => null,
),
array(
'blocktype' => 'recentforumposts',
'title' => get_string('title', 'blocktype.recentforumposts'),
'column' => 1,
'config' => null,
),
array(
'blocktype' => 'groupviews',
'title' => get_string('title', 'blocktype.groupviews'),
'column' => 1,
'config' => null,
),
array(
'blocktype' => 'groupmembers',
'title' => get_string('title', 'blocktype.groupmembers'),
'column' => 1,
'config' => null,
),
);
$installed = get_column_sql('SELECT name FROM {blocktype_installed}');
$weights = array(1 => 0, 2 => 0);
foreach ($blocktypes as $blocktype) {
if (in_array($blocktype['blocktype'], $installed)) {
$weights[$blocktype['column']]++;
insert_record('block_instance', (object) array(
'blocktype' => $blocktype['blocktype'],
'title' => $blocktype['title'],
'view' => $id,
'column' => $blocktype['column'],
'order' => $weights[$blocktype['column']],
'configdata' => serialize($blocktype['config']),
));
}
}
return $id;
}
......@@ -636,8 +636,10 @@ function core_install_lastcoredata_defaults() {
insert_record('usr', $user);
}
require_once('group.php');
install_system_profile_view();
install_system_dashboard_view();
install_system_grouphomepage_view();
// Insert the admin user
$user = new StdClass;
......
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