]> git.mjollnir.org Git - moodle.git/commitdiff
Changed to use clean_filename() function when calculating
authorstronk7 <stronk7>
Mon, 29 Dec 2003 20:15:56 +0000 (20:15 +0000)
committerstronk7 <stronk7>
Mon, 29 Dec 2003 20:15:56 +0000 (20:15 +0000)
backup file name. Thanks Martin !! :-)

backup/backup_check.html

index 472df23de44ffadc0594e57d66b35346ff6077fe..956f7c6662cd41f17af0f2471c4ece6dbe663540 100644 (file)
     echo get_string("name").":";
     echo "</B></td><td>";
     //Calculate the backup string
+
+    //Calculate the backup word
     //Take off some characters in the filename !!
     $takeoff = array(" ", ":", "/", "\\", "|");
-    $backup_name = str_replace($takeoff,"_",strtolower(get_string("backupfilename")));
+    $backup_word = str_replace($takeoff,"_",strtolower(get_string("backupfilename")));
     //If non-translated, use "backup"
-    if (substr($backup_name,0,1) == "[") {
-        $backup_name = "backup";
+    if (substr($backup_word,0,1) == "[") {
+        $backup_word= "backup";
     }
-    //Calculate the format string
-    $backup_name_format = str_replace(" ","_",get_string("backupnameformat"));
+
+    //Calculate the date format string
+    $backup_date_format = str_replace(" ","_",get_string("backupnameformat"));
     //If non-translated, use "%Y%m%d-%H%M"
-    if (substr($backup_name_format,0,1) == "[") {
-        $backup_name_format = "%%Y%%m%%d-%%H%%M";
+    if (substr($backup_date_format,0,1) == "[") {
+        $backup_date_format = "%%Y%%m%%d-%%H%%M";
+    }
+
+    //Calculate the shortname
+    $backup_shortname = clean_filename($course->shortname);
+    if (empty($backup_shortname) or $backup_shortname == '_' ) {
+        $backup_shortname = $course->id;
     }
-    $backup_name .= str_replace($takeoff,"_","-".strtolower($course->shortname)."-".userdate(time(),$backup_name_format,99,false).".zip");
+
+    //Calculate the final backup filename
+    //The backup word
+    $backup_name = $backup_word."-";
+    //The shortname
+    $backup_name .= strtolower($backup_shortname)."-";
+    //The date format
+    $backup_name .= userdate(time(),$backup_date_format,99,false);
+    //The extension
+    $backup_name .= ".zip";
+
     //Add as text field
     echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backup_name."\">";
     echo "</td></tr>";