Commit e1c964ef authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review

Merge changes I7f55717f,Iba2a5174

* changes:
  Bug 1514374: Fixing pagination in a number of places
  Bug 1515431: Missing templates for the group report page
parents ffa3dd74 0cbdb0e1
......@@ -31,7 +31,7 @@ $dashboard = new View($viewid);
if (!can_view_view($dashboard)) {
json_reply(true, get_string('accessdenied', 'error'));
}
$userid = $USER->get('id');
$views = View::view_search(
null, // $query
null, // $ownerquery
......
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('PUBLIC', 1);
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('pieforms/pieform.php');
require_once('collection.php');
// offset and limit for pagination
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
$setlimit = param_boolean('setlimit', false);
$owner = null;
$groupid = param_integer('group', 0);
$institutionname = param_alphanum('institution', false);
$urlparams = array();
if (!empty($groupid)) {
$group = group_current_group();
// Check if user can edit group collections <-> user can edit group views
$role = group_user_access($group->id);
$canedit = $role && group_role_can_edit_views($group, $role);
if (!$role) {
json_reply('local', get_string('accessdenied', 'error'));
}
$urlparams['group'] = $groupid;
}
else if (!empty($institutionname)) {
if ($institutionname == 'mahara') {
// Check if user is a site admin
$canedit = $USER->get('admin');
if (!$canedit) {
json_reply('local', get_string('accessdenied', 'error'));
}
}
else {
// Check if user is a institution admin
$canedit = $USER->get('admin') || $USER->is_institutional_admin();
if (!$canedit) {
json_reply('local', get_string('accessdenied', 'error'));
}
}
$urlparams['institution'] = $institutionname;
}
else {
$owner = $USER->get('id');
$canedit = true;
}
$baseurl = get_config('wwwroot') . 'collection/index.php';
if ($urlparams) {
$baseurl .= '?' . http_build_query($urlparams);
}
$data = Collection::get_mycollections_data($offset, $limit, $owner, $groupid, $institutionname);
foreach ($data->data as $value) {
$collection = new Collection($value->id);
$views = $collection->get('views');
if (!empty($views)) {
$value->views = $views['views'];
}
}
$smarty = smarty_core();
$smarty->assign('canedit', $canedit);
$smarty->assign('collections', $data->data);
$html = $smarty->fetch('collection/collectionresults.tpl');
$pagination = build_pagination(array(
'id' => 'collectionslist_pagination',
'class' => 'center',
'url' => $baseurl,
'count' => $data->count,
'limit' => $data->limit,
'offset' => $data->offset,
'datatable' => 'mycollections',
'jsonscript' => 'collection/index.json.php',
'firsttext' => '',
'previoustext' => '',
'nexttext' => '',
'lasttext' => '',
'numbersincludefirstlast' => false,
'resultcounttextsingular' => get_string('collection', 'collection'),
'resultcounttextplural' => get_string('collections', 'collection'),
));
json_reply(false, array(
'message' => null,
'data' => array(
'tablerows' => $html,
'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'],
'count' => $data->count,
'results' => $data->count . ' ' . ($data->count == 1 ? get_string('result') : get_string('results')),
'offset' => $data->offset,
'setlimit' => $setlimit,
'institution' => $institutionname,
'group' => $groupid,
)
));
......@@ -111,6 +111,8 @@ $pagination = build_pagination(array(
'count' => $data->count,
'limit' => $data->limit,
'offset' => $data->offset,
'datatable' => 'mycollections',
'jsonscript' => 'collection/index.json.php',
'firsttext' => '',
'previoustext' => '',
'nexttext' => '',
......@@ -149,7 +151,10 @@ setpageicon($smarty, $pageIcon);
$smarty->assign('canedit', $canedit);
$smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('collections', $data->data);
$html = $smarty->fetch('collection/collectionresults.tpl');
$smarty->assign('collectionhtml', $html);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('pagination_js', $pagination['javascript']);
$smarty->assign('headingclass', 'page-header');
$smarty->assign('PAGEHEADING', TITLE);
......
......@@ -51,6 +51,6 @@ $pagination = array(
'resultcounttextplural' => get_string('views', 'view'),
);
View::render_participation_views($groupviews, 'group/participationgroupviews.tpl', $pagination);
$groupviews = View::render_participation_views($groupviews, 'group/participationgroupviews.tpl', $pagination);
json_reply(false, array('data' => $groupviews));
......@@ -51,6 +51,6 @@ $pagination = array(
'resultcounttextplural' => get_string('views', 'view'),
);
View::render_participation_views($sharedviews, 'group/participationsharedviews.tpl', $pagination);
$sharedviews = View::render_participation_views($sharedviews, 'group/participationsharedviews.tpl', $pagination);
json_reply(false, array('data' => $sharedviews));
......@@ -49,7 +49,7 @@ $pagination = array(
'resultcounttextplural' => get_string('views', 'view'),
);
View::render_participation_views($sharedviews, 'group/participationsharedviews.tpl', $pagination);
$sharedviews = View::render_participation_views($sharedviews, 'group/participationsharedviews.tpl', $pagination);
$groupviews = View::get_participation_groupviews_data($group->id, $sort, $direction, $limit, $offset);
......@@ -63,13 +63,14 @@ $pagination = array(
'resultcounttextplural' => get_string('views', 'view'),
);
View::render_participation_views($groupviews, 'group/participationgroupviews.tpl', $pagination);
$groupviews = View::render_participation_views($groupviews, 'group/participationgroupviews.tpl', $pagination);
$smarty = smarty(array('paginator'));
$smarty->assign('baseurl', get_config('wwwroot') . 'group/report.php?group=' . $group->id);
$smarty->assign('heading', $group->name);
$smarty->assign('sharedviews', $sharedviews);
$smarty->assign('groupviews', $groupviews);
$smarty->assign('sort', $sort);
$smarty->assign('direction', $direction);
$smarty->display('group/report.tpl');
......@@ -4990,8 +4990,9 @@ class View {
* @param array options
* @param array pagination
*/
public function render_participation_views(&$views, $template, &$pagination) {
public function render_participation_views($views, $template, $pagination) {
$smarty = smarty_core();
$smarty->assign('itemcount', (!empty($views['data']) ? count($views['data']) : false));
$smarty->assign('items', $views['data']);
$views['tablerows'] = $smarty->fetch($template);
......@@ -5014,6 +5015,7 @@ class View {
$views['pagination'] = $pagination['html'];
$views['pagination_js'] = $pagination['javascript'];
}
return $views;
}
/**
......
......@@ -8,7 +8,7 @@
{if !$blogs->data}
<p class="no-results">{str tag=youhavenoblogs section=artefact.blog}</p>
{else}
<div id="myblogs" class="rel view-container">
<div id="bloglist" class="rel view-container">
<div class="panel-items js-masonry" data-masonry-options='{ "itemSelector": ".panel" }'>
{$blogs->tablerows|safe}
</div>
......
{foreach from=$collections item=collection}
<div class="list-group-item {cycle values='r0,r1'} {if $collection->submitinfo}list-group-item-warning{/if}">
{if $collection->views[0]->view}
<a href="{$collection->views[0]->fullurl}" class="outer-link"><span class="sr-only">{$collection->name}</span></a>
{/if}
<div class="row">
<div class="col-md-9">
<h3 class="title list-group-item-heading" title="{str tag=emptycollection section=collection}">
{$collection->name}
</h3>
<div class="detail">{$collection->description}</div>
<div class="detail">
<span class="lead text-small">{str tag=Views section=view}:</span>
{if $collection->views}
{foreach from=$collection->views item=view name=cviews}
<a href="{$view->fullurl}" class="inner-link">{$view->title}</a>{if !$.foreach.cviews.last}, {/if}
{/foreach}
{else}
{str tag=none}
{/if}
</div>
{if $collection->submitinfo}
<div class="detail submitted-viewitem">{str tag=collectionsubmittedtogroupon section=view arg1=$collection->submitinfo->url arg2=$collection->submitinfo->name arg3=$collection->submitinfo->time|format_date}</div>
{/if}
</div>
<div class="col-md-3">
<div class="inner-link btn-action-list">
{if !$collection->submitinfo && $canedit}
<div class="btn-top-right btn-group btn-group-top">
<a href="{$WWWROOT}collection/views.php?id={$collection->id}" title="{str tag=manageviews section=collection}" class="btn btn-default btn-xs">
<span class="icon icon-list icon-lg text-default"></span>
<span class="sr-only">{str(tag=manageviewsspecific section=collection arg1=$collection->name)|escape:html|safe}</span>
</a>
<a href="{$WWWROOT}collection/edit.php?id={$collection->id}" title="{str tag=edittitleanddescription section=view}" class="btn btn-default btn-xs">
<span class="icon icon-pencil icon-lg text-default"></span>
<span class="sr-only">{str(tag=editspecific arg1=$collection->name)|escape:html|safe}</span>
</a>
<a href="{$WWWROOT}collection/delete.php?id={$collection->id}" title="{str tag=deletecollection section=collection}" class="btn btn-default btn-xs">
<span class="icon icon-trash icon-lg text-danger"></span>
<span class="sr-only">{str(tag=deletespecific arg1=$collection->name)|escape:html|safe}</span>
</a>
</div>
{/if}
</div>
</div>
</div>
</div>
{/foreach}
......@@ -8,60 +8,15 @@
{if $collections}
<div class="panel panel-default">
<div id="mycollections" class="list-group">
{foreach from=$collections item=collection}
<div class="list-group-item {cycle values='r0,r1'} {if $collection->submitinfo}list-group-item-warning{/if}">
{if $collection->views[0]->view}
<a href="{$collection->views[0]->fullurl}" class="outer-link"><span class="sr-only">{$collection->name}</span></a>
{/if}
<div class="row">
<div class="col-md-9">
<h3 class="title list-group-item-heading" title="{str tag=emptycollection section=collection}">
{$collection->name}
</h3>
<div class="detail">{$collection->description}</div>
<div class="detail">
<span class="lead text-small">{str tag=Views section=view}:</span>
{if $collection->views}
{foreach from=$collection->views item=view name=cviews}
<a href="{$view->fullurl}" class="inner-link">{$view->title}</a>{if !$.foreach.cviews.last}, {/if}
{/foreach}
{else}
{str tag=none}
{/if}
</div>
{if $collection->submitinfo}
<div class="detail submitted-viewitem">{str tag=collectionsubmittedtogroupon section=view arg1=$collection->submitinfo->url arg2=$collection->submitinfo->name arg3=$collection->submitinfo->time|format_date}</div>
{/if}
</div>
<div class="col-md-3">
<div class="inner-link btn-action-list">
{if !$collection->submitinfo && $canedit}
<div class="btn-top-right btn-group btn-group-top">
<a href="{$WWWROOT}collection/views.php?id={$collection->id}" title="{str tag=manageviews section=collection}" class="btn btn-default btn-xs">
<span class="icon icon-list icon-lg text-default"></span>
<span class="sr-only">{str(tag=manageviewsspecific section=collection arg1=$collection->name)|escape:html|safe}</span>
</a>
<a href="{$WWWROOT}collection/edit.php?id={$collection->id}" title="{str tag=edittitleanddescription section=view}" class="btn btn-default btn-xs">
<span class="icon icon-pencil icon-lg text-default"></span>
<span class="sr-only">{str(tag=editspecific arg1=$collection->name)|escape:html|safe}</span>
</a>
<a href="{$WWWROOT}collection/delete.php?id={$collection->id}" title="{str tag=deletecollection section=collection}" class="btn btn-default btn-xs">
<span class="icon icon-trash icon-lg text-danger"></span>
<span class="sr-only">{str(tag=deletespecific arg1=$collection->name)|escape:html|safe}</span>
</a>
</div>
{/if}
</div>
</div>
</div>
</div>
{/foreach}
{$collectionhtml|safe}
</div>
</div>
{$pagination|safe}
{if $pagination_js}
<script type="application/javascript">
{$pagination_js|safe}
</script>
{/if}
{else}
<p class="no-results">
{str tag=nocollections section=collection}{if $addonelink} <a href={$addonelink}>{str tag=addone}</a>{/if}
......
......@@ -34,7 +34,7 @@
</h2>
{/if}
<div id="results" class="list-group">
<div id="membersearchresults" class="list-group">
{$results|safe}
</div>
</div>
......
{if count($items) > 0}
{foreach from=$items item=view}
<tr class="{cycle values='r0,r1'}">
<td class="sv"><h3 class="title"><a href="{$view->url}">{$view->title}</a></h3></td>
<td class="mc"><label class="hidden">{str tag=membercommenters section=group}: </label>
<ul>
{foreach from=$view->comments key=commenter item=info}
{if $info.member}<li><a href="{$WWWROOT}user/view.php?id={$info.commenter}">{$info.commenter|display_name:null:true}</a><span> ({$info.count})</span></li>{/if}
{/foreach}
</ul>
{if $view->mcomments > 0}<div class="detail">{$view->mcomments} {str tag=comments section=artefact.comment}</div>{/if}
</td>
<td class="ec"><label class="hidden">{str tag=extcommenters section=group}: </label>
<ul>
{foreach from=$view->comments key=commenter item=info}
{if $info.commenter|is_string}
<li>{$info.commenter}<span> ({$info.count})</span></li>
{elseif ! $info.member}
<li><a href="{$WWWROOT}user/view.php?id={$info.commenter}">{$info.commenter|display_name:null:true}</a><span> ({$info.count})</span></li>
{/if}
{/foreach}
</ul>
{if $view->ecomments > 0}<div class="detail">{$view->ecomments} {str tag=comments section=artefact.comment}</div>{/if}
</td>
</tr>
{/foreach}
{else}
<tr class="{cycle values='r0,r1'}"><td colspan="3" class="message">{str tag=noviewssharedwithgroupyet section=group}</td></tr>
{/if}
\ No newline at end of file
{if $itemcount}
{foreach from=$items item=view}
<tr class="{cycle values='r0,r1'}">
<td class="sv"><h3 class="title"><a href="{$view->url}">{$view->title}</a></h3></td>
<td class="sb"><label class="hidden">{str tag=sharedby section=view}: </label>
{if $view->owner}
<a href="{$WWWROOT}user/view.php?id={$view->owner}">{$view->owner|display_name:null:true}</a>
{elseif $view->group}
<a href="{$WWWROOT}group/view.php?id={$view->group}">{$view->groupname}</a>
{elseif $view->institution}
<a href="{$WWWROOT}institution/view.php?id={$view->institution}">{$view->institution}</a>
{/if}
</td>
<td class="mc"><label class="hidden">{str tag=membercommenters section=group}: </label>
<ul>
{foreach from=$view->comments key=commenter item=info}
{if $info.member}<li><a href="{$WWWROOT}user/view.php?id={$info.commenter}">{$info.commenter|display_name:null:true}</a><span> ({$info.count})</span></li>{/if}
{/foreach}
</ul>
{if $view->mcomments > 0}<div class="detail">{$view->mcomments} {str tag=comments section=artefact.comment}</div>{/if}
</td>
<td class="ec"><label class="hidden">{str tag=extcommenters section=group}: </label>
<ul>
{foreach from=$view->comments key=commenter item=info}
{if $info.commenter|is_string}
<li>{$info.commenter}<span> ({$info.count})</span></li>
{elseif ! $info.member}
<li><a href="{$WWWROOT}user/view.php?id={$info.commenter}">{$info.commenter|display_name:null:true}</a><span> ({$info.count})</span></li>
{/if}
{/foreach}
</ul>
{if $view->ecomments > 0}<div class="detail">{$view->ecomments} {str tag=comments section=artefact.comment}</div>{/if}
</td>
</tr>
{/foreach}
{else}
<tr class="{cycle values='r0,r1'}"><td colspan="4" class="message">{str tag=noviewssharedwithgroupyet section=group}</td></tr>
{/if}
\ No newline at end of file
{include file="header.tpl"}
{if !$sharedviews && !$groupviews}
<h3>{str tag=viewssharedtogroup section=view}</h3>
{if $sharedviews.count == '0'}
<p class="no-results">
{str tag=youhaventcreatedanyviewsyet section=view}
{str tag=noviewssharedwithgroupyet section=group}
</p>
{else}
<table id="sharedviewsreport" class="fullwidth groupreport">
<thead>
<tr>
......@@ -24,84 +23,23 @@
</tr>
</thead>
<tbody>
{if $sharedviews}
{foreach from=$sharedviews item=view}
<tr>
<td class="sv">
<h3 class="title">
<a href="{$view.baseurl}">{$view.title}</a>
</h3>
</td>
<td class="sb">
<label class="hidden">{str tag=sharedby section=view}: </label>
{if $view.owner}
<a href="{$WWWROOT}user/view.php?id={$view.owner}">{$view.user->id|display_name:null:true|escape}</a>
{elseif $view.group}
<a href="{$WWWROOT}group/view.php?id={$view.group}">{$view.groupname|escape}</a>
{elseif $view.institution}
<a href="{$WWWROOT}institution/view.php?id={$view.institution}">{$view.institution|escape}</a>
{/if}
</td>
<td class="mc">
<label class="hidden">{str tag=membercommenters section=group}: </label>
<ul>
{foreach from=$view.comments key=commenter item=info}
{if $info.member}
<li>
<a href="{$WWWROOT}user/view.php?id={$info.commenter}">
{$info.commenter|display_name:null:true|escape}
</a>
<span> ({$info.count})</span>
</li>
{/if}
{/foreach}
</ul>
{if $view.mcomments > 0}
<div class="detail">{$view.mcomments} {str tag=comments section=artefact.comment}</div>
{/if}
</td>
<td class="ec">
<label class="hidden">{str tag=extcommenters section=group}: </label>
<ul>
{foreach from=$view.comments key=commenter item=info}
{if $info.commenter|is_string}
<li>
{$info.commenter}
<span> ({$info.count})</span>
</li>
{elseif ! $info.member}
<li>
<a href="{$WWWROOT}user/view.php?id={$info.commenter}">
{$info.commenter|display_name:null:true|escape}
</a>
<span> ({$info.count})</span>
</li>
{/if}
{/foreach}
</ul>
{if $view.ecomments > 0}
<div class="detail">{$view.ecomments} {str tag=comments section=artefact.comment}</div>
{/if}
</td>
</tr>
{/foreach}
{elseif $svcount > 0}
<tr>
<td colspan="4" class="message">
{str tag=groupsharedviewsscrolled section=group}
</td>
</tr>
{else}
<tr>
<td colspan="4" class="message">
{str tag=noviewssharedwithgroupyet section=group}
</td>
</tr>
{/if}
{$sharedviews.tablerows|safe}
</tbody>
</table>
{$sharedviews.pagination|safe}
{if $sharedviews.pagination_js}
<script type="application/javascript">
{$sharedviews.pagination_js|safe}
</script>
{/if}
{/if}
<h3>{str tag=groupviews section=view}</h3>
{if $groupviews.count == '0'}
<p class="no-results">
{str tag=grouphasntcreatedanyviewsyet section=group}
</p>
{else}
<table id="groupviewsreport" class="fullwidth groupreport">
<thead>
<tr>
......@@ -122,66 +60,14 @@
</tr>
</thead>
<tbody>
{if $groupviews}
{foreach from=$groupviews item=view}
<tr class="{cycle values='r0,r1'}">
<td class="sv"><h3 class="title"><a href="{$view.fullurl}">{$view.title}</a></h3></td>
<td class="mc"><label class="hidden">{str tag=membercommenters section=group}: </label>
<ul>
{foreach from=$view.comments key=commenter item=info}
{if $info.member}
<li>
<a href="{$WWWROOT}user/view.php?id={$info.commenter}">
{$info.commenter|display_name:null:true|escape}
</a>
<span> ({$info.count})</span>
</li>
{/if}
{/foreach}
</ul>
{if $view.mcomments > 0}
<div class="detail">{$view.mcomments} {str tag=comments section=artefact.comment}</div>
{/if}
</td>
<td class="ec"><label class="hidden">{str tag=extcommenters section=group}: </label>
<ul>
{foreach from=$view.comments key=commenter item=info}
{if $info.commenter|is_string}
<li>
{$info.commenter}
<span> ({$info.count})</span>
</li>
{elseif ! $info.member}
<li>
<a href="{$WWWROOT}user/view.php?id={$info.commenter}">
{$info.commenter|display_name:null:true|escape}
</a>
<span> ({$info.count})</span>
</li>
{/if}
{/foreach}
</ul>
{if $view.ecomments > 0}
<div class="detail">{$view.ecomments} {str tag=comments section=artefact.comment}</div>
{/if}
</td>
</tr>
{/foreach}