Commit 3d716b07 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use View::get_views_and_collections for submission lists (bug #786389)



In the group views block, use View::get_views_and_collections to get
submission lists in which submitted views are grouped into
collections.  Also removes the old View::get_submitted_views function
which is no longer necessary.

Change-Id: Iecf288d4084db00bff9551f34abbb10215f87782
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 1f475d19
......@@ -79,11 +79,11 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
if (!empty($configdata['showsharedviews']) && isset($data['sharedviews'])) {
$dwoo->assign('sharedviews', $data['sharedviews']->data);
}
if (isset($data['allsubmittedviews'])) {
$dwoo->assign('allsubmittedviews', $data['allsubmittedviews']);
if (isset($data['allsubmitted'])) {
$dwoo->assign('allsubmitted', $data['allsubmitted']);
}
if (isset($data['mysubmittedviews'])) {
$dwoo->assign('mysubmittedviews', $data['mysubmittedviews']);
if (isset($data['mysubmitted'])) {
$dwoo->assign('mysubmitted', $data['mysubmitted']);
}
if (!$editing && isset($data['group_view_submission_form'])) {
$dwoo->assign('group_view_submission_form', $data['group_view_submission_form']);
......@@ -158,7 +158,8 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
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);
list($collections, $views) = View::get_views_and_collections(null, null, null, null, false, $group->id);
$data['allsubmitted'] = array_merge(array_values($collections), array_values($views));
}
}
......@@ -170,15 +171,8 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
// Display a list of views this user has submitted to this group, and a submission
// form containing drop-down of their unsubmitted views.
$data['mysubmittedviews'] = View::get_submitted_views($group->id, $USER->get('id'));
if (!empty($data['mysubmittedviews'])) {
foreach ($data['mysubmittedviews'] as &$v) {
if ($v['submittedtime']) {
$v['submittedtime'] = format_date($v['submittedtime']);
}
}
}
list($collections, $views) = View::get_views_and_collections($USER->get('id'), null, null, null, false, $group->id);
$data['mysubmitted'] = array_merge(array_values($collections), array_values($views));
$data['group_view_submission_form'] = group_view_submission_form($group->id);
}
......
......@@ -50,19 +50,19 @@
{/if}
{if $mysubmittedviews || $group_view_submission_form}
{if $mysubmitted || $group_view_submission_form}
<div class="groupviewsection">
{if $group_view_submission_form}
<h5>{str tag="submitaviewtogroup" section="view"}</h5>
<h5>{str tag="submittogroup" section="view"}</h5>
{/if}
<table class="fullwidth listing">
{if $mysubmittedviews}
{foreach from=$mysubmittedviews item=view}
{if $mysubmitted}
{foreach from=$mysubmitted item=item}
<tr class="{cycle values='r0,r1'}"><td class="submittedform">
{if $view.submittedtime}
{str tag=youhavesubmittedon section=view arg1=$view.fullurl arg2=$view.title arg3=$view.submittedtime}
{if $item.submittedtime}
{str tag=youhavesubmittedon section=view arg1=$item.url arg2=$item.name arg3=$item.submittedtime|format_date}
{else}
{str tag=youhavesubmitted section=view arg1=$view.fullurl arg2=$view.title}
{str tag=youhavesubmitted section=view arg1=$item.url arg2=$item.name}
{/if}
</td></tr>
{/foreach}
......@@ -76,21 +76,21 @@
</div>
{/if}
{if $allsubmittedviews}
{if $allsubmitted}
<div class="groupviewsection">
<table class="fullwidth listing">
<tr>
<td><h5>{str tag="viewssubmittedtogroup" section="view"}</h5></td>
<td><h5>{str tag="submissionstogroup" section="view"}</h5></td>
<th>{str tag=timeofsubmission section=view}</th>
</tr>
{foreach from=$allsubmittedviews item=view}
{foreach from=$allsubmitted item=item}
<tr class="{cycle values='r0,r1'}">
<td>
<strong><a href="{$view.fullurl}">{$view.title|str_shorten_text:60:true}</a></strong>
<div><a href="{profile_url($view.user)}">{$view.sharedby}</a></div>
<strong><a href="{$item.url}">{$item.name|str_shorten_text:60:true}</a></strong>
<div><a href="{$item.ownerurl}">{$item.ownername}</a></div>
</td>
<td>
<div class="postedon nowrap">{$view.submittedtime|format_date}</div>
<div class="postedon nowrap">{$item.submittedtime|format_date}</div>
</td>
</tr>
{/foreach}
......
......@@ -94,8 +94,8 @@ $string['youhaveviews'] = 'You have %s pages.';
$string['viewsownedbygroup'] = 'Pages owned by this group';
$string['viewssharedtogroup'] = 'Pages shared with this group';
$string['viewssharedtogroupbyothers'] = 'Pages shared with this group by others';
$string['viewssubmittedtogroup'] = 'Pages submitted to this group';
$string['submitaviewtogroup'] = 'Submit a page to this group';
$string['submissionstogroup'] = 'Submissions to this group';
$string['submittogroup'] = 'Submit a page or collection to this group';
$string['youhavesubmitted'] = 'You have submitted <a href="%s">%s</a> to this group';
$string['youhavesubmittedon'] = 'You submitted <a href="%s">%s</a> to this group on %s';
$string['listedinpages'] = 'Listed in pages';
......
......@@ -3369,42 +3369,6 @@ class View {
);
}
/**
* Get views submitted to a group
*/
public static function get_submitted_views($groupid, $userid=null) {
$values = array($groupid);
$where = 'submittedgroup = ?';
if (!empty($userid)) { // Filter by view owner
$values[] = (int) $userid;
$where .= ' AND v.owner = ?';
}
$viewdata = get_records_sql_assoc('
SELECT
v.id as id, v.title, v.description, v.owner, v.ownerformat, v.urlid,
' . db_format_tsfield('v.submittedtime','submittedtime') . '
FROM {view} v
INNER JOIN {usr} u ON u.id = v.owner
WHERE ' . $where . '
ORDER BY u.firstname ASC, u.lastname',
$values
);
if ($viewdata) {
View::get_extra_view_info($viewdata, false);
foreach ($viewdata as &$v) {
$v['sharedby'] = full_name($v['user']);
}
$viewdata = array_values($viewdata);
}
return $viewdata;
}
public static function get_extra_view_info(&$viewdata, $getartefacts=true, $gettags=true) {
if ($viewdata) {
// Get view owner details for display
......
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