Commit 798237e1 authored by Eugene Venter's avatar Eugene Venter
Browse files

group views: added ability to choose which group views ('Shared Views' and/or...

group views: added ability to choose which group views ('Shared Views' and/or 'Group Views') to show (bug #659679)
parent 6e445b8f
......@@ -28,4 +28,8 @@
defined('INTERNAL') || die();
$string['title'] = 'Group Views';
$string['description'] = 'Display the views shared with the group';
$string['description'] = 'Display the views related to the group';
$string['displaygroupviews'] = 'Display Group views?';
$string['displaygroupviewsdesc'] = 'Group views - views created in the group';
$string['displaysharedviews'] = 'Display Shared views?';
$string['displaysharedviewsdesc'] = 'Shared views - views shared by group members from their individual portfolio';
......@@ -39,7 +39,7 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
}
public static function single_only() {
return true;
return false;
}
public static function get_categories() {
......@@ -55,6 +55,7 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
}
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
$groupid = $instance->get_view()->get('group');
if (!$groupid) {
return '';
......@@ -65,7 +66,10 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
$dwoo = smarty_core();
$dwoo->assign('group', $data['group']);
$dwoo->assign('groupid', $data['group']->id);
if (isset($data['sharedviews'])) {
if (!empty($configdata['showgroupviews']) && isset($data['groupviews'])) {
$dwoo->assign('groupviews', $data['groupviews']->data);
}
if (!empty($configdata['showsharedviews']) && isset($data['sharedviews'])) {
$dwoo->assign('sharedviews', $data['sharedviews']->data);
}
if (isset($data['allsubmittedviews'])) {
......@@ -82,7 +86,35 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
}
public static function has_instance_config() {
return false;
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
return array(
'showgroupviews' => array(
'type' => 'radio',
'description' => get_string('displaygroupviewsdesc', 'blocktype.groupviews'),
'title' => get_string('displaygroupviews', 'blocktype.groupviews'),
'options' => array(
1 => get_string('yes'),
0 => get_string('no'),
),
'separator' => '<br>',
'defaultvalue' => isset($configdata['showgroupviews']) ? $configdata['showgroupviews'] : 1,
),
'showsharedviews' => array(
'type' => 'radio',
'title' => get_string('displaysharedviews', 'blocktype.groupviews'),
'description' => get_string('displaysharedviewsdesc', 'blocktype.groupviews'),
'options' => array(
1 => get_string('yes'),
0 => get_string('no'),
),
'separator' => '<br>',
'defaultvalue' => isset($configdata['showsharedviews']) ? $configdata['showsharedviews'] : 0,
),
);
}
public static function default_copy_type() {
......@@ -99,9 +131,13 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
$group = group_current_group();
$role = group_user_access($group->id);
if ($role) {
// Get all views created in the group
$data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id));
// For group members, display a list of views that others have
// shared to the group
$data['sharedviews'] = View::get_sharedviews_data(null, 0, $group->id);
if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) {
// Display a list of views submitted to the group
$data['allsubmittedviews'] = View::get_submitted_views($group->id);
......
{auto_escape off}
{if $groupviews}
<div class="groupviewsection">
<h5>{str tag="groupviews" section="view"}</h5>
<table class="fullwidth listing">
{foreach from=$groupviews item=view}
<tr class="{cycle values='r0,r1'}">
<td>
<a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|escape}</a>
<div>{$view.shortdescription|clean_html}</div>
{if $view.tags}<div class="tags"><label>{str tag=tags}:</label> {list_tags owner=$view.owner tags=$view.tags}</div>{/if}
{if $view.template}
<div><a href="">{str tag=copythisview section=view}</a></div>
{/if}
</td>
</tr>
{/foreach}
</table>
</div>
{/if}
{if $sharedviews}
<div class="groupviewsection">
<h5>{str tag="viewssharedtogroupbyothers" section="view"}</h5>
......
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