Commit 10b1c1bc authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Override block instance titles for 'My Friends', etc profile block types (bug #3085)

parent 6e996933
......@@ -55,6 +55,14 @@ abstract class PluginBlocktype extends Plugin {
public static abstract function get_title();
/**
* Allows block types to override the instance's title.
*
* For example: My Views, My Groups, My Friends, Wall
*/
public static function override_instance_title(BlockInstance $instance) {
}
public static abstract function get_description();
public static abstract function get_categories();
......@@ -438,7 +446,8 @@ class BlockInstance {
$smarty = smarty_core();
$smarty->assign('id', $this->get('id'));
$smarty->assign('title', $this->get('title'));
$title = call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'override_instance_title', $this);
$smarty->assign('title', $title ? $title : $this->get('title'));
$smarty->assign('column', $this->get('column'));
$smarty->assign('order', $this->get('order'));
......@@ -472,7 +481,8 @@ class BlockInstance {
$smarty = smarty_core();
$smarty->assign('id', $this->get('id'));
$smarty->assign('title', $this->get('title'));
$title = call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'override_instance_title', $this);
$smarty->assign('title', $title ? $title : $this->get('title'));
// If this block is for just one artefact, we set the title of the
// block to be a link to view more information about that artefact
......
......@@ -27,5 +27,6 @@
defined('INTERNAL') || die();
$string['title'] = 'My Friends';
$string['otherusertitle'] = "%s's Friends";
$string['description'] = 'Display your friends';
?>
......@@ -154,6 +154,15 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
return $view->get('owner') != null;
}
public static function override_instance_title(BlockInstance $instance) {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.myfriends');
}
return get_string('otherusertitle', 'blocktype.myfriends', display_name($ownerid, null, true));
}
}
?>
......@@ -27,5 +27,6 @@
defined('INTERNAL') || die();
$string['title'] = 'My Groups';
$string['otherusertitle'] = "%s's Groups";
$string['description'] = 'Display a list of the groups you belong to';
?>
......@@ -78,6 +78,15 @@ class PluginBlocktypeMyGroups extends SystemBlocktype {
return $view->get('owner') != null;
}
public static function override_instance_title(BlockInstance $instance) {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.mygroups');
}
return get_string('otherusertitle', 'blocktype.mygroups', display_name($ownerid, null, true));
}
}
?>
......@@ -27,5 +27,6 @@
defined('INTERNAL') || die();
$string['title'] = 'My Views';
$string['otherusertitle'] = "%s's Views";
$string['description'] = 'Display all your views that are visible to the person viewing your profile';
?>
......@@ -111,6 +111,15 @@ class PluginBlocktypeMyviews extends SystemBlocktype {
return $view->get('owner') != null;
}
public static function override_instance_title(BlockInstance $instance) {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.myviews');
}
return get_string('otherusertitle', 'blocktype.myviews', display_name($ownerid, null, true));
}
}
?>
......@@ -27,6 +27,7 @@
defined('INTERNAL') || die();
$string['title'] = 'Wall';
$string['otherusertitle'] = "%s's Wall";
$string['description'] = 'Display an area where people can leave you comments';
$string['noposts'] = 'No wall posts to display';
$string['makeyourpostprivate'] = 'Make your post private?';
......
......@@ -181,6 +181,15 @@ class PluginBlocktypeWall extends SystemBlocktype {
return $view->get('type') == 'profile';
}
public static function override_instance_title(BlockInstance $instance) {
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.wall');
}
return get_string('otherusertitle', 'blocktype.wall', display_name($ownerid, null, true));
}
}
?>
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