Commit c00d4633 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Get group menu tabs from artefact plugins

parent a6cfa223
......@@ -69,6 +69,7 @@ $smarty = smarty(
);
$smarty->assign('heading', get_string('groupfilesfor', 'artefact.file', $group->name));
$smarty->assign('groupid', $groupid);
$smarty->assign('grouptabs', group_get_menu_tabs($group));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->display('artefact:file:index.tpl');
......
......@@ -52,6 +52,7 @@ $string['file'] = 'file';
$string['File'] = 'File';
$string['filealreadyindestination'] = 'The file you moved is already in that folder';
$string['files'] = 'files';
$string['Files'] = 'Files';
$string['fileexists'] = 'File exists';
$string['fileexistsonserver'] = 'A file with the name %s already exists.';
$string['fileexistsoverwritecancel'] = 'A file with that name already exists. You can try a different name, or overwrite the existing file.';
......
......@@ -55,6 +55,15 @@ class PluginArtefactFile extends PluginArtefact {
);
}
public static function group_tabs($groupid) {
return array(
'files' => array(
'url' => 'artefact/file/groupfiles.php?group='.$groupid,
'title' => get_string('Files', 'artefact.file'),
),
);
}
public static function get_event_subscriptions() {
$subscriptions = array(
(object)array(
......
......@@ -70,6 +70,19 @@ abstract class PluginArtefact extends Plugin {
public static function menu_items() {
return array();
}
/**
* This function returns an array of menu items to be displayed
* on a group page when viewed by group members.
* Each item should be a StdClass object containing -
* - title language pack key
* - url relative to wwwroot
* @return array
*/
public static function group_tabs($groupid) {
return array();
}
}
/**
......
......@@ -109,6 +109,7 @@ define('TITLE', $group->name . ' - ' . get_string('changerole', 'group'));
$smarty = smarty(array(), array(), array(), array('sideblocks' => array(interaction_sideblock($groupid, $role))));
$smarty->assign('group', $group);
$smarty->assign('groupid', $groupid);
$smarty->assign('grouptabs', group_get_menu_tabs($group));
$smarty->assign('subtitle', get_string('changeroleofuseringroup', 'group', display_name($user), $group->name));
$smarty->assign('changeform', $changeform);
$smarty->assign('removeform', $removeform);
......
......@@ -49,6 +49,7 @@ list($html, $pagination, $count, $offset) = group_get_membersearch_data($id, $qu
$smarty = smarty(array('paginator', 'groupmembersearch'), array(), array(), array('sideblocks' => array(interaction_sideblock($id, $role))));
$smarty->assign('group', $group);
$smarty->assign('groupid', $id);
$smarty->assign('grouptabs', group_get_menu_tabs($group));
$smarty->assign('query', $query);
$smarty->assign('results', $html);
$smarty->assign('pagination', $pagination['html']);
......
......@@ -73,6 +73,7 @@ $foruminfo = get_records_sql_array('
$smarty = smarty(array(), array(), array(), array('sideblocks' => array(interaction_sideblock($id, $role))));
$smarty->assign('group', $group);
$smarty->assign('groupid', $id);
$smarty->assign('grouptabs', group_get_menu_tabs($group));
$smarty->assign('foruminfo', $foruminfo);
$smarty->assign('strgroupviews', get_string('groupviewscount', 'group', count_records('view', 'group', $group->id)));
$smarty->assign('strcontent', get_string('groupfilescount', 'group', $filecounts->files, $filecounts->folders));
......
......@@ -91,6 +91,9 @@ abstract class GroupType {
public static abstract function get_view_assessing_roles();
public static function get_group_artefact_plugins() {
return array('file');
}
}
?>
......@@ -260,4 +260,6 @@ $string['userremoved'] = 'User removed';
$string['groupviewscount'] = 'This group has %s views';
$string['groupfilescount'] = 'This group has %s files in %s folders';
$string['About'] = 'About';
?>
......@@ -443,4 +443,38 @@ function get_grouptype_options() {
return $groupoptions['jointype'];
}
function group_get_menu_tabs($group) {
$menu = array(
'info' => array(
'url' => 'group/view.php?id='.$group->id,
'title' => get_string('About', 'group'),
),
'members' => array(
'url' => 'group/members.php?id='.$group->id,
'title' => get_string('Members', 'group'),
),
'views' => array(
'url' => 'view/groupviews.php?group='.$group->id,
'title' => get_string('Views', 'group'),
),
);
if (!group_user_access($group->id)) {
return $menu;
}
safe_require('grouptype', $group->grouptype);
$artefactplugins = call_static_method('GroupType' . $grouptype, 'get_group_artefact_plugins');
if ($plugins = get_records_array('artefact_installed', 'active', 1)) {
foreach ($plugins as &$plugin) {
if (!in_array($plugin->name, $artefactplugins)) {
continue;
}
safe_require('artefact', $plugin->name);
$plugin_menu = call_static_method(generate_class_name('artefact',$plugin->name), 'group_tabs', $group->id);
$menu = array_merge($menu, $plugin_menu);
}
}
return $menu;
}
?>
{* Tabs and beginning of page container for group info pages *}
<ul id="grouppage-tabs">
<li{if $current == 'info'} class="current"{/if}><a href="{$WWWROOT}group/view.php?id={$groupid|escape}">About</a></li>
<li{if $current == 'members'} class="current"{/if}><a href="{$WWWROOT}group/members.php?id={$groupid|escape}">Members</a></li>
<li{if $current == 'views'} class="current"{/if}><a href="{$WWWROOT}view/groupviews.php?group={$groupid|escape}">Views</a></li>
<li{if $current == 'files'} class="current"{/if}><a href="{$WWWROOT}artefact/file/groupfiles.php?group={$groupid|escape}">Files</a></li>
{foreach from=$grouptabs key=tab item=tabinfo}
<li{if $current == $tab} class="current"{/if}><a href="{$WWWROOT}{$tabinfo.url}">{$tabinfo.title}</a></li>
{/foreach}
</ul>
<div id="grouppage-container">
......@@ -80,6 +80,7 @@ $pagination = build_pagination(array(
$smarty->assign('groupid', $groupid);
$smarty->assign('groupname', $group->name);
$smarty->assign('grouptabs', group_get_menu_tabs($group));
$smarty->assign('member', $member);
$smarty->assign('views', $data->data);
$smarty->assign('pagination', $pagination['html']);
......
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