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

Addition of a grouphomepage view and an upgrade to add it to all existing groups


Signed-off-by: default avatarPenny Leach <penny@mjollnir.org>
parent b73f6ef5
......@@ -48,6 +48,7 @@ $string['ownerformatdescription'] = 'How do you want people who look at your Vie
$string['profileviewtitle'] = 'Profile View';
$string['dashboardviewtitle'] = 'Dashboard View';
$string['editprofileview'] = 'Edit profile view';
$string['grouphomepageviewtitle'] = 'Group Homepage View';
// my views
$string['artefacts'] = 'Artefacts';
......@@ -295,5 +296,6 @@ $string['blockcopypermissiondesc'] = 'If you allow other users to copy this View
$string['dashboard'] = 'Dashboard';
$string['profile'] = 'Profile';
$string['portfolio'] = 'Portfolio';
$string['grouphomepage'] = 'Group Homepage';
?>
......@@ -1755,5 +1755,79 @@ function xmldb_core_upgrade($oldversion=0) {
set_config('registerterms', 1);
}
if ($oldversion < 2010061800) {
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']),
));
}
}
// 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(
'group' => $groupid,
'title' => $templateview->get('title'),
'description' => $templateview->get('description'),
'type' => 'grouphomepage',
), $id, 0, false);
}
}
return $status;
}
......@@ -145,6 +145,12 @@ function group_change_role($groupid, $userid, $role) {
* @returns boolean
*/
function group_user_can_edit_views($groupid, $userid=null) {
// root user can always do whatever it wants
$sysuser = get_record('usr', 'username', 'root');
if ($sysuser->id == $userid) {
return true;
}
if (!is_logged_in()) {
return false;
}
......
......@@ -802,7 +802,7 @@ function core_install_firstcoredata_defaults() {
// install the view column widths
install_view_column_widths();
$viewtypes = array('dashboard', 'portfolio', 'profile');
$viewtypes = array('dashboard', 'portfolio', 'profile', 'grouphomepage');
foreach ($viewtypes as $vt) {
insert_record('view_type', (object)array(
'type' => $vt,
......
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010061100;
$config->version = 2010061800;
$config->release = '1.3.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
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