Commit b4961420 authored by Pierre Spring's avatar Pierre Spring
Browse files

Added configuration to the groupmembers blocktype


Signed-off-by: default avatarPierre Spring <pierre.spring@caillou.ch>
parent 053bcefb
......@@ -29,4 +29,10 @@ defined('INTERNAL') || die();
$string['title'] = 'Group Members';
$string['description'] = 'Display a list of Members in this Group';
$string['show_all'] = 'View all Members of this Group…';
\ No newline at end of file
$string['show_all'] = 'View all Members of this Group…';
$string['options_rows_title'] = 'Rows';
$string['options_rows_desc'] = 'The amount of rows you want to display.';
$string['options_columns_title'] = 'Columns';
$string['options_columns_desc'] = 'The columns of rows you want to display.';
\ No newline at end of file
......@@ -51,14 +51,19 @@ class PluginBlocktypeGroupMembers extends SystemBlocktype {
public static function render_instance (BlockInstance $instance, $editing = false) {
global $USER;
$configdata = $instance->get('configdata');
$rows = $configdata['rows'];
$columns = $configdata['columns'];
$groupid = $instance->get_view()->get('group');
require_once('searchlib.php');
$groupmembers = get_group_user_search_results($groupid, '', 0, 16, '');
$groupmembers = get_group_user_search_results($groupid, '', 0, ($rows + $columns), '', true);
if ($groupmembers['count']) {
$friendarray = array_chunk($groupmembers['data'], 4); // get the friends into a 4x4 array
$groupmembersarray = array_chunk($groupmembers['data'], $columns);
$smarty = smarty_core();
$smarty->assign_by_ref('friends', $friendarray);
$smarty->assign_by_ref('groupmembers', $groupmembersarray);
$groupmembers['tablerows'] = $smarty->fetch('blocktype:groupmembers:row.tpl');
} else {
$groupmembers = false;
......@@ -70,11 +75,39 @@ class PluginBlocktypeGroupMembers extends SystemBlocktype {
);
$smarty = smarty_core();
$smarty->assign('friends', $groupmembers);
$smarty->assign('groupmembers', $groupmembers);
$smarty->assign('show_all', $show_all);
return $smarty->fetch('blocktype:groupmembers:groupmembers.tpl');
}
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
$options = range(0,9);
unset($options[0]);
return array(
'rows' => array(
'type' => 'select',
'title' => get_string('options_rows_title', 'blocktype.groupmembers'),
'description' => get_string('options_rows_desc', 'blocktype.groupmembers'),
'defaultvalue' => $configdata['rows'] ? $configdata['rows'] : 4,
'options' => $options,
),
'columns' => array(
'type' => 'select',
'title' => get_string('options_columns_title', 'blocktype.groupmembers'),
'description' => get_string('options_columns_desc', 'blocktype.groupmembers'),
'defaultvalue' => $configdata['columns'] ? $configdata['columns'] : 3,
'options' => $options,
),
);
}
}
\ No newline at end of file
{auto_escape off}
<div class="friends">
{if $friends}
{if $groupmembers}
<table id="userfriendstable" class="center fullwidth">
<tbody>
{$friends.tablerows}
{$groupmembers.tablerows}
</tbody>
</table>
{/if}
......
{auto_escape off}
{foreach from=$friends item=row}
{foreach from=$groupmembers item=row}
<tr>
{foreach from=$row item=friend}
{foreach from=$row item=groupmember}
<td class="{cycle values='r0,r1'} friendcell">
<a href="{$WWWROOT}user/view.php?id={$friend['id']}">
<img src="{profile_icon_url user=$friend maxwidth=60 maxheight=60}" alt="">
<a href="{$WWWROOT}user/view.php?id={$groupmember['id']}">
<img src="{profile_icon_url user=$groupmember maxwidth=60 maxheight=60}" alt="" title="{$groupmember|display_default_name|escape}">
</a>
<div><a href="{$WWWROOT}user/view.php?id={$friend['id']}">{$friend|display_default_name|escape}</a></div>
<div><a href="{$WWWROOT}user/view.php?id={$groupmember['id']}">{$groupmember|display_default_name|escape}</a></div>
</td>
{/foreach}
</tr>
......
Supports Markdown
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