Commit 7eaae8d5 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Show count of group views,files on group info page

parent 044c718a
......@@ -568,6 +568,38 @@ JAVASCRIPT;
return $javascript;
}
public static function count_user_files($owner=null, $institution=null, $group=null) {
$filetypes = PluginArtefactFile::get_artefact_types();
foreach ($filetypes as $k => $v) {
if ($v == 'folder') {
unset($filetypes[$k]);
}
}
$filetypesql = "('" . join("','", $filetypes) . "')";
$phvals = array();
if ($institution) {
$ownersql = 'institution = ? AND "group" IS NULL AND owner IS NULL';
$phvals[] = $institution;
}
else if ($group) {
$ownersql = '"group" = ? AND institution IS NULL AND owner IS NULL';
$phvals[] = $group;
}
else {
if (!$owner) {
global $USER;
$owner = $USER->get('id');
}
$ownersql = 'institution IS NULL AND "group" IS NULL AND owner = ?';
$phvals[] = $owner;
}
return (object) array(
'files' => count_records_select('artefact', "artefacttype IN $filetypesql AND $ownersql", $phvals),
'folders' => 1+count_records_select('artefact', "artefacttype = 'folder' AND $ownersql", $phvals)
);
}
}
class ArtefactTypeFile extends ArtefactTypeFileBase {
......
......@@ -30,6 +30,7 @@ require(dirname(dirname(__FILE__)) . '/init.php');
require_once('group.php');
require_once('searchlib.php');
require_once(get_config('docroot') . 'interaction/lib.php');
safe_require('artefact', 'file');
$id = param_integer('id');
......@@ -46,6 +47,7 @@ $group->admins = get_column_sql("SELECT member
$role = group_user_access($id);
$filecounts = ArtefactTypeFileBase::count_user_files(null, null, $group->id);
// Latest forums posts
// NOTE: it would be nicer if there was some generic way to get information
......@@ -72,6 +74,8 @@ $smarty = smarty(array(), array(), array(), array('sideblocks' => array(interact
$smarty->assign('group', $group);
$smarty->assign('groupid', $id);
$smarty->assign('foruminfo', $foruminfo);
$smarty->assign('strgroupviews', get_string('groupviewscount', 'group', count_records('view', 'group', $group->id)));
$smarty->assign('strcontent', get_string('groupfilescount', 'group', $filecounts->files, $filecounts->folders));
$smarty->display('group/view.tpl');
?>
......@@ -189,6 +189,7 @@ $string['pendingfriends'] = 'Pending friends';
$string['backtofriendslist'] = 'Back to Friends List';
$string['findnewfriends'] = 'Find New Friends';
$string['Views'] = 'Views';
$string['Files'] = 'Files';
$string['seeallviews'] = 'See all %s views...';
$string['noviewstosee'] = 'None that you can see :(';
$string['whymakemeyourfriend'] = 'This is why you should make me your friend:';
......@@ -256,4 +257,7 @@ $string['changeroleto'] = 'Change role to';
$string['rolechanged'] = 'Role changed';
$string['removefromgroup'] = 'Remove from group';
$string['userremoved'] = 'User removed';
$string['groupviewscount'] = 'This group has %s views';
$string['groupfilescount'] = 'This group has %s files in %s folders';
?>
......@@ -14,8 +14,8 @@
<a href="{$WWWROOT}user/view.php?id={$id|escape}">{$id|display_name|escape}</a>{if !$smarty.foreach.admins.last}, {/if}
{/foreach}</li>
<li><strong>{str tag=Created section=group}:</strong> {$group->ctime}</li>
{if $strgroupviews}<li>{$strgroupviews}</li>{/if}
{if $strcontent}<li>{$strcontent}</li>{/if}
{if $strgroupviews}<li><strong>{str tag=Views section=group}:</strong> {$strgroupviews}</li>{/if}
{if $strcontent}<li><strong>{str tag=Files section=group}:</strong> {$strcontent}</li>{/if}
</ul>
<div class="group-info-para">
......
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