Commit 9ad2968a authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add lists of submitted, shared views to group home page

parent 871baf39
...@@ -30,6 +30,7 @@ require(dirname(dirname(__FILE__)) . '/init.php'); ...@@ -30,6 +30,7 @@ require(dirname(dirname(__FILE__)) . '/init.php');
require_once('group.php'); require_once('group.php');
require_once('searchlib.php'); require_once('searchlib.php');
require_once(get_config('docroot') . 'interaction/lib.php'); require_once(get_config('docroot') . 'interaction/lib.php');
require_once(get_config('libroot') . 'view.php');
safe_require('artefact', 'file'); safe_require('artefact', 'file');
$id = param_integer('id'); $id = param_integer('id');
...@@ -104,6 +105,16 @@ $smarty->assign('membercount', count_records('group_member', 'group', $group->id ...@@ -104,6 +105,16 @@ $smarty->assign('membercount', count_records('group_member', 'group', $group->id
$smarty->assign('viewcount', count_records('view', 'group', $group->id)); $smarty->assign('viewcount', count_records('view', 'group', $group->id));
$smarty->assign('filecount', $filecounts->files); $smarty->assign('filecount', $filecounts->files);
$smarty->assign('foldercount', $filecounts->folders); $smarty->assign('foldercount', $filecounts->folders);
if ($role) {
// For group members, display a list of views that others have
// shared to the group
$viewdata = View::get_sharedviews_data(null, 0, $group->id);
$smarty->assign('sharedviews', $viewdata->data);
if (group_user_can_assess_submitted_views($group->id, $USER->get('id'))) {
// Display a list of views submitted to the group
$smarty->assign('submittedviews', View::get_submitted_views($group->id));
}
}
$smarty->display('group/view.tpl'); $smarty->display('group/view.tpl');
?> ?>
...@@ -70,6 +70,8 @@ $string['nobodycanseethisview'] = 'Nobody can see this View'; ...@@ -70,6 +70,8 @@ $string['nobodycanseethisview'] = 'Nobody can see this View';
$string['noviews'] = 'You have no Views.'; $string['noviews'] = 'You have no Views.';
$string['viewsownedbygroup'] = 'Views owned by this group'; $string['viewsownedbygroup'] = 'Views owned by this group';
$string['viewssharedtogroup'] = 'Views shared to this group'; $string['viewssharedtogroup'] = 'Views shared to this group';
$string['viewssharedtogroupbyothers'] = 'Views shared to this group by others';
$string['viewssubmittedtogroup'] = 'Views submitted to this group';
// access levels // access levels
$string['public'] = 'Public'; $string['public'] = 'Public';
......
...@@ -1709,7 +1709,12 @@ class View { ...@@ -1709,7 +1709,12 @@ class View {
$ph, $offset, $limit $ph, $offset, $limit
); );
View::get_extra_view_info($viewdata); if ($viewdata) {
View::get_extra_view_info($viewdata);
}
else {
$viewdata = array();
}
return (object) array( return (object) array(
'data' => array_values($viewdata), 'data' => array_values($viewdata),
...@@ -1718,6 +1723,26 @@ class View { ...@@ -1718,6 +1723,26 @@ class View {
} }
/**
* Get views submitted to a group
*/
public static function get_submitted_views($groupid) {
$viewdata = get_records_sql_assoc('
SELECT id, title, description, owner, ownerformat
FROM {view}
WHERE submittedto = ?
ORDER BY title, id',
array($groupid), $offset, $limit
);
if ($viewdata) {
View::get_extra_view_info($viewdata);
return array_values($viewdata);
}
return false;
}
public static function get_extra_view_info(&$viewdata) { public static function get_extra_view_info(&$viewdata) {
if ($viewdata) { if ($viewdata) {
// Get view owner details for display // Get view owner details for display
...@@ -1761,6 +1786,7 @@ class View { ...@@ -1761,6 +1786,7 @@ class View {
$groups = get_records_select_assoc('group', 'id IN (' . join(',', $groups) . ')', null, '', 'id,name'); $groups = get_records_select_assoc('group', 'id IN (' . join(',', $groups) . ')', null, '', 'id,name');
} }
foreach ($viewdata as &$v) { foreach ($viewdata as &$v) {
$v->shortdescription = clean_text(str_shorten(str_replace('<br />', ' ', $v->description), 100, true));
if ($v->owner) { if ($v->owner) {
$v->sharedby = View::owner_name($v->ownerformat, $owners[$v->owner]); $v->sharedby = View::owner_name($v->ownerformat, $owners[$v->owner]);
} else if ($v->group) { } else if ($v->group) {
......
...@@ -42,6 +42,59 @@ ...@@ -42,6 +42,59 @@
<p><a href="{$WWWROOT}interaction/forum/?group={$group->id|escape}">{str tag=gotoforums section=interaction.forum} &raquo;</a></p> <p><a href="{$WWWROOT}interaction/forum/?group={$group->id|escape}">{str tag=gotoforums section=interaction.forum} &raquo;</a></p>
</div> </div>
{if $sharedviews}
<div class="group-info-para">
<h3>{str tag="viewssharedtogroupbyothers" section="view"}</h3>
<table id="myviewstable" class="groupviews">
{foreach from=$sharedviews item=view}
<tr class="r{cycle values=0,1}">
<td>
<a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|escape}</a>
{if $view.sharedby}
{str tag=by section=view}
{if $view.group}
<a href="{$WWWROOT}group/view.php?id={$view.group}">{$view.sharedby}</a>
{else}
<a href="{$WWWROOT}user/view.php?id={$view.owner}">{$view.sharedby}</a>
{/if}
{/if}
<div>{$view.shortdescription}</div>
{if $view.template}
<div><a href="">{str tag=copythisview section=view}</a></div>
{/if}
</td>
</tr>
{/foreach}
</table>
<div class="center">{$pagination}</div>
</div>
{/if}
{if $submittedviews}
<div class="group-info-para">
<h3>{str tag="viewssubmittedtogroup" section="view"}</h3>
<table id="myviewstable" class="groupviews">
{foreach from=$submittedviews item=view}
<tr class="r{cycle values=0,1}">
<td>
<a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|escape}</a>
{if $view.sharedby}
{str tag=by section=view}
{if $view.group}
<a href="{$WWWROOT}group/view.php?id={$view.group}">{$view.sharedby}</a>
{else}
<a href="{$WWWROOT}user/view.php?id={$view.owner}">{$view.sharedby}</a>
{/if}
{/if}
<div>{$view.shortdescription}</div>
</td>
</tr>
{/foreach}
</table>
<div class="center">{$pagination}</div>
</div>
{/if}
{include file="group/tabend.tpl"} {include file="group/tabend.tpl"}
{include file="columnleftend.tpl"} {include file="columnleftend.tpl"}
......
...@@ -53,18 +53,12 @@ $can_edit = group_user_can_edit_views($groupid); ...@@ -53,18 +53,12 @@ $can_edit = group_user_can_edit_views($groupid);
$smarty = smarty(); $smarty = smarty();
$smarty->assign('heading', $group->name); $smarty->assign('heading', $group->name);
//if ($shared) { if ($can_edit) {
// $data = View::get_sharedviews_data($limit, $offset, $groupid); $data = View::get_myviews_data($limit, $offset, $groupid);
// $smarty->assign('shared', true); }
//} else {
//else { $data = View::view_search(null, $groupid, null, null, $limit, $offset);
if ($can_edit) { }
$data = View::get_myviews_data($limit, $offset, $groupid);
}
else {
$data = View::view_search(null, $groupid, null, null, $limit, $offset);
}
//}
$userid = $USER->get('id'); $userid = $USER->get('id');
......
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