Commit fa237250 authored by Nigel McNie's avatar Nigel McNie
Browse files

Make user related blocktypes render sensibly even if they end up in group views.

parent 941caf62
......@@ -53,6 +53,11 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
$userid = $instance->get_view()->get('owner');
if (!$userid) {
// 'My Friends' doesn't make sense for group/site views
return '';
}
$smarty = smarty_core();
$records = get_records_sql_array('SELECT usr1, usr2 FROM {usr_friend}
JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
......@@ -147,7 +152,7 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
if ($ownerid === null || $ownerid == $USER->get('id')) {
$title = get_string('title', 'blocktype.myfriends');
}
else {
......
......@@ -50,6 +50,10 @@ class PluginBlocktypeMyGroups extends SystemBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false) {
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
}
$smarty = smarty_core();
require_once('group.php');
// Group stuff
......@@ -81,7 +85,7 @@ class PluginBlocktypeMyGroups extends SystemBlocktype {
public static function override_instance_title(BlockInstance $instance) {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
if ($ownerid === null || $ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.mygroups');
}
return get_string('otherusertitle', 'blocktype.mygroups', display_name($ownerid, null, true));
......
......@@ -50,6 +50,10 @@ class PluginBlocktypeMyviews extends SystemBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false) {
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
}
$smarty = smarty_core();
// Get viewable views
......@@ -114,7 +118,7 @@ class PluginBlocktypeMyviews extends SystemBlocktype {
public static function override_instance_title(BlockInstance $instance) {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
if ($ownerid === null || $ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.myviews');
}
return get_string('otherusertitle', 'blocktype.myviews', display_name($ownerid, null, true));
......
......@@ -51,6 +51,9 @@ class PluginBlocktypeWall extends SystemBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
$owner = $instance->get_view()->get('owner');
if (!$owner) {
return '';
}
$userid = (!empty($USER) ? $USER->get('id') : 0);
$smarty = smarty_core();
......@@ -185,7 +188,7 @@ class PluginBlocktypeWall extends SystemBlocktype {
public static function override_instance_title(BlockInstance $instance) {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
if ($ownerid === null || $ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.wall');
}
return get_string('otherusertitle', 'blocktype.wall', display_name($ownerid, null, true));
......
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