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

Start filebrowser in the group's files area when configuring a block in a group view

parent 086acf17
......@@ -37,30 +37,25 @@ function pieform_element_filebrowser(Pieform $form, $element) {
global $USER, $_PIEFORM_FILEBROWSERS;
$smarty = smarty_core();
$group = $form->get_property('group');
$institution = $form->get_property('institution');
if (!empty($element['tabs'])) {
$tabdata = pieform_element_filebrowser_configure_tabs($element['tabs']);
$smarty->assign('tabs', $tabdata);
if ($tabdata['owner'] == 'group') {
if (!$group && $tabdata['owner'] == 'group') {
$group = $tabdata['ownerid'];
} else if ($tabdata['owner'] == 'institution') {
$institution = $tabdata['ownerid'];
} else if ($tabdata['owner'] == 'site') {
$institution = 'mahara';
} else if (!$institution) {
if ($tabdata['owner'] == 'institution') {
$institution = $tabdata['ownerid'];
} else if ($tabdata['owner'] == 'site') {
$institution = 'mahara';
}
}
}
if (empty($group)) {
$group = $form->get_property('group');
}
if (empty($institution)) {
$institution = $form->get_property('institution');
}
$userid = ($group || $institution) ? null : $USER->get('id');
if ($group) {
$smarty->assign('groupinfo', pieform_element_filebrowser_get_groupinfo($group));
}
$folder = $element['folder'];
$path = pieform_element_filebrowser_get_path($folder);
$smarty->assign('folder', $folder);
......@@ -71,7 +66,12 @@ function pieform_element_filebrowser(Pieform $form, $element) {
if (isset($element['browse'])) {
$smarty->assign('browse', (int) $element['browse']);
}
$config = array_map('intval', $element['config']);
if ($group && $config['edit']) {
$smarty->assign('groupinfo', pieform_element_filebrowser_get_groupinfo($group));
}
if ($config['select']) {
if (is_array($element['selectlistcallback'])) {
$selected = call_user_func_array($element['selectlistcallback']['name'], $element['selectlistcallback']['args']);
......@@ -128,6 +128,7 @@ function pieform_element_filebrowser(Pieform $form, $element) {
function pieform_element_filebrowser_get_groupinfo($group) {
require_once('group.php');
$groupinfo = array(
'roles' => group_get_role_info($group),
'perms' => group_get_default_artefact_permissions($group),
......
......@@ -622,7 +622,9 @@ class BlockInstance {
'jserrorcallback' => 'blockConfigError',
'elements' => $elements,
'viewgroup' => $this->get_view()->get('group'),
'group' => $this->get_view()->get('group'),
'viewinstitution' => $this->get_view()->get('institution'),
'institution' => $this->get_view()->get('institution'),
'configdirs' => $configdirs,
);
......
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