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

Show submission information on collection index page (bug #786389)



On a user's collections list, remove edit and delete buttons, and
display an additional message for submitted collections.

Change-Id: I02760d10b76da04d34b666056db7a68017f8a338
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a9eef1b4
......@@ -294,7 +294,7 @@ class Collection {
public static function get_mycollections_data($offset=0, $limit=10) {
global $USER;
($data = get_records_sql_array("
($data = get_records_sql_assoc("
SELECT c.id, c.description, c.name
FROM {collection} c
WHERE c.owner = ?
......@@ -302,9 +302,11 @@ class Collection {
LIMIT ? OFFSET ?", array($USER->get('id'), $limit, $offset)))
|| ($data = array());
self::add_submission_info($data);
$result = (object) array(
'count' => count_records('collection', 'owner', $USER->get('id')),
'data' => $data,
'data' => array_values($data),
'offset' => $offset,
'limit' => $limit,
);
......@@ -312,6 +314,47 @@ class Collection {
return $result;
}
private static function add_submission_info(&$data) {
if (empty($data)) {
return;
}
$records = get_records_sql_assoc('
SELECT c.id, c.submittedgroup, c.submittedhost, ' . db_format_tsfield('submittedtime') . ',
sg.name AS groupname, sg.urlid, sh.name AS hostname
FROM {collection} c
LEFT JOIN {group} sg ON c.submittedgroup = sg.id
LEFT JOIN {host} sh ON c.submittedhost = sh.wwwroot
WHERE c.id IN (' . join(',', array_fill(0, count($data), '?')) . ')
AND (c.submittedgroup IS NOT NULL OR c.submittedhost IS NOT NULL)',
array_keys($data)
);
if (empty($records)) {
return;
}
foreach ($records as $r) {
if (!empty($r->submittedgroup)) {
$groupdata = (object) array(
'id' => $r->submittedgroup,
'name' => $r->groupname,
'urlid' => $r->urlid,
'time' => $r->submittedtime,
);
$groupdata->url = group_homepage_url($groupdata);
$data[$r->id]->submitinfo = $groupdata;
}
else if (!empty($r->submittedhost)) {
$data[$r->id]->submitinfo = (object) array(
'name' => $r->hostname,
'url' => $r->submittedhost,
'time' => $r->submittedtime,
);
}
}
}
/**
* Gets the fields for the new/edit collection form
* - populates the fields with collection data if it is an edit
......
......@@ -10,11 +10,14 @@
{foreach from=$collections item=collection}
<tr class="{cycle values='r0,r1'}">
<td>
{if !$collection->submitinfo}
<div class="fr viewcontrolbuttons">
<a href="{$WWWROOT}collection/views.php?id={$collection->id}" title="{str tag=manageviews section=collection}"><img src="{theme_url filename='images/manage.gif'}" alt="{str tag=manageviews section=collection}"></a>
<a href="{$WWWROOT}collection/edit.php?id={$collection->id}" title="{str tag=edittitleanddescription section=view}"><img src="{theme_url filename='images/edit.gif'}" alt="{str tag=edit}"></a>
<a href="{$WWWROOT}collection/delete.php?id={$collection->id}" title="{str tag=deletecollection section=collection}"><img src="{theme_url filename='images/icon_close.gif'}" alt="{str tag=delete}"></a>
</div>
{/if}
{if $collection->views[0]->view}
<h3><a href="{$collection->views[0]->fullurl}">{$collection->name}</a></h3>
{else}
......@@ -35,6 +38,10 @@
{/if}
</div>
</div>
{if $collection->submitinfo}
<div class="videsc submitted-viewitem">{str tag=collectionsubmittedtogroupon section=view arg1=$collection->submitinfo->url arg2=$collection->submitinfo->name arg3=$collection->submitinfo->time|format_date}</div>
{/if}
</td>
</tr>
{/foreach}
......
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