Commit 76516823 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Get data in one place for group homepage & "copy a page" (bug #845282)



These two pages both display the same data, so it makes sense to
fetch it in a single function.  This also reduces the number of
display_name queries and thumb.php requests for group admins.

Change-Id: Ie10caa60d560337fe0302690e629d1ac8196db6f
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent ca0201de
......@@ -28,7 +28,6 @@
defined('INTERNAL') || die();
require_once('group.php');
safe_require('artefact', 'file');
class PluginBlocktypeGroupInfo extends SystemBlocktype {
public static function get_title() {
......@@ -97,18 +96,7 @@ class PluginBlocktypeGroupInfo extends SystemBlocktype {
throw new AccessDeniedException();
}
// find the group administrators
$group->admins = get_column_sql("SELECT \"member\"
FROM {group_member}
WHERE \"group\" = ?
AND \"role\" = 'admin'", array($group->id));
$group->settingsdescription = group_display_settings($group);
if (get_config('allowgroupcategories')) {
$group->categorytitle = ($group->category) ? get_field('group_category', 'title', 'id', $group->category) : '';
}
$filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
list($group, $filecounts) = group_get_groupinfo_data($group);
return array('group'=>$group, 'filecounts'=>$filecounts);
}
......
......@@ -29,19 +29,11 @@ define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'group.php');
safe_require('artefact', 'file');
$id = param_integer('id');
$group = get_record('group', 'id', $id);
$group->admins = get_column_sql("SELECT member
FROM {group_member}
WHERE \"group\" = ?
AND \"role\" = 'admin'", array($group->id));
$filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
$group->settingsdescription = group_display_settings($group);
list($group, $filecounts) = group_get_groupinfo_data($group);
$smarty = smarty_core();
$smarty->assign('group', $group);
......
......@@ -1825,6 +1825,20 @@ function group_display_settings($group) {
return join(', ', $settings);
}
function group_get_groupinfo_data($group) {
safe_require('artefact', 'file');
$group->admins = group_get_admins(array($group->id));
$group->settingsdescription = group_display_settings($group);
if (get_config('allowgroupcategories')) {
$group->categorytitle = ($group->category) ? get_field('group_category', 'title', 'id', $group->category) : '';
}
$filecounts = ArtefactTypeFileBase::count_user_files(null, $group->id, null);
return array($group, $filecounts);
}
/**
* Return the view object for this group's homepage view
*
......
<ul>
<li><label class="groupinfolabel">{str tag=groupadmins section=group}:</label> {foreach name=admins from=$group->admins item=id}
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxsize=20&amp;id={$id}" alt="">
<a href="{$WWWROOT}user/view.php?id={$id}">{$id|display_name}</a>{if !$.foreach.admins.last}, {/if}
<li><label class="groupinfolabel">{str tag=groupadmins section=group}:</label> {foreach name=admins from=$group->admins item=user}
<img src="{profile_icon_url user=$user maxwidth=20 maxheight=20}" alt="">
<a href="{$WWWROOT}user/view.php?id={$user->id}">{$user|display_name}</a>{if !$.foreach.admins.last}, {/if}
{/foreach}</li>
<li><label class="groupinfolabel">{str tag=grouptype section=group}:</label> {$group->settingsdescription}</li>
{if $group->categorytitle}<li><label>{str tag=groupcategory section=group}:</label> {$group->categorytitle}</li>{/if}
......
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