Commit 182f2913 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fixes for display of group artefacts in views

parent fb265a61
......@@ -302,7 +302,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
$smarty->assign('iconpath', $this->get_icon($options));
$smarty->assign('downloadpath', $downloadpath);
$smarty->assign('filetype', $filetype);
$smarty->assign('owner', display_name($this->get('owner')));
$smarty->assign('owner', $this->display_owner());
$smarty->assign('created', strftime(get_string('strftimedaydatetime'), $this->get('ctime')));
$smarty->assign('modified', strftime(get_string('strftimedaydatetime'), $this->get('mtime')));
$smarty->assign('size', $this->describe_size() . ' (' . $this->get('size') . ' ' . get_string('bytes', 'artefact.file') . ')');
......
......@@ -533,6 +533,17 @@ abstract class ArtefactType {
return $this->get('title');
}
public function display_owner() {
if ($owner = $this->get('owner')) {
return display_name($owner);
}
if ($group = $this->get('group')) {
return get_field('group', 'name', 'id', $group);
}
return null;
}
// ******************** HELPER FUNCTIONS ******************** //
protected function get_artefact_type() {
......
......@@ -47,6 +47,7 @@ class View {
private $artefact_instances;
private $artefact_metadata;
private $ownerobj;
private $groupobj;
private $numcolumns;
private $layout;
private $columns;
......@@ -234,6 +235,13 @@ class View {
return $this->ownerobj;
}
public function get_group_object() {
if (!isset($this->groupobj)) {
$this->groupobj = get_record('group', 'id', $this->get('group'));
}
return $this->groupobj;
}
public function delete() {
delete_records('artefact_feedback','view',$this->id);
......@@ -1103,9 +1111,10 @@ class View {
*/
public function formatted_owner() {
$user = $this->get_owner_object();
if ($this->get('owner')) {
$user = $this->get_owner_object();
switch ($this->ownerformat) {
switch ($this->ownerformat) {
case FORMAT_NAME_FIRSTNAME:
return $user->firstname;
case FORMAT_NAME_LASTNAME:
......@@ -1119,7 +1128,26 @@ class View {
case FORMAT_NAME_DISPLAYNAME:
default:
return display_name($user);
}
} else if ($this->get('group')) {
$group = $this->get_group_object();
return $group->name;
}
return null;
}
public function formatted_heading() {
if ($this->get('owner')) {
$link = 'user/view.php?id='.$this->get('owner');
}
else if ($this->get('group')) {
$link = 'group/view.php?id='.$this->get('group');
}
else {
$link = '';
}
return '<a href="' . get_config('wwwroot') . 'view/view.php?id=' . $this->get('id') .'">' . hsc($this->get('title')) . '</a> ' . get_string('by', 'view') . ' <a href="' . get_config('wwwroot') . $link . '">' . $this->formatted_owner() . '</a>';
}
/**
......
......@@ -87,7 +87,7 @@ $artefactpath[] = array(
'title' => $artefact->display_title(),
);
$heading = '<a href="' . get_config('wwwroot') . 'view/view.php?id=' . $view->get('id') .'">' . hsc($view->get('title')) . '</a> ' . get_string('by', 'view') . ' <a href="' . get_config('wwwroot') .'user/view.php?id=' . $view->get('owner'). '">' . $view->formatted_owner() . '</a>';
$heading = $view->formatted_heading();
foreach ($artefactpath as $item) {
if (empty($item['url'])) {
$heading .= ': ' . $item['title'];
......
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