Index: file.php =================================================================== RCS file: /cvsroot/moodle/moodle/file.php,v retrieving revision 1.46.2.3 diff -u -F ^f -r1.46.2.3 file.php --- file.php 5 Jul 2008 14:17:29 -0000 1.46.2.3 +++ file.php 7 Jul 2008 09:21:57 -0000 @@ -1,5 +1,9 @@ libdir.'/filelib.php'); /// MDL-14072: Prevent NULLs, empties and numbers to be processed by the /// heavy interlinking. Just a few cpu cycles saved. @@ -3685,17 +3686,7 @@ //Now decode wwwroot and file.php calls $search = array ("$@FILEPHP@$"); - - //Check for the status of the slasharguments config variable - $slash = $CFG->slasharguments; - - //Build the replace string as needed - if ($slash == 1) { - $replace = array ($CFG->wwwroot."/file.php/".$restore->course_id); - } else { - $replace = array ($CFG->wwwroot."/file.php?file=/".$restore->course_id); - } - + $replace = array(get_file_url($restore->course_id)); $result = str_replace($search,$replace,$content); if ($result != $content && debugging()) { //Debug Index: blog/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/blog/lib.php,v retrieving revision 1.80.2.15 diff -u -F ^f -r1.80.2.15 lib.php --- blog/lib.php 7 Jul 2008 03:19:09 -0000 1.80.2.15 +++ blog/lib.php 7 Jul 2008 09:22:11 -0000 @@ -306,11 +314,7 @@ include_once($CFG->libdir.'/filelib.php'); $icon = mimeinfo("icon", $file); $type = mimeinfo("type", $file); - if ($CFG->slasharguments) { - $ffurl = "$CFG->wwwroot/file.php/$filearea/$file"; - } else { - $ffurl = "$CFG->wwwroot/file.php?file=/$filearea/$file"; - } + $ffurl = get_file_url("$filearea/$file"); $image = "pixpath/f/$icon\" class=\"icon\" alt=\"\" />"; if ($return == "html") { Index: blog/rsslib.php =================================================================== RCS file: /cvsroot/moodle/moodle/blog/rsslib.php,v retrieving revision 1.12 diff -u -F ^f -r1.12 rsslib.php --- blog/rsslib.php 31 Aug 2007 05:46:34 -0000 1.12 +++ blog/rsslib.php 7 Jul 2008 09:22:11 -0000 @@ -38,11 +38,8 @@ $path .= '/rss.xml'; $rsspix = $CFG->pixpath .'/i/rss.gif'; - if ($CFG->slasharguments) { - $path = $CFG->wwwroot.'/rss/file.php/'.$path; - } else { - $path = $CFG->wwwroot.'/rss/file.php?file='.$path; - } + require_once($CFG->libdir.'/filelib.php'); + $path = get_file_url($path, null, 'rssfile'); print '
'.get_string('rss').'
'; } Index: files/index.php =================================================================== RCS file: /cvsroot/moodle/moodle/files/index.php,v retrieving revision 1.121.2.5 diff -u -F ^f -r1.121.2.5 index.php --- files/index.php 14 May 2008 16:42:31 -0000 1.121.2.5 +++ files/index.php 7 Jul 2008 09:22:13 -0000 @@ -812,11 +812,8 @@ function displaydir ($wdir) { print_cell("center", "", 'checkbox'); echo ""; - if ($CFG->slasharguments) { - $ffurl = str_replace('//', '/', "/file.php/$id/$fileurl"); - } else { - $ffurl = str_replace('//', '/', "/file.php?file=/$id/$fileurl"); - } + + $ffurl = str_replace('//', '/', get_file_url("$id/$fileurl")); link_to_popup_window ($ffurl, "display", "pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" /> ".htmlspecialchars($file), 480, 640); Index: lib/filelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/filelib.php,v retrieving revision 1.50.2.17 diff -u -F ^f -r1.50.2.17 filelib.php --- lib/filelib.php 5 Jul 2008 15:34:28 -0000 1.50.2.17 +++ lib/filelib.php 7 Jul 2008 09:22:21 -0000 @@ -9,20 +9,32 @@ function get_file_url($path, $options=nu // type of file switch ($type) { + case 'httpscoursefile': + $url = $CFG->httpswwwroot."/file.php"; + break; + case 'rssfile': + $url = $CFG->wwwroot."/rss/file.php"; + break; + case 'user': + $url = $CFG->wwwroot."/user/pix.php"; + break; + case 'usergroup': + $url = $CFG->wwwroot."/user/pixgroup.php"; + break; case 'coursefile': default: - $url = "$CFG->wwwroot/file.php"; + $url = $CFG->wwwroot."/file.php"; } if ($CFG->slasharguments) { $parts = explode('/', $path); $parts = array_map('rawurlencode', $parts); $path = implode('/', $parts); - $ffurl = "$CFG->wwwroot/file.php/$path"; + $ffurl = $url.'/'.$path; $separator = '?'; } else { - $path = rawurlencode("/$path"); - $ffurl = "$CFG->wwwroot/file.php?file=$path"; + $path = rawurlencode('/'.$path); + $ffurl = $url.'?file='.$path; $separator = '&'; } Index: lib/questionlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/questionlib.php,v retrieving revision 1.119.2.12 diff -u -F ^f -r1.119.2.12 questionlib.php --- lib/questionlib.php 2 Jul 2008 09:14:56 -0000 1.119.2.12 +++ lib/questionlib.php 7 Jul 2008 09:22:26 -0000 @@ -1503,12 +1503,10 @@ function get_question_image($question) { if (substr(strtolower($question->image), 0, 7) == 'http://') { $img .= $question->image; - } else if ($CFG->slasharguments) { // Use this method if possible for better caching - $img .= "$CFG->wwwroot/file.php/$coursefilesdir/$question->image"; - } else { - $img .= "$CFG->wwwroot/file.php?file=/$coursefilesdir/$question->image"; - } + require_once($CFG->libdir .'/filelib.php'); + $img = get_file_url("$courseid/{$question->image}"); + } } return $img; } @@ -2290,12 +2288,8 @@ function question_url_check($url){ */ function question_replace_file_links_in_html($html, $fromcourseid, $tocourseid, $url, $destination, &$changed){ global $CFG; - if ($CFG->slasharguments) { // Use this method if possible for better caching - $tourl = "$CFG->wwwroot/file.php/$tocourseid/$destination"; - - } else { - $tourl = "$CFG->wwwroot/file.php?file=/$tocourseid/$destination"; - } + require_once($CFG->libdir .'/filelib.php'); + $tourl = get_file_url("$tocourseid/$destination"); $fromurl = question_file_links_base_url($fromcourseid).preg_quote($url, '!'); $searchfor = array('!(<\s*(a|img)\s[^>]*(href|src)\s*=\s*")'.$fromurl.'(")!i', '!(<\s*(a|img)\s[^>]*(href|src)\s*=\s*\')'.$fromurl.'(\')!i'); Index: lib/rsslib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/rsslib.php,v retrieving revision 1.52.2.2 diff -u -F ^f -r1.52.2.2 rsslib.php --- lib/rsslib.php 31 Dec 2007 15:36:48 -0000 1.52.2.2 +++ lib/rsslib.php 7 Jul 2008 09:22:27 -0000 @@ -25,12 +25,8 @@ function rss_get_link($courseid, $userid //This function returns the URL for the RSS XML file. function rss_get_url($courseid, $userid, $modulename, $id) { global $CFG; - if ($CFG->slasharguments) { - $rsspath = "$CFG->wwwroot/rss/file.php/$courseid/$userid/$modulename/$id/rss.xml"; - } else { - $rsspath = "$CFG->wwwroot/rss/file.php?file=/$courseid/$userid/$modulename/$id/rss.xml"; - } - return $rsspath; + require_once($CFG->libdir.'/filelib.php'); + return get_file_url($courseid.'/'.$userid.'/'.$modulename.'/'.$id.'/rss.xml', null, 'rssfile'); } //This function prints the icon (from theme) with the link to rss/file.php Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.970.2.95 diff -u -F ^f -r1.970.2.95 weblib.php --- lib/weblib.php 2 Jul 2008 06:38:09 -0000 1.970.2.95 +++ lib/weblib.php 7 Jul 2008 09:22:42 -0000 @@ -4294,11 +4294,8 @@ function print_file_picture($path, $cour } else if ($courseid) { $output .= 'slasharguments) { // Use this method if possible for better caching - $src = $wwwroot .'/user/pix.php/'. $user->id .'/'. $file .'.jpg'; - } else { - $src = $wwwroot .'/user/pix.php?file=/'. $user->id .'/'. $file .'.jpg'; - } + require_once($CFG->libdir.'/filelib.php'); + $src = get_file_url($user->id.'/'.$file.'.jpg', null, 'user'); } else { // Print default user pictures (use theme version if available) $class .= " defaultuserpic"; $src = "$CFG->pixpath/u/$file.png"; @@ -4604,13 +4598,10 @@ function print_group_picture($group, $co $size = 35; } if ($group->picture) { // Print custom group picture - if ($CFG->slasharguments) { // Use this method if possible for better caching - $output .= ''.s(get_string('group').' '.$group->name).''; - } else { - $output .= ''.s(get_string('group').' '.$group->name).''; - } + require_once($CFG->libdir.'/filelib.php'); + $grouppictureurl = get_file_url($group->id.'/'.$file.'.jpg', null, 'usergroup'); + $output .= ''.s(get_string('group').' '.$group->name).''; } if ($link or has_capability('moodle/site:accessallgroups', $context)) { $output .= ''; Index: lib/wiki_to_markdown.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/wiki_to_markdown.php,v retrieving revision 1.11 diff -u -F ^f -r1.11 wiki_to_markdown.php --- lib/wiki_to_markdown.php 7 Mar 2006 20:26:27 -0000 1.11 +++ lib/wiki_to_markdown.php 7 Jul 2008 09:22:42 -0000 @@ -264,24 +264,16 @@ $line = eregi_replace( " ([a-zA-Z]+):([0-9]+)\(([^)]+)\)", " [\\3](".$CFG->wwwroot."/mod/\\1/view.php?id=\\2) ", $line ); + require_once($CFG->libdir.'/filelib.php'); + $coursefileurl = get_file_url($this->courseid); + // Replace picture resource link - if ($CFG->slasharguments) { - $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)", - "![\\3]($CFG->wwwroot/file.php/$this->courseid/\\1\\2)", $line ); - } else { - $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)", - "![\\3]($CFG->wwwroot/file.php?file=/$this->courseid/\\1\\2)", $line ); - } + $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)", + "![\\3](".$coursefileurl."/\\1\\2)", $line ); // Replace file resource link - if ($CFG->slasharguments) { - $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)", - "[\\2]($CFG->wwwroot/file.php/$this->courseid/\\1)", $line ); - } else { - $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)", - "[\\2]($CFG->wwwroot/file.php?file=/$this->courseid/\\1)", $line ); - } - + $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)", + "[\\2](".$coursefileurl."/\\1)", $line ); return $line; } Index: lib/editor/htmlarea/coursefiles.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/editor/htmlarea/coursefiles.php,v retrieving revision 1.13.8.1 diff -u -F ^f -r1.13.8.1 coursefiles.php --- lib/editor/htmlarea/coursefiles.php 2 Apr 2008 06:10:01 -0000 1.13.8.1 +++ lib/editor/htmlarea/coursefiles.php 7 Jul 2008 09:22:45 -0000 @@ -755,17 +755,13 @@ function displaydir ($wdir) { print_cell("center", ""); } echo ""; - if ($CFG->slasharguments) { - $ffurl = "/file.php/$id$fileurl"; - } else { - $ffurl = "/file.php?file=/$id$fileurl"; - } + $ffurl = get_file_url($id$fileurl); link_to_popup_window ($ffurl, "display", "pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" />", 480, 640); $file_size = filesize($filename); - echo "wwwroot.$ffurl."',"; + echo "$file"; echo "\n"; Index: mod/data/preset_class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/preset_class.php,v retrieving revision 1.2.2.3 diff -u -F ^f -r1.2.2.3 preset_class.php --- mod/data/preset_class.php 13 Apr 2008 22:57:09 -0000 1.2.2.3 +++ mod/data/preset_class.php 7 Jul 2008 09:22:50 -0000 @@ -712,7 +712,8 @@ print_error('movezipfailed', 'data'); } - $html .= ''.get_string('download', 'data').""; + require_once($CFG->libdir.'/filelib.php'); + $html .= ''. get_string('download', 'data') .''; $html .= ''; return $html; } Index: mod/data/field/file/field.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/field/file/field.class.php,v retrieving revision 1.17.2.4 diff -u -F ^f -r1.17.2.4 field.class.php --- mod/data/field/file/field.class.php 30 May 2008 01:34:41 -0000 1.17.2.4 +++ mod/data/field/file/field.class.php 7 Jul 2008 09:22:51 -0000 @@ -42,12 +42,8 @@ $src = empty($contents[0]) ? '' : $contents[0]; $name = empty($contents[1]) ? $src : $contents[1]; $displayname = empty($contents[1]) ? '' : $contents[1]; - $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid; - if ($CFG->slasharguments) { - $source = $CFG->wwwroot.'/file.php/'.$path; - } else { - $source = $CFG->wwwroot.'/file.php?file=/'.$path; - } + require_once($CFG->libdir.'/filelib.php'); + $source = get_file_url($this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid); } else { $src = ''; $name = ''; Index: mod/data/field/picture/field.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/field/picture/field.class.php,v retrieving revision 1.24.2.1 diff -u -F ^f -r1.24.2.1 field.class.php --- mod/data/field/picture/field.class.php 30 May 2008 01:34:41 -0000 1.24.2.1 +++ mod/data/field/picture/field.class.php 7 Jul 2008 09:22:51 -0000 @@ -45,11 +45,8 @@ $description = $content->content1; } $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid; - if ($CFG->slasharguments) { - $filepath = $CFG->wwwroot.'/file.php/'.$path.'/'.$filename; - } else { - $filepath = $CFG->wwwroot.'/file.php?file=/'.$path.'/'.$filename; - } + require_once($CFG->libdir.'/filelib.php'); + $filepath = get_file_url("$path/$filename"); } $str = '
'; $str .= '
'.$this->field->name.''; @@ -93,14 +90,11 @@ $title = empty($contents[1])? '':$contents[1]; $src = $contents[0]; $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid; - $thumbnaillocation = $CFG->dataroot .'/'.$this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid.'/thumb/'.$src; - if ($CFG->slasharguments) { - $source = $CFG->wwwroot.'/file.php/'.$path.'/'.$src; - $thumbnailsource = file_exists($thumbnaillocation) ? $CFG->wwwroot.'/file.php/'.$path.'/thumb/'.$src : $source; - } else { - $source = $CFG->wwwroot.'/file.php?file=/'.$path.'/'.$src; - $thumbnailsource = file_exists($thumbnaillocation) ? $CFG->wwwroot.'/file.php?file=/'.$path.'/thumb/'.$src : $source; - } + + $thumbnaillocation = $CFG->dataroot .'/'. $path .'/thumb/'.$src; + require_once($CFG->libdir.'/filelib.php'); + $source = get_file_url("$path/$src"); + $thumbnailsource = file_exists($thumbnaillocation) ? get_file_url("$path/thumb/$src") : $source; if ($template == 'listtemplate') { $width = $this->field->param4 ? ' width="'.s($this->field->param4).'" ' : ' '; Index: mod/exercise/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/exercise/Attic/lib.php,v retrieving revision 1.48.2.2 diff -u -F ^f -r1.48.2.2 lib.php --- mod/exercise/lib.php 8 Mar 2008 12:57:23 -0000 1.48.2.2 +++ mod/exercise/lib.php 7 Jul 2008 09:22:52 -0000 @@ -730,13 +730,10 @@ function exercise_print_submission_title if ($basedir = exercise_file_area($exercise, $submission)) { if (list($file) = get_directory_list($basedir)) { $icon = mimeinfo("icon", $file); - if ($CFG->slasharguments) { - $ffurl = "file.php/$filearea/$file"; - } else { - $ffurl = "file.php?file=/$filearea/$file"; - } + require_once($CFG->libdir .'/filelib.php'); + $ffurl = get_file_url("$filearea/$file"); return "pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" />". - " wwwroot/$ffurl\">$submission->title"; + " $submission->title"; } } } Index: mod/forum/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/lib.php,v retrieving revision 1.609.2.61 diff -u -F ^f -r1.609.2.61 lib.php --- mod/forum/lib.php 2 Jul 2008 21:58:36 -0000 1.609.2.61 +++ mod/forum/lib.php 7 Jul 2008 09:22:58 -0000 @@ -3636,11 +3636,7 @@ function forum_print_attachments($post, foreach ($files as $file) { $icon = mimeinfo("icon", $file); $type = mimeinfo("type", $file); - if ($CFG->slasharguments) { - $ffurl = "$CFG->wwwroot/file.php/$filearea/$file"; - } else { - $ffurl = "$CFG->wwwroot/file.php?file=/$filearea/$file"; - } + $ffurl = get_file_url("$filearea/$file"); $image = "pixpath/f/$icon\" class=\"icon\" alt=\"\" />"; if ($return == "html") { Index: mod/forum/rsslib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/rsslib.php,v retrieving revision 1.25 diff -u -F ^f -r1.25 rsslib.php --- mod/forum/rsslib.php 22 Aug 2007 07:38:38 -0000 1.25 +++ mod/forum/rsslib.php 7 Jul 2008 09:22:58 -0000 @@ -236,6 +236,8 @@ $formatoptions = new object; $formatoptions->trusttext = true; + require_once($CFG->libdir.'/filelib.php'); + foreach ($recs as $rec) { unset($item); unset($user); @@ -256,11 +258,7 @@ $item->attachments = array(); foreach ($post_files as $file) { $attachment = new stdClass; - if ($CFG->slasharguments) { - $attachment->url = "{$CFG->wwwroot}/file.php/$post_file_area_name/$file"; - } else { - $attachment->url = "{$CFG->wwwroot}/file.php?file=/$post_file_area_name/$file"; - } + $attachment->url = get_file_url("$post_file_area_name/$file"); $attachment->length = filesize("$CFG->dataroot/$post_file_area_name/$file"); $item->attachments[] = $attachment; } Index: mod/glossary/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/lib.php,v retrieving revision 1.193.2.13 diff -u -F ^f -r1.193.2.13 lib.php --- mod/glossary/lib.php 5 May 2008 00:08:32 -0000 1.193.2.13 +++ mod/glossary/lib.php 7 Jul 2008 09:23:01 -0000 @@ -1252,11 +1252,7 @@ function glossary_print_attachments($ent $strattachment = get_string("attachment", "glossary"); foreach ($files as $file) { $icon = mimeinfo("icon", $file); - if ($CFG->slasharguments) { - $ffurl = "$CFG->wwwroot/file.php/$filearea/$file"; - } else { - $ffurl = "$CFG->wwwroot/file.php?file=/$filearea/$file"; - } + $ffurl = get_file_url("$filearea/$file"); $image = "pixpath/f/$icon\" class=\"icon\" alt=\"\" />"; if ($return == "html") { Index: mod/hotpot/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/hotpot/lib.php,v retrieving revision 1.79.2.12 diff -u -F ^f -r1.79.2.12 lib.php --- mod/hotpot/lib.php 7 Jun 2008 01:42:32 -0000 1.79.2.12 +++ mod/hotpot/lib.php 7 Jul 2008 09:23:04 -0000 @@ -1798,11 +1798,8 @@ function hotpot_string($id) { // set the url base (first time only) if (!isset($this->baseurl)) { global $CFG; - if ($CFG->slasharguments) { - $this->baseurl = "$CFG->wwwroot/file.php/$this->filedir/"; - } else { - $this->baseurl = "$CFG->wwwroot/file.php?file=/$this->filedir/"; - } + require_once($CFG->libdir.'/filelib.php'); + $this->baseurl = get_file_url($this->filedir .'/'); } return $this->baseurl; } Index: mod/lesson/importppt.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/importppt.php,v retrieving revision 1.22.2.1 diff -u -F ^f -r1.22.2.1 importppt.php --- mod/lesson/importppt.php 12 Oct 2007 16:09:42 -0000 1.22.2.1 +++ mod/lesson/importppt.php 7 Jul 2008 09:23:04 -0000 @@ -195,11 +195,8 @@ function extract_data($pages, $courseid, $imagedir = $CFG->dataroot.'/'.$courseid.'/moddata/'.$modname; - if ($CFG->slasharguments) { - $imagelink = $CFG->wwwroot.'/file.php/'.$courseid.'/moddata/'.$modname; - } else { - $imagelink = $CFG->wwwroot.'/file.php?file=/'.$courseid.'/moddata/'.$modname; - } + require_once($CFG->libdir .'/filelib.php'); + $imagelink = get_file_url($courseid.'/moddata/'.$modname); // try to make a unique subfolder to store the images $lessonname = str_replace(' ', '_', $lessonname); // get rid of spaces Index: mod/lesson/mediafile.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/lesson/mediafile.php,v retrieving revision 1.13 diff -u -F ^f -r1.13 mediafile.php --- mod/lesson/mediafile.php 24 Jul 2007 07:04:33 -0000 1.13 +++ mod/lesson/mediafile.php 7 Jul 2008 09:23:04 -0000 @@ -57,13 +57,7 @@ if (is_url($lesson->mediafile)) { $fullurl = $lesson->mediafile; } else { - // get the full url to the file while taking into consideration $CFG->slasharguments - if ($CFG->slasharguments) { - $relativeurl = "/file.php/{$course->id}/{$lesson->mediafile}"; - } else { - $relativeurl = "/file.php?file=/{$course->id}/{$lesson->mediafile}"; - } - $fullurl = "$CFG->wwwroot$relativeurl"; + $fullurl = get_file_url($course->id .'/'. $lesson->mediafile); } // find the correct type and print it out @@ -213,4 +207,4 @@ } print_footer(); -?> \ No newline at end of file +?> Index: mod/resource/type/file/resource.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/resource/type/file/resource.class.php,v retrieving revision 1.71.2.11 diff -u -F ^f -r1.71.2.11 resource.class.php --- mod/resource/type/file/resource.class.php 16 May 2008 07:10:36 -0000 1.71.2.11 +++ mod/resource/type/file/resource.class.php 7 Jul 2008 09:23:06 -0000 @@ -264,8 +264,8 @@ $isteamspeak = (stripos($resource->reference, 'teamspeak://') === 0); /// Form the parse string + $querys = array(); if (!empty($resource->alltext)) { - $querys = array(); $parray = explode(',', $resource->alltext); foreach ($parray as $fieldstring) { $field = explode('=', $fieldstring); @@ -309,22 +309,10 @@ } else { // Normal uploaded file $forcedownloadsep = '?'; - if ($CFG->slasharguments) { - $relativeurl = "/file.php/{$course->id}/{$resource->reference}"; - if ($querystring) { - $relativeurl .= '?'.$querystring; - $forcedownloadsep = '&'; - } - } else { - $relativeurl = "/file.php?file=/{$course->id}/{$resource->reference}"; - if ($querystring) { - $relativeurl .= '&'.$querystring; - } - } - $fullurl = "$CFG->wwwroot$relativeurl"; if ($resource->options == 'forcedownload') { - $fullurl .= $forcedownloadsep . 'forcedownload=1'; + $querys[] = 'forcedownload=1'; } + $fullurl = get_file_url($course->id.'/'.$resource->reference, $querys); } /// Print a notice and redirect if we are trying to access a file on a local file system Index: mod/resource/type/ims/resource.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/resource/type/ims/resource.class.php,v retrieving revision 1.47.2.4 diff -u -F ^f -r1.47.2.4 resource.class.php --- mod/resource/type/ims/resource.class.php 14 Dec 2007 21:21:07 -0000 1.47.2.4 +++ mod/resource/type/ims/resource.class.php 7 Jul 2008 09:23:06 -0000 @@ -508,11 +508,8 @@ /// Calculate the file.php correct url if (!$this->isrepository) { - if ($CFG->slasharguments) { - $fileurl = "{$CFG->wwwroot}/file.php/{$course->id}/{$CFG->moddata}/resource/{$resource->id}"; - } else { - $fileurl = "{$CFG->wwwroot}/file.php?file=/{$course->id}/{$CFG->moddata}/resource/{$resource->id}"; - } + require_once($CFG->libdir.'/filelib.php'); + $fileurl = get_file_url($course->id.'/'.$CFG->moddata.'/resource/'.$resource->id); } else { $fileurl = $CFG->repositorywebroot . $resource->reference; Index: mod/scorm/loadSCO.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/scorm/loadSCO.php,v retrieving revision 1.33 diff -u -F ^f -r1.33 loadSCO.php --- mod/scorm/loadSCO.php 25 Jan 2007 13:49:50 -0000 1.33 +++ mod/scorm/loadSCO.php 7 Jul 2008 09:23:07 -0000 @@ -108,11 +108,8 @@ } else { $basedir = $CFG->moddata.'/scorm/'.$scorm->id; } - if ($CFG->slasharguments) { - $result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/'.$basedir.'/'.$launcher; - } else { - $result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/'.$basedir.'/'.$launcher; - } + require_once($CFG->libdir.'/filelib.php'); + $result = get_file_url($scorm->course .'/'. $basedir .'/'. $launcher); } } ?> Index: mod/workshop/locallib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/workshop/Attic/locallib.php,v retrieving revision 1.43.2.1 diff -u -F ^f -r1.43.2.1 locallib.php --- mod/workshop/locallib.php 6 Mar 2008 09:41:24 -0000 1.43.2.1 +++ mod/workshop/locallib.php 7 Jul 2008 09:23:12 -0000 @@ -2858,18 +2858,15 @@ function workshop_print_submission($work $filearea = workshop_file_area_name($workshop, $submission); if ($basedir = workshop_file_area($workshop, $submission)) { if ($files = get_directory_list($basedir)) { + require_once($CFG->libdir .'/filelib.php'); foreach ($files as $file) { $icon = mimeinfo("icon", $file); - if ($CFG->slasharguments) { - $ffurl = "file.php/$filearea/$file"; - } else { - $ffurl = "file.php?file=/$filearea/$file"; - } + $ffurl = get_file_url("$filearea/$file"); echo "".get_string("attachment", "workshop")." $n: \n"; // removed target=\"uploadedfile\" as it does not validate // MDL-7861 echo "pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" />". - " wwwroot/$ffurl\">$file"; + " $file"; $n++; } } Index: mod/workshop/submissions.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/workshop/Attic/submissions.php,v retrieving revision 1.60.2.2 diff -u -F ^f -r1.60.2.2 submissions.php --- mod/workshop/submissions.php 2 Apr 2008 06:10:05 -0000 1.60.2.2 +++ mod/workshop/submissions.php 7 Jul 2008 09:23:12 -0000 @@ -264,18 +264,15 @@ "workshop")."\" onclick=\"getElementById('editform').action.value='removeattachments'; getElementById('editform').submit();\"/>
\n"; $n = 1; + require_once($CFG->libdir .'/filelib.php'); foreach ($files as $file) { $icon = mimeinfo("icon", $file); - if ($CFG->slasharguments) { - $ffurl = "file.php/$filearea/$file"; - } else { - $ffurl = "file.php?file=/$filearea/$file"; - } + $ffurl = get_file_url("$filearea/$file"); // removed target=\"uploadedfile\" // as it does not validate MDL_7861 echo "".get_string("attachment", "workshop")." $n: pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" />". - " wwwroot/$ffurl\">$file\n"; + " $file\n"; } } else { echo "".get_string("noattachments", "workshop")."\n"; Index: question/export.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/export.php,v retrieving revision 1.43.2.1 diff -u -F ^f -r1.43.2.1 export.php --- question/export.php 2 Nov 2007 16:20:19 -0000 1.43.2.1 +++ question/export.php 7 Jul 2008 09:23:13 -0000 @@ -118,12 +118,8 @@ // link to download the finished file $file_ext = $qformat->export_file_extension(); - if ($CFG->slasharguments) { - $efile = "{$CFG->wwwroot}/file.php/".$qformat->question_get_export_dir()."/$from_form->exportfilename".$file_ext."?forcedownload=1"; - } - else { - $efile = "{$CFG->wwwroot}/file.php?file=/".$qformat->question_get_export_dir()."/$from_form->exportfilename".$file_ext."&forcedownload=1"; - } + require_once($CFG->libdir.'/filelib.php'); + $efile = get_file_url($qformat->question_get_export_dir() .'/'. $from_form->exportfilename.$file_ext, array('forcedownload'=>1)); echo "

$txt->download

"; echo "

$txt->downloadextra

"; Index: question/format/hotpot/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/hotpot/format.php,v retrieving revision 1.12.4.4 diff -u -F ^f -r1.12.4.4 format.php --- question/format/hotpot/format.php 5 Feb 2008 04:09:58 -0000 1.12.4.4 +++ question/format/hotpot/format.php 7 Jul 2008 09:23:14 -0000 @@ -43,11 +43,8 @@ // shouldn't happen !! $courseid = 0; } - if ($CFG->slasharguments) { - $baseurl = "$CFG->wwwroot/file.php/$courseid/"; - } else { - $baseurl = "$CFG->wwwroot/file.php?file=/$courseid/"; - } + require_once($CFG->libdir.'/filelib.php'); + $baseurl = get_file_url($courseid).'/'; // get import file name global $params; Index: question/format/qti2/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/qti2/format.php,v retrieving revision 1.12.4.1 diff -u -F ^f -r1.12.4.1 format.php --- question/format/qti2/format.php 2 Nov 2007 16:20:35 -0000 1.12.4.1 +++ question/format/qti2/format.php 7 Jul 2008 09:23:16 -0000 @@ -405,6 +405,7 @@ function handle_questions_media(&$questi function quiz_export_prepare_questions($questions, $quizid, $courseid, $shuffleanswers = null) { global $CFG; // add the answers to the questions and format the image property + require_once($CFG->libdir.'/filelib.php'); foreach ($questions as $key=>$question) { $questions[$key] = get_question_data($question); $questions[$key]->courseid = $courseid; @@ -420,11 +421,7 @@ function handle_questions_media(&$questi if ($localfile) { // create the http url that the player will need to access the file - if ($CFG->slasharguments) { // Use this method if possible for better caching - $questions[$key]->mediaurl = "$CFG->wwwroot/file.php/$question->image"; - } else { - $questions[$key]->mediaurl = "$CFG->wwwroot/file.php?file=$question->image"; - } + $questions[$key]->mediaurl = get_file_url($question->image); } else { $questions[$key]->mediaurl = $question->image; } @@ -908,10 +905,9 @@ function xml_entitize(&$collection) { global $CFG; if (substr(strtolower($file), 0, 7) == 'http://') { $url = $file; - } else if ($CFG->slasharguments) { // Use this method if possible for better caching - $url = "{$CFG->wwwroot}/file.php/$courseid/{$file}"; } else { - $url = "{$CFG->wwwroot}/file.php?file=/$courseid/{$file}"; + require_once($CFG->libdir.'/filelib.php'); + $url = get_file_url("$courseid/$file"); } return $url; } Index: question/format/qti2/qt_common.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/qti2/qt_common.php,v retrieving revision 1.4 diff -u -F ^f -r1.4 qt_common.php --- question/format/qti2/qt_common.php 15 Jun 2007 10:24:29 -0000 1.4 +++ question/format/qti2/qt_common.php 7 Jul 2008 09:23:16 -0000 @@ -102,10 +102,9 @@ function get_media_tag($file, $courseid // if it's a moodle library file, it will be served through file.php if (substr(strtolower($file), 0, 7) == 'http://') { $media = $file; - } else if ($CFG->slasharguments) { // Use this method if possible for better caching - $media = "{$CFG->wwwroot}/file.php/$courseid/$file"; } else { - $media = "{$CFG->wwwroot}/file.php?file=/$courseid/$file"; + require_once($CFG->libdir.'/filelib.php'); + $media = get_file_url("$courseid/$file"); } $ismultimedia = false; Index: theme/standardlogo/header.html =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standardlogo/header.html,v retrieving revision 1.26.2.1 diff -u -F ^f -r1.26.2.1 header.html --- theme/standardlogo/header.html 23 Nov 2007 16:41:16 -0000 1.26.2.1 +++ theme/standardlogo/header.html 7 Jul 2008 09:23:20 -0000 @@ -23,17 +23,11 @@ } else if (file_exists($CFG->dirroot.'/logo.gif')) { $standardlogo = $CFG->httpswwwroot.'/logo.gif'; } else if (file_exists($CFG->dataroot.'/1/logo.jpg')) { - if (empty($CFG->slasharguments)) { - $standardlogo = $CFG->httpswwwroot.'/file.php?file=/1/logo.jpg'; - } else { - $standardlogo = $CFG->httpswwwroot.'/file.php/1/logo.jpg'; - } + require_once($CFG->libdir.'/filelib.php'); + $standardlogo = get_file_url('1/logo.jpg', null, 'httpscoursefile'); } else if (file_exists($CFG->dataroot.'/1/logo.gif')) { - if (empty($CFG->slasharguments)) { - $standardlogo = $CFG->httpswwwroot.'/file.php?file=/1/logo.gif'; - } else { - $standardlogo = $CFG->httpswwwroot.'/file.php/1/logo.gif'; - } + require_once($CFG->libdir.'/filelib.php'); + $standardlogo = get_file_url('1/logo.gif', null, 'httpscoursefile'); } else { $standardlogo = $CFG->httpsthemewww .'/'. current_theme().'/logo.gif'; } Index: userpix/index.php =================================================================== RCS file: /cvsroot/moodle/moodle/userpix/index.php,v retrieving revision 1.9.2.2 diff -u -F ^f -r1.9.2.2 index.php --- userpix/index.php 22 Apr 2008 06:16:18 -0000 1.9.2.2 +++ userpix/index.php 7 Jul 2008 09:23:21 -0000 @@ -25,13 +25,10 @@ $fullname = fullname($user); echo "wwwroot/user/view.php?id=$user->id&course=1\" ". "title=\"$fullname\">"; - if ($CFG->slasharguments) { // Use this method if possible for better caching - echo ''.$fullname.''; - } else { - echo ''.$fullname.''; - } + require_once($CFG->libdir.'/filelib.php'); + $userpictureurl = get_file_url($user->id.'/f1.jpg', null, 'user'); + echo ''.$fullname.''; echo " \n"; } Index: userpix/upgrade.php =================================================================== RCS file: /cvsroot/moodle/moodle/userpix/upgrade.php,v retrieving revision 1.5.2.1 diff -u -F ^f -r1.5.2.1 upgrade.php --- userpix/upgrade.php 22 Apr 2008 06:16:18 -0000 1.5.2.1 +++ userpix/upgrade.php 7 Jul 2008 09:23:21 -0000 @@ -22,13 +22,10 @@ $fullname = fullname($user); echo "wwwroot/user/view.php?id=$user->id&course=1\"". "title=\"$fullname\">"; - if ($CFG->slasharguments) { // Use this method if possible for better caching - echo ''.$fullname.''; - } else { - echo ''.$fullname.''; - } + require_once($CFG->libdir.'/filelib.php'); + $userpictureurl = get_file_url($user->id.'/f1.jpg', null, 'user'); + echo ''.$fullname.''; echo " \n"; }