Skip to content

Commit

Permalink
Documents: Fix record audio in groups BT#16848
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Nov 9, 2020
1 parent 7aae09c commit 3571e6b
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions main/document/record_audio.php
Expand Up @@ -16,6 +16,7 @@
api_protect_course_script();
api_block_anonymous_users();
api_protect_course_group(GroupManager::GROUP_TOOL_DOCUMENTS);
$groupId = api_get_group_id();
$_course = api_get_course_info();
$document_data = DocumentManager::get_document_data_by_id(
$_GET['id'],
Expand All @@ -25,16 +26,21 @@

$dir = '/';
$document_id = 0;
$group_properties = null;
if (!empty($groupId)) {
$group_properties = GroupManager::get_group_properties(api_get_group_id());
}
if (empty($document_data)) {
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties(api_get_group_id());
$document_id = DocumentManager::get_document_id($_course, $group_properties['directory']);
$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
$dir = $document_data['path'];
}
} else {
$document_id = $document_data['id'];
$dir = $document_data['path'];
}

//make some vars
$wamidir = $dir;
if ($wamidir === "/") {
Expand All @@ -53,7 +59,7 @@
$dir = substr($dir, 1);
}

if ($dir[0] != '/') {
if ($dir[0] !== '/') {
$dir = '/'.$dir;
}

Expand All @@ -67,20 +73,18 @@
$dir = '/';
}

//groups //TODO: clean
if (!empty($groupId)) {
$group = GroupManager::get_group_properties($groupId);
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace'),
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace').' '.$group_properties['name'],
];
}

$interbreadcrumb[] = ["url" => "./document.php?id=".$document_id.'&'.api_get_cidreq(), "name" => get_lang('Documents')];
$interbreadcrumb[] = ['url' => './document.php?id='.$document_id.'&'.api_get_cidreq(), 'name' => get_lang('Documents')];

if (!api_is_allowed_in_course()) {
api_not_allowed(true);
Expand All @@ -96,16 +100,6 @@
}

Event::event_access_tool(TOOL_DOCUMENT);

$display_dir = $dir;
if (isset($group)) {
$display_dir = explode('/', $dir);
unset($display_dir[0]);
unset($display_dir[1]);
$display_dir = implode('/', $display_dir);
}

// Interbreadcrumb for the current directory root path
$counter = 0;
if (isset($document_data['parents'])) {
foreach ($document_data['parents'] as $document_sub_data) {
Expand Down

0 comments on commit 3571e6b

Please sign in to comment.