function fm_print_user_shared($record, $id = 1, $ownertype, $ownerisuser, $ownerisgroup) { global $CFG, $USER; $table = NULL; $table->align = array("center", "", "center", "center", "center", "center"); $table->size = array("5%", "23%", "15%", "40%", "10%", "7%"); $table->data = array(); $sharedfiles = NULL; $mysql = "SELECT * FROM {$CFG->prefix}fmanager_shared WHERE userid = '{$USER->id}' AND owner = '{$record->id}' AND course = '{$id}' OR userid = '0' AND owner = '{$record->id}' AND course = '{$id}'"; $sharedfiles = get_records_sql($mysql); if (!$sharedfiles) { error(get_string("errnosharedfound", 'block_file_manager')); } $fmdir = fm_get_root_dir(); $strcbx = "<input type=\"checkbox\" name=\"cb[]\" value=\"0\" onClick=\"selectboxes(this)\"> " . get_string("selectall", 'block_file_manager'); $strnamename = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&original={$record->id}&ownertype={$ownertype}&tsort=sortname\">" . get_string("namename", 'block_file_manager') . "</a>"; $strcatname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&original={$record->id}&ownertype={$ownertype}&tsort=sortcat\">" . get_string("catname", 'block_file_manager') . "</a>"; $strdescname = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&original={$record->id}&ownertype={$ownertype}&tsort=sortdesc\">" . get_string("descname", 'block_file_manager') . "</a>"; $strdatename = "<a href=\"{$CFG->wwwroot}/{$fmdir}/view_shared.php?id={$id}&original={$record->id}&ownertype={$ownertype}&tsort=sortdate\">" . get_string("datename", 'block_file_manager') . "</a>"; $stractionname = get_string("actionsname", 'block_file_manager'); $table->head = array($strcbx, $strnamename, $strcatname, $strdescname, $strdatename, $stractionname); // Gets all shared files from the user foreach ($sharedfiles as $sharedfile) { // So far...if the user views a users shared files, the NEW flag will be removed at this point $sharedfile->viewed = 1; if (!update_record('fmanager_shared', $sharedfile)) { notify(get_string('errnoupdate', 'block_file_manager')); } if ($sharedfile->type == STYPE_FILE) { // for links $fileinfo = get_record('fmanager_link', "id", $sharedfile->sharedlink); } else { if ($sharedfile->type == STYPE_CAT) { // for categories $fileinfo = get_record('fmanager_categories', "id", $sharedfile->sharedlink); } else { if ($sharedfile->type == STYPE_FOLD) { $fileinfo = get_record('fmanager_folders', "id", $sharedfile->sharedlink); } } } if ($fileinfo) { fm_user_has_shared($fileinfo->owner, $sharedfile->sharedlink, $ownertype); // Ensures they can view the file } $options = "menubar=1,toolbar=1,status=1,location=0,scrollbars,resizable,width=700,height=500,top=20,left=20"; if ($sharedfile->type == STYPE_FILE) { // for links if ($fileinfo->type == TYPE_FILE) { $icon = "file.gif"; $tmphref = "{$CFG->wwwroot}/blocks/file_manager/file.php?cid={$id}&fileid={$fileinfo->id}"; if ($ownertype == $ownerisgroup) { $tmphref .= "&groupid={$sharedfile->owner}"; } $hreflink = "<a target=\"urlpopup\" title=\"" . get_string("msgopenfile", 'block_file_manager', $fileinfo->link) . "\" href=\"{$tmphref}\" onClick=\"window.open('{$fileinfo->link}','urlpopup','{$options}');\">"; } else { if ($fileinfo->type == TYPE_URL) { $hreflink = "<a target=\"urlpopup\" title=\"" . get_string("msgopenlink", 'block_file_manager') . "\" href=\"{$fileinfo->link}\"" . "onClick=\"window.open('{$fileinfo->link}','urlpopup','{$options}');\">"; $icon = "www.gif"; } else { if ($fileinfo->type == TYPE_ZIP) { $icon = "zip.gif"; $tmphref = "{$CFG->wwwroot}/blocks/file_manager/file.php?cid={$id}&fileid={$fileinfo->id}"; if ($ownertype == $ownerisgroup) { $tmphref .= "&groupid={$sharedfile->owner}"; } $hreflink = "<a target=\"urlpopup\" title=\"" . get_string("msgopenfile", 'block_file_manager', $fileinfo->link) . "\" href=\"{$tmphref}\" onClick=\"window.open('{$fileinfo->link}','urlpopup','{$options}');\">"; } } } } else { if ($sharedfile->type == STYPE_CAT) { // for categories $icon = "cat.gif"; $tmphref = "{$CFG->wwwroot}/blocks/file_manager/view_shared.php?id={$id}&ownertype={$ownertype}&original={$record->id}&catlinkid={$fileinfo->id}"; $hreflink = "<a target=\"catpopup\" title=\"" . get_string("msgopencat", 'block_file_manager') . "\" href=\"{$tmphref}\" onClick=\"window.open('{$tmphref}','catpopup','{$options}');\">"; } else { if ($sharedfile->type == STYPE_FOLD) { $icon = "folder.gif"; $tmphref = "{$CFG->wwwroot}/blocks/file_manager/view_shared.php?id={$id}&ownertype={$ownertype}&original={$record->id}&foldlinkid={$fileinfo->id}"; $hreflink = "<a target=\"foldpopup\" title=\"" . get_string("msgopenfold", 'block_file_manager') . "\" href=\"{$tmphref}\" onClick=\"window.open('{$tmphref}','foldpopup','{$options}');\">"; } } } if ($sharedfile->userid == 0) { $cbx = "<input type=\"checkbox\" name=\"cb[]\" value=\"{$sharedfile->id}\">"; } else { $cbx = "<input type=\"checkbox\" name=\"cb[]\" value=\"{$sharedfile->id}\">"; } $name = "{$hreflink}<img src=\"{$CFG->wwwroot}/blocks/file_manager/pix/{$icon}\" /> {$fileinfo->name}</a>"; $tmp = ""; if (isset($fileinfo->category)) { $tmp = fm_get_user_categories($fileinfo->category); } $desc = ""; if (isset($fileinfo->description)) { $desc = $fileinfo->description; } $date = "<font size=1>" . userdate($fileinfo->timemodified, "%m/%d/%Y %H:%I") . "</font>"; $actions = "<a href=\"conf_delete.php?id={$id}&from='shared'&fromid={$sharedfile->id}\" /><img border=\"0\" src=\"../file_manager/pix/delete.gif\" alt=\"" . get_string("delete") . "\"></a>"; $table->data[] = array($cbx, $name, $tmp, $desc, $date, $actions); } return $table; }
$msgexplain = get_string('msgexpsharedcat', 'block_file_manager'); } elseif (isset($foldlinkid)) { fm_user_has_shared($original, 0, $ownertype); fm_user_has_shared_folder($original, $foldlinkid, $ownertype); $head = get_string('sharedfold', 'block_file_manager'); $msgexplain = get_string('msgexpsharedfold', 'block_file_manager'); } else { $head = get_string('sharedfiles', 'block_file_manager'); } $strtitle = get_string('othersharedfiles', 'block_file_manager'); $nav[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($nav); print_header($strtitle, format_string($course->fullname), $navigation, '', '', false, " ", " "); // Ensures the user can view the file from the user if (isset($original)) { fm_user_has_shared($original, 0, $ownertype); } print_heading($head); echo '<br/>'; print_simple_box(text_to_html($msgexplain), 'center'); echo '<br/>'; if (isset($catlinkid)) { print_table(fm_print_user_shared_cat($id, $catlinkid, $original, $ownertype, OWNERISUSER, OWNERISGROUP)); } elseif (isset($foldlinkid)) { print_table(fm_print_user_shared_folder($id, $foldlinkid, $original, $ownertype, OWNERISUSER, OWNERISGROUP)); } else { // If $original not set, shows all files shared to current user if (!isset($original)) { // Link shows coursewide/sitewide shared if (!isset($sitewide)) { echo "<center><a href=\"view_shared.php?id={$id}&sitewide=1\">" . get_string("showallshared", 'block_file_manager') . "</a>";