} else { redirect("{$from}.php?id={$id}&groupid={$groupid}&linkid={$fromid}"); } } else { redirect("view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } } } } if (isset($catid)) { // Modifying an existing category if ($groupid == 0) { fm_user_owns_cat($catid); // Ensures the user owns the category } else { fm_group_owns_cat($catid, $groupid); // Depending on the groupmode, ensures that the user is member of the group and is allowed to access $groupmode = groups_get_course_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 VISIBLEGROUPS: 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; }
print_simple_box(get_string('msgcancelok', 'block_file_manager'), 'center'); redirect("view.php?id={$id}&groupid={$groupid}&rootdir={$rootdir}"); } /// Used to provide details on deleting confirmation message $list->type = get_string($from, 'block_file_manager') . get_string('plural', 'block_file_manager'); $list->thelist = array(); $list->inusemsg = NULL; switch ($from) { case 'category': $catusedfile = 0; $tmpcount = 0; // Ensures user owns category(s) foreach ($cb as $c) { $tmplist = ''; if ($c != 0) { if ($groupid == 0 && !fm_user_owns_cat($c) || $groupid != 0 && !fm_group_owns_cat($c, $groupid)) { die; // backup... } if (!isset($_POST['yesdel']) && !isset($_POST['nodel'])) { $tmpcount = $catusedfile; $tmpcount += count_records('fmanager_link', 'category', $c); $tmpcount += count_records('fmanager_folders', 'category', $c); if ($tmpcount > $catusedfile) { $tmplist .= '* '; } $catusedfile += $tmpcount; $tmprec = get_record('fmanager_categories', 'id', $c); $tmplist .= $tmprec->name; $list->thelist[] = $tmplist; $catshared = count_records('fmanager_shared', 'sharedlink', $c, 'type', STYPE_CAT);
} } 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) { fm_user_owns_cat($c); } else { fm_group_owns_cat($c, $groupid); } } } elseif ($from == 'folder') { // $from is folder only when sharing 1 folder $type = 2; } if (isset($_POST['share'])) { if ($course->id != 1) { $sql = "\r\n\t\t\t SELECT \r\n\t\t\t u.firstname \r\n\t\t\t FROM \r\n\t\t\t {$CFG->prefix}user u, \r\n\t\t\t {$CFG->prefix}course_display cd \r\n\t\t\t WHERE \r\n\t\t\t course = {$id} AND \r\n\t\t\t cd.userid = u.id\r\n\t\t\t"; $count = count_records_sql($sql); } else { $count = count_records('user', 'idnumber', ''); } // Deletes all existing records for the file in the course foreach ($cb as $c) {