function fm_view_zipped($file, $groupid) { global $CFG, $USER; if ($file->folder == 0) { if ($groupid == 0) { $ziploc = $CFG->dataroot . "/" . fm_get_user_dir_space(); //."/".$file->link; } else { $ziploc = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid); //."/".$file->link; } } else { if ($groupid == 0) { $ziploc = $CFG->dataroot . "/" . fm_get_user_dir_space() . fm_get_folder_path($file->folder, false, $goupid); //."/".$file->link; } else { $ziploc = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid) . fm_get_folder_path($file->folder, false, $goupid); //."/".$file->link; } } /*$filelist = array(); $zip = zip_open($ziploc); if ($zip) { $count = 0; while ($zip_entry = zip_read($zip)) { $filelist[$count]->name = zip_entry_name($zip_entry); $filelist[$count]->actualsize = zip_entry_filesize($zip_entry); $filelist[$count]->compsize = zip_entry_compressedsize($zip_entry); $count++; } zip_close($zip); }*/ include_once "{$CFG->libdir}/pclzip/pclzip.lib.php"; $archive = new PclZip(cleardoubleslashes("{$ziploc}/{$file->link}")); if (!($zip = $archive->listContent(cleardoubleslashes("{$ziploc}")))) { notify($archive->errorInfo(true)); } else { $count = 0; foreach ($zip as $file) { $filelist[$count]->name = $file['filename']; $filelist[$count]->actualsize = $file['size']; $filelist[$count]->compsize = $file['compressed_size']; $count++; } } return $filelist; }
echo "</form>"; break; case 'unzip': /*if (isset($_POST['cancel'])) { print_simple_box(get_string('msgcancelok', 'block_file_manager'), 'center'); redirect("link_manage.php?id=$id&linkid=$zipid&rootdir=$rootdir"); } else if (isset($_POST['unzip'])) {*/ if ($groupid == 0) { $zipfile = fm_get_user_link($zipid); } else { $zipfile = fm_get_group_link($zipid, $groupid); } if ($groupid == 0) { $zipfileloc = $CFG->dataroot . "/" . fm_get_user_dir_space() . fm_get_folder_path($zipfile->folder, false, $groupid) . "/" . $zipfile->link; } else { $zipfileloc = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid) . fm_get_folder_path($zipfile->folder, false, $groupid) . "/" . $zipfile->link; } fm_unzip_file($zipfileloc, '', false, $zipfile->folder, $groupid); print_simple_box(get_string('msgmodificationok', 'block_file_manager'), "center", "", "#FFFFFF"); redirect("view.php?id={$id}&rootdir={$rootdir}&groupid={$groupid}"); //} /*$list = fm_view_zipped(fm_get_user_link($zipid), $groupid); $fmdir = fm_get_root_dir(); echo "<form name=\"unzipform\" method=\"post\" action=\"$CFG->wwwroot/$fmdir/zip.php?id={$id}&rootdir={$rootdir}&zipid=$zipid&what='$action'\">"; print_simple_box_start('center','500','#C0C0C0'); echo "<table name=\"viewziptable\" cellspacing=\"5\" align=\"center\" width=\"375\">"; echo "<tr>"; echo "<td align='center' nowrap><b><u>".get_string("file",'block_file_manager')."</u></b></td>"; echo "<td align='center' nowrap><b><u>".get_string("compressedsize",'block_file_manager')."</u></b></td>"; echo "<td align='center' nowrap><b><u>".get_string("actualsize",'block_file_manager')."</u></b></td>"; echo "</tr>";
if ($store->radioval == 'file') { // If hd space exceeded...unlinks file and issue warning if ($groupid == 0) { $tmpdir = $CFG->dataroot . "/" . fm_get_user_dir_space(); } else { $tmpdir = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid); } $usertype = fm_get_user_int_type(); $adminsettings = get_record('fmanager_admin', 'usertype', $usertype); if ($_FILES['linkfile']['size'] > $adminsettings->maxupload * 1048576) { error(get_string('errfiletoolarge', 'block_file_manager')); } else { $store->url = fm_upload_file($_FILES['linkfile'], $linkrename, $rootdir, $groupid); $dirsize = fm_get_size($tmpdir, 1); if ($adminsettings->maxdir * 1048576 - $dirsize < 0 && $adminsettings->maxdir != 0) { unlink($tmpdir . fm_get_folder_path($store->folder, false, $groupid) . "/" . $store->url); error(get_string('errmaxdirexceeded', 'block_file_manager'), "link_manage.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } } } if ($store->url != '') { fm_update_link($store, $groupid); notify(get_string('msgmodificationok', 'block_file_manager'), 'notifysuccess'); if (!$popup) { redirect("view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } else { redirect("link_manage.php?id={$id}&groupid={$groupid}&popup=close&rootdir={$rootdir}"); } } else { // Add option to rename file if it exists already notify(get_string('msgfileexists', 'block_file_manager', $_FILES['linkfile']['name']));
function fm_print_user_shared_folder($id, $foldid, $original, $ownertype, $ownerisuser, $ownerisgroup) { global $USER, $CFG; if ($ownertype == $ownerisuser) { $groupid = 0; } else { if ($ownertype == $ownerisgroup) { $groupid = $original; } } $fmdir = fm_get_root_dir(); $options = "menubar=1,toolbar=1,status=1,location=0,scrollbars,resizable,width=600,height=400,top=150,left=100"; $table->align = array("", "center", "center", "center"); $table->width = "100%"; $table->size = array("25%", "25%", "30%", "20%"); $table->wrap = array('no', 'no', 'yes', 'no'); $table->data = array(); $strnamename = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&ownertype={$ownertype}&original={$original}&catlinkid={$foldid}&tsort=sortname\">" . get_string("namename", 'block_file_manager') . "</a>"; $strcatname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&ownertype={$ownertype}&original={$original}&catlinkid={$foldid}&tsort=sortcat\">" . get_string("catname", 'block_file_manager') . "</a>"; $strdescname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&ownertype={$ownertype}&original={$original}&catlinkid={$foldid}&tsort=sortdesc\">" . get_string("descname", 'block_file_manager') . "</a>"; $strdatename = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&ownertype={$ownertype}&original={$original}&catlinkid={$foldid}&tsort=sortdate\">" . get_string("datename", 'block_file_manager') . "</a>"; $table->head = array($strnamename, $strcatname, $strdescname, $strdatename); // Get all shared folders under folder $sharedfolder = fm_get_all_sharedf_by_folder($original, $foldid); if ($sharedfolder) { foreach ($sharedfolder as $sf) { $name = ""; $cat = ""; $desc = ""; $date = ""; $tmpurl = "{$CFG->wwwroot}/blocks/file_manager/view_shared.php?id={$id}&ownertype={$ownertype}&original={$original}&foldlinkid={$sf->id}"; $name = "<a target=\"foldpopup\" title=\"" . get_string("msgopenfold", 'block_file_manager') . "\" href=\"{$tmpurl}\">" . "<img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/folder.gif\" > " . format_text($sf->name, FORMAT_PLAIN) . "</a>"; $table->data[] = array($name, $cat, $desc, $date); } } // Get all shared files under folder $sharedfiles = fm_get_all_shared_by_folder($original, $foldid); if ($sharedfiles) { foreach ($sharedfiles as $sf) { $name = ""; $cat = ""; $desc = ""; $date = ""; if ($sf->type == TYPE_FILE) { if ($sf->folder != 0) { $folderinfo = fm_get_folder_path($sf->folder, true); $bdir = $folderinfo . $sf->link; } else { $bdir = $sf->link; } $tmphref = "{$CFG->wwwroot}/blocks/file_manager/file.php?cid={$id}&groupid={$groupid}&ownertype={$ownertype}&fileid={$sf->id}"; $name = "<a target=\"urlpopup\" title=\"" . get_string("msgopenfile", 'block_file_manager', $sf->link) . "\" href=\"{$tmphref}\" onClick=\"window.open('{$tmphref}','urlpopup','{$options}');\"><img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/file.gif\" > " . format_text($sf->name, FORMAT_PLAIN) . "</a>"; } else { if ($sf->type == TYPE_URL) { $name = "<a target=\"urlpopup\" title=\"" . get_string("msgopenlink", 'block_file_manager') . "\" href=\"{$sf->link}\"" . "onClick=\"window.open('{$sf->link}','urlpopup','{$options}');\"><img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/www.gif\" > " . format_text($sf->name, FORMAT_PLAIN) . "</a>"; } else { if ($sf->type == TYPE_ZIP) { $tmphref = "{$CFG->wwwroot}/blocks/file_manager/file.php?cid={$id}&groupid={$groupid}&ownertype={$ownertype}&fileid={$sf->id}"; $name = "<a target=\"urlpopup\" title=\"" . get_string("msgopenfile", 'block_file_manager', $sf->link) . "\" href=\"{$tmphref}\" onClick=\"window.open('{$tmphref}','urlpopup','{$options}');\"><img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/zip.gif\" > " . format_text($sf->name, FORMAT_PLAIN) . "</a>"; } } } $desc = $sf->description; $cat = fm_get_user_categories($sf->category); $date = "<font size=1>" . userdate($sf->timemodified, "%m/%d/%Y %H:%I") . "</font>"; $table->data[] = array($name, $cat, $desc, $date); } } // If folder is empty if (!$sharedfiles && !$sharedfolder) { $table->data[] = array(get_string("msgnosharedfoldlink", 'block_file_manager')); } return $table; }
function filemanager_print_user_files_form($id = 1, $rootdir = 0, $action = 'none', $groupid = 0, $readonlyaccess = false) { global $CFG, $USER; // TO ADD : // if the user is not member of the group, he can't change anything, he just has the reading right only if the group mode is GROUP VISIBLE unset($table); $fmdir = fm_get_root_dir(); $strcbx = "<input type=\"checkbox\" name=\"cb[]\" value=\"0\" onClick=\"selectboxes(this, 1)\"> " . get_string("selectall", 'block_file_manager'); $strnamename = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}&tsort=sortname\">" . get_string('namename', 'block_file_manager') . "</a>"; $strcatname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}&tsort=sortcat\">" . get_string('catname', 'block_file_manager') . "</a>"; $strdescname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}&tsort=sortdesc\">" . get_string('descname', 'block_file_manager') . "</a>"; $strfilesizename = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}&tsort=sortsize\">" . get_string('filesizename', 'block_file_manager') . "</a>"; $strdatename = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}&tsort=sortdate\">" . get_string('datename', 'block_file_manager') . "</a>"; $stractionname = get_string('actionsname', 'block_file_manager'); if (!$readonlyaccess) { $table->head = array($strcbx, $strnamename, $strcatname, $strfilesizename, $strdatename, $stractionname); } else { $table->head = array("", $strnamename, $strcatname, $strfilesizename, $strdatename); } $table->align = array("center", "left", "center", "center", "center"); $table->width = "90%"; $table->size = array("5%", "20%", "15%", "10%", "10%", "12%"); $table->wrap = array(NULL, 'no', 'no', 'no', 'no'); $table->data = array(); if ($action == 'movesel') { $moveurl = "&what='{$action}'"; } else { $moveurl = ''; } // Not at root...so print an up folder link if ($rootdir != 0) { $tmpfold = get_record('fmanager_folders', "id", $rootdir); $name = "<a href=\"view.php?id={$id}&groupid={$groupid}&rootdir={$tmpfold->pathid}{$moveurl}\"><img border=\"0\" src=\"{$CFG->pixpath}/f/parent.gif\" alt=\"" . get_string("msgrootdir", 'block_file_manager') . "\" /> " . get_string("msgrootdir", 'block_file_manager') . "</a>"; $table->data[] = array("", $name, "", "", "", "", ""); } // Prints folders if ($groupid == 0) { $ownertype = OWNERISUSER; $allfolders = get_records('fmanager_folders', "owner={$USER->id} AND ownertype = {$ownertype} AND pathid", $rootdir, "name"); } else { $ownertype = OWNERISGROUP; $allfolders = get_records('fmanager_folders', "owner={$groupid} AND ownertype = {$ownertype} AND pathid", $rootdir, "name"); } if ($allfolders) { foreach ($allfolders as $folder) { $date = "<font size=1>" . userdate($folder->timemodified, "%m/%d/%Y %H:%I") . "</font>"; $cbx = "<input type=\"checkbox\" name=\"" . format_text($folder->name, FORMAT_PLAIN) . "\" value=\"fold{$folder->id}\">"; $actions = "<a title=\"" . get_string('edit') . "\" href=\"folder_manage.php?id={$id}&groupid={$groupid}&foldid={$folder->id}&rootdir={$rootdir}\"><img border=\"0\" src=\"{$CFG->pixpath}/i/edit.gif\" alt=\"" . get_string("edit") . "\" /></a> "; // deleting shared resources is disabled, from this dialog //<a title=\"".get_string('delete')."\" href=\"conf_delete.php?id=$id&groupid=$groupid&from=folder&fromid=$folder->id&rootdir=$rootdir\"><img border=\"0\" src=\"../file_manager/pix/delete.gif\" alt=\"" . get_string("delete"). "\" /></a>"; // Determines if the user can view the share option in the main course (default is no) $userinttype = fm_get_user_int_type(); $tmpcount = count_records('fmanager_shared', "sharedlink", $folder->id, "type", 2, "course", $id); if ($tmpcount > 0) { $icon = "group.gif"; } else { $icon = "group_noshare.gif"; } $priv = NULL; $priv = get_record('fmanager_admin', 'usertype', $userinttype); if ($id == 1) { // They can share from the main page to anyone if ($priv->sharetoany == 1) { $actions .= " <a title=\"" . get_string('sharetoany', 'block_file_manager') . "\" href=\"sharing.php?id={$id}&groupid={$groupid}&linkid={$folder->id}&groupid={$groupid}&from=folder&rootdir={$rootdir}\"><img border=\"0\" src=\"{$CFG->wwwroot}/blocks/file_manager/pix/" . $icon . "\" alt=\"" . get_string('sharetoany', 'block_file_manager') . "\" /></a>"; } } else { if ($priv->allowsharing == 1) { $actions .= " <a title=\"" . get_string('msgsharetoothers', 'block_file_manager') . "\" href=\"sharing.php?id={$id}&groupid={$groupid}&linkid={$folder->id}&from=folder&groupid={$groupid}&rootdir={$rootdir}\"><img border=\"0\" src=\"{$CFG->wwwroot}/blocks/file_manager/pix/" . $icon . "\" alt=\"" . get_string('msgsharetoothers', 'block_file_manager') . "!\" /></a>"; } } $name = "<a href=\"{$CFG->wwwroot}/" . fm_get_root_dir() . "/view.php?id={$id}&groupid={$groupid}&rootdir={$folder->id}{$moveurl}\"><img border=\"0\" src=\"{$CFG->wwwroot}/blocks/file_manager/pix/folder.gif\" alt=\"" . get_string('msgfolder', 'block_file_manager', format_text($folder->name, FORMAT_PLAIN)) . "\" />" . format_text($folder->name, FORMAT_PLAIN) . "</a>"; $catname = get_record('fmanager_categories', 'id', $folder->category); if (isset($catname->name)) { $catname = format_text($catname->name, FORMAT_PLAIN); } // Finds size of folder if ($groupid == 0) { $tmpdir = $CFG->dataroot . "/" . fm_get_user_dir_space() . fm_get_folder_path($folder->id, false, $groupid); } else { $tmpdir = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid) . fm_get_folder_path($folder->id, false, $groupid); } $filesize = fm_get_size($tmpdir); $desc = ''; // There is no description for folders if (!$readonlyaccess) { $table->data[] = array($cbx, $name, $catname, $filesize, $date, $actions); } else { $table->data[] = array("", $name, $catname, $filesize, $date); } } } // Prints all links if ($groupid == 0) { $ownertype = OWNERISUSER; $alllinks = get_records('fmanager_link', "owner={$USER->id} AND ownertype={$ownertype} AND folder", $rootdir, 'name'); } else { $ownertype = OWNERISGROUP; $alllinks = get_records('fmanager_link', "owner={$groupid} AND ownertype={$ownertype} AND folder", $rootdir, 'name'); } if (!$alllinks) { $table->data[] = array('', '<center><i><b>' . get_string('msgnolinks', 'block_file_manager') . '</b></i></center>', '', '', '', '', ''); } else { // Gets all associative information tied with user's links foreach ($alllinks as $link) { $catname = fm_get_user_categories($link->category); $date = "<font size=\"1\">" . userdate($link->timemodified, "%m/%d/%Y %H:%I") . "</font>"; $cbx = "<input type=\"checkbox\" name=\"" . format_text($link->name, FORMAT_PLAIN) . "\" value=\"{$link->id}\" />"; $actions = "<a title=\"" . get_string('edit') . "\" href=\"{$CFG->wwwroot}/blocks/file_manager/link_manage.php?id={$id}&groupid={$groupid}&linkid={$link->id}&rootdir={$rootdir}\"><img border=\"0\" src=\"{$CFG->pixpath}/i/edit.gif\" alt=\"" . get_string('edit') . "\" /></a> "; // deleting shared resources is disabled, from this dialog //<a title=\"".get_string('delete')."\" href=\"{$CFG->wwwroot}/blocks/file_manager/conf_delete.php?id=$id&groupid={$groupid}&from=link&fromid={$link->id}&rootdir={$rootdir}\"><img border=\"0\" src=\"../file_manager/pix/delete.gif\" alt=\"" . get_string('delete'). "\"></a>"; // Determines if the user can view the share option in the main course (default is no) $userinttype = fm_get_user_int_type(); $tmpcount = count_records('fmanager_shared', 'sharedlink', $link->id, 'type', 0, 'course', $id); if ($tmpcount > 0) { $icon = "group.gif"; } else { $icon = "group_noshare.gif"; } $priv = NULL; $priv = get_record('fmanager_admin', 'usertype', $userinttype); if ($id == 1) { // They can share from the main page to anyone if ($priv->sharetoany == 1) { $actions .= " <a title=\"" . get_string('sharetoany', 'block_file_manager') . "\" href=\"{$CFG->wwwroot}/blocks/file_manager/sharing.php?id={$id}&groupid={$groupid}&linkid={$link->id}&from='link'&rootdir={$rootdir}\"><img border=\"0\" src=\"{$CFG->wwwroot}/blocks/file_manager/pix/" . $icon . "\" alt=\"" . get_string('sharetoany', 'block_file_manager') . "\"></a>"; } } else { if ($priv->allowsharing == 1) { $actions .= " <a title=\"" . get_string('msgsharetoothers', 'block_file_manager') . "\" href=\"{$CFG->wwwroot}/blocks/file_manager/sharing.php?id={$id}&groupid={$groupid}&linkid={$link->id}&from='link'&rootdir={$rootdir}\"><img border=\"0\" src=\"{$CFG->wwwroot}/blocks/file_manager/pix/" . $icon . "\" alt=\"" . get_string('msgsharetoothers', 'block_file_manager') . "!\"></a>"; } } $options = "menubar=1,toolbar=1,status=1,location=0,scrollbars,resizable,width=700,height=500,top=20,left=20"; if ($link->type == TYPE_FILE) { if ($link->folder != 0) { $folderinfo->path = fm_get_folder_path($link->folder, false, $groupid); $bdir = $folderinfo->path . $link->link; } else { $bdir = $link->link; } $tmphref = "{$CFG->wwwroot}/blocks/file_manager/file.php?cid={$id}&groupid={$groupid}&fileid={$link->id}"; $name = "<a target=\"urlpopup\" title=\"" . get_string('msgopenfile', 'block_file_manager', $link->link) . "\" href=\"{$tmphref}\" onClick=\"window.open('{$tmphref}','urlpopup','{$options}');\"><img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/file.gif\" > " . format_text($link->name, FORMAT_PLAIN) . "</a>"; } else { if ($link->type == TYPE_URL) { $name = "<a target=\"urlpopup\" title=\"" . get_string("msgopenlink", 'block_file_manager') . "\" href=\"{$link->link}\"" . "onClick=\"window.open('{$link->link}','urlpopup','{$options}');\"><img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/www.gif\"> " . format_text($link->name, FORMAT_PLAIN) . "</a>"; } else { if ($link->type == TYPE_ZIP) { if ($link->folder != 0) { $folderinfo = fm_get_folder_path($link->folder, false, $groupid); if (isset($folderinfo->path)) { $bdir = $folderinfo->path . $link->link; } } else { $bdir = $link->link; } $tmphref = "{$CFG->wwwroot}/blocks/file_manager/file.php?cid={$id}&groupid={$groupid}&fileid={$link->id}"; $name = "<a target=\"urlpopup\" title=\"" . get_string('msgopenfile', 'block_file_manager', $link->link) . "\" href=\"{$tmphref}\" onClick=\"window.open('{$tmphref}','urlpopup','{$options}');\"><img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/zip.gif\" > " . format_text($link->name, FORMAT_PLAIN) . "</a>"; } } } /* $desc = wordwrap($link->description, 70, '<br/>'); $tmp = ''; if (strlen($desc) > 120) { $tmp = " <b><i>(More)...</i></b>"; } $desc = substr($desc, 0, 120); $desc = $desc.$tmp; */ $desc = format_text(shorten_text($link->description, 120)); // Finds size of file $filesize = ''; if ($link->type == TYPE_FILE || $link->type == TYPE_ZIP) { if ($groupid == 0) { $tmpdir = $CFG->dataroot . "/" . fm_get_user_dir_space() . fm_get_folder_path($link->folder, false, $groupid) . "/" . $link->link; } else { $tmpdir = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid) . fm_get_folder_path($link->folder, false, $groupid) . "/" . $link->link; } $filesize = fm_get_size($tmpdir); } if (!$readonlyaccess) { $table->data[] = array($cbx, $name, $catname, $filesize, $date, $actions); } else { $table->data[] = array("", $name, $catname, $filesize, $date); } } } return $table; }
function fm_view_zipped($file, $groupid) { global $CFG, $USER; if ($file->folder == 0) { if ($groupid == 0) { $ziploc = $CFG->dataroot . "/" . fm_get_user_dir_space(); //."/".$file->link; } else { $ziploc = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid); //."/".$file->link; } } else { if ($groupid == 0) { $ziploc = $CFG->dataroot . "/" . fm_get_user_dir_space() . fm_get_folder_path($file->folder, false, $goupid); //."/".$file->link; } else { $ziploc = $CFG->dataroot . "/" . fm_get_group_dir_space($groupid) . fm_get_folder_path($file->folder, false, $goupid); //."/".$file->link; } } $filelist = array(); $zip = zip_open($ziploc); if ($zip) { $count = 0; while ($zip_entry = zip_read($zip)) { $filelist[$count]->name = zip_entry_name($zip_entry); $filelist[$count]->actualsize = zip_entry_filesize($zip_entry); $filelist[$count]->compsize = zip_entry_compressedsize($zip_entry); $count++; } zip_close($zip); } return $filelist; }
// $groupid = optional_param('groupid', "0", PARAM_INT); $cid = required_param('id', PARAM_INT); // // Checks if user is owner of file, if not, checks if file is shared to them...if not...errors are displayed if (!fm_user_can_view_file($course->id, $fileid, $groupid)) { error(get_string("errnoviewfile", 'block_file_manager')); } $filerec = get_record('fmanager_link', "id", $fileid); $filename = $filerec->link; if ($groupid == 0) { $pathinfo = fm_get_user_dir_space($filerec->owner); } else { $pathinfo = fm_get_group_dir_space($groupid); } if ($tmpfolder = fm_get_folder_path($filerec->folder, true, $groupid)) { $pathinfo = $pathinfo . $tmpfolder; } $pathname = $CFG->dataroot . "/" . $pathinfo . "/" . $filename; // check that file exists if (!file_exists("{$pathname}")) { not_found($course->id); } $firstcourseid = 0; /* if (empty($CFG->disablemycourses) and !empty($USER->id) and !(has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) and $adminseesall) and !isguest()) { // Just print My Courses*/ if ($courses = get_my_courses($USER->id, 'visible DESC, fullname ASC')) { foreach ($courses as $course) { if ($course->id == SITEID) {