/** * make a complete folder path * @param int $folderid A fm_folders unique id number * @param boolean $notsecure flag to not check for ownership...(for shared files) * @param int $groupid * @uses $USER */ function fm_get_folder_path($folderid, $notsecure = false, $groupid = 0) { global $USER; if ($folderid == 0) { return ''; } else { // Ensure user owns the folder if ($notsecure == false && $groupid == 0) { fm_user_owns_folder($folderid); } if ($notsecure == false && $groupid != 0) { fm_group_owns_folder($folderid, $groupid); } if (!($retval = get_record('fmanager_folders', 'id', $folderid))) { return ''; } return $retval->path . $retval->name; } }
} } if (fm_del_shared($cb)) { print_simple_box(get_string('msgdeleteok', 'block_file_manager'), 'center', "", "#FFFFFF"); redirect("view_shared.php?id={$id}&groupid={$groupid}"); } break; // deletes a folder // deletes a folder case 'folder': $tmpcount = 0; $list->type = get_string($from, 'block_file_manager') . ' ' . get_string('plural', 'block_file_manager'); foreach ($cb as $c) { $tmplist = ''; if ($c != 0) { if ($groupid == 0 && !fm_user_owns_folder($c) || $groupid != 0 && !fm_group_owns_folder($c, $groupid)) { die; } if (!isset($_POST['yesdel']) && !isset($_POST['nodel'])) { $tmpcount = count_records('fmanager_shared', 'sharedlink', $c, 'type', 2); if ($tmpcount > 0) { $tmplist .= '*'; } $tmprec = get_record('fmanager_folders', 'id', $c); $tmplist .= $tmprec->name; $list->thelist[] = $tmplist; } } if ($tmpcount > 0) { $list->inusemsg = get_string('msgfolderinuse', 'block_file_manager'); }
} if ($dupname != true) { print_simple_box(get_string('msgcreationok', 'block_file_manager'), "center", "", "#FFFFFF"); redirect("view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } } } } } else { if (isset($_POST['cancel'])) { print_simple_box(get_string('msgcancelok', 'block_file_manager'), 'center'); redirect("view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } } if (isset($foldid)) { // Renaming an existing folder if ($groupid == 0) { // Ensures user owns the folder fm_user_owns_folder($foldid); } else { // Ensures group owns the folder fm_group_owns_folder($foldid, $groupid); } print_simple_box(get_string('msgfoldmod', 'block_file_manager'), 'center'); } else { print_simple_box(get_string('msgfoldcreate', 'block_file_manager'), 'center'); } print_simple_box_start('center', '350'); include "folder_manage.html"; print_simple_box_end(); print_footer();
$dupfile = false; $onload = ''; if ($popup == 'close') { $onload = 'onload="window.close()"'; } elseif ($popup != '') { $onload = 'onload="window.focus()"'; } if (!($course = get_record('course', 'id', $id))) { error('Invalid Course Id', "view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } require_login($course->id); // Ensures the user is able to view the fmanager fm_check_access_rights($course->id); if ($groupid == 0) { // Ensures user owns the folder fm_user_owns_folder($rootdir); } else { // Ensures group owns the folder fm_group_owns_folder($rootdir, $groupid); // Depending on the groupmode, ensures that the user is member of the group and is allowed to access // 1.8 old code compatible if (function_exists('build_navigation')) { $groupmode = groups_get_course_groupmode($course); } else { $groupmode = groupmode($course); } switch ($groupmode) { case NOGROUPS: // Should no to be there ... error(get_string('errnogroups', 'block_file_manager'), "{$CFG->wwwroot}/course/view.php?id={$course->id}"); break;
case SEPARATEGROUPS: if (!$canmanagegroups && !groups_is_member($groupid)) { // Must check if the user is member of that group error(get_string('errnotmemberreadonly', 'block_file_manager'), "view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } break; } } $type = 0; // Link shared by default if ($from == 'link') { $type = 0; foreach ($cb as $c) { if (substr($c, 0, 2) == 'f-') { if ($groupid == 0) { fm_user_owns_folder(substr($c, 2)); } else { fm_group_owns_folder(substr($c, 2), $groupid); } } else { if ($groupid == 0) { fm_user_owns_link($c); } else { fm_group_owns_link($c, $groupid); } } } } elseif ($from == 'category') { $type = 1; foreach ($cb as $c) { if ($groupid == 0) {